Added:
trunk/gom/idl/ (props changed)
trunk/gom/idl/Makefile.inc
trunk/gom/idl/xgPIWrapped.idl
trunk/gom/include/gom/gomcdata.h
trunk/gom/include/gom/gomcmt.h
trunk/gom/include/gom/gomunknown.h
trunk/gom/include/xpgom/gomwrapped.hh
trunk/gom/include/xpgom/gomwrappeddocument.hh
trunk/gom/include/xpgom/gomwrappeddomimplementation.hh
trunk/gom/include/xpgom/gomwrappedelement.hh
trunk/gom/include/xpgom/gomwrappednode.hh
trunk/gom/include/xpgom/xgElement.hh
trunk/gom/include/xpgom/xgWrapped.hh
trunk/gom/src/libgom/gomcdata.c
trunk/gom/src/libgom/gomcmt.c
trunk/gom/src/xpgom/gomwrapped.cc
trunk/gom/src/xpgom/gomwrappeddocument.cc
trunk/gom/src/xpgom/gomwrappeddomimplementation.cc
trunk/gom/src/xpgom/gomwrappedelement.cc
trunk/gom/src/xpgom/gomwrappednode.cc
trunk/gom/src/xpgom/xgElement.cc
trunk/gom/src/xpgom/xgWrapped.cc
Removed:
trunk/gom/include/xpgom/xgObject.hh
trunk/gom/src/xpgom/xgObject.cc
Modified:
trunk/gom/ChangeLog
trunk/gom/Makefile.am
trunk/gom/configure.ac
trunk/gom/include/gom/Makefile.inc
trunk/gom/include/gom/dom/gomdomexception.h
trunk/gom/include/gommacros.h
trunk/gom/include/xpgom/Makefile.inc
trunk/gom/include/xpgom/xgDOMImplementation.hh
trunk/gom/include/xpgom/xgDocument.hh
trunk/gom/include/xpgom/xgNode.hh
trunk/gom/src/gom/gom.c
trunk/gom/src/libgom/Makefile.inc
trunk/gom/src/libgom/gomcamel.c
trunk/gom/src/libgom/gomchardata.c
trunk/gom/src/libgom/gomdoc.c
trunk/gom/src/libgom/gomelem.c
trunk/gom/src/libgom/gomevt.c
trunk/gom/src/libgom/gomgcmanager.c
trunk/gom/src/libgom/gominterfaces.c
trunk/gom/src/libgom/gomjselement.c
trunk/gom/src/libgom/gomjseventlistener.c
trunk/gom/src/libgom/gomjsgerrorexception.c
trunk/gom/src/libgom/gomjsnavigator.c
trunk/gom/src/libgom/gomjsobject.c
trunk/gom/src/libgom/gomjswindow.c
trunk/gom/src/libgom/gomlistenerlist.c
trunk/gom/src/libgom/gomnoodle.c
trunk/gom/src/libgom/gomwidget.c
trunk/gom/src/xpgom/Makefile.inc
trunk/gom/src/xpgom/xgDOMImplementation.cc
trunk/gom/src/xpgom/xgDocument.cc
trunk/gom/src/xpgom/xgGomModule.cc
trunk/gom/src/xpgom/xgNode.cc
trunk/gom/src/xpgom/xpgom.js
trunk/gom/tests/checkgomvalue.c
Log:
2008-08-09 jacob berkman <ja...@ilovegom.org>
* src/xpgom/xgElement.cc: an nsIElement wrapper of a
GomElement
* src/xpgom/xgGomModule.cc (nsGomModuleConstructor):
initialize GomWidget, and our wrapper classes
* src/xpgom/gomwrapped.cc: the base GObject for a wrapped
nsISupports object; implement wrapping a GObject or an
nsISupports with the other
* src/xpgom/gomwrappeddocument.cc: a GObject wrapping of an
nsIDOMDocument
* src/xpgom/xgNode.cc (ReplaceChild): implement
* src/xpgom/xgDOMImplementation.cc (CreateDocument): use the
gom_wrap* api to create our nsIDOMDocument
* src/xpgom/xgWrapped.cc: rename xgObject.cc; support the
xgPIWrapped interface
* src/xpgom/gomwrappedelement.cc: a GObject wrapping of an
nsIDOMElement
* src/xpgom/xgDocument.cc (Init): take our wrapped object here
rather than in the constructor
(GetDocumentElement): implement
(ImportNode): implement
* src/xpgom/gomwrappednode.cc: a GObject wrapping of an
nsIDOMNode
* src/xpgom/gomwrappeddomimplementation.cc: a GObject wrapping
of an nsIDOMDOMImplementation
* src/libgom/gomcmt.c: implementation of GomComment
* src/libgom/gominterfaces.c (gom_unknown_query_interface): a
clever implementation of _query_interface() for GObjects
* src/libgom/gomdoc.c (gom_doc_get_property): use gom_unknown
to query our first child for its element interface
(gom_doc_create_comment): implement
(gom_doc_create_cdata_section): implement
(get_elements_by_tag_name): instead of using a GObject type
check, use gom_unknown_query_interface
(gom_doc_import_node): begin to implement
(get_element_by_id): use gom_unknown_query_interface
* src/libgom/gomcdata.c: implementaion of GomCDATASection
Modified: trunk/gom/ChangeLog
==============================================================================
--- trunk/gom/ChangeLog (original)
+++ trunk/gom/ChangeLog Sat Aug 9 03:37:32 2008
@@ -1,3 +1,56 @@
+2008-08-09 jacob berkman <ja...@ilovegom.org>
+
+ * src/xpgom/xgElement.cc: an nsIElement wrapper of a
+ GomElement
+
+ * src/xpgom/xgGomModule.cc (nsGomModuleConstructor):
+ initialize GomWidget, and our wrapper classes
+
+ * src/xpgom/gomwrapped.cc: the base GObject for a wrapped
+ nsISupports object; implement wrapping a GObject or an
+ nsISupports with the other
+
+ * src/xpgom/gomwrappeddocument.cc: a GObject wrapping of an
+ nsIDOMDocument
+
+ * src/xpgom/xgNode.cc (ReplaceChild): implement
+
+ * src/xpgom/xgDOMImplementation.cc (CreateDocument): use the
+ gom_wrap* api to create our nsIDOMDocument
+
+ * src/xpgom/xgWrapped.cc: rename xgObject.cc; support the
+ xgPIWrapped interface
+
+ * src/xpgom/gomwrappedelement.cc: a GObject wrapping of an
+ nsIDOMElement
+
+ * src/xpgom/xgDocument.cc (Init): take our wrapped object here
+ rather than in the constructor
+ (GetDocumentElement): implement
+ (ImportNode): implement
+
+ * src/xpgom/gomwrappednode.cc: a GObject wrapping of an
+ nsIDOMNode
+
+ * src/xpgom/gomwrappeddomimplementation.cc: a GObject wrapping
+ of an nsIDOMDOMImplementation
+
+ * src/libgom/gomcmt.c: implementation of GomComment
+
+ * src/libgom/gominterfaces.c (gom_unknown_query_interface): a
+ clever implementation of _query_interface() for GObjects
+
+ * src/libgom/gomdoc.c (gom_doc_get_property): use gom_unknown
+ to query our first child for its element interface
+ (gom_doc_create_comment): implement
+ (gom_doc_create_cdata_section): implement
+ (get_elements_by_tag_name): instead of using a GObject type
+ check, use gom_unknown_query_interface
+ (gom_doc_import_node): begin to implement
+ (get_element_by_id): use gom_unknown_query_interface
+
+ * src/libgom/gomcdata.c: implementaion of GomCDATASection
+
2008-08-05 jacob berkman <ja...@ilovegom.org>
* src/xpgom/xgGomModule.cc (nsGomModuleConstructor): use a proper
Modified: trunk/gom/Makefile.am
==============================================================================
--- trunk/gom/Makefile.am (original)
+++ trunk/gom/Makefile.am Sat Aug 9 03:37:32 2008
@@ -73,6 +73,7 @@
fi
include examples/Makefile.inc
+include idl/Makefile.inc
include include/gom/Makefile.inc
include include/gom/dom/Makefile.inc
include include/xpgom/Makefile.inc
@@ -87,3 +88,6 @@
echo " cp $(top_srcdir)/Makefile.am.subdir
$(top_srcdir)/$$dir/Makefile.am" ; \
cp "$(top_srcdir)/Makefile.am.subdir" "$(top_srcdir)/$$dir/Makefile.am" |
| exit 1 ; \
done
+
+.idl.hh:
+ $(XPIDL) $(XPIDL_FLAGS) -m header -e $@ $<
Modified: trunk/gom/configure.ac
==============================================================================
--- trunk/gom/configure.ac (original)
+++ trunk/gom/configure.ac Sat Aug 9 03:37:32 2008
@@ -42,11 +42,17 @@
AC_PROG_CXX
# AC_PROG_RANLIB
AC_PROG_LIBTOOL
-
# Make libtool use --silent when --silent is passed to make
changequote(,)dnl
LIBTOOL="${LIBTOOL} \$(shell echo \"\$(MFLAGS)\" | awk '/^[^ ]*s/ { print
\"--silent\" }')"
changequote([,])dnl
+
+AC_CHECK_PROG([XPIDL],[xpidl],[$xulrunnersdk/bin/xpidl],[],[$xulrunnersdk/bin])
+if test -z "$XPIDL" ; then
+ AC_MSG_ERROR([$xuldunnersdk is missing xpidl])
+fi
+XPIDL_FLAGS="-I $xulrunnersdk/idl"
+AC_SUBST(XPIDL_FLAGS)
# Checks for libraries.
#
Added: trunk/gom/idl/Makefile.inc
==============================================================================
--- (empty file)
+++ trunk/gom/idl/Makefile.inc Sat Aug 9 03:37:32 2008
@@ -0,0 +1,3 @@
+# -*- Makefile -*-
+
+dist_noinst_DATA += idl/xgPIWrapped.idl
Added: trunk/gom/idl/xgPIWrapped.idl
==============================================================================
--- (empty file)
+++ trunk/gom/idl/xgPIWrapped.idl Sat Aug 9 03:37:32 2008
@@ -0,0 +1,13 @@
+#include "nsISupports.idl"
+
+%{C++
+#include <glib-object.h>
+%}
+
+[ptr] native xgNativeGObject(GObject);
+
+[uuid(97457374-87E2-4213-9B18-9ED575692D2E)]
+interface xgPIWrapped : nsISupports
+{
+ xgNativeGObject getWrappedGObject();
+};
Modified: trunk/gom/include/gom/Makefile.inc
==============================================================================
--- trunk/gom/include/gom/Makefile.inc (original)
+++ trunk/gom/include/gom/Makefile.inc Sat Aug 9 03:37:32 2008
@@ -3,7 +3,9 @@
gomincludedir := $(includedir)/gom-0/gom
gominclude_HEADERS := \
include/gom/gomcamel.h \
+ include/gom/gomcdata.h \
include/gom/gomchardata.h \
+ include/gom/gomcmt.h \
include/gom/gomdoc.h \
include/gom/gomdom.h \
include/gom/gomelem.h \
@@ -40,6 +42,7 @@
include/gom/gomobject.h \
include/gom/gomtxt.h \
include/gom/gomuievt.h \
+ include/gom/gomunknown.h \
include/gom/gomuriutils.h \
include/gom/gomvalue.h \
include/gom/gomwidget.h \
Modified: trunk/gom/include/gom/dom/gomdomexception.h
==============================================================================
--- trunk/gom/include/gom/dom/gomdomexception.h (original)
+++ trunk/gom/include/gom/dom/gomdomexception.h Sat Aug 9 03:37:32 2008
@@ -61,7 +61,8 @@
/* Gom-specific exceptions */
GOM_UNKNOWN_TAG_NAME_ERR = 87001,
GOM_INVALID_ATTRIBUTE_TYPE_ERR = 87002,
- GOM_NOT_IMPLEMENTED_ERR = 87003
+ GOM_NOT_IMPLEMENTED_ERR = 87003,
+ GOM_NO_INTERFACE_ERR = 87004
} GomExceptionCode;
GQuark gom_dom_exception_error_quark (void);
Added: trunk/gom/include/gom/gomcdata.h
==============================================================================
--- (empty file)
+++ trunk/gom/include/gom/gomcdata.h Sat Aug 9 03:37:32 2008
@@ -0,0 +1,59 @@
+/*
+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_CDATA_H
+#define GOM_CDATA_H
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomCData GomCData;
+typedef struct _GomCDataClass GomCDataClass;
+
+G_END_DECLS
+
+#include <gom/gomtxt.h>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_CDATA (gom_cdata_get_type ())
+#define GOM_CDATA(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_CDATA, GomCData))
+#define GOM_CDATA_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
GOM_TYPE_CDATA, GomCDataClass))
+#define GOM_IS_CDATA(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_CDATA))
+#define GOM_IS_CDATA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GOM_TYPE_CDATA))
+#define GOM_CDATA_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i),
GOM_TYPE_CDATA, GomCDataClass))
+
+struct _GomCData {
+ GomTxt parent;
+};
+
+struct _GomCDataClass {
+ GomTxtClass parent_class;
+};
+
+GType gom_cdata_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_CDATA_H */
Added: trunk/gom/include/gom/gomcmt.h
==============================================================================
--- (empty file)
+++ trunk/gom/include/gom/gomcmt.h Sat Aug 9 03:37:32 2008
@@ -0,0 +1,59 @@
+/*
+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_CMT_H
+#define GOM_CMT_H
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomCmt GomCmt;
+typedef struct _GomCmtClass GomCmtClass;
+
+G_END_DECLS
+
+#include <gom/gomchardata.h>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_CMT (gom_cmt_get_type ())
+#define GOM_CMT(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_CMT, GomCmt))
+#define GOM_CMT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
GOM_TYPE_CMT, GomCmtClass))
+#define GOM_IS_CMT(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_CMT))
+#define GOM_IS_CMT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GOM_TYPE_CMT))
+#define GOM_CMT_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i),
GOM_TYPE_CMT, GomCmtClass))
+
+struct _GomCmt {
+ GomCharData parent;
+};
+
+struct _GomCmtClass {
+ GomCharDataClass parent_class;
+};
+
+GType gom_cmt_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_CMT_H */
Added: trunk/gom/include/gom/gomunknown.h
==============================================================================
--- (empty file)
+++ trunk/gom/include/gom/gomunknown.h Sat Aug 9 03:37:32 2008
@@ -0,0 +1,66 @@
+/*
+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_UNKNOWN_H
+#define GOM_UNKNOWN_H
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomUnknown GomUnknown; /* dummy object */
+typedef struct _GomUnknownInterface GomUnknownInterface;
+
+G_END_DECLS
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_UNKNOWN (gom_unknown_get_type ())
+#define GOM_UNKNOWN(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_UNKNOWN, GomUnknown))
+#define GOM_IS_UNKNOWN(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_UNKNOWN))
+#define GOM_UNKNOWN_GET_INTERFACE(i) (G_TYPE_INSTANCE_GET_INTERFACE ((i),
GOM_TYPE_UNKNOWN, GomUnknownInterface))
+
+#define _GOM_IMPLEMENT_UNKNOWN(i, p, f) (((GomUnknownInterface*)i)->f =
p##_##f)
+#define GOM_IMPLEMENT_UNKNOWN(i, p) \
+ G_STMT_START { \
+ _GOM_IMPLEMENT_UNKNOWN (i, p, query_interface); \
+ } G_STMT_END
+
+struct _GomUnknownInterface {
+ GTypeInterface parent;
+ gpointer (*query_interface) (gpointer unknown,
+ GType requested_interface,
+ GError **error);
+};
+
+GType gom_unknown_get_type (void);
+
+gpointer gom_unknown_query_interface (gpointer unknown,
+ GType requested_interface,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* GOM_UNKNOWN_H */
Modified: trunk/gom/include/gommacros.h
==============================================================================
--- trunk/gom/include/gommacros.h (original)
+++ trunk/gom/include/gommacros.h Sat Aug 9 03:37:32 2008
@@ -26,11 +26,20 @@
#define JSVAL_CHARS(jval) (JS_GetStringBytes (JSVAL_TO_STRING (jval)))
-#define GOM_NOT_IMPLEMENTED (g_message (G_STRLOC": Not implemented yet."))
+#ifdef __cplusplus
+#define GOM_LOC(s) G_STRLOC":%s: "s, G_STRFUNC
+#else
+#define GOM_LOC(s) G_STRLOC":%s(): "s, G_STRFUNC
+#endif
+
+#define GOM_NOT_IMPLEMENTED (g_message (GOM_LOC("Not implemented yet.")))
#define GOM_NOT_IMPLEMENTED_ERROR(error) \
- (g_set_error (error, GOM_DOM_EXCEPTION_ERROR, GOM_NOT_IMPLEMENTED_ERR,
\
- G_STRLOC": Not implemented yet"))
+ G_STMT_START { \
+ GOM_NOT_IMPLEMENTED; \
+ g_set_error (error, GOM_DOM_EXCEPTION_ERROR,
GOM_NOT_IMPLEMENTED_ERR, \
+ GOM_LOC ("Not implemented yet")); \
+ } G_STMT_END
#define GOM_JS_NOT_IMPLEMENTED(cx) \
G_STMT_START { \
@@ -41,6 +50,11 @@
} \
} G_STMT_END
+#define GOM_PROPERTY_NOT_IMPLEMENTED(pspec) \
+ (g_message (GOM_LOC ("%s.%s not implemented"), \
+ g_type_name (pspec->owner_type), pspec->name))
+
+
#define GOM_DEFINE_QUARK(n) \
static gpointer \
gom_##n##_quark_once (gpointer data) \
@@ -159,28 +173,53 @@
#define GOM_UNSET_WEAK(p) GOM_SET_WEAK(p, NULL)
-#define GOM_ASTRING_TO_GSTRING(_aCString, _aString, _errval) \
+#define GOM_ASTRING_TO_GSTRING_RETURN(_aCString, _aString, _errval) \
nsCAutoString _aCString##String; \
if (NS_FAILED (NS_UTF16ToCString (_aString, NS_CSTRING_ENCODING_UTF8,
_aCString##String))) { \
return _errval; \
} \
const char *_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_ASTRING_TO_GSTRING(_aCString, _aString) \
+ nsCAutoString _aCString##String; \
+ NS_UTF16ToCString (_aString, NS_CSTRING_ENCODING_UTF8,
_aCString##String); \
+ const char *_aCString = _aCString##String.get();
-#define GOM_RETURN_NSRESULT_FROM_GERROR(_err) \
- G_STMT_START { \
- nsresult _rv = GOM_GERROR_TO_NSRESULT(_err); \
- g_error_free (_err); \
- return _rv; \
+#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; \
+ break; \
+ } \
+ } \
+ } \
+ g_error_free (_err); \
+ return _rv; \
} G_STMT_END
-#define GOM_XGO_CHECK_INIALIZED(t) \
+#define GOM_XG_WRAPPED_CHECK_INIALIZED(t) \
G_STMT_START { \
- if (!mObject || !g_type_is_a (G_OBJECT_TYPE (mObject), t)) { \
+ if (!mWrapped || !g_type_is_a (G_OBJECT_TYPE (mWrapped), t)) { \
return NS_ERROR_NOT_INITIALIZED; \
} \
} G_STMT_END
+
+#define GOM_WRAPPED_GET(_obj, _iface, _var) \
+ nsCOMPtr<_iface> _var; \
+ { \
+ nsISupports *raw; \
+ g_object_get (_obj, "wrapped-object", &raw, NULL); \
+ nsCOMPtr<nsISupports> tmp = dont_AddRef (raw); \
+ _var = do_QueryInterface (tmp); \
+ }
#endif /* GOM_MACROS_H */
Modified: trunk/gom/include/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/include/xpgom/Makefile.inc (original)
+++ trunk/gom/include/xpgom/Makefile.inc Sat Aug 9 03:37:32 2008
@@ -2,7 +2,13 @@
# xpgomincludedir := $(includedir)/gom-0/xpgom
# xpgominclude_HEADERS :=
+noinst_HEADERS += include/xpgom/gomwrapped.hh
+noinst_HEADERS += include/xpgom/gomwrappeddocument.hh
+noinst_HEADERS += include/xpgom/gomwrappeddomimplementation.hh
+noinst_HEADERS += include/xpgom/gomwrappedelement.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/xgObject.hh
+noinst_HEADERS += include/xpgom/xgWrapped.hh
Added: trunk/gom/include/xpgom/gomwrapped.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrapped.hh Sat Aug 9 03:37:32 2008
@@ -0,0 +1,102 @@
+/*
+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_HH
+#define GOM_WRAPPED_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrapped GomWrapped;
+typedef struct _GomWrappedClass GomWrappedClass;
+
+G_END_DECLS
+
+#include <glib-object.h>
+#include <nsISupports.h>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED (gom_wrapped_get_type ())
+#define GOM_WRAPPED(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_WRAPPED, GomWrapped))
+#define GOM_WRAPPED_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
GOM_TYPE_WRAPPED, GomWrappedClass))
+#define GOM_IS_WRAPPED(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_WRAPPED))
+#define GOM_IS_WRAPPED_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GOM_TYPE_WRAPPED))
+#define GOM_WRAPPED_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i),
GOM_TYPE_WRAPPED, GomWrappedClass))
+
+struct _GomWrapped {
+ GObject parent;
+};
+
+struct _GomWrappedClass {
+ GObjectClass parent_class;
+};
+
+GType gom_wrapped_get_type (void);
+
+G_END_DECLS
+
+typedef NS_CALLBACK (GomWrappedConstructor) (GObject *object, REFNSIID
aIID, void **aResult);
+
+#define GOM_WRAPPED_CONSTRUCTOR_INIT(_InstanceClass, _InitMethod) \
+static NS_IMETHODIMP \
+_InstanceClass##Constructor(GObject *object, REFNSIID aIID, \
+ void **aResult) \
+{ \
+ nsresult rv; \
+ \
+ _InstanceClass * inst; \
+ \
+ *aResult = NULL; \
+ \
+ NS_NEWXPCOM(inst, _InstanceClass); \
+ if (NULL == inst) { \
+ rv = NS_ERROR_OUT_OF_MEMORY; \
+ return rv; \
+ } \
+ NS_ADDREF(inst); \
+ rv = inst->_InitMethod(object); \
+ if(NS_SUCCEEDED(rv)) { \
+ rv = inst->QueryInterface(aIID, aResult); \
+ } \
+ NS_RELEASE(inst); \
+ \
+ return rv; \
+} \
+
+void gom_wrapped_register_interface (GType g_interface,
+ GType g_wrapper,
+ REFNSIID iid,
+ GomWrappedConstructor ctor);
+
+gpointer gom_wrap_xpcom (nsISupports *object,
+ GType requested_interface,
+ GError **error);
+
+nsresult gom_wrap_g_object (gpointer object,
+ REFNSIID iid,
+ void **retval);
+
+#endif /* GOM_WRAPPED_HH */
+
Added: trunk/gom/include/xpgom/gomwrappeddocument.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrappeddocument.hh Sat Aug 9 03:37:32 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_DOCUMENT_HH
+#define GOM_WRAPPED_DOCUMENT_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrappedDocument GomWrappedDocument;
+typedef struct _GomWrappedDocumentClass GomWrappedDocumentClass;
+
+G_END_DECLS
+
+#include <xpgom/gomwrappednode.hh>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED_DOCUMENT (gom_wrapped_document_get_type
())
+#define GOM_WRAPPED_DOCUMENT(i) (G_TYPE_CHECK_INSTANCE_CAST
((i), GOM_TYPE_WRAPPED_DOCUMENT, GomWrappedDocument))
+#define GOM_WRAPPED_DOCUMENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST
((k), GOM_TYPE_WRAPPED_DOCUMENT, GomWrappedDocumentClass))
+#define GOM_IS_WRAPPED_DOCUMENT(i) (G_TYPE_CHECK_INSTANCE_TYPE
((i), GOM_TYPE_WRAPPED_DOCUMENT))
+#define GOM_IS_WRAPPED_DOCUMENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE
((k), GOM_TYPE_WRAPPED_DOCUMENT))
+#define GOM_WRAPPED_DOCUMENT_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS
((i), GOM_TYPE_WRAPPED_DOCUMENT, GomWrappedDocumentClass))
+
+struct _GomWrappedDocument {
+ GomWrappedNode parent;
+};
+
+struct _GomWrappedDocumentClass {
+ GomWrappedNodeClass parent_class;
+};
+
+GType gom_wrapped_document_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_WRAPPED_DOCUMENT_HH */
+
Added: trunk/gom/include/xpgom/gomwrappeddomimplementation.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrappeddomimplementation.hh Sat Aug 9
03:37:32 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_DOM_IMPLEMENTATION_HH
+#define GOM_WRAPPED_DOM_IMPLEMENTATION_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrappedDOMImplementation
GomWrappedDOMImplementation;
+typedef struct _GomWrappedDOMImplementationClass
GomWrappedDOMImplementationClass;
+
+G_END_DECLS
+
+#include <xpgom/gomwrapped.hh>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION
(gom_wrapped_dom_implementation_get_type ())
+#define GOM_WRAPPED_DOM_IMPLEMENTATION(i)
(G_TYPE_CHECK_INSTANCE_CAST ((i), GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION,
GomWrappedDOMImplementation))
+#define GOM_WRAPPED_DOM_IMPLEMENTATION_CLASS(k)
(G_TYPE_CHECK_CLASS_CAST ((k), GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION,
GomWrappedDOMImplementationClass))
+#define GOM_IS_WRAPPED_DOM_IMPLEMENTATION(i)
(G_TYPE_CHECK_INSTANCE_TYPE ((i), GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION))
+#define GOM_IS_WRAPPED_DOM_IMPLEMENTATION_CLASS(k)
(G_TYPE_CHECK_CLASS_TYPE ((k), GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION))
+#define GOM_WRAPPED_DOM_IMPLEMENTATION_GET_CLASS(i)
(G_TYPE_INSTANCE_GET_CLASS ((i), GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION,
GomWrappedDOMImplementationClass))
+
+struct _GomWrappedDOMImplementation {
+ GomWrapped parent;
+};
+
+struct _GomWrappedDOMImplementationClass {
+ GomWrappedClass parent_class;
+};
+
+GType gom_wrapped_dom_implementation_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_WRAPPED_DOM_IMPLEMENTATION_HH */
+
Added: trunk/gom/include/xpgom/gomwrappedelement.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrappedelement.hh Sat Aug 9 03:37:32 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_ELEMENT_HH
+#define GOM_WRAPPED_ELEMENT_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrappedElement GomWrappedElement;
+typedef struct _GomWrappedElementClass GomWrappedElementClass;
+
+G_END_DECLS
+
+#include <xpgom/gomwrappednode.hh>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED_ELEMENT (gom_wrapped_element_get_type ())
+#define GOM_WRAPPED_ELEMENT(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_WRAPPED_ELEMENT, GomWrappedElement))
+#define GOM_WRAPPED_ELEMENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
GOM_TYPE_WRAPPED_ELEMENT, GomWrappedElementClass))
+#define GOM_IS_WRAPPED_ELEMENT(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_WRAPPED_ELEMENT))
+#define GOM_IS_WRAPPED_ELEMENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GOM_TYPE_WRAPPED_ELEMENT))
+#define GOM_WRAPPED_ELEMENT_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i),
GOM_TYPE_WRAPPED_ELEMENT, GomWrappedElementClass))
+
+struct _GomWrappedElement {
+ GomWrappedNode parent;
+};
+
+struct _GomWrappedElementClass {
+ GomWrappedNodeClass parent_class;
+};
+
+GType gom_wrapped_element_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_WRAPPED_ELEMENT_HH */
+
Added: trunk/gom/include/xpgom/gomwrappednode.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/gomwrappednode.hh Sat Aug 9 03:37:32 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_NODE_HH
+#define GOM_WRAPPED_NODE_HH
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GomWrappedNode GomWrappedNode;
+typedef struct _GomWrappedNodeClass GomWrappedNodeClass;
+
+G_END_DECLS
+
+#include <xpgom/gomwrapped.hh>
+
+G_BEGIN_DECLS
+
+#define GOM_TYPE_WRAPPED_NODE (gom_wrapped_node_get_type ())
+#define GOM_WRAPPED_NODE(i) (G_TYPE_CHECK_INSTANCE_CAST ((i),
GOM_TYPE_WRAPPED_NODE, GomWrappedNode))
+#define GOM_WRAPPED_NODE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
GOM_TYPE_WRAPPED_NODE, GomWrappedNodeClass))
+#define GOM_IS_WRAPPED_NODE(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i),
GOM_TYPE_WRAPPED_NODE))
+#define GOM_IS_WRAPPED_NODE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GOM_TYPE_WRAPPED_NODE))
+#define GOM_WRAPPED_NODE_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i),
GOM_TYPE_WRAPPED_NODE, GomWrappedNodeClass))
+
+struct _GomWrappedNode {
+ GomWrapped parent;
+};
+
+struct _GomWrappedNodeClass {
+ GomWrappedClass parent_class;
+};
+
+GType gom_wrapped_node_get_type (void);
+
+G_END_DECLS
+
+#endif /* GOM_WRAPPED_NODE_HH */
+
Modified: trunk/gom/include/xpgom/xgDOMImplementation.hh
==============================================================================
--- trunk/gom/include/xpgom/xgDOMImplementation.hh (original)
+++ trunk/gom/include/xpgom/xgDOMImplementation.hh Sat Aug 9 03:37:32 2008
@@ -24,7 +24,7 @@
#ifndef XG_DOM_IMPLEMENTATION_HH
#define XG_DOM_IMPLEMENTATION_HH
-#include "xpgom/xgObject.hh"
+#include "xpgom/xgWrapped.hh"
#include "gom/dom/gomdomimplementation.h"
#include <nsIDOMDOMImplementation.h>
@@ -34,15 +34,15 @@
{ 0x4138BAA2, 0x29BD, 0x4D1C, { 0x91, 0x93, 0x2D, 0x22, 0x54, 0xD4, 0xCA,
0x28 } }
#define
XG_DOMIMPLEMENTATION_CONTRACTID "@ilovegom.org/dom-implementation;1"
-class xgDOMImplementation : protected xgObject,
+class xgDOMImplementation : protected xgWrapped,
public nsIDOMDOMImplementation
{
public:
- NS_DECL_ISUPPORTS
+ NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMDOMIMPLEMENTATION
- xgDOMImplementation (GomDOMImplementation *aDom = NULL);
- nsresult Init ();
+ xgDOMImplementation ();
+ nsresult Init (GObject *aDom = NULL);
private:
~xgDOMImplementation ();
Modified: trunk/gom/include/xpgom/xgDocument.hh
==============================================================================
--- trunk/gom/include/xpgom/xgDocument.hh (original)
+++ trunk/gom/include/xpgom/xgDocument.hh Sat Aug 9 03:37:32 2008
@@ -36,11 +36,11 @@
NS_FORWARD_NSIDOMNODE(xgNode::)
NS_DECL_NSIDOMDOCUMENT
- xgDocument (GomDocument *aDoc = NULL);
- nsresult Init();
+ xgDocument ();
+ nsresult Init (GObject *aDoc = NULL);
protected:
- xgDocument (GomDocument *aDoc, GType aType);
+ xgDocument (GType aType);
~xgDocument ();
};
Added: trunk/gom/include/xpgom/xgElement.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgElement.hh Sat Aug 9 03:37:32 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_ELEMENT_HH
+#define XG_ELEMENT_HH
+
+#include "xpgom/xgNode.hh"
+#include "gom/dom/gomelement.h"
+
+#include <nsIDOMElement.h>
+
+class xgElement : protected xgNode,
+ public nsIDOMElement
+{
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_FORWARD_NSIDOMNODE(xgNode::)
+ NS_DECL_NSIDOMELEMENT
+
+ xgElement ();
+ nsresult Init (GObject *aElement = NULL);
+
+protected:
+ xgElement (GType aType);
+ ~xgElement ();
+};
+
+#endif /* XG_ELEMENT_HH */
Modified: trunk/gom/include/xpgom/xgNode.hh
==============================================================================
--- trunk/gom/include/xpgom/xgNode.hh (original)
+++ trunk/gom/include/xpgom/xgNode.hh Sat Aug 9 03:37:32 2008
@@ -24,22 +24,22 @@
#ifndef XG_NODE_HH
#define XG_NODE_HH
-#include "xpgom/xgObject.hh"
+#include "xpgom/xgWrapped.hh"
#include "gom/dom/gomnode.h"
#include <nsIDOMNode.h>
-class xgNode : public xgObject,
+class xgNode : protected xgWrapped,
public nsIDOMNode
{
- NS_DECL_ISUPPORTS
+ NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMNODE
- xgNode (GomNode *aNode = NULL);
- nsresult Init();
+ xgNode ();
+ nsresult Init (GObject *aNode = NULL);
protected:
- xgNode (GomNode *aNode, GType aType);
+ xgNode (GType aType);
~xgNode ();
};
Added: trunk/gom/include/xpgom/xgWrapped.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgWrapped.hh Sat Aug 9 03:37:32 2008
@@ -0,0 +1,50 @@
+/*
+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_WRAPPED_HH
+#define XG_WRAPPED_HH
+
+#include "xgPIWrapped.hh"
+
+#include <nscore.h>
+#include <nsISupports.h>
+
+#include <glib-object.h>
+
+class xgWrapped : public xgPIWrapped
+{
+ NS_DECL_ISUPPORTS
+ NS_DECL_XGPIWRAPPED
+protected:
+ xgWrapped (GType aType = 0);
+ ~xgWrapped ();
+
+ nsresult Init (GType *ifaces, GObject *aObject = NULL);
+
+ GObject *mWrapped;
+
+private:
+ GType mType;
+};
+
+#endif /* XG_WRAPPED_HH */
Modified: trunk/gom/src/gom/gom.c
==============================================================================
--- trunk/gom/src/gom/gom.c (original)
+++ trunk/gom/src/gom/gom.c Sat Aug 9 03:37:32 2008
@@ -75,7 +75,7 @@
static void
gom_error_reporter (JSContext *cx, const char *message, JSErrorReport
*report)
{
- g_warning (G_STRLOC": %s:%d: Unhandled JavaScript exception: %s
(%d)\n",
+ g_warning (GOM_LOC ("%s:%d: Unhandled JavaScript exception: %s
(%d)\n"),
report->filename, report->lineno,
message, report->errorNumber);
}
@@ -97,7 +97,7 @@
gc_cb (gpointer data)
{
MainData *d = data;
- g_print (G_STRLOC": running GC()...\n");
+ g_print (GOM_LOC ("running GC()...\n"));
JS_DumpNamedRoots(JS_GetRuntime (d->cx), dump_root, NULL);
JS_GC (d->cx);
return TRUE;
Modified: trunk/gom/src/libgom/Makefile.inc
==============================================================================
--- trunk/gom/src/libgom/Makefile.inc (original)
+++ trunk/gom/src/libgom/Makefile.inc Sat Aug 9 03:37:32 2008
@@ -5,7 +5,9 @@
libgom_a_SOURCES := \
include/gommacros.h \
src/libgom/gomcamel.c \
+ src/libgom/gomcdata.c \
src/libgom/gomchardata.c \
+ src/libgom/gomcmt.c \
src/libgom/gomdoc.c \
src/libgom/gomdom.c \
src/libgom/gomdombuiltins.c \
Modified: trunk/gom/src/libgom/gomcamel.c
==============================================================================
--- trunk/gom/src/libgom/gomcamel.c (original)
+++ trunk/gom/src/libgom/gomcamel.c Sat Aug 9 03:37:32 2008
@@ -61,7 +61,7 @@
r[ri] = s[si];
}
#if 0
- g_print ("\n"G_STRLOC": %s -> %s\n", s, r);
+ g_print ("\n"GOM_LOC ("%s -> %s\n"), s, r);
#endif
return (const char *)r;
}
@@ -88,7 +88,7 @@
r[ri] = s[si];
}
#if 0
- g_print (G_STRLOC": %s -> %s\n", s, r);
+ g_print (GOM_LOC ("%s -> %s\n"), s, r);
#endif
return (const char *)r;
}
Added: trunk/gom/src/libgom/gomcdata.c
==============================================================================
--- (empty file)
+++ trunk/gom/src/libgom/gomcdata.c Sat Aug 9 03:37:32 2008
@@ -0,0 +1,42 @@
+/*
+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 "gom/dom/gomcdatasection.h"
+
+#include "gom/gomcdata.h"
+
+#include "gom/dom/gomdomexception.h"
+
+#include "gommacros.h"
+
+#include <string.h>
+
+GOM_IMPLEMENT (CDATA_SECTION, cdata_section, gom_cdata);
+
+G_DEFINE_TYPE_WITH_CODE (GomCData, gom_cdata, GOM_TYPE_TXT,
+ GOM_IMPLEMENT_INTERFACE (CDATA_SECTION,
cdata_section, gom_cdata));
+
+static void gom_cdata_init (GomCData *cdata) { }
+static void gom_cdata_class_init (GomCDataClass *klass) { }
Modified: trunk/gom/src/libgom/gomchardata.c
==============================================================================
--- trunk/gom/src/libgom/gomchardata.c (original)
+++ trunk/gom/src/libgom/gomchardata.c Sat Aug 9 03:37:32 2008
@@ -144,7 +144,7 @@
{
GomCharDataPrivate *priv = PRIV (object);
#if 0
- g_print (G_STRLOC": %s %p\n",
+ g_print (GOM_LOC ("%s %p\n"),
g_type_name (G_TYPE_FROM_INSTANCE (object)), object);
#endif
g_free (priv->data);
Added: trunk/gom/src/libgom/gomcmt.c
==============================================================================
--- (empty file)
+++ trunk/gom/src/libgom/gomcmt.c Sat Aug 9 03:37:32 2008
@@ -0,0 +1,42 @@
+/*
+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 "gom/dom/gomcomment.h"
+
+#include "gom/gomcmt.h"
+
+#include "gom/dom/gomdomexception.h"
+
+#include "gommacros.h"
+
+#include <string.h>
+
+GOM_IMPLEMENT (COMMENT, comment, gom_cmt);
+
+G_DEFINE_TYPE_WITH_CODE (GomCmt, gom_cmt, GOM_TYPE_CHAR_DATA,
+ GOM_IMPLEMENT_INTERFACE (COMMENT, comment,
gom_cmt));
+
+static void gom_cmt_init (GomCmt *cmt) { }
+static void gom_cmt_class_init (GomCmtClass *klass) { }
Modified: trunk/gom/src/libgom/gomdoc.c
==============================================================================
--- trunk/gom/src/libgom/gomdoc.c (original)
+++ trunk/gom/src/libgom/gomdoc.c Sat Aug 9 03:37:32 2008
@@ -33,12 +33,15 @@
#include "gom/dom/gomdomexception.h"
#include "gom/dom/gomkeyboardevent.h"
#include "gom/dom/gommouseevent.h"
+#include "gom/gomcdata.h"
+#include "gom/gomcmt.h"
#include "gom/gomelem.h"
#include "gom/gomglist.h"
#include "gom/gomkeyboardevt.h"
#include "gom/gommouseevt.h"
#include "gom/gomobject.h"
#include "gom/gomtxt.h"
+#include "gom/gomunknown.h"
#include "gommacros.h"
@@ -73,6 +76,7 @@
GParamSpec *pspec)
{
GomDocPrivate *priv = PRIV (object);
+ gpointer elemp;
GomElement *elem;
switch (property_id) {
case PROP_DOCTYPE:
@@ -82,12 +86,16 @@
g_value_set_object (value, priv->implementation);
break;
case PROP_DOCUMENT_ELEMENT:
- g_object_get (object, "first-child", &elem, NULL);
- if (GOM_IS_ELEMENT (elem)) {
- g_value_set_object (value, elem);
+ g_object_get (object, "first-child", &elemp, NULL);
+ if (G_IS_OBJECT (elemp)) {
+ elem = gom_unknown_query_interface (elemp, GOM_TYPE_ELEMENT,
NULL);
+ if (elem) {
+ g_value_set_object (value, elem);
+ g_object_unref (elem);
+ }
}
- if (G_IS_OBJECT (elem)) {
- g_object_unref (elem);
+ if (G_IS_OBJECT (elemp)) {
+ g_object_unref (elemp);
}
break;
case PROP_NODE_NAME:
@@ -140,7 +148,7 @@
unload = gom_document_event_create_event (doc, "Event", &err);
if (err) {
- g_error (G_STRLOC": Could not create an unload event: %s",
err->message);
+ g_error (GOM_LOC ("Could not create an unload event: %s"),
err->message);
g_assert_not_reached ();
return TRUE;
}
@@ -148,7 +156,7 @@
gom_event_init_event (unload, "unload", FALSE, FALSE);
gom_event_target_dispatch_event (GOM_EVENT_TARGET (doc), unload, &err);
if (err) {
- g_error (G_STRLOC": Error dispatching unload event: %s",
err->message);
+ g_error (GOM_LOC ("Error dispatching unload event: %s"),
err->message);
g_assert_not_reached ();
return TRUE;
}
@@ -205,6 +213,9 @@
if (!type || !g_type_is_a (type, GOM_TYPE_ELEMENT)) {
type = GOM_TYPE_ELEM;
}
+ g_print (GOM_LOC ("<%s:%s xmlns='%s'> (%s)\n"),
+ prefix, local_name, namespace_uri,
+ g_type_name (type));
obj = g_object_new (type,
"owner-document", doc,
"namespace-u-r-i", namespace_uri,
@@ -289,8 +300,10 @@
gom_doc_create_comment (GomDocument *doc,
const char *data)
{
- GOM_NOT_IMPLEMENTED;
- return NULL;
+ return g_object_new (GOM_TYPE_CMT,
+ "owner-document", doc,
+ "data", data,
+ NULL);
}
static GomCDATASection *
@@ -298,8 +311,10 @@
const char *data,
GError **error)
{
- GOM_NOT_IMPLEMENTED_ERROR (error);
- return NULL;
+ return g_object_new (GOM_TYPE_CDATA,
+ "owner-document", doc,
+ "data", data,
+ NULL);
}
static GomProcessingInstruction *
@@ -378,6 +393,7 @@
const char *namespace_uri,
const char *qualified_name)
{
+ GomElement *elem;
GomNode *old_node;
if (matches_by_tag_name (node, namespace_uri, qualified_name)) {
@@ -389,8 +405,10 @@
old_node = node,
g_object_get (old_node, "next-sibling", &node, NULL),
g_object_unref (old_node)) {
- if (GOM_IS_ELEMENT (node)) {
- li = get_elements_by_tag_name (li, node, namespace_uri,
qualified_name);
+ elem = gom_unknown_query_interface (node, GOM_TYPE_ELEMENT, NULL);
+ if (elem) {
+ li = get_elements_by_tag_name (li, GOM_NODE (elem),
namespace_uri, qualified_name);
+ g_object_unref (elem);
}
}
@@ -433,34 +451,106 @@
gboolean deep,
GError **error)
{
- GOM_NOT_IMPLEMENTED_ERROR (error);
+ GomNodeType node_type;
+ char *namespace_uri;
+ char *qualified_name;
+ GomElement *elem;
+ GomNode *ret;
+ 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;
+ }
+ ret = GOM_NODE (elem);
+ if (!deep) {
+ return ret;
+ }
+ 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;
+ case GOM_TEXT_NODE:
+ g_object_get (node, "node-value", &data, NULL);
+ text = gom_document_create_text_node (doc, data);
+ g_free (data);
+ return text ? GOM_NODE (text) : NULL;
+ case GOM_CDATA_SECTION_NODE:
+ g_object_get (node, "node-value", &data, NULL);
+ cdata = gom_document_create_cdata_section (doc, data, error);
+ g_free (data);
+ return cdata ? GOM_NODE (cdata) : NULL;
+ case GOM_COMMENT_NODE:
+ g_object_get (node, "node-value", &data, NULL);
+ comment = gom_document_create_comment (doc, data);
+ g_free (data);
+ return comment ? GOM_NODE (comment) : NULL;
+ default:
+ g_print ("Unimplemnted type: %d\n", node_type);
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+ }
return NULL;
}
static GomElement *
-get_element_by_id (GomNode *node,
+get_element_by_id (GomElement *node,
const char *element_id)
{
const GValue *gval;
- GomNode *old_node;
+ GomElement *old_node;
GomElement *ret;
+ GomElement *elem;
for (g_object_get (node, "first-child", &node, NULL);
node;
old_node = node,
g_object_get (old_node, "next-sibling", &node, NULL),
g_object_unref (old_node)) {
- if (GOM_IS_ELEMENT (node)) {
- gval = gom_object_get_attribute (G_OBJECT (node), "id");
- if (gval && G_VALUE_HOLDS_STRING (gval) && !strcmp
(g_value_get_string (gval), element_id)) {
- return GOM_ELEMENT (node);
- }
+ elem = gom_unknown_query_interface (node, GOM_TYPE_ELEMENT, NULL);
+ if (!elem) {
+ continue;
+ }
+ gval = gom_object_get_attribute (G_OBJECT (elem), "id");
+ if (gval && G_VALUE_HOLDS_STRING (gval) && !strcmp
(g_value_get_string (gval), element_id)) {
+ g_object_unref (node);
+ return elem;
+ }
- ret = get_element_by_id (node, element_id);
- if (ret) {
- g_object_unref (node);
- return ret;
- }
+ ret = get_element_by_id (elem, element_id);
+ g_object_unref (elem);
+ if (ret) {
+ g_object_unref (node);
+ return ret;
}
}
@@ -473,11 +563,11 @@
const char *element_id)
{
GomElement *elem;
- GomNode *node;
+ GomElement *root;
- g_object_get (doc, "document-element", &node, NULL);
- elem = get_element_by_id (node, element_id);
- g_object_unref (node);
+ g_object_get (doc, "document-element", &root, NULL);
+ elem = get_element_by_id (root, element_id);
+ g_object_unref (root);
return elem;
}
@@ -584,8 +674,8 @@
gom_doc_dispose (GObject *object)
{
GomDocPrivate *priv = PRIV (object);
- g_print (G_STRLOC": %s %p\n",
- g_type_name (G_TYPE_FROM_INSTANCE (object)), object);
+ g_print (GOM_LOC ("%s %p\n"),
+ g_type_name (G_TYPE_FROM_INSTANCE (object)), object);
if (priv->doctype) {
g_object_unref (priv->doctype);
priv->doctype = NULL;
Modified: trunk/gom/src/libgom/gomelem.c
==============================================================================
--- trunk/gom/src/libgom/gomelem.c (original)
+++ trunk/gom/src/libgom/gomelem.c Sat Aug 9 03:37:32 2008
@@ -88,21 +88,21 @@
if (priv->namespace_uri) {
if (priv->prefix && !strcmp (priv->prefix, "xml") &&
strcmp
(priv->namespace_uri, "http://www.w3.org/XML/1998/namespace")) {
- g_warning (G_STRLOC": invalid prefix '%s' for namespace '%s'
on %p",
+ g_warning (GOM_LOC ("invalid prefix '%s' for namespace '%s'
on %p"),
priv->prefix, priv->namespace_uri, object);
g_free (priv->prefix);
priv->prefix = NULL;
return;
}
if (!priv->local_name) {
- g_warning (G_STRLOC": no local name set on %p", object);
+ g_warning (GOM_LOC ("no local name set on %p"), object);
return;
}
} else if (priv->prefix) {
- g_warning (G_STRLOC": prefix set without namespace on %p", object);
+ g_warning (GOM_LOC ("prefix set without namespace on %p"), object);
return;
} else if (priv->local_name) {
- g_warning (G_STRLOC": localName set without namespace on %p",
object);
+ g_warning (GOM_LOC ("localName set without namespace on %p"),
object);
return;
} else {
return;
@@ -280,7 +280,7 @@
priv->local_name = NULL;
if (priv->tag_name) {
- g_print (G_STRLOC": <%s>\n", priv->tag_name);
+ g_print (GOM_LOC ("<%s>\n"), priv->tag_name);
}
g_free (priv->tag_name);
priv->tag_name = NULL;
@@ -306,7 +306,7 @@
GObjectClass *oclass = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GomElemPrivate));
-
+
oclass->get_property = gom_elem_get_property;
oclass->set_property = gom_elem_set_property;
oclass->constructed = gom_elem_constructed;
Modified: trunk/gom/src/libgom/gomevt.c
==============================================================================
--- trunk/gom/src/libgom/gomevt.c (original)
+++ trunk/gom/src/libgom/gomevt.c Sat Aug 9 03:37:32 2008
@@ -224,7 +224,7 @@
{
GomEvtPrivate *priv = PRIV (object);
#if 0
- g_print (G_STRLOC": %s %p\n",
+ g_print (GOM_LOC ("%s %p\n"),
g_type_name (G_TYPE_FROM_INSTANCE (object)), object);
#endif
g_free (priv->namespace_uri);
Modified: trunk/gom/src/libgom/gomgcmanager.c
==============================================================================
--- trunk/gom/src/libgom/gomgcmanager.c (original)
+++ trunk/gom/src/libgom/gomgcmanager.c Sat Aug 9 03:37:32 2008
@@ -48,20 +48,20 @@
return JS_TRUE;
}
- g_message (G_STRLOC": Marking live objects...");
+ g_message (GOM_LOC ("Marking live objects..."));
for (li = OBJECTS(cx); li; li = li->next) {
g_assert (GOM_IS_GC_MANAGED (li->data));
gom_gc_managed_mark_live_objects (
GOM_GC_MANAGED (li->data), cx, status);
}
- g_message (G_STRLOC": done.");
+ g_message (GOM_LOC ("done."));
return JS_TRUE;
}
void
gom_gc_manager_manage_runtime (JSRuntime *runtime)
{
- g_message (G_STRLOC": managing runtime %p", runtime);
+ g_message (GOM_LOC ("managing runtime %p"), runtime);
JS_SetGCCallbackRT (runtime, gom_gc_manager_run);
}
Modified: trunk/gom/src/libgom/gominterfaces.c
==============================================================================
--- trunk/gom/src/libgom/gominterfaces.c (original)
+++ trunk/gom/src/libgom/gominterfaces.c Sat Aug 9 03:37:32 2008
@@ -25,8 +25,11 @@
#include "gommacros.h"
+#include "gom/gomunknown.h"
#include "gom/gomeventtargetinternal.h"
+#include "gom/dom/gomdomexception.h"
+
GOM_DEFINE_INTERFACE_WITH_PREREQUISITE (GomEventTargetInternal,
gom_event_target_internal, {}, GOM_TYPE_EVENT_TARGET);
GOM_STUB_FUNC (GOM_EVENT_TARGET_INTERNAL, gom_event_target_internal,
get_parent_target,
@@ -65,3 +68,19 @@
GOM_STUB_VOID (GOM_NODE_INTERNAL, gom_node_internal, sibling_requested,
(GomNodeInternal *gom_node_internal, GomNode *child),
(gom_node_internal, child));
+
+GOM_DEFINE_INTERFACE_WITH_PREREQUISITE (GomUnknown, gom_unknown, {},
G_TYPE_OBJECT);
+
+gpointer
+gom_unknown_query_interface (gpointer unknown, GType requested_interface,
GError **error)
+{
+ if (GOM_IS_UNKNOWN (unknown)) {
+ g_return_val_if_fail (GOM_UNKNOWN_GET_INTERFACE
(unknown)->query_interface, (gpointer)0);
+ return GOM_UNKNOWN_GET_INTERFACE (unknown)->query_interface
(unknown, requested_interface, error);
+ } else if (g_type_is_a (G_OBJECT_TYPE (unknown), requested_interface))
{
+ return g_object_ref (unknown);
+ }
+ g_set_error (error, GOM_DOM_EXCEPTION_ERROR, GOM_NO_INTERFACE_ERR,
+ "Object does not support %s", g_type_name
(requested_interface));
+ return NULL;
+}
Modified: trunk/gom/src/libgom/gomjselement.c
==============================================================================
--- trunk/gom/src/libgom/gomjselement.c (original)
+++ trunk/gom/src/libgom/gomjselement.c Sat Aug 9 03:37:32 2008
@@ -56,7 +56,7 @@
}
#if 0
- g_print (G_STRLOC": ");
+ g_print (GOM_LOC ("");
#endif
name = JSVAL_CHARS (id);
@@ -92,7 +92,7 @@
}
#if 0
- g_print (G_STRLOC": ");
+ g_print (GOM_LOC());
#endif
name = JSVAL_CHARS (id);
@@ -146,8 +146,8 @@
}
if (has_prop) {
#if 0
- g_print (G_STRLOC": %s.%s already exists\n",
- JS_GET_CLASS (cx, proto)->name, name);
+ g_print (GOM_LOC ("%s.%s already exists\n",
+ JS_GET_CLASS (cx, proto)->name, name);
#endif
*objp = NULL;
return JS_TRUE;
@@ -162,8 +162,8 @@
return JS_FALSE;
}
#if 0
- g_print (G_STRLOC": defined new property: %s.%s (%s)\n",
- JS_GET_CLASS (cx, *objp)->name, name, JS_GET_CLASS (cx,
obj)->name);
+ g_print (GOM_LOC ("defined new property: %s.%s (%s)\n",
+ JS_GET_CLASS (cx, *objp)->name, name, JS_GET_CLASS (cx,
obj)->name);
#endif
return JS_TRUE;
}
Modified: trunk/gom/src/libgom/gomjseventlistener.c
==============================================================================
--- trunk/gom/src/libgom/gomjseventlistener.c (original)
+++ trunk/gom/src/libgom/gomjseventlistener.c Sat Aug 9 03:37:32 2008
@@ -58,16 +58,16 @@
switch (property_id) {
case PROP_JS_CONTEXT:
if (priv->cx) {
- g_warning (G_STRLOC": Context is already set on %p", object);
+ g_warning (GOM_LOC ("Context is already set on %p"), object);
} else {
priv->cx = g_value_get_pointer (value);
}
break;
case PROP_JS_OBJECT:
if (priv->obj) {
- g_warning (G_STRLOC": Object is already set on %p", object);
+ g_warning (GOM_LOC ("Object is already set on %p"), object);
} else if (!priv->cx) {
- g_warning (G_STRLOC": Context needs to be set on %p before
object", object);
+ g_warning (GOM_LOC ("Context needs to be set on %p before
object"), object);
}
priv->obj = g_value_get_pointer (value);
break;
@@ -87,11 +87,11 @@
jsval argv, rval, fval;
if (!priv->cx) {
- g_warning (G_STRLOC": %p.cx is NULL\n", listener);
+ g_warning (GOM_LOC ("%p.cx is NULL\n"), listener);
return;
}
if (!priv->obj) {
- g_warning (G_STRLOC": %p.obj is NULL\n", listener);
+ g_warning (GOM_LOC ("%p.obj is NULL\n"), listener);
return;
}
@@ -130,7 +130,7 @@
g_assert (priv->cx == cx);
if (!JS_IsAboutToBeFinalized (cx, priv->obj)) {
- g_message (G_STRLOC": Marking a %s live...", JS_GET_CLASS (cx,
priv->obj)->name);
+ g_message (GOM_LOC ("Marking a %s live..."), JS_GET_CLASS (cx,
priv->obj)->name);
JS_MarkGCThing (cx, priv->obj, g_type_name (G_TYPE_FROM_INSTANCE
(managed)), NULL);
}
}
Modified: trunk/gom/src/libgom/gomjsgerrorexception.c
==============================================================================
--- trunk/gom/src/libgom/gomjsgerrorexception.c (original)
+++ trunk/gom/src/libgom/gomjsgerrorexception.c Sat Aug 9 03:37:32 2008
@@ -33,7 +33,7 @@
gom_js_g_error_exception_finalize (JSContext *cx, JSObject *obj)
{
GError *err;
- g_print (G_STRLOC": %s %p\n", JS_GET_CLASS (cx, obj)->name, obj);
+ g_print (GOM_LOC ("%s %p\n"), JS_GET_CLASS (cx, obj)->name, obj);
err = JS_GetPrivate (cx, obj);
if (err) {
g_error_free (err);
Modified: trunk/gom/src/libgom/gomjsnavigator.c
==============================================================================
--- trunk/gom/src/libgom/gomjsnavigator.c (original)
+++ trunk/gom/src/libgom/gomjsnavigator.c Sat Aug 9 03:37:32 2008
@@ -95,7 +95,7 @@
return JS_FALSE;
}
#if 0
- g_print (G_STRLOC": %d = %s\n", JSVAL_TO_INT (id), JSVAL_CHARS (*vp));
+ g_print (GOM_LOC ("%d = %s\n"), JSVAL_TO_INT (id), JSVAL_CHARS (*vp));
#endif
return JS_TRUE;
}
Modified: trunk/gom/src/libgom/gomjsobject.c
==============================================================================
--- trunk/gom/src/libgom/gomjsobject.c (original)
+++ trunk/gom/src/libgom/gomjsobject.c Sat Aug 9 03:37:32 2008
@@ -68,7 +68,7 @@
ClassMap *map = g_new (ClassMap, 1);
if (objtype != G_TYPE_OBJECT && !G_TYPE_IS_INTERFACE (objtype)) {
- g_warning (G_STRLOC": registering non-interface %s", g_type_name
(objtype));
+ g_warning (GOM_LOC ("registering non-interface %s"), g_type_name
(objtype));
}
map->type = objtype;
@@ -89,12 +89,12 @@
map = li->data;
if (g_type_is_a (type, map->type)) {
#if 0
- g_print (G_STRLOC": %s -> %s\n", g_type_name (type),
map->jsclass->name);
+ g_print (GOM_LOC ("%s -> %s\n"), g_type_name (type),
map->jsclass->name);
#endif
return map->jsclass;
}
#if 0
- g_print (G_STRLOC": %s !> %s\n", g_type_name (type),
map->jsclass->name);
+ g_print (GOM_LOC ("%s !> %s\n"), g_type_name (type),
map->jsclass->name);
#endif
}
@@ -113,7 +113,7 @@
gom_js_closure_finalize (gpointer data, GClosure *closure)
{
GomJSClosure *jsclosure = (GomJSClosure *)closure;
- g_message(G_STRLOC": finalizing a closure");
+ g_message(GOM_LOC ("finalizing a closure"));
JS_RemoveRoot (jsclosure->cx, &jsclosure->obj);
JS_RemoveRoot (jsclosure->cx, &jsclosure->fun_obj);
}
@@ -275,7 +275,7 @@
}
#if 0
- g_print (G_STRLOC": ");
+ g_print (GOM_LOC (""));
#endif
name = JSVAL_CHARS (id);
if (!gom_js_object_resolve (cx, obj, name, &gobj, &spec, &signal_id)) {
@@ -321,7 +321,7 @@
}
#if 0
- g_print (G_STRLOC": ");
+ g_print (GOM_LOC (""));
#endif
name = JSVAL_CHARS (id);
if (!gom_js_object_resolve (cx, obj, name, &gobj, &spec, &signal_id)) {
@@ -381,7 +381,7 @@
name = JSVAL_CHARS (id);
#if 0
- g_print (G_STRLOC": ");
+ g_print (GOM_LOC (""));
#endif
if (!gom_js_object_resolve (cx, *objp, name, &gobj, &spec,
&signal_id)) {
*objp = NULL;
@@ -396,8 +396,8 @@
}
#if 0
- g_print (G_STRLOC": defined new property: %s.%s (%s)\n",
- JS_GET_CLASS (cx, *objp)->name, name, JS_GET_CLASS (cx,
obj)->name);
+ g_print (GOM_LOC ("defined new property: %s.%s (%s)\n"),
+ JS_GET_CLASS (cx, *objp)->name, name, JS_GET_CLASS (cx,
obj)->name);
#endif
return JS_TRUE;
@@ -440,8 +440,8 @@
gobj = gom_js_object_get_g_object (cx, obj);
#if 0
- g_print (G_STRLOC": %s %d -> %p\n",
- JS_GET_CLASS (cx, obj)->name, enum_op, gobj);
+ g_print (GOM_LOC ("%s %d -> %p\n"),
+ JS_GET_CLASS (cx, obj)->name, enum_op, gobj);
#endif
switch (enum_op) {
case JSENUMERATE_INIT:
@@ -543,8 +543,8 @@
g2js_free (gpointer data)
{
GHashTable *g2js = data;
- g_message (G_STRLOC": GObject to JSObject table leaked %d objects",
- g_hash_table_size (g2js));
+ g_message (GOM_LOC ("GObject to JSObject table leaked %d objects"),
+ g_hash_table_size (g2js));
g_hash_table_foreach (g2js, g2js_warn, NULL);
g_hash_table_destroy (g2js);
}
@@ -562,8 +562,8 @@
js2g_free (gpointer data)
{
GHashTable *js2g = data;
- g_message (G_STRLOC": JSObject to GObject table leaked %d objects",
- g_hash_table_size (js2g));
+ g_message (GOM_LOC ("JSObject to GObject table leaked %d objects"),
+ g_hash_table_size (js2g));
g_hash_table_foreach (js2g, js2g_warn, NULL);
g_hash_table_destroy (js2g);
}
Modified: trunk/gom/src/libgom/gomjswindow.c
==============================================================================
--- trunk/gom/src/libgom/gomjswindow.c (original)
+++ trunk/gom/src/libgom/gomjswindow.c Sat Aug 9 03:37:32 2008
@@ -52,7 +52,7 @@
static void
gom_js_window_finalize (JSContext *cx, JSObject *obj)
{
- g_message (G_STRLOC": Finalizing a Window.");
+ g_message (GOM_LOC ("Finalizing a Window."));
}
JSClass GomJSWindowClass = {
@@ -223,7 +223,7 @@
}
if (jsid >= a->len) {
- g_printerr (G_STRLOC": invalid interval id: %u\n", jsid);
+ g_printerr (GOM_LOC ("invalid interval id: %u\n"), jsid);
return JS_FALSE;
}
@@ -346,13 +346,13 @@
g_free, g_free);
for (name = attribute_names, value = attribute_values; *name; name++,
value++) {
if (!strcmp (*name, "xmlns")) {
- g_print (G_STRLOC": default namespace: %s\n", *value);
+ g_print (GOM_LOC ("default namespace: %s\n"), *value);
g_hash_table_replace (scope->namespaces,
g_strdup (""),
g_strdup (*value));
} else if (!strncmp (*name, "xmlns:", XMLNS_LEN+1)) {
- g_print (G_STRLOC": found prefix: %s -> %s\n",
- *name+XMLNS_LEN+1,
+ g_print (GOM_LOC ("found prefix: %s -> %s\n"),
+ *name+XMLNS_LEN+1,
*value);
g_hash_table_replace (scope->namespaces,
g_strdup (*name + XMLNS_LEN + 1),
@@ -549,14 +549,14 @@
file = gom_element_get_attribute (data->scope->elem, "src");
if (file) {
if (!gom_uri_get_contents (file, data->filename, &script,
&script_len, &err)) {
- g_printerr (G_STRLOC": could not load %s: %s\n",
- filename, err->message);
+ g_printerr (GOM_LOC ("could not load %s: %s\n"),
+ filename, err->message);
g_error_free (err);
} else {
char *uri = gom_uri_join (file, data->filename, &err);
if (!uri) {
- g_printerr (G_STRLOC": could not build uri %s: %s\n",
- file, err->message);
+ g_printerr (GOM_LOC ("could not build uri %s: %s\n"),
+ file, err->message);
g_error_free (err);
}
g_free (file);
@@ -600,12 +600,12 @@
"Unknown error encountered while running
script at %s:%d\n",
data->filename, lineno);
}
- g_printerr (G_STRLOC": error running script: %s\n",
err->message);
+ g_printerr (GOM_LOC ("error running script: %s\n"),
err->message);
g_error_free (err);
} else {
str = JS_ValueToString(data->cx, rval);
- g_print (G_STRLOC": script result: %s\n",
- JS_GetStringBytes(str));
+ g_print (GOM_LOC ("script result: %s\n"),
+ JS_GetStringBytes(str));
}
}
g_free (script);
@@ -620,7 +620,7 @@
static void
gom_js_window_parser_text (GMarkupParseContext *context,
const gchar *text,
- gsize text_len,
+ gsize text_len,
gpointer user_data,
GError **error)
{
@@ -629,7 +629,7 @@
char *txt;
if (!data->doc || !data->scope) {
- g_print (G_STRLOC": dropping some text...\n");
+ g_print (GOM_LOC ("dropping some text...\n"));
return;
}
Modified: trunk/gom/src/libgom/gomlistenerlist.c
==============================================================================
--- trunk/gom/src/libgom/gomlistenerlist.c (original)
+++ trunk/gom/src/libgom/gomlistenerlist.c Sat Aug 9 03:37:32 2008
@@ -170,7 +170,7 @@
GSList *li;
if (!GOM_IS_CUSTOM_EVENT (evt)) {
- g_warning (G_STRLOC": cannot dispatch an event that is not a
CustomEvent");
+ g_warning (GOM_LOC ("cannot dispatch an event that is not a
CustomEvent"));
} else {
for (li = list->listeners;
(li = find_entry (li, namespace_uri, type_name, NULL, phase
== GOM_CAPTURING_PHASE));
@@ -196,14 +196,14 @@
GomEventTarget *parent;
if (!GOM_IS_EVT (evt) || !GOM_IS_CUSTOM_EVENT (evt)) {
- g_warning (G_STRLOC": I cannot work with a \"%s\" Event.",
- g_type_name (G_TYPE_FROM_INSTANCE (evt)));
+ g_warning (GOM_LOC ("I cannot work with a \"%s\" Event."),
+ G_OBJECT_TYPE_NAME (evt));
return TRUE;
}
if (!GOM_IS_EVENT_TARGET_INTERNAL (target)) {
- g_warning (G_STRLOC": I cannot work with a \"%s\" EventTarget.",
- g_type_name (G_TYPE_FROM_INSTANCE (target)));
+ g_warning (GOM_LOC ("I cannot work with a \"%s\" EventTarget."),
+ G_OBJECT_TYPE_NAME (target));
return TRUE;
}
Modified: trunk/gom/src/libgom/gomnoodle.c
==============================================================================
--- trunk/gom/src/libgom/gomnoodle.c (original)
+++ trunk/gom/src/libgom/gomnoodle.c Sat Aug 9 03:37:32 2008
@@ -326,8 +326,8 @@
if (parent) {
g_object_get (parent, "node-name", &parent_name, NULL);
}
- g_print (G_STRLOC": <%s %p> <%s %p>\n",
- child_name, child,
+ g_print (GOM_LOC ("<%s %p> <%s %p>\n"),
+ child_name, child,
parent_name ? parent_name : "(no parent)", parent);
g_free (child_name);
g_free (parent_name);
@@ -347,8 +347,8 @@
if (sibling) {
g_object_get (sibling, "node-name", &sibling_name, NULL);
}
- g_print (G_STRLOC": <%s %p> <%s %p>\n",
- child_name, child,
+ g_print (GOM_LOC ("<%s %p> <%s %p>\n"),
+ child_name, child,
sibling_name? sibling_name : "(no sibling)", sibling);
g_free (child_name);
g_free (sibling_name);
@@ -366,7 +366,7 @@
if (sibling) {
g_object_get (sibling, "node-name", &sibling_name, NULL);
}
- g_print (G_STRLOC": <%s %p> <%s %p>\n",
+ g_print (GOM_LOC ("<%s %p> <%s %p>\n"),
child_name, child,
sibling_name ? sibling_name : "(no sibling)", sibling);
g_free (child_name);
@@ -422,7 +422,7 @@
GomNoodlePrivate *priv = PRIV (object);
#if 0
- g_print (G_STRLOC": %s %p\n",
+ g_print (GOM_LOC ("%s %p\n"),
g_type_name (G_TYPE_FROM_INSTANCE (object)), object);
#endif
g_list_foreach (priv->children, unref_child, NULL);
@@ -447,7 +447,7 @@
}
if (!priv->owner_document) {
- g_warning (G_STRLOC": %s %p: No document set",
+ g_warning (GOM_LOC ("%s %p: No document set"),
g_type_name (G_TYPE_FROM_INSTANCE (object)),
object);
}
Modified: trunk/gom/src/libgom/gomwidget.c
==============================================================================
--- trunk/gom/src/libgom/gomwidget.c (original)
+++ trunk/gom/src/libgom/gomwidget.c Sat Aug 9 03:37:32 2008
@@ -101,7 +101,7 @@
{
GomWidgetPrivate *priv = data;
if (priv->tag_name) {
- g_print (G_STRLOC": Freeing a <%s>'s privates\n", priv->tag_name);
+ g_print (GOM_LOC ("Freeing a <%s>'s privates\n"), priv->tag_name);
}
GOM_UNSET_WEAK (priv->owner_document);
gom_listener_list_free (priv->listeners);
@@ -515,14 +515,14 @@
if (priv->namespace_uri) {
if (priv->prefix && !strcmp (priv->prefix, "xml") &&
strcmp
(priv->namespace_uri, "http://www.w3.org/XML/1998/namespace")) {
- g_warning (G_STRLOC": invalid prefix '%s' for namespace '%s'
on %p",
+ g_warning (GOM_LOC ("invalid prefix '%s' for namespace '%s'
on %p"),
priv->prefix, priv->namespace_uri, object);
g_free (priv->prefix);
priv->prefix = NULL;
return;
}
} else if (priv->prefix) {
- g_warning (G_STRLOC": prefix set without namespace on %p", object);
+ g_warning (GOM_LOC ("prefix set without namespace on %p"), object);
return;
} else {
return;
@@ -705,7 +705,7 @@
g_object_ref (widget);
gom_listener_list_dispatch_event (GOM_EVENT_TARGET (widget), evt,
&error);
if (error) {
- g_print (G_STRLOC": Error dispatching event: %s\n",
+ g_print (GOM_LOC ("Error dispatching event: %s\n"),
error->message);
g_clear_error (&error);
}
@@ -724,7 +724,7 @@
}
gom_listener_list_dispatch_event (GOM_EVENT_TARGET (widget), evt,
&error);
if (error) {
- g_print (G_STRLOC": Error dispatching event: %s\n",
+ g_print (GOM_LOC ("Error dispatching event: %s\n"),
error->message);
g_clear_error (&error);
}
@@ -783,7 +783,7 @@
gom_listener_list_dispatch_event (GOM_EVENT_TARGET (widget), evt,
&error);
if (error) {
- g_print (G_STRLOC": Error dispatching event: %s\n",
+ g_print (GOM_LOC ("Error dispatching event: %s\n"),
error->message);
g_clear_error (&error);
}
@@ -944,7 +944,7 @@
if (parent) {
g_object_get (parent, "node-name", &parent_name, NULL);
}
- g_print (G_STRLOC": <%s %p> <%s %p>\n",
+ g_print (GOM_LOC ("<%s %p> <%s %p>\n"),
child_name, child,
parent_name ? parent_name : "(no parent)", parent);
g_free (child_name);
@@ -964,7 +964,7 @@
if (sibling) {
g_object_get (sibling, "node-name", &sibling_name, NULL);
}
- g_print (G_STRLOC": <%s %p> <%s %p>\n",
+ g_print (GOM_LOC ("<%s %p> <%s %p>\n"),
child_name, child,
sibling_name ? sibling_name : "(no sibling)", sibling);
g_free (child_name);
@@ -982,7 +982,7 @@
if (sibling) {
g_object_get (sibling, "node-name", &sibling_name, NULL);
}
- g_print (G_STRLOC": <%s %p> <%s %p>\n",
+ g_print (GOM_LOC ("<%s %p> <%s %p>\n"),
child_name, child,
sibling_name ? sibling_name : "(no sibling)", sibling);
g_free (child_name);
@@ -1052,14 +1052,13 @@
event = gom_document_event_create_event (GOM_DOCUMENT_EVENT
(priv->owner_document),
"UIEvent", &error);
if (!event) {
- g_printerr (G_STRLOC": could not create activate events: %s\n",
+ g_printerr (GOM_LOC ("could not create activate events: %s\n"),
error->message);
g_clear_error (&error);
return;
}
if (!GOM_IS_UI_EVENT (event)) {
- g_printerr (G_STRLOC": event is a %s, but not a UIEvent\n",
-
+ g_printerr (GOM_LOC ("event is a %s, but not a UIEvent\n"),
g_type_name (G_TYPE_FROM_INSTANCE (event)));
g_object_unref (event);
return;
@@ -1071,7 +1070,7 @@
gom_listener_list_dispatch_event (GOM_EVENT_TARGET (w), event, &error);
g_object_unref (event);
if (error) {
- g_printerr (G_STRLOC": Error dispatching event: %s\n",
+ g_printerr (GOM_LOC ("Error dispatching event: %s\n"),
error->message);
g_clear_error (&error);
}
@@ -1095,13 +1094,13 @@
event = gom_document_event_create_event (GOM_DOCUMENT_EVENT
(priv->owner_document),
"UIEvent", &error);
if (!event) {
- g_printerr (G_STRLOC": could not create activate events: %s\n",
+ g_printerr (GOM_LOC ("could not create activate events: %s\n"),
error->message);
g_clear_error (&error);
return;
}
if (!GOM_IS_UI_EVENT (event)) {
- g_printerr (G_STRLOC": event is a %s, but not a UIEvent\n",
+ g_printerr (GOM_LOC ("event is a %s, but not a UIEvent\n"),
g_type_name (G_TYPE_FROM_INSTANCE (event)));
g_object_unref (event);
@@ -1114,7 +1113,7 @@
gom_listener_list_dispatch_event (GOM_EVENT_TARGET (widget), event,
&error);
g_object_unref (event);
if (error) {
- g_printerr (G_STRLOC": Error dispatching event: %s\n",
+ g_printerr (GOM_LOC ("Error dispatching event: %s\n"),
error->message);
g_clear_error (&error);
}
@@ -1134,25 +1133,25 @@
child = widget;
}
if (!child) {
- g_print (G_STRLOC" returning\n");
+ g_print (GOM_LOC ("returning\n"));
return;
}
priv = PRIV (child);
if (!GOM_IS_DOCUMENT_EVENT (priv->owner_document)) {
- g_print (G_STRLOC" returning\n");
+ g_print (GOM_LOC ("returning\n"));
return;
}
event = gom_document_event_create_event (GOM_DOCUMENT_EVENT
(priv->owner_document),
"UIEvent", &error);
if (!event) {
- g_printerr (G_STRLOC": could not create activate events: %s\n",
+ g_printerr (GOM_LOC ("could not create activate events: %s\n"),
error->message);
g_clear_error (&error);
return;
}
if (!GOM_IS_UI_EVENT (event)) {
- g_printerr (G_STRLOC": event is a %s, but not a UIEvent\n",
+ g_printerr (GOM_LOC ("event is a %s, but not a UIEvent\n"),
g_type_name (G_TYPE_FROM_INSTANCE (event)));
g_object_unref (event);
return;
@@ -1164,7 +1163,7 @@
gom_listener_list_dispatch_event (GOM_EVENT_TARGET (child), event,
&error);
g_object_unref (event);
if (error) {
- g_printerr (G_STRLOC": Error dispatching event: %s\n",
+ g_printerr (GOM_LOC ("Error dispatching event: %s\n"),
error->message);
g_clear_error (&error);
}
@@ -1197,7 +1196,7 @@
#if 0
if (!priv->owner_document) {
- g_warning (G_STRLOC": %s %p: No document set",
+ g_warning (GOM_LOC ("%s %p: No document set"),
g_type_name (G_TYPE_FROM_INSTANCE (object)),
object);
}
Modified: trunk/gom/src/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/src/xpgom/Makefile.inc (original)
+++ trunk/gom/src/xpgom/Makefile.inc Sat Aug 9 03:37:32 2008
@@ -3,13 +3,23 @@
lib_LTLIBRARIES += libxpgom.la
libxpgom_la_SOURCES :=
+libxpgom_la_SOURCES += src/xpgom/gomwrapped.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/gomwrappednode.cc
libxpgom_la_SOURCES += src/xpgom/xgDocument.cc
libxpgom_la_SOURCES += src/xpgom/xgDOMImplementation.cc
+libxpgom_la_SOURCES += src/xpgom/xgElement.cc
libxpgom_la_SOURCES += src/xpgom/xgGomModule.cc
libxpgom_la_SOURCES += src/xpgom/xgNode.cc
-libxpgom_la_SOURCES += src/xpgom/xgObject.cc
+libxpgom_la_SOURCES += src/xpgom/xgWrapped.cc
-libxpgom_la_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
$(XPGOM_CFLAGS)
+src/xpgom/xgWrapped.cc: idl/xgPIWrapped.hh
+
+libxpgom_la_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
-I$(top_builddir)/idl $(XPGOM_CFLAGS)
libxpgom_la_CXXFLAGS = -fshort-wchar
libxpgom_la_LIBDADD :=
-libxpgom_la_LDFLAGS := -avoid-version -export-dynamic libgom.a
$(XPGOM_LIBS)
\ No newline at end of file
+libxpgom_la_LDFLAGS := -avoid-version -export-dynamic libgom.a
$(XPGOM_LIBS)
+
+libxpgom_la_DEPENDENCIES := libgom.a
Added: trunk/gom/src/xpgom/gomwrapped.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrapped.cc Sat Aug 9 03:37:32 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/gomwrapped.hh"
+#include "gom/gomunknown.h"
+#include "gom/dom/gomdomexception.h"
+
+#include <nsCOMPtr.h>
+#include "idl/xgPIWrapped.hh"
+
+#include "gommacros.h"
+
+enum {
+ PROP_WRAPPED_OBJECT = 1
+};
+
+typedef struct {
+ nsISupports *wrappedObject;
+} GomWrappedPrivate;
+
+#define PRIV(i) G_TYPE_INSTANCE_GET_PRIVATE ((i), GOM_TYPE_WRAPPED,
GomWrappedPrivate)
+
+static void
+gom_wrapped_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GomWrappedPrivate *priv = PRIV (object);
+
+ switch (property_id) {
+ case PROP_WRAPPED_OBJECT:
+ NS_IF_ADDREF (priv->wrappedObject);
+ g_value_set_pointer (value, priv->wrappedObject);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gom_wrapped_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GomWrappedPrivate *priv = PRIV (object);
+
+ switch (property_id) {
+ case PROP_WRAPPED_OBJECT:
+ if (priv->wrappedObject) {
+ g_warning (GOM_LOC ("Wrapped object already exists: %p"),
+ priv->wrappedObject);
+ return;
+ }
+ priv->wrappedObject = (nsISupports *)g_value_get_pointer (value);
+ NS_IF_ADDREF (priv->wrappedObject);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static gpointer
+gom_wrapped_query_interface (gpointer unknown, GType requested_interface,
GError **error)
+{
+ GomWrappedPrivate *priv = PRIV (unknown);
+ if (g_type_is_a (G_OBJECT_TYPE (unknown), requested_interface)) {
+ return g_object_ref (unknown);
+ }
+ return gom_wrap_xpcom (priv->wrappedObject, requested_interface,
error);
+}
+
+GOM_IMPLEMENT (UNKNOWN, unknown, gom_wrapped);
+
+G_DEFINE_TYPE_WITH_CODE (GomWrapped, gom_wrapped, G_TYPE_OBJECT,
GOM_IMPLEMENT_INTERFACE (UNKNOWN, unknown, gom_wrapped));
+
+static void gom_wrapped_init (GomWrapped *wrapped) { }
+
+static void
+gom_wrapped_dispose (GObject *object)
+{
+ GomWrappedPrivate *priv = PRIV (object);
+
+ NS_IF_RELEASE (priv->wrappedObject);
+ priv->wrappedObject = NULL;
+
+ G_OBJECT_CLASS (gom_wrapped_parent_class)->dispose (object);
+}
+
+static void
+gom_wrapped_class_init (GomWrappedClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GomWrappedPrivate));
+
+ oclass->dispose = gom_wrapped_dispose;
+ oclass->get_property = gom_wrapped_get_property;
+ oclass->set_property = gom_wrapped_set_property;
+
+ g_object_class_install_property (
+ oclass,
+ PROP_WRAPPED_OBJECT,
+ g_param_spec_pointer ("wrapped-object", NULL,
+ "The nsISupports * this object is wrapping",
+ GParamFlags (G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)));
+}
+
+struct WrapMapEntry {
+ GType mInterfaceType;
+ GType mWrapperType;
+ nsIID mIid;
+ GomWrappedConstructor mConstructor;
+};
+static GSList *wrap_map = NULL;
+
+void
+gom_wrapped_register_interface (GType g_interface,
+ GType g_wrapper,
+ REFNSIID iid,
+ GomWrappedConstructor ctor)
+{
+ WrapMapEntry *entry = new WrapMapEntry();
+ char nsid[NSID_LENGTH];
+
+ iid.ToProvidedString (nsid);
+
+ g_message (GOM_LOC ("Adding mapping for %s -> %s (%s -> %p)"),
+ g_type_name (g_interface), g_type_name (g_wrapper),
+ nsid, ctor);
+
+ entry->mInterfaceType = g_interface;
+ entry->mWrapperType = g_wrapper;
+ entry->mIid = iid;
+ entry->mConstructor = ctor;
+
+ wrap_map = g_slist_prepend (wrap_map, entry);
+}
+
+gpointer
+gom_wrap_xpcom (nsISupports *object,
+ 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;
+ }
+ 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 (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_set_error (error, GOM_DOM_EXCEPTION_ERROR, GOM_NO_INTERFACE_ERR,
+ "Could not find a registered wrapper for %s",
+ g_type_name (requested_interface));
+ return NULL;
+}
+
+nsresult
+gom_wrap_g_object (gpointer object,
+ REFNSIID iid,
+ void **retval)
+{
+ GSList *li;
+ WrapMapEntry *ent;
+ if (GOM_IS_WRAPPED (object)) {
+ nsISupports *wrappedp;
+ g_object_get (object, "wrapped-object", &wrappedp, NULL);
+ nsCOMPtr<nsISupports> wrapped = dont_AddRef (wrappedp);
+ return wrapped->QueryInterface (iid, retval);
+ }
+ 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);
+ }
+ }
+ }
+ return NS_ERROR_NO_INTERFACE;
+}
+
Added: trunk/gom/src/xpgom/gomwrappeddocument.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrappeddocument.cc Sat Aug 9 03:37:32 2008
@@ -0,0 +1,241 @@
+/*
+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 "gom/dom/gomdocument.h"
+#include "gom/dom/gomdomexception.h"
+#include "xpgom/gomwrappeddocument.hh"
+#include "xpgom/xgDocument.hh"
+
+#include <nsIDOMDocument.h>
+#include <nsCOMPtr.h>
+
+#include "gommacros.h"
+
+enum {
+ PROP_DOCTYPE = 1,
+ PROP_IMPLEMENTATION,
+ PROP_DOCUMENT_ELEMENT,
+ PROP_NODE_NAME,
+ PROP_NODE_TYPE,
+ PROP_DOCUMENT_URI
+};
+
+#define GET_DOCUMENT(i) GOM_WRAPPED_GET (i, nsIDOMDocument, mDoc)
+
+static void
+gom_wrapped_document_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GET_DOCUMENT (object);
+
+ switch (property_id) {
+ case PROP_DOCUMENT_ELEMENT:
+ case PROP_DOCTYPE:
+ case PROP_IMPLEMENTATION:
+ case PROP_NODE_NAME:
+ case PROP_NODE_TYPE:
+ case PROP_DOCUMENT_URI:
+ GOM_NOT_IMPLEMENTED;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gom_wrapped_document_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GET_DOCUMENT (object);
+
+ switch (property_id) {
+ case PROP_DOCTYPE:
+ case PROP_IMPLEMENTATION:
+ case PROP_DOCUMENT_URI:
+ GOM_NOT_IMPLEMENTED;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static GomElement *
+gom_wrapped_document_create_element (GomDocument *doc,
+ const char *tag_name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomDocumentFragment *
+gom_wrapped_document_create_document_fragment (GomDocument *doc)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomText *
+gom_wrapped_document_create_text_node (GomDocument *doc,
+ const char *data)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomComment *
+gom_wrapped_document_create_comment (GomDocument *doc,
+ const char *data)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomCDATASection *
+gom_wrapped_document_create_cdata_section (GomDocument *doc,
+ const char *data,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomProcessingInstruction *
+gom_wrapped_document_create_processing_instruction (GomDocument *doc,
+ const char *target,
+ const char *data,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomAttr *
+gom_wrapped_document_create_attribute (GomDocument *doc,
+ const char *name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomEntityReference *
+gom_wrapped_document_create_entity_reference (GomDocument *doc,
+ const char *name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNodeList *
+gom_wrapped_document_get_elements_by_tag_name (GomDocument *doc,
+ const char *tag_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+/* Introduced in DOM Level 2: */
+static GomNode *
+gom_wrapped_document_import_node (GomDocument *doc,
+ GomNode *node,
+ gboolean deep,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomElement *
+gom_wrapped_document_create_element_ns (GomDocument *doc,
+ const char *namespace_uri,
+ const char *qualified_name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomAttr *
+gom_wrapped_document_create_attribute_ns (GomDocument *doc,
+ const char *namespace_uri,
+ const char *qualified_name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNodeList *
+gom_wrapped_document_get_elements_by_tag_name_ns (GomDocument *doc,
+ const char *namespace_uri,
+ const char *local_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomElement *
+gom_wrapped_document_get_element_by_id (GomDocument *doc,
+ const char *element_id)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+GOM_WRAPPED_CONSTRUCTOR_INIT (xgDocument, Init)
+
+GOM_IMPLEMENT (DOCUMENT, document, gom_wrapped_document);
+
+G_DEFINE_TYPE_WITH_CODE (GomWrappedDocument, gom_wrapped_document,
GOM_TYPE_WRAPPED_NODE,
+ GOM_IMPLEMENT_INTERFACE (DOCUMENT, document, gom_wrapped_document));
+
+static void gom_wrapped_document_init (GomWrappedDocument *document) { }
+
+static void
+gom_wrapped_document_class_init (GomWrappedDocumentClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ oclass->get_property = gom_wrapped_document_get_property;
+ oclass->set_property = gom_wrapped_document_set_property;
+
+ g_object_class_override_property (oclass,
PROP_DOCTYPE, "doctype");
+ g_object_class_override_property (oclass,
PROP_IMPLEMENTATION, "implementation");
+ g_object_class_override_property (oclass,
PROP_DOCUMENT_ELEMENT, "document-element");
+ g_object_class_override_property (oclass,
PROP_NODE_NAME, "node-name");
+ g_object_class_override_property (oclass,
PROP_NODE_TYPE, "node-type");
+ g_object_class_override_property (oclass,
PROP_DOCUMENT_URI, "document-u-r-i");
+
+ gom_wrapped_register_interface (GOM_TYPE_DOCUMENT,
GOM_TYPE_WRAPPED_DOCUMENT,
+ NS_GET_IID (nsIDOMDocument), xgDocumentConstructor);
+}
Added: trunk/gom/src/xpgom/gomwrappeddomimplementation.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrappeddomimplementation.cc Sat Aug 9 03:37:32
2008
@@ -0,0 +1,83 @@
+/*
+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 "gom/dom/gomdomexception.h"
+#include "gom/dom/gomdomimplementation.h"
+#include "xpgom/gomwrappeddomimplementation.hh"
+#include "xpgom/xgDOMImplementation.hh"
+
+#include <nsIDOMDOMImplementation.h>
+#include <nsCOMPtr.h>
+
+#include "gommacros.h"
+
+#define GET_DOM_IMPLEMENTATION(i) GOM_WRAPPED_GET (i,
nsIDOMDOMImplementation, dom)
+
+static gboolean
+gom_wrapped_dom_implementation_has_feature (GomDOMImplementation *dom,
+ const char *feature,
+ const char *version)
+{
+ GOM_NOT_IMPLEMENTED;
+ return FALSE;
+}
+
+static GomDocumentType *
+gom_wrapped_dom_implementation_create_document_type (GomDOMImplementation
*dom,
+ const char *qualified_name,
+ const char *public_id,
+ const char *system_id,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomDocument *
+gom_wrapped_dom_implementation_create_document (GomDOMImplementation *dom,
+ const char *namespace_uri,
+ const char *qualified_name,
+ GomDocumentType *doctype,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+GOM_WRAPPED_CONSTRUCTOR_INIT (xgDOMImplementation, Init)
+
+GOM_IMPLEMENT (DOM_IMPLEMENTATION, dom_implementation,
gom_wrapped_dom_implementation);
+
+G_DEFINE_TYPE_WITH_CODE (GomWrappedDOMImplementation,
gom_wrapped_dom_implementation, GOM_TYPE_WRAPPED,
+ GOM_IMPLEMENT_INTERFACE (DOM_IMPLEMENTATION, dom_implementation,
gom_wrapped_dom_implementation));
+
+static void gom_wrapped_dom_implementation_init
(GomWrappedDOMImplementation *node) { }
+
+static void
+gom_wrapped_dom_implementation_class_init
(GomWrappedDOMImplementationClass *klass)
+{
+ gom_wrapped_register_interface (GOM_TYPE_DOM_IMPLEMENTATION,
GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION,
+ NS_GET_IID (nsIDOMDOMImplementation),
xgDOMImplementationConstructor);
+}
Added: trunk/gom/src/xpgom/gomwrappedelement.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrappedelement.cc Sat Aug 9 03:37:32 2008
@@ -0,0 +1,223 @@
+/*
+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/gomwrappedelement.hh"
+#include "gom/dom/gomelement.h"
+#include "xpgom/xgElement.hh"
+#include "gom/dom/gomdomexception.h"
+
+#include <nsIDOMElement.h>
+#include <nsCOMPtr.h>
+
+#include "gommacros.h"
+
+enum {
+ PROP_TAG_NAME = 1,
+ PROP_NODE_TYPE,
+ PROP_PREFIX,
+ PROP_NAMESPACE_URI,
+ PROP_LOCAL_NAME
+};
+
+#define GET_ELEMENT(i) GOM_WRAPPED_GET (i, nsIDOMElement, mElement)
+
+static void
+gom_wrapped_element_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GET_ELEMENT (object);
+
+ switch (property_id) {
+ case PROP_TAG_NAME:
+ GOM_NOT_IMPLEMENTED;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gom_wrapped_element_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GET_ELEMENT (object);
+
+ switch (property_id) {
+ case PROP_TAG_NAME:
+ GOM_NOT_IMPLEMENTED;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static char *
+gom_wrapped_element_get_attribute (GomElement *elem, const char *name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static void
+gom_wrapped_element_set_attribute (GomElement *elem, const char *name,
const char *value, GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+}
+
+static void
+gom_wrapped_element_remove_attribute (GomElement *elem, const char *name,
GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+}
+
+static GomAttr *
+gom_wrapped_element_get_attribute_node (GomElement *elem, const char *name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomAttr *
+gom_wrapped_element_set_attribute_node (GomElement *elem, GomAttr
*new_attr, GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomAttr *
+gom_wrapped_element_remove_attribute_node (GomElement *elem, GomAttr
*old_attr, GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNodeList *
+gom_wrapped_element_get_elements_by_tag_name (GomElement *elem, const char
*name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static char *
+gom_wrapped_element_get_attribute_ns (GomElement *elem, const char
*namespace_uri, const char *local_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static void
+gom_wrapped_element_set_attribute_ns (GomElement *elem,
+ const char *namespace_uri,
+ const char *qualified_name,
+ const char *value,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+}
+
+static void
+gom_wrapped_element_remove_attribute_ns (GomElement *elem,
+ const char *namespace_uri,
+ const char *local_name,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+}
+
+static GomAttr *
+gom_wrapped_element_get_attribute_node_ns (GomElement *elem,
+ const char *namespace_uri,
+ const char *local_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static GomAttr *
+gom_wrapped_element_set_attribute_node_ns (GomElement *elem,
+ GomAttr *new_attr,
+ GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNodeList *
+gom_wrapped_element_get_elements_by_tag_name_ns (GomElement *elem,
+ const char *namespace_uri,
+ const char *local_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static gboolean
+gom_wrapped_element_has_attribute (GomElement *elem, const char *name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return FALSE;
+}
+
+static gboolean
+gom_wrapped_element_has_attribute_ns (GomElement *elem, const char
*namespace_uri, const char *local_name)
+{
+ GOM_NOT_IMPLEMENTED;
+ return FALSE;
+}
+
+GOM_WRAPPED_CONSTRUCTOR_INIT (xgElement, Init)
+
+GOM_IMPLEMENT (ELEMENT, element, gom_wrapped_element);
+
+G_DEFINE_TYPE_WITH_CODE (GomWrappedElement, gom_wrapped_element,
GOM_TYPE_WRAPPED_NODE,
+ GOM_IMPLEMENT_INTERFACE (ELEMENT, element, gom_wrapped_element));
+
+static void gom_wrapped_element_init (GomWrappedElement *element) { }
+
+static void
+gom_wrapped_element_class_init (GomWrappedElementClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ oclass->get_property = gom_wrapped_element_get_property;
+ oclass->set_property = gom_wrapped_element_set_property;
+
+ g_object_class_install_property (
+ oclass,
+ PROP_TAG_NAME,
+ g_param_spec_string ("tag-name", NULL,
+ "The name of the element.",
+ NULL,
+ GParamFlags (G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)));
+
+ gom_wrapped_register_interface (GOM_TYPE_ELEMENT,
GOM_TYPE_WRAPPED_ELEMENT,
+ NS_GET_IID (nsIDOMElement), xgElementConstructor);
+}
Added: trunk/gom/src/xpgom/gomwrappednode.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/gomwrappednode.cc Sat Aug 9 03:37:32 2008
@@ -0,0 +1,286 @@
+/*
+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/gomwrappednode.hh"
+#include "gom/dom/gomnode.h"
+#include "xpgom/xgNode.hh"
+#include "gom/dom/gomdomexception.h"
+
+#include <nsIDOMNode.h>
+#include <nsCOMPtr.h>
+#include <nsIDOMDocument.h>
+#include <nsStringAPI.h>
+
+#include "gommacros.h"
+
+enum {
+ PROP_NODE_NAME = 1,
+ PROP_NODE_VALUE,
+ PROP_NODE_TYPE,
+ PROP_PARENT_NODE,
+ PROP_CHILD_NODES,
+ PROP_FIRST_CHILD,
+ PROP_LAST_CHILD,
+ PROP_PREVIOUS_SIBLING,
+ PROP_NEXT_SIBLING,
+ PROP_ATTRIBUTES,
+ PROP_OWNER_DOCUMENT,
+ PROP_NAMESPACE_URI,
+ PROP_PREFIX,
+ PROP_LOCAL_NAME,
+};
+
+#define GET_NODE(i) GOM_WRAPPED_GET (i, nsIDOMNode, mNode)
+
+static void
+gom_wrapped_node_get_property (GObject *object,
+ guint property_id,
+ 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);
+ }
+ break;
+ case PROP_NODE_TYPE:
+ PRUint16 aNodeType;
+ if (NS_SUCCEEDED (mNode->GetNodeType (&aNodeType))) {
+ g_value_set_enum (value, aNodeType);
+ }
+ 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);
+ }
+ 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);
+ }
+ 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);
+ }
+ 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);
+ }
+ 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);
+ }
+ break;
+ case PROP_PREVIOUS_SIBLING:
+ case PROP_PARENT_NODE:
+ case PROP_CHILD_NODES:
+ case PROP_LAST_CHILD:
+ case PROP_PREFIX:
+ case PROP_LOCAL_NAME:
+ case PROP_ATTRIBUTES:
+ GOM_PROPERTY_NOT_IMPLEMENTED (pspec);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gom_wrapped_node_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GET_NODE (object);
+
+ switch (property_id) {
+ case PROP_PREFIX:
+ GOM_PROPERTY_NOT_IMPLEMENTED (pspec);
+ break;
+ case PROP_NAMESPACE_URI:
+ case PROP_LOCAL_NAME:
+ case PROP_OWNER_DOCUMENT:
+ /* */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static GomNode *
+gom_wrapped_node_insert_before (GomNode *node, GomNode *new_child, GomNode
*ref_child, GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_node_replace_child (GomNode *node, GomNode *new_child, GomNode
*ref_child, GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_node_remove_child (GomNode *node, GomNode *old_child, GError
**error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static GomNode *
+gom_wrapped_node_append_child (GomNode *node, GomNode *new_child,
GError **error)
+{
+ GOM_NOT_IMPLEMENTED_ERROR (error);
+ return NULL;
+}
+
+static gboolean
+gom_wrapped_node_has_child_nodes (GomNode *node)
+{
+ GOM_NOT_IMPLEMENTED;
+ return FALSE;
+}
+
+static GomNode *
+gom_wrapped_node_clone_node (GomNode *node, gboolean deep)
+{
+ GOM_NOT_IMPLEMENTED;
+ return NULL;
+}
+
+static void
+gom_wrapped_node_normalize (GomNode *node)
+{
+ GOM_NOT_IMPLEMENTED;
+}
+
+static gboolean
+gom_wrapped_node_is_supported (GomNode *node,
+ const char *feature,
+ const char *version)
+{
+ GOM_NOT_IMPLEMENTED;
+ return FALSE;
+}
+
+static gboolean
+gom_wrapped_node_has_attributes (GomNode *node)
+{
+ GOM_NOT_IMPLEMENTED;
+ return FALSE;
+}
+
+GOM_WRAPPED_CONSTRUCTOR_INIT (xgNode, Init)
+
+GOM_IMPLEMENT (NODE, node, gom_wrapped_node);
+
+G_DEFINE_TYPE_WITH_CODE (GomWrappedNode, gom_wrapped_node,
GOM_TYPE_WRAPPED,
+ GOM_IMPLEMENT_INTERFACE (NODE, node, gom_wrapped_node));
+
+static void gom_wrapped_node_init (GomWrappedNode *node) { }
+
+static void
+gom_wrapped_node_class_init (GomWrappedNodeClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ oclass->get_property = gom_wrapped_node_get_property;
+ oclass->set_property = gom_wrapped_node_set_property;
+
+ g_object_class_override_property (oclass,
PROP_NODE_NAME, "node-name");
+ g_object_class_override_property (oclass,
PROP_NODE_VALUE, "node-value");
+ g_object_class_override_property (oclass,
PROP_NODE_TYPE, "node-type");
+ g_object_class_override_property (oclass,
PROP_PARENT_NODE, "parent-node");
+ g_object_class_override_property (oclass,
PROP_CHILD_NODES, "child-nodes");
+ g_object_class_override_property (oclass,
PROP_FIRST_CHILD, "first-child");
+ g_object_class_override_property (oclass,
PROP_LAST_CHILD, "last-child");
+ g_object_class_override_property (oclass,
PROP_PREVIOUS_SIBLING, "previous-sibling");
+ g_object_class_override_property (oclass,
PROP_NEXT_SIBLING, "next-sibling");
+ g_object_class_override_property (oclass,
PROP_ATTRIBUTES, "attributes");
+
+ g_object_class_install_property (
+ oclass,
+ PROP_OWNER_DOCUMENT,
+ g_param_spec_object ("owner-document", NULL,
+ "The Document object associated with this
node.",
+ GOM_TYPE_DOCUMENT,
+ GParamFlags (G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (
+ oclass,
+ PROP_NAMESPACE_URI,
+ g_param_spec_string ("namespace-u-r-i", "namespace-uri",
+ "The namespace URI of this node, or null if
it is unspecified.",
+ NULL,
+ GParamFlags (G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (
+ oclass,
+ PROP_PREFIX,
+ g_param_spec_string ("prefix", NULL,
+ "The namespace prefix of this node, or null
if it is unspecified.",
+ NULL,
+ GParamFlags (G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (
+ oclass,
+ PROP_LOCAL_NAME,
+ g_param_spec_string ("local-name", NULL,
+ "Returns the local part of the qualified name
of this node.",
+ NULL,
+ GParamFlags (G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)));
+
+ gom_wrapped_register_interface (GOM_TYPE_NODE, GOM_TYPE_WRAPPED_NODE,
+ NS_GET_IID (nsIDOMNode), xgNodeConstructor);
+}
Modified: trunk/gom/src/xpgom/xgDOMImplementation.cc
==============================================================================
--- trunk/gom/src/xpgom/xgDOMImplementation.cc (original)
+++ trunk/gom/src/xpgom/xgDOMImplementation.cc Sat Aug 9 03:37:32 2008
@@ -23,13 +23,12 @@
*/
#include "config.h"
-#include "xpgom/xgDOMImplementation.hh"
+#include "gom/dom/gomdomexception.h"
#include "gom/gomdom.h"
-
+#include "xpgom/gomwrapped.hh"
+#include "xpgom/xgDOMImplementation.hh"
#include "xpgom/xgDocument.hh"
-#include "gom/dom/gomdomexception.h"
-
#include <nsCOMPtr.h>
#include <nsEmbedString.h>
#include <nsIClassInfoImpl.h>
@@ -37,12 +36,20 @@
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XGO_CHECK_INIALIZED
(GOM_TYPE_DOM_IMPLEMENTATION)
+#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED
(GOM_TYPE_DOM_IMPLEMENTATION)
+
+NS_IMPL_ADDREF_INHERITED(xgDOMImplementation, xgWrapped)
+NS_IMPL_RELEASE_INHERITED(xgDOMImplementation, xgWrapped)
+
+NS_INTERFACE_MAP_BEGIN(xgDOMImplementation)
+NS_INTERFACE_MAP_ENTRY(nsIDOMDOMImplementation)
+NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDOMImplementation)
+NS_IMPL_QUERY_CLASSINFO(xgDOMImplementation)
+NS_INTERFACE_MAP_END_INHERITING(xgWrapped)
-NS_IMPL_ISUPPORTS1_CI(xgDOMImplementation, nsIDOMDOMImplementation)
+NS_IMPL_CI_INTERFACE_GETTER1(xgDOMImplementation, nsIDOMDOMImplementation)
-xgDOMImplementation::xgDOMImplementation (GomDOMImplementation *aDom)
- : xgObject (aDom ? G_OBJECT (aDom) : NULL, GOM_TYPE_DOM)
+xgDOMImplementation::xgDOMImplementation () : xgWrapped (GOM_TYPE_DOM)
{
}
@@ -51,12 +58,12 @@
}
nsresult
-xgDOMImplementation::Init ()
+xgDOMImplementation::Init (GObject *aDom)
{
GType ifaces[2];
ifaces[0] = GOM_TYPE_DOM_IMPLEMENTATION;
ifaces[1] = 0;
- return xgObject::Init (ifaces);
+ return xgWrapped::Init (ifaces, aDom);
}
/* boolean hasFeature (in DOMString feature, in DOMString version); */
@@ -66,10 +73,10 @@
PRBool *_retval)
{
CHECK_INITIALIZED;
- GOM_ASTRING_TO_GSTRING (feat, feature, NS_ERROR_INVALID_ARG);
- GOM_ASTRING_TO_GSTRING (ver, version, NS_ERROR_INVALID_ARG);
+ GOM_ASTRING_TO_GSTRING_RETURN (feat, feature, NS_ERROR_INVALID_ARG);
+ GOM_ASTRING_TO_GSTRING_RETURN (ver, version, NS_ERROR_INVALID_ARG);
- *_retval = gom_dom_implementation_has_feature (GOM_DOM_IMPLEMENTATION
(mObject),
+ *_retval = gom_dom_implementation_has_feature (GOM_DOM_IMPLEMENTATION
(mWrapped),
feat, ver);
return NS_OK;
@@ -94,25 +101,19 @@
nsIDOMDocument **_retval)
{
CHECK_INITIALIZED;
- GOM_ASTRING_TO_GSTRING (nspace, namespaceURI, NS_ERROR_INVALID_ARG);
- GOM_ASTRING_TO_GSTRING (qname, qualifiedName, NS_ERROR_INVALID_ARG);
+ GOM_ASTRING_TO_GSTRING_RETURN (nspace, namespaceURI,
NS_ERROR_INVALID_ARG);
+ GOM_ASTRING_TO_GSTRING_RETURN (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),
+ 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);
}
- 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);
- }
+ nsresult rv = gom_wrap_g_object (doc, NS_GET_IID (nsIDOMDocument),
(gpointer *)_retval);
+ 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 Sat Aug 9 03:37:32 2008
@@ -23,30 +23,34 @@
*/
#include "config.h"
-#include "xpgom/xgDocument.hh"
+#include "gom/dom/gomdomexception.h"
#include "gom/gomdoc.h"
+#include "xpgom/gomwrapped.hh"
+#include "xpgom/xgDocument.hh"
+
+#include <nsIDOMElement.h>
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XGO_CHECK_INIALIZED (GOM_TYPE_DOCUMENT)
+#define CHECK_INITIALIZED GOM_XG_WRAPPED_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 () : xgNode (GOM_TYPE_DOC)
{
}
-xgDocument::xgDocument (GomDocument *aDoc, GType aType) : xgNode (aDoc ?
GOM_NODE (aDoc) : NULL, aType)
+xgDocument::xgDocument (GType aType) : xgNode (aType)
{
}
nsresult
-xgDocument::Init()
+xgDocument::Init (GObject *aDoc)
{
GType ifaces[2];
ifaces[0] = GOM_TYPE_DOCUMENT;
ifaces[1] = 0;
- return xgObject::Init (ifaces);
+ return xgWrapped::Init (ifaces, aDoc);
}
/* readonly attribute nsIDOMDocumentType doctype; */
@@ -64,10 +68,20 @@
}
/* readonly attribute nsIDOMElement documentElement; */
-NS_IMETHODIMP xgDocument::GetDocumentElement(nsIDOMElement *
*aDocumentElement)
+NS_IMETHODIMP
+xgDocument::GetDocumentElement (nsIDOMElement **aDocumentElement)
{
CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ 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;
}
/* nsIDOMElement createElement (in DOMString tagName) raises
(DOMException); */
@@ -134,10 +148,25 @@
}
/* 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;
+NS_IMETHODIMP
+xgDocument::ImportNode (nsIDOMNode *importedNode,
+ PRBool deep,
+ nsIDOMNode **_retval)
+{
+ CHECK_INITIALIZED;
+ GError *error = NULL;
+ GomNode *node = (GomNode *)gom_wrap_xpcom (importedNode,
GOM_TYPE_NODE, &error);
+ if (!node) {
+ 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);
+ }
+ nsresult rv = gom_wrap_g_object (ret, NS_GET_IID (nsIDOMNode),
(gpointer *)_retval);
+ g_object_unref (ret);
+ return rv;
}
/* nsIDOMElement createElementNS (in DOMString namespaceURI, in DOMString
qualifiedName) raises (DOMException); */
Added: trunk/gom/src/xpgom/xgElement.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgElement.cc Sat Aug 9 03:37:32 2008
@@ -0,0 +1,150 @@
+/*
+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 "gom/dom/gomdomexception.h"
+#include "gom/gomelem.h"
+#include "xpgom/gomwrapped.hh"
+#include "xpgom/xgElement.hh"
+
+#include <nsIDOMElement.h>
+
+#include "gommacros.h"
+
+#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_ELEMENT)
+
+NS_IMPL_ISUPPORTS_INHERITED1(xgElement, xgNode, nsIDOMElement)
+
+xgElement::xgElement () : xgNode (GOM_TYPE_ELEM)
+{
+}
+
+xgElement::xgElement (GType aType) : xgNode (aType)
+{
+}
+
+nsresult
+xgElement::Init(GObject *aDoc)
+{
+ GType ifaces[2];
+ ifaces[0] = GOM_TYPE_ELEMENT;
+ ifaces[1] = 0;
+ return xgWrapped::Init (ifaces, aDoc);
+}
+
+/* readonly attribute DOMString tagName; */
+NS_IMETHODIMP xgElement::GetTagName(nsAString & aTagName)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* DOMString getAttribute (in DOMString name); */
+NS_IMETHODIMP xgElement::GetAttribute(const nsAString & name, nsAString &
_retval)
+{
+ return NS_ERROR_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;
+}
+
+/* void removeAttribute (in DOMString name) raises (DOMException); */
+NS_IMETHODIMP xgElement::RemoveAttribute(const nsAString & name)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMAttr getAttributeNode (in DOMString name); */
+NS_IMETHODIMP xgElement::GetAttributeNode(const nsAString & name,
nsIDOMAttr **_retval)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMAttr setAttributeNode (in nsIDOMAttr newAttr) raises
(DOMException); */
+NS_IMETHODIMP xgElement::SetAttributeNode(nsIDOMAttr *newAttr, nsIDOMAttr
**_retval)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMAttr removeAttributeNode (in nsIDOMAttr oldAttr) raises
(DOMException); */
+NS_IMETHODIMP xgElement::RemoveAttributeNode(nsIDOMAttr *oldAttr,
nsIDOMAttr **_retval)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIDOMNodeList getElementsByTagName (in DOMString name); */
+NS_IMETHODIMP xgElement::GetElementsByTagName(const nsAString & name,
nsIDOMNodeList **_retval)
+{
+ return NS_ERROR_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;
+}
+
+/* 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;
+}
+
+/* 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;
+}
+
+/* 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;
+}
+
+/* nsIDOMAttr setAttributeNodeNS (in nsIDOMAttr newAttr) raises
(DOMException); */
+NS_IMETHODIMP xgElement::SetAttributeNodeNS(nsIDOMAttr *newAttr,
nsIDOMAttr **_retval)
+{
+ return NS_ERROR_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;
+}
+
+/* boolean hasAttribute (in DOMString name); */
+NS_IMETHODIMP xgElement::HasAttribute(const nsAString & name, PRBool
*_retval)
+{
+ return NS_ERROR_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;
+}
Modified: trunk/gom/src/xpgom/xgGomModule.cc
==============================================================================
--- trunk/gom/src/xpgom/xgGomModule.cc (original)
+++ trunk/gom/src/xpgom/xgGomModule.cc Sat Aug 9 03:37:32 2008
@@ -24,6 +24,10 @@
#include "config.h"
#include "xpgom/xgDOMImplementation.hh"
+#include "xpgom/gomwrappeddomimplementation.hh"
+#include "xpgom/gomwrappeddocument.hh"
+#include "xpgom/gomwrappedelement.hh"
+#include "gom/gomwidget.h"
#include <gtk/gtkmain.h>
@@ -34,31 +38,6 @@
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(xgDOMImplementation, Init);
-#if 0
-static NS_METHOD
-xgGomRegistrationProc (nsIComponentManager *aCompMgr,
- nsIFile *aPath,
- const char *registryLocation,
- const char *componentType,
- const nsModuleComponentInfo *info)
-{
- if (!gtk_init_check (NULL, NULL)) {
- g_warning ("Could not initialize Gtk; Gom module unavailable.");
- return NS_ERROR_NOT_AVAILABLE;
- }
- return NS_OK;
-}
-
-static NS_METHOD
-xgGomUnregistrationProc (nsIComponentManager *aCompMgr,
- nsIFile *aPath,
- const char *registryLocation,
- const nsModuleComponentInfo *info)
-{
- return NS_OK;
-}
-#endif
-
NS_DECL_CLASSINFO(xgDOMImplementation)
static const nsModuleComponentInfo components[] = {
@@ -80,6 +59,10 @@
g_warning ("Could not initialize Gtk; Gom module unavailable.");
return NS_ERROR_NOT_AVAILABLE;
}
+ gom_widget_init ();
+ g_type_class_ref (GOM_TYPE_WRAPPED_DOM_IMPLEMENTATION);
+ 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 Sat Aug 9 03:37:32 2008
@@ -24,22 +24,23 @@
#include "config.h"
#include "xpgom/xgNode.hh"
-
#include "gom/gomnoodle.h"
+#include "gom/dom/gomdomexception.h"
+#include "xpgom/gomwrapped.hh"
#include <nsStringAPI.h>
#include "gommacros.h"
-#define CHECK_INITIALIZED GOM_XGO_CHECK_INIALIZED (GOM_TYPE_NODE)
+#define CHECK_INITIALIZED GOM_XG_WRAPPED_CHECK_INIALIZED (GOM_TYPE_NODE)
-NS_IMPL_ISUPPORTS1 (xgNode, nsIDOMNode)
+NS_IMPL_ISUPPORTS_INHERITED1 (xgNode, xgWrapped, nsIDOMNode)
-xgNode::xgNode (GomNode *aNode) : xgObject (aNode ? G_OBJECT (aNode) :
NULL, GOM_TYPE_NOODLE)
+xgNode::xgNode () : xgWrapped (GOM_TYPE_NOODLE)
{
}
-xgNode::xgNode (GomNode *aNode, GType aType) : xgObject (aNode ? G_OBJECT
(aNode) : NULL, aType)
+xgNode::xgNode (GType aType) : xgWrapped (aType)
{
}
@@ -48,12 +49,12 @@
}
nsresult
-xgNode::Init()
+xgNode::Init (GObject *aNode)
{
GType ifaces[2];
ifaces[0] = GOM_TYPE_NODE;
ifaces[1] = 0;
- return xgObject::Init (ifaces);
+ return xgWrapped::Init (ifaces, aNode);
}
/* readonly attribute DOMString nodeName; */
@@ -61,7 +62,7 @@
{
CHECK_INITIALIZED;
char *s;
- g_object_get (mObject, "node-name", &s, NULL);
+ g_object_get (mWrapped, "node-name", &s, NULL);
nsCAutoString cstr(s);
g_free (s);
CopyUTF8toUTF16 (cstr, aNodeName);
@@ -85,7 +86,7 @@
{
CHECK_INITIALIZED;
GomNodeType t;
- g_object_get (mObject, "node-type", &t, NULL);
+ g_object_get (mWrapped, "node-type", &t, NULL);
*aNodeType = t;
return NS_OK;
}
@@ -154,10 +155,28 @@
}
/* nsIDOMNode replaceChild (in nsIDOMNode newChild, in nsIDOMNode
oldChild) raises (DOMException); */
-NS_IMETHODIMP xgNode::ReplaceChild(nsIDOMNode *newChild, nsIDOMNode
*oldChild, nsIDOMNode **_retval)
+NS_IMETHODIMP xgNode::ReplaceChild (nsIDOMNode *newChild, nsIDOMNode
*oldChild, nsIDOMNode **_retval)
{
CHECK_INITIALIZED;
- return NS_ERROR_NOT_IMPLEMENTED;
+ GError *error = NULL;
+ GomNode *new_child = (GomNode *)gom_wrap_xpcom (newChild,
GOM_TYPE_NODE, &error);
+ if (!new_child) {
+ 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);
+ 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);
+ }
+ nsresult rv = gom_wrap_g_object (ret, NS_GET_IID (nsIDOMNode),
(gpointer *)_retval);
+ g_object_unref (ret);
+ return rv;
}
/* nsIDOMNode removeChild (in nsIDOMNode oldChild) raises (DOMException);
*/
Added: trunk/gom/src/xpgom/xgWrapped.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgWrapped.cc Sat Aug 9 03:37:32 2008
@@ -0,0 +1,76 @@
+/*
+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/xgWrapped.hh"
+
+NS_IMPL_ISUPPORTS1 (xgWrapped, xgPIWrapped)
+
+xgWrapped::xgWrapped (GType aType)
+ : mWrapped (NULL),
+ mType (aType)
+{
+}
+
+xgWrapped::~xgWrapped ()
+{
+ if (mWrapped) {
+ g_object_unref (mWrapped);
+ }
+}
+
+nsresult
+xgWrapped::Init (GType *ifaces, GObject *aObject)
+{
+ if (mWrapped) {
+ return NS_ERROR_ALREADY_INITIALIZED;
+ }
+ if (!aObject) {
+ if (mType) {
+ aObject = (GObject *)g_object_new (mType, NULL);
+ if (!aObject) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+ }
+ for (GType t = G_OBJECT_TYPE (aObject);
+ *ifaces;
+ ++ifaces) {
+ if (!g_type_is_a (t, *ifaces)) {
+ return NS_ERROR_NO_INTERFACE;
+ }
+ }
+ mWrapped = G_OBJECT (g_object_ref (aObject));
+ return NS_OK;
+}
+
+/* xgNativeGObject getWrappedGObject (); */
+NS_IMETHODIMP
+xgWrapped::GetWrappedGObject (GObject **_retval)
+{
+ *_retval = mWrapped ? G_OBJECT (g_object_ref (mWrapped)) : NULL;
+ return NS_OK;
+}
Modified: trunk/gom/src/xpgom/xpgom.js
==============================================================================
--- trunk/gom/src/xpgom/xpgom.js (original)
+++ trunk/gom/src/xpgom/xpgom.js Sat Aug 9 03:37:32 2008
@@ -1,10 +1,40 @@
-(function (args) {
- 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);
- for (var i = 0; i < args.length; i++) {
- print ('args[' + i + '] = ' + args[i]);
+//(function (args) {
+args = arguments;
+ if (args.length == 0) {
+ print ('Usage: xpgom.js <url>');
+ quit (1);
}
-})(arguments);
+ var Cc = Components.classes;
+ var Ci = Components.interfaces;
+ var req =
Cc['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Ci.nsIXMLHttpRequest);
+ print (req);
+ print ('Opening: ' + args[0]);
+ req.open ('GET', args[0], false);
+ req.send(null);
+ print (req.responseXML);
+
+ var serializer =
Cc['@mozilla.org/xmlextras/xmlserializer;1'].createInstance(Ci.nsIDOMSerializer);
+ if (0) {
+ print (serializer.serializeToString(req.responseXML));
+ }
+
+ var root = req.responseXML.documentElement;
+
+ var dom =
Cc['@ilovegom.org/dom-implementation;1'].createInstance(Ci.nsIDOMDOMImplementation);
+ print (dom);
+ print ('has xml: ' + dom.hasFeature ('xml', '1.0'));
+
+ var doc = dom.createDocument (root.namespaceURI, root.nodeName, null);
+ print (doc);
+ if (0) {
+ print (serializer.serializeToString (doc));
+ }
+
+ var gomRoot = doc.importNode (root, true);
+ print (gomRoot);
+ print (gomRoot.nodeType);
+ print (gomRoot.nodeName);
+
+ doc.replaceChild (gomRoot, doc.documentElement);
+ print (doc.documentElement.nodeName);
+//})(arguments);
Modified: trunk/gom/tests/checkgomvalue.c
==============================================================================
--- trunk/gom/tests/checkgomvalue.c (original)
+++ trunk/gom/tests/checkgomvalue.c Sat Aug 9 03:37:32 2008
@@ -39,67 +39,67 @@
static jsval jval;
#define JSINT_VALUES \
- JSVAL_TO_INT (JSVAL_INT_MIN), \
- JSVAL_TO_INT (JSVAL_INT_MIN / 2), \
- -3700, \
- -270, \
- -1, \
- 0, \
- 1, \
- 270, \
- 3700, \
- JSVAL_TO_INT (JSVAL_INT_MAX / 2), \
+ JSVAL_TO_INT (JSVAL_INT_MIN)), \
+ JSVAL_TO_INT (JSVAL_INT_MIN / 2)), \
+ -3700), \
+ -270), \
+ -1), \
+ 0), \
+ 1), \
+ 270), \
+ 3700), \
+ JSVAL_TO_INT (JSVAL_INT_MAX / 2)), \
JSVAL_TO_INT (JSVAL_INT_MAX)
#define JSDOUBLE_VALUES \
- G_E, -G_E, \
- G_LN2, -G_LN2, \
- G_LN10, -G_LN10, \
- G_PI, -G_PI, \
- G_PI_2, -G_PI_2, \
- G_PI_4, -G_PI_4, \
+ G_E, -G_E), \
+ G_LN2, -G_LN2), \
+ G_LN10, -G_LN10), \
+ G_PI, -G_PI), \
+ G_PI_2, -G_PI_2), \
+ G_PI_4, -G_PI_4), \
G_SQRT2, -G_SQRT2
#define GINT_VALUES \
- INT_MIN, \
- INT_MIN / 2, \
- INT_MAX / 2, \
+ INT_MIN), \
+ INT_MIN / 2), \
+ INT_MAX / 2), \
INT_MAX
#define GUINT_VALUES \
- 0, \
- 1, \
- 270, \
- 3700, \
- JSVAL_TO_INT (JSVAL_INT_MAX / 2), \
- JSVAL_TO_INT (JSVAL_INT_MAX), \
- INT_MAX / 2, \
- INT_MAX, \
- UINT_MAX / 2, \
+ 0), \
+ 1), \
+ 270), \
+ 3700), \
+ JSVAL_TO_INT (JSVAL_INT_MAX / 2)), \
+ JSVAL_TO_INT (JSVAL_INT_MAX)), \
+ INT_MAX / 2), \
+ INT_MAX), \
+ UINT_MAX / 2), \
UINT_MAX
#define GLONG_VALUES \
- LONG_MIN, \
- LONG_MIN / 2, \
- LONG_MAX / 2, \
+ LONG_MIN), \
+ LONG_MIN / 2), \
+ LONG_MAX / 2), \
LONG_MAX
#define GULONG_VALUES \
- LONG_MAX / 2, \
- LONG_MAX, \
- ULONG_MAX / 2, \
+ LONG_MAX / 2), \
+ LONG_MAX), \
+ ULONG_MAX / 2), \
ULONG_MAX
#define GINT64_VALUES \
- G_MININT64, \
- G_MININT64 / 2, \
- G_MAXINT64 / 2, \
+ G_MININT64), \
+ G_MININT64 / 2), \
+ G_MAXINT64 / 2), \
G_MAXINT64
#define GUINT64_VALUES \
- G_MAXINT64 / 2, \
- G_MAXINT64, \
- G_MAXUINT64 / 2, \
+ G_MAXINT64 / 2), \
+ G_MAXINT64), \
+ G_MAXUINT64 / 2), \
G_MAXUINT64
static int jsval_int_values[] = {
@@ -372,14 +372,14 @@
} \
END_TEST
-CHECK_G_VALUE_NUMBER (int, int, G_TYPE_INT);
-CHECK_G_VALUE_NUMBER (uint, guint, G_TYPE_UINT);
-CHECK_G_VALUE_NUMBER (long, long, G_TYPE_LONG);
-CHECK_G_VALUE_NUMBER (ulong, gulong, G_TYPE_ULONG);
-CHECK_G_VALUE_NUMBER (int64, gint64, G_TYPE_INT64);
+CHECK_G_VALUE_NUMBER (int), int), G_TYPE_INT);
+CHECK_G_VALUE_NUMBER (uint), guint), G_TYPE_UINT);
+CHECK_G_VALUE_NUMBER (long), long), G_TYPE_LONG);
+CHECK_G_VALUE_NUMBER (ulong), gulong), G_TYPE_ULONG);
+CHECK_G_VALUE_NUMBER (int64), gint64), G_TYPE_INT64);
CHECK_G_VALUE_NUMBER (uint64, guint64, G_TYPE_UINT64);
-CHECK_G_VALUE_NUMBER (float, float, G_TYPE_FLOAT);
-CHECK_G_VALUE_NUMBER (double, double, G_TYPE_DOUBLE);
+CHECK_G_VALUE_NUMBER (float), float), G_TYPE_FLOAT);
+CHECK_G_VALUE_NUMBER (double, double), G_TYPE_DOUBLE);
START_TEST (test_gom_value_g_value_string)
{
@@ -416,7 +416,7 @@
#define _LOOPED_CASE(typename, type, valname) \
tcase = tcase_create (#type); \
tcase_add_checked_fixture (tcase, setup, teardown); \
- tcase_add_loop_test (tcase, test_gom_value_##valname##_##typename, \
+ tcase_add_loop_test (tcase, test_gom_value_##valname##_##typename), \
0, G_N_ELEMENTS (valname##_##typename##_values));
\
suite_add_tcase (s, tcase);
@@ -463,13 +463,13 @@
tcase_add_test (tcase, test_gom_value_g_value_boolean_false);
suite_add_tcase (s, tcase);
- G_LOOPED_CASE (int, G_TYPE_INT);
- G_LOOPED_CASE (uint, G_TYPE_UINT);
- G_LOOPED_CASE (long, G_TYPE_LONG);
- G_LOOPED_CASE (ulong, G_TYPE_ULONG);
- G_LOOPED_CASE (int64, G_TYPE_INT64);
+ G_LOOPED_CASE (int), G_TYPE_INT);
+ G_LOOPED_CASE (uint), G_TYPE_UINT);
+ G_LOOPED_CASE (long), G_TYPE_LONG);
+ G_LOOPED_CASE (ulong), G_TYPE_ULONG);
+ G_LOOPED_CASE (int64), G_TYPE_INT64);
G_LOOPED_CASE (uint64, G_TYPE_UINT64);
- G_LOOPED_CASE (float, G_TYPE_FLOAT);
+ G_LOOPED_CASE (float), G_TYPE_FLOAT);
G_LOOPED_CASE (double, G_TYPE_DOUBLE);
G_LOOPED_CASE (string, G_TYPE_STRING);