Code

change API: separate functions creating a blur filter, one for a given item, another...
[inkscape.git] / src / dom / jsdombind.h
1 #ifndef __JSDOMBIND_H__
2 #define __JSDOMBIND_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 "jsengine.h"
36 namespace org
37 {
38 namespace w3c
39 {
40 namespace dom
41 {
44 /**
45  * Wrap the W3C DOM Core classes around a JavascriptEngine.
46  */
47 class JavascriptDOMBinder
48 {
49 public:
51     /**
52      *  Constructor
53      */
54     JavascriptDOMBinder(JavascriptEngine &someEngine)
55                   : engine(someEngine)
56         { init(); }
59     /**
60      *  Destructor
61      */
62     virtual ~JavascriptDOMBinder()
63         {  }
66     JSObject *wrapDocument(const Document *doc);
68     /**
69      *  Bind with the basic DOM classes
70      */
71     bool createClasses();
73     JSObject *proto_Attr;
74     JSObject *proto_CDATASection;
75     JSObject *proto_CharacterData;
76     JSObject *proto_Comment;
77     JSObject *proto_Document;
78     JSObject *proto_DocumentFragment;
79     JSObject *proto_DocumentType;
80     JSObject *proto_DOMConfiguration;
81     JSObject *proto_DOMError;
82     JSObject *proto_DOMException;
83     JSObject *proto_DOMImplementation;
84     JSObject *proto_DOMImplementationList;
85     JSObject *proto_DOMImplementationRegistry;
86     JSObject *proto_DOMImplementationSource;
87     JSObject *proto_DOMLocator;
88     JSObject *proto_DOMStringList;
89     JSObject *proto_Element;
90     JSObject *proto_Entity;
91     JSObject *proto_EntityReference;
92     JSObject *proto_NamedNodeMap;
93     JSObject *proto_NameList;
94     JSObject *proto_Node;
95     JSObject *proto_NodeList;
96     JSObject *proto_Notation;
97     JSObject *proto_ProcessingInstruction;
98     JSObject *proto_Text;
99     JSObject *proto_TypeInfo;
100     JSObject *proto_UserDataHandler;
102 private:
104     void init()
105         {
106         rt        = engine.getRuntime();
107         cx        = engine.getContext();
108         globalObj = engine.getGlobalObject();
109         }
110     
111     /**
112      *  Assignment operator.  Let's keep this private for now,
113      *  as we want one Spidermonkey runtime per c++ shell     
114      */
115     JavascriptDOMBinder &operator=(const JavascriptDOMBinder &other)
116         { assign(other); return *this; }
118     void assign(const JavascriptDOMBinder &other)
119         {
120         rt        = other.rt;
121         cx        = other.cx;
122         globalObj = other.globalObj;
123         }
126     /**
127      * Ouput a printf-formatted error message
128      */
129     void error(char *fmt, ...);
131     /**
132      * Ouput a printf-formatted error message
133      */
134     void trace(char *fmt, ...);
136     JSRuntime *rt;
138     JSContext *cx;
140     JSObject *globalObj;
142     
143     
144     JavascriptEngine &engine;
145 };
149 } // namespace dom
150 } // namespace w3c
151 } // namespace org
154 #endif /* __JSDOMBIND_H__ */