# HG changeset patch # User Mike Pavone # Date 1376037429 25200 # Node ID 833624457b81c4b879b6128bcf33013e5dd32535 # Parent 15aac5334b6414f3856f5759de0f151f85e35fce# Parent 5bcaddff29f5a2a8c89566e31970f28c6670ee31 Merge diff -r 5bcaddff29f5 -r 833624457b81 cbackend.js --- a/cbackend.js Thu Aug 08 22:31:41 2013 -0700 +++ b/cbackend.js Fri Aug 09 01:37:09 2013 -0700 @@ -423,7 +423,24 @@ cObject.prototype.addInit = function(statement) { this.init.push(statement); -} +}; + +cObject.prototype.addImport = function(symbols, source) { + this.imported.push(source); + var importNum = imported.length - 1; + if (symbols) { + each(symbols, function(i, sym) { + this.addMessage(sym.name, { + vars: {}, + lines: [ + 'return self->import_' + importNum + '->meta->meth_lookup[method_id & 0xF](method_id, num_args, self->import_' + importNum + ', args);' + ] + }); + }); + } else { + //TODO: handle proxying for unimplemented methods + } +}; cObject.prototype.checkInitMsg = function() { if (!this.initmsgadded && this.init.length) { @@ -515,8 +532,6 @@ object.prototype.toCObject = function() { var messages = this.messages; - var values = []; - var imports = []; if (!this.name) { this.name = 'object_' + nextobject++; } @@ -532,16 +547,16 @@ for (var i in messages) { if (messages[i] instanceof funcall) { if (messages[i].name == 'import:' && messages[i].args.length == 1) { - imports.push({symbols: false, src: messages[i].args[0]}); + me.addImport(false, messages[i].args[0]); } else if(messages[i].name == 'import:from:' && messages[i].args.length == 2) { var importsyms = []; each(messages[i].args[0].val, function(i, el) { if (!(el instanceof symbol)) { throw new Error('Names in import:from statement must be symbols'); } - importsyms.push(new strlit(el.name)); + importsyms.push(el); }); - imports.push({symbols: new listlit(importsyms), src: messages[i].args[1]}); + me.addImport(importsyms, messages[i].args[1]); } else if(messages[i].name == 'llProperty:withType:' && messages[i].args.length == 2) { me.addProperty(messages[i].args[0].name, null, messages[i].args[1].toCTypeName()) } else if(messages[i].name == 'llMessage:withVars:andCode:' && messages[i].args.length == 3) { diff -r 5bcaddff29f5 -r 833624457b81 editor.js --- a/editor.js Thu Aug 08 22:31:41 2013 -0700 +++ b/editor.js Fri Aug 09 01:37:09 2013 -0700 @@ -350,3 +350,8 @@ el.webkitRequestFullscreen(); } } + +function create_symbol(name) +{ + return new symbol(name); +} diff -r 5bcaddff29f5 -r 833624457b81 modules/socket.tp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/socket.tp Fri Aug 09 01:37:09 2013 -0700 @@ -0,0 +1,67 @@ +#{ + llMessage: AF_INET withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: AF_INET + intret + } + llMessage: AF_UNIX withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: AF_UNIX + intret + } + llMessage: STREAM withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: SOCK_STREAM + intret + } + llMessage: DGRAM withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: SOCK_DGRAM + intret + } + llMessage: socket withVars: { + fd <- obj_int32 ptr + domain <- obj_int32 ptr + type <- obj_int32 ptr + protocol <- obj_int32 ptr + } andCode: :domain type protocol { + fd <- make_object: (addr_of: obj_int32_meta) NULL 0 + fd num!: (socket: (domain num) (type num) (protocol num)) + fd + } + + llMessage: getaddrinfo withVars: { + + } andCode: { + } + + new <- :domain type protocol { + sfd <- socket: domain type protocol + #{ + fd <- {sfd} + llMessage: close withVars: { + sfd <- obj_int32 ptr + } andCode: { + sfd <- mcall: fd 1 self + close: (sfd num) + self + } + } + } + + connectTo:onPort <- :host :port { + + } + listenOn: <- :port { + } + listenAt:onPort <- :host :port { + } +} diff -r 5bcaddff29f5 -r 833624457b81 src/editor.tp --- a/src/editor.tp Thu Aug 08 22:31:41 2013 -0700 +++ b/src/editor.tp Fri Aug 09 01:37:09 2013 -0700 @@ -13,6 +13,7 @@ getEl <- foreign: :from idx {} setEl <- foreign: :to idx val {} goFullScreen <- foreign: {} +create_symbol <- foreign: :name {} //TP Parser parser <- foreign: #{ @@ -238,10 +239,14 @@ event stopPropagation: (foreign: undefined) } +replaceNode:with <- :astnode domnode :newnode { + +} + lambdaClick <- :domnode astnode event { selectNode: domnode popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { - console log: "foooobar!" + replaceNode: astnode domnode with: (create_symbol: key) } inner <- if: ((astnode args) length) > 0 { (astnode args) getEl: 0