From: <br...@us...> - 2008-12-10 09:46:55
|
Revision: 3813 http://openvrml.svn.sourceforge.net/openvrml/?rev=3813&view=rev Author: braden Date: 2008-12-10 09:46:49 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Build libraries with -no-undefined. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-12-03 07:18:15 UTC (rev 3812) +++ trunk/ChangeLog 2008-12-10 09:46:49 UTC (rev 3813) @@ -1,3 +1,7 @@ +2008-12-10 Braden McDaniel <br...@en...> + + * src/Makefile.am: Build libraries with -no-undefined. + 2008-11-24 Braden McDaniel <br...@en...> Provide access to a PROTO instance's implementation nodes. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-12-03 07:18:15 UTC (rev 3812) +++ trunk/src/Makefile.am 2008-12-10 09:46:49 UTC (rev 3813) @@ -113,6 +113,7 @@ libopenvrml_libopenvrml_la_LDFLAGS = \ -version-info $(LIBOPENVRML_LIBRARY_VERSION) \ + -no-undefined \ $(XML_LIBS) \ $(PTHREAD_LIBS) @@ -140,9 +141,12 @@ script_javascript_la_CXXFLAGS = $(JS_CFLAGS) script_javascript_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version \ $(OPENVRML_JAVASCRIPT_RPATH) \ $(JS_LIBS) +script_javascript_la_LIBADD = \ + libopenvrml/libopenvrml.la script_java_la_SOURCES = script/java.cpp script_java_la_CPPFLAGS = \ @@ -157,7 +161,10 @@ -DBOOST_MPL_LIMIT_VECTOR_SIZE=30 script_java_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +script_java_la_LIBADD = \ + libopenvrml/libopenvrml.la openvrmlnodedir = $(pkglibdir)/node openvrmlnode_LTLIBRARIES = \ @@ -308,12 +315,15 @@ node/vrml97/cad_assembly.cpp node_vrml97_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version \ $(JPEG_LIBS) \ $(PNG_LIBS) \ $(FONTCONFIG_LIBS) \ $(FREETYPE_LIBS) \ $(PTHREAD_LIBS) +node_vrml97_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_core_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -336,7 +346,10 @@ node/x3d-core/metadata_string.h node_x3d_core_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_core_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_networking_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -349,7 +362,10 @@ node/x3d-networking/load_sensor.h node_x3d_networking_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_networking_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_grouping_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -362,7 +378,10 @@ node/x3d-grouping/static_group.h node_x3d_grouping_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_grouping_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_rendering_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -387,7 +406,10 @@ node/x3d-rendering/triangle_strip_set.h node_x3d_rendering_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_rendering_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_shape_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -402,7 +424,10 @@ node/x3d-shape/line_properties.h node_x3d_shape_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_shape_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_geometry2d_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -429,7 +454,10 @@ node/x3d-geometry2d/triangle_set2d.h node_x3d_geometry2d_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_geometry2d_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_texturing_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -448,7 +476,10 @@ node/x3d-texturing/texture_coordinate_generator.h node_x3d_texturing_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_texturing_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_interpolation_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -463,7 +494,10 @@ node/x3d-interpolation/position_interpolator2d.h node_x3d_interpolation_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_interpolation_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_key_device_sensor_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -478,7 +512,10 @@ node/x3d-key-device-sensor/string_sensor.h node_x3d_key_device_sensor_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_key_device_sensor_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_event_utilities_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -503,7 +540,10 @@ node/x3d-event-utilities/time_trigger.h node_x3d_event_utilities_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_event_utilities_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_dis_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -522,7 +562,10 @@ node/x3d-dis/transmitter_pdu.h node_x3d_dis_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_dis_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_environmental_effects_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -535,7 +578,10 @@ node/x3d-environmental-effects/texture_background.h node_x3d_environmental_effects_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_environmental_effects_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_geospatial_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -566,7 +612,10 @@ node/x3d-geospatial/geo_viewpoint.h node_x3d_geospatial_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_geospatial_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_h_anim_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -587,7 +636,10 @@ node/x3d-h-anim/h_anim_site.h node_x3d_h_anim_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_h_anim_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_nurbs_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -626,7 +678,10 @@ node/x3d-nurbs/nurbs_trimmed_surface.h node_x3d_nurbs_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_nurbs_la_LIBADD = \ + libopenvrml/libopenvrml.la node_x3d_cad_geometry_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -640,7 +695,10 @@ node/x3d-cad-geometry/indexed_quad_set.h node_x3d_cad_geometry_la_LDFLAGS = \ -module \ + -no-undefined \ -avoid-version +node_x3d_cad_geometry_la_LIBADD = \ + libopenvrml/libopenvrml.la libopenvrml_gl_libopenvrml_gl_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ @@ -652,6 +710,7 @@ libopenvrml-gl/openvrml/gl/viewer.cpp libopenvrml_gl_libopenvrml_gl_la_LDFLAGS = \ -version-info $(LIBOPENVRML_GL_LIBRARY_VERSION) \ + -no-undefined \ $(GLU_LIBS) libopenvrml_gl_libopenvrml_gl_la_LIBADD = libopenvrml/libopenvrml.la This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-02-27 07:56:28
|
Revision: 3814 http://openvrml.svn.sourceforge.net/openvrml/?rev=3814&view=rev Author: braden Date: 2009-02-27 07:56:25 +0000 (Fri, 27 Feb 2009) Log Message: ----------- Clear the maps before unloading the modules so that we don't reference code that's just been unloaded. Modified Paths: -------------- trunk/ChangeLog trunk/src/libopenvrml/openvrml/script.cpp Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-12-10 09:46:49 UTC (rev 3813) +++ trunk/ChangeLog 2009-02-27 07:56:25 UTC (rev 3814) @@ -1,3 +1,10 @@ +2009-02-27 Braden McDaniel <br...@en...> + + * src/libopenvrml/openvrml/script.cpp + (openvrml::script_factory_registry::impl::~impl()): Clear the maps + before unloading the modules so that we don't reference code + that's just been unloaded. + 2008-12-10 Braden McDaniel <br...@en...> * src/Makefile.am: Build libraries with -no-undefined. Modified: trunk/src/libopenvrml/openvrml/script.cpp =================================================================== --- trunk/src/libopenvrml/openvrml/script.cpp 2008-12-10 09:46:49 UTC (rev 3813) +++ trunk/src/libopenvrml/openvrml/script.cpp 2009-02-27 07:56:25 UTC (rev 3814) @@ -471,6 +471,14 @@ openvrml::script_factory_registry::impl::~impl() OPENVRML_NOTHROW { using namespace openvrml::local; + + // + // Clear the maps before unloading the modules so that we don't reference + // code that's just been unloaded. + // + this->uri_scheme_map_.clear(); + this->media_type_map_.clear(); + std::for_each(this->module_handles_.begin(), this->module_handles_.end(), dl::close); dl::exit(); // Don't care if this fails. What would we do? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-01 05:11:07
|
Revision: 3815 http://openvrml.svn.sourceforge.net/openvrml/?rev=3815&view=rev Author: braden Date: 2009-03-01 05:11:00 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Moved D-Bus interaction out of the main (GTK+) thread and into its own background thread. This avoids a deadlock when a resource fetch comes from the rendering thread and waits on feedback that will happen via D-Bus. Modified Paths: -------------- trunk/ChangeLog trunk/src/openvrml-xembed/browser.cpp trunk/src/openvrml-xembed/browser.h trunk/src/openvrml-xembed/browserfactory.cpp trunk/src/openvrml-xembed/browserfactory.h trunk/src/openvrml-xembed/main.cpp trunk/src/openvrml-xembed/plugin_streambuf.cpp trunk/src/openvrml-xembed/plugin_streambuf.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-02-27 07:56:25 UTC (rev 3814) +++ trunk/ChangeLog 2009-03-01 05:11:00 UTC (rev 3815) @@ -1,3 +1,224 @@ +2009-03-01 Braden McDaniel <br...@en...> + + Moved D-Bus interaction out of the main (GTK+) thread and into its + own background thread. This avoids a deadlock when a resource + fetch comes from the rendering thread and waits on feedback that + will happen via D-Bus. + + openvrml-xembed's "browser" now exists in two parts: + OpenvrmlXembedBrowser is primarily responsible for interaction + with the host (via D-Bus) and OpenvrmlXembedBrowserPlug is a GTK+ + widget that is responsible for rendering and interaction with + GTK+. + + * src/openvrml-xembed/browser.cpp + (browser_listener): Contain a reference to the + OpenvrmlXembedBrowser (instead of the GtkGLViewer). + (OpenvrmlXembedBrowserPrivate_): Removed drawing_area and viewer + members; those have moved to OpenvrmlXembedBrowserPlugPrivate_. + Added listener, browser_plug, browser_plug_mutex, + browser_plug_set_cond, browser_initialized_mutex, and + browser_initialized. + (openvrml_xembed_browser_class_init(OpenvrmlXembedBrowserClass *)): + Set constructor and finalize function pointers; use + g_param_spec_object to define the control-host-proxy property. + (openvrml_xembed_browser_constructor(GType, guint, + GObjectConstructParam *)): Since OpenvrmlXembedBrowser isn't a + widget anymore, moved the initialization code that was in _realize + here. + (openvrml_xembed_browser_finalize(GObject *)): Destroy the stuff + that was created in _constructor. + (openvrml_xembed_browser_set_property(GObject *, guint, const + GValue *, GParamSpec *)): Use g_value_get_object to get the value + for control-host-property + (openvrml_xembed_browser_get_property(GObject *, guint, GValue *, + GParamSpec *)): Use g_value_set_object to set the value for + control-host-proxy property. + (openvrml_xembed_browser_new(DBusGProxy *, gboolean, + GMainContext *, GdkNativeWindow)): Create an OpenvrmlXembedBrowser + and send an event to the GTK+ thread to create an + OpenvrmlXembedBrowserPlug. + (openvrml_xembed_browser_new_for_display(DBusGProxy *, + GdkDisplay *, GdkNativeWindow, gboolean)): Removed. + (load_url): Moved out of GtkGLViewer; lock the + OpenvrmlXembedBrowser's browser_initialized_mutex. + (openvrml_xembed_browser_load_url(OpenvrmlXembedBrowser *, const + gchar **, const gchar **, GError **)): Handle exceptions by + setting the GError. + (openvrml_xembed_browser_get_id(OpenvrmlXembedBrowser *)): We + don't have the plug's ID until the OpenvrmlXembedBrowserPlug has + been created; wait for browser_plug_set_cond. + (openvrml_xembed_browser_initialized(OpenvrmlXembedBrowser *)): + Indicate whether the underlying openvrml::browser has emitted an + "initialized" event. + (GtkGLViewer): Removed friendship declarations for + openvrml_xembed_browser_load_url, + openvrml_xembed_browser_get_world_url, + openvrml_xembed_browser_timeout_callback, and + openvrml_xembed_browser_motion_notify_event. Changed friendship + declaration for openvrml_xembed_browser_expose_event to + openvrml_xembed_browser_plug_expose_event. Grant friendship to + openvrml_xembed_browser_plug_realize and browser_initialized. + Removed browser_listener_, browser_initialized_, and + browser_initialized_mutex_ members; these were moved to + OpenvrmlXembedBrowser. + (OpenvrmlXembedBrowserPlugPrivate_): Private data for + OpenvrmlXembedBrowserPlug. + (openvrml_xembed_browser_plug_init(OpenvrmlXembedBrowserPlug *)): + Initialize the OpenvrmlXembedBrowserPlug instance. + (openvrml_xembed_browser_plug_class_init(OpenvrmlXembedBrowserPlugClass *)): + Initialized the OpenvrmlXembedBrowserPlug class object. + (openvrml_xembed_browser_plug_set_property(GObject *, gint, const + GValue *, GParamSpec *)): OpenvrmlXembedBrowserPlug property + mutator. + (openvrml_xembed_browser_plug_get_property(GObject *, gint, + GValue *, GParamSpec *)): OpenvrmlXembedBrowserPlug property + accessor. + (openvrml_xembed_browser_plug_new(OpenvrmlXembedBrowser *, + GdkNativeWindow)): Create an OpenvrmlXembedBrowserPlug. + (browser_initialized(OpenvrmlXembedBrowser *, + OpenvrmlXembedBrowserPlug *)): Callback called once the underlying + openvrml::browser emits an "initialized" event. + (openvrml_xembed_browser_plug_realize(GtkWidget *)): Instantiate + the GtkGLViewer, set up the GtkDrawingArea, and attach the various + signal handlers. + (openvrml_xembed_browser_plug_unrealize(GtkWidget *)): Destroy the + GtkGLViewer and the GtkDrawingArea. + (openvrml_xembed_drawing_area_expose_event(GtkWidget *, + GdkEventExpose *, OpenvrmlXembedBrowserPlug *)): Moved from + openvrml_xembed_browser_expose_event. + (openvrml_xembed_drawing_area_configure_event(GtkWidget *, + GdkEventConfigure *, OpenvrmlXembedBrowserPlug *)): Moved from + openvrml_xembed_browser_configure_event. + (openvrml_xembed_drawing_area_key_press_event(GtkWidget *, + GdkEventKey *, OpenvrmlXembedBrowserPlug *)): Moved from + openvrml_xembed_browser_key_press_event. + (openvrml_xembed_drawing_area_button_press_event(GtkWidget *, + GdkEventButton *, OpenvrmlXembedBrowserPlug *)): Moved from + openvrml_xembed_browser_button_press_event. + (openvrml_xembed_drawing_area_button_release_event(GtkWidget *, + GdkEventButton *, OpenvrmlXembedBrowserPlug *)): Moved from + openvrml_xembed_browser_button_release_event. + (openvrml_xembed_drawing_area_motion_notify_event(GtkWidget *, + GdkEventMotion *, OpenvrmlXembedBrowserPlug *)): Moved from + openvrml_xembed_browser_motion_notify_event. + (openvrml_xembed_browser_plug_timeout_callback(gpointer)): Moved + from openvrml_xembed_browser_timeout_callback. + (browser_listener::browser_listener(OpenvrmlXembedBrowser &)): + Hold a reference to the OpenvrmlXembedBrowser instead of the + GtkGLViewer. + (browser_listener::do_browser_changed(const + openvrml::browser_event &)): For "initialized", just emit the + signal and set browser_initialized on the OpenvrmlXembedBrowser. + Anything we need to do in the OpenvrmlXembedBrowserPlug can be + handled with a GObject signal handler. + (GtkGLViewer::GtkGLViewer(OpenvrmlXembedBrowserPlug &)): Take a + reference to the OpenvrmlXembedBrowserPlug instead of the + OpenvrmlXembedBrowser. We no longer handle the listener here. + (GtkGLViewer::~GtkGLViewer()): We no longer handle the listener + here. + (OpenvrmlXembedBrowserReadySource): The event source used to + trigger creation of the OpenvrmlXembedBrowserPlug in the GTK+ main + thread. + (openvrml_xembed_browser_ready_source_new(OpenvrmlXembedBrowser *, + guint64)): Create an OpenvrmlXembedBrowserReadySource. + (openvrml_xembed_browser_ready_prepare(GSource *, gint *)): Set + timeout to 0 and return true; + (openvrml_xembed_browser_ready_check(GSource *)): Return true. + (openvrml_xembed_browser_ready_dispatch(GSource *, GSourceFunc, + gpointer)): Create, realize, and show the + OpenvrmlXembedBrowserPlug. + (openvrml_xembed_browser_ready_finalize(GSource *)): Do nothing. + * src/openvrml-xembed/browser.h + (OpenvrmlXembedBrowser_): Inherit GObject instead of GtkPlug. + (OpenvrmlXembedBrowserClass_): Inherit GObjectClass instead of + GtkPlugClass. + (openvrml_xembed_browser_new(DBusGProxy *, gboolean, + GMainContext *, GdkNativeWindow)): Take the GMainContext + associated with the GTK+ main thread as an argument. + (openvrml_xembed_browser_constructor(GType, guint, + GObjectConstructParam *)): plugin_streambuf needs to grant + friendship to this. + (OpenvrmlXembedBrowserPlug): A GTK+ widget to handle rendering. + (OpenvrmlXembedBrowserPlugClass): Class object for + OpenvrmlXembedBrowserPlug. + (openvrml_xembed_browser_plug_new(OpenvrmlXembedBrowser *, + GtkNativeWindow)): Create a new OpenvrmlXembedBrowserPlug. + (openvrml_xembed_browser_plug_get_type(void)): Get the GType for + OpenvrmlXembedBrowserPlug. + * src/openvrml-xembed/browserfactory.cpp + (OpenvrmlXembedBrowserFactoryPrivate_): Removed driver_proxy + member; added connection and main_thread_context members. + (openvrml_xembed_browser_factory_constructor(GType, guint, + GObjectConstructParam *)): Register the D-Bus object + "/org/openvrml/BrowserFactory" and request the + "org.openvrml.BrowserControl" name. + (openvrml_xembed_browser_factory_class_init(OpenvrmlXembedBrowserFactory *)): + Set the property accessor and mutator functions; add the + "connection" and "main-thread-context" properties. + (openvrml_xembed_browser_factory_set_property(GObject *, guint, + const GValue *, GParamSpec *)): Property mutator. + (openvrml_xembed_browser_factory_get_property(GObject *, guint, + GValue *, GParamSpec *)): Property accessor. + (openvrml_xembed_browser_factory_create_control(OpenvrmlXembedBrowserFactory *, + const char *, const char *, guint64, gboolean, + DBusGMethodInvocation *)): Don't realize/show the widget here; + that's now taken care of by + openvrml_xembed_browser_ready_dispatch. + (openvrml_xembed_browser_factory_remove_hosts_for_owner(OpenvrmlXembedBrowserFactory *, + const char *)): Remove references to hosts for the named owner. + (openvrml_xembed_browser_factory_has_hosts(OpenvrmlXembedBrowserFactory *)): + Indicate whether any hosts are associated with the factory. + (openvrml_xembed_browser_factory_name_owner_changed(DBusGProxy *, + const gchar *, const gchar *, const gchar *, gpointer)): Moved to + main.cpp. + * src/openvrml-xembed/browserfactory.h + (OpenvrmlXembedBrowserFactoryClass_): Removed connection member. + Establishing the bus connection is no longer the responsibility of + OpenvrmlXembedBrowserFactory. + (openvrml_xembed_browser_factory_remove_hosts_for_owner(OpenvrmlXembedBrowserFactory *, + const gchar *)): Added public function. + (openvrml_xembed_browser_factory_has_hosts(OpenvrmlXembedBrowserFactory *)): + Added public function. + * src/openvrml-xembed/main.cpp + (bus_get(GMainContext *, DBusBusType, GError **)): Get a + DBusGConnection using a particular GMainContext. + (name_owner_changed_callback_data): Data propagated to + openvrml_xembed_name_owner_changed. + (dbus_thread_loop): Function object for the D-Bus thread main + loop. + (main(int, char *[])): Start, and ultimately join, a thread for + D-Bus interactions. + (openvrml_xembed_name_owner_changed(DBusGProxy *, const gchar *, + const gchar *, const gchar *, gpointer)): Callback to clean up the + browser(s) associated with a host (and exit if there are no more + hosts). + * src/openvrml-xembed/plugin_streambuf.cpp + (openvrml_xembed::plugin_streambuf::plugin_streambuf(const + std::string &, uninitialized_plugin_streambuf_map &, + plugin_streambuf_map &)): Removed initialization of member + "initialized_". + (openvrml_xembed::plugin_streambuf::set_get_url_result(int)): Only + notify waiting threads if the "GetUrl" result indicates success; + the only reason anyone should be waiting on this is if the fetch + operation has (at least partially) succeeded. + (openvrml_xembed::plugin_streambuf::get_url_result() const): + Removed. + (openvrml_xembed::plugin_streambuf::init(size_t, const + std::string&, const std::string &)): Wait for set_get_url_result + to be called. + (openvrml_xembed::plugin_streambuf::url() const): Check state_ + instead of initialized_. + (openvrml_xembed::plugin_streambuf::type() const): Check state_ + instead of initialized_. + (openvrml_xembed::plugin_streambuf::underflow()): Check state_ + instead of initialized_. + * src/openvrml-xembed/plugin_streambuf.h + (openvrml_xembed::plugin_streambuf): Removed friend declaration + for openvrml_xembed_browser_realize; grant friendship to + openvrml_xembed_browser_constructor. Removed member + "initialized_". Removed "get_url_result" member function. + 2009-02-27 Braden McDaniel <br...@en...> * src/libopenvrml/openvrml/script.cpp Modified: trunk/src/openvrml-xembed/browser.cpp =================================================================== --- trunk/src/openvrml-xembed/browser.cpp 2009-02-27 07:56:25 UTC (rev 3814) +++ trunk/src/openvrml-xembed/browser.cpp 2009-03-01 05:11:00 UTC (rev 3815) @@ -31,6 +31,7 @@ # include <openvrml/gl/viewer.h> # include "browser.h" # include "browser-server-glue.h" +# include "browser-host-client-glue.h" # include "plugin_streambuf.h" # include <gtk/gtkgl.h> # include <gtk/gtkdrawingarea.h> @@ -56,60 +57,22 @@ GParamSpec * pspec); // - // GtkWidget overrides - // - G_GNUC_INTERNAL void openvrml_xembed_browser_realize(GtkWidget * widget); - G_GNUC_INTERNAL void openvrml_xembed_browser_unrealize(GtkWidget * widget); - - // // OpenvrmlXembedStreamClient implementation // G_GNUC_INTERNAL void openvrml_xembed_browser_stream_client_interface_init(gpointer g_iface, gpointer iface_data); - - // - // Signal handlers - // - G_GNUC_INTERNAL - gboolean openvrml_xembed_browser_expose_event(GtkWidget * widget, - GdkEventExpose * event, - gpointer data); - G_GNUC_INTERNAL - gboolean openvrml_xembed_browser_configure_event(GtkWidget * widget, - GdkEventConfigure * event, - gpointer data); - G_GNUC_INTERNAL - gboolean openvrml_xembed_browser_key_press_event(GtkWidget * widget, - GdkEventKey * event, - gpointer data); - G_GNUC_INTERNAL - gboolean openvrml_xembed_browser_button_press_event(GtkWidget * widget, - GdkEventButton * event, - gpointer data); - G_GNUC_INTERNAL - gboolean openvrml_xembed_browser_button_release_event(GtkWidget * widget, - GdkEventButton * event, - gpointer data); - G_GNUC_INTERNAL - gboolean openvrml_xembed_browser_motion_notify_event(GtkWidget * widget, - GdkEventMotion * event, - gpointer data); - - G_GNUC_INTERNAL gint openvrml_xembed_browser_timeout_callback(gpointer ptr); } G_DEFINE_TYPE_WITH_CODE(OpenvrmlXembedBrowser, openvrml_xembed_browser, - GTK_TYPE_PLUG, + G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE( OPENVRML_XEMBED_TYPE_STREAM_CLIENT, openvrml_xembed_browser_stream_client_interface_init)) namespace { - G_GNUC_INTERNAL GdkGLConfig * gl_config; - class G_GNUC_INTERNAL resource_fetcher : public openvrml::resource_fetcher { DBusGProxy & control_host_; openvrml_xembed::uninitialized_plugin_streambuf_map & @@ -132,84 +95,32 @@ do_get_resource(const std::string & uri); }; + class G_GNUC_INTERNAL browser_listener : public openvrml::browser_listener { + OpenvrmlXembedBrowser & browser_; - class GtkGLViewer; - - class G_GNUC_INTERNAL browser_listener : - public openvrml::browser_listener { - - GtkGLViewer & viewer_; - public: - explicit browser_listener(GtkGLViewer & viewer); + explicit browser_listener(OpenvrmlXembedBrowser & browser); private: virtual void do_browser_changed(const openvrml::browser_event & event); }; - - - class G_GNUC_INTERNAL GtkGLViewer : public openvrml::gl::viewer { - friend class browser_listener; - - friend gboolean - (::openvrml_xembed_browser_load_url)(OpenvrmlXembedBrowser * browser, - const gchar ** url, - const gchar ** parameter, - GError **); - - friend gchar * - (::openvrml_xembed_browser_get_world_url)( - OpenvrmlXembedBrowser * vrml_browser, - GError ** error); - - friend gint (::openvrml_xembed_browser_timeout_callback)(gpointer ptr); - friend gboolean (::openvrml_xembed_browser_expose_event)( - GtkWidget *, - GdkEventExpose *, - gpointer); - friend gboolean - (::openvrml_xembed_browser_motion_notify_event)(GtkWidget *, - GdkEventMotion *, - gpointer); - - struct load_url; - - ::browser_listener browser_listener_; - bool browser_initialized_; - openvrml::read_write_mutex browser_initialized_mutex_; - OpenvrmlXembedBrowser & vrml_browser_; - guint timer; - - public: - bool redrawNeeded; - - explicit GtkGLViewer(OpenvrmlXembedBrowser & vrml_browser); - virtual ~GtkGLViewer() throw (); - - void timer_update(); - - protected: - // - // Implement pure virtual methods from openvrml::gl::viewer. - // - virtual void post_redraw(); - virtual void set_cursor(openvrml::gl::viewer::cursor_style); - virtual void swap_buffers(); - virtual void set_timer(double); - }; } struct OpenvrmlXembedBrowserPrivate_ { DBusGProxy * control_host; ::resource_fetcher * resource_fetcher; openvrml::browser * browser; - GtkDrawingArea * drawing_area; - GtkGLViewer * viewer; + browser_listener * listener; + OpenvrmlXembedBrowserPlug * browser_plug; + GMutex * browser_plug_mutex; + GCond * browser_plug_set_cond; + GMutex * browser_initialized_mutex; openvrml_xembed::uninitialized_plugin_streambuf_map * uninitialized_streambuf_map; openvrml_xembed::plugin_streambuf_map * streambuf_map; boost::thread * initial_stream_reader_thread; bool expect_initial_stream; bool got_initial_stream; + bool browser_initialized; }; # define OPENVRML_XEMBED_BROWSER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OPENVRML_XEMBED_TYPE_BROWSER, OpenvrmlXembedBrowserPrivate)) @@ -234,14 +145,20 @@ G_GNUC_INTERNAL guint signals[last_signal_id]; } +extern "C" { + G_GNUC_INTERNAL void openvrml_xembed_browser_finalize(GObject * obj); +} + void openvrml_xembed_browser_class_init(OpenvrmlXembedBrowserClass * const klass) { - G_OBJECT_CLASS(klass)->set_property = openvrml_xembed_browser_set_property; - G_OBJECT_CLASS(klass)->get_property = openvrml_xembed_browser_get_property; - GTK_WIDGET_CLASS(klass)->realize = openvrml_xembed_browser_realize; - GTK_WIDGET_CLASS(klass)->unrealize = openvrml_xembed_browser_unrealize; + GObjectClass * const g_object_class = G_OBJECT_CLASS(klass); + g_object_class->constructor = openvrml_xembed_browser_constructor; + g_object_class->finalize = openvrml_xembed_browser_finalize; + g_object_class->set_property = openvrml_xembed_browser_set_property; + g_object_class->get_property = openvrml_xembed_browser_get_property; + signals[initialized_id] = g_signal_new("initialized", G_OBJECT_CLASS_TYPE(klass), @@ -261,12 +178,13 @@ G_TYPE_NONE, 0); GParamSpec * pspec = - g_param_spec_pointer( + g_param_spec_object( "control-host-proxy", "BrowserHost proxy", "DBusGProxy for a BrowserHost", + DBUS_TYPE_G_PROXY, GParamFlags(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), + g_object_class_install_property(g_object_class, control_host_proxy_id, pspec); @@ -281,47 +199,14 @@ expect_initial_stream_id, pspec); - g_type_class_add_private(G_OBJECT_CLASS(klass), + g_type_class_add_private(g_object_class, sizeof (OpenvrmlXembedBrowserPrivate)); - dbus_g_object_type_install_info(OPENVRML_XEMBED_TYPE_BROWSER, - &dbus_glib_openvrml_xembed_browser_object_info); + dbus_g_object_type_install_info( + OPENVRML_XEMBED_TYPE_BROWSER, + &dbus_glib_openvrml_xembed_browser_object_info); } -void openvrml_xembed_browser_set_property(GObject * const obj, - const guint property_id, - const GValue * const value, - GParamSpec * const pspec) -{ - OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); - switch (property_id) { - case control_host_proxy_id: - browser->priv->control_host = - static_cast<DBusGProxy *>(g_value_get_pointer(value)); - break; - case expect_initial_stream_id: - browser->priv->expect_initial_stream = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); - } -} - -void openvrml_xembed_browser_get_property(GObject * const obj, - const guint property_id, - GValue * const value, - GParamSpec * const pspec) -{ - OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); - switch (property_id) { - case control_host_proxy_id: - g_value_set_pointer(value, browser->priv->control_host); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); - } -} - namespace { // // We don't already know what the URI of the initial stream is until we @@ -384,17 +269,26 @@ }; } -void openvrml_xembed_browser_realize(GtkWidget * const widget) +GObject * +openvrml_xembed_browser_constructor( + GType type, + guint n_construct_properties, + GObjectConstructParam * construct_properties) { - GtkWidgetClass * klass = - GTK_WIDGET_CLASS(g_type_class_peek(OPENVRML_XEMBED_TYPE_BROWSER)); - GtkWidgetClass * parent_class = - GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); - parent_class->realize(widget); + GObject * obj; + { + OpenvrmlXembedBrowserClass * const klass = + OPENVRML_XEMBED_BROWSER_CLASS( + g_type_class_peek(OPENVRML_XEMBED_TYPE_BROWSER)); + GObjectClass * const parent_class = + G_OBJECT_CLASS(g_type_class_peek_parent(klass)); + obj = parent_class->constructor(type, + n_construct_properties, + construct_properties); + } - OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(widget); - try { + OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); browser->priv->uninitialized_streambuf_map = new openvrml_xembed::uninitialized_plugin_streambuf_map; browser->priv->streambuf_map = @@ -407,10 +301,16 @@ new openvrml::browser(*browser->priv->resource_fetcher, std::cout, std::cerr); - browser->priv->drawing_area = - GTK_DRAWING_AREA(g_object_new(GTK_TYPE_DRAWING_AREA, 0)); - browser->priv->viewer = new GtkGLViewer(*browser); + browser->priv->listener = new browser_listener(*browser); + browser->priv->browser->add_listener(*browser->priv->listener); + browser->priv->browser_plug = 0; + browser->priv->browser_plug_mutex = g_mutex_new(); + browser->priv->browser_plug_set_cond = g_cond_new(); + + browser->priv->browser_initialized = false; + browser->priv->browser_initialized_mutex = g_mutex_new(); + // // If necessary, create the initial stream. // @@ -439,92 +339,64 @@ // ex is most likely std::bad_alloc or boost::thread_resource_error. // g_critical("%s", ex.what()); - return; + return 0; } - - if (!::gl_config) { - static const int attrib_list[] = { - // GDK_GL_ALPHA_SIZE, 1, - GDK_GL_DOUBLEBUFFER, - GDK_GL_DEPTH_SIZE, 1, - GDK_GL_RGBA, - GDK_GL_RED_SIZE, 1, - GDK_GL_ATTRIB_LIST_NONE - }; - ::gl_config = gdk_gl_config_new(attrib_list); - } - - static GdkGLContext * const share_list = 0; - static const gboolean direct = false; - static const int render_type = GDK_GL_RGBA_TYPE; - gtk_widget_set_gl_capability(GTK_WIDGET(browser->priv->drawing_area), - ::gl_config, - share_list, - direct, - render_type); - - gtk_widget_add_events(GTK_WIDGET(browser->priv->drawing_area), - GDK_EXPOSURE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_KEY_PRESS_MASK - | GDK_FOCUS_CHANGE_MASK); - - g_object_set(G_OBJECT(browser->priv->drawing_area), - "can-focus", true, - NULL); - - g_object_connect( - G_OBJECT(browser->priv->drawing_area), - - "signal::expose_event", - G_CALLBACK(openvrml_xembed_browser_expose_event), - browser->priv->viewer, - - "signal::configure_event", - G_CALLBACK(openvrml_xembed_browser_configure_event), - browser->priv->viewer, - - "signal::key_press_event", - G_CALLBACK(openvrml_xembed_browser_key_press_event), - browser->priv->viewer, - - "signal::button_press_event", - G_CALLBACK(openvrml_xembed_browser_button_press_event), - browser->priv->viewer, - - "signal::button_release_event", - G_CALLBACK(openvrml_xembed_browser_button_release_event), - browser->priv->viewer, - - "signal::motion_notify_event", - G_CALLBACK(openvrml_xembed_browser_motion_notify_event), - browser->priv->viewer, - NULL); - - gtk_container_add(GTK_CONTAINER(widget), - GTK_WIDGET(browser->priv->drawing_area)); + return obj; } -void openvrml_xembed_browser_unrealize(GtkWidget * const widget) +void openvrml_xembed_browser_finalize(GObject * const obj) { - OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(widget); + OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); if (browser->priv->expect_initial_stream) { browser->priv->initial_stream_reader_thread->join(); delete browser->priv->initial_stream_reader_thread; } - delete browser->priv->viewer; + g_mutex_free(browser->priv->browser_initialized_mutex); + g_cond_free(browser->priv->browser_plug_set_cond); + g_mutex_free(browser->priv->browser_plug_mutex); + browser->priv->browser->remove_listener(*browser->priv->listener); + delete browser->priv->listener; + delete browser->priv->browser; + delete browser->priv->resource_fetcher; + delete browser->priv->streambuf_map; + delete browser->priv->uninitialized_streambuf_map; +} - GtkWidgetClass * klass = - GTK_WIDGET_CLASS(g_type_class_peek(OPENVRML_XEMBED_TYPE_BROWSER)); - GtkWidgetClass * parent_class = - GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); - parent_class->unrealize(widget); +void openvrml_xembed_browser_set_property(GObject * const obj, + const guint property_id, + const GValue * const value, + GParamSpec * const pspec) +{ + OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); + switch (property_id) { + case control_host_proxy_id: + browser->priv->control_host = DBUS_G_PROXY(g_value_get_object(value)); + break; + case expect_initial_stream_id: + browser->priv->expect_initial_stream = g_value_get_boolean(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); + } } +void openvrml_xembed_browser_get_property(GObject * const obj, + const guint property_id, + GValue * const value, + GParamSpec * const pspec) +{ + OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); + switch (property_id) { + case control_host_proxy_id: + g_value_set_object(value, browser->priv->control_host); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); + } +} + void openvrml_xembed_browser_stream_client_interface_init(const gpointer g_iface, gpointer /* iface_data */) @@ -536,30 +408,39 @@ iface->write = openvrml_xembed_browser_write; } -GtkWidget * openvrml_xembed_browser_new(DBusGProxy * const host_proxy, - const GdkNativeWindow socket_id, - const gboolean expect_initial_stream) +G_GNUC_INTERNAL +GSource * +openvrml_xembed_browser_ready_source_new(OpenvrmlXembedBrowser * browser, + guint64 host_id); + +OpenvrmlXembedBrowser * +openvrml_xembed_browser_new(DBusGProxy * const host_proxy, + const gboolean expect_initial_stream, + GMainContext * const gtk_thread_context, + const GdkNativeWindow socket_id) { - GtkWidget * browser = - GTK_WIDGET(g_object_new(OPENVRML_XEMBED_TYPE_BROWSER, - "control-host-proxy", host_proxy, - "expect-initial-stream", expect_initial_stream, - 0)); - gtk_plug_construct(GTK_PLUG(browser), socket_id); - return browser; -} + OpenvrmlXembedBrowser * const browser = + OPENVRML_XEMBED_BROWSER( + g_object_new(OPENVRML_XEMBED_TYPE_BROWSER, + "control-host-proxy", host_proxy, + "expect-initial-stream", expect_initial_stream, + 0)); + if (!browser) { return 0; } + scope_guard browser_guard = make_guard(g_object_unref, browser); -GtkWidget * openvrml_xembed_browser_new_for_display(DBusGProxy * const host_proxy, - GdkDisplay * const display, - const GdkNativeWindow socket_id, - const gboolean expect_initial_stream) -{ - GtkWidget * browser = - GTK_WIDGET(g_object_new(OPENVRML_XEMBED_TYPE_BROWSER, - "control-host-proxy", host_proxy, - "expect-initial-stream", expect_initial_stream, - 0)); - gtk_plug_construct_for_display(GTK_PLUG(browser), display, socket_id); + GSource * const browser_ready_source = + openvrml_xembed_browser_ready_source_new(browser, socket_id); + if (!browser_ready_source) { return 0; } + scope_guard browser_ready_source_guard = + make_guard(g_object_unref, browser_ready_source); + + gdk_threads_enter(); + g_source_attach(browser_ready_source, gtk_thread_context); + gdk_threads_leave(); + + browser_ready_source_guard.dismiss(); + browser_guard.dismiss(); + return browser; } @@ -597,7 +478,7 @@ return false; } } - g_assert(streambuf->state() == plugin_streambuf::uninitialized); + g_assert(streambuf->state() != plugin_streambuf::initialized); streambuf->init(stream_id, url, type); return true; } @@ -659,52 +540,542 @@ return true; } -gboolean openvrml_xembed_browser_expose_event(GtkWidget * const widget, - GdkEventExpose * const event, - const gpointer user_data) +namespace { + struct G_GNUC_INTERNAL load_url { + load_url(OpenvrmlXembedBrowser & browser, + const std::vector<std::string> & url, + const std::vector<std::string> & parameter): + browser_(browser), + url_(url), + parameter_(parameter) + {} + + void operator()() const OPENVRML_NOTHROW + { + try { + g_mutex_lock(this->browser_.priv->browser_initialized_mutex); + this->browser_.priv->browser_initialized = false; + g_mutex_unlock(this->browser_.priv->browser_initialized_mutex); + this->browser_.priv->browser->load_url(this->url_, + this->parameter_); + } catch (std::exception & ex) { + this->browser_.priv->browser->err(ex.what()); + } + } + + private: + OpenvrmlXembedBrowser & browser_; + const std::vector<std::string> url_, parameter_; + }; +} + +gboolean +openvrml_xembed_browser_load_url(OpenvrmlXembedBrowser * const vrml_browser, + const gchar ** url, + const gchar ** parameter, + GError ** error) { + using std::string; + using std::vector; + + try { + vector<string> url_vec, param_vec; + while (url && *url) { url_vec.push_back(*(url++)); } + while (parameter && *parameter) { param_vec.push_back(*(parameter++)); } + + vrml_browser->priv->resource_fetcher + ->create_thread(load_url(*vrml_browser, url_vec, param_vec)); + } catch (const std::bad_alloc & ex) { + *error = g_error_new(OPENVRML_XEMBED_ERROR, + OPENVRML_XEMBED_ERROR_NO_MEMORY, + "out of memory"); + return false; + } catch (const std::exception & ex) { + *error = g_error_new(OPENVRML_XEMBED_ERROR, + OPENVRML_XEMBED_ERROR_FAILED, + ex.what()); + return false; + } + return true; +} + +guint64 openvrml_xembed_browser_get_id(OpenvrmlXembedBrowser * const browser) +{ + g_assert(browser); + g_mutex_lock(browser->priv->browser_plug_mutex); + while (!browser->priv->browser_plug) { + g_cond_wait(browser->priv->browser_plug_set_cond, + browser->priv->browser_plug_mutex); + } + g_assert(browser->priv->browser_plug); + const guint64 id = gtk_plug_get_id(GTK_PLUG(browser->priv->browser_plug)); + g_mutex_unlock(browser->priv->browser_plug_mutex); + return id; +} + +gboolean +openvrml_xembed_browser_new_stream(OpenvrmlXembedBrowser * const browser, + const guint64 stream_id, + const char * const type, + const char * const url, + GError ** const error) +{ + return openvrml_xembed_stream_client_new_stream( + OPENVRML_XEMBED_STREAM_CLIENT(browser), + stream_id, + type, + url, + error); +} + +gboolean +openvrml_xembed_browser_destroy_stream(OpenvrmlXembedBrowser * const browser, + const guint64 stream_id, + GError ** const error) +{ + return openvrml_xembed_stream_client_destroy_stream( + OPENVRML_XEMBED_STREAM_CLIENT(browser), + stream_id, + error); +} + +gboolean openvrml_xembed_browser_write(OpenvrmlXembedBrowser * const browser, + const guint64 stream_id, + const GArray * const data, + GError ** const error) +{ + return openvrml_xembed_stream_client_write( + OPENVRML_XEMBED_STREAM_CLIENT(browser), + stream_id, + data, + error); +} + +gchar * +openvrml_xembed_browser_get_world_url( + OpenvrmlXembedBrowser * const vrml_browser, + GError ** /* error */) +{ + return g_strdup(vrml_browser->priv->browser->world_url().c_str()); +} + +gboolean +openvrml_xembed_browser_initialized(OpenvrmlXembedBrowser * const browser) +{ + g_mutex_lock(browser->priv->browser_initialized_mutex); + const bool browser_initialized = browser->priv->browser_initialized; + g_mutex_unlock(browser->priv->browser_initialized_mutex); + return browser_initialized; +} + + +G_DEFINE_TYPE(OpenvrmlXembedBrowserPlug, + openvrml_xembed_browser_plug, + GTK_TYPE_PLUG); + +extern "C" { + G_GNUC_INTERNAL + void openvrml_xembed_browser_plug_set_property(GObject * obj, + guint property_id, + const GValue * value, + GParamSpec * pspec); + + G_GNUC_INTERNAL + void openvrml_xembed_browser_plug_get_property(GObject * obj, + guint property_id, + GValue * value, + GParamSpec * pspec); + + G_GNUC_INTERNAL + void openvrml_xembed_browser_plug_realize(GtkWidget * widget); + + G_GNUC_INTERNAL + void openvrml_xembed_browser_plug_unrealize(GtkWidget * widget); + + // + // Signal handlers + // + G_GNUC_INTERNAL + gboolean + openvrml_xembed_drawing_area_expose_event( + GtkWidget * widget, + GdkEventExpose * event, + OpenvrmlXembedBrowserPlug * browser_plug); + + G_GNUC_INTERNAL + gboolean + openvrml_xembed_drawing_area_configure_event( + GtkWidget * widget, + GdkEventConfigure * event, + OpenvrmlXembedBrowserPlug * browser_plug); + + G_GNUC_INTERNAL + gboolean + openvrml_xembed_drawing_area_key_press_event( + GtkWidget * widget, + GdkEventKey * event, + OpenvrmlXembedBrowserPlug * browser_plug); + + G_GNUC_INTERNAL + gboolean + openvrml_xembed_drawing_area_button_press_event( + GtkWidget * widget, + GdkEventButton * event, + OpenvrmlXembedBrowserPlug * browser_plug); + + G_GNUC_INTERNAL + gboolean + openvrml_xembed_drawing_area_button_release_event( + GtkWidget * widget, + GdkEventButton * event, + OpenvrmlXembedBrowserPlug * browser_plug); + + G_GNUC_INTERNAL + gboolean + openvrml_xembed_drawing_area_motion_notify_event( + GtkWidget * widget, + GdkEventMotion * event, + OpenvrmlXembedBrowserPlug * browser_plug); + + G_GNUC_INTERNAL + gint openvrml_xembed_browser_plug_timeout_callback(gpointer ptr); + + G_GNUC_INTERNAL + void browser_initialized(OpenvrmlXembedBrowser *, + OpenvrmlXembedBrowserPlug *); +} + +namespace { + + G_GNUC_INTERNAL GdkGLConfig * gl_config; + + + class G_GNUC_INTERNAL GtkGLViewer : public openvrml::gl::viewer { + friend + void (::openvrml_xembed_browser_plug_realize)(GtkWidget * widget); + + friend gboolean + (::openvrml_xembed_drawing_area_expose_event)( + GtkWidget *, + GdkEventExpose *, + OpenvrmlXembedBrowserPlug *); + + friend void (::browser_initialized)(OpenvrmlXembedBrowser *, + OpenvrmlXembedBrowserPlug *); + + OpenvrmlXembedBrowserPlug & browser_plug_; + guint timer; + + public: + explicit GtkGLViewer(OpenvrmlXembedBrowserPlug & browser_plug); + virtual ~GtkGLViewer() throw (); + + void timer_update(); + + protected: + // + // Implement pure virtual methods from openvrml::gl::viewer. + // + virtual void post_redraw(); + virtual void set_cursor(openvrml::gl::viewer::cursor_style); + virtual void swap_buffers(); + virtual void set_timer(double); + }; +} + +struct OpenvrmlXembedBrowserPlugPrivate_ { + OpenvrmlXembedBrowser * browser; + GtkDrawingArea * drawing_area; + GtkGLViewer * viewer; + bool redraw_needed; +}; + +# define OPENVRML_XEMBED_BROWSER_PLUG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OPENVRML_XEMBED_TYPE_BROWSER_PLUG, OpenvrmlXembedBrowserPlugPrivate)) + +void +openvrml_xembed_browser_plug_init( + OpenvrmlXembedBrowserPlug * const browser_plug) +{ + browser_plug->priv = OPENVRML_XEMBED_BROWSER_PLUG_GET_PRIVATE(browser_plug); +} + +namespace { + enum browser_plug_property_id { + browser_id = 1 + }; +} + +void +openvrml_xembed_browser_plug_class_init( + OpenvrmlXembedBrowserPlugClass * const klass) +{ + GObjectClass * const g_object_class = G_OBJECT_CLASS(klass); + g_object_class->set_property = openvrml_xembed_browser_plug_set_property; + g_object_class->get_property = openvrml_xembed_browser_plug_get_property; + + GtkWidgetClass * const gtk_widget_class = GTK_WIDGET_CLASS(klass); + gtk_widget_class->realize = openvrml_xembed_browser_plug_realize; + gtk_widget_class->unrealize = openvrml_xembed_browser_plug_unrealize; + + GParamSpec * pspec = + g_param_spec_object( + "browser", + "OpenvrmlXembedBrowser", + "The OpenvrmlXembedBrowser associated with the plug", + OPENVRML_XEMBED_TYPE_BROWSER, + GParamFlags(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); + g_object_class_install_property(g_object_class, browser_id, pspec); + + g_type_class_add_private(g_object_class, + sizeof (OpenvrmlXembedBrowserPrivate)); +} + +void openvrml_xembed_browser_plug_set_property(GObject * const obj, + const guint property_id, + const GValue * const value, + GParamSpec * const pspec) +{ + OpenvrmlXembedBrowserPlug * const browser_plug = + OPENVRML_XEMBED_BROWSER_PLUG(obj); + switch (property_id) { + case browser_id: + g_assert(browser_plug->priv->browser == 0); + browser_plug->priv->browser = + OPENVRML_XEMBED_BROWSER(g_value_get_object(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); + } +} + +void openvrml_xembed_browser_plug_get_property(GObject * const obj, + const guint property_id, + GValue * const value, + GParamSpec * const pspec) +{ + OpenvrmlXembedBrowserPlug * const browser_plug = + OPENVRML_XEMBED_BROWSER_PLUG(obj); + switch (property_id) { + case browser_id: + g_value_set_object(value, browser_plug->priv->browser); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); + } +} + +GtkWidget * +openvrml_xembed_browser_plug_new(OpenvrmlXembedBrowser * browser, + GdkNativeWindow socket_id) +{ + GtkWidget * browser_plug = + GTK_WIDGET(g_object_new(OPENVRML_XEMBED_TYPE_BROWSER_PLUG, + "browser", browser, + 0)); + gtk_plug_construct(GTK_PLUG(browser_plug), socket_id); + + g_signal_connect_data(browser, + "initialized", + G_CALLBACK(browser_initialized), + browser_plug, + 0, + GConnectFlags(0)); + + return browser_plug; +} + +void browser_initialized(OpenvrmlXembedBrowser * /* browser */, + OpenvrmlXembedBrowserPlug * const browser_plug) +{ + g_assert(OPENVRML_XEMBED_IS_BROWSER_PLUG(browser_plug)); + // + // Set redraw_needed to false to ensure that the following call to + // post_redraw results in a redraw. + // + browser_plug->priv->redraw_needed = false; + + // + // viewer will be nonnull if the plug has been realized. + // + if (browser_plug->priv->viewer) { + browser_plug->priv->viewer->post_redraw(); + } +} + +void openvrml_xembed_browser_plug_realize(GtkWidget * const widget) +{ + GtkWidgetClass * klass = + GTK_WIDGET_CLASS( + g_type_class_peek(OPENVRML_XEMBED_TYPE_BROWSER_PLUG)); + GtkWidgetClass * parent_class = + GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); + parent_class->realize(widget); + + OpenvrmlXembedBrowserPlug * const browser_plug = + OPENVRML_XEMBED_BROWSER_PLUG(widget); + + { + OpenvrmlXembedBrowser * browser = 0; + g_object_get(browser_plug, + "browser", &browser, + NULL); + + g_assert(browser); + scope_guard browser_guard = make_guard(g_object_unref, browser); + boost::ignore_unused_variable_warning(browser_guard); + + browser_plug->priv->drawing_area = + GTK_DRAWING_AREA(g_object_new(GTK_TYPE_DRAWING_AREA, 0)); + + try { + browser_plug->priv->viewer = new GtkGLViewer(*browser_plug); + } catch (const std::exception & ex) { + // + // ex is most likely std::bad_alloc. + // + g_critical("%s", ex.what()); + return; + } + } // unref the OpenvrmlXembedBrowser. + + if (!::gl_config) { + static const int attrib_list[] = { + // GDK_GL_ALPHA_SIZE, 1, + GDK_GL_DOUBLEBUFFER, + GDK_GL_DEPTH_SIZE, 1, + GDK_GL_RGBA, + GDK_GL_RED_SIZE, 1, + GDK_GL_ATTRIB_LIST_NONE + }; + ::gl_config = gdk_gl_config_new(attrib_list); + } + + static GdkGLContext * const share_list = 0; + static const gboolean direct = false; + static const int render_type = GDK_GL_RGBA_TYPE; + gtk_widget_set_gl_capability(GTK_WIDGET(browser_plug->priv->drawing_area), + ::gl_config, + share_list, + direct, + render_type); + + gtk_widget_add_events(GTK_WIDGET(browser_plug->priv->drawing_area), + GDK_EXPOSURE_MASK + | GDK_POINTER_MOTION_MASK + | GDK_BUTTON_PRESS_MASK + | GDK_BUTTON_RELEASE_MASK + | GDK_KEY_PRESS_MASK + | GDK_FOCUS_CHANGE_MASK); + + g_object_set(G_OBJECT(browser_plug->priv->drawing_area), + "can-focus", true, + NULL); + + g_object_connect( + G_OBJECT(browser_plug->priv->drawing_area), + + "signal::expose_event", + G_CALLBACK(openvrml_xembed_drawing_area_expose_event), + browser_plug, + + "signal::configure_event", + G_CALLBACK(openvrml_xembed_drawing_area_configure_event), + browser_plug, + + "signal::key_press_event", + G_CALLBACK(openvrml_xembed_drawing_area_key_press_event), + browser_plug, + + "signal::button_press_event", + G_CALLBACK(openvrml_xembed_drawing_area_button_press_event), + browser_plug, + + "signal::button_release_event", + G_CALLBACK(openvrml_xembed_drawing_area_button_release_event), + browser_plug, + + "signal::motion_notify_event", + G_CALLBACK(openvrml_xembed_drawing_area_motion_notify_event), + browser_plug, + NULL); + + gtk_container_add(GTK_CONTAINER(widget), + GTK_WIDGET(browser_plug->priv->drawing_area)); + + // + // If the browser has already been initialized, get things moving. + // + if (openvrml_xembed_browser_initialized(browser_plug->priv->browser)) { + browser_plug->priv->viewer->post_redraw(); + } +} + +void openvrml_xembed_browser_plug_unrealize(GtkWidget * const widget) +{ + OpenvrmlXembedBrowserPlug * const browser_plug = + OPENVRML_XEMBED_BROWSER_PLUG(widget); + + delete browser_plug->priv->viewer; + browser_plug->priv->viewer = 0; + gtk_widget_destroy(GTK_WIDGET(browser_plug->priv->drawing_area)); + browser_plug->priv->drawing_area = 0; + + GtkWidgetClass * klass = + GTK_WIDGET_CLASS(g_type_class_peek(OPENVRML_XEMBED_TYPE_BROWSER_PLUG)); + GtkWidgetClass * parent_class = + GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); + parent_class->unrealize(widget); +} + +gboolean +openvrml_xembed_drawing_area_expose_event( + GtkWidget * const widget, + GdkEventExpose * const event, + OpenvrmlXembedBrowserPlug * const browser_plug) +{ GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); - GtkGLViewer * viewer = static_cast<GtkGLViewer *>(user_data); - g_return_val_if_fail(viewer, true); - { - openvrml::read_write_mutex::scoped_read_lock - lock(viewer->browser_initialized_mutex_); - if (!viewer->browser_initialized_) { return true; } + + if (!openvrml_xembed_browser_initialized(browser_plug->priv->browser)) { + return true; } if (event->count == 0 && gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - viewer->redraw(); + browser_plug->priv->viewer->redraw(); } - viewer->redrawNeeded = false; - if (viewer->timer == 0) { viewer->timer_update(); } + browser_plug->priv->redraw_needed = false; + if (browser_plug->priv->viewer->timer == 0) { + browser_plug->priv->viewer->timer_update(); + } return true; } -gboolean openvrml_xembed_browser_configure_event(GtkWidget * const widget, - GdkEventConfigure *, - const gpointer user_data) +gboolean +openvrml_xembed_drawing_area_configure_event( + GtkWidget * const widget, + GdkEventConfigure *, + OpenvrmlXembedBrowserPlug * const browser_plug) { GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); - GtkGLViewer * const viewer = static_cast<GtkGLViewer *>(user_data); - g_return_val_if_fail(viewer, true); - if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - viewer->resize(widget->allocation.width, widget->allocation.height); + browser_plug->priv->viewer->resize(widget->allocation.width, + widget->allocation.height); } return true; } -gboolean openvrml_xembed_browser_key_press_event(GtkWidget * const widget, - GdkEventKey * const event, - const gpointer user_data) +gboolean +openvrml_xembed_drawing_area_key_press_event( + GtkWidget * const widget, + GdkEventKey * const event, + OpenvrmlXembedBrowserPlug * const browser_plug) { using openvrml::gl::viewer; @@ -749,16 +1120,16 @@ GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - GtkGLViewer * const viewer = static_cast<GtkGLViewer *>(user_data); - viewer->input(&info); + browser_plug->priv->viewer->input(&info); } return true; } gboolean -openvrml_xembed_browser_button_press_event(GtkWidget * const widget, - GdkEventButton * const event, - const gpointer user_data) +openvrml_xembed_drawing_area_button_press_event( + GtkWidget * const widget, + GdkEventButton * const event, + OpenvrmlXembedBrowserPlug * const browser_plug) { using openvrml::gl::viewer; @@ -788,16 +1159,16 @@ GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - GtkGLViewer * const viewer = static_cast<GtkGLViewer *>(user_data); - viewer->input(&info); + browser_plug->priv->viewer->input(&info); } return true; } gboolean -openvrml_xembed_browser_button_release_event(GtkWidget * const widget, - GdkEventButton * const event, - const gpointer user_data) +openvrml_xembed_drawing_area_button_release_event( + GtkWidget * const widget, + GdkEventButton * const event, + OpenvrmlXembedBrowserPlug * const browser_plug) { using openvrml::gl::viewer; @@ -825,16 +1196,16 @@ GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - GtkGLViewer * const viewer = static_cast<GtkGLViewer *>(user_data); - viewer->input(&info); + browser_plug->priv->viewer->input(&info); } return true; } gboolean -openvrml_xembed_browser_motion_notify_event(GtkWidget * const widget, - GdkEventMotion * const event, - const gpointer user_data) +openvrml_xembed_drawing_area_motion_notify_event( + GtkWidget * const widget, + GdkEventMotion * const event, + OpenvrmlXembedBrowserPlug * const browser_plug) { using openvrml::gl::viewer; @@ -859,16 +1230,15 @@ g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - GtkGLViewer * const viewer = static_cast<GtkGLViewer *>(user_data); - openvrml::read_write_mutex::scoped_read_lock - lock(viewer->browser_initialized_mutex_); - if (!viewer->browser_initialized_) { return true; } - viewer->input(&info); + if (!openvrml_xembed_browser_initialized(browser_plug->priv->browser)) { + return true; + } + browser_plug->priv->viewer->input(&info); } return true; } -gint openvrml_xembed_browser_timeout_callback(const gpointer ptr) +gint openvrml_xembed_browser_plug_timeout_callback(const gpointer ptr) { g_assert(ptr); @@ -878,141 +1248,7 @@ } namespace { - struct GtkGLViewer::load_url { - load_url(GtkGLViewer & viewer, - const std::vector<std::string> & url, - const std::vector<std::string> & parameter): - viewer_(&viewer), - url_(url), - parameter_(parameter) - {} - void operator()() const OPENVRML_NOTHROW - { - try { - { - openvrml::read_write_mutex::scoped_write_lock - lock(this->viewer_->browser_initialized_mutex_); - this->viewer_->browser_initialized_ = false; - } - this->viewer_->vrml_browser_.priv->browser - ->load_url(this->url_, this->parameter_); - } catch (std::exception & ex) { - this->viewer_->vrml_browser_.priv->browser->err(ex.what()); - } - } - - private: - GtkGLViewer * const viewer_; - const std::vector<std::string> url_, parameter_; - }; -} - -gboolean -openvrml_xembed_browser_load_url(OpenvrmlXembedBrowser * const vrml_browser, - const gchar ** url, - const gchar ** parameter, - GError ** /* error */) -{ - using std::string; - using std::vector; - - vector<string> url_vec, param_vec; - while (url && *url) { url_vec.push_back(*(url++)); } - while (parameter && *parameter) { param_vec.push_back(*(parameter++)); } - - vrml_browser->priv->resource_fetcher - ->create_thread(GtkGLViewer::load_url(*vrml_browser->priv->viewer, - url_vec, param_vec)); - return true; -} - -guint64 openvrml_xembed_browser_get_id(OpenvrmlXembedBrowser * const browser) -{ - g_assert(browser); -// gdk_threads_enter(); -// scope_guard gdk_threads_guard = make_guard(gdk_threads_leave); - return gtk_plug_get_id(&browser->parent); -} - -gboolean openvrml_xembed_browser_new_stream(OpenvrmlXembedBrowser * const browser, - const guint64 stream_id, - const char * const type, - const char * const url, - GError ** const error) -{ - return openvrml_xembed_stream_client_new_stream( - OPENVRML_XEMBED_STREAM_CLIENT(browser), - stream_id, - type, - url, - error); -} - -gboolean -openvrml_xembed_browser_destroy_stream(OpenvrmlXembedBrowser * const browser, - const guint64 stream_id, - GError ** const error) -{ - return openvrml_xembed_stream_client_destroy_stream( - OPENVRML_XEMBED_STREAM_CLIENT(browser), - stream_id, - error); -} - -gboolean openvrml_xembed_browser_write(OpenvrmlXembedBrowser * const browser, - const guint64 stream_id, - const GArray * const data, - GError ** const error) -{ - return openvrml_xembed_stream_client_write( - OPENVRML_XEMBED_STREAM_CLIENT(browser), - stream_id, - data, - error); -} - -gchar * -openvrml_xembed_browser_get_world_url( - OpenvrmlXembedBrowser * const vrml_browser, - GError ** /* error */) -{ - return g_strdup(vrml_browser->priv->browser->world_url().c_str()); -} - -extern "C" -OPENVRML_LOCAL -void openvrml_xembed_get_url_notify(DBusGProxy * const proxy, - DBusGProxyCall * const call_id, - void * const user_data) -{ - using openvrml_xembed::plugin_streambuf; - - gint get_url_result; - - GError * error = 0; - scope_guard error_guard = make_guard(g_error_free, boost::ref(error)); - const gboolean result = - dbus_g_proxy_end_call(proxy, call_id, &error, - G_TYPE_INT, &get_url_result, - G_TYPE_INVALID); - - if (!result) { - g_critical("Call to org.openvrml.BrowserHost.GetUrl failed: %s", - error->message); - return; - } - - plugin_streambuf * const streambuf = - static_cast<plugin_streambuf *>(user_data); - - streambuf->set_get_url_result(get_url_result); - - error_guard.dismiss(); -} - -namespace { - resource_fetcher::resource_fetcher( DBusGProxy & control_host, openvrml_xembed::uninitialized_plugin_streambuf_map & @@ -1071,28 +1307,22 @@ GError * error = 0; scope_guard error_guard = make_guard(g_error_free, boost::ref(error)); - DBusGProxyCall * get_url_call = - ... [truncated message content] |
From: <br...@us...> - 2009-03-01 20:17:27
|
Revision: 3817 http://openvrml.svn.sourceforge.net/openvrml/?rev=3817&view=rev Author: braden Date: 2009-03-01 20:17:21 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Generate openvrml-xembed/browser-host-client-glue.h. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-01 05:15:08 UTC (rev 3816) +++ trunk/ChangeLog 2009-03-01 20:17:21 UTC (rev 3817) @@ -1,5 +1,10 @@ 2009-03-01 Braden McDaniel <br...@en...> + * src/Makefile.am: Generate + openvrml-xembed/browser-host-client-glue.h. + +2009-03-01 Braden McDaniel <br...@en...> + Moved D-Bus interaction out of the main (GTK+) thread and into its own background thread. This avoids a deadlock when a resource fetch comes from the rendering thread and waits on feedback that Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-01 05:15:08 UTC (rev 3816) +++ trunk/src/Makefile.am 2009-03-01 20:17:21 UTC (rev 3817) @@ -720,7 +720,8 @@ session_bus_services_DATA = openvrml-xembed/org.openvrml.BrowserControl.service BUILT_SOURCES += \ openvrml-xembed/browser-server-glue.h \ - openvrml-xembed/browser-factory-server-glue.h + openvrml-xembed/browser-factory-server-glue.h \ + openvrml-xembed/browser-host-client-glue.h endif openvrml_xembed_openvrml_xembed_CPPFLAGS = \ -I$(top_builddir)/src/openvrml-xembed \ @@ -777,6 +778,13 @@ --output=$@ \ $? +openvrml-xembed/browser-host-client-glue.h: $(srcdir)/openvrml-xembed/browser-host.xml + $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) \ + --prefix=openvrml_xembed_browser_host \ + --mode=glib-client \ + --output=$@ \ + $? + edit = sed -e 's|@libexecdir[@]|$(libexecdir)|g' openvrml-xembed/org.openvrml.BrowserControl.service: Makefile This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-02 01:16:07
|
Revision: 3819 http://openvrml.svn.sourceforge.net/openvrml/?rev=3819&view=rev Author: braden Date: 2009-03-02 01:16:04 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Changed "model/x3d+vrml" to "model/x3d-vrml" in accordance with the pending media type registration. Modified Paths: -------------- trunk/README trunk/src/libopenvrml/openvrml/browser.cpp trunk/src/libopenvrml/openvrml/scene.cpp trunk/src/openvrml-player/filechooserdialog.cpp Modified: trunk/README =================================================================== --- trunk/README 2009-03-01 20:19:15 UTC (rev 3818) +++ trunk/README 2009-03-02 01:16:04 UTC (rev 3819) @@ -268,10 +268,10 @@ If OpenVRML is configured to be installed to the same prefix as a Mozilla-based browser is installed on the system, "make install" will install the Mozilla plug-in to the browser's plug-in directory. This -should be sufficient to enable support for the "model/vrml" media type -in the browser. Entering "about:plugins" in the URL entry bar of a -Mozilla-based browser will show a listing of successfully installed -plug-ins. +should be sufficient to enable support for the "model/vrml" and +"model/x3d-vrml" media types in the browser. Entering "about:plugins" +in the URL entry bar of a Mozilla-based browser will show a listing of +successfully installed plug-ins. To run openvrml-player or the Mozilla plug-in from the build directories, you must first start an openvrml-xembed process. Once Modified: trunk/src/libopenvrml/openvrml/browser.cpp =================================================================== --- trunk/src/libopenvrml/openvrml/browser.cpp 2009-03-01 20:19:15 UTC (rev 3818) +++ trunk/src/libopenvrml/openvrml/browser.cpp 2009-03-02 01:16:04 UTC (rev 3819) @@ -3357,7 +3357,7 @@ /** * @brief X3D VRML MIME media type. */ -const char openvrml::x3d_vrml_media_type[15] = "model/x3d+vrml"; +const char openvrml::x3d_vrml_media_type[15] = "model/x3d-vrml"; /** * @class openvrml::resource_istream openvrml/browser.h @@ -4725,7 +4725,7 @@ * @param[in,out] in an input stream. * * @exception bad_media_type if @p in.type() is not @c model/vrml, - * @c x-world/x-vrml, or @c model/x3d+vrml. + * @c x-world/x-vrml, or @c model/x3d-vrml. * @exception invalid_vrml if @p in has invalid syntax. */ void openvrml::browser::set_world(resource_istream & in) Modified: trunk/src/libopenvrml/openvrml/scene.cpp =================================================================== --- trunk/src/libopenvrml/openvrml/scene.cpp 2009-03-01 20:19:15 UTC (rev 3818) +++ trunk/src/libopenvrml/openvrml/scene.cpp 2009-03-02 01:16:04 UTC (rev 3819) @@ -164,7 +164,7 @@ * @exception bad_media_type if @p in.type() is not * “model/vrml”, * “x-world/x-vrml”, or - * “model/x3d+vrml”. + * “model/x3d-vrml”. * @exception invalid_vrml if @p in has invalid syntax. */ void openvrml::scene::load(resource_istream & in) Modified: trunk/src/openvrml-player/filechooserdialog.cpp =================================================================== --- trunk/src/openvrml-player/filechooserdialog.cpp 2009-03-01 20:19:15 UTC (rev 3818) +++ trunk/src/openvrml-player/filechooserdialog.cpp 2009-03-02 01:16:04 UTC (rev 3819) @@ -73,7 +73,7 @@ gtk_file_filter_set_name(world_filter, "VRML/X3D worlds"); gtk_file_filter_add_mime_type(world_filter, "x-world/x-vrml"); gtk_file_filter_add_mime_type(world_filter, "model/vrml"); - gtk_file_filter_add_mime_type(world_filter, "model/x3d+vrml"); + gtk_file_filter_add_mime_type(world_filter, "model/x3d-vrml"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(obj), world_filter); world_filter_guard.dismiss(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-02 06:29:56
|
Revision: 3826 http://openvrml.svn.sourceforge.net/openvrml/?rev=3826&view=rev Author: braden Date: 2009-03-02 06:29:53 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Updates for 0.17.11 release. Modified Paths: -------------- trunk/ChangeLog trunk/NEWS trunk/README trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.rc trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc trunk/src/Makefile.am Property Changed: ---------------- trunk/ trunk/src/libopenvrml/openvrml/bad_url.cpp trunk/src/libopenvrml/openvrml/scene.cpp trunk/src/libopenvrml/openvrml/scene.h trunk/src/libopenvrml/openvrml/script.cpp Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766 /branches/local:3677-3689 /branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 + /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/local:3677-3689 /branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-02 05:26:56 UTC (rev 3825) +++ trunk/ChangeLog 2009-03-02 06:29:53 UTC (rev 3826) @@ -1,3 +1,18 @@ +2009-03-02 Braden McDaniel <br...@en...> + + Updates for 0.17.11 release. + + * NEWS + * README + * configure.ac + * doc/Doxyfile + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.rc + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.vcproj + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc + * mozilla-plugin/configure.ac + * src/Makefile.am + (LIBOPENVRML_LIBRARY_VERSION): Updated to 8:8:0. + 2009-03-01 Braden McDaniel <br...@en...> Changed "model/x3d+vrml" to "model/x3d-vrml" in accordance with Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-03-02 05:26:56 UTC (rev 3825) +++ trunk/NEWS 2009-03-02 06:29:53 UTC (rev 3826) @@ -1,3 +1,16 @@ +Changes new in version 0.17.11, 2 March, 2009 +======================================================================== + +- Moved D-Bus interaction in openvrml-xembed to a background thread, + preventing some deadlocks. + +- Fixed configure test for nonstandard GLU tesselator callback + function signature on Mac OS 10.4 and previous. + +- Changed the MIME media type for VRML-style X3D to "model/x3d-vrml" + in accordance with the pending registration. + + Changes new in version 0.17.10, 26 October, 2008 ======================================================================== Modified: trunk/README =================================================================== --- trunk/README 2009-03-02 05:26:56 UTC (rev 3825) +++ trunk/README 2009-03-02 06:29:53 UTC (rev 3826) @@ -1,4 +1,4 @@ -OpenVRML library version 0.17.10 +OpenVRML library version 0.17.11 Copyright 1998, 1999, 2000 Chris Morley <cm...@ve...> Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Braden McDaniel <br...@en...> Modified: trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.rc =================================================================== --- trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.rc 2009-03-02 05:26:56 UTC (rev 3825) +++ trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.rc 2009-03-02 06:29:53 UTC (rev 3826) @@ -11,7 +11,7 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 8,7,0,0 + FILEVERSION 8,8,0,0 PRODUCTVERSION 0,17,99,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -28,9 +28,9 @@ BLOCK "040904b0" BEGIN VALUE "FileDescription", "OpenVRML Library" - VALUE "FileVersion", "8, 7, 0, 0" + VALUE "FileVersion", "8, 8, 0, 0" VALUE "InternalName", "openvrml" - VALUE "LegalCopyright", "Copyright (C) 2008" + VALUE "LegalCopyright", "Copyright (C) 2009" VALUE "OriginalFilename", "openvrml.dll" VALUE "ProductName", "OpenVRML Library" VALUE "ProductVersion", "0.17.99" Modified: trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc =================================================================== --- trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc 2009-03-02 05:26:56 UTC (rev 3825) +++ trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc 2009-03-02 06:29:53 UTC (rev 3826) @@ -30,7 +30,7 @@ VALUE "FileDescription", "OpenVRML OpenGL Renderer Library" VALUE "FileVersion", "7, 3, 0, 0" VALUE "InternalName", "openvrml-gl" - VALUE "LegalCopyright", "Copyright (C) 2008" + VALUE "LegalCopyright", "Copyright (C) 2009" VALUE "OriginalFilename", "openvrml-gl.dll" VALUE "ProductName", "OpenVRML Library" VALUE "ProductVersion", "0.17.99" Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-02 05:26:56 UTC (rev 3825) +++ trunk/src/Makefile.am 2009-03-02 06:29:53 UTC (rev 3826) @@ -49,7 +49,7 @@ openvrml-xembed/plugin_streambuf.h \ openvrml-player/filechooserdialog.h -LIBOPENVRML_LIBRARY_VERSION = 8:7:0 +LIBOPENVRML_LIBRARY_VERSION = 8:8:0 LIBOPENVRML_GL_LIBRARY_VERSION = 7:3:0 # | | | # +------+ | +---+ Property changes on: trunk/src/libopenvrml/openvrml/bad_url.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766 /branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/scene.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766 /branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/scene.h ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766 /branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/script.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766 /branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-04 07:16:42
|
Revision: 3827 http://openvrml.svn.sourceforge.net/openvrml/?rev=3827&view=rev Author: braden Date: 2009-03-04 07:16:37 +0000 (Wed, 04 Mar 2009) Log Message: ----------- Moved the parser instances out of browser.cpp along with a lot of other code that implied. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/libopenvrml/openvrml/browser.cpp trunk/src/libopenvrml/openvrml/browser.h trunk/src/libopenvrml/openvrml/node.h trunk/src/libopenvrml/openvrml/scene.cpp Added Paths: ----------- trunk/src/libopenvrml/openvrml/local/component.cpp trunk/src/libopenvrml/openvrml/local/component.h trunk/src/libopenvrml/openvrml/local/externproto.cpp trunk/src/libopenvrml/openvrml/local/externproto.h trunk/src/libopenvrml/openvrml/local/parse_vrml.cpp trunk/src/libopenvrml/openvrml/local/parse_vrml.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-02 06:29:53 UTC (rev 3826) +++ trunk/ChangeLog 2009-03-04 07:16:37 UTC (rev 3827) @@ -1,3 +1,29 @@ +2009-03-04 Braden McDaniel <br...@en...> + + Moved the parser instances out of browser.cpp along with a lot of + other code that implied. + + * src/libopenvrml/openvrml/local/component.cpp: Added file. + * src/libopenvrml/openvrml/local/component.h: Added file. + component and profile class definitions. + * src/libopenvrml/openvrml/local/externproto.cpp: Added file. + * src/libopenvrml/openvrml/local/externproto.h: Added file. + Definitions of externproto_node, externproto_node_type, and + externproto_node_metatype. + * src/libopenvrml/openvrml/local/parse_vrml.cpp: Added file. + * src/libopenvrml/openvrml/local/parse_vrml.h: Added file. + Declaration of parse_vrml function and definitions of the parse + actions classes. + * src/libopenvrml/openvrml/browser.cpp + * src/libopenvrml/openvrml/browser.h + * src/libopenvrml/openvrml/scene.cpp + * src/libopenvrml/openvrml/node.h + * src/Makefile.am + (libopenvrml_libopenvrml_la_SOURCES): Added files + libopenvrml/openvrml/local/parse_vrml.{cpp,h}, + libopenvrml/openvrml/local/component.{cpp,h}, + libopenvrml/openvrml/local/externproto.{cpp,h}. + 2009-03-02 Braden McDaniel <br...@en...> Updates for 0.17.11 release. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-02 06:29:53 UTC (rev 3826) +++ trunk/src/Makefile.am 2009-03-04 07:16:37 UTC (rev 3827) @@ -104,8 +104,14 @@ libopenvrml/openvrml/local/uri.h \ libopenvrml/openvrml/local/xml_reader.cpp \ libopenvrml/openvrml/local/xml_reader.h \ + libopenvrml/openvrml/local/parse_vrml.cpp \ + libopenvrml/openvrml/local/parse_vrml.h \ + libopenvrml/openvrml/local/component.cpp \ + libopenvrml/openvrml/local/component.h \ libopenvrml/openvrml/local/proto.cpp \ libopenvrml/openvrml/local/proto.h \ + libopenvrml/openvrml/local/externproto.cpp \ + libopenvrml/openvrml/local/externproto.h \ libopenvrml/openvrml/local/field_value_types.h \ libopenvrml/openvrml/local/float.h \ libopenvrml/openvrml/local/node_metatype_registry_impl.cpp \ Modified: trunk/src/libopenvrml/openvrml/browser.cpp =================================================================== --- trunk/src/libopenvrml/openvrml/browser.cpp 2009-03-02 06:29:53 UTC (rev 3826) +++ trunk/src/libopenvrml/openvrml/browser.cpp 2009-03-04 07:16:37 UTC (rev 3827) @@ -22,23 +22,15 @@ # include "browser.h" # include "scene.h" # include "scope.h" -# include "x3d_vrml_grammar.h" -# include <openvrml/local/dl.h> # include <openvrml/local/uri.h> -# include <openvrml/local/xml_reader.h> -# include <openvrml/local/field_value_types.h> -# include <openvrml/local/proto.h> # include <openvrml/local/node_metatype_registry_impl.h> +# include <openvrml/local/component.h> +# include <openvrml/local/parse_vrml.h> # include <private.h> -# include <boost/algorithm/string/predicate.hpp> # include <boost/bind.hpp> -# include <boost/enable_shared_from_this.hpp> -# include <boost/filesystem.hpp> # include <boost/functional.hpp> # include <boost/lexical_cast.hpp> -# include <boost/mpl/for_each.hpp> # include <boost/multi_index/detail/scope_guard.hpp> -# include <boost/ptr_container/ptr_map.hpp> # include <boost/thread/thread.hpp> # include <algorithm> # include <functional> @@ -95,242 +87,6 @@ }; } // namespace openvrml - -/** - * @brief @c node_metatype for @c EXTERNPROTO%s. - */ -class OPENVRML_LOCAL openvrml::browser::externproto_node_metatype : - public boost::enable_shared_from_this<externproto_node_metatype>, - public openvrml::node_metatype { - - friend class externproto_node_type; - - struct load_proto; - - mutable boost::mutex mutex_; - boost::weak_ptr<openvrml::local::proto_node_metatype> proto_node_metatype_; - - typedef std::vector<boost::weak_ptr<externproto_node_type> > - externproto_node_types; - - mutable externproto_node_types externproto_node_types_; - bool externproto_node_types_cleared_; - - boost::thread * const load_proto_thread_; - -public: - externproto_node_metatype( - const openvrml::node_metatype_id & id, - const openvrml::scene & scene, - const std::vector<std::string> & uris, - boost::thread_group & load_proto_thread_group) - OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc); - virtual ~externproto_node_metatype() OPENVRML_NOTHROW; - -private: - virtual const boost::shared_ptr<openvrml::node_type> - do_create_type(const std::string & id, - const openvrml::node_interface_set & interfaces) const - OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc); - - virtual void do_shutdown(double time) OPENVRML_NOTHROW; - - void set_proto_node_metatype( - const boost::weak_ptr<openvrml::local::proto_node_metatype> & proto_node_metatype = boost::weak_ptr<openvrml::local::proto_node_metatype>()) - OPENVRML_THROW1(std::bad_alloc); - - void clear_externproto_node_types() OPENVRML_NOTHROW; -}; - - -class OPENVRML_LOCAL openvrml::browser::externproto_node_type : - public openvrml::node_type { - - const boost::shared_ptr<const externproto_node_metatype> node_metatype_; - - openvrml::node_interface_set interfaces_; - - mutable boost::mutex mutex_; - boost::shared_ptr<openvrml::node_type> proto_node_type_; - - typedef std::vector<boost::intrusive_ptr<externproto_node> > - externproto_nodes; - - mutable externproto_nodes externproto_nodes_; - -public: - externproto_node_type( - const boost::shared_ptr<const externproto_node_metatype> & c, - const std::string & id, - const openvrml::node_interface_set & interfaces) - OPENVRML_THROW1(std::bad_alloc); - - virtual ~externproto_node_type() OPENVRML_NOTHROW; - - void set_proto_node_type(openvrml::local::proto_node_metatype & proto_node_metatype) - OPENVRML_THROW1(std::bad_alloc); - - void clear_externproto_nodes() OPENVRML_NOTHROW; - -private: - virtual const openvrml::node_interface_set & do_interfaces() const - OPENVRML_NOTHROW; - - virtual const boost::intrusive_ptr<openvrml::node> - do_create_node( - const boost::shared_ptr<openvrml::scope> & scope, - const openvrml::initial_value_map & initial_values) const - OPENVRML_THROW3(openvrml::unsupported_interface, std::bad_cast, - std::bad_alloc); -}; - - -class OPENVRML_LOCAL openvrml::externproto_node : - public openvrml::local::abstract_proto_node { - - template <typename FieldValue> - class externproto_exposedfield : public FieldValue, - public proto_eventin<FieldValue>, - public proto_eventout<FieldValue> { - public: - explicit externproto_exposedfield( - externproto_node & node, - const FieldValue & initial_value = FieldValue()) - OPENVRML_NOTHROW; - virtual ~externproto_exposedfield() OPENVRML_NOTHROW; - - private: - virtual std::auto_ptr<openvrml::field_value> do_clone() const - OPENVRML_THROW1(std::bad_alloc); - virtual void do_process_event(const FieldValue & value, - double timestamp) - OPENVRML_THROW1(std::bad_alloc); - }; - - struct externproto_exposedfield_creator { - externproto_exposedfield_creator( - externproto_node & node, - const openvrml::field_value::type_id type, - boost::shared_ptr<openvrml::field_value> & exposedfield): - node_(&node), - type_(type), - exposedfield_(&exposedfield) - {} - - template <typename T> - void operator()(T) const - { - if (T::field_value_type_id == this->type_) { - this->exposedfield_->reset( - new externproto_exposedfield<T>(*this->node_)); - } - } - - private: - externproto_node * node_; - openvrml::field_value::type_id type_; - boost::shared_ptr<openvrml::field_value> * exposedfield_; - }; - - static const boost::shared_ptr<openvrml::field_value> - create_exposedfield(externproto_node & node, - openvrml::field_value::type_id type) - OPENVRML_THROW1(std::bad_alloc); - - typedef std::map<std::string, boost::shared_ptr<openvrml::field_value> > - field_map; - - struct externproto_field_equal_to : - std::unary_function<field_map::value_type, bool> { - - explicit externproto_field_equal_to( - const openvrml::field_value & field_value): - field_value_(&field_value) - {} - - bool operator()(const field_map::value_type & arg) const - { - return this->field_value_ == arg.second.get(); - } - - private: - const openvrml::field_value * field_value_; - }; - - initial_value_map initial_values_; - std::set<openvrml::field_value *> received_event_; - field_map field_map_; - - boost::intrusive_ptr<openvrml::node> proto_node_; - -public: - externproto_node(const browser::externproto_node_type & type, - const boost::shared_ptr<openvrml::scope> & scope, - const openvrml::initial_value_map & initial_values) - OPENVRML_THROW1(std::bad_alloc); - - virtual ~externproto_node() OPENVRML_NOTHROW; - - virtual bool modified() const; - - void set_proto_node(node_type & type) - OPENVRML_THROW1(std::bad_alloc); - -private: - virtual - const std::vector<boost::intrusive_ptr<node> > & do_impl_nodes() const - OPENVRML_NOTHROW; - - virtual void do_initialize(double timestamp) - OPENVRML_THROW1(std::bad_alloc); - - virtual const openvrml::field_value & - do_field(const std::string & id) const - OPENVRML_THROW1(openvrml::unsupported_interface); - - virtual openvrml::event_listener & - do_event_listener(const std::string & id) - OPENVRML_THROW1(openvrml::unsupported_interface); - - virtual openvrml::event_emitter & - do_event_emitter(const std::string & id) - OPENVRML_THROW1(openvrml::unsupported_interface); - - virtual void do_shutdown(double timestamp) OPENVRML_NOTHROW; - - virtual openvrml::script_node * to_script() OPENVRML_NOTHROW; - virtual openvrml::appearance_node * to_appearance() OPENVRML_NOTHROW; - virtual openvrml::bounded_volume_node * to_bounded_volume() - OPENVRML_NOTHROW; - virtual openvrml::child_node * to_child() OPENVRML_NOTHROW; - virtual openvrml::color_node * to_color() OPENVRML_NOTHROW; - virtual openvrml::color_rgba_node * to_color_rgba() OPENVRML_NOTHROW; - virtual openvrml::coordinate_node * to_coordinate() OPENVRML_NOTHROW; - virtual openvrml::font_style_node * to_font_style() OPENVRML_NOTHROW ; - virtual openvrml::geometry_node * to_geometry() OPENVRML_NOTHROW; - virtual openvrml::grouping_node * to_grouping() OPENVRML_NOTHROW; - virtual openvrml::light_node * to_light() OPENVRML_NOTHROW; - virtual openvrml::material_node * to_material() OPENVRML_NOTHROW; - virtual openvrml::navigation_info_node * to_navigation_info() - OPENVRML_NOTHROW; - virtual openvrml::normal_node * to_normal() OPENVRML_NOTHROW; - virtual openvrml::pointing_device_sensor_node * - to_pointing_device_sensor() OPENVRML_NOTHROW; - virtual openvrml::scoped_light_node * to_scoped_light() - OPENVRML_NOTHROW; - virtual openvrml::sound_source_node * to_sound_source() - OPENVRML_NOTHROW; - virtual openvrml::texture_node * to_texture() OPENVRML_NOTHROW; - virtual openvrml::texture_coordinate_node * to_texture_coordinate() - OPENVRML_NOTHROW; - virtual openvrml::texture_transform_node * to_texture_transform() - OPENVRML_NOTHROW; - virtual openvrml::time_dependent_node * to_time_dependent() - OPENVRML_NOTHROW; - virtual openvrml::transform_node * to_transform() OPENVRML_NOTHROW; - virtual openvrml::viewpoint_node * to_viewpoint() OPENVRML_NOTHROW; -}; - namespace { class OPENVRML_LOCAL default_navigation_info : @@ -656,231 +412,8 @@ throw openvrml::unsupported_interface(this->type(), id); return *static_cast<openvrml::event_emitter *>(0); } - - - const std::string anonymous_stream_id_prefix_ = - "urn:X-openvrml:stream:"; - - OPENVRML_LOCAL bool anonymous_stream_id(const openvrml::local::uri & id) - { - const std::string str(id); - return str.length() > anonymous_stream_id_prefix_.length() - && std::equal(anonymous_stream_id_prefix_.begin(), - anonymous_stream_id_prefix_.end(), - str.begin()); - } - - - class OPENVRML_LOCAL profile { - typedef std::map<std::string, int> map_t; - map_t components_; - - protected: - void add_component(const std::string & name, int level) - OPENVRML_THROW1(std::bad_alloc); - - public: - std::auto_ptr<openvrml::scope> - create_root_scope(const openvrml::browser & browser, - const std::string & uri) const - OPENVRML_THROW1(std::bad_alloc); - std::auto_ptr<openvrml::node_type_decls> - create_node_type_desc_map() const - OPENVRML_THROW1(std::bad_alloc); - }; - - - class OPENVRML_LOCAL vrml97_profile : public profile { - public: - static const char * const id; - - vrml97_profile(); - }; - - - class OPENVRML_LOCAL x3d_core_profile : public profile { - public: - static const char * const id; - - x3d_core_profile(); - }; - - - class OPENVRML_LOCAL x3d_interchange_profile : public profile { - public: - static const char * const id; - - x3d_interchange_profile(); - }; - - - class OPENVRML_LOCAL x3d_interactive_profile : public profile { - public: - static const char * const id; - - x3d_interactive_profile(); - }; - - - class OPENVRML_LOCAL x3d_mpeg4_profile : public profile { - public: - static const char * const id; - - x3d_mpeg4_profile(); - }; - - - class OPENVRML_LOCAL x3d_immersive_profile : public profile { - public: - static const char * const id; - - x3d_immersive_profile(); - }; - - - class OPENVRML_LOCAL x3d_full_profile : public profile { - public: - static const char * const id; - - x3d_full_profile(); - }; } -namespace { - - class OPENVRML_LOCAL component { - struct node_type_decl { - openvrml::node_interface_set interfaces; - std::string metatype_id; - }; - - class xml_reader; - - class level : std::map<std::string, node_type_decl> { - friend class xml_reader; - - public: - typedef std::map<std::string, size_t> dependencies_t; - - private: - dependencies_t dependencies_; - - public: - typedef std::map<std::string, node_type_decl> base_t; - using base_t::value_type; - using base_t::iterator; - using base_t::const_iterator; - using base_t::begin; - using base_t::end; - using base_t::find; - using base_t::insert; - - const dependencies_t & requires() const; - }; - - class xml_reader : boost::noncopyable { - enum parse_state { - none, - component, - level, - requires, - node, - field - }; - - ::component & component_; - parse_state state_; - std::vector<component::level>::value_type * current_level_; - level::value_type * current_node_; - - public: - explicit xml_reader(::component & c); - - void read(const std::string & filename) - OPENVRML_THROW1(std::runtime_error); - - private: - void process_node(openvrml::local::xml_reader & reader); - void start_element(openvrml::local::xml_reader & reader); - void end_element(openvrml::local::xml_reader & reader); - }; - - std::string id_; - std::vector<level> levels_; - - public: - explicit component(const std::string & filename) - OPENVRML_THROW1(std::runtime_error); - - const std::string & id() const OPENVRML_NOTHROW; - size_t support_level() const OPENVRML_NOTHROW; - void add_to_scope(const openvrml::browser & b, - openvrml::scope & scope, - size_t level) const - OPENVRML_THROW2(std::invalid_argument, std::bad_alloc); - void add_to_node_type_desc_map(openvrml::node_type_decls & type_descs, - size_t level) const - OPENVRML_THROW2(std::invalid_argument, std::bad_alloc); - - private: - static bool - add_type_desc(openvrml::node_type_decls & type_descs, - const std::string & node_type_id, - const openvrml::node_interface_set & interfaces) - OPENVRML_THROW1(std::bad_alloc); - - void add_scope_entry( - const openvrml::browser & b, - const char * node_name, - const openvrml::node_interface_set & interface_set, - const char * urn, - openvrml::scope & scope) const - OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc); - }; - - const class OPENVRML_LOCAL profile_registry : boost::ptr_map<std::string, - profile> { - public: - profile_registry(); - - using boost::ptr_map<std::string, profile>::at; - } profile_registry_; - - profile_registry::profile_registry() - { - std::string key; - bool succeeded; - - key = vrml97_profile::id; - succeeded = this->insert(key, new vrml97_profile).second; - assert(succeeded); - - key = x3d_core_profile::id; - succeeded = this->insert(key, new x3d_core_profile).second; - assert(succeeded); - - key = x3d_interchange_profile::id; - succeeded = this->insert(key, new x3d_interchange_profile).second; - assert(succeeded); - - key = x3d_interactive_profile::id; - succeeded = this->insert(key, new x3d_interactive_profile).second; - assert(succeeded); - - key = x3d_mpeg4_profile::id; - succeeded = this->insert(key, new x3d_mpeg4_profile).second; - assert(succeeded); - - key = x3d_immersive_profile::id; - succeeded = this->insert(key, new x3d_immersive_profile).second; - assert(succeeded); - - key = x3d_full_profile::id; - succeeded = this->insert(key, new x3d_full_profile).second; - assert(succeeded); - } -} - /** * @brief Get a @c node_type_decls map corresponding to a particular profile. * @@ -897,26 +430,14 @@ OPENVRML_THROW2(std::invalid_argument, std::bad_alloc) { try { - return ::profile_registry_.at(profile_id).create_node_type_desc_map(); + return local::profile_registry_.at(profile_id) + .create_node_type_desc_map(); } catch (boost::bad_ptr_container_operation &) { throw std::invalid_argument("unknown profile identifier \"" + profile_id + '"'); } } -namespace { - - const class OPENVRML_LOCAL component_registry : boost::ptr_map<std::string, - component> { - public: - component_registry() - OPENVRML_THROW2(boost::filesystem::filesystem_error, - std::bad_alloc); - - using boost::ptr_map<std::string, component>::at; - } component_registry_; -} - /** * @brief Add the nodes corresponding to a component level to a * @c node_type_decls map. @@ -937,7 +458,8 @@ OPENVRML_THROW2(std::invalid_argument, std::bad_alloc) { try { - const component & comp = ::component_registry_.at(component_id); + const local::component & comp = + local::component_registry_.at(component_id); comp.add_to_node_type_desc_map(node_types, level); } catch (boost::bad_ptr_container_operation &) { throw std::invalid_argument("unknown component identifier \"" @@ -946,2392 +468,6 @@ } -struct OPENVRML_LOCAL openvrml::browser::vrml97_parse_actions { - vrml97_parse_actions( - const std::string & uri, - const openvrml::scene & scene, - std::vector<boost::intrusive_ptr<openvrml::node> > & nodes): - on_scene_start(*this), - on_scene_finish(*this), - on_externproto(*this), - on_proto_start(*this), - on_proto_interface(*this), - on_proto_default_value_start(*this), - on_proto_default_value_finish(*this), - on_proto_body_start(*this), - on_proto_finish(*this), - on_node_start(*this), - on_node_finish(*this), - on_script_interface_decl(*this), - on_route(*this), - on_use(*this), - on_is_mapping(*this), - on_field_start(*this), - on_sfnode(*this), - on_mfnode(*this), - on_sfbool(*this), - on_sfcolor(*this), - on_mfcolor(*this), - on_sffloat(*this), - on_mffloat(*this), - on_sfimage(*this), - on_sfint32(*this), - on_mfint32(*this), - on_sfrotation(*this), - on_mfrotation(*this), - on_sfstring(*this), - on_mfstring(*this), - on_sftime(*this), - on_mftime(*this), - on_sfvec2f(*this), - on_mfvec2f(*this), - on_sfvec3f(*this), - on_mfvec3f(*this), - uri_(uri), - scene_(scene), - nodes_(nodes) - {} - - struct on_scene_start_t { - explicit on_scene_start_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - using std::vector; - using boost::intrusive_ptr; - - this->actions_.ps.push(parse_scope()); - - const ::profile & p = ::profile_registry_.at(vrml97_profile::id); - std::auto_ptr<scope> - root_scope(p.create_root_scope(this->actions_.scene_.browser(), - this->actions_.uri_)); - this->actions_.ps.top().scope = root_scope; - this->actions_.ps.top().children.push( - parse_scope::children_t()); - } - - private: - vrml97_parse_actions & actions_; - } on_scene_start; - - struct on_scene_finish_t { - explicit on_scene_finish_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - using std::vector; - - assert(this->actions_.ps.top().children.size() == 1); - this->actions_.nodes_ = - this->actions_.ps.top().children.top(); - this->actions_.ps.top().children.pop(); - - assert(this->actions_.ps.size() == 1); - - parse_scope & ps = this->actions_.ps.top(); - - for (vector<route>::const_iterator r = ps.routes.begin(); - r != ps.routes.end(); - ++r) { - node * const from = ps.scope->find_node(r->from); - assert(from); - node * const to = ps.scope->find_node(r->to); - assert(to); - // - // Redundant routing is ignored (4.10.2), so we don't care if - // add_route returns false. - // - add_route(*from, r->eventout, *to, r->eventin); - } - this->actions_.ps.pop(); - } - - private: - vrml97_parse_actions & actions_; - } on_scene_finish; - - struct on_externproto_t { - explicit on_externproto_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & node_type_id, - const node_interface_set & interfaces, - const std::vector<std::string> & uri_list) const - { - using std::string; - using std::vector; - using boost::shared_ptr; - using local::uri; - - // - // If we are parsing an "anonymous" stream--that is, one passed to - // browser::create_vrml_from_stream--we cannot use the URI - // associated with the stream to resolve relative URIs. So in - // this instance, we get the base URI from browser::world_url. If - // browser::world_url is an empty string, we call create_file_url - // with an empty (relative) uri. - // - const uri base_uri = - anonymous_stream_id(uri(this->actions_.uri_)) - ? this->actions_.scene_.browser().world_url().empty() - ? create_file_url(uri()) - : uri(this->actions_.scene_.browser().world_url()) - : uri(this->actions_.uri_); - - shared_ptr<node_type> node_type; - for (vector<string>::const_iterator resource_id = uri_list.begin(); - resource_id != uri_list.end(); - ++resource_id) { - const uri absolute_uri = relative(uri(*resource_id)) - ? resolve_against(uri(*resource_id), base_uri) - : uri(*resource_id); - const shared_ptr<openvrml::node_metatype> node_metatype = - this->actions_.scene_.browser().node_metatype( - node_metatype_id(absolute_uri)); - if (node_metatype) { - node_type = node_metatype->create_type(node_type_id, - interfaces); - break; - } - } - - if (!node_type) { - const std::string metatype_id = - path(*this->actions_.ps.top().scope) + '#' - + node_type_id; - const shared_ptr<openvrml::node_metatype> - externproto_class( - new externproto_node_metatype( - metatype_id, - this->actions_.scene_, - uri_list, - this->actions_.scene_.browser() - .load_proto_thread_group_)); - - this->actions_.scene_.browser().add_node_metatype( - externproto_class->id(), - externproto_class); - for (vector<string>::const_iterator resource_id = - uri_list.begin(); - resource_id != uri_list.end(); - ++resource_id) { - const uri absolute_uri = relative(uri(*resource_id)) - ? resolve_against(uri(*resource_id), base_uri) - : uri(*resource_id); - this->actions_.scene_.browser() - .add_node_metatype(node_metatype_id(absolute_uri), - externproto_class); - } - - node_type = externproto_class->create_type(node_type_id, - interfaces); - } - - assert(node_type); - - const bool succeeded = - this->actions_.ps.top().scope->add_type(node_type) - .second; - assert(succeeded); - } - - private: - vrml97_parse_actions & actions_; - } on_externproto; - - struct on_proto_start_t { - explicit on_proto_start_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & node_type_id) const - { - const boost::shared_ptr<scope> outer_scope = - this->actions_.ps.top().scope; - assert(outer_scope); - - this->actions_.ps.push(parse_scope()); - - parse_scope & ps = this->actions_.ps.top(); - - ps.proto_node_type_id = node_type_id; - - // - // We don't want to create the new scope until we start the PROTO - // body. So, for now we set the parse_scope::scope to the outer - // scope. - // - ps.scope = outer_scope; - - // - // We push a node_data onto the stack to hold any field default - // values. - // - ps.node_data_.push(node_data()); - } - - private: - vrml97_parse_actions & actions_; - } on_proto_start; - - struct on_proto_interface_t { - explicit on_proto_interface_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const node_interface & interface_) const - { - parse_scope & ps = this->actions_.ps.top(); - - const bool succeeded = - ps.proto_interfaces.insert(interface_).second; - assert(succeeded); - - assert(!ps.node_data_.empty()); - node_data & nd = ps.node_data_.top(); - - if (interface_.type == node_interface::field_id - || interface_.type == node_interface::exposedfield_id) { - using std::auto_ptr; - using std::pair; - auto_ptr<field_value> value = - field_value::create(interface_.field_type); - pair<initial_value_map::iterator, bool> insert_result = - nd.initial_values.insert( - make_pair(interface_.id, - boost::shared_ptr<field_value>(value))); - assert(insert_result.second); - nd.current_field_value = &(*insert_result.first); - } - } - - private: - vrml97_parse_actions & actions_; - } on_proto_interface; - - struct on_proto_default_value_start_t { - explicit on_proto_default_value_start_t( - vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - parse_scope & ps = this->actions_.ps.top(); - - boost::shared_ptr<scope> outer_scope = ps.scope; - const std::string & proto_node_type_id = ps.proto_node_type_id; - assert(!proto_node_type_id.empty()); - const std::string & field_id = - ps.node_data_.top().current_field_value->first; - const field_value::type_id field_type = - ps.node_data_.top().current_field_value->second->type(); - - if (field_type == field_value::sfnode_id - || field_type == field_value::mfnode_id) { - using std::vector; - using boost::intrusive_ptr; - - const node_data old_nd = ps.node_data_.top(); - - const std::string scope_id = - proto_node_type_id + '.' + field_id; - actions_.ps.push(parse_scope()); - - parse_scope & new_ps = this->actions_.ps.top(); - - new_ps.scope.reset(new scope(scope_id, outer_scope)); - new_ps.node_data_.push(old_nd); - new_ps.children.push(parse_scope::children_t()); - } - } - - private: - vrml97_parse_actions & actions_; - } on_proto_default_value_start; - - struct on_proto_default_value_finish_t { - explicit on_proto_default_value_finish_t( - vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - assert(!actions_.ps.empty()); - - parse_scope & ps = this->actions_.ps.top(); - - const field_value::type_id field_type = - ps.node_data_.top().current_field_value->second->type(); - - if (field_type == field_value::sfnode_id - || field_type == field_value::mfnode_id) { - using std::vector; - - assert(actions_.ps.size() > 1); - - for (vector<route>::const_iterator r = ps.routes.begin(); - r != ps.routes.end(); - ++r) { - node * const from = ps.scope->find_node(r->from); - assert(from); - node * const to = ps.scope->find_node(r->to); - assert(to); - // - // Redundant routing is ignored (4.10.2), so we don't care - // if add_route returns false. - // - add_route(*from, r->eventout, *to, r->eventin); - } - - parse_scope old_ps = ps; - this->actions_.ps.pop(); - parse_scope & new_ps = this->actions_.ps.top(); - new_ps.node_data_.top().current_field_value->second->assign( - *old_ps.node_data_.top().current_field_value->second); - } - } - - private: - vrml97_parse_actions & actions_; - } on_proto_default_value_finish; - - struct on_proto_body_start_t { - explicit on_proto_body_start_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - assert(!actions_.ps.empty()); - const boost::shared_ptr<scope> parent = - actions_.ps.top().scope; - actions_.ps.top().scope - .reset(new scope(actions_.ps.top().proto_node_type_id, - parent)); - actions_.ps.top().proto_default_values = - actions_.ps.top().node_data_.top().initial_values; - actions_.ps.top().node_data_.pop(); - assert(actions_.ps.top().children.empty()); - actions_.ps.top().children.push( - parse_scope::children_t()); - } - - private: - vrml97_parse_actions & actions_; - } on_proto_body_start; - - struct on_proto_finish_t { - explicit on_proto_finish_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - using std::vector; - using boost::shared_ptr; - using boost::dynamic_pointer_cast; - using local::proto_node_metatype; - parse_scope & ps = this->actions_.ps.top(); - assert(ps.children.size() == 1); - assert(ps.node_data_.empty()); - proto_node_metatype::routes_t proto_routes; - for (vector<route>::const_iterator r = ps.routes.begin(); - r != ps.routes.end(); - ++r) { - node * const from = ps.scope->find_node(r->from); - assert(from); - node * const to = ps.scope->find_node(r->to); - assert(to); - proto_routes.push_back( - proto_node_metatype::route(*from, r->eventout, - *to, r->eventin)); - } - const shared_ptr<openvrml::node_metatype> node_metatype( - new proto_node_metatype( - path(*ps.scope), - this->actions_.scene_.browser(), - ps.proto_interfaces, - ps.proto_default_values, - ps.children.top(), - ps.proto_is_map, - proto_routes)); - - // - // Add the new node_metatype (prototype definition) to the - // browser's node_metatype_registry. - // - this->actions_.scene_.browser() - .add_node_metatype(node_metatype->id(), node_metatype); - - if (!dynamic_pointer_cast<proto_node_metatype>( - this->actions_.scene_.browser().node_metatype( - node_metatype_id(this->actions_.uri_)))) { - this->actions_.scene_.browser() - .add_node_metatype(node_metatype_id(this->actions_.uri_), - node_metatype); - } - - // - // PROTOs implicitly introduce a new node type as well. - // - const shared_ptr<node_type> node_type = - node_metatype->create_type( - ps.proto_node_type_id, - this->actions_.ps.top().proto_interfaces); - assert(node_type); - - // - // We want to add the type to the PROTO's enclosing scope, so pop - // off the current scope. - // - assert(this->actions_.ps.size() > 1); - this->actions_.ps.pop(); - - const bool succeeded = - this->actions_.ps.top().scope->add_type(node_type) - .second; - assert(succeeded); - } - - private: - vrml97_parse_actions & actions_; - } on_proto_finish; - - struct on_node_start_t { - explicit on_node_start_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & node_name_id, - const std::string & node_type_id) const - { - parse_scope & ps = this->actions_.ps.top(); - - ps.node_data_.push(node_data()); - ps.node_data_.top().node_name_id = node_name_id; - - assert(ps.scope); - if (node_type_id != "Script") { - ps.node_data_.top().type = ps.scope->find_type(node_type_id); - assert(ps.node_data_.top().type); - } - } - - private: - vrml97_parse_actions & actions_; - } on_node_start; - - struct on_node_finish_t { - explicit on_node_finish_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - using boost::intrusive_ptr; - - parse_scope & ps = this->actions_.ps.top(); - - assert(!ps.children.empty()); - assert(!ps.node_data_.empty()); - - const node_data & nd = ps.node_data_.top(); - - const intrusive_ptr<node> n = nd.type - ? nd.type->create_node(ps.scope, nd.initial_values) - : intrusive_ptr<node>( - new script_node( - this->actions_.scene_.browser().script_node_metatype_, - ps.scope, - nd.script_interfaces, - nd.initial_values)); - - if (!nd.node_name_id.empty()) { n->id(nd.node_name_id); } - - for (node_data::is_map_t::const_iterator entry = nd.is_map.begin(); - entry != nd.is_map.end(); - ++entry) { - ps.proto_is_map.insert( - make_pair(entry->second, - local::proto_node_metatype::is_target( - *n, entry->first))); - } - - ps.children.top().push_back(n); - ps.node_data_.pop(); - } - - private: - vrml97_parse_actions & actions_; - } on_node_finish; - - struct on_script_interface_decl_t { - explicit on_script_interface_decl_t( - vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const node_interface & interface_) const - { - parse_scope & ps = this->actions_.ps.top(); - - assert(!ps.node_data_.empty()); - - node_data & nd = ps.node_data_.top(); - - const bool succeeded = - nd.script_interfaces.insert(interface_).second; - assert(succeeded); - - this->actions_.on_field_start(interface_.id, interface_.field_type); - if ((interface_.type == node_interface::eventin_id - || interface_.type == node_interface::eventout_id) - && (interface_.field_type == field_value::sfnode_id - || interface_.field_type == field_value::mfnode_id)) { - ps.children.pop(); - } - } - - private: - vrml97_parse_actions & actions_; - } on_script_interface_decl; - - struct on_route_t { - explicit on_route_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & from_node_name_id, - const node_interface & from_node_interface, - const std::string & to_node_name_id, - const node_interface & to_node_interface) const - { - parse_scope & ps = this->actions_.ps.top(); - const route r(from_node_name_id, from_node_interface.id, - to_node_name_id, to_node_interface.id); - ps.routes.push_back(r); - } - - private: - vrml97_parse_actions & actions_; - } on_route; - - struct on_use_t { - explicit on_use_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & node_name_id) const - { - using boost::intrusive_ptr; - parse_scope & ps = this->actions_.ps.top(); - node_data & nd = ps.node_data_.top(); - - // - // Check for self-reference. This is legitimate in Script nodes. - // - node * const n = (node_name_id == nd.node_name_id) - ? node::self_tag.get() - : ps.scope->find_node(node_name_id); - assert(n); - assert(!ps.children.empty()); - ps.children.top().push_back(intrusive_ptr<node>(n)); - } - - private: - vrml97_parse_actions & actions_; - } on_use; - - struct on_is_mapping_t { - explicit on_is_mapping_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & proto_interface_id) const - { - node_data & nd = - this->actions_.ps.top().node_data_.top(); - assert(nd.current_field_value); - nd.is_map.insert(make_pair(nd.current_field_value->first, - proto_interface_id)); - - const field_value::type_id field_type = - nd.current_field_value->second->type(); - if (field_type == field_value::sfnode_id - || field_type == field_value::mfnode_id) { - this->actions_.ps.top().children.pop(); - } - - // - // We need to leave this around for Script nodes. - // - if (nd.type) { - const initial_value_map::size_type erased = - nd.initial_values.erase(nd.current_field_value->first); - assert(erased != 0); - } - nd.current_field_value = 0; - } - - private: - vrml97_parse_actions & actions_; - } on_is_mapping; - - struct on_field_start_t { - explicit on_field_start_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & field_name_id, - const field_value::type_id field_type) const - { - parse_scope & ps = this->actions_.ps.top(); - node_data & nd = ps.node_data_.top(); - - using boost::shared_ptr; - using std::pair; - std::auto_ptr<field_value> value = field_value::create(field_type); - pair<initial_value_map::iterator, bool> insert_result = - nd.initial_values.insert( - make_pair(field_name_id, shared_ptr<field_value>(value))); - assert(insert_result.second); - nd.current_field_value = &(*insert_result.first); - - if (field_type == field_value::sfnode_id - || field_type == field_value::mfnode_id) { - ps.children.push(parse_scope::children_t()); - } - } - - private: - vrml97_parse_actions & actions_; - } on_field_start; - - struct on_sfnode_t { - explicit on_sfnode_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(bool null) const - { - assert(!actions_.ps.empty()); - parse_scope & ps = this->actions_.ps.top(); - - if (!null) { - assert(!ps.node_data_.empty()); - assert(!ps.children.top().empty()); - ps.node_data_.top() - .current_field_value->second->assign( - sfnode(ps.children.top().front())); - } - actions_.ps.top().children.pop(); - } - - private: - vrml97_parse_actions & actions_; - } on_sfnode; - - struct on_mfnode_t { - explicit on_mfnode_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()() const - { - assert(!this->actions_.ps.empty()); - assert(!this->actions_.ps.top().node_data_.empty()); - assert(!this->actions_.ps.top().children.empty()); - this->actions_.ps.top().node_data_.top() - .current_field_value->second - ->assign(mfnode(this->actions_.ps.top().children.top())); - this->actions_.ps.top().children.pop(); - } - - private: - vrml97_parse_actions & actions_; - } on_mfnode; - - struct on_sfbool_t { - explicit on_sfbool_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const bool val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfbool(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfbool; - - struct on_sfcolor_t { - explicit on_sfcolor_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const color & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfcolor(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfcolor; - - struct on_mfcolor_t { - explicit on_mfcolor_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<color> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mfcolor(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mfcolor; - - struct on_sffloat_t { - explicit on_sffloat_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const float val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sffloat(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sffloat; - - struct on_mffloat_t { - explicit on_mffloat_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<float> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mffloat(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mffloat; - - struct on_sfimage_t { - explicit on_sfimage_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const image & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfimage(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfimage; - - struct on_sfint32_t { - explicit on_sfint32_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const int32 val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfint32(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfint32; - - struct on_mfint32_t { - explicit on_mfint32_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<int32> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mfint32(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mfint32; - - struct on_sfrotation_t { - explicit on_sfrotation_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const rotation & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfrotation(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfrotation; - - struct on_mfrotation_t { - explicit on_mfrotation_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<rotation> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mfrotation(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mfrotation; - - struct on_sfstring_t { - explicit on_sfstring_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::string & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfstring(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfstring; - - struct on_mfstring_t { - explicit on_mfstring_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<std::string> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mfstring(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mfstring; - - struct on_sftime_t { - explicit on_sftime_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const double val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sftime(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sftime; - - struct on_mftime_t { - explicit on_mftime_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<double> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mftime(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mftime; - - struct on_sfvec2f_t { - explicit on_sfvec2f_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const vec2f & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfvec2f(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfvec2f; - - struct on_mfvec2f_t { - explicit on_mfvec2f_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<vec2f> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mfvec2f(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mfvec2f; - - struct on_sfvec3f_t { - explicit on_sfvec3f_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const vec3f & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(sfvec3f(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_sfvec3f; - - struct on_mfvec3f_t { - explicit on_mfvec3f_t(vrml97_parse_actions & actions): - actions_(actions) - {} - - void operator()(const std::vector<vec3f> & val) const - { - assert(!actions_.ps.empty()); - assert(!actions_.ps.top().node_data_.empty()); - actions_.ps.top().node_data_.top() - .current_field_value->second->assign(mfvec3f(val)); - } - - private: - vrml97_parse_actions & actions_; - } on_mfvec3f; - - struct route { - std::string from; - std::string eventout; - std::string to; - std::string eventin; - - route(const std::string & from, const std::string & eventout, - const std::string & to, const std::string & eventin): - from(from), - eventout(eventout), - to(to), - eventin(eventin) - {} - }; - - struct node_data { - // - // This is a multimap because an exposedField might have multiple - // entries (i.e., for the corresponding eventIn, field, and eventOut). - // - typedef std::multimap<std::string, std::string> is_map_t; - - boost::shared_ptr<node_type> type; - std::string node_name_id; - initial_value_map initial_values; - initial_value_map::value_type * current_field_value; - node_interface_set script_interfaces; - is_map_t is_map; - - node_data(): - current_field_value(0) - {} - - node_data(const node_data & nd): - type(nd.type), - node_name_id(nd.node_name_id), - initial_values(nd.initial_values), - current_field_value(0), - script_interfaces(nd.script_interfaces), - is_map(nd.is_map) - { - if (nd.current_field_value) { - initial_value_map::iterator pos = - this->initial_values.find(nd.current_field_value->first); - assert(pos != this->initial_values.end()); - this->current_field_value = &(*pos); - } - } - - node_data & operator=(const node_data & nd) - { - node_data temp(nd); - this->swap(temp); - return *this; - } - - void swap(node_data & nd) OPENVRML_NOTHROW - { - this->type.swap(nd.type); - this->node_name_id.swap(nd.node_name_id); - this->initial_values.swap(nd.initial_values); - std::swap(this->current_field_value, nd.current_field_value); - this->script_interfaces.swap(nd.script_interfaces); - this->is_map.swap(nd.is_map); - } - }; - - struct parse_scope { - typedef std::vector<boost::intrusive_ptr<node> > children_t; - - std::string proto_node_type_id; - boost::shared_ptr<openvrml::scope> scope; - node_interface_set proto_interfaces; - local::proto_node_metatype::default_value_map_t proto_default_values; - local::proto_node_metatype::is_map_t proto_is_map; - std::vector<route> routes; - std::stack<children_t> children; - std::stack<node_data> node_data_; - }; - - // - // We push a parse_scope onto the stack - // * at the scene root - std::stack<parse_scope> ps; - -private: - const std::string uri_; - const openvrml::scene & scene_; - std::vector<boost::intrusive_ptr<openvrml::node> > & nodes_; -}; - -struct OPENVRML_LOCAL openvrml::browser::x3d_vrml_parse_actions : - openvrml::browser::vrml97_parse_actions { - - x3d_vrml_parse_actions( - const std::string & uri, - const openvrml::scene & scene, - std::vector<boost::intrusive_ptr<openvrml::node> > & nodes, - std::map<std::string, std::string> & meta): - openvrml::browser::vrml97_parse_actions(uri, scene, nodes), - on_profile_statement(*this), - on_component_statement(*this), - on_meta_statement(*this), - on_sfcolorrgba(*this), - on_sfdouble(*this), - on_sfvec2d(*this), - on_sfvec3d(*this), - on_mfbool(*this), - on_mfcolorrgba(*this), - on_mfimage(*this), - on_mfvec2d(*this), - on_mfvec3d(*this), - meta_(meta) - {} - - struct on_profile_statement_t { - explicit on_profile_statement_t(x3d_vrml_parse_actions & actions): - actions_(actions) - {} - - void operator()(cons... [truncated message content] |
From: <br...@us...> - 2009-03-15 18:51:55
|
Revision: 3829 http://openvrml.svn.sourceforge.net/openvrml/?rev=3829&view=rev Author: braden Date: 2009-03-15 18:51:39 +0000 (Sun, 15 Mar 2009) Log Message: ----------- Use the conventional gl.h/glu.h header paths as a first choice. Make it up to users who don't want these to make them unavailable to the build environment. Most of the time, that will be done by configuring --without-x. Modified Paths: -------------- trunk/ChangeLog trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp Property Changed: ---------------- trunk/ trunk/src/libopenvrml/openvrml/bad_url.cpp trunk/src/libopenvrml/openvrml/scene.cpp trunk/src/libopenvrml/openvrml/scene.h trunk/src/libopenvrml/openvrml/script.cpp Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/local:3677-3689 /branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 + /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/local:3677-3689 /branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-15 18:33:14 UTC (rev 3828) +++ trunk/ChangeLog 2009-03-15 18:51:39 UTC (rev 3829) @@ -1,3 +1,11 @@ +2009-03-15 Braden McDaniel <br...@en...> + + * src/libopenvrml-gl/openvrml/gl/viewer.cpp: Use the conventional + gl.h/glu.h header paths as a first choice. Make it up to users + who don't want these to make them unavailable to the build + environment. Most of the time, that will be done by configuring + --without-x. + 2009-03-04 Braden McDaniel <br...@en...> Moved the parser instances out of browser.cpp along with a lot of Property changes on: trunk/src/libopenvrml/openvrml/bad_url.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/scene.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/scene.h ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/script.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824 /branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801 Modified: trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp =================================================================== --- trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp 2009-03-15 18:33:14 UTC (rev 3828) +++ trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp 2009-03-15 18:51:39 UTC (rev 3829) @@ -36,12 +36,14 @@ # undef interface # endif -# ifdef HAVE_OPENGL_GL_H +# ifdef HAVE_GL_GLU_H +# include <GL/gl.h> +# include <GL/glu.h> +# elif defined(HAVE_OPENGL_GLU_H) # include <OpenGL/gl.h> # include <OpenGL/glu.h> # else -# include <GL/gl.h> -# include <GL/glu.h> +# error must define HAVE_GL_GLU_H or HAVE_OPENGL_GLU_H # endif # include <cmath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-16 07:06:17
|
Revision: 3831 http://openvrml.svn.sourceforge.net/openvrml/?rev=3831&view=rev Author: braden Date: 2009-03-16 07:06:12 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Define HAVE_GL_GLU_H. Modified Paths: -------------- trunk/ChangeLog trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.vcproj Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-16 07:01:48 UTC (rev 3830) +++ trunk/ChangeLog 2009-03-16 07:06:12 UTC (rev 3831) @@ -1,3 +1,8 @@ +2009-03-16 Braden McDaniel <br...@en...> + + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.vcproj: + Define HAVE_GL_GLU_H. + 2009-03-15 Braden McDaniel <br...@en...> * src/libopenvrml-gl/openvrml/gl/viewer.cpp: Use the conventional Modified: trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.vcproj =================================================================== --- trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.vcproj 2009-03-16 07:01:48 UTC (rev 3830) +++ trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.vcproj 2009-03-16 07:06:12 UTC (rev 3831) @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=".;..\openvrml;"..\..\..\..\..\src\libopenvrml-gl";..\..\..\..\..\src\libopenvrml" - PreprocessorDefinitions="HAVE_WINDOWS_H;OPENVRML_USE_DLL;OPENVRML_GL_BUILD_DLL" + PreprocessorDefinitions="HAVE_GL_GLU_H;HAVE_WINDOWS_H;OPENVRML_USE_DLL;OPENVRML_GL_BUILD_DLL" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -124,7 +124,7 @@ InlineFunctionExpansion="1" OmitFramePointers="true" AdditionalIncludeDirectories=".;..\openvrml;"..\..\..\..\..\src\libopenvrml-gl";..\..\..\..\..\src\libopenvrml" - PreprocessorDefinitions="_SECURE_SCL=0;HAVE_WINDOWS_H;OPENVRML_GL_BUILD_DLL;OPENVRML_USE_DLL;NDEBUG" + PreprocessorDefinitions="_SECURE_SCL=0;HAVE_GL_GLU_H;HAVE_WINDOWS_H;OPENVRML_GL_BUILD_DLL;OPENVRML_USE_DLL;NDEBUG" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-16 07:14:06
|
Revision: 3833 http://openvrml.svn.sourceforge.net/openvrml/?rev=3833&view=rev Author: braden Date: 2009-03-16 07:13:46 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Explicitly convert to float to quell a warning from the Microsoft compiler. Modified Paths: -------------- trunk/ChangeLog trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-16 07:11:57 UTC (rev 3832) +++ trunk/ChangeLog 2009-03-16 07:13:46 UTC (rev 3833) @@ -1,5 +1,12 @@ 2009-03-16 Braden McDaniel <br...@en...> + * src/libopenvrml-gl/openvrml/gl/viewer.cpp + (openvrml::gl::viewer::do_set_frustum(float, float, float)): + Explicitly convert to float to quell a warning from the Microsoft + compiler. + +2009-03-16 Braden McDaniel <br...@en...> + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.vcproj: Define HAVE_GL_GLU_H. Modified: trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp =================================================================== --- trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp 2009-03-16 07:11:57 UTC (rev 3832) +++ trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp 2009-03-16 07:13:46 UTC (rev 3833) @@ -3812,7 +3812,7 @@ glMatrixMode(GL_PROJECTION); if (!this->select_mode) { glLoadIdentity(); } - (field_of_view *= 180.0) /= pi; + (field_of_view *= 180.0f) /= float(pi); const float aspect = float(this->win_width) / this->win_height; const float znear = (avatar_size > 0.0) ? float(0.5 * avatar_size) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-16 07:20:25
|
Revision: 3835 http://openvrml.svn.sourceforge.net/openvrml/?rev=3835&view=rev Author: braden Date: 2009-03-16 07:20:10 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Updated to use FreeType 2.3.9. Modified Paths: -------------- trunk/ChangeLog trunk/ide-projects/Windows/VisualC9_0/OpenVRML/vrml97/vrml97.vcproj Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-16 07:16:16 UTC (rev 3834) +++ trunk/ChangeLog 2009-03-16 07:20:10 UTC (rev 3835) @@ -1,5 +1,10 @@ 2009-03-16 Braden McDaniel <br...@en...> + * ide-projects/Windows/VisualC9_0/OpenVRML/vrml97/vrml97.vcproj: + Updated to use FreeType 2.3.9. + +2009-03-16 Braden McDaniel <br...@en...> + * src/libopenvrml-gl/openvrml/gl/viewer.cpp (openvrml::gl::viewer::do_set_frustum(float, float, float)): Explicitly convert to float to quell a warning from the Microsoft Modified: trunk/ide-projects/Windows/VisualC9_0/OpenVRML/vrml97/vrml97.vcproj =================================================================== --- trunk/ide-projects/Windows/VisualC9_0/OpenVRML/vrml97/vrml97.vcproj 2009-03-16 07:16:16 UTC (rev 3834) +++ trunk/ide-projects/Windows/VisualC9_0/OpenVRML/vrml97/vrml97.vcproj 2009-03-16 07:20:10 UTC (rev 3835) @@ -62,7 +62,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="libpngd.lib zlibd.lib freetype236MT_D.lib" + AdditionalDependencies="libpngd.lib zlibd.lib freetype239MT_D.lib" OutputFile="$(SolutionDir)..\bin\node\$(ProjectName).dll" IgnoreDefaultLibraryNames="libcmtd" /> @@ -135,7 +135,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="libpng.lib zlib.lib freetype236MT.lib" + AdditionalDependencies="libpng.lib zlib.lib freetype239MT.lib" OutputFile="$(SolutionDir)..\bin\node\$(ProjectName).dll" /> <Tool This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-17 05:55:40
|
Revision: 3838 http://openvrml.svn.sourceforge.net/openvrml/?rev=3838&view=rev Author: braden Date: 2009-03-17 05:55:19 +0000 (Tue, 17 Mar 2009) Log Message: ----------- Updates for 0.17.12 release. Modified Paths: -------------- trunk/ChangeLog trunk/NEWS trunk/README trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc trunk/src/Makefile.am Property Changed: ---------------- trunk/ trunk/src/libopenvrml/openvrml/bad_url.cpp trunk/src/libopenvrml/openvrml/scene.cpp trunk/src/libopenvrml/openvrml/scene.h trunk/src/libopenvrml/openvrml/script.cpp Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/local:3677-3689 /branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 + /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/local:3677-3689 /branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-16 09:50:40 UTC (rev 3837) +++ trunk/ChangeLog 2009-03-17 05:55:19 UTC (rev 3838) @@ -1,6 +1,16 @@ +2009-03-17 Braden McDaniel <br...@en...> + + Updates for 0.17.12 release. + + * NEWS + * README + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc + * src/Makefile.am + (LIBOPENVRML_GL_LIBRARY_VERSION): Updated to 7:4:0. + 2009-03-16 Braden McDaniel <br...@en...> - * ide-projects/Windows/VisualC9_0/OpenVRML/vrml97/vrml97.vcproj: + * ide-projects/Windows/VisualC9_0/OpenVRML/openvrml/openvrml.vcproj: Updated to use FreeType 2.3.9. 2009-03-16 Braden McDaniel <br...@en...> Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-03-16 09:50:40 UTC (rev 3837) +++ trunk/NEWS 2009-03-17 05:55:19 UTC (rev 3838) @@ -1,3 +1,9 @@ +Changes new in version 0.17.12, 16 March, 2009 +======================================================================== + +- Fixes to build against X11 on Mac OS X. + + Changes new in version 0.17.11, 2 March, 2009 ======================================================================== Modified: trunk/README =================================================================== --- trunk/README 2009-03-16 09:50:40 UTC (rev 3837) +++ trunk/README 2009-03-17 05:55:19 UTC (rev 3838) @@ -1,4 +1,4 @@ -OpenVRML library version 0.17.11 +OpenVRML library version 0.17.12 Copyright 1998, 1999, 2000 Chris Morley <cm...@ve...> Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Braden McDaniel <br...@en...> Modified: trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc =================================================================== --- trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc 2009-03-16 09:50:40 UTC (rev 3837) +++ trunk/ide-projects/Windows/VisualC9_0/OpenVRML/openvrml-gl/openvrml-gl.rc 2009-03-17 05:55:19 UTC (rev 3838) @@ -11,7 +11,7 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,3,0,0 + FILEVERSION 7,4,0,0 PRODUCTVERSION 0,17,99,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -28,7 +28,7 @@ BLOCK "040904b0" BEGIN VALUE "FileDescription", "OpenVRML OpenGL Renderer Library" - VALUE "FileVersion", "7, 3, 0, 0" + VALUE "FileVersion", "7, 4, 0, 0" VALUE "InternalName", "openvrml-gl" VALUE "LegalCopyright", "Copyright (C) 2009" VALUE "OriginalFilename", "openvrml-gl.dll" Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-16 09:50:40 UTC (rev 3837) +++ trunk/src/Makefile.am 2009-03-17 05:55:19 UTC (rev 3838) @@ -50,7 +50,7 @@ openvrml-player/filechooserdialog.h LIBOPENVRML_LIBRARY_VERSION = 8:8:0 -LIBOPENVRML_GL_LIBRARY_VERSION = 7:3:0 +LIBOPENVRML_GL_LIBRARY_VERSION = 7:4:0 # | | | # +------+ | +---+ # | | | Property changes on: trunk/src/libopenvrml/openvrml/bad_url.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/scene.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/scene.h ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801 Property changes on: trunk/src/libopenvrml/openvrml/script.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828 /branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801 + /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-17 07:11:04
|
Revision: 3839 http://openvrml.svn.sourceforge.net/openvrml/?rev=3839&view=rev Author: braden Date: 2009-03-17 07:10:58 +0000 (Tue, 17 Mar 2009) Log Message: ----------- Rely on an installed GtkGLExt. Modified Paths: -------------- trunk/Makefile.am trunk/configure.ac trunk/src/Makefile.am Removed Paths: ------------- trunk/lib/ Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-03-17 05:55:19 UTC (rev 3838) +++ trunk/Makefile.am 2009-03-17 07:10:58 UTC (rev 3839) @@ -1,4 +1,4 @@ -SUBDIRS = doc ide-projects models lib src mozilla-plugin data examples tests +SUBDIRS = doc ide-projects models src mozilla-plugin data examples tests ACLOCAL_AMFLAGS = -I m4 Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-03-17 05:55:19 UTC (rev 3838) +++ trunk/configure.ac 2009-03-17 07:10:58 UTC (rev 3839) @@ -8,7 +8,6 @@ [models/Makefile] [models/audio/Makefile] [models/textures/Makefile] - [lib/Makefile] [src/Makefile] [src/libopenvrml/openvrml-config.h] [src/libopenvrml-gl/openvrml-gl-config.h] @@ -172,7 +171,8 @@ # # openvrml-player uses GtkBuilder, which was introduced in GTK+ 2.12. # -PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.12 gthread-2.0 glib-2.0 >= 2.6], , +PKG_CHECK_MODULES([GTKGL], + [gtkglext-1.0 gtk+-2.0 >= 2.12 gthread-2.0 glib-2.0 >= 2.6], , [have_gtk=no]) # # openvrml-player uses GNOME_PARAM_GOPTION_CONTEXT, which was @@ -452,13 +452,8 @@ ]) AC_SUBST([OPENVRML_JAVASCRIPT_RPATH]) -if test X$enable_xembed != Xno; then - gtkglext_subdir=gtkglext -fi -AC_SUBST([gtkglext_subdir]) +AC_CONFIG_SUBDIRS([mozilla-plugin]) -AC_CONFIG_SUBDIRS([lib/gtkglext mozilla-plugin]) - AC_CONFIG_TESTDIR([tests]) AC_OUTPUT Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-17 05:55:19 UTC (rev 3838) +++ trunk/src/Makefile.am 2009-03-17 07:10:58 UTC (rev 3839) @@ -731,9 +731,6 @@ endif openvrml_xembed_openvrml_xembed_CPPFLAGS = \ -I$(top_builddir)/src/openvrml-xembed \ - -I$(top_srcdir)/lib/gtkglext \ - -I$(top_builddir)/lib/gtkglext \ - -I$(top_builddir)/lib/gtkglext/gdk \ -I$(top_builddir)/src/libopenvrml \ -I$(top_srcdir)/src/libopenvrml \ -I$(top_builddir)/src/libopenvrml-gl \ @@ -743,8 +740,7 @@ openvrml_xembed_openvrml_xembed_CXXFLAGS = \ $(PTHREAD_CFLAGS) \ $(DBUS_G_CFLAGS) \ - $(GTK_CFLAGS) \ - $(GL_CFLAGS) + $(GTKGL_CFLAGS) openvrml_xembed_openvrml_xembed_SOURCES = \ openvrml-xembed/main.cpp \ openvrml-xembed/browserfactory.cpp \ @@ -756,12 +752,9 @@ openvrml-xembed/streamclient.h openvrml_xembed_openvrml_xembed_LDFLAGS = \ $(DBUS_G_LIBS) \ - $(GTK_LIBS) \ - $(GL_LIBS) + $(GTKGL_LIBS) openvrml_xembed_openvrml_xembed_LDADD = \ - libopenvrml-gl/libopenvrml-gl.la \ - $(top_builddir)/lib/gtkglext/gtk/libgtkglext-x11-1.0.la \ - $(top_builddir)/lib/gtkglext/gdk/libgdkglext-x11-1.0.la + libopenvrml-gl/libopenvrml-gl.la openvrml_xembed_datadir = $(datadir)/openvrml-xembed openvrml_xembed_dbusdir = $(openvrml_xembed_datadir)/dbus-1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-18 21:23:14
|
Revision: 3843 http://openvrml.svn.sourceforge.net/openvrml/?rev=3843&view=rev Author: braden Date: 2009-03-18 21:23:03 +0000 (Wed, 18 Mar 2009) Log Message: ----------- Fixes to build with gcc 4.0 (on Mac OS X 10.5). This compiler appears to have some bugs with access rules and inner classes; interjecting some forwarding functions works around the problem. Modified Paths: -------------- trunk/ChangeLog trunk/src/libopenvrml/openvrml/local/parse_vrml.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-18 03:49:02 UTC (rev 3842) +++ trunk/ChangeLog 2009-03-18 21:23:03 UTC (rev 3843) @@ -1,3 +1,10 @@ +2009-03-18 Braden McDaniel <br...@en...> + + * src/libopenvrml/openvrml/local/parse_vrml.h: Fixes to build with + gcc 4.0 (on Mac OS X 10.5). This compiler appears to have some + bugs with access rules and inner classes; interjecting some + forwarding functions works around the problem. + 2009-03-17 Braden McDaniel <br...@en...> Rely on an installed GtkGLExt. Modified: trunk/src/libopenvrml/openvrml/local/parse_vrml.h =================================================================== --- trunk/src/libopenvrml/openvrml/local/parse_vrml.h 2009-03-18 03:49:02 UTC (rev 3842) +++ trunk/src/libopenvrml/openvrml/local/parse_vrml.h 2009-03-18 21:23:03 UTC (rev 3843) @@ -150,6 +150,11 @@ vrml97_parse_actions & actions_; } on_scene_finish; + static boost::thread_group & get_load_proto_thread_group(browser & b) + { + return b.load_proto_thread_group_; + } + struct on_externproto_t { explicit on_externproto_t(vrml97_parse_actions & actions): actions_(actions) @@ -209,8 +214,8 @@ metatype_id, this->actions_.scene_, uri_list, - this->actions_.scene_.browser() - .load_proto_thread_group_)); + get_load_proto_thread_group( + this->actions_.scene_.browser()))); this->actions_.scene_.browser().add_node_metatype( externproto_class->id(), @@ -534,6 +539,11 @@ vrml97_parse_actions & actions_; } on_node_start; + static script_node_metatype & get_script_node_metatype(browser & b) + { + return b.script_node_metatype_; + } + struct on_node_finish_t { explicit on_node_finish_t(vrml97_parse_actions & actions): actions_(actions) @@ -554,7 +564,8 @@ ? nd.type->create_node(ps.scope, nd.initial_values) : intrusive_ptr<node>( new script_node( - this->actions_.scene_.browser().script_node_metatype_, + get_script_node_metatype( + this->actions_.scene_.browser()), ps.scope, nd.script_interfaces, nd.initial_values)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 04:07:25
|
Revision: 3845 http://openvrml.svn.sourceforge.net/openvrml/?rev=3845&view=rev Author: braden Date: 2009-03-19 04:07:16 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Newer jni.h is more const-correct; play along. Modified Paths: -------------- trunk/ChangeLog trunk/src/script/java.cpp Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 01:31:51 UTC (rev 3844) +++ trunk/ChangeLog 2009-03-19 04:07:16 UTC (rev 3845) @@ -1,5 +1,15 @@ 2009-03-18 Braden McDaniel <br...@en...> + Newer jni.h is more const-correct; play along. + + * src/script/java.cpp + (set_array_region_t<jfloat>::value): Added "const" for consistency + with newer jni.h. + (set_array_region_t<jdouble>::value): Added "const" for consistency + with newer jni.h. + +2009-03-18 Braden McDaniel <br...@en...> + * src/libopenvrml/openvrml/local/parse_vrml.h: Fixes to build with gcc 4.0 (on Mac OS X 10.5). This compiler appears to have some bugs with access rules and inner classes; interjecting some Modified: trunk/src/script/java.cpp =================================================================== --- trunk/src/script/java.cpp 2009-03-19 01:31:51 UTC (rev 3844) +++ trunk/src/script/java.cpp 2009-03-19 04:07:16 UTC (rev 3845) @@ -4491,20 +4491,20 @@ template <> struct set_array_region_t<jfloat> { static void (JNIEnv::* const value)( - array_type<jfloat>::type, jsize, jsize, jfloat *); + array_type<jfloat>::type, jsize, jsize, const jfloat *); }; void (JNIEnv::* const set_array_region_t<jfloat>::value)( - array_type<jfloat>::type, jsize, jsize, jfloat *) = + array_type<jfloat>::type, jsize, jsize, const jfloat *) = &JNIEnv::SetFloatArrayRegion; template <> struct set_array_region_t<jdouble> { static void (JNIEnv::* const value)( - array_type<jdouble>::type, jsize, jsize, jdouble *); + array_type<jdouble>::type, jsize, jsize, const jdouble *); }; void (JNIEnv::* const set_array_region_t<jdouble>::value)( - array_type<jdouble>::type, jsize, jsize, jdouble *) = + array_type<jdouble>::type, jsize, jsize, const jdouble *) = &JNIEnv::SetDoubleArrayRegion; template <typename T> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 04:19:33
|
Revision: 3846 http://openvrml.svn.sourceforge.net/openvrml/?rev=3846&view=rev Author: braden Date: 2009-03-19 04:19:27 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Created a convenience library libopenvrml-control to hold the platform-independent parts of the OpenVRML control (which is currently called openvrml-xembed). Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/openvrml-xembed/browser.cpp trunk/src/openvrml-xembed/plugin_streambuf.h Added Paths: ----------- trunk/src/libopenvrml-control/ trunk/src/libopenvrml-control/openvrml_control/ trunk/src/libopenvrml-control/openvrml_control/browser.cpp trunk/src/libopenvrml-control/openvrml_control/browser.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 04:07:16 UTC (rev 3845) +++ trunk/ChangeLog 2009-03-19 04:19:27 UTC (rev 3846) @@ -1,3 +1,73 @@ +2009-03-19 Braden McDaniel <br...@en...> + + Created a convenience library libopenvrml-control to hold the + platform-independent parts of the OpenVRML control (which is + currently called openvrml-xembed). + + * src/Makefile.am + (noinst_LTLIBRARIES): Added convenience library + libopenvrml-control. + (libopenvrml_control_libopenvrml_control_la_SOURCES): + libopenvrml-control sources. + (libopenvrml_control_libopenvrml_control_la_CPPFLAGS): + libopenvrml-control CPPFLAGS. + (libopenvrml_control_libopenvrml_control_la_LIBADD): Depends on + libopenvrml. + (openvrml_xembed_openvrml_xembed_CPPFLAGS): Added + libopenvrml-control to include path. + (openvrml_xembed_openvrml_xembed_LDADD): Depends on + libopenvrml-control. + * src/libopenvrml-control/openvrml_control/browser.cpp: Added + file. openvrml_control::browser encapsulates a browser "control". + * src/libopenvrml-control/openvrml_control/browser.h: Added + file. openvrml_control::browser encapsulates a browser "control". + * src/openvrml-xembed/browser.cpp + (resource_fetcher): Moved to + src/libopenvrml-control/openvrml_control/browser.cpp. + (browser_host_proxy): Added; implements + openvrml_control::browser_host. + (OpenvrmlXembedBrowserPrivate_): Added browser_control_host_proxy + and browser_control; removed resource_fetcher, browser, + browser_initialized_mutex, uninitialized_streambuf_map, + streambuf_map, initial_stream_reader_thread, got_initial_stream, + and browser_initialized. The removed members have been moved + to (or have equivalents in) openvrml_control::browser. + (initial_stream_reader): Moved to + src/libopenvrml-control/openvrml_control/browser.cpp. + (openvrml_xembed_browser_constructor(GType, guint, + GObjectConstructParam *)): Initialize the browser_control and + browser_control_host_proxy members; removed initialization of + removed members. + (openvrml_xembed_browser_finalize(GObject *)): Removed cleanup of + removed members; delete browser_control and + browser_control_host_proxy. + (openvrml_xembed_browser_new_stream(OpenvrmlXembedStreamClient *, + guint64, const char *, const char *, GError **)): Delegate to + openvrml_control::browser::new_stream. + (openvrml_xembed_browser_destroy_stream(OpenvrmlXembedStreamClient *, + guint64, GError **)): Delegate to + openvrml_control::browser::destroy_stream. + (openvrml_xembed_browser_write(OpenvrmlXembedStreamClient *, + guint64, const GArray *, GError **)): Delegate to + openvrml_control::browser::write. + (load_url): Moved to + src/libopenvrml-control/openvrml_control/browser.cpp. + (openvrml_xembed_browser_load_url(OpenvrmlXembedBrowser *, const + gchar **, const gchar **, GError **)): Delegate to + openvrml_control::browser::load_uri. + (openvrml_xembed_browser_get_world_url(OpenvrmlXembedBrowser *, + GError **)): Delegate to openvrml_control::browser::world_url. + (openvrml_xembed_browser_initialized(OpenvrmlXembedBrowser *)): + Delegate to openvrml_control::browser::initialized. + (browser_listener::do_browser_changed(const + openvrml::browser_event &)): Don't set browser_initialized; this + is now taken care of inside openvrml_control::browser. + (GtkGLViewer::GtkGLViewer(OpenvrmlXembedBrowserPlug &)): Call + openvrml_control::browser::viewer. + * src/openvrml-xembed/plugin_streambuf.h + (openvrml_xembed::plugin_streambuf): Grant friendship to + openvrml_control::browser. + 2009-03-18 Braden McDaniel <br...@en...> Newer jni.h is more const-correct; play along. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-19 04:07:16 UTC (rev 3845) +++ trunk/src/Makefile.am 2009-03-19 04:19:27 UTC (rev 3846) @@ -721,6 +721,7 @@ libopenvrml_gl_libopenvrml_gl_la_LIBADD = libopenvrml/libopenvrml.la if ENABLE_XEMBED +noinst_LTLIBRARIES = libopenvrml-control/libopenvrml-control.la libexec_PROGRAMS = openvrml-xembed/openvrml-xembed session_bus_servicesdir = $(datadir)/dbus-1/services session_bus_services_DATA = openvrml-xembed/org.openvrml.BrowserControl.service @@ -729,8 +730,20 @@ openvrml-xembed/browser-factory-server-glue.h \ openvrml-xembed/browser-host-client-glue.h endif +libopenvrml_control_libopenvrml_control_la_SOURCES = \ + libopenvrml-control/openvrml_control/browser.cpp \ + libopenvrml-control/openvrml_control/browser.h +libopenvrml_control_libopenvrml_control_la_CPPFLAGS = \ + -I$(top_srcdir)/src/openvrml-xembed \ + -I$(top_builddir)/src/libopenvrml \ + -I$(top_srcdir)/src/libopenvrml +libopenvrml_control_libopenvrml_control_la_LIBADD = \ + libopenvrml/libopenvrml.la + openvrml_xembed_openvrml_xembed_CPPFLAGS = \ -I$(top_builddir)/src/openvrml-xembed \ + -I$(top_srcdir)/src/openvrml-xembed \ + -I$(top_srcdir)/src/libopenvrml-control \ -I$(top_builddir)/src/libopenvrml \ -I$(top_srcdir)/src/libopenvrml \ -I$(top_builddir)/src/libopenvrml-gl \ @@ -753,6 +766,7 @@ $(DBUS_G_LIBS) \ $(GTKGL_LIBS) openvrml_xembed_openvrml_xembed_LDADD = \ + libopenvrml-control/libopenvrml-control.la \ libopenvrml-gl/libopenvrml-gl.la openvrml_xembed_datadir = $(datadir)/openvrml-xembed Added: trunk/src/libopenvrml-control/openvrml_control/browser.cpp =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.cpp (rev 0) +++ trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 04:19:27 UTC (rev 3846) @@ -0,0 +1,366 @@ +// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- +// +// OpenVRML Control +// +// Copyright 2009 Braden N. McDaniel +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; if not, see <http://www.gnu.org/licenses/>. +// + +# include "browser.h" +# include <openvrml/browser.h> +# include <boost/lexical_cast.hpp> +# include <iostream> + +openvrml_control::unknown_stream::unknown_stream(const std::string & uri): + std::logic_error("no stream corresponding to URI: " + uri) +{} + +openvrml_control::unknown_stream::unknown_stream(const uint64_t stream_id): + std::logic_error("no stream corresponding to stream ID: " + + boost::lexical_cast<std::string>(stream_id)) +{} + +openvrml_control::unknown_stream::~unknown_stream() throw () +{} + +openvrml_control::browser::resource_fetcher:: +resource_fetcher(browser_host & control_host, + openvrml_xembed::uninitialized_plugin_streambuf_map & + uninitialized_plugin_streambuf_map, + openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map): + control_host_(control_host), + uninitialized_plugin_streambuf_map_(uninitialized_plugin_streambuf_map), + plugin_streambuf_map_(plugin_streambuf_map) +{} + +openvrml_control::browser::resource_fetcher::~resource_fetcher() + OPENVRML_NOTHROW +{ + this->thread_group_.join_all(); +} + +void +openvrml_control::browser::resource_fetcher:: +create_thread(const boost::function0<void> & threadfunc) +{ + this->thread_group_.create_thread(threadfunc); +} + +std::auto_ptr<openvrml::resource_istream> +openvrml_control::browser::resource_fetcher:: +do_get_resource(const std::string & uri) +{ + using openvrml_xembed::plugin_streambuf; + + class plugin_resource_istream : public openvrml::resource_istream { + const boost::shared_ptr<plugin_streambuf> streambuf_; + resource_fetcher & resource_fetcher_; + + public: + plugin_resource_istream(const std::string & uri, + resource_fetcher & fetcher): + openvrml::resource_istream(0), + streambuf_( + new plugin_streambuf( + uri, + fetcher.uninitialized_plugin_streambuf_map_, + fetcher.plugin_streambuf_map_)), + resource_fetcher_(fetcher) + { + this->rdbuf(this->streambuf_.get()); + fetcher.uninitialized_plugin_streambuf_map_.insert( + uri, this->streambuf_); + + // + // browser_host::get_url could throw; let it. + // + const int get_url_result = fetcher.control_host_.get_url(uri); + + if (get_url_result != 0) { + this->setstate(ios_base::badbit); + } + this->streambuf_->set_get_url_result(get_url_result); + } + + private: + virtual const std::string do_url() const OPENVRML_NOTHROW + { + return this->streambuf_->url(); + } + + virtual const std::string do_type() const OPENVRML_NOTHROW + { + return this->streambuf_->type(); + } + + virtual bool do_data_available() const OPENVRML_NOTHROW + { + return this->streambuf_->data_available(); + } + }; + return std::auto_ptr<openvrml::resource_istream>( + new plugin_resource_istream(uri, *this)); +} + +openvrml_control::browser::browser_listener::browser_listener(browser & b): + browser_(b) +{} + +void +openvrml_control::browser::browser_listener:: +do_browser_changed(const openvrml::browser_event & event) +{ + switch (event.id()) { + case openvrml::browser_event::initialized: + { + boost::mutex::scoped_lock lock(this->browser_.initialized_mutex_); + this->browser_.initialized_ = true; + } + break; + default: + break; + } +} + +namespace { + // + // We don't already know what the URI of the initial stream is until we + // start getting that data from the browser. This is a placeholder that + // is used to identify the plugin_streambuf that will be used to receive + // the initial stream data. + // + const char initial_stream_uri[] = "x-openvrml-initial:"; + + struct OPENVRML_LOCAL initial_stream_reader { + initial_stream_reader( + const boost::shared_ptr<openvrml_xembed::plugin_streambuf> & + streambuf, + openvrml::browser & browser): + streambuf_(streambuf), + browser_(browser) + {} + + void operator()() const throw () + { + using openvrml_xembed::plugin_streambuf; + + class plugin_istream : public openvrml::resource_istream { + boost::shared_ptr<plugin_streambuf> streambuf_; + + public: + explicit plugin_istream( + const boost::shared_ptr<plugin_streambuf> & streambuf): + openvrml::resource_istream(streambuf.get()), + streambuf_(streambuf) + {} + + virtual ~plugin_istream() throw () + {} + + private: + virtual const std::string do_url() const throw (std::bad_alloc) + { + return this->streambuf_->url(); + } + + virtual const std::string do_type() const + throw (std::bad_alloc) + { + return this->streambuf_->type(); + } + + virtual bool do_data_available() const throw () + { + return this->streambuf_->data_available(); + } + } in(this->streambuf_); + + this->browser_.set_world(in); + } + + private: + boost::shared_ptr<openvrml_xembed::plugin_streambuf> streambuf_; + openvrml::browser & browser_; + }; +} + +openvrml_control::browser::browser(browser_host & host, + const bool expect_initial_stream): + fetcher_(host, + this->uninitialized_streambuf_map_, + this->streambuf_map_), + listener_(*this), + browser_(this->fetcher_, std::cout, std::cerr), + host_(host), + expect_initial_stream_(expect_initial_stream), + got_initial_stream_(false) +{ + this->browser_.add_listener(this->listener_); + + // + // If necessary, create the initial stream. + // + if (expect_initial_stream) { + using boost::function0; + using boost::shared_ptr; + using openvrml_xembed::plugin_streambuf; + + const shared_ptr<plugin_streambuf> initial_stream( + new plugin_streambuf(::initial_stream_uri, + this->uninitialized_streambuf_map_, + this->streambuf_map_)); + initial_stream->state_ = plugin_streambuf::uninitialized; + this->uninitialized_streambuf_map_.insert(::initial_stream_uri, + initial_stream); + + const function0<void> initial_stream_reader_func = + initial_stream_reader(initial_stream, this->browser_); + + this->initial_stream_reader_thread_.reset( + new boost::thread(initial_stream_reader_func)); + } +} + +openvrml_control::browser::~browser() OPENVRML_NOTHROW +{ + if (this->expect_initial_stream_) { + this->initial_stream_reader_thread_->join(); + } + this->browser_.remove_listener(this->listener_); +} + +bool openvrml_control::browser::initialized() const +{ + boost::mutex::scoped_lock lock(this->initialized_mutex_); + return this->initialized_; +} + +void openvrml_control::browser::new_stream(const uint64_t stream_id, + const std::string & type, + const std::string & uri) + OPENVRML_THROW1(unknown_stream) +{ + using namespace openvrml_xembed; + using boost::shared_ptr; + + shared_ptr<plugin_streambuf> streambuf = + this->uninitialized_streambuf_map_.find(uri); + + if (!streambuf) { + if (!this->got_initial_stream_) { + assert(this->uninitialized_streambuf_map_.size() == 1); + streambuf = this->uninitialized_streambuf_map_.front(); + this->got_initial_stream_ = true; + } else { + throw unknown_stream(uri); + } + } + assert(streambuf->state() != plugin_streambuf::initialized); + streambuf->init(stream_id, uri, type); +} + +void openvrml_control::browser::destroy_stream(const uint64_t stream_id) + OPENVRML_THROW1(unknown_stream) +{ + using namespace openvrml_xembed; + using boost::shared_ptr; + + const shared_ptr<plugin_streambuf> streambuf = + this->streambuf_map_.find(stream_id); + if (!streambuf) { throw unknown_stream(stream_id); } + streambuf->buf_.set_eof(); + this->streambuf_map_.erase(stream_id); +} + +void openvrml_control::browser::write(const uint64_t stream_id, + const unsigned char * const data, + const size_t size) + OPENVRML_THROW1(unknown_stream) +{ + using namespace openvrml_xembed; + using boost::shared_ptr; + + const shared_ptr<plugin_streambuf> streambuf = + this->streambuf_map_.find(stream_id); + if (!streambuf) { throw unknown_stream(stream_id); } + for (size_t i = 0; i < size; ++i) { streambuf->buf_.put(data[i]); } +} + +struct OPENVRML_LOCAL openvrml_control::browser::load_url { + load_url(browser & b, + const std::vector<std::string> & url, + const std::vector<std::string> & parameter): + browser_(b), + url_(url), + parameter_(parameter) + {} + + void operator()() const OPENVRML_NOTHROW + { + try { + { + boost::mutex::scoped_lock + lock(this->browser_.initialized_mutex_); + this->browser_.initialized_ = false; + } + this->browser_.browser_.load_url(this->url_, this->parameter_); + } catch (std::exception & ex) { + this->browser_.browser_.err(ex.what()); + } + } + + private: + browser & browser_; + const std::vector<std::string> url_, parameter_; +}; + +void +openvrml_control::browser::load_uri(const std::vector<std::string> & uri, + const std::vector<std::string> & parameter) + OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc) +{ + this->fetcher_.create_thread(load_url(*this, uri, parameter)); +} + +const std::string openvrml_control::browser::world_url() +{ + return this->browser_.world_url(); +} + +bool +openvrml_control::browser::add_listener(openvrml::browser_listener & listener) +{ + return this->browser_.add_listener(listener); +} + +bool +openvrml_control::browser:: +remove_listener(openvrml::browser_listener & listener) +{ + return this->browser_.remove_listener(listener); +} + +void openvrml_control::browser::viewer(openvrml::viewer * v) +{ + this->browser_.viewer(v); +} + +openvrml_control::browser_host::~browser_host() +{} + +int openvrml_control::browser_host::get_url(const std::string & url) +{ + this->do_get_url(url); +} Property changes on: trunk/src/libopenvrml-control/openvrml_control/browser.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/src/libopenvrml-control/openvrml_control/browser.h =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.h (rev 0) +++ trunk/src/libopenvrml-control/openvrml_control/browser.h 2009-03-19 04:19:27 UTC (rev 3846) @@ -0,0 +1,123 @@ +// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- +// +// OpenVRML Control +// +// Copyright 2009 Braden N. McDaniel +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; if not, see <http://www.gnu.org/licenses/>. +// + +# ifndef OPENVRML_CONTROL_BROWSER_H +# define OPENVRML_CONTROL_BROWSER_H + +# include "plugin_streambuf.h" +# include <openvrml/browser.h> + +namespace openvrml_control { + + class unknown_stream : public std::logic_error { + public: + explicit unknown_stream(const std::string & uri); + explicit unknown_stream(uint64_t stream_id); + virtual ~unknown_stream() throw (); + }; + + class browser_host; + + class browser { + struct load_url; + + class resource_fetcher : public openvrml::resource_fetcher { + browser_host & control_host_; + openvrml_xembed::uninitialized_plugin_streambuf_map & + uninitialized_plugin_streambuf_map_; + openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map_; + boost::thread_group thread_group_; + + public: + resource_fetcher( + browser_host & control_host, + openvrml_xembed::uninitialized_plugin_streambuf_map & + uninitialized_plugin_streambuf_map, + openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map); + virtual ~resource_fetcher() OPENVRML_NOTHROW; + + void create_thread(const boost::function0<void> & threadfunc); + + private: + virtual std::auto_ptr<openvrml::resource_istream> + do_get_resource(const std::string & uri); + }; + + class browser_listener : public openvrml::browser_listener { + browser & browser_; + + public: + explicit browser_listener(browser & b); + + private: + virtual void + do_browser_changed(const openvrml::browser_event & event); + }; + + openvrml_xembed::uninitialized_plugin_streambuf_map + uninitialized_streambuf_map_; + openvrml_xembed::plugin_streambuf_map streambuf_map_; + resource_fetcher fetcher_; + browser_listener listener_; + openvrml::browser browser_; + browser_host & host_; + boost::scoped_ptr<boost::thread> initial_stream_reader_thread_; + bool expect_initial_stream_, got_initial_stream_; + mutable boost::mutex initialized_mutex_; + bool initialized_; + + public: + browser(browser_host & host, bool expect_initial_stream); + ~browser() OPENVRML_NOTHROW; + + bool initialized() const; + + void new_stream(uint64_t stream_id, + const std::string & type, const std::string & uri) + OPENVRML_THROW1(unknown_stream); + void destroy_stream(uint64_t stream_id) + OPENVRML_THROW1(unknown_stream); + void write(uint64_t stream_id, const unsigned char * data, size_t size) + OPENVRML_THROW1(unknown_stream); + + void load_uri(const std::vector<std::string> & uri, + const std::vector<std::string> & parameter) + OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc); + const std::string world_url(); + + bool add_listener(openvrml::browser_listener & listener); + bool remove_listener(openvrml::browser_listener & listener); + + void viewer(openvrml::viewer * v); + }; + + + class browser_host { + public: + virtual ~browser_host() = 0; + + int get_url(const std::string & url); + + private: + virtual int do_get_url(const std::string & url) = 0; + }; +} + +# endif // ifndef OPENVRML_CONTROL_BROWSER_H Property changes on: trunk/src/libopenvrml-control/openvrml_control/browser.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/src/openvrml-xembed/browser.cpp =================================================================== --- trunk/src/openvrml-xembed/browser.cpp 2009-03-19 04:07:16 UTC (rev 3845) +++ trunk/src/openvrml-xembed/browser.cpp 2009-03-19 04:19:27 UTC (rev 3846) @@ -18,21 +18,17 @@ // with this library; if not, see <http://www.gnu.org/licenses/>. // -# include <iostream> -# include <sstream> # include <boost/multi_index/detail/scope_guard.hpp> // Must include before X11 headers. # include <boost/numeric/conversion/converter.hpp> -# include <boost/ptr_container/ptr_map.hpp> # include <X11/keysym.h> # include <dbus/dbus-glib.h> # include <gdk/gdkx.h> -# include <openvrml/browser.h> +# include <openvrml_control/browser.h> # include <openvrml/gl/viewer.h> # include "browser.h" # include "browser-server-glue.h" # include "browser-host-client-glue.h" -# include "plugin_streambuf.h" # include <gtk/gtkgl.h> # include <gtk/gtkdrawingarea.h> @@ -73,54 +69,59 @@ openvrml_xembed_browser_stream_client_interface_init)) namespace { - class G_GNUC_INTERNAL resource_fetcher : public openvrml::resource_fetcher { - DBusGProxy & control_host_; - openvrml_xembed::uninitialized_plugin_streambuf_map & - uninitialized_plugin_streambuf_map_; - openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map_; - boost::thread_group thread_group_; + class G_GNUC_INTERNAL browser_listener : public openvrml::browser_listener { + OpenvrmlXembedBrowser & browser_; + public: - resource_fetcher( - DBusGProxy & control_host, - openvrml_xembed::uninitialized_plugin_streambuf_map & - uninitialized_plugin_streambuf_map, - openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map); - virtual ~resource_fetcher() OPENVRML_NOTHROW; + explicit browser_listener(OpenvrmlXembedBrowser & browser); - void create_thread(const boost::function0<void> & threadfunc); - private: - virtual std::auto_ptr<openvrml::resource_istream> - do_get_resource(const std::string & uri); + virtual void do_browser_changed(const openvrml::browser_event & event); }; - class G_GNUC_INTERNAL browser_listener : public openvrml::browser_listener { - OpenvrmlXembedBrowser & browser_; + class G_GNUC_INTERNAL browser_host_proxy : + public openvrml_control::browser_host { + + DBusGProxy & host_; + public: - explicit browser_listener(OpenvrmlXembedBrowser & browser); + explicit browser_host_proxy(DBusGProxy & host): + host_(host) + {} private: - virtual void do_browser_changed(const openvrml::browser_event & event); + virtual int do_get_url(const std::string & url) + { + GError * error = 0; + scope_guard error_guard = make_guard(g_error_free, boost::ref(error)); + gint result = -1; + gboolean succeeded = + org_openvrml_BrowserHost_get_url(&this->host_, + url.c_str(), + &result, + &error); + if (!succeeded) { + throw std::invalid_argument(error->message); + } + + error_guard.dismiss(); + + return result; + } }; } struct OpenvrmlXembedBrowserPrivate_ { DBusGProxy * control_host; - ::resource_fetcher * resource_fetcher; - openvrml::browser * browser; + browser_host_proxy * browser_control_host_proxy; + openvrml_control::browser * browser_control; browser_listener * listener; OpenvrmlXembedBrowserPlug * browser_plug; GMutex * browser_plug_mutex; GCond * browser_plug_set_cond; - GMutex * browser_initialized_mutex; - openvrml_xembed::uninitialized_plugin_streambuf_map * uninitialized_streambuf_map; - openvrml_xembed::plugin_streambuf_map * streambuf_map; - boost::thread * initial_stream_reader_thread; bool expect_initial_stream; - bool got_initial_stream; - bool browser_initialized; }; # define OPENVRML_XEMBED_BROWSER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OPENVRML_XEMBED_TYPE_BROWSER, OpenvrmlXembedBrowserPrivate)) @@ -207,68 +208,6 @@ &dbus_glib_openvrml_xembed_browser_object_info); } -namespace { - // - // We don't already know what the URI of the initial stream is until we - // start getting that data from the browser. This is a placeholder that - // is used to identify the plugin_streambuf that will be used to receive - // the initial stream data. - // - const char initial_stream_uri[] = "x-openvrml-initial:"; - - struct OPENVRML_LOCAL initial_stream_reader { - initial_stream_reader( - const boost::shared_ptr<openvrml_xembed::plugin_streambuf> & - streambuf, - openvrml::browser & browser): - streambuf_(streambuf), - browser_(browser) - {} - - void operator()() const throw () - { - using openvrml_xembed::plugin_streambuf; - - class plugin_istream : public openvrml::resource_istream { - boost::shared_ptr<plugin_streambuf> streambuf_; - - public: - explicit plugin_istream( - const boost::shared_ptr<plugin_streambuf> & streambuf): - openvrml::resource_istream(streambuf.get()), - streambuf_(streambuf) - {} - - virtual ~plugin_istream() throw () - {} - - private: - virtual const std::string do_url() const throw (std::bad_alloc) - { - return this->streambuf_->url(); - } - - virtual const std::string do_type() const - throw (std::bad_alloc) - { - return this->streambuf_->type(); - } - - virtual bool do_data_available() const throw () - { - return this->streambuf_->data_available(); - } - } in(this->streambuf_); - - this->browser_.set_world(in); - } - - private: - boost::shared_ptr<openvrml_xembed::plugin_streambuf> streambuf_; - openvrml::browser & browser_; - }; -} - GObject * openvrml_xembed_browser_constructor( GType type, @@ -289,54 +228,21 @@ try { OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); - browser->priv->uninitialized_streambuf_map = - new openvrml_xembed::uninitialized_plugin_streambuf_map; - browser->priv->streambuf_map = - new openvrml_xembed::plugin_streambuf_map; - browser->priv->resource_fetcher = - new resource_fetcher(*browser->priv->control_host, - *browser->priv->uninitialized_streambuf_map, - *browser->priv->streambuf_map); - browser->priv->browser = - new openvrml::browser(*browser->priv->resource_fetcher, - std::cout, - std::cerr); + browser->priv->browser_control_host_proxy = + new browser_host_proxy(*browser->priv->control_host); + browser->priv->browser_control = + new openvrml_control::browser( + *browser->priv->browser_control_host_proxy, + browser->priv->expect_initial_stream); browser->priv->listener = new browser_listener(*browser); - browser->priv->browser->add_listener(*browser->priv->listener); + browser->priv->browser_control->add_listener(*browser->priv->listener); browser->priv->browser_plug = 0; browser->priv->browser_plug_mutex = g_mutex_new(); browser->priv->browser_plug_set_cond = g_cond_new(); - - browser->priv->browser_initialized = false; - browser->priv->browser_initialized_mutex = g_mutex_new(); - - // - // If necessary, create the initial stream. - // - if (browser->priv->expect_initial_stream) { - using boost::function0; - using boost::shared_ptr; - using openvrml_xembed::plugin_streambuf; - - const shared_ptr<plugin_streambuf> initial_stream( - new plugin_streambuf( - ::initial_stream_uri, - *browser->priv->uninitialized_streambuf_map, - *browser->priv->streambuf_map)); - initial_stream->state_ = plugin_streambuf::uninitialized; - browser->priv->uninitialized_streambuf_map - ->insert(::initial_stream_uri, initial_stream); - - const function0<void> initial_stream_reader_func = - initial_stream_reader(initial_stream, *browser->priv->browser); - - browser->priv->initial_stream_reader_thread = - new boost::thread(initial_stream_reader_func); - } } catch (std::exception & ex) { // - // ex is most likely std::bad_alloc or boost::thread_resource_error. + // ex is most likely std::bad_alloc. // g_critical("%s", ex.what()); return 0; @@ -347,21 +253,12 @@ void openvrml_xembed_browser_finalize(GObject * const obj) { OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(obj); - - if (browser->priv->expect_initial_stream) { - browser->priv->initial_stream_reader_thread->join(); - delete browser->priv->initial_stream_reader_thread; - } - - g_mutex_free(browser->priv->browser_initialized_mutex); g_cond_free(browser->priv->browser_plug_set_cond); g_mutex_free(browser->priv->browser_plug_mutex); - browser->priv->browser->remove_listener(*browser->priv->listener); + browser->priv->browser_control->remove_listener(*browser->priv->listener); delete browser->priv->listener; - delete browser->priv->browser; - delete browser->priv->resource_fetcher; - delete browser->priv->streambuf_map; - delete browser->priv->uninitialized_streambuf_map; + delete browser->priv->browser_control; + delete browser->priv->browser_control_host_proxy; } void openvrml_xembed_browser_set_property(GObject * const obj, @@ -458,28 +355,15 @@ OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(stream_client); - shared_ptr<plugin_streambuf> streambuf = - browser->priv->uninitialized_streambuf_map->find(url); - - if (!streambuf) { - if (!browser->priv->got_initial_stream) { - g_assert( - browser->priv->uninitialized_streambuf_map->size() == 1); - streambuf = - browser->priv->uninitialized_streambuf_map->front(); - browser->priv->got_initial_stream = true; - } else { - g_set_error( - error, - OPENVRML_XEMBED_ERROR, - OPENVRML_XEMBED_ERROR_UNKNOWN_STREAM, - "Attempt to create a stream that has not been requested: %s", - url); - return false; - } + try { + browser->priv->browser_control->new_stream(stream_id, type, url); + } catch (const openvrml_control::unknown_stream & ex) { + g_set_error(error, + OPENVRML_XEMBED_ERROR, + OPENVRML_XEMBED_ERROR_UNKNOWN_STREAM, + ex.what()); + return false; } - g_assert(streambuf->state() != plugin_streambuf::initialized); - streambuf->init(stream_id, url, type); return true; } @@ -495,19 +379,15 @@ OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(stream_client); - const shared_ptr<plugin_streambuf> streambuf = - browser->priv->streambuf_map->find(stream_id); - if (!streambuf) { - g_set_error( - error, - OPENVRML_XEMBED_ERROR, - OPENVRML_XEMBED_ERROR_UNKNOWN_STREAM, - "Attempt to destroy a nonexistent stream: %lu", - stream_id); + try { + browser->priv->browser_control->destroy_stream(stream_id); + } catch (const openvrml_control::unknown_stream & ex) { + g_set_error(error, + OPENVRML_XEMBED_ERROR, + OPENVRML_XEMBED_ERROR_UNKNOWN_STREAM, + ex.what()); return false; } - streambuf->buf_.set_eof(); - browser->priv->streambuf_map->erase(stream_id); return true; } @@ -523,52 +403,20 @@ OpenvrmlXembedBrowser * const browser = OPENVRML_XEMBED_BROWSER(stream_client); - const shared_ptr<plugin_streambuf> streambuf = - browser->priv->streambuf_map->find(stream_id); - if (!streambuf) { - g_set_error( - error, - OPENVRML_XEMBED_ERROR, - OPENVRML_XEMBED_ERROR_UNKNOWN_STREAM, - "Attempt to write to a nonexistent stream: %lu", - stream_id); - return false; + try { + browser->priv->browser_control->write( + stream_id, + reinterpret_cast<unsigned char *>(data->data), + data->len); + } catch (const openvrml_control::unknown_stream & ex) { + g_set_error(error, + OPENVRML_XEMBED_ERROR, + OPENVRML_XEMBED_ERROR_UNKNOWN_STREAM, + ex.what()); } - for (size_t i = 0; i < data->len; ++i) { - streambuf->buf_.put(g_array_index(data, unsigned char, i)); - } return true; } -namespace { - struct G_GNUC_INTERNAL load_url { - load_url(OpenvrmlXembedBrowser & browser, - const std::vector<std::string> & url, - const std::vector<std::string> & parameter): - browser_(browser), - url_(url), - parameter_(parameter) - {} - - void operator()() const OPENVRML_NOTHROW - { - try { - g_mutex_lock(this->browser_.priv->browser_initialized_mutex); - this->browser_.priv->browser_initialized = false; - g_mutex_unlock(this->browser_.priv->browser_initialized_mutex); - this->browser_.priv->browser->load_url(this->url_, - this->parameter_); - } catch (std::exception & ex) { - this->browser_.priv->browser->err(ex.what()); - } - } - - private: - OpenvrmlXembedBrowser & browser_; - const std::vector<std::string> url_, parameter_; - }; -} - gboolean openvrml_xembed_browser_load_url(OpenvrmlXembedBrowser * const vrml_browser, const gchar ** url, @@ -583,8 +431,7 @@ while (url && *url) { url_vec.push_back(*(url++)); } while (parameter && *parameter) { param_vec.push_back(*(parameter++)); } - vrml_browser->priv->resource_fetcher - ->create_thread(load_url(*vrml_browser, url_vec, param_vec)); + vrml_browser->priv->browser_control->load_uri(url_vec, param_vec); } catch (const std::bad_alloc & ex) { *error = g_error_new(OPENVRML_XEMBED_ERROR, OPENVRML_XEMBED_ERROR_NO_MEMORY, @@ -653,19 +500,16 @@ gchar * openvrml_xembed_browser_get_world_url( - OpenvrmlXembedBrowser * const vrml_browser, + OpenvrmlXembedBrowser * const browser, GError ** /* error */) { - return g_strdup(vrml_browser->priv->browser->world_url().c_str()); + return g_strdup(browser->priv->browser_control->world_url().c_str()); } gboolean openvrml_xembed_browser_initialized(OpenvrmlXembedBrowser * const browser) { - g_mutex_lock(browser->priv->browser_initialized_mutex); - const bool browser_initialized = browser->priv->browser_initialized; - g_mutex_unlock(browser->priv->browser_initialized_mutex); - return browser_initialized; + return browser->priv->browser_control->initialized(); } @@ -1249,104 +1093,6 @@ namespace { - resource_fetcher::resource_fetcher( - DBusGProxy & control_host, - openvrml_xembed::uninitialized_plugin_streambuf_map & - uninitialized_plugin_streambuf_map, - openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map): - control_host_(control_host), - uninitialized_plugin_streambuf_map_(uninitialized_plugin_streambuf_map), - plugin_streambuf_map_(plugin_streambuf_map) - {} - - resource_fetcher::~resource_fetcher() OPENVRML_NOTHROW - { - this->thread_group_.join_all(); - } - - void - resource_fetcher::create_thread(const boost::function0<void> & threadfunc) - { - this->thread_group_.create_thread(threadfunc); - } - - std::auto_ptr<openvrml::resource_istream> - resource_fetcher::do_get_resource(const std::string & uri) - { - using openvrml_xembed::plugin_streambuf; - - class plugin_resource_istream : public openvrml::resource_istream { - const boost::shared_ptr<plugin_streambuf> streambuf_; - resource_fetcher & resource_fetcher_; - - public: - plugin_resource_istream(const std::string & uri, - resource_fetcher & fetcher): - openvrml::resource_istream(0), - streambuf_( - new plugin_streambuf( - uri, - fetcher.uninitialized_plugin_streambuf_map_, - fetcher.plugin_streambuf_map_)), - resource_fetcher_(fetcher) - { - using std::ostringstream; - using boost::ref; - - this->rdbuf(this->streambuf_.get()); - fetcher.uninitialized_plugin_streambuf_map_ - .insert(uri, this->streambuf_); - - // - // We're in a thread started by libopenvrml here. By using - // dbus_g_proxy_begin_call here (instead of dbus_g_proxy_call), - // we finish the call in the main thread. That's important - // because we want to make sure this call "finishes" before - // we execute the host's successive NewStream call. - // - GError * error = 0; - scope_guard error_guard = make_guard(g_error_free, - boost::ref(error)); - gint get_url_result = -1; - gboolean succeeded = - org_openvrml_BrowserHost_get_url(&fetcher.control_host_, - uri.c_str(), - &get_url_result, - &error); - if (!succeeded) { - g_critical(error->message); - this->setstate(ios_base::badbit); - return; - } - - if (get_url_result != 0) { - this->setstate(ios_base::badbit); - } - this->streambuf_->set_get_url_result(get_url_result); - - error_guard.dismiss(); - } - - private: - virtual const std::string do_url() const throw () - { - return this->streambuf_->url(); - } - - virtual const std::string do_type() const throw () - { - return this->streambuf_->type(); - } - - virtual bool do_data_available() const throw () - { - return this->streambuf_->data_available(); - } - }; - return std::auto_ptr<openvrml::resource_istream>( - new plugin_resource_istream(uri, *this)); - } - browser_listener::browser_listener(OpenvrmlXembedBrowser & browser): browser_(browser) {} @@ -1357,10 +1103,6 @@ switch (event.id()) { case openvrml::browser_event::initialized: g_signal_emit(&this->browser_, signals[initialized_id], 0); - - g_mutex_lock(this->browser_.priv->browser_initialized_mutex); - this->browser_.priv->browser_initialized = true; - g_mutex_unlock(this->browser_.priv->browser_initialized_mutex); break; case openvrml::browser_event::shutdown: g_signal_emit(&this->browser_, signals[shutdown_id], 0); @@ -1374,7 +1116,7 @@ browser_plug_(browser_plug), timer(0) { - this->browser_plug_.priv->browser->priv->browser->viewer(this); + this->browser_plug_.priv->browser->priv->browser_control->viewer(this); } GtkGLViewer::~GtkGLViewer() throw () Modified: trunk/src/openvrml-xembed/plugin_streambuf.h =================================================================== --- trunk/src/openvrml-xembed/plugin_streambuf.h 2009-03-19 04:07:16 UTC (rev 3845) +++ trunk/src/openvrml-xembed/plugin_streambuf.h 2009-03-19 04:19:27 UTC (rev 3846) @@ -28,8 +28,11 @@ # include <boost/enable_shared_from_this.hpp> # include <openvrml/read_write_mutex.h> # include "bounded_buffer.h" -# include "browser.h" +namespace openvrml_control { + class browser; +} + namespace openvrml_xembed { // @@ -86,20 +89,7 @@ public boost::enable_shared_from_this<plugin_streambuf>, public std::streambuf { - friend - GObject * - (::openvrml_xembed_browser_constructor)( - GType type, - guint n_construct_properties, - GObjectConstructParam * construct_properties); - friend - gboolean - (::openvrml_xembed_browser_destroy_stream)(OpenvrmlXembedStreamClient *, - guint64, GError **); - friend - gboolean - (::openvrml_xembed_browser_write)(OpenvrmlXembedStreamClient *, guint64, - const GArray *, GError **); + friend class openvrml_control::browser; public: enum state_id { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 04:53:33
|
Revision: 3847 http://openvrml.svn.sourceforge.net/openvrml/?rev=3847&view=rev Author: braden Date: 2009-03-19 04:53:28 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Removed crufty uses of openvrml_xembed namespace. Modified Paths: -------------- trunk/ChangeLog trunk/src/openvrml-xembed/browser.cpp Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 04:19:27 UTC (rev 3846) +++ trunk/ChangeLog 2009-03-19 04:53:28 UTC (rev 3847) @@ -1,5 +1,20 @@ 2009-03-19 Braden McDaniel <br...@en...> + Removed crufty uses of openvrml_xembed namespace. + + * src/openvrml-xembed/browser.cpp + (openvrml_xembed_browser_new_stream(OpenvrmlXembedStreamClient *, + guint64, const char *, const char *, GError **)): Removed crufty + use of openvrml_xembed namespace. + (openvrml_xembed_browser_destroy_stream(OpenvrmlXembedStreamClient *, + guint64, GError **)): Removed crufty use of openvrml_xembed + namespace. + (openvrml_xembed_browser_write(OpenvrmlXembedStreamClient *, + guint64, const GArray *, GError **)): Removed crufty use of + openvrml_xembed namespace. + +2009-03-19 Braden McDaniel <br...@en...> + Created a convenience library libopenvrml-control to hold the platform-independent parts of the OpenVRML control (which is currently called openvrml-xembed). Modified: trunk/src/openvrml-xembed/browser.cpp =================================================================== --- trunk/src/openvrml-xembed/browser.cpp 2009-03-19 04:19:27 UTC (rev 3846) +++ trunk/src/openvrml-xembed/browser.cpp 2009-03-19 04:53:28 UTC (rev 3847) @@ -349,7 +349,6 @@ const char * const url, GError ** const error) { - using namespace openvrml_xembed; using boost::shared_ptr; OpenvrmlXembedBrowser * const browser = @@ -373,7 +372,6 @@ const guint64 stream_id, GError ** const error) { - using namespace openvrml_xembed; using boost::shared_ptr; OpenvrmlXembedBrowser * const browser = @@ -397,7 +395,6 @@ const GArray * const data, GError ** const error) { - using namespace openvrml_xembed; using boost::shared_ptr; OpenvrmlXembedBrowser * const browser = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 05:27:15
|
Revision: 3848 http://openvrml.svn.sourceforge.net/openvrml/?rev=3848&view=rev Author: braden Date: 2009-03-19 05:27:10 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Moved bounded_buffer and plugin_streambuf to libopenvrml-control. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/libopenvrml-control/openvrml_control/browser.cpp trunk/src/libopenvrml-control/openvrml_control/browser.h Added Paths: ----------- trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h Removed Paths: ------------- trunk/src/openvrml-xembed/bounded_buffer.h trunk/src/openvrml-xembed/plugin_streambuf.cpp trunk/src/openvrml-xembed/plugin_streambuf.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/ChangeLog 2009-03-19 05:27:10 UTC (rev 3848) @@ -1,5 +1,60 @@ 2009-03-19 Braden McDaniel <br...@en...> + Moved bounded_buffer and plugin_streambuf to libopenvrml-control. + + * src/Makefile.am + (noinst_HEADERS): Removed openvrml-xembed/bounded_buffer.h and + openvrml-xembed/plugin_streambuf.h. + (libopenvrml_control_libopenvrml_control_la_SOURCES): Added + libopenvrml-control/openvrml_control/plugin_streambuf.{cpp,h} and + libopenvrml-control/openvrml_control/bounded_buffer.h. + (libopenvrml_control_libopenvrml_control_la_CPPFLAGS): Don't need + $(top_srcdir)/src/openvrml-xembed in the include path anymore. + (openvrml_xembed_openvrml_xembed_CPPFLAGS): Don't need + $(top_srcdir)/src/openvrml-xembed in the include path anymore. + (openvrml_xembed_openvrml_xembed_SOURCES): Removed + openvrml-xembed/plugin_streambuf.cpp. + * src/libopenvrml-control/openvrml_control/bounded_buffer.h: Moved + from src/openvrml-xembed/bounded_buffer.h. + * src/libopenvrml-control/openvrml_control/browser.cpp + (openvrml_control::browser::resource_fetcher::resource_fetcher( + browser_host &, uninitialized_plugin_streambuf_map &, + plugin_streambuf_map &)): uninitialized_plugin_streambuf_map and + plugin_streambuf_map are now in the openvrml_control namespace. + (openvrml_control::browser::resource_fetcher::do_get_resource(const + std::string &)): plugin_streambuf is now in the openvrml_control + namespace. + (initial_stream_reader::initial_stream_reader(const + boost::shared_ptr<openvrml_control::plugin_streambuf> &, + openvrml::browser &)): plugin_streambuf is now in the + openvrml_control namespace. + (initial_stream_reader::operator()() const): plugin_streambuf is + now in the openvrml_control namespace. + (openvrml_control::browser::browser(browser_host &, bool)): + plugin_streambuf is now in the openvrml_control namespace. + (openvrml_control::browser::new_stream(uint64_t, const std::string + &, const std::string &)): Removed obsolete reference to + openvrml_xembed namespace. + (openvrml_control::browser::destroy_stream(uint64_t)): Removed + obsolete reference to openvrml_xembed namespace. + (openvrml_control::browser::write(uint64_t, const unsigned char *, + size_t)): Removed obsolete reference to openvrml_xembed namespace. + * src/libopenvrml-control/openvrml_control/browser.h: + uninitialized_plugin_streambuf_map and plugin_streambuf_map are + now in the openvrml_control namespace. + * src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp: + Moved from src/openvrml-xembed/plugin_streambuf.cpp. + * src/libopenvrml-control/openvrml_control/plugin_streambuf.h: + Moved from src/openvrml-xembed/plugin_streambuf.h. + * src/openvrml-xembed/bounded_buffer.h: Moved to + src/libopenvrml-control/openvrml_control/bounded_buffer.h. + * src/openvrml-xembed/plugin_streambuf.cpp: Moved to + src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp. + * src/openvrml-xembed/plugin_streambuf.h: Moved to + src/libopenvrml-control/openvrml_control/plugin_streambuf.h. + +2009-03-19 Braden McDaniel <br...@en...> + Removed crufty uses of openvrml_xembed namespace. * src/openvrml-xembed/browser.cpp Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/src/Makefile.am 2009-03-19 05:27:10 UTC (rev 3848) @@ -45,8 +45,6 @@ noinst_HEADERS = \ libopenvrml/private.h \ - openvrml-xembed/bounded_buffer.h \ - openvrml-xembed/plugin_streambuf.h \ openvrml-player/filechooserdialog.h LIBOPENVRML_LIBRARY_VERSION = 8:8:0 @@ -732,9 +730,11 @@ endif libopenvrml_control_libopenvrml_control_la_SOURCES = \ libopenvrml-control/openvrml_control/browser.cpp \ - libopenvrml-control/openvrml_control/browser.h + libopenvrml-control/openvrml_control/browser.h \ + libopenvrml-control/openvrml_control/plugin_streambuf.cpp \ + libopenvrml-control/openvrml_control/plugin_streambuf.h \ + libopenvrml-control/openvrml_control/bounded_buffer.h libopenvrml_control_libopenvrml_control_la_CPPFLAGS = \ - -I$(top_srcdir)/src/openvrml-xembed \ -I$(top_builddir)/src/libopenvrml \ -I$(top_srcdir)/src/libopenvrml libopenvrml_control_libopenvrml_control_la_LIBADD = \ @@ -742,7 +742,6 @@ openvrml_xembed_openvrml_xembed_CPPFLAGS = \ -I$(top_builddir)/src/openvrml-xembed \ - -I$(top_srcdir)/src/openvrml-xembed \ -I$(top_srcdir)/src/libopenvrml-control \ -I$(top_builddir)/src/libopenvrml \ -I$(top_srcdir)/src/libopenvrml \ @@ -757,7 +756,6 @@ openvrml-xembed/main.cpp \ openvrml-xembed/browserfactory.cpp \ openvrml-xembed/browserfactory.h \ - openvrml-xembed/plugin_streambuf.cpp \ openvrml-xembed/browser.cpp \ openvrml-xembed/browser.h \ openvrml-xembed/streamclient.cpp \ Copied: trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h (from rev 3845, trunk/src/openvrml-xembed/bounded_buffer.h) =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h (rev 0) +++ trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h 2009-03-19 05:27:10 UTC (rev 3848) @@ -0,0 +1,116 @@ +// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- +// +// OpenVRML Control +// +// Copyright 2004, 2005, 2006, 2007 Braden McDaniel +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; if not, see <http://www.gnu.org/licenses/>. +// + +# ifndef OPENVRML_CONTROL_BOUNDED_BUFFER_H +# define OPENVRML_CONTROL_BOUNDED_BUFFER_H + +# include <cassert> +# include <string> +# include <boost/thread/mutex.hpp> +# include <boost/thread/condition.hpp> + +namespace openvrml_control { + + template <typename CharT, size_t BufferSize> + class bounded_buffer { + mutable boost::mutex mutex_; + boost::condition buffer_not_full_, buffer_not_empty_or_eof_; + + CharT buf_[BufferSize]; + size_t begin_, end_, buffered_; + bool eof_; + + public: + typedef CharT char_type; + typedef typename std::char_traits<char_type> traits_type; + typedef typename traits_type::int_type int_type; + + bounded_buffer(); + void put(const char_type & c); + int_type get(); + size_t buffered() const; + void set_eof(); + bool eof() const; + }; + + template <typename CharT, size_t BufferSize> + bounded_buffer<CharT, BufferSize>::bounded_buffer(): + begin_(0), + end_(0), + buffered_(0), + eof_(false) + {} + + template <typename CharT, size_t BufferSize> + void bounded_buffer<CharT, BufferSize>::put(const char_type & c) + { + boost::mutex::scoped_lock lock(this->mutex_); + while (this->buffered_ == BufferSize) { + this->buffer_not_full_.wait(lock); + } + this->buf_[this->end_] = c; + this->end_ = (this->end_ + 1) % BufferSize; + ++this->buffered_; + this->buffer_not_empty_or_eof_.notify_one(); + } + + template <typename CharT, size_t BufferSize> + typename bounded_buffer<CharT, BufferSize>::int_type + bounded_buffer<CharT, BufferSize>::get() + { + boost::mutex::scoped_lock lock(this->mutex_); + while (this->buffered_ == 0 && !this->eof_) { + this->buffer_not_empty_or_eof_.wait(lock); + } + if (this->buffered_ == 0 && this->eof_) { + return traits_type::eof(); + } + const int_type c = traits_type::to_int_type(this->buf_[this->begin_]); + this->begin_ = (this->begin_ + 1) % BufferSize; + --this->buffered_; + this->buffer_not_full_.notify_one(); + assert(!traits_type::eq_int_type(c, traits_type::eof())); + return c; + } + + template <typename CharT, size_t BufferSize> + size_t bounded_buffer<CharT, BufferSize>::buffered() const + { + boost::mutex::scoped_lock lock(this->mutex_); + return this->buffered_; + } + + template <typename CharT, size_t BufferSize> + void bounded_buffer<CharT, BufferSize>::set_eof() + { + boost::mutex::scoped_lock lock(this->mutex_); + this->eof_ = true; + this->buffer_not_empty_or_eof_.notify_one(); + } + + template <typename CharT, size_t BufferSize> + bool bounded_buffer<CharT, BufferSize>::eof() const + { + boost::mutex::scoped_lock lock(this->mutex_); + return this->eof_; + } +} + +# endif // ifndef OPENVRML_CONTROL_BOUNDED_BUFFER_H Property changes on: trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + /branches/0.17/src/openvrml-xembed/bounded_buffer.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/local/src/openvrml-xembed/bounded_buffer.h:3677-3689 /branches/node-modules/src/openvrml-xembed/bounded_buffer.h:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 Added: svn:eol-style + native Modified: trunk/src/libopenvrml-control/openvrml_control/browser.cpp =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 05:27:10 UTC (rev 3848) @@ -37,9 +37,9 @@ openvrml_control::browser::resource_fetcher:: resource_fetcher(browser_host & control_host, - openvrml_xembed::uninitialized_plugin_streambuf_map & + uninitialized_plugin_streambuf_map & uninitialized_plugin_streambuf_map, - openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map): + plugin_streambuf_map & plugin_streambuf_map): control_host_(control_host), uninitialized_plugin_streambuf_map_(uninitialized_plugin_streambuf_map), plugin_streambuf_map_(plugin_streambuf_map) @@ -62,8 +62,6 @@ openvrml_control::browser::resource_fetcher:: do_get_resource(const std::string & uri) { - using openvrml_xembed::plugin_streambuf; - class plugin_resource_istream : public openvrml::resource_istream { const boost::shared_ptr<plugin_streambuf> streambuf_; resource_fetcher & resource_fetcher_; @@ -145,7 +143,7 @@ struct OPENVRML_LOCAL initial_stream_reader { initial_stream_reader( - const boost::shared_ptr<openvrml_xembed::plugin_streambuf> & + const boost::shared_ptr<openvrml_control::plugin_streambuf> & streambuf, openvrml::browser & browser): streambuf_(streambuf), @@ -154,7 +152,7 @@ void operator()() const throw () { - using openvrml_xembed::plugin_streambuf; + using openvrml_control::plugin_streambuf; class plugin_istream : public openvrml::resource_istream { boost::shared_ptr<plugin_streambuf> streambuf_; @@ -191,7 +189,7 @@ } private: - boost::shared_ptr<openvrml_xembed::plugin_streambuf> streambuf_; + boost::shared_ptr<openvrml_control::plugin_streambuf> streambuf_; openvrml::browser & browser_; }; } @@ -215,7 +213,6 @@ if (expect_initial_stream) { using boost::function0; using boost::shared_ptr; - using openvrml_xembed::plugin_streambuf; const shared_ptr<plugin_streambuf> initial_stream( new plugin_streambuf(::initial_stream_uri, @@ -252,7 +249,6 @@ const std::string & uri) OPENVRML_THROW1(unknown_stream) { - using namespace openvrml_xembed; using boost::shared_ptr; shared_ptr<plugin_streambuf> streambuf = @@ -274,7 +270,6 @@ void openvrml_control::browser::destroy_stream(const uint64_t stream_id) OPENVRML_THROW1(unknown_stream) { - using namespace openvrml_xembed; using boost::shared_ptr; const shared_ptr<plugin_streambuf> streambuf = @@ -289,7 +284,6 @@ const size_t size) OPENVRML_THROW1(unknown_stream) { - using namespace openvrml_xembed; using boost::shared_ptr; const shared_ptr<plugin_streambuf> streambuf = Modified: trunk/src/libopenvrml-control/openvrml_control/browser.h =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.h 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/src/libopenvrml-control/openvrml_control/browser.h 2009-03-19 05:27:10 UTC (rev 3848) @@ -40,17 +40,17 @@ class resource_fetcher : public openvrml::resource_fetcher { browser_host & control_host_; - openvrml_xembed::uninitialized_plugin_streambuf_map & + uninitialized_plugin_streambuf_map & uninitialized_plugin_streambuf_map_; - openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map_; + plugin_streambuf_map & plugin_streambuf_map_; boost::thread_group thread_group_; public: resource_fetcher( browser_host & control_host, - openvrml_xembed::uninitialized_plugin_streambuf_map & + uninitialized_plugin_streambuf_map & uninitialized_plugin_streambuf_map, - openvrml_xembed::plugin_streambuf_map & plugin_streambuf_map); + plugin_streambuf_map & plugin_streambuf_map); virtual ~resource_fetcher() OPENVRML_NOTHROW; void create_thread(const boost::function0<void> & threadfunc); @@ -71,9 +71,9 @@ do_browser_changed(const openvrml::browser_event & event); }; - openvrml_xembed::uninitialized_plugin_streambuf_map + uninitialized_plugin_streambuf_map uninitialized_streambuf_map_; - openvrml_xembed::plugin_streambuf_map streambuf_map_; + plugin_streambuf_map streambuf_map_; resource_fetcher fetcher_; browser_listener listener_; openvrml::browser browser_; Copied: trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp (from rev 3845, trunk/src/openvrml-xembed/plugin_streambuf.cpp) =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp (rev 0) +++ trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp 2009-03-19 05:27:10 UTC (rev 3848) @@ -0,0 +1,264 @@ +// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- +// +// OpenVRML Control +// +// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; if not, see <http://www.gnu.org/licenses/>. +// + +# include "plugin_streambuf.h" + +openvrml_control::plugin_streambuf:: +plugin_streambuf(const std::string & requested_url, + uninitialized_plugin_streambuf_map & uninitialized_map, + plugin_streambuf_map & map): + state_(requested), + get_url_result_(-1), + url_(requested_url), + i_(0), + c_('\0'), + uninitialized_map_(uninitialized_map), + map_(map) +{ + // + // This is really just here to emphasize that c_ must not be EOF. + // + this->i_ = traits_type::not_eof(this->i_); + this->c_ = + traits_type::to_char_type( + traits_type::not_eof(traits_type::to_int_type(this->c_))); + + this->setg(&this->c_, &this->c_, &this->c_); +} + +openvrml_control::plugin_streambuf::state_id +openvrml_control::plugin_streambuf::state() const +{ + boost::mutex::scoped_lock lock(this->mutex_); + return this->state_; +} + +void openvrml_control::plugin_streambuf::set_get_url_result(const int result) +{ + boost::mutex::scoped_lock lock(this->mutex_); + assert(this->get_url_result_ == -1); + this->get_url_result_ = result; + + // + // If result is nonzero, the resource fetch failed early (i.e., before + // actually getting the stream. In that case, nothing else should be + // playing with this. Removing this streambuf from uninitialized_map_ + // below may (and probably will) result in destruction of this instance. + // + // So, anyone waiting on received_get_url_result_ should be doing so + // because the fetching code is trying to do something with this streambuf + // because the fetch is in-progress (i.e., succeeding). If you're waiting + // on this condition and result could possibly indicate failure, you're + // doing it wrong. + // + if (result == 0) { + this->state_ = plugin_streambuf::uninitialized; + this->received_get_url_result_.notify_all(); + } else { + this->uninitialized_map_.erase(*this); + } +} + +void openvrml_control::plugin_streambuf::init(const size_t stream_id, + const std::string & received_url, + const std::string & type) +{ + assert(stream_id); + assert(!received_url.empty()); + assert(!type.empty()); + + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::uninitialized) { + this->received_get_url_result_.wait(lock); + } + + assert(this->state_ == uninitialized); + + bool succeeded = this->uninitialized_map_.erase(*this); + assert(succeeded); + this->url_ = received_url; + this->type_ = type; + this->state_ = plugin_streambuf::initialized; + const boost::shared_ptr<plugin_streambuf> this_ = shared_from_this(); + succeeded = this->map_.insert(stream_id, this_); + assert(succeeded); + this->streambuf_initialized_or_failed_.notify_all(); +} + +void openvrml_control::plugin_streambuf::fail() +{ + boost::mutex::scoped_lock lock(this->mutex_); + const bool succeeded = this->uninitialized_map_.erase(*this); + assert(succeeded); + this->buf_.set_eof(); + this->streambuf_initialized_or_failed_.notify_all(); +} + +const std::string & openvrml_control::plugin_streambuf::url() const +{ + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::initialized) { + this->streambuf_initialized_or_failed_.wait(lock); + } + return this->url_; +} + +const std::string & openvrml_control::plugin_streambuf::type() const +{ + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::initialized) { + this->streambuf_initialized_or_failed_.wait(lock); + } + return this->type_; +} + +bool openvrml_control::plugin_streambuf::data_available() const +{ + // + // It may seem a bit counterintuitive to return true here if the stream + // has been destroyed; however, if we don't return true in this case, + // clients may never get EOF from the stream. + // + return this->buf_.buffered() > 0 || this->buf_.eof(); +} + +openvrml_control::plugin_streambuf::int_type +openvrml_control::plugin_streambuf::underflow() +{ + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::initialized) { + this->streambuf_initialized_or_failed_.wait(lock); + } + + if (traits_type::eq_int_type(this->i_, traits_type::eof())) { + return traits_type::eof(); + } + + this->i_ = this->buf_.get(); + this->c_ = traits_type::to_char_type(this->i_); + + if (traits_type::eq_int_type(this->i_, traits_type::eof())) { + return traits_type::eof(); + } + + this->setg(&this->c_, &this->c_, &this->c_ + 1); + return traits_type::to_int_type(*this->gptr()); +} + +const boost::shared_ptr<openvrml_control::plugin_streambuf> +openvrml_control::uninitialized_plugin_streambuf_map:: +find(const std::string & url) const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + map_t::const_iterator pos = this->map_.find(url); + return pos == this->map_.end() + ? boost::shared_ptr<plugin_streambuf>() + : pos->second; +} + +void +openvrml_control::uninitialized_plugin_streambuf_map:: +insert(const std::string & url, + const boost::shared_ptr<plugin_streambuf> & streambuf) +{ + openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); + this->map_.insert(make_pair(url, streambuf)); +} + +struct openvrml_control::uninitialized_plugin_streambuf_map::map_entry_matches_streambuf : + std::unary_function<bool, map_t::value_type> { + + explicit map_entry_matches_streambuf(const plugin_streambuf * streambuf): + streambuf_(streambuf) + {} + + bool operator()(const map_t::value_type & entry) const + { + return this->streambuf_ == entry.second.get(); + } + +private: + const plugin_streambuf * const streambuf_; +}; + +bool +openvrml_control::uninitialized_plugin_streambuf_map:: +erase(const plugin_streambuf & streambuf) +{ + openvrml::read_write_mutex::scoped_read_write_lock lock(this->mutex_); + const map_t::iterator pos = + std::find_if(this->map_.begin(), this->map_.end(), + map_entry_matches_streambuf(&streambuf)); + if (pos == this->map_.end()) { return false; } + lock.promote(); + this->map_.erase(pos); + return true; +} + +size_t openvrml_control::uninitialized_plugin_streambuf_map::size() const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + return this->map_.size(); +} + +bool openvrml_control::uninitialized_plugin_streambuf_map::empty() const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + return this->map_.empty(); +} + +const boost::shared_ptr<openvrml_control::plugin_streambuf> +openvrml_control::uninitialized_plugin_streambuf_map::front() const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + assert(!this->map_.empty()); + return this->map_.begin()->second; +} + + +const boost::shared_ptr<openvrml_control::plugin_streambuf> +openvrml_control::plugin_streambuf_map::find(const size_t id) const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + map_t::const_iterator pos = this->map_.find(id); + return pos == this->map_.end() + ? boost::shared_ptr<plugin_streambuf>() + : pos->second; +} + +bool +openvrml_control::plugin_streambuf_map:: +insert(const size_t id, + const boost::shared_ptr<plugin_streambuf> & streambuf) +{ + openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); + return this->map_.insert(make_pair(id, streambuf)).second; +} + +/** + * @brief Erase the entry corresponding to @p id. + * + * @return @c true if an entry was removed; @c false otherwise. + */ +bool openvrml_control::plugin_streambuf_map::erase(const size_t id) +{ + openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); + return this->map_.erase(id) > 0; +} Property changes on: trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + /branches/0.17/src/openvrml-xembed/plugin_streambuf.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836 /branches/local/src/openvrml-xembed/plugin_streambuf.cpp:3677-3689 /branches/node-modules/src/openvrml-xembed/plugin_streambuf.cpp:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801 Added: svn:eol-style + native Copied: trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h (from rev 3846, trunk/src/openvrml-xembed/plugin_streambuf.h) =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h (rev 0) +++ trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h 2009-03-19 05:27:10 UTC (rev 3848) @@ -0,0 +1,163 @@ +// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- +// +// OpenVRML Control +// +// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; if not, see <http://www.gnu.org/licenses/>. +// + +# ifndef OPENVRML_CONTROL_PLUGIN_STREAMBUF_H +# define OPENVRML_CONTROL_PLUGIN_STREAMBUF_H + +# include <map> +# include <streambuf> +# include <boost/noncopyable.hpp> +# include <boost/shared_ptr.hpp> +# include <boost/enable_shared_from_this.hpp> +# include <openvrml/read_write_mutex.h> +# include "bounded_buffer.h" + +namespace openvrml_control { + + // + // plugin_streambuf Life Cycle + // + // A plugin_streambuf is first created in GtkVrmlBrowser's + // resource_fetcher::do_get_resource implementation (which is + // called whenever libopenvrml needs to load a stream). + // + // Step 1: Requested plugin_streambuf + // + // Upon creation, the plugin_streambuf is inserted into the + // unintialized_plugin_streambuf_map with an initial + // plugin_streambuf::state of requested. do_get_resource does not + // complete until the result of asking the host application to resolve the + // URL is known; i.e., plugin_streambuf::get_url_result. get_url_result + // blocks until the response is received from the host application; i.e., + // until plugin_streambuf::set_get_url_result has been called. + // + // Step 2: Uninitialized plugin_streambuf + // + // If plugin_streambuf::set_get_url_result is given a result code + // indicating success (i.e., 0), the plugin_streambuf::state is changed to + // uninitialized (otherwise, the stream is removed from the + // uninitialized_plugin_streambuf_map and we're done). When + // openvrml_xembed_stream_client_new_stream is called on the + // GtkVrmlBrowser, a plugin_streambuf matching that URL is gotten from the + // uninitialized_plugin_streambuf_map and plugin_streambuf::init is called + // on it. init removes the plugin_streambuf from the + // uninitialized_plugin_streambuf_map_ and inserts it in the + // plugin_streambuf_map with a plugin_streambuf::state of initialized. + // + // Step 3: Initialized plugin_streambuf (plugin_streambuf_map) + // + // The plugin_streambuf_map comprises plugin_streambufs that are being + // written to in response to openvrml_xembed_stream_client_write calls and + // read from by stream readers in libopenvrml. Once the host is done + // calling openvrml_xembed_stream_client_write for a stream, it is + // expected that it will call + // openvrml_xembed_stream_client_destroy_stream. In response to this + // call, bounded_buffer<>::set_eof is called on the plugin_streambuf's + // underlying bounded_buffer<> and the plugin_streambuf is removed from + // the plugin_streambuf_map. + // + // Once the last reference to the resource_istream corresponding + // to the plugin_streambuf is removed, the plugin_streambuf is + // deleted. + // + + class browser; + + class uninitialized_plugin_streambuf_map; + class plugin_streambuf_map; + + class plugin_streambuf : + public boost::enable_shared_from_this<plugin_streambuf>, + public std::streambuf { + + friend class openvrml_control::browser; + + public: + enum state_id { + requested, + uninitialized, + initialized + }; + + private: + state_id state_; + mutable boost::mutex mutex_; + int get_url_result_; + mutable boost::condition received_get_url_result_; + mutable boost::condition streambuf_initialized_or_failed_; + std::string url_; + std::string type_; + bounded_buffer<char_type, 16384> buf_; + int_type i_; + char_type c_; + uninitialized_plugin_streambuf_map & uninitialized_map_; + plugin_streambuf_map & map_; + + protected: + virtual int_type underflow(); + + public: + plugin_streambuf(const std::string & requested_url, + uninitialized_plugin_streambuf_map & uninitialized_map, + plugin_streambuf_map & map); + state_id state() const; + void set_get_url_result(int result); + void init(size_t stream_id, + const std::string & received_url, + const std::string & type); + void fail(); + const std::string & url() const; + const std::string & type() const; + bool data_available() const; + }; + + class uninitialized_plugin_streambuf_map : boost::noncopyable { + struct map_entry_matches_streambuf; + + mutable openvrml::read_write_mutex mutex_; + typedef std::multimap<std::string, boost::shared_ptr<plugin_streambuf> > + map_t; + map_t map_; + + public: + const boost::shared_ptr<plugin_streambuf> + find(const std::string & url) const; + void insert(const std::string & url, + const boost::shared_ptr<plugin_streambuf> & streambuf); + bool erase(const plugin_streambuf & streambuf); + size_t size() const; + bool empty() const; + const boost::shared_ptr<plugin_streambuf> front() const; + }; + + class plugin_streambuf_map : boost::noncopyable { + mutable openvrml::read_write_mutex mutex_; + typedef std::map<size_t, boost::shared_ptr<plugin_streambuf> > map_t; + map_t map_; + + public: + const boost::shared_ptr<plugin_streambuf> find(size_t id) const; + bool insert(size_t id, + const boost::shared_ptr<plugin_streambuf> & streambuf); + bool erase(size_t id); + }; +} + +# endif // ifndef OPENVRML_CONTROL_PLUGIN_STREAMBUF_H Property changes on: trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Deleted: trunk/src/openvrml-xembed/bounded_buffer.h =================================================================== --- trunk/src/openvrml-xembed/bounded_buffer.h 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/src/openvrml-xembed/bounded_buffer.h 2009-03-19 05:27:10 UTC (rev 3848) @@ -1,116 +0,0 @@ -// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- -// -// OpenVRML XEmbed Control -// -// Copyright 2004, 2005, 2006, 2007 Braden McDaniel -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; if not, see <http://www.gnu.org/licenses/>. -// - -# ifndef OPENVRML_XEMBED_BOUNDED_BUFFER_H -# define OPENVRML_XEMBED_BOUNDED_BUFFER_H - -# include <cassert> -# include <string> -# include <boost/thread/mutex.hpp> -# include <boost/thread/condition.hpp> - -namespace openvrml_xembed { - - template <typename CharT, size_t BufferSize> - class bounded_buffer { - mutable boost::mutex mutex_; - boost::condition buffer_not_full_, buffer_not_empty_or_eof_; - - CharT buf_[BufferSize]; - size_t begin_, end_, buffered_; - bool eof_; - - public: - typedef CharT char_type; - typedef typename std::char_traits<char_type> traits_type; - typedef typename traits_type::int_type int_type; - - bounded_buffer(); - void put(const char_type & c); - int_type get(); - size_t buffered() const; - void set_eof(); - bool eof() const; - }; - - template <typename CharT, size_t BufferSize> - bounded_buffer<CharT, BufferSize>::bounded_buffer(): - begin_(0), - end_(0), - buffered_(0), - eof_(false) - {} - - template <typename CharT, size_t BufferSize> - void bounded_buffer<CharT, BufferSize>::put(const char_type & c) - { - boost::mutex::scoped_lock lock(this->mutex_); - while (this->buffered_ == BufferSize) { - this->buffer_not_full_.wait(lock); - } - this->buf_[this->end_] = c; - this->end_ = (this->end_ + 1) % BufferSize; - ++this->buffered_; - this->buffer_not_empty_or_eof_.notify_one(); - } - - template <typename CharT, size_t BufferSize> - typename bounded_buffer<CharT, BufferSize>::int_type - bounded_buffer<CharT, BufferSize>::get() - { - boost::mutex::scoped_lock lock(this->mutex_); - while (this->buffered_ == 0 && !this->eof_) { - this->buffer_not_empty_or_eof_.wait(lock); - } - if (this->buffered_ == 0 && this->eof_) { - return traits_type::eof(); - } - const int_type c = traits_type::to_int_type(this->buf_[this->begin_]); - this->begin_ = (this->begin_ + 1) % BufferSize; - --this->buffered_; - this->buffer_not_full_.notify_one(); - assert(!traits_type::eq_int_type(c, traits_type::eof())); - return c; - } - - template <typename CharT, size_t BufferSize> - size_t bounded_buffer<CharT, BufferSize>::buffered() const - { - boost::mutex::scoped_lock lock(this->mutex_); - return this->buffered_; - } - - template <typename CharT, size_t BufferSize> - void bounded_buffer<CharT, BufferSize>::set_eof() - { - boost::mutex::scoped_lock lock(this->mutex_); - this->eof_ = true; - this->buffer_not_empty_or_eof_.notify_one(); - } - - template <typename CharT, size_t BufferSize> - bool bounded_buffer<CharT, BufferSize>::eof() const - { - boost::mutex::scoped_lock lock(this->mutex_); - return this->eof_; - } -} - -# endif // ifndef OPENVRML_XEMBED_BOUNDED_BUFFER_H Deleted: trunk/src/openvrml-xembed/plugin_streambuf.cpp =================================================================== --- trunk/src/openvrml-xembed/plugin_streambuf.cpp 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/src/openvrml-xembed/plugin_streambuf.cpp 2009-03-19 05:27:10 UTC (rev 3848) @@ -1,265 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- -// -// OpenVRML XEmbed Control -// -// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; if not, see <http://www.gnu.org/licenses/>. -// - -# include <glib.h> -# include "plugin_streambuf.h" - -openvrml_xembed::plugin_streambuf:: -plugin_streambuf(const std::string & requested_url, - uninitialized_plugin_streambuf_map & uninitialized_map, - plugin_streambuf_map & map): - state_(requested), - get_url_result_(-1), - url_(requested_url), - i_(0), - c_('\0'), - uninitialized_map_(uninitialized_map), - map_(map) -{ - // - // This is really just here to emphasize that c_ must not be EOF. - // - this->i_ = traits_type::not_eof(this->i_); - this->c_ = - traits_type::to_char_type( - traits_type::not_eof(traits_type::to_int_type(this->c_))); - - this->setg(&this->c_, &this->c_, &this->c_); -} - -openvrml_xembed::plugin_streambuf::state_id -openvrml_xembed::plugin_streambuf::state() const -{ - boost::mutex::scoped_lock lock(this->mutex_); - return this->state_; -} - -void openvrml_xembed::plugin_streambuf::set_get_url_result(const int result) -{ - boost::mutex::scoped_lock lock(this->mutex_); - g_assert(this->get_url_result_ == -1); - this->get_url_result_ = result; - - // - // If result is nonzero, the resource fetch failed early (i.e., before - // actually getting the stream. In that case, nothing else should be - // playing with this. Removing this streambuf from uninitialized_map_ - // below may (and probably will) result in destruction of this instance. - // - // So, anyone waiting on received_get_url_result_ should be doing so - // because the fetching code is trying to do something with this streambuf - // because the fetch is in-progress (i.e., succeeding). If you're waiting - // on this condition and result could possibly indicate failure, you're - // doing it wrong. - // - if (result == 0) { - this->state_ = plugin_streambuf::uninitialized; - this->received_get_url_result_.notify_all(); - } else { - this->uninitialized_map_.erase(*this); - } -} - -void openvrml_xembed::plugin_streambuf::init(const size_t stream_id, - const std::string & received_url, - const std::string & type) -{ - g_assert(stream_id); - g_assert(!received_url.empty()); - g_assert(!type.empty()); - - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::uninitialized) { - this->received_get_url_result_.wait(lock); - } - - g_assert(this->state_ == uninitialized); - - bool succeeded = this->uninitialized_map_.erase(*this); - g_assert(succeeded); - this->url_ = received_url; - this->type_ = type; - this->state_ = plugin_streambuf::initialized; - const boost::shared_ptr<plugin_streambuf> this_ = shared_from_this(); - succeeded = this->map_.insert(stream_id, this_); - g_assert(succeeded); - this->streambuf_initialized_or_failed_.notify_all(); -} - -void openvrml_xembed::plugin_streambuf::fail() -{ - boost::mutex::scoped_lock lock(this->mutex_); - const bool succeeded = this->uninitialized_map_.erase(*this); - g_assert(succeeded); - this->buf_.set_eof(); - this->streambuf_initialized_or_failed_.notify_all(); -} - -const std::string & openvrml_xembed::plugin_streambuf::url() const -{ - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::initialized) { - this->streambuf_initialized_or_failed_.wait(lock); - } - return this->url_; -} - -const std::string & openvrml_xembed::plugin_streambuf::type() const -{ - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::initialized) { - this->streambuf_initialized_or_failed_.wait(lock); - } - return this->type_; -} - -bool openvrml_xembed::plugin_streambuf::data_available() const -{ - // - // It may seem a bit counterintuitive to return true here if the stream - // has been destroyed; however, if we don't return true in this case, - // clients may never get EOF from the stream. - // - return this->buf_.buffered() > 0 || this->buf_.eof(); -} - -openvrml_xembed::plugin_streambuf::int_type -openvrml_xembed::plugin_streambuf::underflow() -{ - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::initialized) { - this->streambuf_initialized_or_failed_.wait(lock); - } - - if (traits_type::eq_int_type(this->i_, traits_type::eof())) { - return traits_type::eof(); - } - - this->i_ = this->buf_.get(); - this->c_ = traits_type::to_char_type(this->i_); - - if (traits_type::eq_int_type(this->i_, traits_type::eof())) { - return traits_type::eof(); - } - - this->setg(&this->c_, &this->c_, &this->c_ + 1); - return traits_type::to_int_type(*this->gptr()); -} - -const boost::shared_ptr<openvrml_xembed::plugin_streambuf> -openvrml_xembed::uninitialized_plugin_streambuf_map:: -find(const std::string & url) const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - map_t::const_iterator pos = this->map_.find(url); - return pos == this->map_.end() - ? boost::shared_ptr<plugin_streambuf>() - : pos->second; -} - -void -openvrml_xembed::uninitialized_plugin_streambuf_map:: -insert(const std::string & url, - const boost::shared_ptr<plugin_streambuf> & streambuf) -{ - openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); - this->map_.insert(make_pair(url, streambuf)); -} - -struct openvrml_xembed::uninitialized_plugin_streambuf_map::map_entry_matches_streambuf : - std::unary_function<bool, map_t::value_type> { - - explicit map_entry_matches_streambuf(const plugin_streambuf * streambuf): - streambuf_(streambuf) - {} - - bool operator()(const map_t::value_type & entry) const - { - return this->streambuf_ == entry.second.get(); - } - -private: - const plugin_streambuf * const streambuf_; -}; - -bool -openvrml_xembed::uninitialized_plugin_streambuf_map:: -erase(const plugin_streambuf & streambuf) -{ - openvrml::read_write_mutex::scoped_read_write_lock lock(this->mutex_); - const map_t::iterator pos = - std::find_if(this->map_.begin(), this->map_.end(), - map_entry_matches_streambuf(&streambuf)); - if (pos == this->map_.end()) { return false; } - lock.promote(); - this->map_.erase(pos); - return true; -} - -size_t openvrml_xembed::uninitialized_plugin_streambuf_map::size() const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - return this->map_.size(); -} - -bool openvrml_xembed::uninitialized_plugin_streambuf_map::empty() const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - return this->map_.empty(); -} - -const boost::shared_ptr<openvrml_xembed::plugin_streambuf> -openvrml_xembed::uninitialized_plugin_streambuf_map::front() const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - g_assert(!this->map_.empty()); - return this->map_.begin()->second; -} - - -const boost::shared_ptr<openvrml_xembed::plugin_streambuf> -openvrml_xembed::plugin_streambuf_map::find(const size_t id) const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - map_t::const_iterator pos = this->map_.find(id); - return pos == this->map_.end() - ? boost::shared_ptr<plugin_streambuf>() - : pos->second; -} - -bool -openvrml_xembed::plugin_streambuf_map:: -insert(const size_t id, - const boost::shared_ptr<plugin_streambuf> & streambuf) -{ - openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); - return this->map_.insert(make_pair(id, streambuf)).second; -} - -/** - * @brief Erase the entry corresponding to @p id. - * - * @return @c true if an entry was removed; @c false otherwise. - */ -bool openvrml_xembed::plugin_streambuf_map::erase(const size_t id) -{ - openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); - return this->map_.erase(id) > 0; -} Deleted: trunk/src/openvrml-xembed/plugin_streambuf.h =================================================================== --- trunk/src/openvrml-xembed/plugin_streambuf.h 2009-03-19 04:53:28 UTC (rev 3847) +++ trunk/src/openvrml-xembed/plugin_streambuf.h 2009-03-19 05:27:10 UTC (rev 3848) @@ -1,165 +0,0 @@ -// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- -// -// OpenVRML XEmbed Control -// -// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; if not, see <http://www.gnu.org/licenses/>. -// - -# ifndef OPENVRML_XEMBED_PLUGIN_STREAMBUF_H -# define OPENVRML_XEMBED_PLUGIN_STREAMBUF_H - -# include <map> -# include <streambuf> -# include <boost/noncopyable.hpp> -# include <boost/shared_ptr.hpp> -# include <boost/enable_shared_from_this.hpp> -# include <openvrml/read_write_mutex.h> -# include "bounded_buffer.h" - -namespace openvrml_control { - class browser; -} - -namespace openvrml_xembed { - - // - // plugin_streambuf Life Cycle - // - // A plugin_streambuf is first created in GtkVrmlBrowser's - // resource_fetcher::do_get_resource implementation (which is - // called whenever libopenvrml needs to load a stream). - // - // Step 1: Requested plugin_streambuf - // - // Upon creation, the plugin_streambuf is inserted into the - // unintialized_plugin_streambuf_map with an initial - // plugin_streambuf::state of requested. do_get_resource does not - // complete until the result of asking the host application to resolve the - // URL is known; i.e., plugin_streambuf::get_url_result. get_url_result - // blocks until the response is received from the host application; i.e., - // until plugin_streambuf::set_get_url_result has been called. - // - // Step 2: Uninitialized plugin_streambuf - // - // If plugin_streambuf::set_get_url_result is given a result code - // indicating success (i.e., 0), the plugin_streambuf::state is changed to - // uninitialized (otherwise, the stream is removed from the - // uninitialized_plugin_streambuf_map and we're done). When - // openvrml_xembed_stream_client_new_stream is called on the - // GtkVrmlBrowser, a plugin_streambuf matching that URL is gotten from the - // uninitialized_plugin_streambuf_map and plugin_streambuf::init is called - // on it. init removes the plugin_streambuf from the - // uninitialized_plugin_streambuf_map_ and inserts it in the - // plugin_streambuf_map with a plugin_streambuf::state of initialized. - // - // Step 3: Initialized plugin_streambuf (plugin_streambuf_map) - // - // The plugin_streambuf_map comprises plugin_streambufs that are being - // written to in response to openvrml_xembed_stream_client_write calls and - // read from by stream readers in libopenvrml. Once the host is done - // calling openvrml_xembed_stream_client_write for a stream, it is - // expected that it will call - // openvrml_xembed_stream_client_destroy_stream. In response to this - // call, bounded_buffer<>::set_eof is called on the plugin_streambuf's - // underlying bounded_buffer<> and the plugin_streambuf is removed from - // the plugin_streambuf_map. - // - // Once the last reference to the resource_istream corresponding - // to the plugin_streambuf is removed, the plugin_streambuf is - // deleted. - // - - class uninitialized_plugin_streambuf_map; - class plugin_streambuf_map; - - class plugin_streambuf : - public boost::enable_shared_from_this<plugin_streambuf>, - public std::streambuf { - - friend class openvrml_control::browser; - - public: - enum state_id { - requested, - uninitialized, - initialized - }; - - private: - state_id state_; - mutable boost::mutex mutex_; - int get_url_result_; - mutable boost::condition received_get_url_result_; - mutable boost::condition streambuf_initialized_or_failed_; - std::string url_; - std::string type_; - bounded_buffer<char_type, 16384> buf_; - int_type i_; - char_type c_; - uninitialized_plugin_streambuf_map & uninitialized_map_; - plugin_streambuf_map & map_; - - protected: - virtual int_type underflow(); - - public: - plugin_streambuf(const std::string & requested_url, - uninitialized_plugin_streambuf_map & uninitialized_map, - plugin_streambuf_map & map); - state_id state() const; - void set_get_url_result(int result); - void init(size_t stream_id, - const std::string & received_url, - const std::string & type); - void fail(); - const std::string & url() const; - const std::string & type() const; - bool data_available() const; - }; - - class uninitialized_plugin_streambuf_map : boost::noncopyable { - struct map_entry_matches_streambuf; - - mutable openvrml::read_write_mutex mutex_; - typedef std::multimap<std::string, boost::shared_ptr<plugin_streambuf> > - map_t; - map_t map_; - - public: - const boost::shared_ptr<plugin_streambuf> - find(const std::string & url) const; - void insert(const std::string & url, - const boost::shared_ptr<plugin_streambuf> & streambuf); - bool erase(const plugin_streambuf & streambuf); - size_t size() const; - bool empty() const; - const boost::shared_ptr<plugin_streambuf> front() const; - }; - - class plugin_streambuf_map : boost::noncopyable { - mutable openvrml::read_write_mutex mutex_; - typedef std::map<size_t, boost::shared_ptr<plugin_streambuf> > map_t; - map_t map_; - - public: - const boost::shared_ptr<plugin_streambuf> find(size_t id) const; - bool insert(size_t id, - const boost::shared_ptr<plugin_streambuf> & streambuf); - bool erase(size_t id); - }; -} - -# endif // ifndef OPENVRML_XEMBED_PLUGIN_STREAMBUF_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 05:46:18
|
Revision: 3849 http://openvrml.svn.sourceforge.net/openvrml/?rev=3849&view=rev Author: braden Date: 2009-03-19 05:46:08 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Added missing return statement. Modified Paths: -------------- trunk/ChangeLog trunk/src/libopenvrml-control/openvrml_control/browser.cpp Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 05:27:10 UTC (rev 3848) +++ trunk/ChangeLog 2009-03-19 05:46:08 UTC (rev 3849) @@ -1,5 +1,11 @@ 2009-03-19 Braden McDaniel <br...@en...> + * src/libopenvrml-control/openvrml_control/browser.cpp + (openvrml_control::browser_host::get_url(const std::string &)): + Added missing return statement. + +2009-03-19 Braden McDaniel <br...@en...> + Moved bounded_buffer and plugin_streambuf to libopenvrml-control. * src/Makefile.am Modified: trunk/src/libopenvrml-control/openvrml_control/browser.cpp =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 05:27:10 UTC (rev 3848) +++ trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 05:46:08 UTC (rev 3849) @@ -356,5 +356,5 @@ int openvrml_control::browser_host::get_url(const std::string & url) { - this->do_get_url(url); + return this->do_get_url(url); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 06:30:23
|
Revision: 3850 http://openvrml.svn.sourceforge.net/openvrml/?rev=3850&view=rev Author: braden Date: 2009-03-19 06:30:11 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Moved plugin_streambuf, uninitialized_plugin_streambuf_map, and plugin_streambuf_map to be private member classes of openvrml_control::browser. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/libopenvrml-control/openvrml_control/browser.cpp trunk/src/libopenvrml-control/openvrml_control/browser.h Removed Paths: ------------- trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 05:46:08 UTC (rev 3849) +++ trunk/ChangeLog 2009-03-19 06:30:11 UTC (rev 3850) @@ -1,5 +1,28 @@ 2009-03-19 Braden McDaniel <br...@en...> + Moved plugin_streambuf, uninitialized_plugin_streambuf_map, and + plugin_streambuf_map to be private member classes of + openvrml_control::browser. + + * src/Makefile.am + (libopenvrml_control_libopenvrml_control_la_SOURCES): Removed + libopenvrml-control/openvrml_control/plugin_streambuf.{cpp,h}. + * src/libopenvrml-control/openvrml_control/browser.cpp: Added + definition of openvrml_control::browser::plugin_streambuf as well + as member definitions for it and + openvrml_control::browser::uninitialized_plugin_streambuf_map and + openvrml_control::browser::plugin_streambuf_map. + * src/libopenvrml-control/openvrml_control/browser.h + (openvrml_control::browser): Added declaration plugin_streambuf; + added definitions of uninitialized_plugin_streambuf_map and + plugin_streambuf_map. + * src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp: + Removed. + * src/libopenvrml-control/openvrml_control/plugin_streambuf.h: + Removed. + +2009-03-19 Braden McDaniel <br...@en...> + * src/libopenvrml-control/openvrml_control/browser.cpp (openvrml_control::browser_host::get_url(const std::string &)): Added missing return statement. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-19 05:46:08 UTC (rev 3849) +++ trunk/src/Makefile.am 2009-03-19 06:30:11 UTC (rev 3850) @@ -731,8 +731,6 @@ libopenvrml_control_libopenvrml_control_la_SOURCES = \ libopenvrml-control/openvrml_control/browser.cpp \ libopenvrml-control/openvrml_control/browser.h \ - libopenvrml-control/openvrml_control/plugin_streambuf.cpp \ - libopenvrml-control/openvrml_control/plugin_streambuf.h \ libopenvrml-control/openvrml_control/bounded_buffer.h libopenvrml_control_libopenvrml_control_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ Modified: trunk/src/libopenvrml-control/openvrml_control/browser.cpp =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 05:46:08 UTC (rev 3849) +++ trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 06:30:11 UTC (rev 3850) @@ -19,7 +19,8 @@ // # include "browser.h" -# include <openvrml/browser.h> +# include "bounded_buffer.h" +# include <boost/enable_shared_from_this.hpp> # include <boost/lexical_cast.hpp> # include <iostream> @@ -35,6 +36,344 @@ openvrml_control::unknown_stream::~unknown_stream() throw () {} +// +// plugin_streambuf Life Cycle +// +// A plugin_streambuf is first created in +// browser::resource_fetcher::do_get_resource (which is called whenever +// libopenvrml needs to load a stream). +// +// Step 1: Requested plugin_streambuf +// +// Upon creation, the plugin_streambuf is inserted into the +// unintialized_plugin_streambuf_map with an initial plugin_streambuf::state +// of requested. do_get_resource does not complete until the result of asking +// the host application to resolve the URL is known; i.e., +// plugin_streambuf::get_url_result. get_url_result blocks until the response +// is received from the host application; i.e., until +// plugin_streambuf::set_get_url_result has been called. +// +// Step 2: Uninitialized plugin_streambuf +// +// If plugin_streambuf::set_get_url_result is given a result code indicating +// success (i.e., 0), the plugin_streambuf::state is changed to uninitialized +// (otherwise, the stream is removed from the +// uninitialized_plugin_streambuf_map and we're done). When +// browser::new_stream is called, a plugin_streambuf matching that URL is +// gotten from the uninitialized_plugin_streambuf_map and +// plugin_streambuf::init is called on it. init removes the plugin_streambuf +// from the uninitialized_plugin_streambuf_map_ and inserts it in the +// plugin_streambuf_map with a plugin_streambuf::state of initialized. +// +// Step 3: Initialized plugin_streambuf (plugin_streambuf_map) +// +// The plugin_streambuf_map comprises plugin_streambufs that are being written +// to in response to browser::write calls and read from by stream readers in +// libopenvrml. Once the host is done calling browser::write for a stream, it +// is expected that it will call browser::destroy_stream. In response to this +// call, bounded_buffer<>::set_eof is called on the plugin_streambuf's +// underlying bounded_buffer<> and the plugin_streambuf is removed from the +// plugin_streambuf_map. +// +// Once the last reference to the resource_istream corresponding to the +// plugin_streambuf is removed, the plugin_streambuf is deleted. +// + +class OPENVRML_LOCAL openvrml_control::browser::plugin_streambuf : + public boost::enable_shared_from_this< + openvrml_control::browser::plugin_streambuf>, + public std::streambuf { + + friend class openvrml_control::browser; + +public: + enum state_id { + requested, + uninitialized, + initialized + }; + +private: + state_id state_; + mutable boost::mutex mutex_; + int get_url_result_; + mutable boost::condition received_get_url_result_; + mutable boost::condition streambuf_initialized_or_failed_; + std::string url_; + std::string type_; + bounded_buffer<char_type, 16384> buf_; + int_type i_; + char_type c_; + uninitialized_plugin_streambuf_map & uninitialized_map_; + plugin_streambuf_map & map_; + +protected: + virtual int_type underflow(); + +public: + plugin_streambuf(const std::string & requested_url, + uninitialized_plugin_streambuf_map & uninitialized_map, + plugin_streambuf_map & map); + state_id state() const; + void set_get_url_result(int result); + void init(size_t stream_id, + const std::string & received_url, + const std::string & type); + void fail(); + const std::string & url() const; + const std::string & type() const; + bool data_available() const; +}; + +openvrml_control::browser::plugin_streambuf:: +plugin_streambuf(const std::string & requested_url, + uninitialized_plugin_streambuf_map & uninitialized_map, + plugin_streambuf_map & map): + state_(requested), + get_url_result_(-1), + url_(requested_url), + i_(0), + c_('\0'), + uninitialized_map_(uninitialized_map), + map_(map) +{ + // + // This is really just here to emphasize that c_ must not be EOF. + // + this->i_ = traits_type::not_eof(this->i_); + this->c_ = + traits_type::to_char_type( + traits_type::not_eof(traits_type::to_int_type(this->c_))); + + this->setg(&this->c_, &this->c_, &this->c_); +} + +openvrml_control::browser::plugin_streambuf::state_id +openvrml_control::browser::plugin_streambuf::state() const +{ + boost::mutex::scoped_lock lock(this->mutex_); + return this->state_; +} + +void +openvrml_control::browser::plugin_streambuf:: +set_get_url_result(const int result) +{ + boost::mutex::scoped_lock lock(this->mutex_); + assert(this->get_url_result_ == -1); + this->get_url_result_ = result; + + // + // If result is nonzero, the resource fetch failed early (i.e., before + // actually getting the stream. In that case, nothing else should be + // playing with this. Removing this streambuf from uninitialized_map_ + // below may (and probably will) result in destruction of this instance. + // + // So, anyone waiting on received_get_url_result_ should be doing so + // because the fetching code is trying to do something with this streambuf + // because the fetch is in-progress (i.e., succeeding). If you're waiting + // on this condition and result could possibly indicate failure, you're + // doing it wrong. + // + if (result == 0) { + this->state_ = plugin_streambuf::uninitialized; + this->received_get_url_result_.notify_all(); + } else { + this->uninitialized_map_.erase(*this); + } +} + +void +openvrml_control::browser::plugin_streambuf:: +init(const size_t stream_id, + const std::string & received_url, + const std::string & type) +{ + assert(stream_id); + assert(!received_url.empty()); + assert(!type.empty()); + + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::uninitialized) { + this->received_get_url_result_.wait(lock); + } + + assert(this->state_ == uninitialized); + + bool succeeded = this->uninitialized_map_.erase(*this); + assert(succeeded); + this->url_ = received_url; + this->type_ = type; + this->state_ = plugin_streambuf::initialized; + const boost::shared_ptr<plugin_streambuf> this_ = shared_from_this(); + succeeded = this->map_.insert(stream_id, this_); + assert(succeeded); + this->streambuf_initialized_or_failed_.notify_all(); +} + +void openvrml_control::browser::plugin_streambuf::fail() +{ + boost::mutex::scoped_lock lock(this->mutex_); + const bool succeeded = this->uninitialized_map_.erase(*this); + assert(succeeded); + this->buf_.set_eof(); + this->streambuf_initialized_or_failed_.notify_all(); +} + +const std::string & openvrml_control::browser::plugin_streambuf::url() const +{ + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::initialized) { + this->streambuf_initialized_or_failed_.wait(lock); + } + return this->url_; +} + +const std::string & openvrml_control::browser::plugin_streambuf::type() const +{ + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::initialized) { + this->streambuf_initialized_or_failed_.wait(lock); + } + return this->type_; +} + +bool openvrml_control::browser::plugin_streambuf::data_available() const +{ + // + // It may seem a bit counterintuitive to return true here if the stream + // has been destroyed; however, if we don't return true in this case, + // clients may never get EOF from the stream. + // + return this->buf_.buffered() > 0 || this->buf_.eof(); +} + +openvrml_control::browser::plugin_streambuf::int_type +openvrml_control::browser::plugin_streambuf::underflow() +{ + boost::mutex::scoped_lock lock(this->mutex_); + while (this->state_ != plugin_streambuf::initialized) { + this->streambuf_initialized_or_failed_.wait(lock); + } + + if (traits_type::eq_int_type(this->i_, traits_type::eof())) { + return traits_type::eof(); + } + + this->i_ = this->buf_.get(); + this->c_ = traits_type::to_char_type(this->i_); + + if (traits_type::eq_int_type(this->i_, traits_type::eof())) { + return traits_type::eof(); + } + + this->setg(&this->c_, &this->c_, &this->c_ + 1); + return traits_type::to_int_type(*this->gptr()); +} + +const boost::shared_ptr<openvrml_control::browser::plugin_streambuf> +openvrml_control::browser::uninitialized_plugin_streambuf_map:: +find(const std::string & url) const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + map_t::const_iterator pos = this->map_.find(url); + return pos == this->map_.end() + ? boost::shared_ptr<plugin_streambuf>() + : pos->second; +} + +void +openvrml_control::browser::uninitialized_plugin_streambuf_map:: +insert(const std::string & url, + const boost::shared_ptr<plugin_streambuf> & streambuf) +{ + openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); + this->map_.insert(make_pair(url, streambuf)); +} + +struct openvrml_control::browser::uninitialized_plugin_streambuf_map::map_entry_matches_streambuf : + std::unary_function<bool, map_t::value_type> { + + explicit map_entry_matches_streambuf(const plugin_streambuf * streambuf): + streambuf_(streambuf) + {} + + bool operator()(const map_t::value_type & entry) const + { + return this->streambuf_ == entry.second.get(); + } + +private: + const plugin_streambuf * const streambuf_; +}; + +bool +openvrml_control::browser::uninitialized_plugin_streambuf_map:: +erase(const plugin_streambuf & streambuf) +{ + openvrml::read_write_mutex::scoped_read_write_lock lock(this->mutex_); + const map_t::iterator pos = + std::find_if(this->map_.begin(), this->map_.end(), + map_entry_matches_streambuf(&streambuf)); + if (pos == this->map_.end()) { return false; } + lock.promote(); + this->map_.erase(pos); + return true; +} + +size_t +openvrml_control::browser::uninitialized_plugin_streambuf_map::size() const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + return this->map_.size(); +} + +bool +openvrml_control::browser::uninitialized_plugin_streambuf_map::empty() const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + return this->map_.empty(); +} + +const boost::shared_ptr<openvrml_control::browser::plugin_streambuf> +openvrml_control::browser::uninitialized_plugin_streambuf_map::front() const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + assert(!this->map_.empty()); + return this->map_.begin()->second; +} + + +const boost::shared_ptr<openvrml_control::browser::plugin_streambuf> +openvrml_control::browser::plugin_streambuf_map::find(const size_t id) const +{ + openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); + map_t::const_iterator pos = this->map_.find(id); + return pos == this->map_.end() + ? boost::shared_ptr<plugin_streambuf>() + : pos->second; +} + +bool +openvrml_control::browser::plugin_streambuf_map:: +insert(const size_t id, + const boost::shared_ptr<plugin_streambuf> & streambuf) +{ + openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); + return this->map_.insert(make_pair(id, streambuf)).second; +} + +/** + * @brief Erase the entry corresponding to @p id. + * + * @return @c true if an entry was removed; @c false otherwise. + */ +bool openvrml_control::browser::plugin_streambuf_map::erase(const size_t id) +{ + openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); + return this->map_.erase(id) > 0; +} + openvrml_control::browser::resource_fetcher:: resource_fetcher(browser_host & control_host, uninitialized_plugin_streambuf_map & @@ -141,59 +480,57 @@ // const char initial_stream_uri[] = "x-openvrml-initial:"; - struct OPENVRML_LOCAL initial_stream_reader { - initial_stream_reader( - const boost::shared_ptr<openvrml_control::plugin_streambuf> & - streambuf, - openvrml::browser & browser): - streambuf_(streambuf), - browser_(browser) +} + +struct OPENVRML_LOCAL openvrml_control::browser::initial_stream_reader { + initial_stream_reader( + const boost::shared_ptr<plugin_streambuf> & streambuf, + openvrml::browser & browser): + streambuf_(streambuf), + browser_(browser) {} - void operator()() const throw () - { - using openvrml_control::plugin_streambuf; + void operator()() const throw () + { + class plugin_istream : public openvrml::resource_istream { + boost::shared_ptr<plugin_streambuf> streambuf_; - class plugin_istream : public openvrml::resource_istream { - boost::shared_ptr<plugin_streambuf> streambuf_; + public: + explicit plugin_istream( + const boost::shared_ptr<plugin_streambuf> & streambuf): + openvrml::resource_istream(streambuf.get()), + streambuf_(streambuf) + {} - public: - explicit plugin_istream( - const boost::shared_ptr<plugin_streambuf> & streambuf): - openvrml::resource_istream(streambuf.get()), - streambuf_(streambuf) - {} + virtual ~plugin_istream() throw () + {} - virtual ~plugin_istream() throw () - {} + private: + virtual const std::string do_url() const throw (std::bad_alloc) + { + return this->streambuf_->url(); + } - private: - virtual const std::string do_url() const throw (std::bad_alloc) - { - return this->streambuf_->url(); - } + virtual const std::string do_type() const + throw (std::bad_alloc) + { + return this->streambuf_->type(); + } - virtual const std::string do_type() const - throw (std::bad_alloc) - { - return this->streambuf_->type(); - } + virtual bool do_data_available() const throw () + { + return this->streambuf_->data_available(); + } + } in(this->streambuf_); - virtual bool do_data_available() const throw () - { - return this->streambuf_->data_available(); - } - } in(this->streambuf_); + this->browser_.set_world(in); + } - this->browser_.set_world(in); - } +private: + boost::shared_ptr<plugin_streambuf> streambuf_; + openvrml::browser & browser_; +}; - private: - boost::shared_ptr<openvrml_control::plugin_streambuf> streambuf_; - openvrml::browser & browser_; - }; -} - openvrml_control::browser::browser(browser_host & host, const bool expect_initial_stream): fetcher_(host, Modified: trunk/src/libopenvrml-control/openvrml_control/browser.h =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.h 2009-03-19 05:46:08 UTC (rev 3849) +++ trunk/src/libopenvrml-control/openvrml_control/browser.h 2009-03-19 06:30:11 UTC (rev 3850) @@ -21,7 +21,6 @@ # ifndef OPENVRML_CONTROL_BROWSER_H # define OPENVRML_CONTROL_BROWSER_H -# include "plugin_streambuf.h" # include <openvrml/browser.h> namespace openvrml_control { @@ -36,8 +35,43 @@ class browser_host; class browser { + class plugin_streambuf; + struct initial_stream_reader; struct load_url; + class uninitialized_plugin_streambuf_map : boost::noncopyable { + struct map_entry_matches_streambuf; + + mutable openvrml::read_write_mutex mutex_; + typedef std::multimap<std::string, + boost::shared_ptr<plugin_streambuf> > + map_t; + map_t map_; + + public: + const boost::shared_ptr<plugin_streambuf> + find(const std::string & url) const; + void insert(const std::string & url, + const boost::shared_ptr<plugin_streambuf> & streambuf); + bool erase(const plugin_streambuf & streambuf); + size_t size() const; + bool empty() const; + const boost::shared_ptr<plugin_streambuf> front() const; + }; + + class plugin_streambuf_map : boost::noncopyable { + mutable openvrml::read_write_mutex mutex_; + typedef std::map<size_t, boost::shared_ptr<plugin_streambuf> > + map_t; + map_t map_; + + public: + const boost::shared_ptr<plugin_streambuf> find(size_t id) const; + bool insert(size_t id, + const boost::shared_ptr<plugin_streambuf> & streambuf); + bool erase(size_t id); + }; + class resource_fetcher : public openvrml::resource_fetcher { browser_host & control_host_; uninitialized_plugin_streambuf_map & Deleted: trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp 2009-03-19 05:46:08 UTC (rev 3849) +++ trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.cpp 2009-03-19 06:30:11 UTC (rev 3850) @@ -1,264 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- -// -// OpenVRML Control -// -// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; if not, see <http://www.gnu.org/licenses/>. -// - -# include "plugin_streambuf.h" - -openvrml_control::plugin_streambuf:: -plugin_streambuf(const std::string & requested_url, - uninitialized_plugin_streambuf_map & uninitialized_map, - plugin_streambuf_map & map): - state_(requested), - get_url_result_(-1), - url_(requested_url), - i_(0), - c_('\0'), - uninitialized_map_(uninitialized_map), - map_(map) -{ - // - // This is really just here to emphasize that c_ must not be EOF. - // - this->i_ = traits_type::not_eof(this->i_); - this->c_ = - traits_type::to_char_type( - traits_type::not_eof(traits_type::to_int_type(this->c_))); - - this->setg(&this->c_, &this->c_, &this->c_); -} - -openvrml_control::plugin_streambuf::state_id -openvrml_control::plugin_streambuf::state() const -{ - boost::mutex::scoped_lock lock(this->mutex_); - return this->state_; -} - -void openvrml_control::plugin_streambuf::set_get_url_result(const int result) -{ - boost::mutex::scoped_lock lock(this->mutex_); - assert(this->get_url_result_ == -1); - this->get_url_result_ = result; - - // - // If result is nonzero, the resource fetch failed early (i.e., before - // actually getting the stream. In that case, nothing else should be - // playing with this. Removing this streambuf from uninitialized_map_ - // below may (and probably will) result in destruction of this instance. - // - // So, anyone waiting on received_get_url_result_ should be doing so - // because the fetching code is trying to do something with this streambuf - // because the fetch is in-progress (i.e., succeeding). If you're waiting - // on this condition and result could possibly indicate failure, you're - // doing it wrong. - // - if (result == 0) { - this->state_ = plugin_streambuf::uninitialized; - this->received_get_url_result_.notify_all(); - } else { - this->uninitialized_map_.erase(*this); - } -} - -void openvrml_control::plugin_streambuf::init(const size_t stream_id, - const std::string & received_url, - const std::string & type) -{ - assert(stream_id); - assert(!received_url.empty()); - assert(!type.empty()); - - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::uninitialized) { - this->received_get_url_result_.wait(lock); - } - - assert(this->state_ == uninitialized); - - bool succeeded = this->uninitialized_map_.erase(*this); - assert(succeeded); - this->url_ = received_url; - this->type_ = type; - this->state_ = plugin_streambuf::initialized; - const boost::shared_ptr<plugin_streambuf> this_ = shared_from_this(); - succeeded = this->map_.insert(stream_id, this_); - assert(succeeded); - this->streambuf_initialized_or_failed_.notify_all(); -} - -void openvrml_control::plugin_streambuf::fail() -{ - boost::mutex::scoped_lock lock(this->mutex_); - const bool succeeded = this->uninitialized_map_.erase(*this); - assert(succeeded); - this->buf_.set_eof(); - this->streambuf_initialized_or_failed_.notify_all(); -} - -const std::string & openvrml_control::plugin_streambuf::url() const -{ - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::initialized) { - this->streambuf_initialized_or_failed_.wait(lock); - } - return this->url_; -} - -const std::string & openvrml_control::plugin_streambuf::type() const -{ - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::initialized) { - this->streambuf_initialized_or_failed_.wait(lock); - } - return this->type_; -} - -bool openvrml_control::plugin_streambuf::data_available() const -{ - // - // It may seem a bit counterintuitive to return true here if the stream - // has been destroyed; however, if we don't return true in this case, - // clients may never get EOF from the stream. - // - return this->buf_.buffered() > 0 || this->buf_.eof(); -} - -openvrml_control::plugin_streambuf::int_type -openvrml_control::plugin_streambuf::underflow() -{ - boost::mutex::scoped_lock lock(this->mutex_); - while (this->state_ != plugin_streambuf::initialized) { - this->streambuf_initialized_or_failed_.wait(lock); - } - - if (traits_type::eq_int_type(this->i_, traits_type::eof())) { - return traits_type::eof(); - } - - this->i_ = this->buf_.get(); - this->c_ = traits_type::to_char_type(this->i_); - - if (traits_type::eq_int_type(this->i_, traits_type::eof())) { - return traits_type::eof(); - } - - this->setg(&this->c_, &this->c_, &this->c_ + 1); - return traits_type::to_int_type(*this->gptr()); -} - -const boost::shared_ptr<openvrml_control::plugin_streambuf> -openvrml_control::uninitialized_plugin_streambuf_map:: -find(const std::string & url) const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - map_t::const_iterator pos = this->map_.find(url); - return pos == this->map_.end() - ? boost::shared_ptr<plugin_streambuf>() - : pos->second; -} - -void -openvrml_control::uninitialized_plugin_streambuf_map:: -insert(const std::string & url, - const boost::shared_ptr<plugin_streambuf> & streambuf) -{ - openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); - this->map_.insert(make_pair(url, streambuf)); -} - -struct openvrml_control::uninitialized_plugin_streambuf_map::map_entry_matches_streambuf : - std::unary_function<bool, map_t::value_type> { - - explicit map_entry_matches_streambuf(const plugin_streambuf * streambuf): - streambuf_(streambuf) - {} - - bool operator()(const map_t::value_type & entry) const - { - return this->streambuf_ == entry.second.get(); - } - -private: - const plugin_streambuf * const streambuf_; -}; - -bool -openvrml_control::uninitialized_plugin_streambuf_map:: -erase(const plugin_streambuf & streambuf) -{ - openvrml::read_write_mutex::scoped_read_write_lock lock(this->mutex_); - const map_t::iterator pos = - std::find_if(this->map_.begin(), this->map_.end(), - map_entry_matches_streambuf(&streambuf)); - if (pos == this->map_.end()) { return false; } - lock.promote(); - this->map_.erase(pos); - return true; -} - -size_t openvrml_control::uninitialized_plugin_streambuf_map::size() const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - return this->map_.size(); -} - -bool openvrml_control::uninitialized_plugin_streambuf_map::empty() const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - return this->map_.empty(); -} - -const boost::shared_ptr<openvrml_control::plugin_streambuf> -openvrml_control::uninitialized_plugin_streambuf_map::front() const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - assert(!this->map_.empty()); - return this->map_.begin()->second; -} - - -const boost::shared_ptr<openvrml_control::plugin_streambuf> -openvrml_control::plugin_streambuf_map::find(const size_t id) const -{ - openvrml::read_write_mutex::scoped_read_lock lock(this->mutex_); - map_t::const_iterator pos = this->map_.find(id); - return pos == this->map_.end() - ? boost::shared_ptr<plugin_streambuf>() - : pos->second; -} - -bool -openvrml_control::plugin_streambuf_map:: -insert(const size_t id, - const boost::shared_ptr<plugin_streambuf> & streambuf) -{ - openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); - return this->map_.insert(make_pair(id, streambuf)).second; -} - -/** - * @brief Erase the entry corresponding to @p id. - * - * @return @c true if an entry was removed; @c false otherwise. - */ -bool openvrml_control::plugin_streambuf_map::erase(const size_t id) -{ - openvrml::read_write_mutex::scoped_write_lock lock(this->mutex_); - return this->map_.erase(id) > 0; -} Deleted: trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h 2009-03-19 05:46:08 UTC (rev 3849) +++ trunk/src/libopenvrml-control/openvrml_control/plugin_streambuf.h 2009-03-19 06:30:11 UTC (rev 3850) @@ -1,163 +0,0 @@ -// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- -// -// OpenVRML Control -// -// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; if not, see <http://www.gnu.org/licenses/>. -// - -# ifndef OPENVRML_CONTROL_PLUGIN_STREAMBUF_H -# define OPENVRML_CONTROL_PLUGIN_STREAMBUF_H - -# include <map> -# include <streambuf> -# include <boost/noncopyable.hpp> -# include <boost/shared_ptr.hpp> -# include <boost/enable_shared_from_this.hpp> -# include <openvrml/read_write_mutex.h> -# include "bounded_buffer.h" - -namespace openvrml_control { - - // - // plugin_streambuf Life Cycle - // - // A plugin_streambuf is first created in GtkVrmlBrowser's - // resource_fetcher::do_get_resource implementation (which is - // called whenever libopenvrml needs to load a stream). - // - // Step 1: Requested plugin_streambuf - // - // Upon creation, the plugin_streambuf is inserted into the - // unintialized_plugin_streambuf_map with an initial - // plugin_streambuf::state of requested. do_get_resource does not - // complete until the result of asking the host application to resolve the - // URL is known; i.e., plugin_streambuf::get_url_result. get_url_result - // blocks until the response is received from the host application; i.e., - // until plugin_streambuf::set_get_url_result has been called. - // - // Step 2: Uninitialized plugin_streambuf - // - // If plugin_streambuf::set_get_url_result is given a result code - // indicating success (i.e., 0), the plugin_streambuf::state is changed to - // uninitialized (otherwise, the stream is removed from the - // uninitialized_plugin_streambuf_map and we're done). When - // openvrml_xembed_stream_client_new_stream is called on the - // GtkVrmlBrowser, a plugin_streambuf matching that URL is gotten from the - // uninitialized_plugin_streambuf_map and plugin_streambuf::init is called - // on it. init removes the plugin_streambuf from the - // uninitialized_plugin_streambuf_map_ and inserts it in the - // plugin_streambuf_map with a plugin_streambuf::state of initialized. - // - // Step 3: Initialized plugin_streambuf (plugin_streambuf_map) - // - // The plugin_streambuf_map comprises plugin_streambufs that are being - // written to in response to openvrml_xembed_stream_client_write calls and - // read from by stream readers in libopenvrml. Once the host is done - // calling openvrml_xembed_stream_client_write for a stream, it is - // expected that it will call - // openvrml_xembed_stream_client_destroy_stream. In response to this - // call, bounded_buffer<>::set_eof is called on the plugin_streambuf's - // underlying bounded_buffer<> and the plugin_streambuf is removed from - // the plugin_streambuf_map. - // - // Once the last reference to the resource_istream corresponding - // to the plugin_streambuf is removed, the plugin_streambuf is - // deleted. - // - - class browser; - - class uninitialized_plugin_streambuf_map; - class plugin_streambuf_map; - - class plugin_streambuf : - public boost::enable_shared_from_this<plugin_streambuf>, - public std::streambuf { - - friend class openvrml_control::browser; - - public: - enum state_id { - requested, - uninitialized, - initialized - }; - - private: - state_id state_; - mutable boost::mutex mutex_; - int get_url_result_; - mutable boost::condition received_get_url_result_; - mutable boost::condition streambuf_initialized_or_failed_; - std::string url_; - std::string type_; - bounded_buffer<char_type, 16384> buf_; - int_type i_; - char_type c_; - uninitialized_plugin_streambuf_map & uninitialized_map_; - plugin_streambuf_map & map_; - - protected: - virtual int_type underflow(); - - public: - plugin_streambuf(const std::string & requested_url, - uninitialized_plugin_streambuf_map & uninitialized_map, - plugin_streambuf_map & map); - state_id state() const; - void set_get_url_result(int result); - void init(size_t stream_id, - const std::string & received_url, - const std::string & type); - void fail(); - const std::string & url() const; - const std::string & type() const; - bool data_available() const; - }; - - class uninitialized_plugin_streambuf_map : boost::noncopyable { - struct map_entry_matches_streambuf; - - mutable openvrml::read_write_mutex mutex_; - typedef std::multimap<std::string, boost::shared_ptr<plugin_streambuf> > - map_t; - map_t map_; - - public: - const boost::shared_ptr<plugin_streambuf> - find(const std::string & url) const; - void insert(const std::string & url, - const boost::shared_ptr<plugin_streambuf> & streambuf); - bool erase(const plugin_streambuf & streambuf); - size_t size() const; - bool empty() const; - const boost::shared_ptr<plugin_streambuf> front() const; - }; - - class plugin_streambuf_map : boost::noncopyable { - mutable openvrml::read_write_mutex mutex_; - typedef std::map<size_t, boost::shared_ptr<plugin_streambuf> > map_t; - map_t map_; - - public: - const boost::shared_ptr<plugin_streambuf> find(size_t id) const; - bool insert(size_t id, - const boost::shared_ptr<plugin_streambuf> & streambuf); - bool erase(size_t id); - }; -} - -# endif // ifndef OPENVRML_CONTROL_PLUGIN_STREAMBUF_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-19 06:38:55
|
Revision: 3851 http://openvrml.svn.sourceforge.net/openvrml/?rev=3851&view=rev Author: braden Date: 2009-03-19 06:38:39 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Moved bounded_buffer to the implementation of openvrml_control::browser. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/libopenvrml-control/openvrml_control/browser.cpp Removed Paths: ------------- trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-19 06:30:11 UTC (rev 3850) +++ trunk/ChangeLog 2009-03-19 06:38:39 UTC (rev 3851) @@ -1,5 +1,21 @@ 2009-03-19 Braden McDaniel <br...@en...> + Moved bounded_buffer to the implementation of + openvrml_control::browser. + + * src/Makefile.am + (libopenvrml_control_libopenvrml_control_la_SOURCES): Removed + reference to + libopenvrml-control/openvrml_control/bounded_buffer.h. + * src/libopenvrml-control/openvrml_control/bounded_buffer.h: + Removed. + * src/libopenvrml-control/openvrml_control/browser.cpp: Moved + bounded_buffer from + src/libopenvrml-control/openvrml_control/bounded_buffer.h to an + unnamed namespace here. + +2009-03-19 Braden McDaniel <br...@en...> + Moved plugin_streambuf, uninitialized_plugin_streambuf_map, and plugin_streambuf_map to be private member classes of openvrml_control::browser. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-19 06:30:11 UTC (rev 3850) +++ trunk/src/Makefile.am 2009-03-19 06:38:39 UTC (rev 3851) @@ -730,8 +730,7 @@ endif libopenvrml_control_libopenvrml_control_la_SOURCES = \ libopenvrml-control/openvrml_control/browser.cpp \ - libopenvrml-control/openvrml_control/browser.h \ - libopenvrml-control/openvrml_control/bounded_buffer.h + libopenvrml-control/openvrml_control/browser.h libopenvrml_control_libopenvrml_control_la_CPPFLAGS = \ -I$(top_builddir)/src/libopenvrml \ -I$(top_srcdir)/src/libopenvrml Deleted: trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h 2009-03-19 06:30:11 UTC (rev 3850) +++ trunk/src/libopenvrml-control/openvrml_control/bounded_buffer.h 2009-03-19 06:38:39 UTC (rev 3851) @@ -1,116 +0,0 @@ -// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- -// -// OpenVRML Control -// -// Copyright 2004, 2005, 2006, 2007 Braden McDaniel -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; if not, see <http://www.gnu.org/licenses/>. -// - -# ifndef OPENVRML_CONTROL_BOUNDED_BUFFER_H -# define OPENVRML_CONTROL_BOUNDED_BUFFER_H - -# include <cassert> -# include <string> -# include <boost/thread/mutex.hpp> -# include <boost/thread/condition.hpp> - -namespace openvrml_control { - - template <typename CharT, size_t BufferSize> - class bounded_buffer { - mutable boost::mutex mutex_; - boost::condition buffer_not_full_, buffer_not_empty_or_eof_; - - CharT buf_[BufferSize]; - size_t begin_, end_, buffered_; - bool eof_; - - public: - typedef CharT char_type; - typedef typename std::char_traits<char_type> traits_type; - typedef typename traits_type::int_type int_type; - - bounded_buffer(); - void put(const char_type & c); - int_type get(); - size_t buffered() const; - void set_eof(); - bool eof() const; - }; - - template <typename CharT, size_t BufferSize> - bounded_buffer<CharT, BufferSize>::bounded_buffer(): - begin_(0), - end_(0), - buffered_(0), - eof_(false) - {} - - template <typename CharT, size_t BufferSize> - void bounded_buffer<CharT, BufferSize>::put(const char_type & c) - { - boost::mutex::scoped_lock lock(this->mutex_); - while (this->buffered_ == BufferSize) { - this->buffer_not_full_.wait(lock); - } - this->buf_[this->end_] = c; - this->end_ = (this->end_ + 1) % BufferSize; - ++this->buffered_; - this->buffer_not_empty_or_eof_.notify_one(); - } - - template <typename CharT, size_t BufferSize> - typename bounded_buffer<CharT, BufferSize>::int_type - bounded_buffer<CharT, BufferSize>::get() - { - boost::mutex::scoped_lock lock(this->mutex_); - while (this->buffered_ == 0 && !this->eof_) { - this->buffer_not_empty_or_eof_.wait(lock); - } - if (this->buffered_ == 0 && this->eof_) { - return traits_type::eof(); - } - const int_type c = traits_type::to_int_type(this->buf_[this->begin_]); - this->begin_ = (this->begin_ + 1) % BufferSize; - --this->buffered_; - this->buffer_not_full_.notify_one(); - assert(!traits_type::eq_int_type(c, traits_type::eof())); - return c; - } - - template <typename CharT, size_t BufferSize> - size_t bounded_buffer<CharT, BufferSize>::buffered() const - { - boost::mutex::scoped_lock lock(this->mutex_); - return this->buffered_; - } - - template <typename CharT, size_t BufferSize> - void bounded_buffer<CharT, BufferSize>::set_eof() - { - boost::mutex::scoped_lock lock(this->mutex_); - this->eof_ = true; - this->buffer_not_empty_or_eof_.notify_one(); - } - - template <typename CharT, size_t BufferSize> - bool bounded_buffer<CharT, BufferSize>::eof() const - { - boost::mutex::scoped_lock lock(this->mutex_); - return this->eof_; - } -} - -# endif // ifndef OPENVRML_CONTROL_BOUNDED_BUFFER_H Modified: trunk/src/libopenvrml-control/openvrml_control/browser.cpp =================================================================== --- trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 06:30:11 UTC (rev 3850) +++ trunk/src/libopenvrml-control/openvrml_control/browser.cpp 2009-03-19 06:38:39 UTC (rev 3851) @@ -19,7 +19,6 @@ // # include "browser.h" -# include "bounded_buffer.h" # include <boost/enable_shared_from_this.hpp> # include <boost/lexical_cast.hpp> # include <iostream> @@ -79,6 +78,93 @@ // plugin_streambuf is removed, the plugin_streambuf is deleted. // +namespace { + + template <typename CharT, size_t BufferSize> + class bounded_buffer { + mutable boost::mutex mutex_; + boost::condition buffer_not_full_, buffer_not_empty_or_eof_; + + CharT buf_[BufferSize]; + size_t begin_, end_, buffered_; + bool eof_; + + public: + typedef CharT char_type; + typedef typename std::char_traits<char_type> traits_type; + typedef typename traits_type::int_type int_type; + + bounded_buffer(); + void put(const char_type & c); + int_type get(); + size_t buffered() const; + void set_eof(); + bool eof() const; + }; + + template <typename CharT, size_t BufferSize> + bounded_buffer<CharT, BufferSize>::bounded_buffer(): + begin_(0), + end_(0), + buffered_(0), + eof_(false) + {} + + template <typename CharT, size_t BufferSize> + void bounded_buffer<CharT, BufferSize>::put(const char_type & c) + { + boost::mutex::scoped_lock lock(this->mutex_); + while (this->buffered_ == BufferSize) { + this->buffer_not_full_.wait(lock); + } + this->buf_[this->end_] = c; + this->end_ = (this->end_ + 1) % BufferSize; + ++this->buffered_; + this->buffer_not_empty_or_eof_.notify_one(); + } + + template <typename CharT, size_t BufferSize> + typename bounded_buffer<CharT, BufferSize>::int_type + bounded_buffer<CharT, BufferSize>::get() + { + boost::mutex::scoped_lock lock(this->mutex_); + while (this->buffered_ == 0 && !this->eof_) { + this->buffer_not_empty_or_eof_.wait(lock); + } + if (this->buffered_ == 0 && this->eof_) { + return traits_type::eof(); + } + const int_type c = traits_type::to_int_type(this->buf_[this->begin_]); + this->begin_ = (this->begin_ + 1) % BufferSize; + --this->buffered_; + this->buffer_not_full_.notify_one(); + assert(!traits_type::eq_int_type(c, traits_type::eof())); + return c; + } + + template <typename CharT, size_t BufferSize> + size_t bounded_buffer<CharT, BufferSize>::buffered() const + { + boost::mutex::scoped_lock lock(this->mutex_); + return this->buffered_; + } + + template <typename CharT, size_t BufferSize> + void bounded_buffer<CharT, BufferSize>::set_eof() + { + boost::mutex::scoped_lock lock(this->mutex_); + this->eof_ = true; + this->buffer_not_empty_or_eof_.notify_one(); + } + + template <typename CharT, size_t BufferSize> + bool bounded_buffer<CharT, BufferSize>::eof() const + { + boost::mutex::scoped_lock lock(this->mutex_); + return this->eof_; + } +} + class OPENVRML_LOCAL openvrml_control::browser::plugin_streambuf : public boost::enable_shared_from_this< openvrml_control::browser::plugin_streambuf>, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-20 08:29:28
|
Revision: 3857 http://openvrml.svn.sourceforge.net/openvrml/?rev=3857&view=rev Author: braden Date: 2009-03-20 08:29:17 +0000 (Fri, 20 Mar 2009) Log Message: ----------- libopenvrml no longer links with libjpeg and libpng. Modified Paths: -------------- trunk/ChangeLog trunk/openvrml.pc.in Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-20 07:57:23 UTC (rev 3856) +++ trunk/ChangeLog 2009-03-20 08:29:17 UTC (rev 3857) @@ -1,5 +1,10 @@ 2009-03-19 Braden McDaniel <br...@en...> + * openvrml.pc.in: libopenvrml no longer links with libjpeg and + libpng. + +2009-03-19 Braden McDaniel <br...@en...> + Moved bounded_buffer to the implementation of openvrml_control::browser. Modified: trunk/openvrml.pc.in =================================================================== --- trunk/openvrml.pc.in 2009-03-20 07:57:23 UTC (rev 3856) +++ trunk/openvrml.pc.in 2009-03-20 08:29:17 UTC (rev 3857) @@ -7,5 +7,5 @@ Description: VRML/X3D run-time library. Version: @PACKAGE_VERSION@ Requires: @OPENVRML_PKG_REQUIRES@ -Libs: -L${libdir} -lopenvrml @JPEG_LIBS@ @PNG_LIBS@ -lboost_thread@BOOST_LIB_SUFFIX@ +Libs: -L${libdir} -lopenvrml -lboost_thread@BOOST_LIB_SUFFIX@ Cflags: -I${includedir} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-20 08:33:27
|
Revision: 3858 http://openvrml.svn.sourceforge.net/openvrml/?rev=3858&view=rev Author: braden Date: 2009-03-20 08:33:25 +0000 (Fri, 20 Mar 2009) Log Message: ----------- Link with libboost_filesystem and libltdl. Modified Paths: -------------- trunk/ChangeLog trunk/openvrml.pc.in Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-20 08:29:17 UTC (rev 3857) +++ trunk/ChangeLog 2009-03-20 08:33:25 UTC (rev 3858) @@ -1,5 +1,9 @@ -2009-03-19 Braden McDaniel <br...@en...> +2009-03-20 Braden McDaniel <br...@en...> + * openvrml.pc.in: Link with libboost_filesystem and libltdl. + +2009-03-20 Braden McDaniel <br...@en...> + * openvrml.pc.in: libopenvrml no longer links with libjpeg and libpng. Modified: trunk/openvrml.pc.in =================================================================== --- trunk/openvrml.pc.in 2009-03-20 08:29:17 UTC (rev 3857) +++ trunk/openvrml.pc.in 2009-03-20 08:33:25 UTC (rev 3858) @@ -7,5 +7,5 @@ Description: VRML/X3D run-time library. Version: @PACKAGE_VERSION@ Requires: @OPENVRML_PKG_REQUIRES@ -Libs: -L${libdir} -lopenvrml -lboost_thread@BOOST_LIB_SUFFIX@ +Libs: -L${libdir} -lopenvrml -lboost_thread@BOOST_LIB_SUFFIX@ -lboost_filesystem@BOOST_LIB_SUFFIX@ -lltdl Cflags: -I${includedir} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-20 08:35:38
|
Revision: 3859 http://openvrml.svn.sourceforge.net/openvrml/?rev=3859&view=rev Author: braden Date: 2009-03-20 08:35:32 +0000 (Fri, 20 Mar 2009) Log Message: ----------- Add JAVA_HOME as a precious variable. Modified Paths: -------------- trunk/ChangeLog trunk/configure.ac Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-20 08:33:25 UTC (rev 3858) +++ trunk/ChangeLog 2009-03-20 08:35:32 UTC (rev 3859) @@ -1,5 +1,9 @@ 2009-03-20 Braden McDaniel <br...@en...> + * configure.ac: Add JAVA_HOME as a precious variable. + +2009-03-20 Braden McDaniel <br...@en...> + * openvrml.pc.in: Link with libboost_filesystem and libltdl. 2009-03-20 Braden McDaniel <br...@en...> Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-03-20 08:33:25 UTC (rev 3858) +++ trunk/configure.ac 2009-03-20 08:35:32 UTC (rev 3859) @@ -322,6 +322,7 @@ # # Script node Java support # +AC_ARG_VAR([JAVA_HOME], [Path to Java Runtime Environment]) AC_ARG_ENABLE([script-node-java], [AC_HELP_STRING([--disable-script-node-java], [disable Script node Java support])]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-20 08:39:39
|
Revision: 3860 http://openvrml.svn.sourceforge.net/openvrml/?rev=3860&view=rev Author: braden Date: 2009-03-20 08:39:34 +0000 (Fri, 20 Mar 2009) Log Message: ----------- Now that the SpiderMonkey dependency is isolated to a dlopen'd module, we don't need to add mozilla-js to OPENVRML_PKG_REQUIRES. Modified Paths: -------------- trunk/ChangeLog trunk/configure.ac Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-20 08:35:32 UTC (rev 3859) +++ trunk/ChangeLog 2009-03-20 08:39:34 UTC (rev 3860) @@ -1,5 +1,11 @@ 2009-03-20 Braden McDaniel <br...@en...> + * configure.ac: Now that the SpiderMonkey dependency is isolated + to a dlopen'd module, we don't need to add mozilla-js to + OPENVRML_PKG_REQUIRES. + +2009-03-20 Braden McDaniel <br...@en...> + * configure.ac: Add JAVA_HOME as a precious variable. 2009-03-20 Braden McDaniel <br...@en...> Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-03-20 08:35:32 UTC (rev 3859) +++ trunk/configure.ac 2009-03-20 08:39:34 UTC (rev 3860) @@ -289,10 +289,6 @@ AS_IF([test -z "$JS_LIBS"], [JS_LIBS="-ljs"])]) AS_IF([test X$have_libmozjs != Xyes -a \( X$with_libjs = Xyes -a X$have_libjs != Xyes \) -o X$have_jsapi_h != Xyes], [AC_MSG_FAILURE([SpiderMonkey is required for Script node JavaScript support.])]) -AS_IF([test X$with_libjs != Xyes], - [AS_IF([test -n "${OPENVRML_PKG_REQUIRES}"], - [OPENVRML_PKG_REQUIRES="${OPENVRML_PKG_REQUIRES},"]) - OPENVRML_PKG_REQUIRES="${OPENVRML_PKG_REQUIRES} ${mozilla_js_pkg}"]) AC_DEFINE([OPENVRML_ENABLE_SCRIPT_NODE_JAVASCRIPT], [1], [Defined if Script node JavaScript support is enabled.]) # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |