Added:
trunk/gom/include/xpgom/xgDocument.hh
trunk/gom/include/xpgom/xgNode.hh
trunk/gom/include/xpgom/xgObject.hh
trunk/gom/src/xpgom/xgDocument.cc
trunk/gom/src/xpgom/xgNode.cc
trunk/gom/src/xpgom/xgObject.cc
Modified:
trunk/gom/ChangeLog
trunk/gom/include/gommacros.h
trunk/gom/include/xpgom/Makefile.inc
trunk/gom/include/xpgom/xgDOMImplementation.hh
trunk/gom/src/libgom/gomdom.c
trunk/gom/src/xpgom/Makefile.inc
trunk/gom/src/xpgom/xgDOMImplementation.cc
trunk/gom/src/xpgom/xgGomModule.cc
trunk/gom/src/xpgom/xpgom.js
Log:
2008-08-04 jacob berkman <ja...@ilovegom.org>
* src/xpgom/xgGomModule.cc: xgDOMImplementation has an init
function now
* src/xpgom/xgObject.cc (xgObject): unref our object
(Init): if we don't yet have an object, but do have a type,
try creating an object; then check that our object implements
our required interfaces
* src/xpgom/xgNode.cc (GetNodeName, GetNodeType): implement
* src/xpgom/xgDOMImplementation.cc (Init): check that our
GObject implements GOM_TYPE_DOM_IMPLEMENTATION
(HasFeature): use new macros
(CreateDocument): implement
* src/libgom/gomdom.c (gom_dom_class_init): there's really no
reason to make this a singleton object
* include/gommacros.h (GOM_ASTRING_TO_GSTRING)
(GOM_GERROR_TO_NSRESULT, GOM_RETURN_NSRESULT_FROM_GERROR)
(GOM_XGO_CHECK_INIALIZED): some macros useful for xpcom
objects
* src/xpgom/xgDocument.cc:
* include/xpgom/xgDocument.hh: xpcom binding for GomDocument
interface
* include/xpgom/xgObject.hh (class xgObject): base class for
xpcom objects proxying a GObject
* include/xpgom/xgNode.hh: xpcom binding for GomNode interface
* include/xpgom/xgDOMImplementation.hh
(nsIDOMDOMImplementation): abstract some common bits to xgObject
Modified: trunk/gom/ChangeLog
==============================================================================
--- trunk/gom/ChangeLog (original)
+++ trunk/gom/ChangeLog Mon Aug 4 22:42:50 2008
@@ -1,3 +1,40 @@
+2008-08-04 jacob berkman <ja...@ilovegom.org>
+
+ * src/xpgom/xgGomModule.cc: xgDOMImplementation has an init
+ function now
+
+ * src/xpgom/xgObject.cc (xgObject): unref our object
+ (Init): if we don't yet have an object, but do have a type,
+ try creating an object; then check that our object implements
+ our required interfaces
+
+ * src/xpgom/xgNode.cc (GetNodeName, GetNodeType): implement
+
+ * src/xpgom/xgDOMImplementation.cc (Init): check that our
+ GObject implements GOM_TYPE_DOM_IMPLEMENTATION
+ (HasFeature): use new macros
+ (CreateDocument): implement
+
+ * src/libgom/gomdom.c (gom_dom_class_init): there's really no
+ reason to make this a singleton object
+
+ * include/gommacros.h (GOM_ASTRING_TO_GSTRING)
+ (GOM_GERROR_TO_NSRESULT, GOM_RETURN_NSRESULT_FROM_GERROR)
+ (GOM_XGO_CHECK_INIALIZED): some macros useful for xpcom
+ objects
+
+ * src/xpgom/xgDocument.cc:
+ * include/xpgom/xgDocument.hh: xpcom binding for GomDocument
+ interface
+
+ * include/xpgom/xgObject.hh (class xgObject): base class for
+ xpcom objects proxying a GObject
+
+ * include/xpgom/xgNode.hh: xpcom binding for GomNode interface
+
+ * include/xpgom/xgDOMImplementation.hh
+ (nsIDOMDOMImplementation): abstract some common bits to xgObject
+
2008-08-01 jacob berkman <ja...@ilovegom.org>
* src/xpgom/xgGomModule.cc (xgGomRegistrationProc): try to
Modified: trunk/gom/include/gommacros.h
==============================================================================
--- trunk/gom/include/gommacros.h (original)
+++ trunk/gom/include/gommacros.h Mon Aug 4 22:42:50 2008
@@ -24,10 +24,6 @@
#ifndef GOM_MACROS_H
#define GOM_MACROS_H
-#include <glib/gmacros.h>
-
-G_BEGIN_DECLS
-
#define JSVAL_CHARS(jval) (JS_GetStringBytes (JSVAL_TO_STRING (jval)))
#define GOM_NOT_IMPLEMENTED (g_message (G_STRLOC": Not implemented yet."))
@@ -163,6 +159,31 @@
#define GOM_UNSET_WEAK(p) GOM_SET_WEAK(p, NULL)
-G_END_DECLS
+#define GOM_ASTRING_TO_GSTRING(_aCString, _aString, _errval)
\
+ const char *_aCString;
\
+ {
\
+ nsCAutoString _aCString##String;
\
+ if (NS_FAILED (NS_UTF16ToCString (_aString,
NS_CSTRING_ENCODING_UTF8, _aCString##String))) { \
+ return _errval;
\
+ }
\
+ _aCString = _aCString##String.get();
\
+ }
+
+#define GOM_GERROR_TO_NSRESULT(_err) \
+ (_err->domain == GOM_DOM_EXCEPTION_ERROR) ?
NS_ERROR_GENERATE_FAILURE (NS_ERROR_MODULE_DOM, _err->code) : NS_ERROR_UNEXPECTED;
+#define GOM_RETURN_NSRESULT_FROM_GERROR(_err) \
+ G_STMT_START { \
+ nsresult _rv = GOM_GERROR_TO_NSRESULT(_err); \
+ g_error_free (_err); \
+ return _rv; \
+ } G_STMT_END
+
+#define GOM_XGO_CHECK_INIALIZED(t)
\
+ G_STMT_START {
\
+ if (!mObject || !g_type_is_a (G_OBJECT_TYPE (mObject), t)) {
\
+ return NS_ERROR_NOT_INITIALIZED;
\
+ }
\
+ } G_STMT_END
+
#endif /* GOM_MACROS_H */
Modified: trunk/gom/include/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/include/xpgom/Makefile.inc (original)
+++ trunk/gom/include/xpgom/Makefile.inc Mon Aug 4 22:42:50 2008
@@ -3,4 +3,6 @@
# xpgomincludedir := $(includedir)/gom-0/xpgom
# xpgominclude_HEADERS :=
noinst_HEADERS += xgDOMImplementation.hh
-
+noinst_HEADERS += xgDocument.hh
+noinst_HEADERS += xgNode.hh
+noinst_HEADERS += xgObject.hh
Modified: trunk/gom/include/xpgom/xgDOMImplementation.hh
==============================================================================
--- trunk/gom/include/xpgom/xgDOMImplementation.hh (original)
+++ trunk/gom/include/xpgom/xgDOMImplementation.hh Mon Aug 4 22:42:50 2008
@@ -24,27 +24,28 @@
#ifndef XG_DOM_IMPLEMENTATION_HH
#define XG_DOM_IMPLEMENTATION_HH
-#include <nsIDOMDOMImplementation.h>
+#include "xpgom/xgObject.hh"
#include "gom/dom/gomdomimplementation.h"
+#include <nsIDOMDOMImplementation.h>
+
#define XG_DOMIMPLEMENTATION_CID_STR "4138BAA2-29BD-4D1C-9193-2D2254D4CA28"
#define XG_DOMIMPLEMENTATION_CID \
{ 0x4138BAA2, 0x29BD, 0x4D1C, { 0x91, 0x93, 0x2D, 0x22, 0x54, 0xD4,
0xCA, 0x28 } }
#define XG_DOMIMPLEMENTATION_CONTRACTID "@ilovegom.org/dom-implementation;1"
-class xgDOMImplementation : public nsIDOMDOMImplementation
+class xgDOMImplementation : protected xgObject,
+ public nsIDOMDOMImplementation
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDOMIMPLEMENTATION
- xgDOMImplementation();
+ xgDOMImplementation (GomDOMImplementation *aDom = NULL);
+ nsresult Init ();
private:
- ~xgDOMImplementation();
-
- GomDOMImplementation *gdom;
-protected:
+ ~xgDOMImplementation ();
};
#endif /* XG_DOM_IMPLEMENTATION_HH */
Added: trunk/gom/include/xpgom/xgDocument.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgDocument.hh Mon Aug 4 22:42:50 2008
@@ -0,0 +1,47 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining
a copy
+of this software and associated documentation files (the "Software"),
to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#ifndef XG_DOCUMENT_HH
+#define XG_DOCUMENT_HH
+
+#include "xpgom/xgNode.hh"
+#include "gom/dom/gomdocument.h"
+
+#include <nsIDOMDocument.h>
+
+class xgDocument : public xgNode,
+ public nsIDOMDocument
+{
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_FORWARD_NSIDOMNODE(xgNode::)
+ NS_DECL_NSIDOMDOCUMENT
+
+ xgDocument (GomDocument *aDoc = NULL);
+ nsresult Init();
+
+protected:
+ xgDocument (GomDocument *aDoc, GType aType);
+ ~xgDocument ();
+};
+
+#endif /* XG_DOCUMENT_HH */
Added: trunk/gom/include/xpgom/xgNode.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgNode.hh Mon Aug 4 22:42:50 2008
@@ -0,0 +1,46 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining
a copy
+of this software and associated documentation files (the "Software"),
to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#ifndef XG_NODE_HH
+#define XG_NODE_HH
+
+#include "xpgom/xgObject.hh"
+#include "gom/dom/gomnode.h"
+
+#include <nsIDOMNode.h>
+
+class xgNode : public xgObject,
+ public nsIDOMNode
+{
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDOMNODE
+
+ xgNode (GomNode *aNode = NULL);
+ nsresult Init();
+
+protected:
+ xgNode (GomNode *aNode, GType aType);
+ ~xgNode ();
+};
+
+#endif /* XG_NODE_HH */
Added: trunk/gom/include/xpgom/xgObject.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgObject.hh Mon Aug 4 22:42:50 2008
@@ -0,0 +1,44 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining
a copy
+of this software and associated documentation files (the "Software"),
to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#ifndef XG_OBJECT_HH
+#define XG_OBJECT_HH
+
+#include <nscore.h>
+#include <glib-object.h>
+
+class xgObject
+{
+protected:
+ xgObject (GObject *aObject = NULL, GType aType = 0);
+ ~xgObject ();
+
+ nsresult Init (GType *ifaces);
+
+ GObject *mObject;
+
+private:
+ GType mType;
+};
+
+#endif /* XG_OBJECT_HH */
Modified: trunk/gom/src/libgom/gomdom.c
==============================================================================
--- trunk/gom/src/libgom/gomdom.c (original)
+++ trunk/gom/src/libgom/gomdom.c Mon Aug 4 22:42:50 2008
@@ -115,40 +115,6 @@
GOM_IMPLEMENT (DOM_IMPLEMENTATION, dom_implementation, gom_dom);
G_DEFINE_TYPE_WITH_CODE (GomDOM, gom_dom, G_TYPE_OBJECT,
GOM_IMPLEMENT_INTERFACE (DOM_IMPLEMENTATION, dom_implementation, gom_dom));
-
-typedef struct {
- GType type;
- guint n_construct_properties;
- GObjectConstructParam *construct_properties;
-} OnceData;
-
-static gpointer
-gom_dom_once (gpointer data)
-{
- OnceData *d = data;
- return G_OBJECT_CLASS (gom_dom_parent_class)->constructor (
- d->type, d->n_construct_properties, d->construct_properties);
-}
-
-static GObject *
-gom_dom_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- static GOnce once = G_ONCE_INIT;
- OnceData data;
-
- data.type = type;
- data.n_construct_properties = n_construct_properties;
- data.construct_properties = construct_properties;
-
- return g_object_ref (g_once (&once, gom_dom_once, &data));
-}
-
static void gom_dom_init (GomDOM *dom) { }
-static void
-gom_dom_class_init (GomDOMClass *klass)
-{
- G_OBJECT_CLASS (klass)->constructor = gom_dom_constructor;
-}
+static void gom_dom_class_init (GomDOMClass *klass) { }
Modified: trunk/gom/src/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/src/xpgom/Makefile.inc (original)
+++ trunk/gom/src/xpgom/Makefile.inc Mon Aug 4 22:42:50 2008
@@ -3,8 +3,11 @@
lib_LTLIBRARIES += libxpgom.la
libxpgom_la_SOURCES :=
+libxpgom_la_SOURCES += src/xpgom/xgDocument.cc
libxpgom_la_SOURCES += src/xpgom/xgDOMImplementation.cc
libxpgom_la_SOURCES += src/xpgom/xgGomModule.cc
+libxpgom_la_SOURCES += src/xpgom/xgNode.cc
+libxpgom_la_SOURCES += src/xpgom/xgObject.cc
libxpgom_la_CPPFLAGS = -I$(top_builddir)/include
-I$(top_srcdir)/include $(XPGOM_CFLAGS)
libxpgom_la_CXXFLAGS = -fshort-wchar
Modified: trunk/gom/src/xpgom/xgDOMImplementation.cc
==============================================================================
--- trunk/gom/src/xpgom/xgDOMImplementation.cc (original)
+++ trunk/gom/src/xpgom/xgDOMImplementation.cc Mon Aug 4 22:42:50 2008
@@ -26,23 +26,38 @@
#include "xpgom/xgDOMImplementation.hh"
#include "gom/gomdom.h"
-#include <nsIClassInfoImpl.h>
+#include "xpgom/xgDocument.hh"
-#include <nsMemory.h>
+#include "gom/dom/gomdomexception.h"
+
+#include <nsCOMPtr.h>
#include <nsEmbedString.h>
+#include <nsIClassInfoImpl.h>
+#include <nsMemory.h>
-xgDOMImplementation::xgDOMImplementation()
- : gdom(GOM_DOM_IMPLEMENTATION (g_object_new (GOM_TYPE_DOM, NULL)))
+#include "gommacros.h"
+
+#define CHECK_INITIALIZED GOM_XGO_CHECK_INIALIZED (GOM_TYPE_DOM_IMPLEMENTATION)
+
+NS_IMPL_ISUPPORTS1_CI(xgDOMImplementation, nsIDOMDOMImplementation)
+
+xgDOMImplementation::xgDOMImplementation (GomDOMImplementation *aDom)
+ : xgObject (aDom ? G_OBJECT (aDom) : NULL, GOM_TYPE_DOM)
{
- g_object_add_weak_pointer (G_OBJECT (gdom), (gpointer *)&gdom);
}
-xgDOMImplementation::~xgDOMImplementation()
+xgDOMImplementation::~xgDOMImplementation ()
{
- g_object_unref (gdom);
}
-NS_IMPL_ISUPPORTS1_CI(xgDOMImplementation, nsIDOMDOMImplementation);
+nsresult
+xgDOMImplementation::Init ()
+{
+ GType ifaces[2];
+ ifaces[0] = GOM_TYPE_DOM_IMPLEMENTATION;
+ ifaces[1] = 0;
+ return xgObject::Init (ifaces);
+}
/* boolean hasFeature (in DOMString feature, in DOMString version); */
NS_IMETHODIMP
@@ -50,17 +65,12 @@
const nsAString &version,
PRBool *_retval)
{
- nsCAutoString cfeature;
- if (NS_FAILED (NS_UTF16ToCString (feature,
NS_CSTRING_ENCODING_UTF8, cfeature))) {
- return NS_ERROR_INVALID_ARG;
- }
-
- nsCAutoString cversion;
- if (NS_FAILED (NS_UTF16ToCString (version,
NS_CSTRING_ENCODING_UTF8, cversion))) {
- return NS_ERROR_INVALID_ARG;
- }
+ CHECK_INITIALIZED;
+ GOM_ASTRING_TO_GSTRING (feat, feature, NS_ERROR_INVALID_ARG);
+ GOM_ASTRING_TO_GSTRING (ver, version, NS_ERROR_INVALID_ARG);
- *_retval = gom_dom_implementation_has_feature (gdom,
cfeature.get(), cversion.get());
+ *_retval = gom_dom_implementation_has_feature
(GOM_DOM_IMPLEMENTATION (mObject),
+ feat, ver);
return NS_OK;
}
@@ -72,6 +82,7 @@
const nsAString &systemId,
nsIDOMDocumentType **_retval)
{
+ CHECK_INITIALIZED;
return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -82,5 +93,26 @@
nsIDOMDocumentType *doctype,
nsIDOMDocument **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ CHECK_INITIALIZED;
+ GOM_ASTRING_TO_GSTRING (nspace, namespaceURI, NS_ERROR_INVALID_ARG);
+ GOM_ASTRING_TO_GSTRING (qname, qualifiedName, NS_ERROR_INVALID_ARG);
+ g_return_val_if_fail (doctype == NULL, NS_ERROR_INVALID_ARG);
+
+ GError *error = NULL;
+ GomDocument *doc = gom_dom_implementation_create_document
(GOM_DOM_IMPLEMENTATION (mObject),
+ nspace, qname, NULL, &error);
+ if (!doc) {
+ // frees error
+ GOM_RETURN_NSRESULT_FROM_GERROR (error);
+ }
+
+ xgDocument *xDoc = new xgDocument (doc);
+ if (!xDoc) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ nsresult rv = xDoc->Init();
+ if (NS_SUCCEEDED (rv)) {
+ rv = CallQueryInterface (xDoc, _retval);
+ }
+ return rv;
}
Added: trunk/gom/src/xpgom/xgDocument.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgDocument.cc Mon Aug 4 22:42:50 2008
@@ -0,0 +1,169 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining
a copy
+of this software and associated documentation files (the "Software"),
to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#include "config.h"
+
+#include "xpgom/xgDocument.hh"
+#include "gom/gomdoc.h"
+
+#include "gommacros.h"
+
+#define CHECK_INITIALIZED GOM_XGO_CHECK_INIALIZED (GOM_TYPE_DOCUMENT)
+
+NS_IMPL_ISUPPORTS_INHERITED1(xgDocument, xgNode, nsIDOMDocument)
+
+xgDocument::xgDocument (GomDocument *aDoc) : xgNode (aDoc ? GOM_NODE
(aDoc) : NULL, GOM_TYPE_DOC)
+{
+}
+
+xgDocument::xgDocument (GomDocument *aDoc, GType aType) : xgNode
(aDoc ? GOM_NODE (aDoc) : NULL, aType)
+{
+}
+
+nsresult
+xgDocument::Init()
+{
+ GType ifaces[2];
+ ifaces[0] = GOM_TYPE_DOCUMENT;
+ ifaces[1] = 0;
+ return xgObject::Init (ifaces);
+}
+
+/* readonly attribute nsIDOMDocumentType doctype; */
+NS_IMETHODIMP xgDocument::GetDoctype(nsIDOMDocumentType * *aDoctype)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMDOMImplementation implementation; */
+NS_IMETHODIMP xgDocument::GetImplementation(nsIDOMDOMImplementation * *aImplementation)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMElement documentElement; */
+NS_IMETHODIMP xgDocument::GetDocumentElement(nsIDOMElement * *aDocumentElement)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMElement createElement (in DOMString tagName) raises
(DOMException); */
+NS_IMETHODIMP xgDocument::CreateElement(const nsAString & tagName,
nsIDOMElement **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMDocumentFragment createDocumentFragment (); */
+NS_IMETHODIMP
xgDocument::CreateDocumentFragment(nsIDOMDocumentFragment **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMText createTextNode (in DOMString data); */
+NS_IMETHODIMP xgDocument::CreateTextNode(const nsAString & data,
nsIDOMText **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMComment createComment (in DOMString data); */
+NS_IMETHODIMP xgDocument::CreateComment(const nsAString & data,
nsIDOMComment **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMCDATASection createCDATASection (in DOMString data) raises
(DOMException); */
+NS_IMETHODIMP xgDocument::CreateCDATASection(const nsAString & data,
nsIDOMCDATASection **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMProcessingInstruction createProcessingInstruction (in
DOMString target, in DOMString data) raises (DOMException); */
+NS_IMETHODIMP xgDocument::CreateProcessingInstruction(const nsAString
& target, const nsAString & data, nsIDOMProcessingInstruction **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMAttr createAttribute (in DOMString name) raises
(DOMException); */
+NS_IMETHODIMP xgDocument::CreateAttribute(const nsAString & name,
nsIDOMAttr **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMEntityReference createEntityReference (in DOMString name)
raises (DOMException); */
+NS_IMETHODIMP xgDocument::CreateEntityReference(const nsAString &
name, nsIDOMEntityReference **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNodeList getElementsByTagName (in DOMString tagname); */
+NS_IMETHODIMP xgDocument::GetElementsByTagName(const nsAString &
tagname, nsIDOMNodeList **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNode importNode (in nsIDOMNode importedNode, in boolean deep)
raises (DOMException); */
+NS_IMETHODIMP xgDocument::ImportNode(nsIDOMNode *importedNode, PRBool
deep, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMElement createElementNS (in DOMString namespaceURI, in
DOMString qualifiedName) raises (DOMException); */
+NS_IMETHODIMP xgDocument::CreateElementNS(const nsAString &
namespaceURI, const nsAString & qualifiedName, nsIDOMElement **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMAttr createAttributeNS (in DOMString namespaceURI, in
DOMString qualifiedName) raises (DOMException); */
+NS_IMETHODIMP xgDocument::CreateAttributeNS(const nsAString &
namespaceURI, const nsAString & qualifiedName, nsIDOMAttr **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNodeList getElementsByTagNameNS (in DOMString namespaceURI,
in DOMString localName); */
+NS_IMETHODIMP xgDocument::GetElementsByTagNameNS(const nsAString &
namespaceURI, const nsAString & localName, nsIDOMNodeList **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMElement getElementById (in DOMString elementId); */
+NS_IMETHODIMP xgDocument::GetElementById(const nsAString & elementId,
nsIDOMElement **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
Modified: trunk/gom/src/xpgom/xgGomModule.cc
==============================================================================
--- trunk/gom/src/xpgom/xgGomModule.cc (original)
+++ trunk/gom/src/xpgom/xgGomModule.cc Mon Aug 4 22:42:50 2008
@@ -32,7 +32,7 @@
#include <nsIFile.h>
#include <nsStringAPI.h>
-NS_GENERIC_FACTORY_CONSTRUCTOR(xgDOMImplementation);
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(xgDOMImplementation, Init);
static NS_METHOD
xgGomRegistrationProc (nsIComponentManager *aCompMgr,
Added: trunk/gom/src/xpgom/xgNode.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgNode.cc Mon Aug 4 22:42:50 2008
@@ -0,0 +1,236 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining
a copy
+of this software and associated documentation files (the "Software"),
to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#include "config.h"
+
+#include "xpgom/xgNode.hh"
+
+#include "gom/gomnoodle.h"
+
+#include <nsStringAPI.h>
+
+#include "gommacros.h"
+
+#define CHECK_INITIALIZED GOM_XGO_CHECK_INIALIZED (GOM_TYPE_NODE)
+
+NS_IMPL_ISUPPORTS1 (xgNode, nsIDOMNode)
+
+xgNode::xgNode (GomNode *aNode) : xgObject (aNode ? G_OBJECT (aNode) :
NULL, GOM_TYPE_NOODLE)
+{
+}
+
+xgNode::xgNode (GomNode *aNode, GType aType) : xgObject (aNode ?
G_OBJECT (aNode) : NULL, aType)
+{
+}
+
+xgNode::~xgNode ()
+{
+}
+
+nsresult
+xgNode::Init()
+{
+ GType ifaces[2];
+ ifaces[0] = GOM_TYPE_NODE;
+ ifaces[1] = 0;
+ return xgObject::Init (ifaces);
+}
+
+/* readonly attribute DOMString nodeName; */
+NS_IMETHODIMP xgNode::GetNodeName(nsAString & aNodeName)
+{
+ CHECK_INITIALIZED;
+ char *s;
+ g_object_get (mObject, "node-name", &s, NULL);
+ nsCAutoString cstr(s);
+ g_free (s);
+ CopyUTF8toUTF16 (cstr, aNodeName);
+ return NS_OK;
+}
+
+/* attribute DOMString nodeValue; */
+NS_IMETHODIMP xgNode::GetNodeValue(nsAString & aNodeValue)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP xgNode::SetNodeValue(const nsAString & aNodeValue)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute unsigned short nodeType; */
+NS_IMETHODIMP xgNode::GetNodeType(PRUint16 *aNodeType)
+{
+ CHECK_INITIALIZED;
+ GomNodeType t;
+ g_object_get (mObject, "node-type", &t, NULL);
+ *aNodeType = t;
+ return NS_OK;
+}
+
+/* readonly attribute nsIDOMNode parentNode; */
+NS_IMETHODIMP xgNode::GetParentNode(nsIDOMNode * *aParentNode)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMNodeList childNodes; */
+NS_IMETHODIMP xgNode::GetChildNodes(nsIDOMNodeList * *aChildNodes)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMNode firstChild; */
+NS_IMETHODIMP xgNode::GetFirstChild(nsIDOMNode * *aFirstChild)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMNode lastChild; */
+NS_IMETHODIMP xgNode::GetLastChild(nsIDOMNode * *aLastChild)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMNode previousSibling; */
+NS_IMETHODIMP xgNode::GetPreviousSibling(nsIDOMNode * *aPreviousSibling)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMNode nextSibling; */
+NS_IMETHODIMP xgNode::GetNextSibling(nsIDOMNode * *aNextSibling)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMNamedNodeMap attributes; */
+NS_IMETHODIMP xgNode::GetAttributes(nsIDOMNamedNodeMap * *aAttributes)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIDOMDocument ownerDocument; */
+NS_IMETHODIMP xgNode::GetOwnerDocument(nsIDOMDocument * *aOwnerDocument)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNode insertBefore (in nsIDOMNode newChild, in nsIDOMNode
refChild) raises (DOMException); */
+NS_IMETHODIMP xgNode::InsertBefore(nsIDOMNode *newChild, nsIDOMNode
*refChild, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNode replaceChild (in nsIDOMNode newChild, in nsIDOMNode
oldChild) raises (DOMException); */
+NS_IMETHODIMP xgNode::ReplaceChild(nsIDOMNode *newChild, nsIDOMNode
*oldChild, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNode removeChild (in nsIDOMNode oldChild) raises
(DOMException); */
+NS_IMETHODIMP xgNode::RemoveChild(nsIDOMNode *oldChild, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNode appendChild (in nsIDOMNode newChild) raises
(DOMException); */
+NS_IMETHODIMP xgNode::AppendChild(nsIDOMNode *newChild, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean hasChildNodes (); */
+NS_IMETHODIMP xgNode::HasChildNodes(PRBool *_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNode cloneNode (in boolean deep); */
+NS_IMETHODIMP xgNode::CloneNode(PRBool deep, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void normalize (); */
+NS_IMETHODIMP xgNode::Normalize()
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean isSupported (in DOMString feature, in DOMString version); */
+NS_IMETHODIMP xgNode::IsSupported(const nsAString & feature, const
nsAString & version, PRBool *_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute DOMString namespaceURI; */
+NS_IMETHODIMP xgNode::GetNamespaceURI(nsAString & aNamespaceURI)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString prefix; */
+NS_IMETHODIMP xgNode::GetPrefix(nsAString & aPrefix)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP xgNode::SetPrefix(const nsAString & aPrefix)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute DOMString localName; */
+NS_IMETHODIMP xgNode::GetLocalName(nsAString & aLocalName)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean hasAttributes (); */
+NS_IMETHODIMP xgNode::HasAttributes(PRBool *_retval)
+{
+ CHECK_INITIALIZED;
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
Added: trunk/gom/src/xpgom/xgObject.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgObject.cc Mon Aug 4 22:42:50 2008
@@ -0,0 +1,64 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining
a copy
+of this software and associated documentation files (the "Software"),
to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#include "config.h"
+
+#include "xpgom/xgObject.hh"
+
+xgObject::xgObject (GObject *aObject, GType aType)
+ : mObject (aObject ? (GObject *)g_object_ref (aObject) : aObject)
+ , mType(aType)
+{
+}
+
+xgObject::~xgObject ()
+{
+ if (mObject) {
+ g_object_unref (mObject);
+ }
+}
+
+nsresult
+xgObject::Init (GType *ifaces)
+{
+ if (!mObject) {
+ if (mType) {
+ mObject = (GObject *)g_object_new (mType, NULL);
+ if (!mObject) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+ }
+ for (GType t = G_OBJECT_TYPE (mObject);
+ *ifaces;
+ ++ifaces) {
+ if (!g_type_is_a (t, *ifaces)) {
+ g_object_unref (mObject);
+ mObject = NULL;
+ return NS_ERROR_NO_INTERFACE;
+ }
+ }
+ return NS_OK;
+}
Modified: trunk/gom/src/xpgom/xpgom.js
==============================================================================
--- trunk/gom/src/xpgom/xpgom.js (original)
+++ trunk/gom/src/xpgom/xpgom.js Mon Aug 4 22:42:50 2008
@@ -1,4 +1,7 @@
(function () {
print (dom = Components.classes["@ilovegom.org/dom-implementation;1"].createInstance(Components.interfaces.nsIDOMDOMImplementation));
print (dom.hasFeature ("xml", "1.0"));
+ print (doc = dom.createDocument (null, "gom", null));
+ print (doc.nodeType);
+ print (doc.nodeName);
})();