Added:
trunk/gom/include/xpgom/gomwrappedattr.hh
trunk/gom/include/xpgom/gomwrappednamednodemap.hh
trunk/gom/include/xpgom/xgNodeList.hh
trunk/gom/src/xpgom/gomwrappedattr.cc
trunk/gom/src/xpgom/gomwrappednamednodemap.cc
trunk/gom/src/xpgom/xgNodeList.cc
Modified:
trunk/gom/ChangeLog
trunk/gom/examples/console.gom
trunk/gom/include/gom/dom/gomnode.h
trunk/gom/include/gommacros.h
trunk/gom/include/xpgom/Makefile.inc
trunk/gom/include/xpgom/xgWrapped.hh
trunk/gom/src/libgom/gomdoc.c
trunk/gom/src/xpgom/Makefile.inc
trunk/gom/src/xpgom/gomwrapped.cc
trunk/gom/src/xpgom/gomwrappeddocument.cc
trunk/gom/src/xpgom/gomwrappedelement.cc
trunk/gom/src/xpgom/gomwrappednode.cc
trunk/gom/src/xpgom/xgDOMImplementation.cc
trunk/gom/src/xpgom/xgDocument.cc
trunk/gom/src/xpgom/xgElement.cc
trunk/gom/src/xpgom/xgGomModule.cc
trunk/gom/src/xpgom/xgNode.cc
trunk/gom/src/xpgom/xgWrapped.cc
Log:
2008-08-11 jacob berkman <ja...@ilovegom.org>
* include/gommacros.h (XG_RETURN_NOT_IMPLEMENTED): macro to
return not implemented for xpcom funcs
(GOM_RETURN_NSRESULT_FROM_GERROR): now only executes if error
is set
(XG_WRAPPED_IMPL_GET_OBJECT): implement an attribute getter
for objects
(XG_WRAPPED_IMPL_GET_STRING): ditto for strings
(XG_WRAPPED_IMPL_GET_SIMPLE, XG_WRAPPED_IMPL_GET_ENUM)
(XG_WRAPPED_IMPL_GET_BOOL, XG_WRAPPED_IMPL_GET_ULONG): etc
(GOM_WRAPPED_GET_OBJECT): set a GValue based on an xpcom
getter function
(GOM_WRAPPED_GET_ENUM, GOM_WRAPPED_GET_STRING)
(GOM_WRAPPED_GET_BOOL, GOM_WRAPPED_GET_ULONG): ditto
* src/xpgom/xgGomModule.cc (nsGomModuleConstructor): add new
wrapper types
* src/xpgom/xgNode.cc: implement attribute getters
* src/xpgom/xgNodeList.cc: xpcom wrapper for GomNodeList
* src/xpgom/gomwrappedelement.cc
(gom_wrapped_element_get_property): implement attribute getter
* src/xpgom/gomwrappednamednodemap.cc: GObject
nsIDOMNamedNodeMap wrapper
* src/xpgom/xgDocument.cc: implement all attribute getters
* src/xpgom/gomwrappednode.cc (gom_wrapped_node_get_property):
implement all properties
* src/xpgom/gomwrapped.cc (gom_wrap_xpcom): use
QueryInterface() to find the most highly specific interface
this object supports
(gom_wrap_g_object): we don't need to do that here, since com
objects will be using query interface itself (although perhaps
we need to do a custom implementation of that...)
* src/xpgom/gomwrappeddocument.cc
(gom_wrapped_document_get_property): implement more properties
* src/xpgom/xgWrapped.cc (~xgWrapped): warn if we had an
object, but it was destroyed
(Init): also grab a weak ref of our object to catch destroyed
objects
* src/xpgom/gomwrappedattr.cc: GObject nsIDOMAttr wrapper
* src/libgom/gomdoc.c (gom_doc_import_node): apply specified
attrs when importing elements
Modified: trunk/gom/ChangeLog
==============================================================================
--- trunk/gom/ChangeLog (original)
+++ trunk/gom/ChangeLog Mon Aug 11 00:34:29 2008
@@ -1,3 +1,57 @@
+2008-08-11 jacob berkman <ja...@ilovegom.org>
+
+ * include/gommacros.h (XG_RETURN_NOT_IMPLEMENTED): macro to
+ return not implemented for xpcom funcs
+ (GOM_RETURN_NSRESULT_FROM_GERROR): now only executes if error
+ is set
+ (XG_WRAPPED_IMPL_GET_OBJECT): implement an attribute getter
+ for objects
+ (XG_WRAPPED_IMPL_GET_STRING): ditto for strings
+ (XG_WRAPPED_IMPL_GET_SIMPLE, XG_WRAPPED_IMPL_GET_ENUM)
+ (XG_WRAPPED_IMPL_GET_BOOL, XG_WRAPPED_IMPL_GET_ULONG): etc
+ (GOM_WRAPPED_GET_OBJECT): set a GValue based on an xpcom
+ getter function
+ (GOM_WRAPPED_GET_ENUM, GOM_WRAPPED_GET_STRING)
+ (GOM_WRAPPED_GET_BOOL, GOM_WRAPPED_GET_ULONG): ditto
+
+ * src/xpgom/xgGomModule.cc (nsGomModuleConstructor): add new
+ wrapper types
+
+ * src/xpgom/xgNode.cc: implement attribute getters
+
+ * src/xpgom/xgNodeList.cc: xpcom wrapper for GomNodeList
+
+ * src/xpgom/gomwrappedelement.cc
+ (gom_wrapped_element_get_property): implement attribute getter
+
+ * src/xpgom/gomwrappednamednodemap.cc: GObject
+ nsIDOMNamedNodeMap wrapper
+
+ * src/xpgom/xgDocument.cc: implement all attribute getters
+
+ * src/xpgom/gomwrappednode.cc (gom_wrapped_node_get_property):
+ implement all properties
+
+ * src/xpgom/gomwrapped.cc (gom_wrap_xpcom): use
+ QueryInterface() to find the most highly specific interface
+ this object supports
+ (gom_wrap_g_object): we don't need to do that here, since com
+ objects will be using query interface itself (although perhaps
+ we need to do a custom implementation of that...)
+
+ * src/xpgom/gomwrappeddocument.cc
+ (gom_wrapped_document_get_property): implement more properties
+
+ * src/xpgom/xgWrapped.cc (~xgWrapped): warn if we had an
+ object, but it was destroyed
+ (Init): also grab a weak ref of our object to catch destroyed
+ objects
+
+ * src/xpgom/gomwrappedattr.cc: GObject nsIDOMAttr wrapper
+
+ * src/libgom/gomdoc.c (gom_doc_import_node): apply specified
+ attrs when importing elements
+
2008-08-09 jacob berkman <ja...@ilovegom.org>
* src/xpgom/xgElement.cc: an nsIElement wrapper of a
Modified: trunk/gom/examples/console.gom
==============================================================================
--- trunk/gom/examples/console.gom (original)
+++ trunk/gom/examples/console.gom Mon Aug 11 00:34:29 2008
@@ -20,9 +20,6 @@
<GtkEntry id="entry" expand="true" fill="true"/>
<GtkLabel id="x" expand="false" fill="false"/>
<GtkLabel id="y" expand="false" fill="false"/>
-<!--
- <GtkButton id="go" label="Go" expand="false" fill="false"/>
- -->
</GtkHBox>
</GtkVBox>
</GtkWindow>
Modified: trunk/gom/include/gom/dom/gomnode.h
==============================================================================
--- trunk/gom/include/gom/dom/gomnode.h (original)
+++ trunk/gom/include/gom/dom/gomnode.h Mon Aug 11 00:34:29 2008
@@ -79,22 +79,22 @@
GTypeInterface parent;
GomNode *(*insert_before) (GomNode *node,
- GomNode *new_child,
- GomNode *ref_child,
- GError **error);
+ GomNode *new_child,
+ GomNode *ref_child,
+ GError **error);
GomNode *(*replace_child) (GomNode *node,
- GomNode *new_child,
- GomNode *ref_child,
- GError **error);
+ GomNode *new_child,
+ GomNode *ref_child,
+ GError **error);
GomNode *(*remove_child) (GomNode *node,
- GomNode *old_child,
- GError **error);
+ GomNode *old_child,
+ GError **error);
GomNode *(*append_child) (GomNode *node,
- GomNode *new_child,
- GError **error);
+ GomNode *new_child,
+ GError **error);
gboolean (*has_child_nodes) (GomNode *node);
@@ -115,9 +115,9 @@
GomNode *gom_node_insert_before (GomNode *node, GomNode *new_child,
GomNode *ref_child, GError **error);
GomNode *gom_node_replace_child (GomNode *node, GomNode *new_child,
GomNode *ref_child, GError **error);
GomNode *gom_node_remove_child (GomNode *node, GomNode *old_child, GError
**error);
-GomNode *gom_node_append_child (GomNode *node, GomNode *new_child,
GError **error);
+GomNode *gom_node_append_child (GomNode *node, GomNode *new_child, GError
**error);
-gboolean gom_node_has_child_nodes (GomNode *node);
+gboolean gom_node_has_child_nodes (GomNode *node);
GomNode *gom_node_clone_node (GomNode *node, gboolean deep);
Modified: trunk/gom/include/gommacros.h
==============================================================================
--- trunk/gom/include/gommacros.h (original)
+++ trunk/gom/include/gommacros.h Mon Aug 11 00:34:29 2008
@@ -54,6 +54,11 @@
(g_message (GOM_LOC ("%s.%s not implemented"), \
g_type_name (pspec->owner_type), pspec->name))
+#define XG_RETURN_NOT_IMPLEMENTED \
+ G_STMT_START { \
+ GOM_NOT_IMPLEMENTED; \
+ return NS_ERROR_NOT_IMPLEMENTED; \
+ } G_STMT_END
#define GOM_DEFINE_QUARK(n) \
static gpointer \
@@ -185,34 +190,92 @@
NS_UTF16ToCString (_aString, NS_CSTRING_ENCODING_UTF8,
_aCString##String); \
const char *_aCString = _aCString##String.get();
+#define GOM_GSTRING_TO_ASTRING_RETURN(_aString, _aCString, _errval) \
+ G_STMT_START { \
+ nsCAutoString _aCString##String (_aCString); \
+ if (NS_FAILED (NS_CStringToUTF16 (_aCString##String,
NS_CSTRING_ENCODING_UTF8, _aString))) { \
+ g_free (_aCString); \
+ return _errval; \
+ } \
+ g_free (_aCString); \
+ } G_STMT_END
+
#define GOM_RETURN_NSRESULT_FROM_GERROR(_err) \
G_STMT_START { \
- nsresult _rv = NS_ERROR_UNEXPECTED; \
- if (_err->domain == GOM_DOM_EXCEPTION_ERROR) { \
- if (_err->code < 87000) { \
- _rv = NS_ERROR_GENERATE_FAILURE (NS_ERROR_MODULE_DOM,
_err->code); \
- } else { \
- switch (_err->code) { \
- case GOM_NO_INTERFACE_ERR: \
- _rv = NS_ERROR_NOT_INITIALIZED; \
- break; \
- case GOM_NOT_IMPLEMENTED_ERR: \
- _rv = NS_ERROR_NOT_IMPLEMENTED; \
+ if (_err) { \
+ nsresult _rv = NS_ERROR_UNEXPECTED; \
+ if (_err->domain == GOM_DOM_EXCEPTION_ERROR) { \
+ if (_err->code < 87000) { \
+ _rv = NS_ERROR_GENERATE_FAILURE (NS_ERROR_MODULE_DOM,
_err->code); \
+ } else { \
+ switch (_err->code) { \
+ case GOM_NO_INTERFACE_ERR: \
+ _rv = NS_ERROR_NOT_INITIALIZED; \
break; \
+ case GOM_NOT_IMPLEMENTED_ERR: \
+ _rv = NS_ERROR_NOT_IMPLEMENTED; \
+ break; \
+ } \
} \
} \
+ g_error_free (_err); \
+ return _rv; \
} \
- g_error_free (_err); \
- return _rv; \
} G_STMT_END
-#define GOM_XG_WRAPPED_CHECK_INIALIZED(t) \
+#define XG_WRAPPED_CHECK_INIALIZED(t) \
G_STMT_START { \
if (!mWrapped || !g_type_is_a (G_OBJECT_TYPE (mWrapped), t)) { \
return NS_ERROR_NOT_INITIALIZED; \
} \
} G_STMT_END
+#define XG_WRAPPED_IMPL_GET_OBJECT(_class, _gtype, _func, _iface,
_prop_name, _prop_gtype, _prop_class) \
+ NS_IMETHODIMP \
+ _class::_func (_iface **_retval) \
+ { \
+ XG_WRAPPED_CHECK_INIALIZED (_gtype); \
+ _prop_class *prop = NULL; \
+ g_object_get (mWrapped, _prop_name, &prop, NULL); \
+ nsresult rv; \
+ rv = gom_wrap_g_object (prop, NS_GET_IID (_iface), (gpointer
*)_retval); \
+ if (prop) { \
+ g_object_unref (prop); \
+ } \
+ return rv; \
+ }
+
+#define XG_WRAPPED_IMPL_GET_STRING(_class, _gtype, _func, _prop_name) \
+ NS_IMETHODIMP \
+ _class::_func (nsAString &aProp) \
+ { \
+ XG_WRAPPED_CHECK_INIALIZED (_gtype); \
+ char *prop; \
+ g_object_get (mWrapped, _prop_name, &prop, NULL); \
+ GOM_GSTRING_TO_ASTRING_RETURN (aProp, prop, NS_ERROR_UNEXPECTED); \
+ return NS_OK; \
+ }
+
+#define XG_WRAPPED_IMPL_GET_SIMPLE(_class, _gtype, _func, _prop_name,
_prop_prtype, _prop_gtype) \
+ NS_IMETHODIMP \
+ _class::_func (_prop_prtype *aProp) \
+ { \
+ XG_WRAPPED_CHECK_INIALIZED (_gtype); \
+ _prop_gtype prop; \
+ g_object_get (mWrapped, _prop_name, &prop, NULL); \
+ *aProp = prop; \
+ return NS_OK; \
+ }
+
+#define XG_WRAPPED_IMPL_GET_ENUM(_class, _gtype, _func, _prop_name,
_prop_class) \
+ XG_WRAPPED_IMPL_GET_SIMPLE(_class, _gtype, _func, _prop_name,
PRUint16, _prop_class)
+
+#define XG_WRAPPED_IMPL_GET_BOOL(_class, _gtype, _func, _prop_name) \
+ XG_WRAPPED_IMPL_GET_SIMPLE(_class, _gtype, _func, _prop_name, PRBool,
gboolean)
+
+#define XG_WRAPPED_IMPL_GET_ULONG(_class, _gtype, _func, _prop_name) \
+ XG_WRAPPED_IMPL_GET_SIMPLE(_class, _gtype, _func, _prop_name,
PRUint32, gulong)
+
#define GOM_WRAPPED_GET(_obj, _iface, _var) \
nsCOMPtr<_iface> _var; \
{ \
@@ -221,5 +284,51 @@
nsCOMPtr<nsISupports> tmp = dont_AddRef (raw); \
_var = do_QueryInterface (tmp); \
}
+
+#define GOM_WRAPPED_GET_OBJECT(_wrapped, _func, _iface, _gtype, _klass) \
+ G_STMT_START { \
+ nsCOMPtr<_iface> aProp; \
+ _klass *prop = NULL; \
+ if (NS_SUCCEEDED (_wrapped->_func (getter_AddRefs (aProp))) &&
aProp) { \
+ prop = (_klass *)gom_wrap_xpcom (aProp, _gtype, NULL); \
+ } \
+ if (prop && g_type_is_a (G_OBJECT_TYPE (prop), _gtype)) { \
+ g_value_set_object (value, prop); \
+ g_object_unref (prop); \
+ } \
+ } G_STMT_END
+
+#define GOM_WRAPPED_GET_ENUM(_wrapped, _func) \
+ G_STMT_START { \
+ PRUint16 aProp; \
+ if (NS_SUCCEEDED (_wrapped->_func (&aProp))) { \
+ g_value_set_enum (value, aProp); \
+ } \
+ } G_STMT_END
+#define GOM_WRAPPED_GET_STRING(_wrapped, _func) \
+ G_STMT_START { \
+ nsAutoString aProp; \
+ if (NS_SUCCEEDED (_wrapped->_func (aProp))) { \
+ GOM_ASTRING_TO_GSTRING (prop, aProp); \
+ g_value_set_string (value, prop); \
+ } \
+ } G_STMT_END
+
+#define GOM_WRAPPED_GET_BOOL(_wrapped, _func) \
+ G_STMT_START { \
+ PRBool aProp; \
+ if (NS_SUCCEEDED (_wrapped->_func (&aProp))) { \
+ g_value_set_boolean (value, aProp); \
+ } \
+ } G_STMT_END
+
+#define GOM_WRAPPED_GET_ULONG(_wrapped, _func) \
+ G_STMT_START { \
+ PRUint32 aProp; \
+ if (NS_SUCCEEDED (_wrapped->_func (&aProp))) { \
+ g_value_set_ulong (value, aProp); \
+ } \
+ } 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 11 00:34:29 2008
@@ -3,12 +3,15 @@
# xpgomincludedir := $(includedir)/gom-0/xpgom
# xpgominclude_HEADERS :=
noinst_HEADERS += include/xpgom/gomwrapped.hh
+noinst_HEADERS += include/xpgom/gomwrappedattr.h
noinst_HEADERS += include/xpgom/gomwrappeddocument.hh
noinst_HEADERS += include/xpgom/gomwrappeddomimplementation.hh
noinst_HEADERS += include/xpgom/gomwrappedelement.hh
+noinst_HEADERS += include/xpgom/gomwrappednamednodemap.hh
noinst_HEADERS += include/xpgom/gomwrappednode.hh
noinst_HEADERS += include/xpgom/xgDOMImplementation.hh
noinst_HEADERS += include/xpgom/xgDocument.hh
noinst_HEADERS += include/xpgom/xgElement.hh
noinst_HEADERS += include/xpgom/xgNode.hh
+noinst_HEADERS += include/xpgom/xgNodeList.hh
noinst_HEADERS += include/xpgom/xgWrapped.hh
Added: trunk/gom/include/xpgom/gomwrappedattr.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrappedattr.hh Mon Aug 11 00:34:29 2008
@@ -0,0 +1,60 @@
+/*
+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 GOM_WRAPPED_ATTR_HH
+#define GOM_WRAPPED_ATTR_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrappedAttr GomWrappedAttr;
+typedef struct _GomWrappedAttrClass GomWrappedAttrClass;
+
+G_END_DECLS
+
+#include <xpgom/gomwrappednode.hh>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED_ATTR (gom_wrapped_attr_get_type ())
+#define GOM_WRAPPED_ATTR(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_WRAPPED_ATTR, GomWrappedAttr))
+#define GOM_WRAPPED_ATTR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
GOM_TYPE_WRAPPED_ATTR, GomWrappedAttrClass))
+#define GOM_IS_WRAPPED_ATTR(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_WRAPPED_ATTR))
+#define GOM_IS_WRAPPED_ATTR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GOM_TYPE_WRAPPED_ATTR))
+#define GOM_WRAPPED_ATTR_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i),
GOM_TYPE_WRAPPED_ATTR, GomWrappedAttrClass))
+
+struct _GomWrappedAttr {
+ GomWrappedNode parent;
+};
+
+struct _GomWrappedAttrClass {
+ GomWrappedNodeClass parent_class;
+};
+
+GType gom_wrapped_attr_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_WRAPPED_ATTR_HH */
+
Added: trunk/gom/include/xpgom/gomwrappednamednodemap.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrappednamednodemap.hh Mon Aug 11 00:34:29
2008
@@ -0,0 +1,60 @@
+/*
+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 GOM_WRAPPED_NAMED_NODE_MAP_HH
+#define GOM_WRAPPED_NAMED_NODE_MAP_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrappedNamedNodeMap GomWrappedNamedNodeMap;
+typedef struct _GomWrappedNamedNodeMapClass GomWrappedNamedNodeMapClass;
+
+G_END_DECLS
+
+#include <xpgom/gomwrapped.hh>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED_NAMED_NODE_MAP
(gom_wrapped_named_node_map_get_type ())
+#define GOM_WRAPPED_NAMED_NODE_MAP(i)
(G_TYPE_CHECK_INSTANCE_CAST ((i), GOM_TYPE_WRAPPED_NAMED_NODE_MAP,
GomWrappedNamedNodeMap))
+#define GOM_WRAPPED_NAMED_NODE_MAP_CLASS(k)
(G_TYPE_CHECK_CLASS_CAST ((k), GOM_TYPE_WRAPPED_NAMED_NODE_MAP,
GomWrappedNamedNodeMapClass))
+#define GOM_IS_WRAPPED_NAMED_NODE_MAP(i)
(G_TYPE_CHECK_INSTANCE_TYPE ((i), GOM_TYPE_WRAPPED_NAMED_NODE_MAP))
+#define GOM_IS_WRAPPED_NAMED_NODE_MAP_CLASS(k)
(G_TYPE_CHECK_CLASS_TYPE ((k), GOM_TYPE_WRAPPED_NAMED_NODE_MAP))
+#define GOM_WRAPPED_NAMED_NODE_MAP_GET_CLASS(i)
(G_TYPE_INSTANCE_GET_CLASS ((i), GOM_TYPE_WRAPPED_NAMED_NODE_MAP,
GomWrappedNamedNodeMapClass))
+
+struct _GomWrappedNamedNodeMap {
+ GomWrapped parent;
+};
+
+struct _GomWrappedNamedNodeMapClass {
+ GomWrappedClass parent_class;
+};
+
+GType gom_wrapped_named_node_map_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_WRAPPED_NAMED_NODE_MAP_HH */
+
Added: trunk/gom/include/xpgom/xgNodeList.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgNodeList.hh Mon Aug 11 00:34:29 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_LIST_HH
+#define XG_NODE_LIST_HH
+
+#include "xpgom/xgWrapped.hh"
+#include "gom/dom/gomnodelist.h"
+
+#include <nsIDOMNodeList.h>
+
+class xgNodeList : protected xgWrapped,
+ public nsIDOMNodeList
+{
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_NSIDOMNODELIST
+
+ xgNodeList ();
+ nsresult Init (GObject *aNodeList = NULL);
+
+protected:
+ xgNodeList (GType aType);
+ ~xgNodeList ();
+};
+
+#endif /* XG_NODE_LIST_HH */
Modified: trunk/gom/include/xpgom/xgWrapped.hh
==============================================================================
--- trunk/gom/include/xpgom/xgWrapped.hh (original)
+++ trunk/gom/include/xpgom/xgWrapped.hh Mon Aug 11 00:34:29 2008
@@ -45,6 +45,7 @@
private:
GType mType;
+ const char *mTypeName;
};
#endif /* XG_WRAPPED_HH */
Modified: trunk/gom/src/libgom/gomdoc.c
==============================================================================
--- trunk/gom/src/libgom/gomdoc.c (original)
+++ trunk/gom/src/libgom/gomdoc.c Mon Aug 11 00:34:29 2008
@@ -452,74 +452,106 @@
GError **error)
{
GomNodeType node_type;
- char *namespace_uri;
- char *qualified_name;
- GomElement *elem;
- GomNode *ret;
+ GomNode *ret = NULL;
char *data;
- GomNode *child;
- GomNode *old_child;
- GomNode *imported_child;
- GomText *text;
- GomComment *comment;
- GomCDATASection *cdata;
g_object_get (node, "node-type", &node_type, NULL);
switch (node_type) {
case GOM_ELEMENT_NODE:
- g_object_get (node,
- "namespace-u-r-i", &namespace_uri,
- "node-name", &qualified_name,
- NULL);
- elem = gom_document_create_element_ns (doc, namespace_uri,
qualified_name, error);
- g_free (namespace_uri);
- g_free (qualified_name);
- if (!elem) {
- return NULL;
+ {
+ char *namespace_uri;
+ char *qualified_name;
+ g_object_get (node,
+ "namespace-u-r-i", &namespace_uri,
+ "node-name", &qualified_name,
+ NULL);
+ ret = (GomNode *)gom_document_create_element_ns (doc,
namespace_uri, qualified_name, error);
+ g_free (namespace_uri);
+ g_free (qualified_name);
}
- ret = GOM_NODE (elem);
- if (!deep) {
- return ret;
+ if (!ret) {
+ break;
}
- for (g_object_get (node, "first-child", &child, NULL);
- child;
- old_child = child,
- g_object_get (old_child, "next-sibling", &child, NULL),
- g_object_unref (old_child)) {
- imported_child = gom_document_import_node (doc, child, deep,
error);
- if (!imported_child) {
- g_object_unref (ret);
- g_object_unref (child);
- return NULL;
+ {
+ GomNamedNodeMap *attrs;
+ gulong i, len;
+ char *name, *value;
+ gboolean specified;
+ GomNode *attr;
+ GError *error = NULL;
+ g_object_get (node, "attributes", &attrs, NULL);
+ if (attrs) {
+ g_object_get (attrs, "length", &len, NULL);
+ for (i = 0; i < len; i++) {
+ attr = gom_named_node_map_item (attrs, i);
+ g_object_get (attr, "specified", &specified, NULL);
+ if (specified) {
+ g_object_get (attr, "name", &name, "value",
&value, NULL);
+ gom_element_set_attribute (GOM_ELEMENT (ret),
name, value, &error);
+ if (error) {
+ g_warning (GOM_LOC ("setting attribute
<%s %s=\"%s\"> failed: %s"),
+ G_OBJECT_TYPE_NAME (ret), name,
value,
+ error->message);
+ g_error_free (error);
+ }
+ g_free (name);
+ g_free (value);
+ }
+ g_object_unref (attr);
+ }
+ g_object_unref (attrs);
}
- if (!gom_node_append_child (ret, imported_child, error)) {
- g_object_unref (ret);
- g_object_unref (child);
- return NULL;
+ }
+ if (!deep) {
+ break;
+ }
+ {
+ GomNode *child, *old_child, *imported_child;
+ for (g_object_get (node, "first-child", &child, NULL);
+ child;
+ old_child = child,
+ g_object_get (old_child, "next-sibling", &child,
NULL),
+ g_object_unref (old_child)) {
+ imported_child = gom_document_import_node (doc, child,
deep, error);
+ if (!imported_child) {
+ g_object_unref (ret);
+ g_object_unref (child);
+ return NULL;
+ }
+ if (!gom_node_append_child (ret, imported_child, error)) {
+ g_object_unref (ret);
+ g_object_unref (child);
+ return NULL;
+ }
}
}
- return ret;
+ break;
case GOM_TEXT_NODE:
g_object_get (node, "node-value", &data, NULL);
- text = gom_document_create_text_node (doc, data);
+ ret = (GomNode *)gom_document_create_text_node (doc, data);
g_free (data);
- return text ? GOM_NODE (text) : NULL;
+ break;
case GOM_CDATA_SECTION_NODE:
g_object_get (node, "node-value", &data, NULL);
- cdata = gom_document_create_cdata_section (doc, data, error);
+ ret = (GomNode *)gom_document_create_cdata_section (doc, data,
error);
g_free (data);
- return cdata ? GOM_NODE (cdata) : NULL;
+ break;
case GOM_COMMENT_NODE:
g_object_get (node, "node-value", &data, NULL);
- comment = gom_document_create_comment (doc, data);
+ ret = (GomNode *)gom_document_create_comment (doc, data);
g_free (data);
- return comment ? GOM_NODE (comment) : NULL;
+ break;
+ case GOM_DOCUMENT_NODE:
+ case GOM_DOCUMENT_TYPE_NODE:
+ g_set_error (error, GOM_DOM_EXCEPTION_ERROR, GOM_NOT_SUPPORTED_ERR,
+ GOM_LOC ("import not supported for type: %d"),
node_type);
+ break;
default:
- g_print ("Unimplemnted type: %d\n", node_type);
+ g_print ("Unimplemented type: %d\n", node_type);
GOM_NOT_IMPLEMENTED_ERROR (error);
- return NULL;
+ break;
}
- return NULL;
+ return ret;
}
static GomElement *
Modified: trunk/gom/src/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/src/xpgom/Makefile.inc (original)
+++ trunk/gom/src/xpgom/Makefile.inc Mon Aug 11 00:34:29 2008
@@ -4,9 +4,11 @@
libxpgom_la_SOURCES :=
libxpgom_la_SOURCES += src/xpgom/gomwrapped.cc
+libxpgom_la_SOURCES += src/xpgom/gomwrappedattr.cc
libxpgom_la_SOURCES += src/xpgom/gomwrappeddocument.cc
libxpgom_la_SOURCES += src/xpgom/gomwrappeddomimplementation.cc
libxpgom_la_SOURCES += src/xpgom/gomwrappedelement.cc
+libxpgom_la_SOURCES += src/xpgom/gomwrappednamednodemap.cc
libxpgom_la_SOURCES += src/xpgom/gomwrappednode.cc
libxpgom_la_SOURCES += src/xpgom/xgDocument.cc
libxpgom_la_SOURCES += src/xpgom/xgDOMImplementation.cc
Modified: trunk/gom/src/xpgom/gomwrapped.cc
==============================================================================
--- trunk/gom/src/xpgom/gomwrapped.cc (original)
+++ trunk/gom/src/xpgom/gomwrapped.cc Mon Aug 11 00:34:29 2008
@@ -167,29 +167,38 @@
GType requested_interface,
GError **error)
{
- GSList *li;
- WrapMapEntry *ent;
-
- nsCOMPtr<xgPIWrapped> wrapped = do_QueryInterface (object);
- if (wrapped) {
- GObject *nugget;
- wrapped->GetWrappedGObject (&nugget);
- GObject *ret = G_OBJECT (gom_unknown_query_interface ((gpointer)nugget,
requested_interface, error));
- g_object_unref (nugget);
- g_message ("Returning a GObject nugget %s for %s",
- G_OBJECT_TYPE_NAME (ret),
- g_type_name (requested_interface));
- return ret;
+ if (!object) {
+ return NULL;
}
- for (li = wrap_map; li; li = li->next) {
+ {
+ nsCOMPtr<xgPIWrapped> wrapped = do_QueryInterface (object);
+ if (wrapped) {
+ GObject *nugget;
+ wrapped->GetWrappedGObject (&nugget);
+ GObject *ret = G_OBJECT (gom_unknown_query_interface
((gpointer)nugget, requested_interface, error));
+ g_object_unref (nugget);
+ g_message ("Returning a GObject nugget %p %s for %s",
+ ret, G_OBJECT_TYPE_NAME (ret),
+ g_type_name (requested_interface));
+ return ret;
+ }
+ }
+ WrapMapEntry *ent;
+ for (GSList *li = wrap_map; li; li = li->next) {
ent = (WrapMapEntry *)li->data;
- g_print (GOM_LOC ("%s is_a %s: %d\n"),
- g_type_name (requested_interface),
- g_type_name (ent->mInterfaceType),
- g_type_is_a (requested_interface, ent->mInterfaceType));
- if (g_type_is_a (requested_interface, ent->mInterfaceType)) {
- g_print (GOM_LOC ("Creating %s\n"), g_type_name (ent->mWrapperType));
- return g_object_new (ent->mWrapperType, "wrapped-object", object,
NULL);
+ //g_print (GOM_LOC ("%s?\n"), g_type_name (ent->mInterfaceType));
+ if (g_type_is_a (ent->mInterfaceType, requested_interface)) {
+ //g_print (GOM_LOC ("maybe %s...\n"), g_type_name
(ent->mInterfaceType));
+ nsCOMPtr<nsISupports> queried;
+ if (NS_SUCCEEDED (object->QueryInterface (ent->mIid, getter_AddRefs
(queried)))) {
+ char nsid[NSID_LENGTH];
+ ent->mIid.ToProvidedString (nsid);
+ g_print (GOM_LOC ("%s %p is_a %s (%s)\n"),
+ nsid, object,
+ g_type_name (requested_interface),
+ g_type_name (ent->mWrapperType));
+ return g_object_new (ent->mWrapperType, "wrapped-object", object, NULL);
+ }
}
}
g_set_error (error, GOM_DOM_EXCEPTION_ERROR, GOM_NO_INTERFACE_ERR,
@@ -205,6 +214,10 @@
{
GSList *li;
WrapMapEntry *ent;
+ if (!object) {
+ *retval = NULL;
+ return NS_OK;
+ }
if (GOM_IS_WRAPPED (object)) {
nsISupports *wrappedp;
g_object_get (object, "wrapped-object", &wrappedp, NULL);
@@ -213,22 +226,15 @@
}
for (li = wrap_map; li; li = li->next) {
ent = (WrapMapEntry *)li->data;
- if (!iid.Equals (ent->mIid)) {
- continue;
- }
- break;
- }
- if (li) {
- GType interface_type = ent->mInterfaceType;
- for (li = wrap_map; li; li = li->next) {
- ent = (WrapMapEntry *)li->data;
- g_print (GOM_LOC ("%s is_a %s: %d\n"),
- g_type_name (interface_type),
- g_type_name (ent->mInterfaceType),
- g_type_is_a (interface_type, ent->mInterfaceType));
- if (g_type_is_a (interface_type, ent->mInterfaceType)) {
- return ent->mConstructor (G_OBJECT (object), iid, retval);
- }
+ if (iid.Equals (ent->mIid)) {
+ char nsid[NSID_LENGTH];
+ iid.ToProvidedString (nsid);
+ g_print (GOM_LOC ("%s %p is_a %s (%s)\n"),
+ G_OBJECT_TYPE_NAME (object),
+ object,
+ nsid,
+ g_type_name (ent->mInterfaceType));
+ return ent->mConstructor (G_OBJECT (object), iid, retval);
}
}
return NS_ERROR_NO_INTERFACE;
Added: trunk/gom/src/xpgom/gomwrappedattr.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrappedattr.cc Mon Aug 11 00:34:29 2008
@@ -0,0 +1,117 @@
+/*
+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/gomwrappedattr.hh"
+#include "gom/dom/gomattr.h"
+#include "gom/dom/gomelement.h"
+#if 0
+#include "xpgom/xgAttr.hh"
+#endif
+#include "gom/dom/gomdomexception.h"
+
+#include <nsCOMPtr.h>
+#include <nsIDOMAttr.h>
+#include <nsIDOMElement.h>
+#include <nsStringAPI.h>
+
+#include "gommacros.h"
+
+enum {
+ PROP_NAME = 1,
+ PROP_SPECIFIED,
+ PROP_VALUE,
+ PROP_OWNER_ELEMENT
+};
+
+#define GET_ATTR(i) GOM_WRAPPED_GET (i, nsIDOMAttr, mAttr)
+
+static void
+gom_wrapped_attr_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GET_ATTR (object);
+ switch (property_id) {
+ case PROP_NAME:
+ GOM_WRAPPED_GET_STRING (mAttr, GetName);
+ break;
+ case PROP_SPECIFIED:
+ GOM_WRAPPED_GET_BOOL (mAttr, GetSpecified);
+ break;
+ case PROP_VALUE:
+ GOM_WRAPPED_GET_STRING (mAttr, GetValue);
+ break;
+ case PROP_OWNER_ELEMENT:
+ GOM_WRAPPED_GET_OBJECT (mAttr, GetOwnerElement, nsIDOMElement,
GOM_TYPE_ELEMENT, GomElement);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gom_wrapped_attr_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GET_ATTR (object);
+ switch (property_id) {
+ case PROP_NAME:
+ case PROP_SPECIFIED:
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+// GOM_WRAPPED_CONSTRUCTOR_INIT (xgNode, Init)
+
+GOM_IMPLEMENT (ATTR, attr, gom_wrapped_attr)
+
+G_DEFINE_TYPE_WITH_CODE (GomWrappedAttr, gom_wrapped_attr,
GOM_TYPE_WRAPPED_NODE,
+ GOM_IMPLEMENT_INTERFACE (ATTR, attr, gom_wrapped_attr))
+
+static void gom_wrapped_attr_init (GomWrappedAttr *node) { }
+
+static void
+gom_wrapped_attr_class_init (GomWrappedAttrClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ oclass->get_property = gom_wrapped_attr_get_property;
+ oclass->set_property = gom_wrapped_attr_set_property;
+
+ g_object_class_override_property (oclass, PROP_NAME, "name");
+ g_object_class_override_property (oclass, PROP_SPECIFIED, "specified");
+ g_object_class_override_property (oclass, PROP_VALUE, "value");
+ g_object_class_override_property (oclass,
PROP_OWNER_ELEMENT, "owner-element");
+
+ gom_wrapped_register_interface (GOM_TYPE_ATTR, GOM_TYPE_WRAPPED_ATTR,
+ NS_GET_IID (nsIDOMAttr), NULL /*xgAttrConstructor*/);
+}
Modified: trunk/gom/src/xpgom/gomwrappeddocument.cc
==============================================================================
--- trunk/gom/src/xpgom/gomwrappeddocument.cc (original)
+++ trunk/gom/src/xpgom/gomwrappeddocument.cc Mon Aug 11 00:34:29 2008
@@ -30,6 +30,9 @@
#include <nsIDOMDocument.h>
#include <nsCOMPtr.h>
+#include <nsIDOMElement.h>
+#include <nsIDOMDocumentType.h>
+#include <nsIDOMDOMImplementation.h>
#include "gommacros.h"
@@ -54,13 +57,19 @@
switch (property_id) {
case PROP_DOCUMENT_ELEMENT:
+ GOM_WRAPPED_GET_OBJECT (mDoc, GetDocumentElement, nsIDOMElement,
GOM_TYPE_ELEMENT, GomElement);
+ break;
case PROP_DOCTYPE:
+ GOM_WRAPPED_GET_OBJECT (mDoc, GetDoctype, nsIDOMDocumentType,
GOM_TYPE_DOCUMENT_TYPE, GomDocumentType);
+ break;
case PROP_IMPLEMENTATION:
- case PROP_NODE_NAME:
- case PROP_NODE_TYPE:
+ GOM_WRAPPED_GET_OBJECT (mDoc, GetImplementation, nsIDOMDOMImplementation,
GOM_TYPE_DOM_IMPLEMENTATION, GomDOMImplementation);
+ break;
+#if 0
case PROP_DOCUMENT_URI:
- GOM_NOT_IMPLEMENTED;
+ GOM_WRAPPED_GET_STRING (mDoc, GetDocumentURI);
break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
Modified: trunk/gom/src/xpgom/gomwrappedelement.cc
==============================================================================
--- trunk/gom/src/xpgom/gomwrappedelement.cc (original)
+++ trunk/gom/src/xpgom/gomwrappedelement.cc Mon Aug 11 00:34:29 2008
@@ -30,6 +30,7 @@
#include <nsIDOMElement.h>
#include <nsCOMPtr.h>
+#include <nsStringAPI.h>
#include "gommacros.h"
@@ -53,7 +54,7 @@
switch (property_id) {
case PROP_TAG_NAME:
- GOM_NOT_IMPLEMENTED;
+ GOM_WRAPPED_GET_STRING (mElement, GetTagName);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Added: trunk/gom/src/xpgom/gomwrappednamednodemap.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrappednamednodemap.cc Mon Aug 11 00:34:29 2008
@@ -0,0 +1,149 @@
+/*
+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/gomwrappednamednodemap.hh"
+#include "gom/dom/gomnamednodemap.h"
+#if 0
+#include "xpgom/xgNode.hh"
+#endif
+#include "gom/dom/gomdomexception.h"
+
+#include <nsCOMPtr.h>
+#include <nsIDOMNamedNodeMap.h>
+#include <nsIDOMNode.h>
+#include <nsStringAPI.h>
+
+#include "gommacros.h"
+
+enum {
+ PROP_LENGTH = 1,
+};
+
+#define GET_MAP(i) GOM_WRAPPED_GET (i, nsIDOMNamedNodeMap, mMap)
+
+static void
+gom_wrapped_named_node_map_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GET_MAP (object);
+ switch (property_id) {
+ case PROP_LENGTH:
+ GOM_WRAPPED_GET_ULONG (mMap, GetLength);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static GomNode *
+gom_wrapped_named_node_map_get_named_item (GomNamedNodeMap *map,
+ const char *name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_named_node_map_set_named_item (GomNamedNodeMap *map,
+ GomNode *arg,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_named_node_map_remove_named_item (GomNamedNodeMap *map,
+ const char *name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_named_node_map_item (GomNamedNodeMap *map,
+ gulong index)
+{
+ GET_MAP (map);
+ nsCOMPtr<nsIDOMNode> aNode;
+ if (NS_FAILED (mMap->Item (index, getter_AddRefs (aNode)))) {
+ return NULL;
+ }
+ return (GomNode *)gom_wrap_xpcom (aNode, GOM_TYPE_NODE, NULL);
+}
+
+static GomNode *
+gom_wrapped_named_node_map_get_named_item_ns (GomNamedNodeMap *map,
+ const char *namespace_uri,
+ const char *local_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_named_node_map_set_named_item_ns (GomNamedNodeMap *map,
+ GomNode *arg,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_named_node_map_remove_named_item_ns (GomNamedNodeMap *map,
+ const char *namespace_uri,
+ const char *local_name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+// GOM_WRAPPED_CONSTRUCTOR_INIT (xgNode, Init)
+
+GOM_IMPLEMENT (NAMED_NODE_MAP, named_node_map, gom_wrapped_named_node_map)
+
+G_DEFINE_TYPE_WITH_CODE (GomWrappedNamedNodeMap,
gom_wrapped_named_node_map, GOM_TYPE_WRAPPED,
+ GOM_IMPLEMENT_INTERFACE (NAMED_NODE_MAP, named_node_map,
gom_wrapped_named_node_map))
+
+static void gom_wrapped_named_node_map_init (GomWrappedNamedNodeMap *node)
{ }
+
+static void
+gom_wrapped_named_node_map_class_init (GomWrappedNamedNodeMapClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ oclass->get_property = gom_wrapped_named_node_map_get_property;
+
+ g_object_class_override_property (oclass, PROP_LENGTH, "length");
+
+ gom_wrapped_register_interface (GOM_TYPE_NAMED_NODE_MAP,
GOM_TYPE_WRAPPED_NAMED_NODE_MAP,
+ NS_GET_IID (nsIDOMNamedNodeMap), NULL
/*xgNamedNodeMapConstructor*/);
+}
Modified: trunk/gom/src/xpgom/gomwrappednode.cc
==============================================================================
--- trunk/gom/src/xpgom/gomwrappednode.cc (original)
+++ trunk/gom/src/xpgom/gomwrappednode.cc Mon Aug 11 00:34:29 2008
@@ -27,11 +27,14 @@
#include "gom/dom/gomnode.h"
#include "xpgom/xgNode.hh"
#include "gom/dom/gomdomexception.h"
+#include "gom/dom/gomnamednodemap.h"
#include <nsIDOMNode.h>
#include <nsCOMPtr.h>
#include <nsIDOMDocument.h>
+#include <nsIDOMNamedNodeMap.h>
#include <nsStringAPI.h>
+#include <nsIDOMNodeList.h>
#include "gommacros.h"
@@ -60,74 +63,50 @@
GValue *value,
GParamSpec *pspec)
{
- gpointer doc = NULL;
- nsCOMPtr<nsIDOMDocument> aDoc;
- nsAutoString aString;
- nsCOMPtr<nsIDOMNode> aNode;
- GomNode *node = NULL;
-
GET_NODE (object);
switch (property_id) {
case PROP_OWNER_DOCUMENT:
- if (NS_SUCCEEDED (mNode->GetOwnerDocument (getter_AddRefs (aDoc)))) {
- doc = gom_wrap_xpcom (aDoc, GOM_TYPE_DOCUMENT, NULL);
- }
- if (GOM_IS_DOCUMENT (doc)) {
- g_value_set_object (value, doc);
- g_object_unref (doc);
- }
+ GOM_WRAPPED_GET_OBJECT (mNode, GetOwnerDocument, nsIDOMDocument,
GOM_TYPE_DOCUMENT, GomDocument);
break;
case PROP_NODE_TYPE:
- PRUint16 aNodeType;
- if (NS_SUCCEEDED (mNode->GetNodeType (&aNodeType))) {
- g_value_set_enum (value, aNodeType);
- }
+ GOM_WRAPPED_GET_ENUM (mNode, GetNodeType);
break;
case PROP_NAMESPACE_URI:
- if (NS_SUCCEEDED (mNode->GetNamespaceURI (aString))) {
- GOM_ASTRING_TO_GSTRING (namespace_uri, aString);
- g_value_set_string (value, namespace_uri);
- }
+ GOM_WRAPPED_GET_STRING (mNode, GetNamespaceURI);
break;
case PROP_NODE_NAME:
- if (NS_SUCCEEDED (mNode->GetNodeName (aString))) {
- GOM_ASTRING_TO_GSTRING (node_name, aString);
- g_value_set_string (value, node_name);
- }
+ GOM_WRAPPED_GET_STRING (mNode, GetNodeName);
break;
case PROP_FIRST_CHILD:
- if (NS_SUCCEEDED (mNode->GetFirstChild (getter_AddRefs (aNode))) &&
aNode) {
- node = (GomNode *)gom_wrap_xpcom (aNode, GOM_TYPE_NODE, NULL);
- }
- if (GOM_IS_NODE (node)) {
- g_value_set_object (value, node);
- g_object_unref (node);
- }
+ GOM_WRAPPED_GET_OBJECT (mNode, GetFirstChild, nsIDOMNode, GOM_TYPE_NODE,
GomNode);
break;
case PROP_NEXT_SIBLING:
- if (NS_SUCCEEDED (mNode->GetNextSibling (getter_AddRefs (aNode))) &&
aNode) {
- node = (GomNode *)gom_wrap_xpcom (aNode, GOM_TYPE_NODE, NULL);
- }
- if (GOM_IS_NODE (node)) {
- g_value_set_object (value, node);
- g_object_unref (node);
- }
+ GOM_WRAPPED_GET_OBJECT (mNode, GetNextSibling, nsIDOMNode, GOM_TYPE_NODE,
GomNode);
break;
case PROP_NODE_VALUE:
- if (NS_SUCCEEDED (mNode->GetNodeValue (aString))) {
- GOM_ASTRING_TO_GSTRING (node_value, aString);
- g_value_set_string (value, node_value);
- }
+ GOM_WRAPPED_GET_STRING (mNode, GetNodeValue);
+ break;
+ case PROP_ATTRIBUTES:
+ GOM_WRAPPED_GET_OBJECT (mNode, GetAttributes, nsIDOMNamedNodeMap,
GOM_TYPE_NAMED_NODE_MAP, GomNamedNodeMap);
break;
case PROP_PREVIOUS_SIBLING:
+ GOM_WRAPPED_GET_OBJECT (mNode, GetPreviousSibling, nsIDOMNode,
GOM_TYPE_NODE, GomNode);
+ break;
case PROP_PARENT_NODE:
+ GOM_WRAPPED_GET_OBJECT (mNode, GetParentNode, nsIDOMNode, GOM_TYPE_NODE,
GomNode);
+ break;
case PROP_CHILD_NODES:
+ GOM_WRAPPED_GET_OBJECT (mNode, GetChildNodes, nsIDOMNodeList,
GOM_TYPE_NODE_LIST, GomNodeList);
+ break;
case PROP_LAST_CHILD:
+ GOM_WRAPPED_GET_OBJECT (mNode, GetLastChild, nsIDOMNode, GOM_TYPE_NODE,
GomNode);
+ break;
case PROP_PREFIX:
+ GOM_WRAPPED_GET_STRING (mNode, GetPrefix);
+ break;
case PROP_LOCAL_NAME:
- case PROP_ATTRIBUTES:
- GOM_PROPERTY_NOT_IMPLEMENTED (pspec);
+ GOM_WRAPPED_GET_STRING (mNode, GetLocalName);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Modified: trunk/gom/src/xpgom/xgDOMImplementation.cc
==============================================================================
--- trunk/gom/src/xpgom/xgDOMImplementation.cc (original)
+++ trunk/gom/src/xpgom/xgDOMImplementation.cc Mon Aug 11 00:34:29 2008
@@ -36,7 +36,7 @@
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED
(GOM_TYPE_DOM_IMPLEMENTATION)
+#define CHECK_INITIALIZED XG_WRAPPED_CHECK_INIALIZED
(GOM_TYPE_DOM_IMPLEMENTATION)
NS_IMPL_ADDREF_INHERITED(xgDOMImplementation, xgWrapped)
NS_IMPL_RELEASE_INHERITED(xgDOMImplementation, xgWrapped)
@@ -89,8 +89,7 @@
const nsAString &systemId,
nsIDOMDocumentType **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMDocument createDocument (in DOMString namespaceURI, in DOMString
qualifiedName, in nsIDOMDocumentType doctype) raises (DOMException); */
@@ -108,12 +107,11 @@
GError *error = NULL;
GomDocument *doc = gom_dom_implementation_create_document
(GOM_DOM_IMPLEMENTATION (mWrapped),
nspace, qname, NULL, &error);
- if (!doc) {
- // frees error
- GOM_RETURN_NSRESULT_FROM_GERROR (error);
- }
+ GOM_RETURN_NSRESULT_FROM_GERROR (error);
nsresult rv = gom_wrap_g_object (doc, NS_GET_IID (nsIDOMDocument),
(gpointer *)_retval);
- g_object_unref (doc);
+ if (doc) {
+ g_object_unref (doc);
+ }
return rv;
}
Modified: trunk/gom/src/xpgom/xgDocument.cc
==============================================================================
--- trunk/gom/src/xpgom/xgDocument.cc (original)
+++ trunk/gom/src/xpgom/xgDocument.cc Mon Aug 11 00:34:29 2008
@@ -29,10 +29,14 @@
#include "xpgom/xgDocument.hh"
#include <nsIDOMElement.h>
+#include <nsIDOMDOMImplementation.h>
+#include <nsIDOMDocumentType.h>
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED
(GOM_TYPE_DOCUMENT)
+#define CHECK_INITIALIZED XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_DOCUMENT)
+#define IMPL_GET_OBJECT(_func, _iface, _prop_name, _prop_gtype,
_prop_class) \
+ XG_WRAPPED_IMPL_GET_OBJECT (xgDocument, GOM_TYPE_DOCUMENT, _func,
_iface, _prop_name, _prop_gtype, _prop_class);
NS_IMPL_ISUPPORTS_INHERITED1(xgDocument, xgNode, nsIDOMDocument)
@@ -54,97 +58,68 @@
}
/* readonly attribute nsIDOMDocumentType doctype; */
-NS_IMETHODIMP xgDocument::GetDoctype(nsIDOMDocumentType * *aDoctype)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT(GetDoctype, nsIDOMDocumentType, "doctype",
GOM_TYPE_DOCUMENT_TYPE, GomDocumentType)
/* readonly attribute nsIDOMDOMImplementation implementation; */
-NS_IMETHODIMP xgDocument::GetImplementation(nsIDOMDOMImplementation *
*aImplementation)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetImplementation,
nsIDOMDOMImplementation, "implementation",
+ GOM_TYPE_DOM_IMPLEMENTATION, GomDOMImplementation)
+
/* readonly attribute nsIDOMElement documentElement; */
-NS_IMETHODIMP
-xgDocument::GetDocumentElement (nsIDOMElement **aDocumentElement)
-{
- CHECK_INITIALIZED;
- GomElement *elem;
- g_object_get (mWrapped, "document-element", &elem, NULL);
- if (!GOM_IS_ELEMENT (elem)) {
- g_message (GOM_LOC ("got document element: %s"),
- elem ? G_OBJECT_TYPE_NAME (elem) : "NULL");
- return NS_ERROR_UNEXPECTED;
- }
- nsresult rv = gom_wrap_g_object (elem, NS_GET_IID (nsIDOMElement),
(gpointer *)aDocumentElement);
- g_object_unref (elem);
- return rv;
-}
+IMPL_GET_OBJECT (GetDocumentElement, nsIDOMElement, "document-element",
GOM_TYPE_ELEMENT, GomElement)
/* nsIDOMElement createElement (in DOMString tagName) raises
(DOMException); */
NS_IMETHODIMP xgDocument::CreateElement(const nsAString & tagName,
nsIDOMElement **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMDocumentFragment createDocumentFragment (); */
NS_IMETHODIMP xgDocument::CreateDocumentFragment(nsIDOMDocumentFragment
**_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMText createTextNode (in DOMString data); */
NS_IMETHODIMP xgDocument::CreateTextNode(const nsAString & data,
nsIDOMText **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMComment createComment (in DOMString data); */
NS_IMETHODIMP xgDocument::CreateComment(const nsAString & data,
nsIDOMComment **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_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;
+ XG_RETURN_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;
+ XG_RETURN_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;
+ XG_RETURN_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;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNodeList getElementsByTagName (in DOMString tagname); */
NS_IMETHODIMP xgDocument::GetElementsByTagName(const nsAString & tagname,
nsIDOMNodeList **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNode importNode (in nsIDOMNode importedNode, in boolean deep)
raises (DOMException); */
@@ -156,43 +131,41 @@
CHECK_INITIALIZED;
GError *error = NULL;
GomNode *node = (GomNode *)gom_wrap_xpcom (importedNode,
GOM_TYPE_NODE, &error);
- if (!node) {
- GOM_RETURN_NSRESULT_FROM_GERROR (error);
- }
+ GOM_RETURN_NSRESULT_FROM_GERROR (error);
+
GomNode *ret = gom_document_import_node (GOM_DOCUMENT (mWrapped),
node, deep, &error);
- g_object_unref (node);
- if (!ret) {
- GOM_RETURN_NSRESULT_FROM_GERROR (error);
+ if (node) {
+ g_object_unref (node);
}
+ GOM_RETURN_NSRESULT_FROM_GERROR (error);
+
nsresult rv = gom_wrap_g_object (ret, NS_GET_IID (nsIDOMNode),
(gpointer *)_retval);
- g_object_unref (ret);
+ if (ret) {
+ g_object_unref (ret);
+ }
return rv;
}
/* 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;
+ XG_RETURN_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;
+ XG_RETURN_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;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMElement getElementById (in DOMString elementId); */
NS_IMETHODIMP xgDocument::GetElementById(const nsAString & elementId,
nsIDOMElement **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
Modified: trunk/gom/src/xpgom/xgElement.cc
==============================================================================
--- trunk/gom/src/xpgom/xgElement.cc (original)
+++ trunk/gom/src/xpgom/xgElement.cc Mon Aug 11 00:34:29 2008
@@ -29,10 +29,11 @@
#include "xpgom/xgElement.hh"
#include <nsIDOMElement.h>
+#include <nsStringAPI.h>
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_ELEMENT)
+#define CHECK_INITIALIZED XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_ELEMENT)
NS_IMPL_ISUPPORTS_INHERITED1(xgElement, xgNode, nsIDOMElement)
@@ -54,97 +55,94 @@
}
/* readonly attribute DOMString tagName; */
-NS_IMETHODIMP xgElement::GetTagName(nsAString & aTagName)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+XG_WRAPPED_IMPL_GET_STRING (xgElement, GOM_TYPE_ELEMENT,
GetTagName, "tag-name")
/* DOMString getAttribute (in DOMString name); */
NS_IMETHODIMP xgElement::GetAttribute(const nsAString & name, nsAString &
_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* void setAttribute (in DOMString name, in DOMString value) raises
(DOMException); */
NS_IMETHODIMP xgElement::SetAttribute(const nsAString & name, const
nsAString & value)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* void removeAttribute (in DOMString name) raises (DOMException); */
NS_IMETHODIMP xgElement::RemoveAttribute(const nsAString & name)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMAttr getAttributeNode (in DOMString name); */
NS_IMETHODIMP xgElement::GetAttributeNode(const nsAString & name,
nsIDOMAttr **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMAttr setAttributeNode (in nsIDOMAttr newAttr) raises
(DOMException); */
NS_IMETHODIMP xgElement::SetAttributeNode(nsIDOMAttr *newAttr, nsIDOMAttr
**_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMAttr removeAttributeNode (in nsIDOMAttr oldAttr) raises
(DOMException); */
NS_IMETHODIMP xgElement::RemoveAttributeNode(nsIDOMAttr *oldAttr,
nsIDOMAttr **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNodeList getElementsByTagName (in DOMString name); */
NS_IMETHODIMP xgElement::GetElementsByTagName(const nsAString & name,
nsIDOMNodeList **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* DOMString getAttributeNS (in DOMString namespaceURI, in DOMString
localName); */
NS_IMETHODIMP xgElement::GetAttributeNS(const nsAString & namespaceURI,
const nsAString & localName, nsAString & _retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* void setAttributeNS (in DOMString namespaceURI, in DOMString
qualifiedName, in DOMString value) raises (DOMException); */
NS_IMETHODIMP xgElement::SetAttributeNS(const nsAString & namespaceURI,
const nsAString & qualifiedName, const nsAString & value)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* void removeAttributeNS (in DOMString namespaceURI, in DOMString
localName) raises (DOMException); */
NS_IMETHODIMP xgElement::RemoveAttributeNS(const nsAString & namespaceURI,
const nsAString & localName)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMAttr getAttributeNodeNS (in DOMString namespaceURI, in DOMString
localName); */
NS_IMETHODIMP xgElement::GetAttributeNodeNS(const nsAString &
namespaceURI, const nsAString & localName, nsIDOMAttr **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMAttr setAttributeNodeNS (in nsIDOMAttr newAttr) raises
(DOMException); */
NS_IMETHODIMP xgElement::SetAttributeNodeNS(nsIDOMAttr *newAttr,
nsIDOMAttr **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNodeList getElementsByTagNameNS (in DOMString namespaceURI, in
DOMString localName); */
NS_IMETHODIMP xgElement::GetElementsByTagNameNS(const nsAString &
namespaceURI, const nsAString & localName, nsIDOMNodeList **_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* boolean hasAttribute (in DOMString name); */
NS_IMETHODIMP xgElement::HasAttribute(const nsAString & name, PRBool
*_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* boolean hasAttributeNS (in DOMString namespaceURI, in DOMString
localName); */
NS_IMETHODIMP xgElement::HasAttributeNS(const nsAString & namespaceURI,
const nsAString & localName, PRBool *_retval)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
Modified: trunk/gom/src/xpgom/xgGomModule.cc
==============================================================================
--- trunk/gom/src/xpgom/xgGomModule.cc (original)
+++ trunk/gom/src/xpgom/xgGomModule.cc Mon Aug 11 00:34:29 2008
@@ -27,6 +27,9 @@
#include "xpgom/gomwrappeddomimplementation.hh"
#include "xpgom/gomwrappeddocument.hh"
#include "xpgom/gomwrappedelement.hh"
+#include "xpgom/gomwrappednamednodemap.hh"
+#include "xpgom/gomwrappedattr.hh"
+
#include "gom/gomwidget.h"
#include <gtk/gtkmain.h>
@@ -61,6 +64,8 @@
}
gom_widget_init ();
g_type_class_ref (GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION);
+ g_type_class_ref (GOM_TYPE_WRAPPED_NAMED_NODE_MAP);
+ g_type_class_ref (GOM_TYPE_WRAPPED_ATTR);
g_type_class_ref (GOM_TYPE_WRAPPED_ELEMENT);
g_type_class_ref (GOM_TYPE_WRAPPED_DOCUMENT);
return NS_OK;
Modified: trunk/gom/src/xpgom/xgNode.cc
==============================================================================
--- trunk/gom/src/xpgom/xgNode.cc (original)
+++ trunk/gom/src/xpgom/xgNode.cc Mon Aug 11 00:34:29 2008
@@ -29,10 +29,22 @@
#include "xpgom/gomwrapped.hh"
#include <nsStringAPI.h>
+#include <nsIDOMNodeList.h>
+#include <nsIDOMNamedNodeMap.h>
+#include <nsIDOMDocument.h>
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_NODE)
+#define CHECK_INITIALIZED XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_NODE)
+
+#define IMPL_GET_OBJECT(_func, _iface, _prop_name, _prop_gtype,
_prop_class) \
+ XG_WRAPPED_IMPL_GET_OBJECT (xgNode, GOM_TYPE_NODE, _func, _iface,
_prop_name, _prop_gtype, _prop_class);
+
+#define IMPL_GET_STRING(_func, _prop_name) \
+ XG_WRAPPED_IMPL_GET_STRING (xgNode, GOM_TYPE_NODE, _func, _prop_name);
+
+#define IMPL_GET_ENUM(_func, _prop_name, _prop_class) \
+ XG_WRAPPED_IMPL_GET_ENUM (xgNode, GOM_TYPE_NODE, _func, _prop_name,
_prop_class);
NS_IMPL_ISUPPORTS_INHERITED1 (xgNode, xgWrapped, nsIDOMNode)
@@ -58,100 +70,46 @@
}
/* readonly attribute DOMString nodeName; */
-NS_IMETHODIMP xgNode::GetNodeName(nsAString & aNodeName)
-{
- CHECK_INITIALIZED;
- char *s;
- g_object_get (mWrapped, "node-name", &s, NULL);
- nsCAutoString cstr(s);
- g_free (s);
- CopyUTF8toUTF16 (cstr, aNodeName);
- return NS_OK;
-}
+IMPL_GET_STRING (GetNodeName, "node-name")
/* attribute DOMString nodeValue; */
-NS_IMETHODIMP xgNode::GetNodeValue(nsAString & aNodeValue)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_STRING (GetNodeValue, "node-value")
NS_IMETHODIMP xgNode::SetNodeValue(const nsAString & aNodeValue)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* readonly attribute unsigned short nodeType; */
-NS_IMETHODIMP xgNode::GetNodeType(PRUint16 *aNodeType)
-{
- CHECK_INITIALIZED;
- GomNodeType t;
- g_object_get (mWrapped, "node-type", &t, NULL);
- *aNodeType = t;
- return NS_OK;
-}
+IMPL_GET_ENUM (GetNodeType, "node-type", GomNodeType)
/* readonly attribute nsIDOMNode parentNode; */
-NS_IMETHODIMP xgNode::GetParentNode(nsIDOMNode * *aParentNode)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetParentNode, nsIDOMNode, "parent-node", GOM_TYPE_NODE,
GomNode)
/* readonly attribute nsIDOMNodeList childNodes; */
-NS_IMETHODIMP xgNode::GetChildNodes(nsIDOMNodeList * *aChildNodes)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetChildNodes, nsIDOMNodeList, "child-nodes",
GOM_TYPE_NODE_LIST, GomNodeList)
/* readonly attribute nsIDOMNode firstChild; */
-NS_IMETHODIMP xgNode::GetFirstChild(nsIDOMNode * *aFirstChild)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetFirstChild, nsIDOMNode, "first-child", GOM_TYPE_NODE,
GomNode)
/* readonly attribute nsIDOMNode lastChild; */
-NS_IMETHODIMP xgNode::GetLastChild(nsIDOMNode * *aLastChild)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetLastChild, nsIDOMNode, "last-child", GOM_TYPE_NODE,
GomNode)
/* readonly attribute nsIDOMNode previousSibling; */
-NS_IMETHODIMP xgNode::GetPreviousSibling(nsIDOMNode * *aPreviousSibling)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetPreviousSibling, nsIDOMNode, "previous-sibling",
GOM_TYPE_NODE, GomNode)
/* readonly attribute nsIDOMNode nextSibling; */
-NS_IMETHODIMP xgNode::GetNextSibling(nsIDOMNode * *aNextSibling)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetNextSibling, nsIDOMNode, "next-sibling",
GOM_TYPE_NODE, GomNode)
/* readonly attribute nsIDOMNamedNodeMap attributes; */
-NS_IMETHODIMP xgNode::GetAttributes(nsIDOMNamedNodeMap * *aAttributes)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetAttributes, nsIDOMNamedNodeMap, "attributes",
GOM_TYPE_NAMED_NODE_MAP, GomNamedNodeMap)
/* readonly attribute nsIDOMDocument ownerDocument; */
-NS_IMETHODIMP xgNode::GetOwnerDocument(nsIDOMDocument * *aOwnerDocument)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_OBJECT (GetOwnerDocument, nsIDOMDocument, "owner-document",
GOM_TYPE_DOCUMENT, GomDocument)
/* 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;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNode replaceChild (in nsIDOMNode newChild, in nsIDOMNode
oldChild) raises (DOMException); */
@@ -160,96 +118,82 @@
CHECK_INITIALIZED;
GError *error = NULL;
GomNode *new_child = (GomNode *)gom_wrap_xpcom (newChild,
GOM_TYPE_NODE, &error);
- if (!new_child) {
- GOM_RETURN_NSRESULT_FROM_GERROR (error);
- }
+ GOM_RETURN_NSRESULT_FROM_GERROR (error);
+
GomNode *old_child = (GomNode *)gom_wrap_xpcom (oldChild,
GOM_TYPE_NODE, &error);
- if (!old_child) {
- g_object_unref (new_child);
+ if (error) {
+ if (newChild) {
+ g_object_unref (new_child);
+ }
GOM_RETURN_NSRESULT_FROM_GERROR (error);
}
GomNode *ret = gom_node_replace_child (GOM_NODE (mWrapped), new_child,
old_child, &error);
- g_object_unref (new_child);
- g_object_unref (old_child);
- if (!ret) {
- GOM_RETURN_NSRESULT_FROM_GERROR (error);
+ if (new_child) {
+ g_object_unref (new_child);
}
+ if (old_child) {
+ g_object_unref (old_child);
+ }
+ GOM_RETURN_NSRESULT_FROM_GERROR (error);
+
nsresult rv = gom_wrap_g_object (ret, NS_GET_IID (nsIDOMNode),
(gpointer *)_retval);
- g_object_unref (ret);
+ if (ret) {
+ g_object_unref (ret);
+ }
return rv;
}
/* nsIDOMNode removeChild (in nsIDOMNode oldChild) raises (DOMException);
*/
NS_IMETHODIMP xgNode::RemoveChild(nsIDOMNode *oldChild, nsIDOMNode
**_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNode appendChild (in nsIDOMNode newChild) raises (DOMException);
*/
NS_IMETHODIMP xgNode::AppendChild(nsIDOMNode *newChild, nsIDOMNode
**_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* boolean hasChildNodes (); */
NS_IMETHODIMP xgNode::HasChildNodes(PRBool *_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* nsIDOMNode cloneNode (in boolean deep); */
NS_IMETHODIMP xgNode::CloneNode(PRBool deep, nsIDOMNode **_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* void normalize (); */
NS_IMETHODIMP xgNode::Normalize()
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_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;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* readonly attribute DOMString namespaceURI; */
-NS_IMETHODIMP xgNode::GetNamespaceURI(nsAString & aNamespaceURI)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_STRING (GetNamespaceURI, "namespace-u-r-i")
/* attribute DOMString prefix; */
-NS_IMETHODIMP xgNode::GetPrefix(nsAString & aPrefix)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_STRING (GetPrefix, "prefix")
NS_IMETHODIMP xgNode::SetPrefix(const nsAString & aPrefix)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
/* readonly attribute DOMString localName; */
-NS_IMETHODIMP xgNode::GetLocalName(nsAString & aLocalName)
-{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
+IMPL_GET_STRING (GetLocalName, "local-name")
/* boolean hasAttributes (); */
NS_IMETHODIMP xgNode::HasAttributes(PRBool *_retval)
{
- CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
Added: trunk/gom/src/xpgom/xgNodeList.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgNodeList.cc Mon Aug 11 00:34:29 2008
@@ -0,0 +1,75 @@
+/*
+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/xgNodeList.hh"
+#include "gom/gomglist.h"
+#include "gom/dom/gomdomexception.h"
+#include "xpgom/gomwrapped.hh"
+
+#include <nsStringAPI.h>
+#include <nsIDOMNodeList.h>
+
+#include "gommacros.h"
+
+#define CHECK_INITIALIZED XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_NODE_LIST)
+
+NS_IMPL_ISUPPORTS_INHERITED1 (xgNodeList, xgWrapped, nsIDOMNodeList)
+
+xgNodeList::xgNodeList () : xgWrapped (GOM_TYPE_NOODLE)
+{
+}
+
+xgNodeList::xgNodeList (GType aType) : xgWrapped (aType)
+{
+}
+
+xgNodeList::~xgNodeList ()
+{
+}
+
+nsresult
+xgNodeList::Init (GObject *aNodeList)
+{
+ GType ifaces[2];
+ ifaces[0] = GOM_TYPE_NODE_LIST;
+ ifaces[1] = 0;
+ return xgWrapped::Init (ifaces, aNodeList);
+}
+
+/* nsIDOMNode item (in unsigned long index); */
+NS_IMETHODIMP
+xgNodeList::Item (PRUint32 index, nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ GomNode *node = gom_node_list_item (GOM_NODE_LIST (mWrapped), index);
+ nsresult rv = gom_wrap_g_object (node, NS_GET_IID (nsIDOMNode),
(gpointer *)_retval);
+ if (node) {
+ g_object_unref (node);
+ }
+ return rv;
+}
+
+/* readonly attribute unsigned long length; */
+XG_WRAPPED_IMPL_GET_ULONG (xgNodeList, GOM_TYPE_NODE_LIST,
GetLength, "length")
Modified: trunk/gom/src/xpgom/xgWrapped.cc
==============================================================================
--- trunk/gom/src/xpgom/xgWrapped.cc (original)
+++ trunk/gom/src/xpgom/xgWrapped.cc Mon Aug 11 00:34:29 2008
@@ -24,6 +24,9 @@
#include "config.h"
#include "xpgom/xgWrapped.hh"
+#include "gom/dom/gomdomexception.h"
+
+#include "gommacros.h"
NS_IMPL_ISUPPORTS1 (xgWrapped, xgPIWrapped)
@@ -36,7 +39,10 @@
xgWrapped::~xgWrapped ()
{
if (mWrapped) {
+ g_object_remove_weak_pointer (mWrapped, (gpointer *)&mWrapped);
g_object_unref (mWrapped);
+ } else if (mTypeName) {
+ g_warning (GOM_LOC ("We had a %s, but now it's gone..."), mTypeName);
}
}
@@ -53,7 +59,7 @@
return NS_ERROR_OUT_OF_MEMORY;
}
} else {
- return NS_ERROR_NOT_IMPLEMENTED;
+ XG_RETURN_NOT_IMPLEMENTED;
}
}
for (GType t = G_OBJECT_TYPE (aObject);
@@ -64,6 +70,8 @@
}
}
mWrapped = G_OBJECT (g_object_ref (aObject));
+ g_object_add_weak_pointer (mWrapped, (gpointer *)&mWrapped);
+ mTypeName = G_OBJECT_TYPE_NAME (mWrapped);
return NS_OK;
}