⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swfdec-internals.html

📁 Swfdec is a decoder/renderer for Macromedia Flash animations. The decoding and rendering engine is
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Internals and garbage collection</title><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="index.html" title="Swfdec Reference Manual"><link rel="up" href="ch03.html" title="Actionscript interpreter"><link rel="prev" href="ch03.html" title="Actionscript interpreter"><link rel="next" href="swfdec-SwfdecAsValue.html" title="SwfdecAsValue"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="ch01.html" title="Swfdec Gtk library"><link rel="chapter" href="ch02.html" title="Swfdec library"><link rel="chapter" href="ch03.html" title="Actionscript interpreter"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="ch03.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="ch03.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">Swfdec Reference Manual</th><td><a accesskey="n" href="swfdec-SwfdecAsValue.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id2565755" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id2595491" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="swfdec-Internals"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id2565755"></a><span class="refentrytitle">Internals and garbage collection</span></h2><p>Internals and garbage collection &#8212; understanding internals such as garbage collection</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">void                <a href="swfdec-Internals.html#swfdec-as-object-mark">swfdec_as_object_mark</a>               (<a href="swfdec-SwfdecAsObject.html#SwfdecAsObject">SwfdecAsObject</a> *object);void                <a href="swfdec-Internals.html#swfdec-as-string-mark">swfdec_as_string_mark</a>               (const char *string);void                <a href="swfdec-Internals.html#swfdec-as-value-mark">swfdec_as_value_mark</a>                (<a href="swfdec-SwfdecAsValue.html#SwfdecAsValue">SwfdecAsValue</a> *value);</pre></div><div class="refsect1" lang="en"><a name="id2595491"></a><h2>Description</h2><p>This section deals with the internals of the Swfdec Actionscript engine. Youshould probably read this first when trying to write code with it. If you'rejust trying to use Swfdec for creating Flash content, you can probably skipthis section.</p><p>First, I'd like to note that the Swfdec script engine has to be modeled very closely after the existing Flash players. So if there are some behavioursthat seem stupid at first sight, it might very well be that it was chosen fora very particular reason. Now on to the features.</p><p>The Swfdec script engine tries to imitate Actionscript as good as possible.Actionscript is similar to Javascript, but not equal. Depending on the version of the script executed it might be more or less similar. An importantexample is that Flash in versions up to 6 did case-insensitive variable lookups.</p><p>The script engine starts its life when it is initialized via <a href="SwfdecAsContext.html#swfdec-as-context-startup"><code class="function">swfdec_as_context_startup()</code></a>. At that point, the basic objects are created.After this function has been called, you can start executing code. All codeexecution happens by creating a new <a href="swfdec-SwfdecAsFrame.html#SwfdecAsFrame"><span class="type">SwfdecAsFrame</span></a> and then calling <a href="SwfdecAsContext.html#swfdec-as-context-run"><code class="function">swfdec_as_context_run()</code></a> to execute it. This function is the single entry point for code execution. Convenience functions exist that make executing code easy, most notably <a href="swfdec-SwfdecAsObject.html#swfdec-as-object-run"><code class="function">swfdec_as_object_run()</code></a> and <a href="swfdec-SwfdecAsObject.html#swfdec-as-object-call"><code class="function">swfdec_as_object_call()</code></a>.</p><p>It is also easily possible to extend the environment by adding new objects.In fact, without doing so, the environment is pretty bare as it just containsthe basic Math, String, Number, Array, Date and Boolean objects. This is doneby adding <a href="swfdec-SwfdecAsFunction.html#SwfdecAsNative"><span class="type">SwfdecAsNative</span></a> functions to the environment. The easy wayto do this is via <a href="swfdec-SwfdecAsObject.html#swfdec-as-object-add-function"><code class="function">swfdec_as_object_add_function()</code></a>.</p><p>The Swfdec script engine is dynamically typed and knows about different typesof values. See <a href="swfdec-SwfdecAsValue.html#SwfdecAsValue"><span class="type">SwfdecAsValue</span></a> for the different values. Memory management isdone using a mark and sweep garbage collector. You can initiate a garbage collection cycle by calling <a href="SwfdecAsContext.html#swfdec-as-context-gc"><code class="function">swfdec_as_context_gc()</code></a> or <a href="SwfdecAsContext.html#swfdec-as-context-maybe-gc"><code class="function">swfdec_as_context_maybe_gc()</code></a>. You should do this regularly to avoid excessivememory use. The <a href="SwfdecAsContext.html" title="SwfdecAsContext"><span class="type">SwfdecAsContext</span></a> will then collect the objects and strings itis keeping track of. If you want to use an object or string in the script engine, you'll have to add it first via <a href="swfdec-SwfdecAsObject.html#swfdec-as-object-add"><code class="function">swfdec_as_object_add()</code></a> or<a href="SwfdecAsContext.html#swfdec-as-context-get-string"><code class="function">swfdec_as_context_get_string()</code></a> and <a href="SwfdecAsContext.html#swfdec-as-context-give-string"><code class="function">swfdec_as_context_give_string()</code></a>, respectively.</p><p>Garbage-collected strings are special in Swfdec in that they are unique. Thismeans the same string exists exactly once. Because of this you can do equality comparisons using == instead of strcmp. It also means that if you forget to add a string to the context before using it, your app will most likely not work, since the string will not compare equal to any other string.</p><p>When a garbage collection cycle happens, all reachable objects and strings are marked and all unreachable ones are freed. This is done by calling thecontext class's mark function which will mark all reachable objects. This isusually called the "root set". For any reachable object, the object's markfunction is called so that the object in turn can mark all objects it can reach itself. Marking is done via functions described below.</p><p></p></div><div class="refsect1" lang="en"><a name="id2608064"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2608074"></a><h3><a name="swfdec-as-object-mark"></a>swfdec_as_object_mark ()</h3><a class="indexterm" name="id2608086"></a><pre class="programlisting">void                swfdec_as_object_mark               (<a href="swfdec-SwfdecAsObject.html#SwfdecAsObject">SwfdecAsObject</a> *object);</pre><p>Mark <em class="parameter"><code>object</code></em> as being in use. Calling this function is only valid duringthe marking phase of garbage collection.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>object</code></em>&#160;:</span></td><td> a <a href="swfdec-SwfdecAsObject.html#SwfdecAsObject"><span class="type">SwfdecAsObject</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2608691"></a><h3><a name="swfdec-as-string-mark"></a>swfdec_as_string_mark ()</h3><a class="indexterm" name="id2608702"></a><pre class="programlisting">void                swfdec_as_string_mark               (const char *string);</pre><p>Mark <em class="parameter"><code>string</code></em> as being in use. Calling this function is only valid duringthe marking phase of garbage collection.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>string</code></em>&#160;:</span></td><td> a garbage-collected string</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2608759"></a><h3><a name="swfdec-as-value-mark"></a>swfdec_as_value_mark ()</h3><a class="indexterm" name="id2608770"></a><pre class="programlisting">void                swfdec_as_value_mark                (<a href="swfdec-SwfdecAsValue.html#SwfdecAsValue">SwfdecAsValue</a> *value);</pre><p>Mark <em class="parameter"><code>value</code></em> as being in use. This is just a convenience function that callsthe right marking function depending on the value's type. Calling this function is only valid during the marking phase of garbage collection.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>value</code></em>&#160;:</span></td><td> a <a href="swfdec-SwfdecAsValue.html#SwfdecAsValue"><span class="type">SwfdecAsValue</span></a></td></tr></tbody></table></div></div></div><div class="refsect1" lang="en"><a name="id2608838"></a><h2>See Also</h2><a href="SwfdecAsContext.html" title="SwfdecAsContext"><span class="type">SwfdecAsContext</span></a></div><div class="refsect1" lang="en"><a name="id2608853"></a><div class="refsect2" lang="en"><a name="id2608854"></a></div><hr><div class="refsect2" lang="en"><a name="id2616758"></a></div></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -