Benjamin Otte
2007-Mar-07 03:35 UTC
[Swfdec] 2 commits - libswfdec/swfdec_script.c test/trace
libswfdec/swfdec_script.c | 14 ++++++++++++-- test/trace/Makefile.am | 2 ++ test/trace/gotoframe.swf |binary test/trace/gotoframe.swf.trace | 13 +++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) New commits: diff-tree 12348410a3509928a6e8e4c8ca00292a58ff542c (from 46e62d4410c20c19774a45758d8ebf11cd0bdf96) Author: Benjamin Otte <otte@gnome.org> Date: Wed Mar 7 12:35:34 2007 +0100 add GotoFrame2 test diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 2368dc6..a0fa2ca 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -69,6 +69,8 @@ EXTRA_DIST = \ goto4.swf.trace \ goto5.swf \ goto5.swf.trace \ + gotoframe.swf \ + gotoframe.swf.trace \ height1.swf \ height1.swf.trace \ height2.swf \ diff --git a/test/trace/gotoframe.swf b/test/trace/gotoframe.swf new file mode 100755 index 0000000..0aa1970 Binary files /dev/null and b/test/trace/gotoframe.swf differ diff --git a/test/trace/gotoframe.swf.trace b/test/trace/gotoframe.swf.trace new file mode 100755 index 0000000..db5fe6d --- /dev/null +++ b/test/trace/gotoframe.swf.trace @@ -0,0 +1,13 @@ +Check the effect of various GotoFrame2 commands +6 +6 +6 +12 +15 +14 +14 +4 +4 +4 +4 +15 diff-tree 46e62d4410c20c19774a45758d8ebf11cd0bdf96 (from a4cbb09c7024047e4b128d87f5d27325adcfe2a0) Author: Benjamin Otte <otte@gnome.org> Date: Wed Mar 7 12:34:24 2007 +0100 fix swfdec_value_to_frame to handle weird cases diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c index 88b1b1d..7d93740 100644 --- a/libswfdec/swfdec_script.c +++ b/libswfdec/swfdec_script.c @@ -291,16 +291,26 @@ swfdec_value_to_frame (JSContext *cx, Sw if (JSVAL_IS_STRING (val)) { const char *name = swfdec_js_to_string (cx, val); + char *end; if (name == NULL || !SWFDEC_IS_SPRITE_MOVIE (movie)) return -1; if (strchr (name, ':')) { SWFDEC_ERROR ("FIXME: handle targets"); } - frame = swfdec_sprite_get_frame (SWFDEC_SPRITE_MOVIE (movie)->sprite, name); + /* treat valid encoded numbers as numbers, otherwise assume it's a frame label */ + frame = strtol (name, &end, 0); + if (*end != '\0') + frame = swfdec_sprite_get_frame (SWFDEC_SPRITE_MOVIE (movie)->sprite, name); + else + frame--; + } else if (JSVAL_IS_INT (val)) { + return JSVAL_TO_INT (val) - 1; + } else if (JSVAL_IS_DOUBLE (val)) { + return (int) *JSVAL_TO_DOUBLE (val) - 1; } else { /* FIXME: how do we treat undefined etc? */ - frame = swfdec_value_to_number (cx, val); + frame = -1; } return frame; }
Benjamin Otte
2007-Mar-12 08:18 UTC
[Swfdec] 2 commits - libswfdec/swfdec_script.c test/trace
libswfdec/swfdec_script.c | 46 ++++++++++++++++++++++++++++++++---- test/trace/Makefile.am | 5 +++ test/trace/extends-simple.swf |binary test/trace/extends-simple.swf.trace | 5 +++ test/trace/extends-super.swf |binary test/trace/extends-super.swf.trace | 9 +++++++ 6 files changed, 60 insertions(+), 5 deletions(-) New commits: diff-tree a4707072b71463188e6fa49a397f893fc9ad5b89 (from abde74daded99c21e3992f8171f2748f8aef8ba6) Author: Benjamin Otte <otte@gnome.org> Date: Mon Mar 12 16:18:17 2007 +0100 Add 2 new tests for ActionExtends diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 7b65208..1994892 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -57,7 +57,12 @@ EXTRA_DIST = \ empty-stack.as \ empty-stack.swf \ empty-stack.swf.trace \ + event-order.swf \ event-order.swf.trace \ + extends-simple.swf \ + extends-simple.swf.trace \ + extends-super.swf \ + extends-super.swf.trace \ function1.swf \ function1.swf.trace \ function2.swf \ diff --git a/test/trace/extends-simple.swf b/test/trace/extends-simple.swf new file mode 100755 index 0000000..96b8edc Binary files /dev/null and b/test/trace/extends-simple.swf differ diff --git a/test/trace/extends-simple.swf.trace b/test/trace/extends-simple.swf.trace new file mode 100755 index 0000000..1c7149e --- /dev/null +++ b/test/trace/extends-simple.swf.trace @@ -0,0 +1,5 @@ +Check simple inheritance +constructed a Simple +constructed a Sub +called Sub.trace +called Simple.trace diff --git a/test/trace/extends-super.swf b/test/trace/extends-super.swf new file mode 100755 index 0000000..de49a32 Binary files /dev/null and b/test/trace/extends-super.swf differ diff --git a/test/trace/extends-super.swf.trace b/test/trace/extends-super.swf.trace new file mode 100755 index 0000000..53ab226 --- /dev/null +++ b/test/trace/extends-super.swf.trace @@ -0,0 +1,9 @@ +Check how super works +it's me +constructed a Sub +called Sub.trace +called Simple.trace +it's me +constructed a Sub +called Sub.trace +it's me diff-tree abde74daded99c21e3992f8171f2748f8aef8ba6 (from 03fccd9bc1924e4e128d1d0d6454a867991fd623) Author: Benjamin Otte <otte@gnome.org> Date: Mon Mar 12 16:17:01 2007 +0100 implement ActionExtends also includes: - implement preloading super - make CallMethod treat the method name being undefined as empty string diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c index 4b17af1..ac4921c 100644 --- a/libswfdec/swfdec_script.c +++ b/libswfdec/swfdec_script.c @@ -719,9 +719,13 @@ swfdec_action_call_method (JSContext *cx if (!swfdec_script_ensure_stack (cx, 3)) return JS_FALSE; - s = swfdec_js_to_string (cx, fp->sp[-1]); - if (s == NULL) - return JS_FALSE; + if (fp->sp[-1] == JSVAL_VOID) { + s = ""; + } else { + s = swfdec_js_to_string (cx, fp->sp[-1]); + if (s == NULL) + return JS_FALSE; + } if (!JS_ValueToECMAUint32 (cx, fp->sp[-3], &n_args)) return JS_FALSE; @@ -1979,6 +1983,33 @@ swfdec_action_get_time (JSContext *cx, g return JS_TRUE; } +static JSBool +swfdec_action_extends (JSContext *cx, guint action, const guint8 *data, guint len) +{ + jsval superclass, subclass, proto; + JSObject *prototype; + + superclass = cx->fp->sp[-1]; + subclass = cx->fp->sp[-2]; + cx->fp->sp -= 2; + if (!JSVAL_IS_OBJECT (superclass) || superclass == JSVAL_NULL || + !JSVAL_IS_OBJECT (subclass) || subclass == JSVAL_NULL) { + SWFDEC_ERROR ("superclass or subclass aren't objects"); + return JS_TRUE; + } + if (!JS_GetProperty (cx, JSVAL_TO_OBJECT (superclass), "prototype", &proto) || + !JSVAL_IS_OBJECT (proto)) + return JS_FALSE; + prototype = JS_NewObject (cx, NULL, JSVAL_TO_OBJECT (proto), NULL); + if (prototype == NULL) + return JS_FALSE; + proto = OBJECT_TO_JSVAL (prototype); + if (!JS_SetProperty (cx, prototype, "__constructor__", &superclass) || + !JS_SetProperty (cx, JSVAL_TO_OBJECT (subclass), "prototype", &proto)) + return JS_FALSE; + return JS_TRUE; +} + /*** PRINT FUNCTIONS ***/ static char * @@ -2365,7 +2396,7 @@ static const SwfdecActionSpec actions[25 [0x67] = { "Greater", NULL, 2, 1, { NULL, NULL, NULL, swfdec_action_new_comparison_6, swfdec_action_new_comparison_7 } }, [0x68] = { "StringGreater", NULL }, /* version 7 */ - [0x69] = { "Extends", NULL }, + [0x69] = { "Extends", NULL, 2, 0, { NULL, NULL, NULL, NULL, swfdec_action_extends } }, /* version 3 */ [0x81] = { "GotoFrame", swfdec_action_print_goto_frame, 0, 0, { swfdec_action_goto_frame, swfdec_action_goto_frame, swfdec_action_goto_frame, swfdec_action_goto_frame, swfdec_action_goto_frame } }, @@ -2627,7 +2658,12 @@ swfdec_script_interpret (SwfdecScript *s fp->flags |= JS_BIT (JSFRAME_OVERRIDE_SHIFT); } if (script->flags & SWFDEC_SCRIPT_PRELOAD_SUPER) { - SWFDEC_ERROR ("preloading super isn't implemented"); + if (!JS_GetProperty (cx, JS_GetPrototype (cx, fp->thisp), + fp->flags & JSINVOKE_CONSTRUCT ? "__constructor__" : "__proto__", + &fp->vars[preload_reg++])) { + ok = JS_FALSE; + goto out; + } } if (script->flags & SWFDEC_SCRIPT_PRELOAD_ROOT) { JSAtom *atom;
Reasonably Related Threads
- Branch 'interpreter' - 2 commits - libswfdec/js libswfdec/swfdec_js_movie.c libswfdec/swfdec_script.c
- SwfDec in Windows
- 14 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_interpret.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_script.c libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_tag.c libswfdec/swfdec_text_field_movie.c
- Branch 'interpreter' - 8 commits - libswfdec/swfdec_bits.c libswfdec/swfdec_bits.h libswfdec/swfdec_js.c libswfdec/swfdec_js.h libswfdec/swfdec_script.c test/swfdec_out.c test/swfdec_out.h test/swfedit_tag.c test/swfedit_token.c test/swfedit_token.h
- Branch 'as' - 2 commits - libswfdec/swfdec_as_interpret.c