diff --git a/docs/plugins/index.md b/docs/plugins/index.md index bf9d5cbf..57d19678 100644 --- a/docs/plugins/index.md +++ b/docs/plugins/index.md @@ -261,25 +261,33 @@ This is a list of provided methods: double getSlotDouble(WrenVM* vm, int slot); const char* getSlotString(WrenVM* vm, int slot); const char* getSlotBytes(WrenVM* vm, int slot, int* length); - void abortFiber(WrenVM* vm, int slot); WrenType getSlotType(WrenVM* vm, int slot); + void setSlotNewList(WrenVM* vm, int slot); int getListCount(WrenVM* vm, int slot); void getListElement(WrenVM* vm, int listSlot, int index, int elementSlot); void setListElement(WrenVM* vm, int listSlot, int index, int elementSlot); void insertInList(WrenVM* vm, int listSlot, int index, int elementSlot); + void setSlotNewMap(WrenVM* vm, int slot); int getMapCount(WrenVM* vm, int slot); bool getMapContainsKey(WrenVM* vm, int mapSlot, int keySlot); void getMapValue(WrenVM* vm, int mapSlot, int keySlot, int valueSlot); void setMapValue(WrenVM* vm, int mapSlot, int keySlot, int valueSlot); void removeMapValue(WrenVM* vm, int mapSlot, int keySlot, int removedValueSlot); + +WrenInterpretResult interpret(WrenVM* vm, const char* module, const char* source); +WrenInterpretResult call(WrenVM* vm, WrenHandle* method); + + bool hasModule(WrenVM* vm, const char* module); + bool hasVariable(WrenVM* vm, const char* module, const char* name); void getVariable(WrenVM* vm, const char* module, const char* name, int slot); WrenHandle* getSlotHandle(WrenVM* vm, int slot); void setSlotHandle(WrenVM* vm, int slot, WrenHandle* handle); void releaseHandle(WrenVM* vm, WrenHandle* handle); + void abortFiber(WrenVM* vm, int slot); ``` ### Module Embedding diff --git a/include/dome.h b/include/dome.h index a99bea21..de0e7a79 100644 --- a/include/dome.h +++ b/include/dome.h @@ -63,8 +63,7 @@ typedef struct WrenHandle WrenHandle; typedef void (*WrenForeignMethodFn)(WrenVM* vm); typedef void (*WrenFinalizerFn)(void* data); -typedef enum -{ +typedef enum { WREN_TYPE_BOOL, WREN_TYPE_NUM, WREN_TYPE_FOREIGN, @@ -76,6 +75,14 @@ typedef enum // The object is of a type that isn't accessible by the C API. WREN_TYPE_UNKNOWN } WrenType; + +typedef enum +{ + WREN_RESULT_SUCCESS, + WREN_RESULT_COMPILE_ERROR, + WREN_RESULT_RUNTIME_ERROR +} WrenInterpretResult; + #endif typedef DOME_Result (*DOME_Plugin_Hook) (DOME_Context context); @@ -133,6 +140,12 @@ typedef struct { WrenHandle* (*getSlotHandle)(WrenVM* vm, int slot); void (*setSlotHandle)(WrenVM* vm, int slot, WrenHandle* handle); void (*releaseHandle)(WrenVM* vm, WrenHandle* handle); + + bool (*hasVariable)(WrenVM* vm, const char* module, const char* name); + bool (*hasModule)(WrenVM* vm, const char* module); + + WrenInterpretResult (*call)(WrenVM* vm, WrenHandle* method); + WrenInterpretResult (*interpret)(WrenVM* vm, const char* module, const char* source); } WREN_API_v0; typedef struct { diff --git a/src/plugin.c b/src/plugin.c index 3ffde1ae..dbe147b2 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -323,7 +323,12 @@ WREN_API_v0 wren_v0 = { .getVariable = wrenGetVariable, .getSlotHandle = wrenGetSlotHandle, .setSlotHandle = wrenSetSlotHandle, - .releaseHandle = wrenReleaseHandle + .releaseHandle = wrenReleaseHandle, + + .hasVariable = wrenHasVariable, + .hasModule = wrenHasModule, + .call = wrenCall, + .interpret = wrenInterpret, }; DOME_API_v0 dome_v0 = {