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

JSType.H

00001 /* $Id: JSType.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 JSTYPE_H
00023 #define JSTYPE_H
00024 
00025 #include <string>
00026 #include <map>
00027 #include <vector>
00028 #include <SFW/Object.H>
00029 
00030 extern "C" {
00031 #include <js.h>
00032 #include <jsint.h>
00033 }
00034 
00035 namespace SFW {
00036     /*********************************************************** JavaScriptType **/
00037     class JavaScriptType : public Object {
00038     
00039     protected:
00040     bool     owned;
00041     JSNode * jsn;
00042 
00043     friend   JavaScriptInterpreter;
00044     
00045     public:
00046         TYPE_INFO(SFW::JavaScriptType, SFW::Object);
00047         
00048     JavaScriptType();
00049     JavaScriptType(const JavaScriptType& o);
00050     JavaScriptType(JSNode& o, bool copy = true);
00051     JavaScriptType(const string &s);
00052     JavaScriptType(int i);
00053         JavaScriptType(bool b);
00054     JavaScriptType(double d);
00055     JavaScriptType(const JSTArray &a);
00056 
00057     virtual ~JavaScriptType();
00058 
00059     int      getJSType(void);
00060     bool     copyToI(JSType * t, JSInterpPtr i) const;
00061 
00062     JavaScriptType& JavaScriptType::operator= (const JavaScriptType& o);
00063 
00064     /* Conversions back to regular types */
00065     operator bool();
00066     operator string();
00067     operator int();
00068     operator double();
00069     operator JSTArray();
00070     };
00071 
00072 
00073     /**************************************************** JavaScriptByteCode **/
00074     class JavaScriptByteCode : public Object {
00075     unsigned int   len;
00076     unsigned char *data;
00077 
00078     friend JavaScriptByteCode
00079     JavaScriptInterpreter::compile(const string &code);
00080     friend JavaScriptByteCode
00081     JavaScriptInterpreter::exec(const JavaScriptByteCode &jsbc);
00082 
00083     public:
00084         TYPE_INFO(SFW::JavaScriptByteCode, SFW::Object);
00085         
00086     JavaScriptByteCode();
00087     JavaScriptByteCode(const JavaScriptByteCode &jsbc);
00088     ~JavaScriptByteCode();
00089 
00090     unsigned int getLength();
00091 
00092     JavaScriptByteCode& operator= (const JavaScriptByteCode &_jsbc);
00093     };
00094 }
00095 
00096 #endif /* JSTYPE_H */

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