Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Oct 6, 2024
1 parent 76415bb commit 455c001
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/scripting/expose.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,16 @@ const functions = CacheTable"DispatcherFunctions" # Maps from scope name to li
const injectors = CacheTable"Injectors" # Maps from type name (referring to nim type) to function
const exposedFunctions* = CacheTable"ExposedFunctions" # Maps from type name (referring to nim type) to type name of the api type (from scripting_api)
const wasmImportedFunctions* = CacheTable"WasmImportedFunctions"
const jsPrototypes = CacheTable"JsPrototypes"

template varargs*() {.pragma.}

template nodispatch*() {.pragma.}
## Don't add this function to the dispatcher, and don't create a json wrapper

template nojsonwrapper*() {.pragma.}
## Don't add this function to the dispatcher, and don't create a json wrapper

macro addTypeMap*(source: untyped, wrapper: typed, mapperFunction: typed) =
mapperFunctions[$source] = mapperFunction
typeWrapper[$source] = wrapper

macro addInjector*(name: untyped, function: typed) =
injectors[$name] = function

macro registerJsPrototype*(name: static string) =
jsPrototypes[name] = nnkStmtList.newTree()

macro addWasmImportedFunction*(moduleName: static string, name: untyped, thisSide: untyped, wasmSide: untyped) =
let n = nnkStmtList.newTree(name, thisSide, wasmSide)
for name, _ in wasmImportedFunctions:
Expand Down Expand Up @@ -346,15 +336,12 @@ macro expose*(moduleName: static string, def: untyped): untyped =
addWasmImportedFunction(`moduleName`, `jsonStringWrapperFunctionName`, `jsonStringWrapperFunctionWasm`):
proc `jsonStringWrapperFunctionName`(`arg`: cstring): cstring {.importc.}

result.add quote do:
static:
# This makes the function dispatchable
addFunction(`pureFunctionName`, `signature`, `jsonWrapperFunctionName`, `moduleName`, `documentationStr`)

# Only add the json wrapper and dispatch function if the {.nodispatch.} is not present
if not def.hasCustomPragma("nodispatch") or not def.hasCustomPragma("nojsonwrapper"):
result.add quote do:
static:
# This makes the function dispatchable
addFunction(`pureFunctionName`, `signature`, `jsonWrapperFunctionName`, `moduleName`, `documentationStr`)

# echo result[result.len - 1].repr
# echo result[result.len - 1].repr

macro genDispatchTable*(moduleName: static string): untyped =
defer:
Expand Down

0 comments on commit 455c001

Please sign in to comment.