-
Notifications
You must be signed in to change notification settings - Fork 1
C Code
justinmann edited this page Dec 24, 2017
·
3 revisions
You can include any C code you would like inside of a block, like this:
--c--
printf("Hello from C");
--c--
To make it easy to inter-operate with SJ, there are several macros you can use in your C code:
--c--
#include(<stdio.h>) // Add an include statement to output, include statements are sorted alphabetically and only included once
#type(i32) // Converts an SJ type into the C equivalent
#retain(x) // Keeps a reference to an object, this is required if you are keeping a value beyond the scope of this request
#release(x) // Drop your reference
#isValue(i32) // Returns true if type is a simple value and false if type is function pointer
--c--
In C you may also need to access an SJ variable:
class(
y : 0
func(x : 0) {
result := 0
--c--
result = x + _parent->y;
--c--
}
) {
--c--
_this->y = 1234;
--c--
this
}