Benjamin Otte
2007-May-29 16:38 UTC
[Swfdec] Branch 'as' - 6 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_js_xml.c libswfdec/swfdec_tag.c player/swfplay.c
libswfdec/swfdec_as_interpret.c | 126 +++++++++++++++++----------------------- libswfdec/swfdec_js_xml.c | 2 libswfdec/swfdec_tag.c | 2 player/swfplay.c | 2 4 files changed, 60 insertions(+), 72 deletions(-) New commits: diff-tree 66f9ced7820cb09446dc493778fbd8348bfcb626 (from 33ee0a567aa0a7d9b287a5285527b436ae3fe560) Author: Benjamin Otte <otte at gnome.org> Date: Tue May 29 15:13:03 2007 +0200 this is just INFO, since 0-frame sprites are common diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c index 7df13f4..10a33b6 100644 --- a/libswfdec/swfdec_tag.c +++ b/libswfdec/swfdec_tag.c @@ -254,7 +254,7 @@ tag_func_define_sprite (SwfdecSwfDecoder /* sanity check the sprite */ if (s->parse_sprite->n_frames != s->parse_sprite->parse_frame) { - SWFDEC_ERROR ("not enough frames in sprite %u (have %u, want %u), filling up with empty frames", + SWFDEC_INFO ("not enough frames in sprite %u (have %u, want %u), filling up with empty frames", id, s->parse_sprite->parse_frame, s->parse_sprite->n_frames); s->parse_sprite->parse_frame = s->parse_sprite->n_frames; } diff-tree 33ee0a567aa0a7d9b287a5285527b436ae3fe560 (from 91a151966efb877bc00d769a59700857e8534353) Author: Benjamin Otte <otte at gnome.org> Date: Tue May 29 15:09:12 2007 +0200 implement Delete and Delete2 diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index 42479d2..abc4c8c 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1652,41 +1652,29 @@ swfdec_action_return (SwfdecAsContext *c swfdec_as_context_return (cx); } -#if 0 static void swfdec_action_delete (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { + SwfdecAsValue *val; const char *name; - cx->fp->sp -= 2; - name = swfdec_js_to_string (cx, cx->fp->sp[1]); - if (name == NULL) - return JS_FALSE; - if (!JSVAL_IS_OBJECT (cx->fp->sp[0])) - return JS_TRUE; - return JS_DeleteProperty (cx, JSVAL_TO_OBJECT (cx->fp->sp[0]), name); + name = swfdec_as_value_to_string (cx, swfdec_as_stack_pop (cx->frame->stack)); + val = swfdec_as_stack_pop (cx->frame->stack); + if (SWFDEC_AS_VALUE_IS_OBJECT (val)) + swfdec_as_object_delete_variable (SWFDEC_AS_VALUE_GET_OBJECT (val), name); } static void swfdec_action_delete2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { const char *name; - JSObject *obj, *pobj; - JSProperty *prop; - JSAtom *atom; + SwfdecAsObject *object; - cx->fp->sp -= 1; - name = swfdec_js_to_string (cx, cx->fp->sp[1]); - if (name == NULL) - return JS_FALSE; - if (!(atom = js_Atomize (cx, name, strlen (name), 0)) || - !js_FindProperty (cx, (jsid) atom, &obj, &pobj, &prop)) - return JS_FALSE; - if (!pobj) - return JS_TRUE; - return JS_DeleteProperty (cx, pobj, name); + name = swfdec_as_value_to_string (cx, swfdec_as_stack_pop (cx->frame->stack)); + object = swfdec_as_frame_find_variable (cx->frame, name); + if (object) + swfdec_as_object_delete_variable (object, name); } -#endif static void swfdec_action_store_register (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) @@ -2236,10 +2224,8 @@ const SwfdecActionSpec swfdec_as_actions [SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII] = { "MBCharToAscii", NULL }, [SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR] = { "MBAsciiToChar", NULL }, /* version 5 */ -#if 0 - [0x3a] = { "Delete", NULL, 2, 0, { NULL, NULL, swfdec_action_delete, swfdec_action_delete, swfdec_action_delete } }, - [0x3b] = { "Delete2", NULL, 1, 0, { NULL, NULL, swfdec_action_delete2, swfdec_action_delete2, swfdec_action_delete2 } }, -#endif + [SWFDEC_AS_ACTION_DELETE] = { "Delete", NULL, 2, 0, { NULL, NULL, swfdec_action_delete, swfdec_action_delete, swfdec_action_delete } }, + [SWFDEC_AS_ACTION_DELETE2] = { "Delete2", NULL, 1, 0, { NULL, NULL, swfdec_action_delete2, swfdec_action_delete2, swfdec_action_delete2 } }, [SWFDEC_AS_ACTION_DEFINE_LOCAL] = { "DefineLocal", NULL, 2, 0, { NULL, NULL, swfdec_action_define_local, swfdec_action_define_local, swfdec_action_define_local } }, [SWFDEC_AS_ACTION_CALL_FUNCTION] = { "CallFunction", NULL, -1, 1, { NULL, NULL, swfdec_action_call_function, swfdec_action_call_function, swfdec_action_call_function } }, [SWFDEC_AS_ACTION_RETURN] = { "Return", NULL, 1, 0, { NULL, NULL, swfdec_action_return, swfdec_action_return, swfdec_action_return } }, diff-tree 91a151966efb877bc00d769a59700857e8534353 (from e43ad1b2e784b00f6ba8b9955a32ee61388269b1) Author: Benjamin Otte <otte at gnome.org> Date: Tue May 29 14:57:43 2007 +0200 reimplement NewMethod action diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index b9e19ad..42479d2 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1327,54 +1327,44 @@ fail: SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx->frame->stack, 1)); } -#if 0 static void swfdec_action_new_method (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { - JSStackFrame *fp = cx->fp; - const char *s; - guint32 n_args; - JSObject *object; - jsval constructor; - - 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 (!JS_ValueToECMAUint32 (cx, fp->sp[-3], &n_args)) - return JS_FALSE; - - if (!JS_ValueToObject (cx, fp->sp[-2], &object)) - return JS_FALSE; - if (object == NULL) + SwfdecAsValue *constructor; + SwfdecAsFunction *fun; + guint n_args; + const char *name; + + swfdec_as_stack_ensure_size (cx->frame->stack, 3); + name = swfdec_as_value_to_string (cx, swfdec_as_stack_pop (cx->frame->stack)); + + constructor = swfdec_as_stack_pop (cx->frame->stack); + n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx->frame->stack, 1)); + n_args = MIN (swfdec_as_stack_get_size (cx->frame->stack) - 1, n_args); + if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) || + !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) { + SWFDEC_WARNING ("%s is not a constructor", name); goto fail; - if (s[0] == '\0') { - constructor = OBJECT_TO_JSVAL (object); - } else { - if (!JS_GetProperty (cx, object, s, &constructor)) - return JS_FALSE; - if (!JSVAL_IS_OBJECT (constructor)) { - SWFDEC_WARNING ("%s:%s is not a function", JS_GetClass (object)->name, s); + } + if (name != SWFDEC_AS_STR_EMPTY) { + if (SWFDEC_AS_VALUE_IS_OBJECT (constructor)) { + swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (constructor), + name, constructor); } } - fp->sp[-1] = OBJECT_TO_JSVAL (constructor); - if (!swfdec_js_construct_object (cx, NULL, constructor, &object)) - return JS_FALSE; - if (object == NULL) + if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) || + !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) { + SWFDEC_WARNING ("%s is not a constructor", name); goto fail; - fp->sp[-2] = OBJECT_TO_JSVAL (object); - if (!swfdec_action_call (cx, n_args, JSINVOKE_CONSTRUCT)) - return JS_FALSE; - fp->sp[-1] = OBJECT_TO_JSVAL (object); - return JS_TRUE; + } + + swfdec_action_create (fun, n_args); + return; fail: - fp->sp -= 2 + n_args; - fp->sp[-1] = JSVAL_VOID; - return JS_TRUE; + swfdec_as_stack_pop_n (cx->frame->stack, n_args); + SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx->frame->stack, 1)); } -#endif static void swfdec_action_init_object (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) @@ -2275,10 +2265,8 @@ const SwfdecActionSpec swfdec_as_actions [SWFDEC_AS_ACTION_INCREMENT] = { "Increment", NULL, 1, 1, { NULL, NULL, swfdec_action_increment, swfdec_action_increment, swfdec_action_increment } }, [SWFDEC_AS_ACTION_DECREMENT] = { "Decrement", NULL, 1, 1, { NULL, NULL, swfdec_action_decrement, swfdec_action_decrement, swfdec_action_decrement } }, [SWFDEC_AS_ACTION_CALL_METHOD] = { "CallMethod", NULL, -1, 1, { NULL, NULL, swfdec_action_call_method, swfdec_action_call_method, swfdec_action_call_method } }, -#if 0 - [0x53] = { "NewMethod", NULL, -1, 1, { NULL, NULL, swfdec_action_new_method, swfdec_action_new_method, swfdec_action_new_method } }, + [SWFDEC_AS_ACTION_NEW_METHOD] = { "NewMethod", NULL, -1, 1, { NULL, NULL, swfdec_action_new_method, swfdec_action_new_method, swfdec_action_new_method } }, /* version 6 */ -#endif [SWFDEC_AS_ACTION_INSTANCE_OF] = { "InstanceOf", NULL }, [SWFDEC_AS_ACTION_ENUMERATE2] = { "Enumerate2", NULL, 1, -1, { NULL, NULL, NULL, swfdec_action_enumerate2, swfdec_action_enumerate2 } }, /* version 5 */ diff-tree e43ad1b2e784b00f6ba8b9955a32ee61388269b1 (from df33e9b5c1cf59dafab3a0dd3518e825df80e714) Author: Benjamin Otte <otte at gnome.org> Date: Tue May 29 14:45:58 2007 +0200 handle NaN == NaN diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index 3f81944..b9e19ad 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1055,7 +1055,10 @@ swfdec_action_equals2_5 (SwfdecAsContext } /* else compare as numbers */ - cond = l == r; + if (isnan (l) && isnan (r)) + cond = ltype == rtype; + else + cond = l == r; out: swfdec_as_stack_pop (cx->frame->stack); @@ -1138,7 +1141,11 @@ swfdec_action_equals2 (SwfdecAsContext * /* else compare as numbers */ l = swfdec_as_value_to_number (cx, lval); r = swfdec_as_value_to_number (cx, rval); - cond = l == r; + + if (isnan (l) && isnan (r)) + cond = ltype == rtype; + else + cond = l == r; out: swfdec_as_stack_pop (cx->frame->stack); @@ -1166,7 +1173,12 @@ swfdec_action_strict_equals (SwfdecAsCon cond = SWFDEC_AS_VALUE_GET_BOOLEAN (rval) == SWFDEC_AS_VALUE_GET_BOOLEAN (lval); break; case SWFDEC_AS_TYPE_NUMBER: - cond = SWFDEC_AS_VALUE_GET_NUMBER (rval) == SWFDEC_AS_VALUE_GET_NUMBER (lval); + { + double l, r; + r = SWFDEC_AS_VALUE_GET_NUMBER (rval); + l = SWFDEC_AS_VALUE_GET_NUMBER (lval); + cond = (l == r) || (isnan (l) && isnan (r)); + } break; case SWFDEC_AS_TYPE_STRING: cond = SWFDEC_AS_VALUE_GET_STRING (rval) == SWFDEC_AS_VALUE_GET_STRING (lval); diff-tree df33e9b5c1cf59dafab3a0dd3518e825df80e714 (from parents) Merge: 0d9fe11f2441d5fa448c46d5b770dd213566825d abce336a0b32f84a97e5a6621b634833ed78a49c Author: Benjamin Otte <otte at gnome.org> Date: Tue May 29 13:47:19 2007 +0200 Merge branch 'as' of ssh://company at git.freedesktop.org/git/swfdec into as diff-tree 0d9fe11f2441d5fa448c46d5b770dd213566825d (from dc6c1becbfb201aa15c126c05ba38e4c772fac80) Author: Benjamin Otte <otte at gnome.org> Date: Tue May 29 13:46:32 2007 +0200 merge master diff --git a/libswfdec/swfdec_js_xml.c b/libswfdec/swfdec_js_xml.c index 59632b6..92da66e 100644 --- a/libswfdec/swfdec_js_xml.c +++ b/libswfdec/swfdec_js_xml.c @@ -32,7 +32,7 @@ swfdec_js_xml_load (JSContext *cx, JSObj SwfdecXml *xml; const char *url; - xml = JS_GetPrivate (cx, obj); + xml = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_XML); if (xml == NULL) return JS_TRUE; url = swfdec_js_to_string (cx, argv[0]); diff --git a/player/swfplay.c b/player/swfplay.c index 0c2e062..46737ae 100644 --- a/player/swfplay.c +++ b/player/swfplay.c @@ -122,6 +122,8 @@ main (int argc, char *argv[]) #else loader = swfdec_gtk_loader_new (argv[1]); #endif + g_object_unref (loader); + loader = swfdec_loader_new_from_file (argv[1]); if (loader->error) { g_printerr ("Couldn't open file \"%s\": %s\n", argv[1], loader->error); g_object_unref (loader);
Maybe Matching Threads
- Branch 'as' - 4 commits - libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_interpret.h libswfdec/swfdec_as_object.c libswfdec/swfdec_as_types.c libswfdec/swfdec_as_types.h
- 11 commits - configure.ac libswfdec/swfdec_js_movie.c libswfdec/swfdec_root_movie.c libswfdec/swfdec_root_movie.h libswfdec/swfdec_script.c libswfdec/swfdec_sprite.c libswfdec/swfdec_sprite.h libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_swf_decoder.c
- 10 commits - libswfdec/js libswfdec/swfdec_js_color.c libswfdec/swfdec_js_connection.c libswfdec/swfdec_js_movie.c libswfdec/swfdec_js_net_stream.c libswfdec/swfdec_js_video.c libswfdec/swfdec_js_xml.c libswfdec/swfdec_script.c player/.gitignore
- 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
- 11 commits - libswfdec/swfdec_font.c libswfdec/swfdec_font.h libswfdec/swfdec_js_movie.c libswfdec/swfdec_script.c libswfdec/swfdec_script.h test/.gitignore test/trace