-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builtin functions #232
base: master
Are you sure you want to change the base?
Builtin functions #232
Conversation
By the way, let's not get hung up on the specific interfaces and implementations for the builtin functions included in this PR, the lack of option types (and optional parameters) and proper error handling in Titan right now restricts what we can do. These builtin functions can improve later as the type system improves. |
Codecov Report
Continue to review full report at Codecov.
|
… for vararg primitives
…m instead of titan.h
Rebased this onto the current master. |
Adds the capability of having builtin functions in the Titan runtime that are callable directly from Titan code, and defines a few builtins available to all Titan modules (such as
print
).The idea is to use builtin functions for standard library functions that need to access Titan's Lua state, and for functions that do not need to access the Lua state but where it is incovenient or impossible to define the function by a combination of Titan code plus FFI calls.
These builtin functions have the Titan calling convention, apart from the addition of variadic arguments, encoded as an
int
parameter that takes the size of the variadic argument list, and a standard C variadic parameter.The C name of a builtin function is always
titan_<name>
for the builtins that are not part of any module, such asprint
andtostring
, andtitan_<mangled_fqtn>
for builtins declared in as part of a module, wheremangled_fqtn
is the fully-qualified name of the function with all dashes and dots replaced by underscores.