Mercurial > repos > tabletprog
diff cbackend.js @ 266:75dc7161c1ca
Added object module which provides some basic reflection capabilities
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 17 Jul 2014 23:57:41 -0700 |
parents | d6a4c9e7716e |
children | d2b70cba661e |
line wrap: on
line diff
--- a/cbackend.js Mon Jul 14 19:03:46 2014 -0700 +++ b/cbackend.js Thu Jul 17 23:57:41 2014 -0700 @@ -522,6 +522,8 @@ cObject.prototype.toCDef = function() { this.checkInitMsg(); var slotdefs = ''; + var methlists = ''; + var methdict = '}, {' var metadef = 'obj_meta ' + this.name + '_meta = {sizeof(' + this.name +'), {'; for (var i = 0; i < 16; i++) { if (i) { @@ -552,13 +554,20 @@ '\t\t\treturn no_impl(method_id, num_params, (object *)self, args);\n\t}\n}\n'; } + methlists += 'uint32_t ' + this.name + '_methods_' + i + '[] = {' + for (j in this.slots[i]) { + methlists += this.slots[i][j][0] + ', '; + } + methlists += 'LAST_METHOD};'; metadef += this.name + '_slot_' + i; + methdict += (i ? ', ' : '') + this.name + '_methods_' + i; } else { metadef += 'no_impl'; + methdict += (i ? ', ' : '') + 'NULL'; } } - metadef += '}};\n'; - return slotdefs + metadef; + metadef += methdict + '}};\n'; + return slotdefs + methlists + metadef; } cObject.prototype.toCInstance = function() {