Mercurial > repos > tabletprog
annotate runtime/object.c @ 111:b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 14 Apr 2013 17:24:53 -0700 |
parents | abc6f3d644a4 |
children | 75dc7161c1ca |
rev | line source |
---|---|
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "object.h" |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdarg.h> |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include <stdlib.h> |
34
a10f1b049193
Working closures, but need to rethink method call strategy
Mike Pavone <pavone@retrodev.com>
parents:
31
diff
changeset
|
4 #include <stddef.h> |
78
abc6f3d644a4
Use Boehm-GC for garbage collection. Also make no_impl print on stderr rather than standard in and return a non-zero error code.
Mike Pavone <pavone@retrodev.com>
parents:
45
diff
changeset
|
5 #include <gc/gc.h> |
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 object * make_object(obj_meta * meta, void * parent, int num_props, ...) |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 { |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 va_list args; |
78
abc6f3d644a4
Use Boehm-GC for garbage collection. Also make no_impl print on stderr rather than standard in and return a non-zero error code.
Mike Pavone <pavone@retrodev.com>
parents:
45
diff
changeset
|
10 object * newobj = GC_MALLOC(meta->size); |
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 newobj->meta = meta; |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 newobj->parent = parent; |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 va_start(args, num_props); |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 object ** curprop = ((object **)(newobj + 1)); |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 for (; num_props > 0; num_props--) |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 { |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 *curprop = va_arg(args, object *); |
34
a10f1b049193
Working closures, but need to rethink method call strategy
Mike Pavone <pavone@retrodev.com>
parents:
31
diff
changeset
|
19 curprop++; |
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 } |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 va_end(args); |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 return newobj; |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 |
35
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
25 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...) |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
26 { |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
27 va_list args; |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
28 va_start(args, self); |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
29 object * ret = self->meta->meth_lookup[method_id & 0xF](method_id, num_args, self, args); |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
30 va_end(args); |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
31 return ret; |
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
32 } |