-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default null to nil when injectObjects is not set
- Loading branch information
Showing
5 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Global from '../global' | ||
import Thread from '../thread' | ||
import TypeExtension from '../type-extension' | ||
|
||
// A default extension that treats js null as lua nil | ||
class DefaultNullTypeExtension extends TypeExtension<unknown> { | ||
constructor(thread: Global) { | ||
super(thread, 'js_null') | ||
} | ||
public getValue(): null { | ||
throw new Error('nil values should be converted by pushValue') | ||
} | ||
public pushValue(thread: Thread, decoration: any): boolean { | ||
if (decoration?.target !== null) { | ||
return false | ||
} | ||
thread.lua.lua_pushnil(thread.address) | ||
return true | ||
} | ||
public close(): void {} | ||
} | ||
|
||
export default function createTypeExtension(thread: Global): TypeExtension<null> { | ||
return new DefaultNullTypeExtension(thread) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters