Code

New files. These will be the basis for ECMA-DOM binding using Spidermonkey.
[inkscape.git] / src / dom / jsengine.h
1 #ifndef __JSENGINE_H__
2 #define __JSENGINE_H__
3 /**
4  * Phoebe DOM Implementation.
5  *
6  * This is a C++ approximation of the W3C DOM model, which follows
7  * fairly closely the specifications in the various .idl files, copies of
8  * which are provided for reference.  Most important is this one:
9  *
10  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11  *
12  * Authors:
13  *   Bob Jamison
14  *
15  * Copyright (C) 2006 Bob Jamison
16  *
17  *  This library is free software; you can redistribute it and/or
18  *  modify it under the terms of the GNU Lesser General Public
19  *  License as published by the Free Software Foundation; either
20  *  version 2.1 of the License, or (at your option) any later version.
21  *
22  *  This library is distributed in the hope that it will be useful,
23  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  *  Lesser General Public License for more details.
26  *
27  *  You should have received a copy of the GNU Lesser General Public
28  *  License along with this library; if not, write to the Free Software
29  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30  */
33 #include "js/jsapi.h"
36 namespace org
37 {
38 namespace w3c
39 {
40 namespace dom
41 {
43 /**
44  *
45  */
46 class JavascriptEngine
47 {
48 public:
50     /**
51      *
52      */
53     JavascriptEngine()
54         { init(); }
56     /**
57      *
58      */
59     JavascriptEngine(const JavascriptEngine &other)
60         { assign(other); }
62     /**
63      *
64      */
65     JavascriptEngine &operator=(const JavascriptEngine &other)
66         { assign(other); return *this; }
68     /**
69      *
70      */
71     bool startup();
73     /**
74      *
75      */
76     bool shutdown();
78     /**
79      *
80      */
81     virtual ~JavascriptEngine()
82         {}
85 private:
87     void init()
88         {
89         rt        = NULL;
90         cx        = NULL;
91         globalObj = NULL;
92         }
93     
94     void assign(const JavascriptEngine &other)
95         {
96         rt        = other.rt;
97         cx        = other.cx;
98         globalObj = other.globalObj;
99         }
101     /**
102      *
103      */
104     bool createClasses();
106     void error(char *fmt, ...);
107     void trace(char *fmt, ...);
109     JSRuntime *rt;
111     JSContext *cx;
113     JSObject *globalObj;
115 };
119 } // namespace dom
120 } // namespace w3c
121 } // namespace org
124 #endif /* __JSENGINE_H__ */