aboutsummaryrefslogtreecommitdiff
path: root/matrix/init.c
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-15 02:36:55 +0800
committerDeterminant <[email protected]>2015-05-15 02:36:55 +0800
commitefb786d716363dde8f90ef0672f479790befc79c (patch)
tree1d7a6f07db9cae3fd65a437d3ca6ff398a2b684b /matrix/init.c
parentb03471e2b0d604806773b540551cd047979b7b3b (diff)
use C macro to implement matrix template
Diffstat (limited to 'matrix/init.c')
-rw-r--r--matrix/init.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/matrix/init.c b/matrix/init.c
new file mode 100644
index 0000000..e251628
--- /dev/null
+++ b/matrix/init.c
@@ -0,0 +1,19 @@
+#include "../common.h"
+#include "generic/matrix.h"
+
+const char *nerv_matrix_tname = "nerv.Matrix";
+static const luaL_Reg matrix_methods[] = {
+ {"__tostring__", nerv_error_method_not_implemented },
+ {"__add__", nerv_error_method_not_implemented },
+ {"__sub__", nerv_error_method_not_implemented },
+ {"__mul__", nerv_error_method_not_implemented },
+ {NULL, NULL}
+};
+
+void nerv_matrix_init(lua_State *L) {
+ /* abstract class */
+ luaT_newmetatable(L, nerv_matrix_tname, NULL, NULL, NULL, NULL);
+ luaL_register(L, NULL, matrix_methods);
+ lua_pop(L, 1);
+ nerv_float_matrix_host_init(L);
+}