[Swfdec-commits] 5 commits - swfdec/swfdec_net_stream.c swfdec/swfdec_video_movie.c vivified/code

Benjamin Otte company at kemper.freedesktop.org
Thu Apr 17 04:46:20 PDT 2008


 swfdec/swfdec_net_stream.c                 |    2 
 swfdec/swfdec_video_movie.c                |   40 +++++--
 vivified/code/Makefile.am                  |    8 +
 vivified/code/vivi_code_asm.c              |   61 +++++++++++
 vivified/code/vivi_code_asm.h              |   45 ++++++++
 vivified/code/vivi_code_asm_code.c         |   72 +++++++++++++
 vivified/code/vivi_code_asm_code.h         |   59 ++++++++++
 vivified/code/vivi_code_asm_code_default.c |   57 ++++++++++
 vivified/code/vivi_code_asm_code_default.h |   41 +++++++
 vivified/code/vivi_code_assembler.c        |  157 +++++++++++++++++++++++++++++
 vivified/code/vivi_code_assembler.h        |   67 ++++++++++++
 vivified/code/vivi_code_block.c            |    2 
 vivified/code/vivi_code_comment.c          |   11 +-
 vivified/code/vivi_code_defaults.h         |  112 ++++++++++++++++++++
 vivified/code/vivi_code_label.c            |   11 +-
 15 files changed, 729 insertions(+), 16 deletions(-)

New commits:
commit 2cd251489f9c4dff96e47373810f13a7e95ae965
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Apr 17 13:39:57 2008 +0200

    add asm codes

diff --git a/vivified/code/Makefile.am b/vivified/code/Makefile.am
index f62ce22..145e1ca 100644
--- a/vivified/code/Makefile.am
+++ b/vivified/code/Makefile.am
@@ -18,6 +18,8 @@ libvivified_compiler_la_LIBADD = \
 libvivified_compiler_la_SOURCES = \
 	vivi_code_and.c \
 	vivi_code_asm.c \
+	vivi_code_asm_code.c \
+	vivi_code_asm_code_default.c \
 	vivi_code_assembler.c \
 	vivi_code_assignment.c \
 	vivi_code_binary.c \
@@ -65,6 +67,8 @@ libvivified_compiler_la_SOURCES = \
 noinst_HEADERS = \
 	vivi_code_and.h \
 	vivi_code_asm.h \
+	vivi_code_asm_code.h \
+	vivi_code_asm_code_default.h \
 	vivi_code_assembler.h \
 	vivi_code_assignment.h \
 	vivi_code_binary.h \
diff --git a/vivified/code/vivi_code_asm_code.c b/vivified/code/vivi_code_asm_code.c
new file mode 100644
index 0000000..7f060b3
--- /dev/null
+++ b/vivified/code/vivi_code_asm_code.c
@@ -0,0 +1,72 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <swfdec/swfdec_as_interpret.h>
+
+#include "vivi_code_asm_code.h"
+#include "vivi_code_asm.h"
+#include "vivi_code_compiler.h"
+#include "vivi_code_printer.h"
+
+static void
+vivi_code_asm_code_asm_init (ViviCodeAsmInterface *iface)
+{
+}
+
+G_DEFINE_TYPE_WITH_CODE (ViviCodeAsmCode, vivi_code_asm_code, VIVI_TYPE_CODE_ASM_CODE,
+    G_IMPLEMENT_INTERFACE (VIVI_TYPE_CODE_ASM, vivi_code_asm_code_asm_init))
+
+static void
+vivi_code_asm_code_compile (ViviCodeToken *token, ViviCodeCompiler *compiler)
+{
+  ViviCodeAsmCode *code = VIVI_CODE_ASM_CODE (token);
+  SwfdecAsAction action = vivi_code_asm_code_get_action (code);
+
+  g_assert (action < 0x80);
+  vivi_code_compiler_write_empty_action (compiler, action); 
+}
+
+static void
+vivi_code_asm_code_class_init (ViviCodeAsmCodeClass *klass)
+{
+  ViviCodeTokenClass *token_class = VIVI_CODE_TOKEN_CLASS (klass);
+
+  token_class->compile = vivi_code_asm_code_compile;
+}
+
+static void
+vivi_code_asm_code_init (ViviCodeAsmCode *asm_code)
+{
+}
+
+SwfdecAsAction
+vivi_code_asm_code_get_action (ViviCodeAsmCode *code)
+{
+  ViviCodeAsmCodeClass *klass;
+
+  g_return_val_if_fail (VIVI_IS_CODE_ASM_CODE (code), 0);
+
+  klass = VIVI_CODE_ASM_CODE_GET_CLASS (code);
+
+  return klass->bytecode;
+}
diff --git a/vivified/code/vivi_code_asm_code.h b/vivified/code/vivi_code_asm_code.h
new file mode 100644
index 0000000..d62f6b6
--- /dev/null
+++ b/vivified/code/vivi_code_asm_code.h
@@ -0,0 +1,59 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef _VIVI_CODE_ASM_CODE_H_
+#define _VIVI_CODE_ASM_CODE_H_
+
+#include <swfdec/swfdec_as_interpret.h>
+#include <vivified/code/vivi_code_token.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _ViviCodeAsmCode ViviCodeAsmCode;
+typedef struct _ViviCodeAsmCodeClass ViviCodeAsmCodeClass;
+
+#define VIVI_TYPE_CODE_ASM_CODE                    (vivi_code_asm_code_get_type())
+#define VIVI_IS_CODE_ASM_CODE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_CODE_ASM_CODE))
+#define VIVI_IS_CODE_ASM_CODE_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_CODE_ASM_CODE))
+#define VIVI_CODE_ASM_CODE(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_CODE_ASM_CODE, ViviCodeAsmCode))
+#define VIVI_CODE_ASM_CODE_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_CODE_ASM_CODE, ViviCodeAsmCodeClass))
+#define VIVI_CODE_ASM_CODE_GET_CLASS(obj)          (G_TYPE_INSTANCE_GET_CLASS ((obj), VIVI_TYPE_CODE_ASM_CODE, ViviCodeAsmCodeClass))
+
+struct _ViviCodeAsmCode
+{
+  ViviCodeToken		token;
+};
+
+struct _ViviCodeAsmCodeClass
+{
+  ViviCodeTokenClass	token_class;
+
+  /*< private >*/
+  /* use vivi_code_default.h */
+  SwfdecAsAction	bytecode;
+};
+
+GType			vivi_code_asm_code_get_type   	(void);
+
+SwfdecAsAction		vivi_code_asm_code_get_action	(ViviCodeAsmCode *	code);
+
+
+G_END_DECLS
+#endif
diff --git a/vivified/code/vivi_code_asm_code_default.c b/vivified/code/vivi_code_asm_code_default.c
new file mode 100644
index 0000000..3a40fb6
--- /dev/null
+++ b/vivified/code/vivi_code_asm_code_default.c
@@ -0,0 +1,57 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vivi_code_asm_code_default.h"
+#include "vivi_code_printer.h"
+
+#define DEFAULT_ASM(CapsName, underscore_name, bytecode) \
+\
+G_DEFINE_TYPE (ViviCodeAsm ## CapsName, vivi_code_asm_ ## underscore_name, VIVI_TYPE_CODE_ASM_CODE); \
+\
+static void \
+vivi_code_asm_ ## underscore_name ## _print (ViviCodeToken *token, ViviCodePrinter *printer) \
+{ \
+  vivi_code_printer_print (printer, G_STRINGIFY (underscore_name)); \
+  vivi_code_printer_new_line (printer, TRUE); \
+} \
+\
+static void \
+vivi_code_asm_ ## underscore_name ## _class_init (ViviCodeAsm ## CapsName ## Class *klass) \
+{ \
+  ViviCodeTokenClass *token_class = VIVI_CODE_TOKEN_CLASS (klass); \
+\
+  token_class->print = vivi_code_asm_ ## underscore_name ## _print; \
+} \
+\
+static void \
+vivi_code_asm_ ## underscore_name ## _init (ViviCodeAsm ## CapsName *code) \
+{ \
+} \
+\
+ViviCodeAsm * \
+vivi_code_asm_ ## underscore_name ## _new (void) \
+{ \
+  return g_object_new (vivi_code_asm_ ## underscore_name ## _get_type (), NULL); \
+}
+
+#include "vivi_code_defaults.h"
diff --git a/vivified/code/vivi_code_asm_code_default.h b/vivified/code/vivi_code_asm_code_default.h
new file mode 100644
index 0000000..d30c181
--- /dev/null
+++ b/vivified/code/vivi_code_asm_code_default.h
@@ -0,0 +1,41 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef _VIVI_CODE_BINARY_DEFAULT_H_
+#define _VIVI_CODE_BINARY_DEFAULT_H_
+
+#include <vivified/code/vivi_code_asm_code.h>
+#include <vivified/code/vivi_code_asm.h>
+
+G_BEGIN_DECLS
+
+#define DEFAULT_ASM(CapsName, underscore_name, bytecode) \
+\
+typedef ViviCodeAsmCode ViviCodeAsm ## CapsName; \
+typedef ViviCodeAsmCodeClass ViviCodeAsm ## CapsName ## Class; \
+\
+GType			vivi_code_asm_ ## underscore_name ## _get_type 	(void); \
+\
+ViviCodeAsm *		vivi_code_asm_ ## underscore_name ## _new	(void);
+
+#include "vivi_code_defaults.h"
+
+
+G_END_DECLS
+#endif
diff --git a/vivified/code/vivi_code_defaults.h b/vivified/code/vivi_code_defaults.h
index f18b2ce..10f1045 100644
--- a/vivified/code/vivi_code_defaults.h
+++ b/vivified/code/vivi_code_defaults.h
@@ -50,3 +50,115 @@ DEFAULT_BINARY (Or,		or,		"||",	???,				VIVI_PRECEDENCE_AND)
 */
 
 #undef DEFAULT_BINARY
+
+
+#ifndef DEFAULT_ASM
+#define DEFAULT_ASM(CapsName, underscore_name, bytecode)
+#endif
+
+DEFAULT_ASM (End, end, SWFDEC_AS_ACTION_END)
+DEFAULT_ASM (NextFrame, next_frame, SWFDEC_AS_ACTION_NEXT_FRAME)
+DEFAULT_ASM (PreviousFrame, previous_frame, SWFDEC_AS_ACTION_PREVIOUS_FRAME)
+DEFAULT_ASM (Play, play, SWFDEC_AS_ACTION_PLAY)
+DEFAULT_ASM (Stop, stop, SWFDEC_AS_ACTION_STOP)
+DEFAULT_ASM (ToggleQuality, toggle_quality, SWFDEC_AS_ACTION_TOGGLE_QUALITY)
+DEFAULT_ASM (StopSounds, stop_sounds, SWFDEC_AS_ACTION_STOP_SOUNDS)
+DEFAULT_ASM (Add, add, SWFDEC_AS_ACTION_ADD)
+DEFAULT_ASM (Subtract, subtract, SWFDEC_AS_ACTION_SUBTRACT)
+DEFAULT_ASM (Multiply, multiply, SWFDEC_AS_ACTION_MULTIPLY)
+DEFAULT_ASM (Divide, divide, SWFDEC_AS_ACTION_DIVIDE)
+DEFAULT_ASM (Equals, equals, SWFDEC_AS_ACTION_EQUALS)
+DEFAULT_ASM (Less, less, SWFDEC_AS_ACTION_LESS)
+DEFAULT_ASM (And, and, SWFDEC_AS_ACTION_AND)
+DEFAULT_ASM (Or, or, SWFDEC_AS_ACTION_OR)
+DEFAULT_ASM (Not, not, SWFDEC_AS_ACTION_NOT)
+DEFAULT_ASM (StringEquals, string_equals, SWFDEC_AS_ACTION_STRING_EQUALS)
+DEFAULT_ASM (StringLength, string_length, SWFDEC_AS_ACTION_STRING_LENGTH)
+DEFAULT_ASM (StringExtract, string_extract, SWFDEC_AS_ACTION_STRING_EXTRACT)
+DEFAULT_ASM (Pop, pop, SWFDEC_AS_ACTION_POP)
+DEFAULT_ASM (ToInteger, to_integer, SWFDEC_AS_ACTION_TO_INTEGER)
+DEFAULT_ASM (GetVariable, get_variable, SWFDEC_AS_ACTION_GET_VARIABLE)
+DEFAULT_ASM (SetVariable, set_variable, SWFDEC_AS_ACTION_SET_VARIABLE)
+DEFAULT_ASM (SetTarget2, set_target2, SWFDEC_AS_ACTION_SET_TARGET2)
+DEFAULT_ASM (StringAdd, string_add, SWFDEC_AS_ACTION_STRING_ADD)
+DEFAULT_ASM (GetProperty, get_property, SWFDEC_AS_ACTION_GET_PROPERTY)
+DEFAULT_ASM (SetProperty, set_property, SWFDEC_AS_ACTION_SET_PROPERTY)
+DEFAULT_ASM (CloneSprite, clone_sprite, SWFDEC_AS_ACTION_CLONE_SPRITE)
+DEFAULT_ASM (RemoveSprite, remove_sprite, SWFDEC_AS_ACTION_REMOVE_SPRITE)
+DEFAULT_ASM (Trace, trace, SWFDEC_AS_ACTION_TRACE)
+DEFAULT_ASM (StartDrag, start_drag, SWFDEC_AS_ACTION_START_DRAG)
+DEFAULT_ASM (EndDrag, end_drag, SWFDEC_AS_ACTION_END_DRAG)
+DEFAULT_ASM (StringLess, string_less, SWFDEC_AS_ACTION_STRING_LESS)
+DEFAULT_ASM (Throw, throw, SWFDEC_AS_ACTION_THROW)
+DEFAULT_ASM (Cast, cast, SWFDEC_AS_ACTION_CAST)
+DEFAULT_ASM (Implements, implements, SWFDEC_AS_ACTION_IMPLEMENTS)
+DEFAULT_ASM (Random, random, SWFDEC_AS_ACTION_RANDOM)
+DEFAULT_ASM (MbStringLength, mb_string_length, SWFDEC_AS_ACTION_MB_STRING_LENGTH)
+DEFAULT_ASM (CharToAscii, char_to_ascii, SWFDEC_AS_ACTION_CHAR_TO_ASCII)
+DEFAULT_ASM (AsciiToChar, ascii_to_char, SWFDEC_AS_ACTION_ASCII_TO_CHAR)
+DEFAULT_ASM (GetTime, get_time, SWFDEC_AS_ACTION_GET_TIME)
+DEFAULT_ASM (MbStringExtract, mb_string_extract, SWFDEC_AS_ACTION_MB_STRING_EXTRACT)
+DEFAULT_ASM (MbCharToAscii, mb_char_to_ascii, SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII)
+DEFAULT_ASM (MbAsciiToChar, mb_ascii_to_char, SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR)
+DEFAULT_ASM (Delete, delete, SWFDEC_AS_ACTION_DELETE)
+DEFAULT_ASM (Delete2, delete2, SWFDEC_AS_ACTION_DELETE2)
+DEFAULT_ASM (DefineLocal, define_local, SWFDEC_AS_ACTION_DEFINE_LOCAL)
+DEFAULT_ASM (CallFunction, call_function, SWFDEC_AS_ACTION_CALL_FUNCTION)
+DEFAULT_ASM (Return, return, SWFDEC_AS_ACTION_RETURN)
+DEFAULT_ASM (Modulo, modulo, SWFDEC_AS_ACTION_MODULO)
+DEFAULT_ASM (NewObject, new_object, SWFDEC_AS_ACTION_NEW_OBJECT)
+DEFAULT_ASM (DefineLocal2, define_local2, SWFDEC_AS_ACTION_DEFINE_LOCAL2)
+DEFAULT_ASM (InitArray, init_array, SWFDEC_AS_ACTION_INIT_ARRAY)
+DEFAULT_ASM (InitObject, init_object, SWFDEC_AS_ACTION_INIT_OBJECT)
+DEFAULT_ASM (TypeOf, type_of, SWFDEC_AS_ACTION_TYPE_OF)
+DEFAULT_ASM (TargetPath, target_path, SWFDEC_AS_ACTION_TARGET_PATH)
+DEFAULT_ASM (Enumerate, enumerate, SWFDEC_AS_ACTION_ENUMERATE)
+DEFAULT_ASM (Add2, add2, SWFDEC_AS_ACTION_ADD2)
+DEFAULT_ASM (Less2, less2, SWFDEC_AS_ACTION_LESS2)
+DEFAULT_ASM (Equals2, equals2, SWFDEC_AS_ACTION_EQUALS2)
+DEFAULT_ASM (ToNumber, to_number, SWFDEC_AS_ACTION_TO_NUMBER)
+DEFAULT_ASM (ToString, to_string, SWFDEC_AS_ACTION_TO_STRING)
+DEFAULT_ASM (PushDuplicate, push_duplicate, SWFDEC_AS_ACTION_PUSH_DUPLICATE)
+DEFAULT_ASM (Swap, swap, SWFDEC_AS_ACTION_SWAP)
+DEFAULT_ASM (GetMember, get_member, SWFDEC_AS_ACTION_GET_MEMBER)
+DEFAULT_ASM (SetMember, set_member, SWFDEC_AS_ACTION_SET_MEMBER)
+DEFAULT_ASM (Increment, increment, SWFDEC_AS_ACTION_INCREMENT)
+DEFAULT_ASM (Decrement, decrement, SWFDEC_AS_ACTION_DECREMENT)
+DEFAULT_ASM (CallMethod, call_method, SWFDEC_AS_ACTION_CALL_METHOD)
+DEFAULT_ASM (NewMethod, new_method, SWFDEC_AS_ACTION_NEW_METHOD)
+DEFAULT_ASM (InstanceOf, instance_of, SWFDEC_AS_ACTION_INSTANCE_OF)
+DEFAULT_ASM (Enumerate2, enumerate2, SWFDEC_AS_ACTION_ENUMERATE2)
+DEFAULT_ASM (Breakpoint, breakpoint, SWFDEC_AS_ACTION_BREAKPOINT)
+DEFAULT_ASM (BitAnd, bit_and, SWFDEC_AS_ACTION_BIT_AND)
+DEFAULT_ASM (BitOr, bit_or, SWFDEC_AS_ACTION_BIT_OR)
+DEFAULT_ASM (BitXor, bit_xor, SWFDEC_AS_ACTION_BIT_XOR)
+DEFAULT_ASM (BitLshift, bit_lshift, SWFDEC_AS_ACTION_BIT_LSHIFT)
+DEFAULT_ASM (BitRshift, bit_rshift, SWFDEC_AS_ACTION_BIT_RSHIFT)
+DEFAULT_ASM (BitUrshift, bit_urshift, SWFDEC_AS_ACTION_BIT_URSHIFT)
+DEFAULT_ASM (StrictEquals, strict_equals, SWFDEC_AS_ACTION_STRICT_EQUALS)
+DEFAULT_ASM (Greater, greater, SWFDEC_AS_ACTION_GREATER)
+DEFAULT_ASM (StringGreater, string_greater, SWFDEC_AS_ACTION_STRING_GREATER)
+DEFAULT_ASM (Extends, extends, SWFDEC_AS_ACTION_EXTENDS)
+#if 0
+DEFAULT_ASM (GotoFrame, goto_frame, SWFDEC_AS_ACTION_GOTO_FRAME)
+DEFAULT_ASM (GetUrl, get_url, SWFDEC_AS_ACTION_GET_URL)
+DEFAULT_ASM (StoreRegister, store_register, SWFDEC_AS_ACTION_STORE_REGISTER)
+DEFAULT_ASM (ConstantPool, constant_pool, SWFDEC_AS_ACTION_CONSTANT_POOL)
+DEFAULT_ASM (StrictMode, strict_mode, SWFDEC_AS_ACTION_STRICT_MODE)
+DEFAULT_ASM (WaitForFrame, wait_for_frame, SWFDEC_AS_ACTION_WAIT_FOR_FRAME)
+DEFAULT_ASM (SetTarget, set_target, SWFDEC_AS_ACTION_SET_TARGET)
+DEFAULT_ASM (GotoLabel, goto_label, SWFDEC_AS_ACTION_GOTO_LABEL)
+DEFAULT_ASM (WaitForFrame2, wait_for_frame2, SWFDEC_AS_ACTION_WAIT_FOR_FRAME2)
+DEFAULT_ASM (DefineFunction2, define_function2, SWFDEC_AS_ACTION_DEFINE_FUNCTION2)
+DEFAULT_ASM (Try, try, SWFDEC_AS_ACTION_TRY)
+DEFAULT_ASM (With, with, SWFDEC_AS_ACTION_WITH)
+DEFAULT_ASM (Push, push, SWFDEC_AS_ACTION_PUSH)
+DEFAULT_ASM (Jump, jump, SWFDEC_AS_ACTION_JUMP)
+DEFAULT_ASM (GetUrl2, get_url2, SWFDEC_AS_ACTION_GET_URL2)
+DEFAULT_ASM (DefineFunction, define_function, SWFDEC_AS_ACTION_DEFINE_FUNCTION)
+DEFAULT_ASM (If, if, SWFDEC_AS_ACTION_IF)
+DEFAULT_ASM (Call, call, SWFDEC_AS_ACTION_CALL)
+DEFAULT_ASM (GotoFrame2, goto_frame2, SWFDEC_AS_ACTION_GOTO_FRAME2)
+#endif
+
+#undef DEFAULT_ASM
commit be5a5e81d8de25cc6c054f033c8b6ae2119e6525
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Apr 17 12:18:53 2008 +0200

    add assembler statement

diff --git a/vivified/code/Makefile.am b/vivified/code/Makefile.am
index 205e734..f62ce22 100644
--- a/vivified/code/Makefile.am
+++ b/vivified/code/Makefile.am
@@ -17,6 +17,8 @@ libvivified_compiler_la_LIBADD = \
 
 libvivified_compiler_la_SOURCES = \
 	vivi_code_and.c \
+	vivi_code_asm.c \
+	vivi_code_assembler.c \
 	vivi_code_assignment.c \
 	vivi_code_binary.c \
 	vivi_code_binary_default.c \
@@ -62,6 +64,8 @@ libvivified_compiler_la_SOURCES = \
 
 noinst_HEADERS = \
 	vivi_code_and.h \
+	vivi_code_asm.h \
+	vivi_code_assembler.h \
 	vivi_code_assignment.h \
 	vivi_code_binary.h \
 	vivi_code_binary_default.h \
diff --git a/vivified/code/vivi_code_asm.c b/vivified/code/vivi_code_asm.c
new file mode 100644
index 0000000..bc5f0dc
--- /dev/null
+++ b/vivified/code/vivi_code_asm.c
@@ -0,0 +1,61 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vivi_code_asm.h"
+
+static void
+vivi_code_asm_base_init (gpointer klass)
+{
+  static gboolean initialized = FALSE;
+
+  if (G_UNLIKELY (!initialized)) {
+    initialized = TRUE;
+  }
+}
+
+GType
+vivi_code_asm_get_type (void)
+{
+  static GType code_asm_type = 0;
+  
+  if (!code_asm_type) {
+    static const GTypeInfo code_asm_info = {
+      sizeof (ViviCodeAsmInterface),
+      vivi_code_asm_base_init,
+      NULL,
+      NULL,
+      NULL,
+      NULL,
+      0,
+      0,
+      NULL,
+    };
+    
+    code_asm_type = g_type_register_static (G_TYPE_INTERFACE,
+        "ViviCodeAsm", &code_asm_info, 0);
+    g_type_interface_add_prerequisite (code_asm_type, G_TYPE_OBJECT);
+  }
+  
+  return code_asm_type;
+}
+
diff --git a/vivified/code/vivi_code_asm.h b/vivified/code/vivi_code_asm.h
new file mode 100644
index 0000000..0687471
--- /dev/null
+++ b/vivified/code/vivi_code_asm.h
@@ -0,0 +1,45 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef __VIVI_CODE_ASM_H__
+#define __VIVI_CODE_ASM_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+
+#define VIVI_TYPE_CODE_ASM                (vivi_code_asm_get_type ())
+#define VIVI_CODE_ASM(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_CODE_ASM, ViviCodeAsm))
+#define VIVI_IS_CODE_ASM(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_CODE_ASM))
+#define VIVI_CODE_ASM_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), VIVI_TYPE_CODE_ASM, ViviCodeAsmInterface))
+
+typedef struct _ViviCodeAsm ViviCodeAsm; /* dummy object */
+typedef struct _ViviCodeAsmInterface ViviCodeAsmInterface;
+
+struct _ViviCodeAsmInterface {
+  GTypeInterface	interface;
+};
+
+GType			vivi_code_asm_get_type		(void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif /* __VIVI_CODE_ASM_H__ */
diff --git a/vivified/code/vivi_code_assembler.c b/vivified/code/vivi_code_assembler.c
new file mode 100644
index 0000000..d1fecd5
--- /dev/null
+++ b/vivified/code/vivi_code_assembler.c
@@ -0,0 +1,157 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <swfdec/swfdec_script_internal.h>
+
+#include "vivi_code_assembler.h"
+#include "vivi_code_comment.h"
+#include "vivi_code_label.h"
+#include "vivi_code_printer.h"
+#include "vivi_code_compiler.h"
+
+G_DEFINE_TYPE (ViviCodeAssembler, vivi_code_assembler, VIVI_TYPE_CODE_STATEMENT)
+
+static void
+vivi_code_assembler_dispose (GObject *object)
+{
+  ViviCodeAssembler *assembler = VIVI_CODE_ASSEMBLER (object);
+  guint i;
+
+  for (i = 0; i < assembler->codes->len; i++) {
+    g_object_unref (g_ptr_array_index (assembler->codes, i));
+  }
+  g_ptr_array_free (assembler->codes, TRUE);
+
+  G_OBJECT_CLASS (vivi_code_assembler_parent_class)->dispose (object);
+}
+
+static ViviCodeStatement *
+vivi_code_assembler_optimize (ViviCodeStatement *stmt)
+{
+  return g_object_ref (stmt);
+}
+
+static void
+vivi_code_assembler_print (ViviCodeToken *token, ViviCodePrinter *printer)
+{
+  ViviCodeAssembler *assembler = VIVI_CODE_ASSEMBLER (token);
+  guint i;
+
+  vivi_code_printer_print (printer, "asm {");
+  vivi_code_printer_new_line (printer, TRUE);
+  vivi_code_printer_push_indentation (printer);
+  for (i = 0; i < assembler->codes->len; i++) {
+    vivi_code_printer_print_token (printer, g_ptr_array_index (assembler->codes, i));
+  }
+  vivi_code_printer_pop_indentation (printer);
+  vivi_code_printer_print (printer, "}");
+  vivi_code_printer_new_line (printer, TRUE);
+}
+
+static void
+vivi_code_assembler_compile (ViviCodeToken *token, ViviCodeCompiler *compiler)
+{
+  ViviCodeAssembler *assembler = VIVI_CODE_ASSEMBLER (token);
+  guint i;
+
+  for (i = 0; i < assembler->codes->len; i++) {
+    vivi_code_compiler_compile_token (compiler,
+	VIVI_CODE_TOKEN (g_ptr_array_index (assembler->codes, i)));
+  }
+}
+
+static void
+vivi_code_assembler_class_init (ViviCodeAssemblerClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  ViviCodeTokenClass *token_class = VIVI_CODE_TOKEN_CLASS (klass);
+  ViviCodeStatementClass *code_class = VIVI_CODE_STATEMENT_CLASS (klass);
+
+  object_class->dispose = vivi_code_assembler_dispose;
+
+  token_class->print = vivi_code_assembler_print;
+  token_class->compile = vivi_code_assembler_compile;
+
+  code_class->optimize = vivi_code_assembler_optimize;
+}
+
+static void
+vivi_code_assembler_init (ViviCodeAssembler *assembler)
+{
+  assembler->codes = g_ptr_array_new ();
+}
+
+ViviCodeStatement *
+vivi_code_assembler_new (void)
+{
+  return g_object_new (VIVI_TYPE_CODE_ASSEMBLER, NULL);
+}
+
+guint
+vivi_code_assembler_get_n_codes (ViviCodeAssembler *assembler)
+{
+  g_return_val_if_fail (VIVI_IS_CODE_ASSEMBLER (assembler), 0);
+
+  return assembler->codes->len;
+}
+
+ViviCodeAsm *
+vivi_code_assembler_get_code (ViviCodeAssembler *assembler, guint i)
+{
+  g_return_val_if_fail (VIVI_IS_CODE_ASSEMBLER (assembler), NULL);
+  g_return_val_if_fail (i < assembler->codes->len, NULL);
+
+  return g_ptr_array_index (assembler->codes, i);
+}
+
+void
+vivi_code_assembler_insert_code (ViviCodeAssembler *assembler, guint i, ViviCodeAsm *code)
+{
+  g_return_if_fail (VIVI_IS_CODE_ASSEMBLER (assembler));
+  g_return_if_fail (VIVI_IS_CODE_ASM (assembler));
+
+  g_object_ref (code);
+  if (i >= assembler->codes->len) {
+    g_ptr_array_add (assembler->codes, code);
+  } else {
+    guint after = assembler->codes->len - i;
+    g_ptr_array_set_size (assembler->codes, assembler->codes->len + 1);
+    memmove (&g_ptr_array_index (assembler->codes, i + 1),
+	&g_ptr_array_index (assembler->codes, i), sizeof (gpointer) * after);
+    g_ptr_array_index (assembler->codes, i) = code;
+  }
+}
+
+void
+vivi_code_assembler_remove_code (ViviCodeAssembler *assembler, ViviCodeAsm *code)
+{
+  g_return_if_fail (VIVI_IS_CODE_ASSEMBLER (assembler));
+  g_return_if_fail (VIVI_IS_CODE_ASM (code));
+
+  if (g_ptr_array_remove (assembler->codes, code))
+    g_object_unref (code);
+  else
+    g_return_if_reached ();
+}
+
diff --git a/vivified/code/vivi_code_assembler.h b/vivified/code/vivi_code_assembler.h
new file mode 100644
index 0000000..2fcd1f3
--- /dev/null
+++ b/vivified/code/vivi_code_assembler.h
@@ -0,0 +1,67 @@
+/* Vivified
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef _VIVI_CODE_ASSEMBLER_H_
+#define _VIVI_CODE_ASSEMBLER_H_
+
+#include <vivified/code/vivi_code_asm.h>
+#include <vivified/code/vivi_code_statement.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _ViviCodeAssembler ViviCodeAssembler;
+typedef struct _ViviCodeAssemblerClass ViviCodeAssemblerClass;
+
+#define VIVI_TYPE_CODE_ASSEMBLER                    (vivi_code_assembler_get_type())
+#define VIVI_IS_CODE_ASSEMBLER(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_CODE_ASSEMBLER))
+#define VIVI_IS_CODE_ASSEMBLER_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_CODE_ASSEMBLER))
+#define VIVI_CODE_ASSEMBLER(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_CODE_ASSEMBLER, ViviCodeAssembler))
+#define VIVI_CODE_ASSEMBLER_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_CODE_ASSEMBLER, ViviCodeAssemblerClass))
+#define VIVI_CODE_ASSEMBLER_GET_CLASS(obj)          (G_TYPE_INSTANCE_GET_CLASS ((obj), VIVI_TYPE_CODE_ASSEMBLER, ViviCodeAssemblerClass))
+
+struct _ViviCodeAssembler
+{
+  ViviCodeStatement	statement;
+
+  GPtrArray *		codes;		/* ViviCodeAsm inside this assembler */
+};
+
+struct _ViviCodeAssemblerClass
+{
+  ViviCodeStatementClass statement_class;
+};
+
+GType			vivi_code_assembler_get_type		(void);
+
+ViviCodeStatement *	vivi_code_assembler_new			(void);
+
+guint			vivi_code_assembler_get_n_codes		(ViviCodeAssembler *	assembler);
+ViviCodeAsm *		vivi_code_assembler_get_code		(ViviCodeAssembler *	assembler,
+								 guint			i);
+#define vivi_code_assembler_add_code(assembler, code) vivi_code_assembler_insert_code (assembler, G_MAXUINT, code)
+void			vivi_code_assembler_insert_code  	(ViviCodeAssembler *	assembler,
+								 guint			i,
+								 ViviCodeAsm *		code);
+void			vivi_code_assembler_remove_code		(ViviCodeAssembler *	assembler,
+								 ViviCodeAsm *		code);
+
+
+G_END_DECLS
+#endif
diff --git a/vivified/code/vivi_code_comment.c b/vivified/code/vivi_code_comment.c
index 251bc2a..65fe694 100644
--- a/vivified/code/vivi_code_comment.c
+++ b/vivified/code/vivi_code_comment.c
@@ -22,10 +22,17 @@
 #endif
 
 #include "vivi_code_comment.h"
-#include "vivi_code_printer.h"
+#include "vivi_code_asm.h"
 #include "vivi_code_compiler.h"
+#include "vivi_code_printer.h"
+
+static void
+vivi_code_comment_asm_init (ViviCodeAsmInterface *iface)
+{
+}
 
-G_DEFINE_TYPE (ViviCodeComment, vivi_code_comment, VIVI_TYPE_CODE_STATEMENT)
+G_DEFINE_TYPE_WITH_CODE (ViviCodeComment, vivi_code_comment, VIVI_TYPE_CODE_STATEMENT,
+    G_IMPLEMENT_INTERFACE (VIVI_TYPE_CODE_ASM, vivi_code_comment_asm_init))
 
 static void
 vivi_code_comment_dispose (GObject *object)
diff --git a/vivified/code/vivi_code_label.c b/vivified/code/vivi_code_label.c
index 34cbf4c..7588554 100644
--- a/vivified/code/vivi_code_label.c
+++ b/vivified/code/vivi_code_label.c
@@ -22,10 +22,17 @@
 #endif
 
 #include "vivi_code_label.h"
-#include "vivi_code_printer.h"
+#include "vivi_code_asm.h"
 #include "vivi_code_compiler.h"
+#include "vivi_code_printer.h"
+
+static void
+vivi_code_label_asm_init (ViviCodeAsmInterface *iface)
+{
+}
 
-G_DEFINE_TYPE (ViviCodeLabel, vivi_code_label, VIVI_TYPE_CODE_STATEMENT)
+G_DEFINE_TYPE_WITH_CODE (ViviCodeLabel, vivi_code_label, VIVI_TYPE_CODE_LABEL,
+    G_IMPLEMENT_INTERFACE (VIVI_TYPE_CODE_ASM, vivi_code_label_asm_init))
 
 static void
 vivi_code_label_dispose (GObject *object)
commit df97e22c195a5a7e0803237bdb48382e9dce1361
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Apr 17 12:06:07 2008 +0200

    check right variable here

diff --git a/vivified/code/vivi_code_block.c b/vivified/code/vivi_code_block.c
index 2dbec28..06c415a 100644
--- a/vivified/code/vivi_code_block.c
+++ b/vivified/code/vivi_code_block.c
@@ -168,7 +168,7 @@ void
 vivi_code_block_remove_statement (ViviCodeBlock *block, ViviCodeStatement *statement)
 {
   g_return_if_fail (VIVI_IS_CODE_BLOCK (block));
-  g_return_if_fail (VIVI_IS_CODE_STATEMENT (block));
+  g_return_if_fail (VIVI_IS_CODE_STATEMENT (statement));
 
   if (g_ptr_array_remove (block->statements, statement))
     g_object_unref (statement);
commit 4dda73cc917abb0d79700cd6d00ba0080327d337
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Apr 16 15:38:20 2008 +0200

    neither leaking whole surfaces nor crashing sounds like a good idea

diff --git a/swfdec/swfdec_video_movie.c b/swfdec/swfdec_video_movie.c
index 7c4f868..2b81519 100644
--- a/swfdec/swfdec_video_movie.c
+++ b/swfdec/swfdec_video_movie.c
@@ -70,11 +70,24 @@ swfdec_video_movie_render (SwfdecMovie *mov, cairo_t *cr,
 }
 
 static void
+swfdec_video_movie_new_image (SwfdecVideoProvider *provider, SwfdecVideoMovie *movie)
+{
+  movie->clear = FALSE;
+  swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
+}
+
+static void
 swfdec_video_movie_dispose (GObject *object)
 {
   SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (object);
 
-  swfdec_video_movie_set_provider (movie, NULL);
+  if (movie->provider) {
+    g_signal_handlers_disconnect_by_func (movie->provider,
+	swfdec_video_movie_new_image, movie);
+    g_object_unref (movie->provider);
+    movie->provider = NULL;
+  }
+
   g_object_unref (movie->video);
 
   G_OBJECT_CLASS (swfdec_video_movie_parent_class)->dispose (object);
@@ -100,19 +113,33 @@ swfdec_video_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
   video = SWFDEC_VIDEO_MOVIE (object);
 
   if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_width) == 0) {
+    /* FIXME: find better solution here */
+    cairo_surface_t *surface;
     if (video->provider) {
-      swfdec_video_provider_get_image (video->provider,
+      surface = swfdec_video_provider_get_image (video->provider,
 	  SWFDEC_PLAYER (object->context)->priv->renderer, &w, &h);
     } else {
+      surface = NULL;
+    }
+    if (surface) {
+      cairo_surface_destroy (surface);
+    } else {
       w = 0;
     }
     SWFDEC_AS_VALUE_SET_NUMBER (val, w);
     return TRUE;
   } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_height) == 0) {
+    /* FIXME: find better solution here */
+    cairo_surface_t *surface;
     if (video->provider) {
-      swfdec_video_provider_get_image (video->provider,
+      surface = swfdec_video_provider_get_image (video->provider,
 	  SWFDEC_PLAYER (object->context)->priv->renderer, &w, &h);
     } else {
+      surface = NULL;
+    }
+    if (surface) {
+      cairo_surface_destroy (surface);
+    } else {
       h = 0;
     }
     SWFDEC_AS_VALUE_SET_NUMBER (val, h);
@@ -208,13 +235,6 @@ swfdec_video_movie_init (SwfdecVideoMovie * video_movie)
 {
 }
 
-static void
-swfdec_video_movie_new_image (SwfdecVideoProvider *provider, SwfdecVideoMovie *movie)
-{
-  movie->clear = FALSE;
-  swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
-}
-
 void
 swfdec_video_movie_set_provider (SwfdecVideoMovie *movie, 
     SwfdecVideoProvider *provider)
commit aada1fd69e5ab0f1294a3d262570f1e8ac797afc
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Apr 16 15:37:07 2008 +0200

    we don't get images from decoders without images either

diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index bc19bbf..9336f09 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -342,7 +342,7 @@ swfdec_net_stream_video_provider_get_image (SwfdecVideoProvider *provider,
     return swfdec_cached_video_get_surface (cached);
   }
 
-  if (stream->flvdecoder == NULL)
+  if (stream->flvdecoder == NULL || stream->flvdecoder->video == NULL)
     return NULL;
 
   if (stream->decoder != NULL &&


More information about the Swfdec-commits mailing list