Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesBoer committed Jun 18, 2022
2 parents 6ddfe82 + ccd4999 commit f2280a7
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 68 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ Build/


.DS_Store

.idea/
11 changes: 9 additions & 2 deletions Docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.3.7] - 2022-03-27
## [1.3.9] - 2022-06-17

- Fixed issue with duplicate non-local function registration
- Fix unit tests to allow easier max instruction tests
- Minor spelling corrections
- Corrected previously out-of-sync patch messages in changelog

## [1.3.8] - 2022-03-27

- Improved error messages
- Fixed URL to tutorial in JinxPad

## [1.3.6] - 2022-03-27
## [1.3.7] - 2022-03-27

- Fixed memory allocation stats in amalgamated header

Expand Down
11 changes: 7 additions & 4 deletions Include/Jinx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ namespace Jinx
const uint32_t MinorVersion = 3;

/// Patch number
const uint32_t PatchNumber = 8;
const uint32_t PatchNumber = 9;

// Forward declaration
class IScript;
Expand Down Expand Up @@ -5174,7 +5174,7 @@ namespace Jinx::Impl
if (!signature.IsValid())
return false;

// Register function in library table. This allows the the parser to find
// Register function in library table. This allows the parser to find
// and use this function.
RegisterFunctionSignature(signature);

Expand All @@ -5192,7 +5192,10 @@ namespace Jinx::Impl
inline void Library::RegisterFunctionSignature(const FunctionSignature & signature)
{
std::lock_guard<std::mutex> lock(m_functionMutex);
m_functionList.push_back(signature);
auto itr = std::find(m_functionList.begin(), m_functionList.end(), signature);
if (itr != m_functionList.end())
return;
m_functionList.push_back(signature);
}

inline bool Library::RegisterProperty(Visibility visibility, Access access, const String & name, const Variant & value)
Expand Down Expand Up @@ -9723,7 +9726,7 @@ namespace Jinx::Impl
auto result = op1 - op2;
if (result.IsNull())
{
Error("Invalid variable for subraction");
Error("Invalid variable for subtraction");
return false;
}
Push(result);
Expand Down
2 changes: 1 addition & 1 deletion Source/Jinx.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace Jinx
const uint32_t MinorVersion = 3;

/// Patch number
const uint32_t PatchNumber = 8;
const uint32_t PatchNumber = 9;

// Forward declaration
class IScript;
Expand Down
7 changes: 5 additions & 2 deletions Source/JxLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace Jinx::Impl
if (!signature.IsValid())
return false;

// Register function in library table. This allows the the parser to find
// Register function in library table. This allows the parser to find
// and use this function.
RegisterFunctionSignature(signature);

Expand All @@ -122,7 +122,10 @@ namespace Jinx::Impl
inline_t void Library::RegisterFunctionSignature(const FunctionSignature & signature)
{
std::lock_guard<std::mutex> lock(m_functionMutex);
m_functionList.push_back(signature);
auto itr = std::find(m_functionList.begin(), m_functionList.end(), signature);
if (itr != m_functionList.end())
return;
m_functionList.push_back(signature);
}

inline_t bool Library::RegisterProperty(Visibility visibility, Access access, const String & name, const Variant & value)
Expand Down
2 changes: 1 addition & 1 deletion Source/JxScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ namespace Jinx::Impl
auto result = op1 - op2;
if (result.IsNull())
{
Error("Invalid variable for subraction");
Error("Invalid variable for subtraction");
return false;
}
Push(result);
Expand Down
7 changes: 4 additions & 3 deletions Tests/Features/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Copyright (c) 2016 James Boer
#include <string.h>
#include <assert.h>
#include <stdexcept>
#include <inttypes.h>

#include "../../Source/Jinx.h"

Expand Down Expand Up @@ -83,9 +84,9 @@ int main(int argc, char ** argv)
auto memStats = GetMemoryStats();
printf("\nMemory Stats\n");
printf("-------------\n");
printf("Allocation count: %zu\n", memStats.allocationCount);
printf("Free count: %zu\n", memStats.freeCount);
printf("Allocated memory: %zu bytes\n", memStats.allocatedMemory);
printf("Allocation count: %" PRIu64 "\n", memStats.allocationCount);
printf("Free count: %" PRIu64 "\n", memStats.freeCount);
printf("Allocated memory: %" PRIu64 " bytes\n", memStats.allocatedMemory);

return 0;
}
17 changes: 8 additions & 9 deletions Tests/UnitTests/TestCollections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ TEST_CASE("Test Collections", "[Collections]")

auto script = TestExecuteScript(scriptText);
REQUIRE(script);
REQUIRE(script->Execute());
REQUIRE(script->GetVariable("a") == 2);
}

Expand All @@ -547,7 +546,7 @@ TEST_CASE("Test Collections", "[Collections]")
)";

auto script = TestExecuteScript(scriptText);
REQUIRE(script->Execute());
REQUIRE(script);
REQUIRE(script->GetVariable("a") == 5);
}

Expand All @@ -561,7 +560,7 @@ TEST_CASE("Test Collections", "[Collections]")
)";

auto script = TestExecuteScript(scriptText);
REQUIRE(script->Execute());
REQUIRE(script);
REQUIRE(script->GetLibrary()->GetProperty("a") == 5);
}

Expand Down Expand Up @@ -644,7 +643,7 @@ TEST_CASE("Test Collections", "[Collections]")

auto script = TestCreateScript(scriptText);
script->SetVariable("text", tableText);
REQUIRE(script->Execute());
REQUIRE(TestExecuteScript(script));
REQUIRE(script->GetVariable("table").IsCollection());
REQUIRE(script->GetVariable("a") == "Test Name A");
REQUIRE(script->GetVariable("b") == 2);
Expand Down Expand Up @@ -680,7 +679,7 @@ TEST_CASE("Test Collections", "[Collections]")
Variant table = tableText;
REQUIRE(table.ConvertTo(ValueType::Collection));
script->SetVariable("table", table);
REQUIRE(script->Execute());
REQUIRE(TestExecuteScript(script));
REQUIRE(script->GetVariable("table").IsCollection());
REQUIRE(script->GetVariable("a") == "Test Name A");
REQUIRE(script->GetVariable("b") == 2);
Expand Down Expand Up @@ -716,7 +715,7 @@ TEST_CASE("Test Collections", "[Collections]")
Variant table = tableText;
REQUIRE(table.ConvertTo(ValueType::Collection));
script->SetVariable("table", table);
REQUIRE(script->Execute());
REQUIRE(TestExecuteScript(script));
REQUIRE(script->GetVariable("table").IsCollection());
REQUIRE(script->GetVariable("a") == "Test Name A");
REQUIRE(script->GetVariable("b") == 2);
Expand Down Expand Up @@ -746,7 +745,7 @@ TEST_CASE("Test Collections", "[Collections]")

auto script = TestCreateScript(scriptText);
script->SetVariable("text", tableText);
REQUIRE(script->Execute());
REQUIRE(TestExecuteScript(script));
REQUIRE(script->GetVariable("table").IsCollection());
REQUIRE(script->GetVariable("a") == "Test 1, 2, 3");
REQUIRE(script->GetVariable("b") == "Test 4");
Expand All @@ -771,7 +770,7 @@ TEST_CASE("Test Collections", "[Collections]")

auto script = TestCreateScript(scriptText);
script->SetVariable("text", tableText);
REQUIRE(script->Execute());
REQUIRE(TestExecuteScript(script));
REQUIRE(script->GetVariable("table").IsCollection());
REQUIRE(script->GetVariable("a") == "\"Quoted text\"");
}
Expand All @@ -795,7 +794,7 @@ TEST_CASE("Test Collections", "[Collections]")

auto script = TestCreateScript(scriptText);
script->SetVariable("text", tableText);
REQUIRE(script->Execute());
REQUIRE(TestExecuteScript(script));
REQUIRE(script->GetVariable("table").IsCollection());
REQUIRE(script->GetVariable("a").GetNumber() == Approx(123.456));
}
Expand Down
Loading

0 comments on commit f2280a7

Please sign in to comment.