Skip to content

Conversation

@taminob
Copy link
Owner

@taminob taminob commented Nov 27, 2024

Add two functions for setting/getting global variables to each plugin type:

  • global<T>(variable_name) for getting global variables
  • global(variable_name, value) for setting global variables

Resolves #12

Additionally, this PR introduces the new container types std::vector and std::map which can be filled with any of the already existing types.

Resolves #23

@taminob taminob added enhancement New feature or request python Related to python plugin C Related to C plugin C++ Related to C++ plugin Lua Related to Lua plugin labels Nov 27, 2024
@taminob taminob self-assigned this Nov 27, 2024
Since this plugin is supposed to do nothing, the global function will
simply return a default constructed value for the getter and do nothing
for the setter.
This will return the second template parameter of a template class.
It will be used for retrieving the error of Expected when it is not
clear that the class actually has enough template parameters.
A default value can be passed in case the class does not have sufficient
template parameters.
Although the class is called CallError, it is also used for errors when
setting/getting variables.
Thus, the new error class incorrectType can help narrowing down the
actual issue when passing the wrong type for a variable. This can only
be detected in the scripting languages.
This alternative is called RemoveCvrefT.
Previously, this was performed in PythonTuple.
However, this is less flexible since an unnecessary PythonTuple needs to
be constructed that way which is why it was moved to PythonObject.
Previously, the returned string was interpreted as a null-terminated
C-string. However, a Python bytes object may contain null bytes in the
string which is why the separately stored string length must be used to
construct the correct string.
This feature will probably not be implemented and thus the placeholder
does no longer make sense.
@taminob taminob force-pushed the feature/set-global-in-plugin branch from 1c3aa07 to 703f04b Compare February 19, 2025 00:45
taminob added 9 commits March 30, 2025 21:18
This will allow to indicate to the user if setting the variable was
successful. This can happen for C++ if the symbol does not exist or
theoretically for Python where the API indicates that an exception can
be thrown by the set function.
…efinition

Most member functions were already at the bottom of the header files or
in their own source file. This commit moves the remaining definitions
there as well.
Since Python does have its own philosophy for header includes (always
include Python.h as first header which also includes all other required
headers), it is not feasible to use the include-cleaner in this project.
Since there is no common pattern for the Python headers, it is also not
possible to simply use the option "IgnoreHeaders" to disable this check
only for Python headers.
These includes are not part of the official API and thus can change
between different Python versions. This makes them unsuitable to be
used by external libraries. Thus, this project will rely on the official
Python.h header which includes all the necessary headers.

They were originally included to satisfy the include cleaner of
clang-tidy.
The implicit conversion to CallError made it impossible to get the
CallError::Code inside the object. Additionally, the name was confusing
since the CallError is usually wrapped inside an Expected which also has
a method called error().
@taminob taminob force-pushed the feature/set-global-in-plugin branch from 2ebbcbd to bf2d74e Compare April 29, 2025 20:52
taminob added 3 commits May 2, 2025 10:30
This function will make developing and debugging the Lua part easier
since it allows to inspect the entire Lua stack at certain points of
execution.
Add some basic test cases to test the high-level Lua functionalities.
They are part of a dedicated static library which will be linked into
the test executable.
@taminob taminob force-pushed the feature/set-global-in-plugin branch 3 times, most recently from 216e77d to 207b802 Compare May 2, 2025 09:07
@taminob taminob force-pushed the feature/set-global-in-plugin branch from 207b802 to cbaabaa Compare May 9, 2025 18:30
@taminob taminob force-pushed the feature/set-global-in-plugin branch from 68b320b to 7f37b0b Compare May 9, 2025 19:01
@taminob taminob merged commit e0f74b0 into main May 9, 2025
11 checks passed
@taminob taminob deleted the feature/set-global-in-plugin branch May 9, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related to C plugin C++ Related to C++ plugin enhancement New feature or request Lua Related to Lua plugin python Related to python plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add array and dictionary/table types Support global variables in plugins

2 participants