Benjamin Otte
2007-Jun-28 17:00 UTC
[Swfdec] Branch 'as' - 4 commits - doc/Makefile.am doc/swfdec-docs.sgml doc/swfdec-sections.txt libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_types.c libswfdec/swfdec_as_types.h
doc/Makefile.am | 12 ++++ doc/swfdec-docs.sgml | 4 + doc/swfdec-sections.txt | 13 +++++ libswfdec/swfdec_as_interpret.c | 11 +++- libswfdec/swfdec_as_types.c | 98 ++++++++++++++++++++++++++++++---------- libswfdec/swfdec_as_types.h | 7 +- 6 files changed, 113 insertions(+), 32 deletions(-) New commits: diff-tree afacd9f6211b9b43e2ea1ef808fc612ba92b3cce (from 54d9e25821ca4303c7182c626343ee08c84b1ea2) Author: Benjamin Otte <otte at gnome.org> Date: Thu Jun 28 18:59:47 2007 +0200 improve documentation, add first chunk of script-engine related docs. diff --git a/doc/Makefile.am b/doc/Makefile.am index 5ce6db0..f43e706 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -55,6 +55,12 @@ IGNORE_HFILES= \ js \ jpeg \ swfdec_amf.h \ + swfdec_as_interpret.h \ + swfdec_as_number.h \ + swfdec_as_string.h \ + swfdec_as_strings.h \ + swfdec_as_super.h \ + swfdec_as_with.h \ swfdec_audio_internal.h \ swfdec_audio_event.h \ swfdec_audio_flv.h \ @@ -68,7 +74,7 @@ IGNORE_HFILES= \ swfdec_codec_audio.h \ swfdec_codec_video.h \ swfdec_color.h \ - swfdec_connection.h \ + swfdec_color_as.h \ swfdec_debug.h \ swfdec_debugger.h \ swfdec_decoder.h \ @@ -80,6 +86,7 @@ IGNORE_HFILES= \ swfdec_graphic.h \ swfdec_graphic_movie.h \ swfdec_image.h \ + swfdec_interval.h \ swfdec_js.h \ swfdec_listener.h \ swfdec_loader_internal.h \ @@ -88,6 +95,7 @@ IGNORE_HFILES= \ swfdec_morph_movie.h \ swfdec_morphshape.h \ swfdec_movie.h \ + swfdec_net_connection.h \ swfdec_net_stream.h \ swfdec_pattern.h \ swfdec_player_internal.h \ @@ -103,9 +111,11 @@ IGNORE_HFILES= \ swfdec_sprite_movie.h \ swfdec_stroke.h \ swfdec_swf_decoder.h \ + swfdec_swf_instance.h \ swfdec_tag.h \ swfdec_text.h \ swfdec_types.h \ + swfdec_utils.h \ swfdec_video.h \ swfdec_video_movie.h \ swfdec_xml.h diff --git a/doc/swfdec-docs.sgml b/doc/swfdec-docs.sgml index aa1c339..07c7ee4 100644 --- a/doc/swfdec-docs.sgml +++ b/doc/swfdec-docs.sgml @@ -20,4 +20,8 @@ <xi:include href="xml/SwfdecBuffer.xml"/> <xi:include href="xml/SwfdecLoader.xml"/> </chapter> + <chapter> + <title>Actionscript interpreter</title> + <xi:include href="xml/SwfdecAsValue.xml"/> + </chapter> </book> diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index e0454c7..30ac93b 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -178,3 +178,16 @@ SWFDEC_IS_GTK_LOADER SWFDEC_IS_GTK_LOADER_CLASS SWFDEC_TYPE_GTK_LOADER </SECTION> + +<SECTION> +<FILE>SwfdecAsValue</FILE> +<TITLE>SwfdecAsValue</TITLE> +SwfdecAsValueType +SwfdecAsValue +swfdec_as_value_to_boolean +swfdec_as_value_to_integer +swfdec_as_value_to_number +swfdec_as_value_to_object +swfdec_as_value_to_primitive +swfdec_as_value_to_string +</SECTION> diff-tree 54d9e25821ca4303c7182c626343ee08c84b1ea2 (from 35053a70dfbdc472fecadb29b21e38dd9e055410) Author: Benjamin Otte <otte at gnome.org> Date: Thu Jun 28 18:59:21 2007 +0200 add documentation diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c index 873a921..6b8f3a5 100644 --- a/libswfdec/swfdec_as_types.c +++ b/libswfdec/swfdec_as_types.c @@ -32,6 +32,67 @@ #include "swfdec_debug.h" #include "swfdec_movie.h" +/*** GTK-DOC ***/ + +/** + * SECTION:SwfdecAsValue + * @title: SwfdecAsValue + * @short_description: exchanging values with the Actionscript engine + * + * This section describes how values are handled inside the Actionscript + * engine. Sice Actionscript is a dynamically typed language, the variable type + * has to be carried with every value. #SwfdecAsValue accomplishes that. Swfdec + * allows two possible ways of accessing these values: The common method is to + * use the provided functions to explicitly convert the values to a given type + * with a function such as swfdec_as_value_to_string (). This is convenient, + * but can be very slow as it can call back into the Actionscript engine when + * converting various objects. So it can be unsuitable in some cases. + * A different possibiltiy is accessing the values directly using the accessor + * macros. You must check the type before doing so though. For setting values, + * there only exist macros, since type conversion is not necessary. + */ + +/** + * SwfdecAsValueType: + * @SWFDEC_AS_TYPE_UNDEFINED: the special undefined value + * @SWFDEC_AS_TYPE_BOOLEAN: a boolean value - true or false + * @SWFDEC_AS_TYPE_INT: reserved value for integers. Should the need arise for + * performance enhancements - especially on embedded + * devices - it might be useful to implement this type. + * For now, this type will never appear in Swfdec. Using + * it will cause Swfdec to crash. + * @SWFDEC_AS_TYPE_NUMBER: a double value - also used for integer numbers + * @SWFDEC_AS_TYPE_STRING: a string. Strings are garbage-collected and unique. + * @SWFDEC_AS_TYPE_NULL: the spaecial null value + * @SWFDEC_AS_TYPE_OBJECT: an object - must be of type #SwfdecAsObject + * + * These are the possible values the Swfdec Actionscript engine knows about. + */ + +/** + * SwfdecAsValue: + * @type: the type of this value. + * + * This is the type used to present an opaque value in the Actionscript + * engine. See #SwfdecAsValueType for possible types. It's similar in + * spirit to #GValue. The value held is garbage-collected. Apart from the type + * member, use the provided macros to access this structure. + * <note>If you memset a SwfdecAsValue to 0, it is a valid undefined value.</note> + */ + +/*** actual code ***/ + +/** + * swfdec_as_str_concat: + * @cx: a #SwfdecAsContext + * @s1: first string + * @s2: second string + * + * Convenience function to concatenate two garbage-collected strings. This + * function is equivalent to g_strconcat (). + * + * Returns: A new garbage-collected string + **/ const char * swfdec_as_str_concat (SwfdecAsContext *cx, const char * s1, const char *s2) { @@ -174,10 +235,13 @@ swfdec_as_double_to_string (SwfdecAsCont * @context: a #SwfdecAsContext * @value: value to be expressed as string * - * Converts @value to a string. - * <warning>This function may run the garbage collector.</warning> + * Converts @value to a string according to the rules of Flash. This might + * cause calling back into the script engine if the @value is an object. In + * that case, the object's valueOf function is called. + * <warning>Never use this function for debugging purposes.</warning> * - * Returns: a garbage-collected string representing @value + * Returns: a garbage-collected string representing @value. The value will + * never be %NULL. **/ const char * swfdec_as_value_to_string (SwfdecAsContext *context, const SwfdecAsValue *value) @@ -224,6 +288,18 @@ swfdec_as_value_to_string (SwfdecAsConte } } +/** + * swfdec_as_value_to_number: + * @context: a #SwfdecAsContext + * @value: a #SwfdecAsValue used by context + * + * Converts the value to a number according to Flash's conversion routines and + * the current Flash version. This conversion routine is similar, but not equal + * to ECMAScript. For objects, it can call back into the script engine by + * calling the object's valueOf function. + * + * Returns: a double value. It can be NaN or +-Infinity. It will not be -0.0. + **/ double swfdec_as_value_to_number (SwfdecAsContext *context, const SwfdecAsValue *value) { diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h index 531cf52..757958f 100644 --- a/libswfdec/swfdec_as_types.h +++ b/libswfdec/swfdec_as_types.h @@ -54,6 +54,7 @@ typedef void (* SwfdecAsNative) (SwfdecA /* IMPORTANT: a SwfdecAsValue memset to 0 is a valid undefined value */ struct _SwfdecAsValue { SwfdecAsValueType type; + /*< private >*/ union { gboolean boolean; double number; diff-tree 35053a70dfbdc472fecadb29b21e38dd9e055410 (from 180173af2a16e939d54a0bb01eb37c7eff877333) Author: Benjamin Otte <otte at gnome.org> Date: Thu Jun 28 17:34:24 2007 +0200 rename SwfdecAsType to SwfdecAsValueType It's the type of the value after all. diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index f006486..5f5838e 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1011,7 +1011,7 @@ swfdec_action_equals2_5 (SwfdecAsContext { SwfdecAsValue *rval, *lval; SwfdecAsValue rtmp, ltmp; - SwfdecAsType ltype, rtype; + SwfdecAsValueType ltype, rtype; double l, r; gboolean cond; @@ -1100,7 +1100,7 @@ static void swfdec_action_equals2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { SwfdecAsValue *rval, *lval; - SwfdecAsType ltype, rtype; + SwfdecAsValueType ltype, rtype; double l, r; gboolean cond; diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h index 23502d9..531cf52 100644 --- a/libswfdec/swfdec_as_types.h +++ b/libswfdec/swfdec_as_types.h @@ -35,7 +35,7 @@ typedef enum { SWFDEC_AS_TYPE_STRING, SWFDEC_AS_TYPE_NULL, SWFDEC_AS_TYPE_OBJECT -} SwfdecAsType; +} SwfdecAsValueType; typedef struct _SwfdecAsArray SwfdecAsArray; typedef struct _SwfdecAsContext SwfdecAsContext; @@ -53,7 +53,7 @@ typedef void (* SwfdecAsNative) (SwfdecA /* IMPORTANT: a SwfdecAsValue memset to 0 is a valid undefined value */ struct _SwfdecAsValue { - SwfdecAsType type; + SwfdecAsValueType type; union { gboolean boolean; double number; diff-tree 180173af2a16e939d54a0bb01eb37c7eff877333 (from 0a6d54d5df44db6ef9d1d81b2dc8add873f20787) Author: Benjamin Otte <otte at gnome.org> Date: Thu Jun 28 17:29:37 2007 +0200 remove swfdec_as_value_to_printable () It was only used by the trace action, and that code can do it itself diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index e6f6c78..f006486 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -544,9 +544,14 @@ swfdec_action_set_member (SwfdecAsContex static void swfdec_action_trace (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { + SwfdecAsValue *val; const char *s; - s = swfdec_as_value_to_printable (cx, swfdec_as_stack_pop (cx->frame->stack)); + val = swfdec_as_stack_pop (cx->frame->stack); + if (val->type == SWFDEC_AS_TYPE_UNDEFINED) + s = SWFDEC_AS_STR_undefined; + else + s = swfdec_as_value_to_string (cx, val); swfdec_as_context_trace (cx, s); } diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c index 1d61c51..873a921 100644 --- a/libswfdec/swfdec_as_types.c +++ b/libswfdec/swfdec_as_types.c @@ -224,32 +224,6 @@ swfdec_as_value_to_string (SwfdecAsConte } } -/** - * swfdec_as_value_to_printable: - * @context: a #SwfdecAsContext - * @value: value to be converted to a printable string - * - * Converts @value to a string. This function is used by the trace signal. It - * uses a slightly different conversion then swfdec_as_value_to_string(). Don't - * use this function if you can avoid it. - * - * Returns: a garbage collected string representing @value. - **/ -const char * -swfdec_as_value_to_printable (SwfdecAsContext *context, const SwfdecAsValue *value) -{ - g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), SWFDEC_AS_STR_EMPTY); - g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), SWFDEC_AS_STR_EMPTY); - - switch (value->type) { - case SWFDEC_AS_TYPE_UNDEFINED: - return SWFDEC_AS_STR_undefined; - default: - break; - } - return swfdec_as_value_to_string (context, value); -} - double swfdec_as_value_to_number (SwfdecAsContext *context, const SwfdecAsValue *value) { diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h index 0dc580f..23502d9 100644 --- a/libswfdec/swfdec_as_types.h +++ b/libswfdec/swfdec_as_types.h @@ -220,8 +220,6 @@ double swfdec_as_value_to_number (Swfde SwfdecAsObject *swfdec_as_value_to_object (SwfdecAsContext * context, const SwfdecAsValue * value); void swfdec_as_value_to_primitive (SwfdecAsValue * value); -const char * swfdec_as_value_to_printable (SwfdecAsContext * context, - const SwfdecAsValue * value); const char * swfdec_as_value_to_string (SwfdecAsContext * context, const SwfdecAsValue * value);
Reasonably Related Threads
- Branch 'as' - 4 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_types.c libswfdec/swfdec_as_types.h
- Branch 'as' - 14 commits - libswfdec-gtk/swfdec_playback_alsa.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_context.h libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_function.c libswfdec/swfdec_as_function.h
- Branch 'as' - 11 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_native_function.c libswfdec/swfdec_as_number.c libswfdec/swfdec_as_object.c
- Branch 'as' - 8 commits - libswfdec/Makefile.am libswfdec/swfdec_as_array.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_math.c libswfdec/swfdec_as_math.h libswfdec/swfdec_as_strings.c libswfdec/swfdec_as_types.c
- 12 commits - AUTHORS doc/Makefile.am doc/swfdec-docs.sgml doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_array.c libswfdec/swfdec_as_array.h libswfdec/swfdec_as_context.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_function.h