-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_as.cpp
More file actions
35 lines (28 loc) · 998 Bytes
/
Copy pathtest_as.cpp
File metadata and controls
35 lines (28 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <angelscript.h>
#include <stdio.h>
static void testFunc()
{
printf("testFunc called\n");
}
int main()
{
printf("creating engine\n");
asIScriptEngine* engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
printf("engine = %p\n", (void*)engine);
if (!engine)
{
printf("ENGINE IS NULL - version mismatch!\n");
return 1;
}
int r = engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true);
printf("SetEngineProperty = %d\n", r);
r = engine->RegisterGlobalFunction("void test()", asFUNCTION(testFunc), asCALL_CDECL);
printf("RegisterGlobalFunction = %d\n", r);
r = engine->RegisterGlobalFunction("int add(int a, int b)", asFUNCTIONPR([](int a, int b) -> int { return a + b; }, (int, int), int), asCALL_CDECL);
printf("RegisterGlobalFunction lambda = %d\n", r);
asIScriptContext* ctx = engine->CreateContext();
printf("context = %p\n", (void*)ctx);
engine->Release();
printf("done\n");
return 0;
}