-
Notifications
You must be signed in to change notification settings - Fork 163
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
4 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-------------------------------------------------------------------------------- | ||
-- Copyright (c) 2015 , 蒙占志(topameng) topameng@gmail.com | ||
-- All rights reserved. | ||
-- Use, modification and distribution are subject to the "MIT License" | ||
-------------------------------------------------------------------------------- | ||
local setmetatable = setmetatable | ||
|
||
local _slot = {} | ||
setmetatable(_slot, _slot) | ||
|
||
_slot.__call = function(self, ...) | ||
if nil == self.obj then | ||
return self.func(...) | ||
else | ||
return self.func(self.obj, ...) | ||
end | ||
end | ||
|
||
_slot.__eq = function (lhs, rhs) | ||
return lhs.func == rhs.func and lhs.obj == rhs.obj | ||
end | ||
|
||
function slot(func, obj) | ||
local st = {func = func, obj = obj} | ||
setmetatable(st, _slot) | ||
return st | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,19 @@ | ||
local types = {} | ||
local _typeof = tolua.typeof | ||
|
||
|
||
function typeof(obj) | ||
local t = type(obj) | ||
local ret = nil | ||
|
||
if t == "table" then | ||
ret = types[obj] | ||
|
||
if ret == nil then | ||
ret = _typeof(obj) | ||
types[obj] = ret | ||
end | ||
end | ||
|
||
return ret | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.