[Swfdec] 4 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_boolean.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_number.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_string.c libswfdec/swfdec_color_as.c test/trace

Pekka Lampila medar at kemper.freedesktop.org
Tue Aug 21 14:11:05 PDT 2007


 libswfdec/swfdec_as_array.c    |    3 ++-
 libswfdec/swfdec_as_boolean.c  |    3 ++-
 libswfdec/swfdec_as_function.c |   13 ++++++++-----
 libswfdec/swfdec_as_number.c   |   14 ++++++++++----
 libswfdec/swfdec_as_object.c   |   19 ++++++++++++++-----
 libswfdec/swfdec_as_string.c   |    6 ++++--
 libswfdec/swfdec_color_as.c    |   11 ++++++++---
 test/trace/propflags-5.swf     |binary
 test/trace/propflags-6.swf     |binary
 test/trace/propflags-7.swf     |binary
 test/trace/propflags.as        |    6 +-----
 test/trace/trace.c             |    2 +-
 test/trace/trace_properties.as |    5 +++--
 13 files changed, 53 insertions(+), 29 deletions(-)

New commits:
diff-tree 7c86c8ada24c3ba63a98036f901bf5c92487447d (from 881535b3416be86eb7fea7449b29ee7a09d7c106)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Wed Aug 22 00:10:10 2007 +0300

    Set some property flags, mostly for __proto__

diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index 495bff1..81ef701 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -1107,7 +1107,8 @@ swfdec_as_array_init_context (SwfdecAsCo
 
   /* set the right properties on the Array.prototype object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR___proto__, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, array);
   swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString, 0,
diff --git a/libswfdec/swfdec_as_boolean.c b/libswfdec/swfdec_as_boolean.c
index 907960a..18872cb 100644
--- a/libswfdec/swfdec_as_boolean.c
+++ b/libswfdec/swfdec_as_boolean.c
@@ -103,7 +103,8 @@ swfdec_as_boolean_init_context (SwfdecAs
   swfdec_as_object_set_variable (boolean, SWFDEC_AS_STR_constructor, &val);
   /* set the right properties on the Boolean.prototype object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR___proto__, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, boolean);
   swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_toString, 0);
diff --git a/libswfdec/swfdec_as_function.c b/libswfdec/swfdec_as_function.c
index 3e9b6dd..55a9ea3 100644
--- a/libswfdec/swfdec_as_function.c
+++ b/libswfdec/swfdec_as_function.c
@@ -97,7 +97,8 @@ swfdec_as_function_create (SwfdecAsConte
   }
   if (context->Function_prototype) {
     SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function_prototype);
-    swfdec_as_object_set_variable (fun, SWFDEC_AS_STR___proto__, &val);
+    swfdec_as_object_set_variable_and_flags (fun, SWFDEC_AS_STR___proto__,
+	&val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   }
 
   return SWFDEC_AS_FUNCTION (fun);
@@ -194,11 +195,13 @@ swfdec_as_function_init_context (SwfdecA
       return;
     context->Function_prototype = proto;
     SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
-    swfdec_as_object_set_variable (function, SWFDEC_AS_STR___proto__, &val);
-    swfdec_as_object_set_variable (function, SWFDEC_AS_STR_prototype, &val);
+    swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR___proto__,
+	&val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+    swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR_prototype,
+	&val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
     /* prototype functions */
-    swfdec_as_object_add_function (proto, SWFDEC_AS_STR_call, SWFDEC_TYPE_AS_FUNCTION, 
-	swfdec_as_function_do_call, 0);
+    swfdec_as_object_add_function (proto, SWFDEC_AS_STR_call,
+	SWFDEC_TYPE_AS_FUNCTION, swfdec_as_function_do_call, 0);
   }
 }
 
diff --git a/libswfdec/swfdec_as_number.c b/libswfdec/swfdec_as_number.c
index bc0b8cf..d0437b8 100644
--- a/libswfdec/swfdec_as_number.c
+++ b/libswfdec/swfdec_as_number.c
@@ -108,9 +108,13 @@ swfdec_as_number_init_context (SwfdecAsC
   proto = swfdec_as_object_new (context);
   /* set the right properties on the Number object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
-  swfdec_as_object_set_variable (number, SWFDEC_AS_STR_prototype, &val);
+  swfdec_as_object_set_variable_and_flags (number, SWFDEC_AS_STR_prototype,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function);
-  swfdec_as_object_set_variable (number, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable_and_flags (number, SWFDEC_AS_STR_constructor,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   SWFDEC_AS_VALUE_SET_NUMBER (&val, NAN);
   swfdec_as_object_set_variable (number, SWFDEC_AS_STR_NaN, &val);
   SWFDEC_AS_VALUE_SET_NUMBER (&val, G_MAXDOUBLE);
@@ -123,9 +127,11 @@ swfdec_as_number_init_context (SwfdecAsC
   swfdec_as_object_set_variable (number, SWFDEC_AS_STR_POSITIVE_INFINITY, &val);
   /* set the right properties on the Number.prototype object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR___proto__, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, number);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString, SWFDEC_TYPE_AS_NUMBER, swfdec_as_number_toString, 0);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_valueOf, SWFDEC_TYPE_AS_NUMBER, swfdec_as_number_valueOf, 0);
 }
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 83ad4cf..873c3cd 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -494,9 +494,13 @@ swfdec_as_object_new (SwfdecAsContext *c
   
   object = swfdec_as_object_new_empty (context);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
-  swfdec_as_object_set_variable (object, SWFDEC_AS_STR___proto__, &val);
+  swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object);
-  swfdec_as_object_set_variable (object, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   return object;
 }
 
@@ -1104,12 +1108,17 @@ swfdec_as_object_init_context (SwfdecAsC
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
   if (context->Function_prototype) {
     /* first, finish the function prototype */
-    swfdec_as_object_set_variable (context->Function_prototype, SWFDEC_AS_STR___proto__, &val);
+    swfdec_as_object_set_variable_and_flags (context->Function_prototype,
+	SWFDEC_AS_STR___proto__, &val,
+	SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   }
   /* now, set our own */
-  swfdec_as_object_set_variable (object, SWFDEC_AS_STR_prototype, &val);
+  swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_prototype,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
 
   if (version > 5) {
     swfdec_as_object_add_function (proto, SWFDEC_AS_STR_addProperty, 
diff --git a/libswfdec/swfdec_as_string.c b/libswfdec/swfdec_as_string.c
index 720bc5c..ab70a38 100644
--- a/libswfdec/swfdec_as_string.c
+++ b/libswfdec/swfdec_as_string.c
@@ -711,9 +711,11 @@ swfdec_as_string_init_context (SwfdecAsC
 
   /* set the right properties on the String.prototype object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR___proto__, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, string);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_charAt, SWFDEC_TYPE_AS_STRING, swfdec_as_string_charAt, 1);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_indexOf, SWFDEC_TYPE_AS_STRING, swfdec_as_string_indexOf, 1);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_charCodeAt, SWFDEC_TYPE_AS_STRING, swfdec_as_string_charCodeAt, 1);
diff --git a/libswfdec/swfdec_color_as.c b/libswfdec/swfdec_color_as.c
index 3abf5f9..06b7d5c 100644
--- a/libswfdec/swfdec_color_as.c
+++ b/libswfdec/swfdec_color_as.c
@@ -204,12 +204,17 @@ swfdec_movie_color_init_context (SwfdecP
   swfdec_as_object_add (proto, context, sizeof (SwfdecMovieColor));
   /* set the right properties on the Color object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
-  swfdec_as_object_set_variable (color, SWFDEC_AS_STR_prototype, &val);
+  swfdec_as_object_set_variable_and_flags (color, SWFDEC_AS_STR_prototype, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   /* set the right properties on the Color.prototype object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR___proto__, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, color);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+      SWFDEC_AS_VARIABLE_CONSTANT);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_getRGB, SWFDEC_TYPE_MOVIE_COLOR,
       swfdec_movie_color_getRGB, 0);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_getTransform, SWFDEC_TYPE_MOVIE_COLOR,
diff-tree 881535b3416be86eb7fea7449b29ee7a09d7c106 (from cbc47ba95627cedece316a1d0eea0ae993be2d5b)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Wed Aug 22 00:05:31 2007 +0300

    Another small fix to trace_properties.as

diff --git a/test/trace/trace_properties.as b/test/trace/trace_properties.as
index a93f05c..5c6f171 100644
--- a/test/trace/trace_properties.as
+++ b/test/trace/trace_properties.as
@@ -16,8 +16,8 @@ function hasOwnProperty (o, prop)
   if (o.hasOwnProperty != undefined)
     return o.hasOwnProperty (prop);
 
-  o.hasOwnProperty = Object.prototype.hasOwnProperty;
-  result = o.hasOwnProperty (prop);
+  o.hasOwnProperty = _global.Object.prototype.hasOwnProperty;
+  var result = o.hasOwnProperty (prop);
   delete o.hasOwnProperty;
   return result;
 }
diff-tree cbc47ba95627cedece316a1d0eea0ae993be2d5b (from 9c1568477d8c26d87239f58b6b75091b36059ae1)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Aug 21 23:19:44 2007 +0300

    Fix one more error in trace_properties.as
    
    In trace_properties.as's new_empty_object set value to string before deleting
    to allow all things to be deleted in all version
    Use new_empty_object in propflags.as too, instead of writing it out again there

diff --git a/test/trace/propflags-5.swf b/test/trace/propflags-5.swf
index acea9ad..3648a4f 100644
Binary files a/test/trace/propflags-5.swf and b/test/trace/propflags-5.swf differ
diff --git a/test/trace/propflags-6.swf b/test/trace/propflags-6.swf
index ea5e27b..bb8f6ef 100644
Binary files a/test/trace/propflags-6.swf and b/test/trace/propflags-6.swf differ
diff --git a/test/trace/propflags-7.swf b/test/trace/propflags-7.swf
index ee97994..3bcd68d 100644
Binary files a/test/trace/propflags-7.swf and b/test/trace/propflags-7.swf differ
diff --git a/test/trace/propflags.as b/test/trace/propflags.as
index 944d63e..8387431 100644
--- a/test/trace/propflags.as
+++ b/test/trace/propflags.as
@@ -2,11 +2,7 @@
 
 #include "trace_properties.as"
 
-var o = new Object ();
-ASSetPropFlags (o, null, 0, 7);
-for (var prop in o) {
-  delete o[prop];
-}
+var o = new_empty_object ();
 o[0] = 0;
 for (var i = 1; i <= 7; i++) {
   o[i] = i;
diff --git a/test/trace/trace_properties.as b/test/trace/trace_properties.as
index 92294a9..a93f05c 100644
--- a/test/trace/trace_properties.as
+++ b/test/trace/trace_properties.as
@@ -4,6 +4,7 @@ function new_empty_object () {
   var hash = new Object ();
   ASSetPropFlags (hash, null, 0, 7);
   for (var prop in hash) {
+    hash[prop] = "to-be-deleted";
     delete hash[prop];
   }
   return hash;
diff-tree 9c1568477d8c26d87239f58b6b75091b36059ae1 (from 92ddd92a1bf234440d90f8707067be07d36ab16c)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Aug 21 23:13:53 2007 +0300

    Fix a warning in trace.c

diff --git a/test/trace/trace.c b/test/trace/trace.c
index af52ef6..a4c1868 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -90,7 +90,7 @@ run_test (gpointer testp, gpointer unuse
   GString *string, *output;
   GError *error = NULL;
   gboolean quit = FALSE;
-  SwfdecInteraction *inter;
+  SwfdecInteraction *inter = NULL;
 
   output = g_string_new ("");
   g_string_append_printf (output, "Testing %s:\n", test->filename);


More information about the Swfdec mailing list