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-08 00:36:24 +0400
committerRonan Collobert <ronan@collobert.com>2012-02-08 00:36:24 +0400
commit7d055b3f0f57fdf48010162ed6ec7bf5e3af3895 (patch)
tree1f43d4d6e8213475a96843ad767ed1944408169f
parent742b834090588af4e32015f44ee80f6fa2ed6c61 (diff)
more dok
-rw-r--r--dok/index.dok42
1 files changed, 42 insertions, 0 deletions
diff --git a/dok/index.dok b/dok/index.dok
index e5a503a..422c606 100644
--- a/dok/index.dok
+++ b/dok/index.dok
@@ -47,3 +47,45 @@ some of them might be optional, can become very quickly a tedious task. The
**wrap** package is here to help the process. Remember however that even
though you might be able to treat most complex cases with **wrap**,
sometimes it is also good to do everything by hand yourself!
+
+===== High Level Interface =====
+
+**wrap** provides only one class: ''CInterface''. Considering our easy example, a typical usage
+would be:
+'
+<file lua>
+require 'wrap'
+
+interface = wrap.CInterface.new()
+
+interface:wrap(
+ "numel", -- the Lua name
+ "numel", -- the C function name, here the same
+ -- now we describe the 'arguments' (or possibly returned values)
+ {
+ {name="DoubleTensor"},
+ {name="int", creturned=true} -- this one is returned by the C function
+ }
+)
+
+print(interface:tostring())
+</file>
+The wrapper generated by **wrap** is quite similar to what one would write by hand:
+<file c>
+static int wrapper_numel(lua_State *L)
+{
+ int narg = lua_gettop(L);
+ THDoubleTensor *arg1 = NULL;
+ int arg2 = 0;
+ if(narg == 1
+ && (arg1 = luaT_toudata(L, 1, torch_DoubleTensor_id))
+ )
+ {
+ }
+ else
+ luaL_error(L, "expected arguments: DoubleTensor");
+ arg2 = numel(arg1);
+ lua_pushnumber(L, (lua_Number)arg2);
+ return 1;
+}
+</file>