[Swfdec] libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_types.c

Benjamin Otte company at kemper.freedesktop.org
Thu Nov 1 09:11:42 PDT 2007


 libswfdec/swfdec_as_interpret.c |    4 +--
 libswfdec/swfdec_as_object.c    |   44 ++++++++++++++++++++--------------------
 libswfdec/swfdec_as_object.h    |    3 +-
 libswfdec/swfdec_as_types.c     |    7 ++----
 4 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit f5d6530095d2df7b61a4cd49167729883d0376cb
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Nov 1 17:08:14 2007 +0100

    make swfdec_as_object_create() require a pointer to the return value

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 83634c6..234ba33 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1662,7 +1662,7 @@ swfdec_action_new_object (SwfdecAsContext *cx, guint action, const guint8 *data,
   }
 
   swfdec_as_stack_pop_n (cx, 2);
-  swfdec_as_object_create (fun, n_args, NULL);
+  swfdec_as_object_create (fun, n_args, NULL, NULL);
   return;
 
 fail:
@@ -1699,7 +1699,7 @@ swfdec_action_new_method (SwfdecAsContext *cx, guint action, const guint8 *data,
   }
 
   swfdec_as_stack_pop_n (cx, 3);
-  swfdec_as_object_create (fun, n_args, NULL);
+  swfdec_as_object_create (fun, n_args, NULL, NULL);
   return;
 
 fail:
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index d0709ac..665b608 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -1178,15 +1178,16 @@ swfdec_as_object_has_function (SwfdecAsObject *object, const char *name)
  * @fun: constructor
  * @n_args: number of arguments
  * @args: arguments to pass to constructor
+ * @return_value: pointer for return value or %NULL to push the return value to 
+ *                the stack
  *
  * Creates a new object for the given constructor and pushes the constructor on
  * top of the stack. To actually run the constructor, you need to call 
- * swfdec_as_context_run(). After the constructor has been run, the new object 
- * will be pushed to the top of the stack.
+ * swfdec_as_context_run().
  **/
 void
 swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args, 
-    const SwfdecAsValue *args)
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
   SwfdecAsValue val;
   SwfdecAsObject *new;
@@ -1225,26 +1226,25 @@ swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
     type = SWFDEC_TYPE_AS_OBJECT;
     size = sizeof (SwfdecAsObject);
   }
-  if (swfdec_as_context_use_mem (context, size)) {
-    new = g_object_new (type, NULL);
-    swfdec_as_object_add (new, context, size);
-    /* set initial variables */
-    if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype, &val)) {
-	swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___proto__,
-	    &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-    }
-    SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
-    if (context->version < 7) {
-      swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR_constructor, 
-	  &val, SWFDEC_AS_VARIABLE_HIDDEN);
-    }
-    swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___constructor__, 
-	&val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
-  } else {
-    /* need to do this, since we must push something to the frame stack */
-    new = NULL;
+  if (!swfdec_as_context_use_mem (context, size))
+    return;
+
+  new = g_object_new (type, NULL);
+  swfdec_as_object_add (new, context, size);
+  /* set initial variables */
+  if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype, &val)) {
+      swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___proto__,
+	  &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+  }
+  SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
+  if (context->version < 7) {
+    swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR_constructor, 
+	&val, SWFDEC_AS_VARIABLE_HIDDEN);
   }
-  swfdec_as_function_call (fun, new, n_args, args, NULL);
+  swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___constructor__, 
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
+
+  swfdec_as_function_call (fun, new, n_args, args, return_value);
   context->frame->construct = TRUE;
 }
 
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index 4fcddb4..8fec190 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -110,7 +110,8 @@ SwfdecAsObject *swfdec_as_object_new		(SwfdecAsContext *    	context);
 SwfdecAsObject *swfdec_as_object_new_empty    	(SwfdecAsContext *    	context);
 void		swfdec_as_object_create		(SwfdecAsFunction *	fun,
 						 guint			n_args,
-						 const SwfdecAsValue *	args);
+						 const SwfdecAsValue *	args,
+						 SwfdecAsValue *	return_value);
 void		swfdec_as_object_set_constructor(SwfdecAsObject *	object,
 						 SwfdecAsObject *	construct);
 SwfdecAsObject *swfdec_as_object_resolve	(SwfdecAsObject *	object);
diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c
index 409780a..cfc58a8 100644
--- a/libswfdec/swfdec_as_types.c
+++ b/libswfdec/swfdec_as_types.c
@@ -554,11 +554,10 @@ swfdec_as_value_to_object (SwfdecAsContext *context, const SwfdecAsValue *value)
   if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
       !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
     return NULL;
-  swfdec_as_object_create (fun, 1, value);
+  swfdec_as_object_create (fun, 1, value, &val);
   swfdec_as_context_run (context);
-  value = swfdec_as_stack_pop (context);
-  if (SWFDEC_AS_VALUE_IS_OBJECT (value)) {
-    return SWFDEC_AS_VALUE_GET_OBJECT (value);
+  if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+    return SWFDEC_AS_VALUE_GET_OBJECT (&val);
   } else {
     SWFDEC_ERROR ("did not construct an object");
     return NULL;


More information about the Swfdec mailing list