📄 swfdecasobject.xml
字号:
<?xml version="1.0"?><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"><refentry id="swfdec-SwfdecAsObject"><refmeta><refentrytitle role="top_of_page">SwfdecAsObject</refentrytitle><manvolnum>3</manvolnum><refmiscinfo>SWFDEC Library</refmiscinfo></refmeta><refnamediv><refname>SwfdecAsObject</refname><refpurpose>the base object type for scriptable objects</refpurpose><!--[<xref linkend="desc" endterm="desc.title"/>]--></refnamediv><refsynopsisdiv role="synopsis"><title role="synopsis.title">Synopsis</title><synopsis> <link linkend="SwfdecAsObject">SwfdecAsObject</link>;<link linkend="SwfdecAsObject">SwfdecAsObject</link>* <link linkend="swfdec-as-object-new">swfdec_as_object_new</link> (<link linkend="SwfdecAsContext">SwfdecAsContext</link> *context);<link linkend="SwfdecAsObject">SwfdecAsObject</link>* <link linkend="swfdec-as-object-new-empty">swfdec_as_object_new_empty</link> (<link linkend="SwfdecAsContext">SwfdecAsContext</link> *context);<link linkend="void">void</link> <link linkend="swfdec-as-object-create">swfdec_as_object_create</link> (<link linkend="SwfdecAsFunction">SwfdecAsFunction</link> *fun, <link linkend="guint">guint</link> n_args, const <link linkend="SwfdecAsValue">SwfdecAsValue</link> *args);<link linkend="void">void</link> <link linkend="swfdec-as-object-add">swfdec_as_object_add</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, <link linkend="SwfdecAsContext">SwfdecAsContext</link> *context, <link linkend="gsize">gsize</link> size);<link linkend="void">void</link> <link linkend="swfdec-as-object-set-constructor">swfdec_as_object_set_constructor</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, <link linkend="SwfdecAsObject">SwfdecAsObject</link> *construct);enum <link linkend="SwfdecAsVariableFlag">SwfdecAsVariableFlag</link>;#define <link linkend="swfdec-as-object-get-variable">swfdec_as_object_get_variable</link> (object, variable, value)<link linkend="gboolean">gboolean</link> <link linkend="swfdec-as-object-get-variable-and-flags">swfdec_as_object_get_variable_and_flags</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable, <link linkend="SwfdecAsValue">SwfdecAsValue</link> *value, <link linkend="guint">guint</link> *flags, <link linkend="SwfdecAsObject">SwfdecAsObject</link> **pobject);#define <link linkend="swfdec-as-object-set-variable">swfdec_as_object_set_variable</link> (object, variable, value)<link linkend="void">void</link> <link linkend="swfdec-as-object-set-variable-and-flags">swfdec_as_object_set_variable_and_flags</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable, const <link linkend="SwfdecAsValue">SwfdecAsValue</link> *value, <link linkend="guint">guint</link> default_flags);<link linkend="void">void</link> <link linkend="swfdec-as-object-add-variable">swfdec_as_object_add_variable</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable, <link linkend="SwfdecAsFunction">SwfdecAsFunction</link> *get, <link linkend="SwfdecAsFunction">SwfdecAsFunction</link> *set);<link linkend="void">void</link> <link linkend="swfdec-as-object-set-variable-flags">swfdec_as_object_set_variable_flags</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable, <link linkend="SwfdecAsVariableFlag">SwfdecAsVariableFlag</link> flags);<link linkend="void">void</link> <link linkend="swfdec-as-object-unset-variable-flags">swfdec_as_object_unset_variable_flags</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable, <link linkend="SwfdecAsVariableFlag">SwfdecAsVariableFlag</link> flags);<link linkend="SwfdecAsDeleteReturn">SwfdecAsDeleteReturn</link> <link linkend="swfdec-as-object-delete-variable">swfdec_as_object_delete_variable</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable);<link linkend="gboolean">gboolean</link> (<link linkend="SwfdecAsVariableForeach">*SwfdecAsVariableForeach</link>) (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *variable, <link linkend="SwfdecAsValue">SwfdecAsValue</link> *value, <link linkend="guint">guint</link> flags, <link linkend="gpointer">gpointer</link> data);<link linkend="gboolean">gboolean</link> <link linkend="swfdec-as-object-foreach">swfdec_as_object_foreach</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, <link linkend="SwfdecAsVariableForeach">SwfdecAsVariableForeach</link> func, <link linkend="gpointer">gpointer</link> data);<link linkend="gboolean">gboolean</link> <link linkend="swfdec-as-object-has-function">swfdec_as_object_has_function</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *name);<link linkend="void">void</link> <link linkend="swfdec-as-object-run">swfdec_as_object_run</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, <link linkend="SwfdecScript">SwfdecScript</link> *script);<link linkend="void">void</link> <link linkend="swfdec-as-object-call">swfdec_as_object_call</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *name, <link linkend="guint">guint</link> argc, <link linkend="SwfdecAsValue">SwfdecAsValue</link> *argv, <link linkend="SwfdecAsValue">SwfdecAsValue</link> *return_value);<link linkend="SwfdecAsFunction">SwfdecAsFunction</link>* <link linkend="swfdec-as-object-add-function">swfdec_as_object_add_function</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *name, <link linkend="GType">GType</link> type, <link linkend="SwfdecAsNative">SwfdecAsNative</link> native, <link linkend="guint">guint</link> min_args);<link linkend="SwfdecAsFunction">SwfdecAsFunction</link>* <link linkend="swfdec-as-object-add-constructor">swfdec_as_object_add_constructor</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object, const <link linkend="char">char</link> *name, <link linkend="GType">GType</link> type, <link linkend="GType">GType</link> construct_type, <link linkend="SwfdecAsNative">SwfdecAsNative</link> native, <link linkend="guint">guint</link> min_args, <link linkend="SwfdecAsObject">SwfdecAsObject</link> *prototype);<link linkend="char">char</link>* <link linkend="swfdec-as-object-get-debug">swfdec_as_object_get_debug</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object);<link linkend="SwfdecAsObject">SwfdecAsObject</link>* <link linkend="swfdec-as-object-resolve">swfdec_as_object_resolve</link> (<link linkend="SwfdecAsObject">SwfdecAsObject</link> *object);</synopsis></refsynopsisdiv><refsect1 role="desc"><title role="desc.title">Description</title><para>This is the basic object type in Swfdec. Every object used by the script engine must be a <link linkend="SwfdecAsObject"><type>SwfdecAsObject</type></link>. It handles memory management and assigningvariables to it. Almost all functions that are called on objects require thatthe objects have been added to the garbage collector previously. For custom-created objects, you need to do this using <link linkend="swfdec-as-object-add"><function>swfdec_as_object_add()</function></link>, built-in functions that create objects do this manually.</para><para>Note that you cannot know the lifetime of a <link linkend="SwfdecAsObject"><type>SwfdecAsObject</type></link>, since scripts may assign it as a variable to other objects. So you should not assume to know when an object gets removed.</para><para></para></refsect1><refsect1 role="details"><title role="details.title">Details</title><refsect2><title><anchor id="SwfdecAsObject" role="struct"/>SwfdecAsObject</title><indexterm><primary>SwfdecAsObject</primary></indexterm><programlisting>typedef struct {} SwfdecAsObject;</programlisting><para>Every object value inside the Swfdec script engine must be a SwfdecAsObject.If you want to add custom objects to your script engine, you need to create asubclass. The class provides a number of virtual functions that you can override to achieve the desired behaviour.</para><para></para></refsect2><refsect2><title><anchor id="swfdec-as-object-new" role="function"/>swfdec_as_object_new ()</title><indexterm><primary>swfdec_as_object_new</primary></indexterm><programlisting><link linkend="SwfdecAsObject">SwfdecAsObject</link>* swfdec_as_object_new (<link linkend="SwfdecAsContext">SwfdecAsContext</link> *context);</programlisting><para>Allocates a new Object. This does the same as the Actionscript code "new <link linkend="Object"><function>Object()</function></link>".</para><para></para><variablelist role="params"><varlistentry><term><parameter>context</parameter> :</term><listitem><simpara> a <link linkend="SwfdecAsContext"><type>SwfdecAsContext</type></link></simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the new object or NULL on out of memory.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="swfdec-as-object-new-empty" role="function"/>swfdec_as_object_new_empty ()</title><indexterm><primary>swfdec_as_object_new_empty</primary></indexterm><programlisting><link linkend="SwfdecAsObject">SwfdecAsObject</link>* swfdec_as_object_new_empty (<link linkend="SwfdecAsContext">SwfdecAsContext</link> *context);</programlisting><para>Creates an empty object. The prototype and constructor properties of thereturned object will not be set. You probably want to call <link linkend="swfdec-as-object-set-constructor"><function>swfdec_as_object_set_constructor()</function></link> on the returned object yourself.You may want to use <link linkend="swfdec-as-object-new"><function>swfdec_as_object_new()</function></link> instead.</para><para></para><variablelist role="params"><varlistentry><term><parameter>context</parameter> :</term><listitem><simpara> a <link linkend="SwfdecAsContext"><type>SwfdecAsContext</type></link></simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> A new <link linkend="SwfdecAsObject"><type>SwfdecAsObject</type></link> adde to <parameter>context</parameter> or <link linkend="NULL:CAPS"><literal>NULL</literal></link> on OOM.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="swfdec-as-object-create" role="function"/>swfdec_as_object_create ()</title><indexterm><primary>swfdec_as_object_create</primary></indexterm><programlisting><link linkend="void">void</link> swfdec_as_object_create (<link linkend="SwfdecAsFunction">SwfdecAsFunction</link> *fun, <link linkend="guint">guint</link> n_args, const <link linkend="SwfdecAsValue">SwfdecAsValue</link> *args);</programlisting><para>Creates a new object for the given constructor and pushes the constructor ontop of the stack. To actually run the constructor, you need to call <link linkend="swfdec-as-context-run"><function>swfdec_as_context_run()</function></link>. After the constructor has been run, the new object will be pushed to the top of the stack.</para><para></para><variablelist role="params">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -