Benjamin Otte
2007-Aug-16 11:09 UTC
[Swfdec] Branch 'vivi' - 23 commits - libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_super.c libswfdec/swfdec_as_with.c libswfdec/swfdec_movie.c libswfdec/swfdec_net_stream.c libswfdec/swfdec_sprite_movie.c test/trace vivified/core vivified/dock vivified/ui
libswfdec/swfdec_as_object.c | 111 ++++++++++++++-------- libswfdec/swfdec_as_object.h | 1 libswfdec/swfdec_as_super.c | 4 libswfdec/swfdec_as_with.c | 7 - libswfdec/swfdec_movie.c | 10 - libswfdec/swfdec_net_stream.c | 6 - libswfdec/swfdec_sprite_movie.c | 6 - test/trace/Makefile.am | 45 ++++++++ test/trace/addProperty-delete-5.swf |binary test/trace/addProperty-delete-5.swf.trace | 3 test/trace/addProperty-delete-6.swf |binary test/trace/addProperty-delete-6.swf.trace | 3 test/trace/addProperty-delete-7.swf |binary test/trace/addProperty-delete-7.swf.trace | 3 test/trace/addProperty-delete-8.swf |binary test/trace/addProperty-delete-8.swf.trace | 3 test/trace/addProperty-delete.as | 11 ++ test/trace/addProperty-get-prototypes-5.swf |binary test/trace/addProperty-get-prototypes-5.swf.trace | 6 + test/trace/addProperty-get-prototypes-6.swf |binary test/trace/addProperty-get-prototypes-6.swf.trace | 9 + test/trace/addProperty-get-prototypes-7.swf |binary test/trace/addProperty-get-prototypes-7.swf.trace | 9 + test/trace/addProperty-get-prototypes-8.swf |binary test/trace/addProperty-get-prototypes-8.swf.trace | 9 + test/trace/addProperty-get-prototypes.as | 18 +++ test/trace/addProperty-set-prototypes-5.swf |binary test/trace/addProperty-set-prototypes-5.swf.trace | 4 test/trace/addProperty-set-prototypes-6.swf |binary test/trace/addProperty-set-prototypes-6.swf.trace | 5 test/trace/addProperty-set-prototypes-7.swf |binary test/trace/addProperty-set-prototypes-7.swf.trace | 5 test/trace/addProperty-set-prototypes-8.swf |binary test/trace/addProperty-set-prototypes-8.swf.trace | 5 test/trace/addProperty-set-prototypes.as | 18 +++ test/trace/property-native-5.swf |binary test/trace/property-native-5.swf.trace | 4 test/trace/property-native-6.swf |binary test/trace/property-native-6.swf.trace | 4 test/trace/property-native-7.swf |binary test/trace/property-native-7.swf.trace | 4 test/trace/property-native-8.swf |binary test/trace/property-native-8.swf.trace | 4 test/trace/property-native.as | 11 ++ test/trace/prototype-movie-5.swf |binary test/trace/prototype-movie-5.swf.trace | 4 test/trace/prototype-movie-6.swf |binary test/trace/prototype-movie-6.swf.trace | 4 test/trace/prototype-movie-7.swf |binary test/trace/prototype-movie-7.swf.trace | 4 test/trace/prototype-movie-8.swf |binary test/trace/prototype-movie-8.swf.trace | 4 test/trace/prototype-movie.as | 12 ++ vivified/core/vivi_application.c | 58 ++++++++++- vivified/core/vivi_application.h | 2 vivified/core/vivi_application_as.c | 15 ++ vivified/core/vivi_debugger.c | 2 vivified/core/vivi_function.c | 6 + vivified/core/vivi_initialize.as | 52 ++++++++-- vivified/dock/vivi_vdock.c | 73 ++++---------- vivified/dock/vivi_vdock.h | 6 + vivified/ui/main.c | 18 ++- vivified/ui/vivi_player.c | 3 63 files changed, 467 insertions(+), 124 deletions(-) New commits: diff-tree 6e6a99cc02d9399a08398cdcffe0599bc724fe1a (from 380e971ad1cbc7ebf9e8bea743d47cf70072d6c7) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 13:09:31 2007 +0200 debugging g_print removal #3423 diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index 803d82f..ee112db 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -897,7 +897,6 @@ swfdec_as_object_create (SwfdecAsFunctio if (native->construct_size) { type = native->construct_type; size = native->construct_size; - g_print ("type is %s\n", g_type_name (type)); break; } } @@ -908,7 +907,6 @@ swfdec_as_object_create (SwfdecAsFunctio if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) { cur = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val); if (SWFDEC_IS_AS_FUNCTION (cur)) { - g_print ("found one!\n"); continue; } } diff-tree 380e971ad1cbc7ebf9e8bea743d47cf70072d6c7 (from 670335c62948358e9126c86478752e20eee5d20f) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 13:09:05 2007 +0200 don't mess with the prototype anymore, swfdec handles it now diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 6c8640b..430110d 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -22,7 +22,6 @@ Breakpoint = function () extends Native. Breakpoint.list.push (this); }; Breakpoint.list = new Array (); -Breakpoint.prototype = new Object (); Wrap = function () {}; Wrap.prototype = {}; diff-tree 670335c62948358e9126c86478752e20eee5d20f (from ab94c6f2d440cd05cf4363a717769aa7886a7587) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 13:08:44 2007 +0200 walk the inheritance chain to find an objects type diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index b5dcd25..803d82f 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -883,6 +883,7 @@ swfdec_as_object_create (SwfdecAsFunctio SwfdecAsObject *new; SwfdecAsContext *context; SwfdecAsFunction *cur; + SwfdecAsValue val; guint size; GType type = 0; @@ -890,29 +891,30 @@ swfdec_as_object_create (SwfdecAsFunctio context = SWFDEC_AS_OBJECT (fun)->context; cur = fun; - while (type == 0 && cur != NULL) { + do { if (SWFDEC_IS_AS_NATIVE_FUNCTION (cur)) { SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (cur); if (native->construct_size) { type = native->construct_type; size = native->construct_size; + g_print ("type is %s\n", g_type_name (type)); break; } } -#if 0 - This doesn't work. It's supposed to figure out the last native object in the inheritance chain. - swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (cur), SWFDEC_AS_STR___constructor__, &val); + swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (cur), SWFDEC_AS_STR_prototype, &val); if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) { - cur = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val); - if (!SWFDEC_IS_AS_FUNCTION (cur)) - cur = NULL; - } else { - cur = NULL; + SwfdecAsObject *proto = SWFDEC_AS_VALUE_GET_OBJECT (&val); + swfdec_as_object_get_variable (proto, SWFDEC_AS_STR___constructor__, &val); + if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) { + cur = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val); + if (SWFDEC_IS_AS_FUNCTION (cur)) { + g_print ("found one!\n"); + continue; + } + } } -#else cur = NULL; -#endif - } + } while (type == 0 && cur != NULL); if (type == 0) { type = SWFDEC_TYPE_AS_OBJECT; size = sizeof (SwfdecAsObject); diff-tree ab94c6f2d440cd05cf4363a717769aa7886a7587 (from 9792ce9e8ae0793131e59008f15c2d47e69dd2b5) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 13:08:17 2007 +0200 breakpoints are objects diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c index 4c2608c..686862a 100644 --- a/vivified/core/vivi_function.c +++ b/vivified/core/vivi_function.c @@ -76,6 +76,12 @@ vivi_function_init_context (ViviApplicat 0, functions[i].fun, 0); swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (fun), VIVI_TYPE_BREAKPOINT); + obj = swfdec_as_object_new (cx); + if (obj == NULL) + return; + SWFDEC_AS_VALUE_SET_OBJECT (&val, obj); + swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (fun), + swfdec_as_context_get_string (cx, "prototype"), &val); g_signal_connect (app, "message", G_CALLBACK (vivi_function_not_reached), NULL); vivi_application_execute (app, vivi_initialize); diff-tree 9792ce9e8ae0793131e59008f15c2d47e69dd2b5 (from 567ee69db12396392b896a06868c6c27edcc6a90) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:54:24 2007 +0200 add a list command to list all breakpoints diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index a754cb2..6c8640b 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -17,7 +17,12 @@ * Boston, MA 02110-1301 USA */ -Breakpoint = Native.Breakpoint; +Breakpoint = function () extends Native.Breakpoint { + super (); + Breakpoint.list.push (this); +}; +Breakpoint.list = new Array (); +Breakpoint.prototype = new Object (); Wrap = function () {}; Wrap.prototype = {}; @@ -59,5 +64,14 @@ Commands.add = function (name) { Commands.print (" " + frame); return true; }; + ret.toString = function () { + return "function call " + name; + }; +}; +Commands.list = function () { + var a = Breakpoint.list; + var i; + for (i = 0; i < a.length; i++) { + Commands.print (i + ": " + a[i]); + } }; - diff-tree 567ee69db12396392b896a06868c6c27edcc6a90 (from 2101df59fadb5037503673f1ce712ecb1a3dff19) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:35:25 2007 +0200 new "add" function to add breakpoints diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 281faba..a754cb2 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -44,3 +44,20 @@ Commands.restart = function () { Commands.run (); }; Commands.quit = Native.quit; +/* can't use "break" as a function name, it's a keyword in JS */ +Commands.add = function (name) { + if (name == undefined) { + Commands.error ("add command requires a function name"); + return undefined; + } + var ret = new Breakpoint (); + ret.onStartFrame = function (frame) { + if (frame.name != name) + return false; + + Commands.print ("Breakpoint: function " + name + " called"); + Commands.print (" " + frame); + return true; + }; +}; + diff-tree 2101df59fadb5037503673f1ce712ecb1a3dff19 (from 97c4c386c1da957a75e2b41fecac9a2253515211) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:33:01 2007 +0200 restructure and add error function diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 4852d82..281faba 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -17,8 +17,21 @@ * Boston, MA 02110-1301 USA */ +Breakpoint = Native.Breakpoint; + +Wrap = function () {}; +Wrap.prototype = {}; +Wrap.prototype.toString = Native.wrap_toString; + +Frame = function () extends Wrap {}; +Frame.prototype = new Wrap (); +Frame.prototype.addProperty ("name", Native.frame_name_get, null); + +/*** commands available for debugging ***/ + Commands = new Object (); Commands.print = Native.print; +Commands.error = Native.error; Commands.r = Native.run; Commands.run = Native.run; Commands.halt = Native.stop; @@ -31,14 +44,3 @@ Commands.restart = function () { Commands.run (); }; Commands.quit = Native.quit; - -Breakpoint = Native.Breakpoint; - -Wrap = function () {}; -Wrap.prototype = {}; -Wrap.prototype.toString = Native.wrap_toString; - -Frame = function () extends Wrap {}; -Frame.prototype = new Wrap (); -Frame.prototype.addProperty ("name", Native.frame_name_get, null); - diff-tree 97c4c386c1da957a75e2b41fecac9a2253515211 (from ece89b8a8842215f3e1e68a09181e1b6ebadf8e3) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:32:20 2007 +0200 clean up the vdock, so it properly shuts down diff --git a/vivified/dock/vivi_vdock.c b/vivified/dock/vivi_vdock.c index d37d563..f79cb2d 100644 --- a/vivified/dock/vivi_vdock.c +++ b/vivified/dock/vivi_vdock.c @@ -28,14 +28,14 @@ G_DEFINE_TYPE (ViviVDock, vivi_vdock, GTK_TYPE_BIN) static void -vivi_vdock_dispose (GObject *object) +vivi_vdock_destroy (GtkObject *object) { ViviVDock *vdock = VIVI_VDOCK (object); + GTK_OBJECT_CLASS (vivi_vdock_parent_class)->destroy (object); + g_list_free (vdock->docklets); vdock->docklets = NULL; - - G_OBJECT_CLASS (vivi_vdock_parent_class)->dispose (object); } static void @@ -62,18 +62,20 @@ vivi_vdock_size_allocate (GtkWidget *wid } } -static void -vivi_vdock_add (GtkContainer *container, GtkWidget *widget) +void +vivi_vdock_add (ViviVDock *vdock, GtkWidget *widget) { - ViviVDock *vdock = VIVI_VDOCK (container); GtkWidget *docker; + g_return_if_fail (VIVI_IS_VDOCK (vdock)); + g_return_if_fail (GTK_IS_WIDGET (widget)); + docker = vivi_docker_new (VIVI_DOCKLET (widget)); gtk_widget_show (docker); g_object_ref (widget); if (vdock->docklets == NULL) { - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->add (container, docker); + gtk_container_add (GTK_CONTAINER (vdock), docker); } else { /* docklet is in docker, so we need to use parent */ GtkWidget *last = gtk_widget_get_parent (vdock->docklets->data); @@ -81,18 +83,14 @@ vivi_vdock_add (GtkContainer *container, GtkWidget *paned; g_object_ref (last); - if (parent == (GtkWidget *) container) { - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->remove (container, last); - } else { - gtk_container_remove (GTK_CONTAINER (parent), last); - } + gtk_container_remove (GTK_CONTAINER (parent), last); paned = gtk_vpaned_new (); gtk_paned_pack1 (GTK_PANED (paned), last, TRUE, FALSE); gtk_paned_pack2 (GTK_PANED (paned), docker, TRUE, FALSE); g_object_unref (last); gtk_widget_show (paned); - if (parent == (GtkWidget *) container) { - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->add (container, paned); + if (parent == (GtkWidget *) vdock) { + gtk_container_add (GTK_CONTAINER (vdock), paned); } else { gtk_paned_pack1 (GTK_PANED (parent), paned, TRUE, FALSE); } @@ -100,18 +98,17 @@ vivi_vdock_add (GtkContainer *container, vdock->docklets = g_list_prepend (vdock->docklets, widget); } -static void -vivi_vdock_remove (GtkContainer *container, GtkWidget *widget) +void +vivi_vdock_remove (ViviVDock *vdock, GtkWidget *widget) { - ViviVDock *vdock = VIVI_VDOCK (container); GtkWidget *docker, *parent; g_return_if_fail (g_list_find (vdock->docklets, widget)); docker = gtk_widget_get_parent (widget); parent = gtk_widget_get_parent (docker); - if (parent == (GtkWidget *) container) { - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->remove (container, docker); + if (parent == (GtkWidget *) vdock) { + gtk_container_remove (GTK_CONTAINER (vdock), docker); } else { GtkWidget *other; GtkWidget *paned_parent; @@ -123,9 +120,9 @@ vivi_vdock_remove (GtkContainer *contain g_object_ref (other); gtk_container_remove (GTK_CONTAINER (parent), docker); gtk_container_remove (GTK_CONTAINER (parent), other); - if (paned_parent == (GtkWidget *) container) { - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->remove (container, parent); - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->remove (container, other); + if (paned_parent == (GtkWidget *) vdock) { + gtk_container_remove (GTK_CONTAINER (vdock), parent); + gtk_container_add (GTK_CONTAINER (vdock), other); } else { gtk_container_remove (GTK_CONTAINER (paned_parent), parent); gtk_paned_pack1 (GTK_PANED (parent), other, TRUE, FALSE); @@ -136,44 +133,16 @@ vivi_vdock_remove (GtkContainer *contain g_object_unref (widget); } -static GType -vivi_vdock_child_type (GtkContainer *container) -{ - return VIVI_TYPE_DOCKLET; -} - -static void -vivi_vdock_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - if (include_internals) { - GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->forall (container, include_internals, - callback, callback_data); - } else { - GList *walk; - - for (walk = VIVI_VDOCK (container)->docklets; walk; walk = walk->next) { - callback (walk->data, callback_data); - } - } -} - static void vivi_vdock_class_init (ViviVDockClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - object_class->dispose = vivi_vdock_dispose; + object_class->destroy = vivi_vdock_destroy; widget_class->size_request = vivi_vdock_size_request; widget_class->size_allocate = vivi_vdock_size_allocate; - - container_class->add = vivi_vdock_add; - container_class->remove = vivi_vdock_remove; - container_class->child_type = vivi_vdock_child_type; - container_class->forall = vivi_vdock_forall; } static void diff --git a/vivified/dock/vivi_vdock.h b/vivified/dock/vivi_vdock.h index ec3527f..7b0f61f 100644 --- a/vivified/dock/vivi_vdock.h +++ b/vivified/dock/vivi_vdock.h @@ -50,5 +50,11 @@ GType vivi_vdock_get_type (void); GtkWidget * vivi_vdock_new (void); +void vivi_vdock_add (ViviVDock * vdock, + GtkWidget * widget); +void vivi_vdock_remove (ViviVDock * vdock, + GtkWidget * widget); + + G_END_DECLS #endif diff --git a/vivified/ui/main.c b/vivified/ui/main.c index 399483f..3f96021 100644 --- a/vivified/ui/main.c +++ b/vivified/ui/main.c @@ -37,6 +37,16 @@ try_grab_focus (GtkWidget *widget, gpoin gtk_container_foreach (GTK_CONTAINER (widget), try_grab_focus, NULL); } +static gboolean +delete_event (GtkWidget *widget, GdkEvent *event, ViviApplication *app) +{ + if (!vivi_application_is_quit (app)) { + vivi_application_quit (app); + return TRUE; + } + return FALSE; +} + static void setup (const char *filename) { @@ -46,15 +56,17 @@ setup (const char *filename) app = vivi_application_new (); vivi_application_set_filename (app, filename); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect_swapped (app, "notify::quit", G_CALLBACK (gtk_widget_destroy), window); box = vivi_vdock_new (); gtk_container_add (GTK_CONTAINER (window), box); widget = vivi_player_new (app); - gtk_container_add (GTK_CONTAINER (box), widget); + vivi_vdock_add (VIVI_VDOCK (box), widget); widget = vivi_command_line_new (app); - gtk_container_add (GTK_CONTAINER (box), widget); + vivi_vdock_add (VIVI_VDOCK (box), widget); gtk_container_foreach (GTK_CONTAINER (widget), try_grab_focus, NULL); - g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); + g_signal_connect (window, "delete-event", G_CALLBACK (delete_event), app); + g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), app); gtk_widget_show_all (window); } diff-tree ece89b8a8842215f3e1e68a09181e1b6ebadf8e3 (from 49807e47ac5b6560070a29a2d041df5ae57a2e88) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:31:51 2007 +0200 listen to the app's interrupted state and disable mouse and keyboard input on breakpoints diff --git a/vivified/ui/vivi_player.c b/vivified/ui/vivi_player.c index 657d169..f54a935 100644 --- a/vivified/ui/vivi_player.c +++ b/vivified/ui/vivi_player.c @@ -31,6 +31,9 @@ vivi_player_notify_app (ViviApplication { if (g_str_equal (pspec->name, "player")) { swfdec_gtk_widget_set_player (SWFDEC_GTK_WIDGET (player->player), vivi_application_get_player (app)); + } else if (g_str_equal (pspec->name, "interrupted")) { + swfdec_gtk_widget_set_interactive (SWFDEC_GTK_WIDGET (player->player), + !vivi_application_get_interrupted (app)); } } diff-tree 49807e47ac5b6560070a29a2d041df5ae57a2e88 (from dfa2a625eb1c2f036a30220c4606a8c010786272) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:31:10 2007 +0200 notify when the application is interrupted diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c index 44149cc..915dff0 100644 --- a/vivified/core/vivi_debugger.c +++ b/vivified/core/vivi_debugger.c @@ -72,11 +72,13 @@ vivi_debugger_break (ViviDebugger *debug app->playback_state = 0; app->playback_count = 0; app->loop = g_main_loop_new (NULL, FALSE); + g_object_notify (G_OBJECT (app), "interrupted"); g_main_loop_run (app->loop); g_main_loop_unref (app->loop); app->loop = NULL; + g_object_notify (G_OBJECT (app), "interrupted"); swfdec_player_lock_soft (app->player); } diff-tree dfa2a625eb1c2f036a30220c4606a8c010786272 (from af9936023a852946d0c23048d7d3195b757a7cdb) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 12:30:45 2007 +0200 add "interrupted" and "quit" property ALso improve quitting to work as expected diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index e8f489f..624c911 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -35,7 +35,9 @@ enum { enum { PROP_0, PROP_FILENAME, - PROP_PLAYER + PROP_PLAYER, + PROP_INTERRUPTED, + PROP_QUIT }; G_DEFINE_TYPE (ViviApplication, vivi_application, SWFDEC_TYPE_AS_CONTEXT) @@ -54,6 +56,12 @@ vivi_application_get_property (GObject * case PROP_PLAYER: g_value_set_object (value, app->player); break; + case PROP_INTERRUPTED: + g_value_set_boolean (value, app->loop != NULL); + break; + case PROP_QUIT: + g_value_set_boolean (value, app->playback_state == VIVI_APPLICATION_EXITING); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -81,6 +89,9 @@ vivi_application_dispose (GObject *objec { ViviApplication *app = VIVI_APPLICATION (object); + if (app->playback_state != VIVI_APPLICATION_EXITING) + vivi_application_quit (app); + g_object_unref (app->player); g_hash_table_destroy (app->wraps); @@ -102,6 +113,12 @@ vivi_application_class_init (ViviApplica g_object_class_install_property (object_class, PROP_PLAYER, g_param_spec_object ("player", "player", "Flash player in use", SWFDEC_TYPE_PLAYER, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_INTERRUPTED, + g_param_spec_boolean ("interrupted", "interrupted", "TRUE if handling a breakpoint", + FALSE, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_QUIT, + g_param_spec_boolean ("quit", "quit", "TRUE if application has been quit (no breakpoints will happen)", + FALSE, G_PARAM_READABLE)); signals[MESSAGE] = g_signal_new ("message", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT_POINTER, /* FIXME */ @@ -189,6 +206,22 @@ vivi_application_get_player (ViviApplica return app->player; } +gboolean +vivi_application_get_interrupted (ViviApplication *app) +{ + g_return_val_if_fail (VIVI_IS_APPLICATION (app), FALSE); + + return app->loop != NULL; +} + +gboolean +vivi_application_is_quit (ViviApplication *app) +{ + g_return_val_if_fail (VIVI_IS_APPLICATION (app), FALSE); + + return app->playback_state == VIVI_APPLICATION_EXITING; +} + static gboolean vivi_application_step_forward (gpointer appp) { @@ -204,9 +237,14 @@ vivi_application_step_forward (gpointer static void vivi_application_check (ViviApplication *app) { - gboolean is_playing = swfdec_gtk_player_get_playing (SWFDEC_GTK_PLAYER (app->player)); - gboolean is_breakpoint = app->loop != NULL; + gboolean is_playing, is_breakpoint; + /* if we're inside some script code, don't do anything */ + if (swfdec_as_context_get_frame (SWFDEC_AS_CONTEXT (app))) + return; + + is_playing = swfdec_gtk_player_get_playing (SWFDEC_GTK_PLAYER (app->player)); + is_breakpoint = app->loop != NULL; swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (app)); switch (app->playback_state) { @@ -293,8 +331,11 @@ vivi_application_play (ViviApplication * { g_return_if_fail (VIVI_IS_APPLICATION (app)); + if (app->playback_state == VIVI_APPLICATION_EXITING) + return; app->playback_state = VIVI_APPLICATION_PLAYING; app->playback_count = 1; + vivi_application_check (app); } void @@ -302,8 +343,11 @@ vivi_application_stop (ViviApplication * { g_return_if_fail (VIVI_IS_APPLICATION (app)); + if (app->playback_state == VIVI_APPLICATION_EXITING) + return; app->playback_state = VIVI_APPLICATION_STOPPED; app->playback_count = 0; + vivi_application_check (app); } void @@ -311,8 +355,11 @@ vivi_application_step (ViviApplication * { g_return_if_fail (VIVI_IS_APPLICATION (app)); + if (app->playback_state == VIVI_APPLICATION_EXITING) + return; app->playback_state = VIVI_APPLICATION_STEPPING; app->playback_count = n_times; + vivi_application_check (app); } void @@ -320,8 +367,11 @@ vivi_application_quit (ViviApplication * { g_return_if_fail (VIVI_IS_APPLICATION (app)); + if (app->playback_state == VIVI_APPLICATION_EXITING) + return; app->playback_state = VIVI_APPLICATION_EXITING; app->playback_count = 1; - gtk_main_quit (); + g_object_notify (G_OBJECT (app), "quit"); + vivi_application_check (app); } diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h index 2636453..812b304 100644 --- a/vivified/core/vivi_application.h +++ b/vivified/core/vivi_application.h @@ -89,6 +89,8 @@ void vivi_application_set_filename (Vi const char * filename); const char * vivi_application_get_filename (ViviApplication * app); SwfdecPlayer * vivi_application_get_player (ViviApplication * app); +gboolean vivi_application_get_interrupted(ViviApplication * app); +gboolean vivi_application_is_quit (ViviApplication * app); void vivi_application_init_player (ViviApplication * app); void vivi_application_reset (ViviApplication * app); diff-tree af9936023a852946d0c23048d7d3195b757a7cdb (from 400039ceb439cbeb5938dac445ca5995eb0fce9d) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 09:32:39 2007 +0200 add an error function for printing errors diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c index a637428..6e2c011 100644 --- a/vivified/core/vivi_application_as.c +++ b/vivified/core/vivi_application_as.c @@ -89,6 +89,21 @@ vivi_application_as_print (SwfdecAsConte vivi_application_output (app, "%s", s); } +VIVI_FUNCTION ("error", vivi_application_as_error) +void +vivi_application_as_error (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + ViviApplication *app = VIVI_APPLICATION (cx); + const char *s; + + if (argc == 0) + return; + + s = swfdec_as_value_to_string (cx, &argv[0]); + vivi_application_error (app, "%s", s); +} + VIVI_FUNCTION ("quit", vivi_application_as_quit) void vivi_application_as_quit (SwfdecAsContext *cx, SwfdecAsObject *this, diff-tree 400039ceb439cbeb5938dac445ca5995eb0fce9d (from parents) Merge: 82cbf15d290ca8584505fd0c1970fa976de545dc bf81efebf34c71944530945a70c24532de6ea111 Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 23:17:16 2007 +0200 Merge branch 'master' into vivi diff-tree bf81efebf34c71944530945a70c24532de6ea111 (from 565cb315b34355849f0de3c656b3d9497b1164d2) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 23:14:01 2007 +0200 add test for deleting addProperty()'d properties diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 6ec5d28..45b56a8 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -37,6 +37,15 @@ EXTRA_DIST = \ addProperty-7.swf.trace \ addProperty-8.swf \ addProperty-8.swf.trace \ + addProperty-delete.as \ + addProperty-delete-5.swf \ + addProperty-delete-5.swf.trace \ + addProperty-delete-6.swf \ + addProperty-delete-6.swf.trace \ + addProperty-delete-7.swf \ + addProperty-delete-7.swf.trace \ + addProperty-delete-8.swf \ + addProperty-delete-8.swf.trace \ addProperty-get-prototypes.as \ addProperty-get-prototypes-5.swf \ addProperty-get-prototypes-5.swf.trace \ diff --git a/test/trace/addProperty-delete-5.swf b/test/trace/addProperty-delete-5.swf new file mode 100644 index 0000000..e10fec5 Binary files /dev/null and b/test/trace/addProperty-delete-5.swf differ diff --git a/test/trace/addProperty-delete-5.swf.trace b/test/trace/addProperty-delete-5.swf.trace new file mode 100644 index 0000000..2796bd0 --- /dev/null +++ b/test/trace/addProperty-delete-5.swf.trace @@ -0,0 +1,3 @@ +check if deleting a property added with addProperty works +undefined +undefined diff --git a/test/trace/addProperty-delete-6.swf b/test/trace/addProperty-delete-6.swf new file mode 100644 index 0000000..86571b2 Binary files /dev/null and b/test/trace/addProperty-delete-6.swf differ diff --git a/test/trace/addProperty-delete-6.swf.trace b/test/trace/addProperty-delete-6.swf.trace new file mode 100644 index 0000000..ec5834a --- /dev/null +++ b/test/trace/addProperty-delete-6.swf.trace @@ -0,0 +1,3 @@ +check if deleting a property added with addProperty works +42 +undefined diff --git a/test/trace/addProperty-delete-7.swf b/test/trace/addProperty-delete-7.swf new file mode 100644 index 0000000..ef3db72 Binary files /dev/null and b/test/trace/addProperty-delete-7.swf differ diff --git a/test/trace/addProperty-delete-7.swf.trace b/test/trace/addProperty-delete-7.swf.trace new file mode 100644 index 0000000..ec5834a --- /dev/null +++ b/test/trace/addProperty-delete-7.swf.trace @@ -0,0 +1,3 @@ +check if deleting a property added with addProperty works +42 +undefined diff --git a/test/trace/addProperty-delete-8.swf b/test/trace/addProperty-delete-8.swf new file mode 100644 index 0000000..cdf6511 Binary files /dev/null and b/test/trace/addProperty-delete-8.swf differ diff --git a/test/trace/addProperty-delete-8.swf.trace b/test/trace/addProperty-delete-8.swf.trace new file mode 100644 index 0000000..ec5834a --- /dev/null +++ b/test/trace/addProperty-delete-8.swf.trace @@ -0,0 +1,3 @@ +check if deleting a property added with addProperty works +42 +undefined diff --git a/test/trace/addProperty-delete.as b/test/trace/addProperty-delete.as new file mode 100644 index 0000000..2c8076b --- /dev/null +++ b/test/trace/addProperty-delete.as @@ -0,0 +1,11 @@ +// makeswf -v 7 -s 200x150 -r 1 -o addProperty-delete.swf addProperty-delete.as + +trace ("check if deleting a property added with addProperty works"); + +o = {}; +o.addProperty ("x", function () { return 42; }, null); +trace (o.x); +delete o.x; +trace (o.x); + +loadMovie ("FSCommand:quit", ""); diff-tree 565cb315b34355849f0de3c656b3d9497b1164d2 (from b9d80cd0852b204c03e5828bfb4210e3ed98a2a4) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 23:11:31 2007 +0200 porperties added with addProperty aren't permanent. diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index 8999597..b5dcd25 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -991,7 +991,7 @@ swfdec_as_object_add_variable (SwfdecAsO return; var->get = get; var->set = set; - var->flags = SWFDEC_AS_VARIABLE_PERMANENT; + var->flags = 0; if (set == NULL) var->flags |= SWFDEC_AS_VARIABLE_READONLY; } diff-tree b9d80cd0852b204c03e5828bfb4210e3ed98a2a4 (from c94ea432d4a4a30c76cd89d701d8cb9395347647) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 23:09:59 2007 +0200 fix getting of properties added with addProperty We need access to the original object, so we can call the getter function with that object. diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index b1d06e5..8999597 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -172,8 +172,8 @@ swfdec_as_object_hash_create (SwfdecAsOb } static gboolean -swfdec_as_object_do_get (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *val, guint *flags) +swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig, + const char *variable, SwfdecAsValue *val, guint *flags) { SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable); @@ -184,7 +184,7 @@ swfdec_as_object_do_get (SwfdecAsObject return FALSE; if (var->get) { - swfdec_as_function_call (var->get, object, 0, NULL, val); + swfdec_as_function_call (var->get, orig, 0, NULL, val); swfdec_as_context_run (object->context); *flags = var->flags; } else { @@ -602,7 +602,7 @@ swfdec_as_object_get_variable_and_flags guint i; SwfdecAsValue tmp_val; guint tmp_flags; - SwfdecAsObject *tmp_pobject; + SwfdecAsObject *tmp_pobject, *cur; g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE); g_return_val_if_fail (variable != NULL, FALSE); @@ -614,13 +614,14 @@ swfdec_as_object_get_variable_and_flags if (pobject == NULL) pobject = &tmp_pobject; - for (i = 0; i < 256 && object != NULL; i++) { - klass = SWFDEC_AS_OBJECT_GET_CLASS (object); - if (klass->get (object, variable, value, flags)) { - *pobject = object; + cur = object; + for (i = 0; i < 256 && cur != NULL; i++) { + klass = SWFDEC_AS_OBJECT_GET_CLASS (cur); + if (klass->get (cur, object, variable, value, flags)) { + *pobject = cur; return TRUE; } - object = object->prototype; + cur = cur->prototype; } if (i == 256) { swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded"); diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h index f82cd9c..265c6cb 100644 --- a/libswfdec/swfdec_as_object.h +++ b/libswfdec/swfdec_as_object.h @@ -65,6 +65,7 @@ struct _SwfdecAsObjectClass { void (* add) (SwfdecAsObject * object); /* get the value and flags for a variables */ gboolean (* get) (SwfdecAsObject * object, + SwfdecAsObject * orig, const char * variable, SwfdecAsValue * val, guint * flags); diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c index 5447bcd..653c30a 100644 --- a/libswfdec/swfdec_as_super.c +++ b/libswfdec/swfdec_as_super.c @@ -68,8 +68,8 @@ swfdec_as_super_call (SwfdecAsFunction * } static gboolean -swfdec_as_super_get (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *val, guint *flags) +swfdec_as_super_get (SwfdecAsObject *object, SwfdecAsObject *orig, + const char *variable, SwfdecAsValue *val, guint *flags) { SwfdecAsSuper *super = SWFDEC_AS_SUPER (object); diff --git a/libswfdec/swfdec_as_with.c b/libswfdec/swfdec_as_with.c index a000ca3..62af9b8 100644 --- a/libswfdec/swfdec_as_with.c +++ b/libswfdec/swfdec_as_with.c @@ -47,11 +47,14 @@ swfdec_as_with_resolve (SwfdecAsObject * } static gboolean -swfdec_as_with_get (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *val, guint *flags) +swfdec_as_with_get (SwfdecAsObject *object, SwfdecAsObject *orig, + const char *variable, SwfdecAsValue *val, guint *flags) { SwfdecAsWith *with = SWFDEC_AS_WITH (object); + if (orig != object) { + SWFDEC_FIXME ("write tests for this case"); + } return swfdec_as_object_get_variable_and_flags (with->object, variable, val, flags, NULL); } diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c index 776e2b1..3bac79f 100644 --- a/libswfdec/swfdec_movie.c +++ b/libswfdec/swfdec_movie.c @@ -841,15 +841,15 @@ swfdec_movie_get_by_name (SwfdecPlayer * } static gboolean -swfdec_movie_get_variable (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *val, guint *flags) +swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig, + const char *variable, SwfdecAsValue *val, guint *flags) { SwfdecMovie *movie = SWFDEC_MOVIE (object); if (movie->state == SWFDEC_MOVIE_STATE_DESTROYED) return FALSE; - if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, variable, val, flags)) + if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, orig, variable, val, flags)) return TRUE; if (swfdec_movie_get_asprop (movie, variable, val)) { diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c index b95f7a4..fac0886 100644 --- a/libswfdec/swfdec_net_stream.c +++ b/libswfdec/swfdec_net_stream.c @@ -350,12 +350,12 @@ swfdec_net_stream_dispose (GObject *obje } static gboolean -swfdec_net_stream_get_variable (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *val, guint *flags) +swfdec_net_stream_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig, + const char *variable, SwfdecAsValue *val, guint *flags) { SwfdecNetStream *stream; - if (SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->get (object, variable, val, flags)) + if (SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->get (object, orig, variable, val, flags)) return TRUE; stream = SWFDEC_NET_STREAM (object); diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c index 488864c..4f9067d 100644 --- a/libswfdec/swfdec_sprite_movie.c +++ b/libswfdec/swfdec_sprite_movie.c @@ -622,12 +622,12 @@ swfdec_sprite_movie_get_by_name (SwfdecM } static gboolean -swfdec_sprite_movie_get_variable (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *val, guint *flags) +swfdec_sprite_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig, + const char *variable, SwfdecAsValue *val, guint *flags) { SwfdecMovie *movie; - if (SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->get (object, variable, val, flags)) + if (SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->get (object, orig, variable, val, flags)) return TRUE; movie = swfdec_sprite_movie_get_by_name (SWFDEC_MOVIE (object), variable); diff-tree c94ea432d4a4a30c76cd89d701d8cb9395347647 (from 01e8d90362605acf52d171de350853bd773e7edb) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 23:09:10 2007 +0200 add test case for next commit diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 591144a..6ec5d28 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -37,6 +37,15 @@ EXTRA_DIST = \ addProperty-7.swf.trace \ addProperty-8.swf \ addProperty-8.swf.trace \ + addProperty-get-prototypes.as \ + addProperty-get-prototypes-5.swf \ + addProperty-get-prototypes-5.swf.trace \ + addProperty-get-prototypes-6.swf \ + addProperty-get-prototypes-6.swf.trace \ + addProperty-get-prototypes-7.swf \ + addProperty-get-prototypes-7.swf.trace \ + addProperty-get-prototypes-8.swf \ + addProperty-get-prototypes-8.swf.trace \ addProperty-set-prototypes.as \ addProperty-set-prototypes-5.swf \ addProperty-set-prototypes-5.swf.trace \ diff --git a/test/trace/addProperty-get-prototypes-5.swf b/test/trace/addProperty-get-prototypes-5.swf new file mode 100644 index 0000000..171fd19 Binary files /dev/null and b/test/trace/addProperty-get-prototypes-5.swf differ diff --git a/test/trace/addProperty-get-prototypes-5.swf.trace b/test/trace/addProperty-get-prototypes-5.swf.trace new file mode 100644 index 0000000..f9ebb80 --- /dev/null +++ b/test/trace/addProperty-get-prototypes-5.swf.trace @@ -0,0 +1,6 @@ +Check getting of variables when addProperty has been used on prototypes. +10 +10 +15 +undefined +20 diff --git a/test/trace/addProperty-get-prototypes-6.swf b/test/trace/addProperty-get-prototypes-6.swf new file mode 100644 index 0000000..9207fd8 Binary files /dev/null and b/test/trace/addProperty-get-prototypes-6.swf differ diff --git a/test/trace/addProperty-get-prototypes-6.swf.trace b/test/trace/addProperty-get-prototypes-6.swf.trace new file mode 100644 index 0000000..1082851 --- /dev/null +++ b/test/trace/addProperty-get-prototypes-6.swf.trace @@ -0,0 +1,9 @@ +Check getting of variables when addProperty has been used on prototypes. +10 +10 +15 +o +42 +o set +o +42 diff --git a/test/trace/addProperty-get-prototypes-7.swf b/test/trace/addProperty-get-prototypes-7.swf new file mode 100644 index 0000000..cd76446 Binary files /dev/null and b/test/trace/addProperty-get-prototypes-7.swf differ diff --git a/test/trace/addProperty-get-prototypes-7.swf.trace b/test/trace/addProperty-get-prototypes-7.swf.trace new file mode 100644 index 0000000..1082851 --- /dev/null +++ b/test/trace/addProperty-get-prototypes-7.swf.trace @@ -0,0 +1,9 @@ +Check getting of variables when addProperty has been used on prototypes. +10 +10 +15 +o +42 +o set +o +42 diff --git a/test/trace/addProperty-get-prototypes-8.swf b/test/trace/addProperty-get-prototypes-8.swf new file mode 100644 index 0000000..c2b4add Binary files /dev/null and b/test/trace/addProperty-get-prototypes-8.swf differ diff --git a/test/trace/addProperty-get-prototypes-8.swf.trace b/test/trace/addProperty-get-prototypes-8.swf.trace new file mode 100644 index 0000000..1082851 --- /dev/null +++ b/test/trace/addProperty-get-prototypes-8.swf.trace @@ -0,0 +1,9 @@ +Check getting of variables when addProperty has been used on prototypes. +10 +10 +15 +o +42 +o set +o +42 diff --git a/test/trace/addProperty-get-prototypes.as b/test/trace/addProperty-get-prototypes.as new file mode 100644 index 0000000..e617cc2 --- /dev/null +++ b/test/trace/addProperty-get-prototypes.as @@ -0,0 +1,18 @@ +// makeswf -v 7 -s 200x150 -r 1 -o addProperty-get-prototypes.swf addProperty-get-prototypes.as + +trace ("Check getting of variables when addProperty has been used on prototypes."); + +o = {name: "o"}; +o.__proto__ = {name: "proto"}; +o.x = 10; +trace (o.x); +o.__proto__.addProperty ("x", function () { trace (this.name); return 42; }, function () { trace (this.name + " set"); }); +trace (o.x); +o.x = 15; +trace (o.x); +delete o.x; +trace (o.x); +o.x = 20; +trace (o.x); + +loadMovie ("FSCommand:quit", ""); diff-tree 01e8d90362605acf52d171de350853bd773e7edb (from d43d504a01b534233965d5c7fd851ae65ac5ce09) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 22:03:07 2007 +0200 add check for last commit diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 7e72228..591144a 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -37,6 +37,15 @@ EXTRA_DIST = \ addProperty-7.swf.trace \ addProperty-8.swf \ addProperty-8.swf.trace \ + addProperty-set-prototypes.as \ + addProperty-set-prototypes-5.swf \ + addProperty-set-prototypes-5.swf.trace \ + addProperty-set-prototypes-6.swf \ + addProperty-set-prototypes-6.swf.trace \ + addProperty-set-prototypes-7.swf \ + addProperty-set-prototypes-7.swf.trace \ + addProperty-set-prototypes-8.swf \ + addProperty-set-prototypes-8.swf.trace \ and-or-5.swf \ and-or-5.swf.trace \ and-or-6.swf \ diff --git a/test/trace/addProperty-set-prototypes-5.swf b/test/trace/addProperty-set-prototypes-5.swf new file mode 100644 index 0000000..956a6b1 Binary files /dev/null and b/test/trace/addProperty-set-prototypes-5.swf differ diff --git a/test/trace/addProperty-set-prototypes-5.swf.trace b/test/trace/addProperty-set-prototypes-5.swf.trace new file mode 100644 index 0000000..50d348c --- /dev/null +++ b/test/trace/addProperty-set-prototypes-5.swf.trace @@ -0,0 +1,4 @@ +Check how addProperty affects prototypes +10 +15 +15 diff --git a/test/trace/addProperty-set-prototypes-6.swf b/test/trace/addProperty-set-prototypes-6.swf new file mode 100644 index 0000000..22ca2dc Binary files /dev/null and b/test/trace/addProperty-set-prototypes-6.swf differ diff --git a/test/trace/addProperty-set-prototypes-6.swf.trace b/test/trace/addProperty-set-prototypes-6.swf.trace new file mode 100644 index 0000000..2d83ca9 --- /dev/null +++ b/test/trace/addProperty-set-prototypes-6.swf.trace @@ -0,0 +1,5 @@ +Check how addProperty affects prototypes +10 +10 +a set +10 diff --git a/test/trace/addProperty-set-prototypes-7.swf b/test/trace/addProperty-set-prototypes-7.swf new file mode 100644 index 0000000..e49f1e8 Binary files /dev/null and b/test/trace/addProperty-set-prototypes-7.swf differ diff --git a/test/trace/addProperty-set-prototypes-7.swf.trace b/test/trace/addProperty-set-prototypes-7.swf.trace new file mode 100644 index 0000000..2d83ca9 --- /dev/null +++ b/test/trace/addProperty-set-prototypes-7.swf.trace @@ -0,0 +1,5 @@ +Check how addProperty affects prototypes +10 +10 +a set +10 diff --git a/test/trace/addProperty-set-prototypes-8.swf b/test/trace/addProperty-set-prototypes-8.swf new file mode 100644 index 0000000..e3cf58f Binary files /dev/null and b/test/trace/addProperty-set-prototypes-8.swf differ diff --git a/test/trace/addProperty-set-prototypes-8.swf.trace b/test/trace/addProperty-set-prototypes-8.swf.trace new file mode 100644 index 0000000..2d83ca9 --- /dev/null +++ b/test/trace/addProperty-set-prototypes-8.swf.trace @@ -0,0 +1,5 @@ +Check how addProperty affects prototypes +10 +10 +a set +10 diff --git a/test/trace/addProperty-set-prototypes.as b/test/trace/addProperty-set-prototypes.as new file mode 100644 index 0000000..9cf4c38 --- /dev/null +++ b/test/trace/addProperty-set-prototypes.as @@ -0,0 +1,18 @@ +// makeswf -v 7 -s 200x150 -r 1 -o addProperty-set-prototypes.swf addProperty-set-prototypes.as + +trace ("Check how addProperty affects prototypes"); + +o = {name: "a"}; +o.__proto__ = {name: "b", x: 10 }; +o.__proto__.__proto__ = {name: "c"}; +o.__proto__.__proto__.__proto__ = {name: "d"}; +o.__proto__.__proto__.addProperty ("x", function () { trace (this.name); return 42; }, null); +o.__proto__.__proto__.__proto__.addProperty ("x", function () { trace (this.name); return 642; }, function () { trace (this.name + " set"); }); +trace (o.x); +o.x = 15; +trace (o.x); +o.__proto__.__proto__ = o.__proto__.__proto__.__proto__; +o.x = 15; +trace (o.x); + +loadMovie ("FSCommand:quit", ""); diff-tree d43d504a01b534233965d5c7fd851ae65ac5ce09 (from 01dc987b2068a641f131abed7da476b2f7fd852a) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 21:59:48 2007 +0200 fix property setting when addProperty had been called on parents diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index 64b8ff0..b1d06e5 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -139,6 +139,12 @@ swfdec_as_object_lookup_case_insensitive return strcasecmp (key, user_data) == 0; } +static gboolean +swfdec_as_variable_name_is_valid (const char *name) +{ + return name != SWFDEC_AS_STR_EMPTY; +} + static inline SwfdecAsVariable * swfdec_as_object_hash_lookup (SwfdecAsObject *object, const char *variable) { @@ -150,6 +156,21 @@ swfdec_as_object_hash_lookup (SwfdecAsOb return var; } +static inline SwfdecAsVariable * +swfdec_as_object_hash_create (SwfdecAsObject *object, const char *variable) +{ + SwfdecAsVariable *var; + + if (!swfdec_as_context_use_mem (object->context, sizeof (SwfdecAsVariable))) + return NULL; + if (!swfdec_as_variable_name_is_valid (variable)) + return NULL; + var = g_slice_new0 (SwfdecAsVariable); + g_hash_table_insert (object->properties, (gpointer) variable, var); + + return var; +} + static gboolean swfdec_as_object_do_get (SwfdecAsObject *object, const char *variable, SwfdecAsValue *val, guint *flags) @@ -173,26 +194,14 @@ swfdec_as_object_do_get (SwfdecAsObject return TRUE; } -static gboolean -swfdec_as_variable_name_is_valid (const char *name) -{ - return name != SWFDEC_AS_STR_EMPTY; -} - static SwfdecAsVariable * swfdec_as_object_lookup_variable (SwfdecAsObject *object, const char *variable) { SwfdecAsVariable *var; var = swfdec_as_object_hash_lookup (object, variable); - if (var == NULL) { - if (!swfdec_as_context_use_mem (object->context, sizeof (SwfdecAsVariable))) - return NULL; - if (!swfdec_as_variable_name_is_valid (variable)) - return NULL; - var = g_slice_new0 (SwfdecAsVariable); - g_hash_table_insert (object->properties, (gpointer) variable, var); - } + if (var == NULL) + var = swfdec_as_object_hash_create (object, variable); return var; } @@ -214,9 +223,28 @@ swfdec_as_object_do_set (SwfdecAsObject } } - var = swfdec_as_object_lookup_variable (object, variable); - if (var == NULL) - return; + var = swfdec_as_object_hash_lookup (object, variable); + if (var == NULL) { + guint i; + SwfdecAsObject *proto = object->prototype; + + for (i = 0; i < 256 && proto; i++) { + var = swfdec_as_object_hash_lookup (proto, variable); + if (var && var->get) + break; + proto = proto->prototype; + var = NULL; + } + if (i == 256) { + swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded"); + return; + } + } + if (var == NULL) { + var = swfdec_as_object_hash_create (object, variable); + if (var == NULL) + return; + } if (var->flags & SWFDEC_AS_VARIABLE_READONLY) return; if (var->get) { diff-tree 01dc987b2068a641f131abed7da476b2f7fd852a (from 130724227041a0e3916529bd498b207986880838) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 19:01:48 2007 +0200 add test for last commit diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index e3168fe..7e72228 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -740,6 +740,15 @@ EXTRA_DIST = \ place-object-remove-name-7.swf.trace \ preload.swf \ preload.swf.trace \ + property-native.as \ + property-native-5.swf \ + property-native-5.swf.trace \ + property-native-6.swf \ + property-native-6.swf.trace \ + property-native-7.swf \ + property-native-7.swf.trace \ + property-native-8.swf \ + property-native-8.swf.trace \ prototype-movie.as \ prototype-movie-5.swf \ prototype-movie-5.swf.trace \ diff --git a/test/trace/property-native-5.swf b/test/trace/property-native-5.swf new file mode 100644 index 0000000..e70f266 Binary files /dev/null and b/test/trace/property-native-5.swf differ diff --git a/test/trace/property-native-5.swf.trace b/test/trace/property-native-5.swf.trace new file mode 100644 index 0000000..c64601c --- /dev/null +++ b/test/trace/property-native-5.swf.trace @@ -0,0 +1,4 @@ +Check how addProperty overwrites native properties +0 +0 +10 diff --git a/test/trace/property-native-6.swf b/test/trace/property-native-6.swf new file mode 100644 index 0000000..a875d5e Binary files /dev/null and b/test/trace/property-native-6.swf differ diff --git a/test/trace/property-native-6.swf.trace b/test/trace/property-native-6.swf.trace new file mode 100644 index 0000000..bcc092c --- /dev/null +++ b/test/trace/property-native-6.swf.trace @@ -0,0 +1,4 @@ +Check how addProperty overwrites native properties +0 +42 +42 diff --git a/test/trace/property-native-7.swf b/test/trace/property-native-7.swf new file mode 100644 index 0000000..5e0b535 Binary files /dev/null and b/test/trace/property-native-7.swf differ diff --git a/test/trace/property-native-7.swf.trace b/test/trace/property-native-7.swf.trace new file mode 100644 index 0000000..bcc092c --- /dev/null +++ b/test/trace/property-native-7.swf.trace @@ -0,0 +1,4 @@ +Check how addProperty overwrites native properties +0 +42 +42 diff --git a/test/trace/property-native-8.swf b/test/trace/property-native-8.swf new file mode 100644 index 0000000..d081fd9 Binary files /dev/null and b/test/trace/property-native-8.swf differ diff --git a/test/trace/property-native-8.swf.trace b/test/trace/property-native-8.swf.trace new file mode 100644 index 0000000..bcc092c --- /dev/null +++ b/test/trace/property-native-8.swf.trace @@ -0,0 +1,4 @@ +Check how addProperty overwrites native properties +0 +42 +42 diff --git a/test/trace/property-native.as b/test/trace/property-native.as new file mode 100644 index 0000000..a987b1b --- /dev/null +++ b/test/trace/property-native.as @@ -0,0 +1,11 @@ +// makeswf -v 7 -s 200x150 -r 1 -o property-native.swf property-native.as + +trace ("Check how addProperty overwrites native properties"); +this.__proto__._x = 42; +trace (this._x); +this.addProperty ("_x", function () { return 42; }, function () { trace ("set"); }); +trace (this._x); +this._x = 10; +trace (this._x); + +loadMovie ("FSCommand:quit", ""); diff-tree 130724227041a0e3916529bd498b207986880838 (from d930fe50031d06c34edff598697220405ce7e88b) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 18:55:52 2007 +0200 query own properties before doing special ones diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c index 42444b7..776e2b1 100644 --- a/libswfdec/swfdec_movie.c +++ b/libswfdec/swfdec_movie.c @@ -849,14 +849,14 @@ swfdec_movie_get_variable (SwfdecAsObjec if (movie->state == SWFDEC_MOVIE_STATE_DESTROYED) return FALSE; + if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, variable, val, flags)) + return TRUE; + if (swfdec_movie_get_asprop (movie, variable, val)) { *flags = 0; return TRUE; } - if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, variable, val, flags)) - return TRUE; - /* FIXME: check that this is correct */ if (object->context->version > 5 && variable == SWFDEC_AS_STR__global) { SWFDEC_AS_VALUE_SET_OBJECT (val, object->context->global); diff-tree d930fe50031d06c34edff598697220405ce7e88b (from 261b8c34898a7a4cd6b89a11acc08bfb0a5c35d2) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 16:03:40 2007 +0200 add check that sets movie as prototype diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 3481072..e3168fe 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -740,6 +740,15 @@ EXTRA_DIST = \ place-object-remove-name-7.swf.trace \ preload.swf \ preload.swf.trace \ + prototype-movie.as \ + prototype-movie-5.swf \ + prototype-movie-5.swf.trace \ + prototype-movie-6.swf \ + prototype-movie-6.swf.trace \ + prototype-movie-7.swf \ + prototype-movie-7.swf.trace \ + prototype-movie-8.swf \ + prototype-movie-8.swf.trace \ prototypes.swf \ prototypes.swf.trace \ register-count.swf \ diff --git a/test/trace/prototype-movie-5.swf b/test/trace/prototype-movie-5.swf new file mode 100644 index 0000000..d6e8053 Binary files /dev/null and b/test/trace/prototype-movie-5.swf differ diff --git a/test/trace/prototype-movie-5.swf.trace b/test/trace/prototype-movie-5.swf.trace new file mode 100644 index 0000000..84187bf --- /dev/null +++ b/test/trace/prototype-movie-5.swf.trace @@ -0,0 +1,4 @@ +Check that movies cannot be prototypes +undefined +undefined +undefined diff --git a/test/trace/prototype-movie-6.swf b/test/trace/prototype-movie-6.swf new file mode 100644 index 0000000..41a4005 Binary files /dev/null and b/test/trace/prototype-movie-6.swf differ diff --git a/test/trace/prototype-movie-6.swf.trace b/test/trace/prototype-movie-6.swf.trace new file mode 100644 index 0000000..d8b7ab2 --- /dev/null +++ b/test/trace/prototype-movie-6.swf.trace @@ -0,0 +1,4 @@ +Check that movies cannot be prototypes +[type Function] +undefined +undefined diff --git a/test/trace/prototype-movie-7.swf b/test/trace/prototype-movie-7.swf new file mode 100644 index 0000000..434a42a Binary files /dev/null and b/test/trace/prototype-movie-7.swf differ diff --git a/test/trace/prototype-movie-7.swf.trace b/test/trace/prototype-movie-7.swf.trace new file mode 100644 index 0000000..d8b7ab2 --- /dev/null +++ b/test/trace/prototype-movie-7.swf.trace @@ -0,0 +1,4 @@ +Check that movies cannot be prototypes +[type Function] +undefined +undefined diff --git a/test/trace/prototype-movie-8.swf b/test/trace/prototype-movie-8.swf new file mode 100644 index 0000000..18f4e1b Binary files /dev/null and b/test/trace/prototype-movie-8.swf differ diff --git a/test/trace/prototype-movie-8.swf.trace b/test/trace/prototype-movie-8.swf.trace new file mode 100644 index 0000000..d8b7ab2 --- /dev/null +++ b/test/trace/prototype-movie-8.swf.trace @@ -0,0 +1,4 @@ +Check that movies cannot be prototypes +[type Function] +undefined +undefined diff --git a/test/trace/prototype-movie.as b/test/trace/prototype-movie.as new file mode 100644 index 0000000..92074b9 --- /dev/null +++ b/test/trace/prototype-movie.as @@ -0,0 +1,12 @@ +// makeswf -v 7 -s 200x150 -r 1 -o prototype-movie.swf movie6.as + +trace ("Check that movies cannot be prototypes"); + +o = new Object (); +this.foo = 42; +trace (o.addProperty); +o.__proto__ = this; +trace (o.foo); +trace (o.addProperty); + +loadMovie ("FSCommand:quit", ""); diff-tree 261b8c34898a7a4cd6b89a11acc08bfb0a5c35d2 (from 37ed222d6ea5305df2c238122be4e31a98af3229) Author: Benjamin Otte <otte at gnome.org> Date: Wed Aug 15 16:02:30 2007 +0200 movies cannot be prototypes diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index f7b0e98..64b8ff0 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -31,6 +31,7 @@ #include "swfdec_as_stack.h" #include "swfdec_as_strings.h" #include "swfdec_debug.h" +#include "swfdec_movie.h" /** * SECTION:SwfdecAsObject @@ -205,7 +206,8 @@ swfdec_as_object_do_set (SwfdecAsObject return; if (variable == SWFDEC_AS_STR___proto__) { - if (SWFDEC_AS_VALUE_IS_OBJECT (val)) { + if (SWFDEC_AS_VALUE_IS_OBJECT (val) && + !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (val))) { object->prototype = SWFDEC_AS_VALUE_GET_OBJECT (val); } else { object->prototype = NULL;
Maybe Matching Threads
- 163 commits - autogen.sh configure.ac doc/swfdec-sections.txt libswfdec-gtk/swfdec_gtk_player.c libswfdec-gtk/swfdec_gtk_player.h libswfdec-gtk/swfdec_gtk_widget.c libswfdec-gtk/swfdec_source.c libswfdec/Makefile.am libswfdec/swfdec_as_array.c
- Branch 'vivi' - 10 commits - libswfdec/swfdec_button_movie.c libswfdec/swfdec_movie.c libswfdec/swfdec_player.c vivified/core vivified/dock vivified/ui
- Branch 'vivi' - 13 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_debugger.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_script_function.c test/trace vivified/core vivified/ui
- Branch 'vivi' - 18 commits - configure.ac doc/swfdec-sections.txt libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_types.h libswfdec/swfdec_player.c vivified/core vivified/ui
- Branch 'vivi' - 24 commits - configure.ac libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_tag.c libswfdec/swfdec_tag.h vivified/core vivified/dock vivified/ui