/* Copyright (c) 2003-2004 Jan-Klaas Kollhof This file is part of the JavaScript o lait library(jsolait). jsolait is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** Provides an JSON-RPC imlementation. */ Module("jsonrpc", "0.3.2", function(mod){ var lang = importModule("lang"); var tokens = lang.tokens; var ObjectBuffer=Class("ObjectBuffer", function(publ, supr){ publ.init=function(){ this.data=""; } publ.getObjects=function(data){ this.data += data; var t = new lang.Tokenizer(this.data); var brCnt= 0; var objects = []; var readCnt = 0 while(! t.finished()){ var n = t.next(); if(n.type != tokens.ERR){ if(n.value == "{"){ brCnt+=1; }else if(n.value == "}"){ brCnt-=1; if(brCnt==0){ var s = this.data.slice(readCnt, n.pos+1); readCnt += s.length; objects.push(s); } } }else{ break; } } this.data = this.data.slice(readCnt); return objects; } }) var nameAllowed=function(name){ return name.match(/^[a-zA-Z]\w*$/) != null; } var getMethodByName=function(obj, name){ try{//to get a method by asking the service obj = obj._getMethodByName(name) }catch(e){ var names = name.split("."); for(var i=0;i