Skip to content

Commit

Permalink
fix: update header
Browse files Browse the repository at this point in the history
  • Loading branch information
liz3 committed Feb 20, 2024
1 parent a39b86c commit c768a93
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/ffi-example/ffi.du
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(System.platform == "windows") {
}

for(var i = 0; i < 25; i+=1) {
print(mod.dictu_ffi_test(1, i*2));
print(mod.dictu_ffi_test_str());
print(mod.dictuFFITestAdd(1, i*2));
print(mod.dictuFFITestStr());
}
print(mod.test);
1 change: 1 addition & 0 deletions src/include/dictu_ffi_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ typedef struct {
} CallFrame;

struct _vm {
void* _compilerStub;
Value stack[STACK_MAX];
Value *stackTop;
bool repl;
Expand Down
9 changes: 5 additions & 4 deletions tests/ffi/ffi.du
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Used c code start:

#include "dictu-include.h"
#include <dictu_ffi_include.h>

Value dictu_ffi_test(DictuVM *vm, int argCount, Value *args) {
if(argCount != 2 || !IS_NUMBER(args[0]) || !IS_NUMBER(args[1])){
Expand All @@ -16,17 +16,18 @@ Value dictu_ffi_test(DictuVM *vm, int argCount, Value *args) {
return NUMBER_VAL(a+b);
}
Value dictu_ffi_test_str(DictuVM *vm, int argCount, Value *args) {
return OBJ_VAL(copyString(vm, "Hello world", 11));
return OBJ_VAL(copyString(vm, "Hello From Dictu FFI module!", 28));
}

int dictu_ffi_init(DictuVM *vm, Table *method_table) {
defineNative(vm, method_table, "dictu_ffi_test", dictu_ffi_test);
defineNative(vm, method_table, "dictu_ffi_test_str", dictu_ffi_test_str);
defineNative(vm, method_table, "dictuFFITestAdd", dictu_ffi_test);
defineNative(vm, method_table, "dictuFFITestStr", dictu_ffi_test_str);
defineNativeProperty(
vm, method_table, "test",
OBJ_VAL(copyString(vm, "Dictu!", 6)));
return 0;
}

Used c code end
*/

Expand Down
Binary file modified tests/ffi/libs/test-lib.dylib
Binary file not shown.

0 comments on commit c768a93

Please sign in to comment.