Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ You might also be interested in our [users](https://groups.google.com/forum/#!fo
Please [contact us](https://opencor.ws/libopencor/contactUs.html) if you have any questions about libOpenCOR.

[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opencor/libopencor)
![Alt](https://repobeats.axiom.co/api/embed/e57859796c7c35c163c88238f9bfd3f2aad9649f.svg "Repobeats analytics image")
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20260210.0
0.20260211.0
51 changes: 24 additions & 27 deletions newversion
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
#!/bin/sh

# Major version.
# Current version from `VERSION.txt`.

major_version=0
version_file=$(cd "$(dirname "$0")" && pwd)/VERSION.txt

# Minor version.
old_version=$(cat "$version_file")

old_major_version=$(echo $old_version | cut -d. -f1)
old_minor_version=$(echo $old_version | cut -d. -f2)
old_patch_version=$(echo $old_version | cut -d. -f3)

# Determine the new version based on the current version and the current date.

now=$(date +%Y%m%d)
minor_version=$now

# Patch version.

patch_version=0

if latest_tag_commit=$(git rev-list --tags --max-count=1 2> /dev/null); then
if git_describe=$(git describe --tags "$latest_tag_commit" 2> /dev/null); then
if echo "$git_describe" | grep -Eo '^v?[0-9]+\.[0-9]+\.[0-9]+' > /dev/null; then
minor=$(echo "$git_describe" | cut -d. -f2)
patch=$(echo "$git_describe" | cut -d. -f3)
patch_version=$patch

if [ "$minor" = "$minor_version" ]; then
patch_version=$((patch_version + 1))
else
patch_version=0
fi
fi
fi
fi

# Full version.
new_major_version=$old_major_version
new_minor_version=$now

version="$major_version.$minor_version.$patch_version"
if [ $old_minor_version -lt $now ]; then
new_patch_version=0
else
new_patch_version=$(($old_patch_version + 1))
fi

new_version="$new_major_version.$new_minor_version.$new_patch_version"

# Update our version file.

echo $version > $(cd $(dirname $0); pwd)/VERSION.txt
echo "$new_version" > "$version_file"

# Display the old and new versions.

printf '\033[1mOld version:\033[0m %s\n' "$old_version"
printf '\033[1mNew version:\033[0m %s\n' "$new_version"
59 changes: 24 additions & 35 deletions newversion.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,38 @@

SETLOCAL ENABLEDELAYEDEXPANSION

REM Major version.
REM Current version from `VERSION.txt`.

SET MajorVersion=0
SET VersionFile=%~dp0VERSION.txt

REM Minor version.
FOR /F "usebackq delims=" %%I IN ("%VersionFile%") DO SET OldVersion=%%I

FOR /F "tokens=2 delims==" %%I IN ('wmic os get localdatetime /value') DO SET Now=%%I
SET MinorVersion=!Now:~0,8!
ECHO "MinorVersion: !MinorVersion!"
FOR /F "tokens=1-3 delims=." %%A IN ("!OldVersion!") DO (
SET OldMajorVersion=%%A
SET OldMinorVersion=%%B
SET OldPatchVersion=%%C
)

REM Patch version.
REM Determine the new version based on the current version and the current date.

SET PatchVersion=0
FOR /F "tokens=2 delims==" %%I IN ('wmic os get localdatetime /value') DO SET Now=%%I

FOR /F %%I IN ('git rev-list --tags --max-count=1 2^> NUL') DO (
SET LatestTagCommit=%%I
)
ECHO "LatestTagCommit: !LatestTagCommit!"

IF DEFINED LatestTagCommit (
FOR /F %%I IN ('git describe --tags !LatestTagCommit! 2^> NUL') DO (
SET GitDescribe=%%I
)
ECHO "GitDescribe: !GitDescribe!"

FOR /F "tokens=2,3 delims=." %%A IN ("!GitDescribe!") DO (
SET MinorVersion=%%A
ECHO "MinorVersion: !MinorVersion!"
SET PatchVersion=%%B
ECHO "PatchVersion: !PatchVersion!"

IF "!MinorVersion!"=="!MinorVersion!" (
SET /A PatchVersion+=1
) ELSE (
SET PatchVersion=0
)
)
)
SET NewMajorVersion=!OldMajorVersion!
SET NewMinorVersion=!Now:~0,8!

REM Full version.
IF !OldMinorVersion! LSS !NewMinorVersion! (
SET NewPatchVersion=0
) ELSE (
SET /A NewPatchVersion=!OldPatchVersion! + 1
)

SET Version=!MajorVersion!.!MinorVersion!.!PatchVersion!
SET NewVersion=!NewMajorVersion!.!NewMinorVersion!.!NewPatchVersion!

REM Update our version file.

ECHO !Version! > "%~dp0VERSION.txt"
ECHO !NewVersion! > "%VersionFile%"

REM Display the old and new versions.

ECHO Old version: !OldVersion!
ECHO New version: !NewVersion!
10 changes: 7 additions & 3 deletions src/bindings/javascript/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ void fileApi()

return res;
}))
.function("setContents", emscripten::optional_override([](const libOpenCOR::FilePtr &pThis, uintptr_t pContents, size_t pSize) {
auto contents {reinterpret_cast<unsigned char *>(pContents)};
.function("setContents", emscripten::optional_override([](const libOpenCOR::FilePtr &pThis, emscripten::val pContents) {
if (pContents.isNull() || pContents.isUndefined()) {
pThis->setContents(libOpenCOR::UnsignedChars {});

pThis->setContents(libOpenCOR::UnsignedChars(contents, contents + pSize));
return;
}

pThis->setContents(emscripten::vecFromJSArray<unsigned char>(pContents));
}))
.property("hasChildFiles", &libOpenCOR::File::hasChildFiles)
.property("childFileCount", &libOpenCOR::File::childFileCount)
Expand Down
16 changes: 3 additions & 13 deletions tests/bindings/javascript/file.basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@ const expectedUnknownFileIssues = [
];

test.describe('File basic tests', () => {
let unknownContentsPtr;

test.before(() => {
unknownContentsPtr = utils.allocateMemory(loc, utils.UNKNOWN_CONTENTS);
});

test.beforeEach(() => {
loc.FileManager.instance().reset();
});

test.after(() => {
utils.freeMemory(loc, unknownContentsPtr);
});

test('Local file', () => {
const file = new loc.File(utils.LOCAL_FILE);

Expand All @@ -53,7 +43,7 @@ test.describe('File basic tests', () => {
assert.deepStrictEqual(file.contents(), utils.NO_CONTENTS);
assertIssues(loc, file, expectedNoIssues);

file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length);
file.setContents(utils.UNKNOWN_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value);
assert.deepStrictEqual(file.contents(), utils.UNKNOWN_CONTENTS);
Expand All @@ -70,7 +60,7 @@ test.describe('File basic tests', () => {
assert.deepStrictEqual(file.contents(), utils.NO_CONTENTS);
assertIssues(loc, file, expectedNoIssues);

file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length);
file.setContents(utils.UNKNOWN_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value);
assert.deepStrictEqual(file.contents(), utils.UNKNOWN_CONTENTS);
Expand All @@ -87,7 +77,7 @@ test.describe('File basic tests', () => {
assert.deepStrictEqual(file.contents(), utils.NO_CONTENTS);
assertIssues(loc, file, expectedNoIssues);

file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length);
file.setContents(utils.UNKNOWN_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value);
assert.deepStrictEqual(file.contents(), utils.UNKNOWN_CONTENTS);
Expand Down
27 changes: 4 additions & 23 deletions tests/bindings/javascript/file.child.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,14 @@ import * as utils from './utils.js';
const loc = await libOpenCOR();

test.describe('File type tests', () => {
let dataset135OmexContentsPtr;
let dataset135JsonContentsPtr;
let dataset157OmexContentsPtr;
let dataset157JsonContentsPtr;

test.before(() => {
dataset135OmexContentsPtr = utils.allocateMemory(loc, utils.DATASET_135_OMEX_CONTENTS);
dataset135JsonContentsPtr = utils.allocateMemory(loc, utils.DATASET_135_JSON_CONTENTS);
dataset157OmexContentsPtr = utils.allocateMemory(loc, utils.DATASET_157_OMEX_CONTENTS);
dataset157JsonContentsPtr = utils.allocateMemory(loc, utils.DATASET_157_JSON_CONTENTS);
});

test.beforeEach(() => {
loc.FileManager.instance().reset();
});

test.after(() => {
utils.freeMemory(loc, dataset135OmexContentsPtr);
utils.freeMemory(loc, dataset135JsonContentsPtr);
utils.freeMemory(loc, dataset157OmexContentsPtr);
utils.freeMemory(loc, dataset157JsonContentsPtr);
});

function doTestDataset(omexContentsPtr, omexContents, jsonContents, specificChildFileNames) {
function doTestDataset(omexContents, jsonContents, specificChildFileNames) {
const file = new loc.File(utils.COMBINE_ARCHIVE);

file.setContents(omexContentsPtr, omexContents.length);
file.setContents(omexContents);

assert.strictEqual(file.hasChildFiles, true);
assert.strictEqual(file.childFileCount, specificChildFileNames.length + 1);
Expand Down Expand Up @@ -85,13 +66,13 @@ test.describe('File type tests', () => {
});

test('Dataset 135', () => {
doTestDataset(dataset135OmexContentsPtr, utils.DATASET_135_OMEX_CONTENTS, utils.DATASET_135_JSON_CONTENTS, [
doTestDataset(utils.DATASET_135_OMEX_CONTENTS, utils.DATASET_135_JSON_CONTENTS, [
'HumanSAN_Fabbri_Fantini_Wilders_Severi_2017.cellml'
]);
});

test('Dataset 157', () => {
doTestDataset(dataset157OmexContentsPtr, utils.DATASET_157_OMEX_CONTENTS, utils.DATASET_157_JSON_CONTENTS, [
doTestDataset(utils.DATASET_157_OMEX_CONTENTS, utils.DATASET_157_JSON_CONTENTS, [
'fabbri_et_al_based_composite_SAN_model.cellml',
'fabbri_et_al_based_composite_SAN_model.sedml'
]);
Expand Down
21 changes: 4 additions & 17 deletions tests/bindings/javascript/file.coverage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,30 @@ import * as utils from './utils.js';
const loc = await libOpenCOR();

test.describe('File coverage tests', () => {
let nullCharacterContentsPtr;
let combineArchiveContentsPtr;

test.before(() => {
nullCharacterContentsPtr = utils.allocateMemory(loc, utils.NULL_CHARACTER_CONTENTS);
combineArchiveContentsPtr = utils.allocateMemory(loc, utils.COMBINE_ARCHIVE_CONTENTS);
});

test.beforeEach(() => {
loc.FileManager.instance().reset();
});

test.after(() => {
utils.freeMemory(loc, nullCharacterContentsPtr);
utils.freeMemory(loc, combineArchiveContentsPtr);
});

test('Empty file', () => {
const file = new loc.File(utils.UNKNOWN_FILE);

file.setContents(null, 0);
file.setContents(null);

assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value);
});

test('File with null character', () => {
const file = new loc.File(utils.UNKNOWN_FILE);

file.setContents(nullCharacterContentsPtr, utils.NULL_CHARACTER_CONTENTS.length);
file.setContents(utils.NULL_CHARACTER_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value);
});

test('SED-ML file with no parent', () => {
const file = new loc.File(utils.SEDML_FILE);

file.setContents(utils.SEDML_CONTENTS, utils.SEDML_CONTENTS.length);
file.setContents(utils.SEDML_CONTENTS);
});

test('Same local file', () => {
Expand All @@ -80,7 +67,7 @@ test.describe('File coverage tests', () => {
const file = new loc.File(utils.COMBINE_ARCHIVE);
const fileManager = loc.FileManager.instance();

file.setContents(combineArchiveContentsPtr, utils.COMBINE_ARCHIVE_CONTENTS.length);
file.setContents(utils.COMBINE_ARCHIVE_CONTENTS);

assert.strictEqual(fileManager.fileCount, 3);

Expand Down
27 changes: 4 additions & 23 deletions tests/bindings/javascript/file.type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,14 @@ import { assertIssues } from './utils.js';
const loc = await libOpenCOR();

test.describe('File type tests', () => {
let unknownContentsPtr;
let cellmlContentsPtr;
let sedmlContentsPtr;
let combineArchiveContentsPtr;

test.before(() => {
unknownContentsPtr = utils.allocateMemory(loc, utils.UNKNOWN_CONTENTS);
cellmlContentsPtr = utils.allocateMemory(loc, utils.CELLML_CONTENTS);
sedmlContentsPtr = utils.allocateMemory(loc, utils.SEDML_CONTENTS);
combineArchiveContentsPtr = utils.allocateMemory(loc, utils.COMBINE_ARCHIVE_CONTENTS);
});

test.beforeEach(() => {
loc.FileManager.instance().reset();
});

test.after(() => {
utils.freeMemory(loc, unknownContentsPtr);
utils.freeMemory(loc, cellmlContentsPtr);
utils.freeMemory(loc, sedmlContentsPtr);
utils.freeMemory(loc, combineArchiveContentsPtr);
});

test('Unknown file', () => {
const file = new loc.File(utils.UNKNOWN_FILE);

file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length);
file.setContents(utils.UNKNOWN_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value);
assertIssues(loc, file, [
Expand All @@ -61,23 +42,23 @@ test.describe('File type tests', () => {
test('CellML file', () => {
const file = new loc.File(utils.CELLML_FILE);

file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length);
file.setContents(utils.CELLML_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.CELLML_FILE.value);
});

test('SED-ML file', () => {
const file = new loc.File(utils.SEDML_FILE);

file.setContents(sedmlContentsPtr, utils.SEDML_CONTENTS.length);
file.setContents(utils.SEDML_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.SEDML_FILE.value);
});

test('COMBINE archive', () => {
const file = new loc.File(utils.COMBINE_ARCHIVE);

file.setContents(combineArchiveContentsPtr, utils.COMBINE_ARCHIVE_CONTENTS.length);
file.setContents(utils.COMBINE_ARCHIVE_CONTENTS);

assert.strictEqual(file.type.value, loc.File.Type.COMBINE_ARCHIVE.value);
});
Expand Down
Loading
Loading