From b8da9da8a7a5ebd58cb38cf4c981d809ad6fd5ab Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 3 Sep 2007 17:37:55 +0200 Subject: [PATCH] init Boolean class via script --- libswfdec/swfdec_as_boolean.c | 49 +++++++++----------------- libswfdec/swfdec_as_boolean.h | 3 -- libswfdec/swfdec_as_context.c | 2 -- libswfdec/swfdec_as_initialize.as | 4 +++ libswfdec/swfdec_as_initialize.h | 72 +++++++++++++++++++++------------------ 5 files changed, 60 insertions(+), 70 deletions(-) rewrite libswfdec/swfdec_as_initialize.h (83%) diff --git a/libswfdec/swfdec_as_boolean.c b/libswfdec/swfdec_as_boolean.c index 5d3a90b1..6764cbed 100644 --- a/libswfdec/swfdec_as_boolean.c +++ b/libswfdec/swfdec_as_boolean.c @@ -28,6 +28,7 @@ #include "swfdec_as_native_function.h" #include "swfdec_as_strings.h" #include "swfdec_debug.h" +#include "swfdec_player_internal.h" G_DEFINE_TYPE (SwfdecAsBoolean, swfdec_as_boolean, SWFDEC_TYPE_AS_OBJECT) @@ -43,7 +44,8 @@ swfdec_as_boolean_init (SwfdecAsBoolean *boolean) /*** AS CODE ***/ -static void +SWFDEC_AS_CONSTRUCTOR (107, 2, swfdec_as_boolean_construct, swfdec_as_boolean_get_type) +void swfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { @@ -63,48 +65,31 @@ swfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object, } } -static void +SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString) +void swfdec_as_boolean_toString (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { - SwfdecAsBoolean *b = SWFDEC_AS_BOOLEAN (object); + SwfdecAsBoolean *b; + + if (!SWFDEC_IS_AS_BOOLEAN (object)) + return; + b = SWFDEC_AS_BOOLEAN (object); SWFDEC_AS_VALUE_SET_STRING (ret, b->boolean ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false); } -static void +SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf) +void swfdec_as_boolean_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { - SwfdecAsBoolean *b = SWFDEC_AS_BOOLEAN (object); - - SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean); -} - -void -swfdec_as_boolean_init_context (SwfdecAsContext *context, guint version) -{ - SwfdecAsObject *boolean, *proto; - SwfdecAsValue val; + SwfdecAsBoolean *b; - g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context)); - - proto = swfdec_as_object_new_empty (context); - if (proto == NULL) - return; - boolean = SWFDEC_AS_OBJECT (swfdec_as_object_add_constructor (context->global, - SWFDEC_AS_STR_Boolean, 0, SWFDEC_TYPE_AS_BOOLEAN, - swfdec_as_boolean_construct, 0, proto)); - if (!boolean) + if (!SWFDEC_IS_AS_BOOLEAN (object)) return; - /* set the right properties on the Boolean.prototype object */ - SWFDEC_AS_VALUE_SET_OBJECT (&val, boolean); - 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_BOOLEAN, swfdec_as_boolean_toString, 0); - swfdec_as_object_add_function (proto, SWFDEC_AS_STR_valueOf, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_valueOf, 0); - SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype); - swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val, - SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT); + b = SWFDEC_AS_BOOLEAN (object); + + SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean); } diff --git a/libswfdec/swfdec_as_boolean.h b/libswfdec/swfdec_as_boolean.h index 16bdebd7..723f076e 100644 --- a/libswfdec/swfdec_as_boolean.h +++ b/libswfdec/swfdec_as_boolean.h @@ -47,9 +47,6 @@ struct _SwfdecAsBooleanClass { GType swfdec_as_boolean_get_type (void); -void swfdec_as_boolean_init_context (SwfdecAsContext * context, - guint version); - G_END_DECLS #endif diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c index 3b0ec123..3ce93564 100644 --- a/libswfdec/swfdec_as_context.c +++ b/libswfdec/swfdec_as_context.c @@ -25,7 +25,6 @@ #include #include "swfdec_as_context.h" #include "swfdec_as_array.h" -#include "swfdec_as_boolean.h" #include "swfdec_as_frame_internal.h" #include "swfdec_as_function.h" #include "swfdec_as_initialize.h" @@ -1227,7 +1226,6 @@ swfdec_as_context_startup (SwfdecAsContext *context, guint version) swfdec_as_context_init_global (context, version); swfdec_as_array_init_context (context, version); /* define the type objects */ - swfdec_as_boolean_init_context (context, version); swfdec_as_string_init_context (context, version); /* define the rest */ swfdec_as_math_init_context (context, version); diff --git a/libswfdec/swfdec_as_initialize.as b/libswfdec/swfdec_as_initialize.as index 4085c919..8ded5bb7 100644 --- a/libswfdec/swfdec_as_initialize.as +++ b/libswfdec/swfdec_as_initialize.as @@ -24,6 +24,10 @@ ASSetNativeAccessor = ASnative (4, 1); /*** BASE OBJECTS ***/ +Boolean = ASconstructor(107, 2); +ASSetNative(Boolean.prototype, 107, "valueOf,toString"); +ASSetPropFlags(Boolean.prototype, null, 3); + Number = ASconstructor (106, 2); ASSetNative (Number.prototype, 106, "valueOf,toString"); ASSetPropFlags(Number.prototype, null, 3); diff --git a/libswfdec/swfdec_as_initialize.h b/libswfdec/swfdec_as_initialize.h dissimilarity index 83% index 64fd129a..fec8c25e 100644 --- a/libswfdec/swfdec_as_initialize.h +++ b/libswfdec/swfdec_as_initialize.h @@ -1,33 +1,39 @@ -/* This file is autogenerated, do not edit! */ - -/* compiled from swfdec_as_initialize.as */ -const unsigned char swfdec_as_initialize[] = { - 0x88, 0xAF, 0x00, 0x0E, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, - 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, - 0x61, 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x4E, 0x75, - 0x6D, 0x62, 0x65, 0x72, 0x00, 0x41, 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, - 0x6F, 0x72, 0x00, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x76, 0x61, 0x6C, - 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x41, 0x53, - 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x4E, 0x61, 0x4E, - 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, - 0x54, 0x59, 0x00, 0x49, 0x6E, 0x66, 0x69, 0x6E, 0x69, 0x74, 0x79, 0x00, 0x4E, 0x45, 0x47, 0x41, - 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x4D, 0x49, - 0x4E, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, 0x4D, 0x41, 0x58, 0x5F, 0x56, 0x41, 0x4C, 0x55, - 0x45, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, - 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x02, 0x07, - 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, - 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x6A, 0x00, 0x00, - 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x06, 0x07, - 0x6A, 0x00, 0x00, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, - 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, - 0x00, 0x02, 0x08, 0x03, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, - 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x04, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x04, 0x00, 0x08, - 0x09, 0x08, 0x0A, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0B, - 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x4F, 0x96, 0x02, 0x00, - 0x08, 0x03, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x0C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, - 0x00, 0x08, 0x03, 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x0D, 0x06, 0xFF, 0xFF, 0xEF, 0x7F, 0xE2, 0xFF, - 0xFF, 0xFF, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x03, 0x1C, 0x96, - 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x00 -}; - +/* This file is autogenerated, do not edit! */ + +/* compiled from swfdec_as_initialize.as */ +const unsigned char swfdec_as_initialize[] = { + 0x88, 0xB7, 0x00, 0x0F, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, + 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, + 0x61, 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x42, 0x6F, + 0x6F, 0x6C, 0x65, 0x61, 0x6E, 0x00, 0x41, 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x6F, 0x72, 0x00, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x76, 0x61, + 0x6C, 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x41, + 0x53, 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x4E, 0x75, + 0x6D, 0x62, 0x65, 0x72, 0x00, 0x4E, 0x61, 0x4E, 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x56, + 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x49, 0x6E, 0x66, 0x69, 0x6E, + 0x69, 0x74, 0x79, 0x00, 0x4E, 0x45, 0x47, 0x41, 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46, + 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x4D, 0x49, 0x4E, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, + 0x4D, 0x41, 0x58, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, + 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x02, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, + 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, + 0x02, 0x00, 0x00, 0x00, 0x07, 0x6B, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, + 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x06, 0x07, 0x6B, 0x00, 0x00, 0x00, 0x08, 0x03, 0x1C, 0x96, + 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, + 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x03, 0x1C, 0x96, 0x02, 0x00, + 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x96, + 0x13, 0x00, 0x08, 0x08, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x6A, 0x00, 0x00, 0x00, 0x07, 0x02, + 0x00, 0x00, 0x00, 0x08, 0x04, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x06, 0x07, 0x6A, 0x00, 0x00, + 0x00, 0x08, 0x08, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, + 0x08, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, + 0x08, 0x07, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x09, 0x08, + 0x09, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0A, 0x08, 0x0B, + 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0C, 0x08, 0x0B, 0x1C, + 0x96, 0x05, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, + 0x96, 0x07, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, + 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x0E, 0x06, 0xFF, 0xFF, 0xEF, 0x7F, 0xE2, 0xFF, 0xFF, 0xFF, 0x4F, + 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x1C, 0x96, 0x07, 0x00, 0x07, + 0x03, 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x00 +}; + -- 2.11.4.GIT