Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/cwrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2012-02-07 17:48:47 +0400
committerRonan Collobert <ronan@collobert.com>2012-02-07 17:48:47 +0400
commite79a02893ec9b8e0e49fbc08d5c79b9ed3f9a65c (patch)
tree01bc6a92dc575e40b8a03d050ca59dd5903f4a04
parent76df9ac9d248b7d72b53d403166ddbb110e42fa5 (diff)
removed user functions, and added arg.__metatable field instead
-rw-r--r--init.lua49
1 files changed, 1 insertions, 48 deletions
diff --git a/init.lua b/init.lua
index 096b94e..429a72c 100644
--- a/init.lua
+++ b/init.lua
@@ -163,6 +163,7 @@ function CInterface:__writeheaders(txt, args, argoffset)
arg.args = args -- in case we want to do stuff depending on other args
assert(argtypes[arg.name], 'unknown type ' .. arg.name)
setmetatable(arg, {__index=argtypes[arg.name]})
+ arg.__metatable = argtypes[arg.name]
tableinsertcheck(txt, arg:declare())
local helpname = arg:helpname()
if arg.returned then
@@ -194,18 +195,6 @@ function CInterface:__writeheaders(txt, args, argoffset)
end
end
- for _,arg in ipairs(args) do
- if arg.userhead then
- if type(arg.userhead) == 'string' then
- table.insert(txt, arg.userhead)
- elseif type(arg.userhead) == 'function' then
- tableinsertcheck(txt, arg:userhead())
- else
- error('userhead must be a string or a function')
- end
- end
- end
-
return helpargs, cargs, argcreturned
end
@@ -286,18 +275,6 @@ function CInterface:__writechecks(txt, args, argset)
tableinsertcheck(txt, arg:init())
end
- for _,arg in ipairs(args) do
- if arg.usercheck then
- if type(arg.usercheck) == 'string' then
- table.insert(txt, arg.usercheck)
- elseif type(arg.usercheck) == 'function' then
- tableinsertcheck(txt, arg:usercheck())
- else
- error('usercheck must be a string or a function')
- end
- end
- end
-
table.insert(txt, '}')
end
@@ -310,18 +287,6 @@ function CInterface:__writecall(txt, args, cfuncname, cargs, argcreturned)
tableinsertcheck(txt, arg:precall())
end
- for _,arg in ipairs(args) do
- if arg.userprecall then
- if type(arg.userprecall) == 'string' then
- table.insert(txt, arg.userprecall)
- elseif type(arg.userprecall) == 'function' then
- tableinsertcheck(txt, arg:userprecall())
- else
- error('userprecall must be a string or a function')
- end
- end
- end
-
if argcreturned then
table.insert(txt, string.format('%s = %s(%s);', argtypes[argcreturned.name].creturn(argcreturned), cfuncname, table.concat(cargs, ',')))
else
@@ -332,18 +297,6 @@ function CInterface:__writecall(txt, args, cfuncname, cargs, argcreturned)
tableinsertcheck(txt, arg:postcall())
end
- for _,arg in ipairs(args) do
- if arg.userpostcall then
- if type(arg.userpostcall) == 'string' then
- table.insert(txt, arg.userpostcall)
- elseif type(arg.userpostcall) == 'function' then
- tableinsertcheck(txt, arg:userpostcall())
- else
- error('userpostcall must be a string or a function')
- end
- end
- end
-
local nret = 0
if argcreturned then
nret = nret + 1