summaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
authorDamien <damien.p.george@gmail.com>2013-11-02 23:58:38 +0000
committerDamien <damien.p.george@gmail.com>2013-11-02 23:58:38 +0000
commita53f694dc3bda40431bad21ebeefe88d65bf1d6b (patch)
tree73853c43988c7a72693542e79e1473e52b0c1c36 /unix
parentd57eba51e520ddc7d57ffa3c67a10e5d0d73d4ce (diff)
Test code for user objects.
Diffstat (limited to 'unix')
-rw-r--r--unix/main.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/unix/main.c b/unix/main.c
index ebab64627..778284bdd 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -131,10 +131,38 @@ void do_file(const char *file) {
}
}
+void test_print(py_obj_t o_in) {
+ printf("<test>");
+}
+
+py_obj_t test_get(py_obj_t o_in) {
+ py_obj_t d1;
+ py_obj_t d2;
+ py_user_get_data(o_in, &d1, &d2);
+ return d1;
+}
+
+py_obj_t test_set(py_obj_t o_in, py_obj_t arg) {
+ py_user_set_data(o_in, (machine_uint_t)arg, (machine_uint_t)arg);
+ return py_const_none;
+}
+
+const py_user_info_t test_obj_info = {
+ "Test",
+ test_print,
+ {
+ { "get", 0, test_get },
+ { "set", 1, test_set },
+ { NULL, 0, NULL },
+ }
+};
+
int main(int argc, char **argv) {
qstr_init();
rt_init();
+ rt_store_name(qstr_from_str_static("test"), py_obj_new_user(&test_obj_info, py_obj_new_int(42), 0));
+
if (argc == 1) {
do_repl();
} else if (argc == 2) {