Call a foreign-language function: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Capitalize Wren file name.) |
m (→{{header|Wren}}: Oops!) |
||
Line 2,839: | Line 2,839: | ||
Although RC task solutions are usually written for execution by Wren CLI, the language's main purpose is for embedding and the embedding API is written in C. It is therefore a relative easy matter to call a C function from Wren after first embedding the latter in a suitable C program. |
Although RC task solutions are usually written for execution by Wren CLI, the language's main purpose is for embedding and the embedding API is written in C. It is therefore a relative easy matter to call a C function from Wren after first embedding the latter in a suitable C program. |
||
<syntaxhighlight lang="wren">/* |
<syntaxhighlight lang="wren">/* Call_a_foreign-language_function.wren */ |
||
class C { |
class C { |
||
Line 2,917: | Line 2,917: | ||
WrenVM* vm = wrenNewVM(&config); |
WrenVM* vm = wrenNewVM(&config); |
||
const char* module = "main"; |
const char* module = "main"; |
||
const char* fileName = " |
const char* fileName = "Call_a_foreign-language_function.wren"; |
||
char *script = readFile(fileName); |
char *script = readFile(fileName); |
||
WrenInterpretResult result = wrenInterpret(vm, module, script); |
WrenInterpretResult result = wrenInterpret(vm, module, script); |