MCPcopy Create free account
hub / github.com/ceifa/wasmoon / getValue

Method getValue

src/thread.ts:271–307  ·  view source on GitHub ↗
(index: number, inputType?: LuaType, userdata?: unknown)

Source from the content-addressed store, hash-verified

269 }
270
271 public getValue(index: number, inputType?: LuaType, userdata?: unknown): any {
272 index = this.lua.lua_absindex(this.address, index)
273
274 const type: LuaType = inputType ?? this.lua.lua_type(this.address, index)
275
276 switch (type) {
277 case LuaType.None:
278 return undefined
279 case LuaType.Nil:
280 return null
281 case LuaType.Number:
282 return this.lua.lua_tonumberx(this.address, index, null)
283 case LuaType.String:
284 return this.lua.lua_tolstring(this.address, index, null)
285 case LuaType.Boolean:
286 return Boolean(this.lua.lua_toboolean(this.address, index))
287 case LuaType.Thread:
288 return this.stateToThread(this.lua.lua_tothread(this.address, index))
289 default: {
290 let metatableName: string | undefined
291 if (type === LuaType.Table || type === LuaType.Userdata) {
292 metatableName = this.getMetatableName(index)
293 }
294
295 const typeExtensionWrapper = this.typeExtensions.find((wrapper) =>
296 wrapper.extension.isType(this, index, type, metatableName),
297 )
298 if (typeExtensionWrapper) {
299 return typeExtensionWrapper.extension.getValue(this, index, userdata)
300 }
301
302 // Fallthrough if unrecognised user data
303 console.warn(`The type '${this.lua.lua_typename(this.address, type)}' returned is not supported on JS`)
304 return new Pointer(this.lua.lua_topointer(this.address, index))
305 }
306 }
307 }
308
309 public close(): void {
310 if (this.isClosed()) {

Callers 9

runMethod · 0.95
getStackValuesMethod · 0.95
dumpStackMethod · 0.95
assertOkMethod · 0.95
engine.test.jsFile · 0.45
getMethod · 0.45
callByteCodeMethod · 0.45
resumeMethod · 0.45
getValueFunction · 0.45

Calls 3

stateToThreadMethod · 0.95
getMetatableNameMethod · 0.95
isTypeMethod · 0.45

Tested by

no test coverage detected