Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

JSInterp.H

00001 /* $Id: JSInterp.H,v 1.2 2000/11/03 22:03:28 rpav Exp $
00002  *
00003  * 
00004  * Copyright (C) 1999  Ryan Pavlik
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  */
00021 
00022 #ifndef JSINTERP_H
00023 #define JSINTERP_H
00024 
00025 #include <string>
00026 #include <list>
00027 #include <vector>
00028 #include <SFW/Object.H>
00029 
00030 extern "C" {
00031 #include <js.h>
00032 }
00033 
00034 namespace SFW {
00035     class JavaScriptInterpreter : public Object {
00036     JSInterpOptions jsopts;
00037     JSInterpPtr     jsi;
00038     bool            error_cond;
00039 
00040         friend class JavaScriptClass;
00041         
00042     public:
00043         TYPE_INFO(SFW::JavaScriptInterpreter, SFW::Object);
00044         
00045     JavaScriptInterpreter();
00046     ~JavaScriptInterpreter();
00047 
00048     string getVersion(void) const;
00049 
00050     JavaScriptType     eval(const string& code);
00051     JavaScriptType     evalFile(const string& filename);
00052     JavaScriptType     exec(const JavaScriptByteCode &jsbc);
00053     /* need execFile here too */
00054 
00055     bool   error    ()     const;
00056     string errorMsg (void) const;
00057         
00058     JavaScriptByteCode compile(const string& code);
00059     /* need compileFile here too */
00060 
00061     void           setVar(const string& name, JavaScriptType& o);
00062     JavaScriptType getVar(const string& name);
00063     JavaScriptType callMethod(JavaScriptType& ob, const string& method,
00064                   const vector<JavaScriptType>& argv);
00065     
00066     JSTMap         objectProperties(JavaScriptType &t);
00067     JSPropList     listProperties(JavaScriptType &t);
00068     void           setProperty(JavaScriptType &object,
00069                    const JavaScriptType &name,
00070                    JavaScriptType &value);
00071     JavaScriptType getProperty(JavaScriptType &object,
00072                    const JavaScriptType &name);
00073     void           delProperty(JavaScriptType &object,
00074                    const JavaScriptType &name);
00075 
00076     void define(JavaScriptMethod& m);
00077     void define(JavaScriptClass& jsc);
00078 
00079     string format(JavaScriptType &ob);
00080     };
00081 
00082     class JavaScriptMethod : public Object {
00083     string name;
00084 
00085     public:
00086         V_TYPE_INFO(SFW::JavaScriptMethod, SFW::Object);
00087         
00088     JavaScriptMethod(const string& s);
00089     virtual ~JavaScriptMethod() {}
00090 
00091     virtual bool proc (vector<JavaScriptType>& jstav,
00092                JavaScriptType& ret, string& error) = 0;
00093     
00094     const string getName(void);
00095     };
00096 }
00097 
00098 #endif /* JSINTERP_H */

Generated at Tue Jan 2 15:38:33 2001 for SFW by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000