-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
108 additions
and
117 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
require "./spec_helper" | ||
require "../src/wrappers/nil" | ||
|
||
describe Luajit::Wrappers::NIL do | ||
it ".setup" do | ||
Luajit.run do |state| | ||
Luajit::Wrappers::NIL.setup(state) | ||
|
||
state.execute(<<-LUA).ok?.should be_true | ||
local x = NIL | ||
assert(type(x) == 'userdata') | ||
assert(x ~= nil) | ||
assert(tostring(x) == 'NIL') | ||
LUA | ||
end | ||
end | ||
|
||
it ".is_nil?" do | ||
Luajit.run do |state| | ||
Luajit::Wrappers::NIL.setup(state) | ||
|
||
state.execute("return NIL").ok?.should be_true | ||
Luajit::Wrappers::NIL.is_nil?(state, -1).should be_true | ||
|
||
state.execute("return nil").ok?.should be_true | ||
Luajit::Wrappers::NIL.is_nil?(state, -1).should be_false | ||
end | ||
end | ||
end |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
require "../luajit" | ||
|
||
class Luajit::Wrappers::IO < Luajit::LuaObject | ||
global_name "IO" | ||
metatable_name "__IO__" | ||
|
||
def self.setup(state : Luajit::LuaState) : Nil | ||
Luajit.create_lua_object(state, self) | ||
end | ||
end |
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,4 @@ | ||
---@meta _ | ||
|
||
---@class (exact) IO | ||
IO = {} |
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,26 @@ | ||
require "../luajit" | ||
|
||
class Luajit::Wrappers::NIL | ||
def self.setup(state : Luajit::LuaState) : Nil | ||
state.new_userdata(0_u64) | ||
state.push({ | ||
"__tostring" => Luajit::LuaState::Function.new { |__state| | ||
__state.push("NIL") | ||
1 | ||
} | ||
}) | ||
state.push_value(-1) | ||
state.set_registry("__NIL__") | ||
state.set_metatable(-2) | ||
state.set_global("NIL") | ||
end | ||
|
||
def self.is_nil?(state : Luajit::LuaState, index : Int32) : Bool | ||
begin | ||
state.check_userdata!(index, "__NIL__") | ||
true | ||
rescue Luajit::LuaError | ||
false | ||
end | ||
end | ||
end |
File renamed without changes.
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
---@meta _ | ||
|
||
---@class (exact) __STRING__ | ||
---@class (exact) String | ||
---@field split fun(path: string, sep: string): string[] | ||
__STRING__ = {} | ||
String = {} |