Added:
trunk/gom/src/libgom/gomuriutils.c
Modified:
trunk/gom/ChangeLog
trunk/gom/configure.ac
trunk/gom/include/xpgom/Makefile.inc
trunk/gom/src/gom/Makefile.inc
trunk/gom/src/gom/gom.c
trunk/gom/src/libgom/Makefile.inc
Log:
2008-08-13 jacob berkman <ja...@ilovegom.org>
* src/gom/gom.c (main): disable xpcom initialization
* src/libgom/gomuriutils.c (gom_uri_join)
(gom_uri_get_contents): implement using gio
Modified: trunk/gom/ChangeLog
==============================================================================
--- trunk/gom/ChangeLog (original)
+++ trunk/gom/ChangeLog Wed Aug 13 23:39:57 2008
@@ -1,3 +1,10 @@
+2008-08-13 jacob berkman <ja...@ilovegom.org>
+
+ * src/gom/gom.c (main): disable xpcom initialization
+
+ * src/libgom/gomuriutils.c (gom_uri_join)
+ (gom_uri_get_contents): implement using gio
+
2008-08-12 jacob berkman <ja...@ilovegom.org>
* src/xpgom/xpgom.js: use an io stream and
Modified: trunk/gom/configure.ac
==============================================================================
--- trunk/gom/configure.ac (original)
+++ trunk/gom/configure.ac Wed Aug 13 23:39:57 2008
@@ -24,7 +24,7 @@
GTK_REQVER="2.6.0"
CURL_REQVER="0"
-GOM_MODULES="gtk+-2.0 >= $GTK_REQVER gthread-2.0"
+GOM_MODULES="gtk+-2.0 >= $GTK_REQVER gthread-2.0 gio-2.0"
PKG_CHECK_MODULES(GOM, [$GOM_MODULES])
AC_SUBST(GOM_CFLAGS)
AC_SUBST(GOM_LIBS)
Modified: trunk/gom/include/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/include/xpgom/Makefile.inc (original)
+++ trunk/gom/include/xpgom/Makefile.inc Wed Aug 13 23:39:57 2008
@@ -3,7 +3,7 @@
# xpgomincludedir := $(includedir)/gom-0/xpgom
# xpgominclude_HEADERS :=
noinst_HEADERS += include/xpgom/gomwrapped.hh
-noinst_HEADERS += include/xpgom/gomwrappedattr.h
+noinst_HEADERS += include/xpgom/gomwrappedattr.hh
noinst_HEADERS += include/xpgom/gomwrappeddocument.hh
noinst_HEADERS += include/xpgom/gomwrappeddomimplementation.hh
noinst_HEADERS += include/xpgom/gomwrappedelement.hh
Modified: trunk/gom/src/gom/Makefile.inc
==============================================================================
--- trunk/gom/src/gom/Makefile.inc (original)
+++ trunk/gom/src/gom/Makefile.inc Wed Aug 13 23:39:57 2008
@@ -6,7 +6,7 @@
empty.cc:
touch $@
-gom_SOURCES := src/gom/gom.c empty.cc
+gom_SOURCES := src/gom/gom.c # empty.cc
gom_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
$(GOM_CFLAGS)
gom_CXXFLAGS = -fshort-wchar
gom_LDADD := libgom.a $(GOM_LIBS)
Modified: trunk/gom/src/gom/gom.c
==============================================================================
--- trunk/gom/src/gom/gom.c (original)
+++ trunk/gom/src/gom/gom.c Wed Aug 13 23:39:57 2008
@@ -31,6 +31,9 @@
#include "gom/gomjsobject.h"
#include "gom/gomwidget.h"
+#include "gommacros.h"
+
+#ifdef GOM_USE_XPCOM
#include <nsXPCOM.h>
#if 0
@@ -67,6 +70,7 @@
NS_HIDDEN_(nsresult)
XPCOMGlueStartup(const char* xpcomFile);
#endif
+#endif
#include <gtk/gtk.h>
@@ -129,9 +133,11 @@
MainData d = { NULL };
GObject *cxpriv;
JSRuntime *rt;
+#ifdef GOM_USE_XPCOM
nsresult rv;
char xpcom_path[PATH_MAX];
GREVersionRange gre_version = { "1.9", PR_TRUE, "2", PR_TRUE };
+#endif
gtk_init (&argc, &argv);
@@ -139,7 +145,7 @@
g_printerr ("Usage: gom <file.gom>\n");
return 1;
}
-
+#ifdef GOM_USE_XPCOM
rv = GRE_GetGREPathWithProperties (&gre_version, 1, nsnull, 0,
xpcom_path, sizeof (xpcom_path));
if (NS_FAILED (rv)) {
@@ -152,7 +158,7 @@
g_printerr ("Could not start up xpcom glue.\n");
return 1;
}
-
+#endif
d.filename = argv[1];
gom_widget_init ();
Modified: trunk/gom/src/libgom/Makefile.inc
==============================================================================
--- trunk/gom/src/libgom/Makefile.inc (original)
+++ trunk/gom/src/libgom/Makefile.inc Wed Aug 13 23:39:57 2008
@@ -43,7 +43,7 @@
src/libgom/gomobject.c \
src/libgom/gomtxt.c \
src/libgom/gomuievt.c \
- src/libgom/gomuriutils.cc \
+ src/libgom/gomuriutils.c \
src/libgom/gomvalue.c \
src/libgom/gomwidget.c \
src/libgom/gomxhr.c
Added: trunk/gom/src/libgom/gomuriutils.c
==============================================================================
--- (empty file)
+++ trunk/gom/src/libgom/gomuriutils.c Wed Aug 13 23:39:57 2008
@@ -0,0 +1,95 @@
+/*
+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/gomuriutils.h"
+#include "gommacros.h"
+
+#include <gio/gio.h>
+
+#include <string.h>
+
+static GFile *
+get_relative (const char *uri, const char *base_uri)
+{
+ GFile *base;
+ GFile *rel;
+
+ if (!base_uri) {
+ return g_file_new_for_uri (uri);
+ }
+
+ /* g_file_resolve_relative_path() is totally daft; it treats
+ * base_uri as a directory, but g_file_new_for_uri() forgets the
+ * trailing '/' so we can't always use _get_parent().
+ */
+ base = g_file_new_for_uri (base_uri);
+ if (base_uri[strlen (base_uri) - 1] != '/') {
+ GFile *parent;
+ parent = g_file_get_parent (base);
+ g_object_unref (base);
+ base = parent;
+ }
+ rel = g_file_resolve_relative_path (base, uri);
+ g_object_unref (base);
+
+ return rel;
+}
+
+char *
+gom_uri_join (const char *uri, const char *base_uri, GError **error)
+{
+ GFile *rel;
+ char *ret;
+
+ rel = get_relative (uri, base_uri);
+ ret = g_file_get_uri (rel);
+ g_object_unref (rel);
+
+ return ret;
+}
+
+gboolean
+gom_uri_get_contents (const char *uri,
+ const char *base_uri,
+ char **contents,
+ gsize *length,
+ GError **error)
+{
+ GFile *rel;
+ gboolean ret;
+
+ rel = get_relative (uri, base_uri);
+ {
+ char *s = g_file_get_uri (rel);
+ g_print (GOM_LOC ("URI: %s\n"), s);
+ g_free (s);
+ }
+
+ ret = g_file_load_contents (rel, NULL, contents, length, NULL, error);
+ g_object_unref (rel);
+
+ return ret;
+}
+