/xbmc/visualizations/Vortex/angelscript/docs/manual/doc_addon_helpers.html
http://github.com/xbmc/xbmc · HTML · 55 lines · 51 code · 3 blank · 1 comment · 0 complexity · dd983fe71bf4d12f9f9cfa98c306d370 MD5 · raw file
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
- <title>AngelScript: Helper functions</title>
- <link href="tabs.css" rel="stylesheet" type="text/css">
- <link href="doxygen.css" rel="stylesheet" type="text/css">
- </head><body>
- <!-- Generated by Doxygen 1.5.9 -->
- <div class="contents">
- <h1><a class="anchor" name="doc_addon_helpers">Helper functions </a></h1><b>Path:</b> /sdk/add_on/scripthelper/<p>
- These helper functions simplify the implemention of common tasks. They can be used as is or can serve as the starting point for your own framework.<h2><a class="anchor" name="doc_addon_helpers_1">
- Public C++ interface</a></h2>
- <div class="fragment"><pre class="fragment"><span class="comment">// Compare relation between two objects of the same type.</span>
- <span class="comment">// Uses the object's opCmp method to perform the comparison.</span>
- <span class="comment">// Returns a negative value if the comparison couldn't be performed.</span>
- <span class="keywordtype">int</span> CompareRelation(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine, <span class="keywordtype">void</span> *leftObj, <span class="keywordtype">void</span> *rightObj, <span class="keywordtype">int</span> typeId, <span class="keywordtype">int</span> &result);
- <span class="comment">// Compare equality between two objects of the same type.</span>
- <span class="comment">// Uses the object's opEquals method to perform the comparison, or if that doesn't exist the opCmp method.</span>
- <span class="comment">// Returns a negative value if the comparison couldn't be performed.</span>
- <span class="keywordtype">int</span> CompareEquality(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine, <span class="keywordtype">void</span> *leftObj, <span class="keywordtype">void</span> *rightObj, <span class="keywordtype">int</span> typeId, <span class="keywordtype">bool</span> &result);
- <span class="comment">// Compile and execute simple statements.</span>
- <span class="comment">// The module is optional. If given the statements can access the entities compiled in the module.</span>
- <span class="comment">// The caller can optionally provide its own context, for example if a context should be reused.</span>
- <span class="keywordtype">int</span> ExecuteString(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine, <span class="keyword">const</span> <span class="keywordtype">char</span> *code, <a class="code" href="classas_i_script_module.html" title="The interface to the script modules.">asIScriptModule</a> *mod = 0, <a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *ctx = 0);
- </pre></div><h2><a class="anchor" name="doc_addon_helpers_2">
- Example</a></h2>
- To compare two script objects the application can execute the following code:<p>
- <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Compare(<a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a> *a, <a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a> *b)
- {
- <a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine = a-><a class="code" href="classas_i_script_object.html#5dda2d380ae1580e15ddf9d95893c57a" title="Return the script engine.">GetEngine</a>();
- <span class="keywordtype">int</span> typeId = a-><a class="code" href="classas_i_script_object.html#19c5ab9d8adb0f921bf0b6474d97f468" title="Returns the type id of the object.">GetTypeId</a>();
- <span class="keywordtype">int</span> cmp;
- <span class="keywordtype">int</span> r = CompareRelation(engine, a, b, typeId, cmp);
- <span class="keywordflow">if</span>( r < 0 )
- {
- cout << <span class="stringliteral">"The relation between a and b cannot be established b"</span> << endl;
- }
- <span class="keywordflow">else</span>
- {
- <span class="keywordflow">if</span>( cmp < 0 )
- cout << <span class="stringliteral">"a is smaller than b"</span> << endl;
- <span class="keywordflow">else</span> <span class="keywordflow">if</span>( cmp == 0 )
- cout << <span class="stringliteral">"a is equal to b"</span> << endl;
- <span class="keywordflow">else</span>
- cout << <span class="stringliteral">"a is greater than b"</span> << endl;
- }
- }
- </pre></div> </div>
- <hr size="1"><address style="text-align: right;"><small>Generated on Wed Dec 16 19:34:50 2009 for AngelScript by
- <a href="http://www.doxygen.org/index.html">
- <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
- </body>
- </html>