Modified: websites/staging/thrift/trunk/content/tutorial/d.html ============================================================================== --- websites/staging/thrift/trunk/content/tutorial/d.html (original) +++ websites/staging/thrift/trunk/content/tutorial/d.html Sat Mar 22 18:57:03 2014 @@ -87,154 +87,130 @@ </ol> <h3 id="prerequisites">Prerequisites</h3> <h3 id="client">Client</h3> -<div class="codehilite"><pre> <span class="p">:::</span><span class="n">cpp</span> -<span class="n">module</span> <span class="n">server</span><span class="p">;</span> - -<span class="n">import</span> <span class="n">std</span><span class="p">.</span><span class="n">conv</span> <span class="p">:</span> <span class="n">to</span><span class="p">;</span> +<p><div class="codehilite"><pre><span class="n">module</span> <span class="n">server</span><span class="p">;</span></p> +<p><span class="n">import</span> <span class="n">std</span><span class="p">.</span><span class="n">conv</span> <span class="o">:</span> <span class="n">to</span><span class="p">;</span> <span class="n">import</span> <span class="n">std</span><span class="p">.</span><span class="n">stdio</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">codegen</span><span class="p">.</span><span class="n">processor</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">protocol</span><span class="p">.</span><span class="n">binary</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">simple</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">transport</span><span class="p">.</span><span class="n">socket</span><span class="p">;</span> -<span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">transport</span><span class="p">.</span><span class="n">buffered</span><span class="p">;</span> - -<span class="n">import</span> <span class="n">share</span><span class="p">.</span><span class="n">SharedService</span><span class="p">;</span> +<span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">transport</span><span class="p">.</span><span class="n">buffered</span><span class="p">;</span></p> +<p><span class="n">import</span> <span class="n">share</span><span class="p">.</span><span class="n">SharedService</span><span class="p">;</span> <span class="n">import</span> <span class="n">share</span><span class="p">.</span><span class="n">shared_types</span><span class="p">;</span> <span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">Calculator</span><span class="p">;</span> -<span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">tutorial_types</span><span class="p">;</span> - -<span class="o">/**</span> - <span class="o">*</span> <span class="n">The</span> <span class="n">actual</span> <span class="n">implementation</span> <span class="n">of</span> <span class="n">the</span> <span class="n">Calculator</span> <span class="n">interface</span> <span class="n">that</span> <span class="n">is</span> <span class="n">called</span> <span class="n">by</span> - <span class="o">*</span> <span class="n">the</span> <span class="n">server</span> <span class="n">to</span> <span class="n">answer</span> <span class="n">the</span> <span class="n">requests</span><span class="p">.</span> - <span class="o">*/</span> -<span class="n">class</span> <span class="n">CalculatorHandler</span> <span class="p">:</span> <span class="n">Calculator</span> <span class="p">{</span> - <span class="n">void</span> <span class="n">ping</span><span class="p">()</span> <span class="p">{</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">ping</span><span class="p">()</span><span class="o">&</span><span class="n">quot</span><span class="p">;);</span> - <span class="p">}</span> - - <span class="n">int</span> <span class="n">add</span><span class="p">(</span><span class="n">int</span> <span class="n">n1</span><span class="p">,</span> <span class="n">int</span> <span class="n">n2</span><span class="p">)</span> <span class="p">{</span> - <span class="n">writefln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">add</span><span class="p">(</span><span class="c">%s,%s)&quot;, n1, n2);</span> +<span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">tutorial_types</span><span class="p">;</span></p> +<p><span class="cm">/*<em></span> +<span class="cm"> * The actual implementation of the Calculator interface that is called by</span> +<span class="cm"> * the server to answer the requests.</span> +<span class="cm"> </em>/</span> +<span class="k">class</span> <span class="nc">CalculatorHandler</span> <span class="o">:</span> <span class="n">Calculator</span> <span class="p">{</span> + <span class="kt">void</span> <span class="n">ping</span><span class="p">()</span> <span class="p">{</span> + <span class="n">writeln</span><span class="p">(</span><span class="s">"ping()"</span><span class="p">);</span> + <span class="p">}</span></p> +<p><span class="kt">int</span> <span class="n">add</span><span class="p">(</span><span class="kt">int</span> <span class="n">n1</span><span class="p">,</span> <span class="kt">int</span> <span class="n">n2</span><span class="p">)</span> <span class="p">{</span> + <span class="n">writefln</span><span class="p">(</span><span class="s">"add(%s,%s)"</span><span class="p">,</span> <span class="n">n1</span><span class="p">,</span> <span class="n">n2</span><span class="p">);</span> <span class="k">return</span> <span class="n">n1</span> <span class="o">+</span> <span class="n">n2</span><span class="p">;</span> - <span class="p">}</span> - - <span class="n">int</span> <span class="n">calculate</span><span class="p">(</span><span class="n">int</span> <span class="n">logid</span><span class="p">,</span> <span class="n">ref</span> <span class="n">const</span><span class="p">(</span><span class="n">Work</span><span class="p">)</span> <span class="n">work</span><span class="p">)</span> <span class="p">{</span> - <span class="n">writefln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">calculate</span><span class="p">(</span><span class="c">%s, {%s, %s, %s})&quot;, logid, work.op, work.num1, work.num2);</span> - <span class="n">int</span> <span class="n">val</span><span class="p">;</span> - - <span class="k">switch</span> <span class="p">(</span><span class="n">work</span><span class="p">.</span><span class="n">op</span><span class="p">)</span> <span class="p">{</span> - <span class="k">case</span> <span class="n">Operation</span><span class="p">.</span><span class="n">ADD</span><span class="p">:</span> - <span class="n">val</span> <span class="p">=</span> <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="o">+</span> <span class="n">work</span><span class="p">.</span><span class="n">num2</span><span class="p">;</span> - <span class="k">break</span><span class="p">;</span> - <span class="k">case</span> <span class="n">Operation</span><span class="p">.</span><span class="n">SUBTRACT</span><span class="p">:</span> - <span class="n">val</span> <span class="p">=</span> <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="o">-</span> <span class="n">work</span><span class="p">.</span><span class="n">num2</span><span class="p">;</span> - <span class="k">break</span><span class="p">;</span> - <span class="k">case</span> <span class="n">Operation</span><span class="p">.</span><span class="n">MULTIPLY</span><span class="p">:</span> - <span class="n">val</span> <span class="p">=</span> <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="o">*</span> <span class="n">work</span><span class="p">.</span><span class="n">num2</span><span class="p">;</span> - <span class="k">break</span><span class="p">;</span> - <span class="k">case</span> <span class="n">Operation</span><span class="p">.</span><span class="n">DIVIDE</span><span class="p">:</span> - <span class="k">if</span> <span class="p">(</span><span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="o">==</span> 0<span class="p">)</span> <span class="p">{</span> - <span class="n">auto</span> <span class="n">io</span> <span class="p">=</span> <span class="n">new</span> <span class="n">InvalidOperation</span><span class="p">();</span> - <span class="n">io</span><span class="p">.</span><span class="n">what</span> <span class="p">=</span> <span class="n">work</span><span class="p">.</span><span class="n">op</span><span class="p">;</span> - <span class="n">io</span><span class="p">.</span><span class="nb">why</span> <span class="p">=</span> <span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">Cannot</span> <span class="n">divide</span> <span class="n">by</span> 0<span class="o">&</span><span class="n">quot</span><span class="p">;;</span> - <span class="n">throw</span> <span class="n">io</span><span class="p">;</span> - <span class="p">}</span> - <span class="n">val</span> <span class="p">=</span> <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="o">/</span> <span class="n">work</span><span class="p">.</span><span class="n">num2</span><span class="p">;</span> - <span class="k">break</span><span class="p">;</span> - <span class="n">default</span><span class="p">:</span> - <span class="n">auto</span> <span class="n">io</span> <span class="p">=</span> <span class="n">new</span> <span class="n">InvalidOperation</span><span class="p">();</span> - <span class="n">io</span><span class="p">.</span><span class="n">what</span> <span class="p">=</span> <span class="n">work</span><span class="p">.</span><span class="n">op</span><span class="p">;</span> - <span class="n">io</span><span class="p">.</span><span class="nb">why</span> <span class="p">=</span> <span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">Invalid</span> <span class="n">Operation</span><span class="o">&</span><span class="n">quot</span><span class="p">;;</span> - <span class="n">throw</span> <span class="n">io</span><span class="p">;</span> - <span class="p">}</span> - - <span class="n">auto</span> <span class="n">ss</span> <span class="p">=</span> <span class="n">SharedStruct</span><span class="p">();</span> - <span class="n">ss</span><span class="p">.</span><span class="n">key</span> <span class="p">=</span> <span class="n">logid</span><span class="p">;</span> - <span class="n">ss</span><span class="p">.</span><span class="n">value</span> <span class="p">=</span> <span class="n">to</span>!<span class="n">string</span><span class="p">(</span><span class="n">val</span><span class="p">);</span> - <span class="nb">log</span><span class="p">[</span><span class="n">logid</span><span class="p">]</span> <span class="p">=</span> <span class="n">ss</span><span class="p">;</span> + <span class="p">}</span></p> +<p><span class="kt">int</span> <span class="n">calculate</span><span class="p">(</span><span class="kt">int</span> <span class="n">logid</span><span class="p">,</span> <span class="n">ref</span> <span class="k">const</span><span class="p">(</span><span class="n">Work</span><span class="p">)</span> <span class="n">work</span><span class="p">)</span> <span class="p">{</span> + <span class="n">writefln</span><span class="p">(</span><span class="s">"calculate(%s, {%s, %s, %s})"</span><span class="p">,</span> <span class="n">logid</span><span class="p">,</span> <span class="n">work</span><span class="p">.</span><span class="n">op</span><span class="p">,</span> <span class="n">work</span><span class="p">.</span><span class="n">num1</span><span class="p">,</span> <span class="n">work</span><span class="p">.</span><span class="n">num2</span><span class="p">);</span> + <span class="kt">int</span> <span class="n">val</span><span class="p">;</span></p> +<div class="codehilite"><pre><span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>switch<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>(<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>op<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>)<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span> <span class="s">"p"</span><span class="nt">></span>{<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>case<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>Operation<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"nl"</span><span class="nt">></span>ADD:<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>val<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num1<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>+<span class="nt"></span></span> <span class="nt"><span</span> <span cl ass="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num2<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>break<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>case<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>Operation<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"nl"</span><span class="nt">></span>SUBTRACT:<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>val<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num1<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>-<span class="nt"></span></span> <span class="nt"><span</span> <span cl ass="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num2<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>break<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>case<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>Operation<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"nl"</span><span class="nt">></span>MULTIPLY:<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>val<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num1<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>*<span class="nt"></span></span> <span class="nt"><span</span> <span cl ass="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num2<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>break<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>case<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>Operation<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"nl"</span><span class="nt">></span>DIVIDE:<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>if<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>(<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num2<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>==<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><sp an class="s">"mi"</span><span class="nt">></span>0<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>)<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>{<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>auto<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>new<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>InvalidOperation<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>();<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>what<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n&quo t;</span><span class="nt">></span>op<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>why<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"s"</span><span class="nt">></span><span class="ni">&quot;</span>Cannot divide by 0<span class="ni">&quot;</span><span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></ span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>throw<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>}<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>val<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num1<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>/<span class="nt"></span></span> <span class="nt"><span</span> <span cl ass="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>num2<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>break<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>default<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>:<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>auto<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>new<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>InvalidOperation<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>();<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>what<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>work<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n" </span><span class="nt">></span>op<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>why<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"s"</span><span class="nt">></span><span class="ni">&quot;</span>Invalid Operation<span class="ni">&quot;</span><span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></spa n></span> + <span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>throw<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>io<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>}<span class="nt"></span></span> + +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>auto<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>ss<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>SharedStruct<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>();<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>ss<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>key<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>logid<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>ss<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>.<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>value<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>to<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>!<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</s pan><span class="nt">></span>string<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>(<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>val<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>);<span class="nt"></span></span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>log<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>[<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>logid<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>]<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"o"</span><span class="nt">></span>=<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>ss<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</ span><span class="nt">></span>;<span class="nt"></span></span> - <span class="k">return</span> <span class="n">val</span><span class="p">;</span> - <span class="p">}</span> - - <span class="n">SharedStruct</span> <span class="n">getStruct</span><span class="p">(</span><span class="n">int</span> <span class="n">logid</span><span class="p">)</span> <span class="p">{</span> - <span class="n">writefln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">getStruct</span><span class="p">(</span><span class="c">%s)&quot;, logid);</span> - <span class="k">return</span> <span class="nb">log</span><span class="p">[</span><span class="n">logid</span><span class="p">];</span> - <span class="p">}</span> - - <span class="n">void</span> <span class="n">zip</span><span class="p">()</span> <span class="p">{</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">zip</span><span class="p">()</span><span class="o">&</span><span class="n">quot</span><span class="p">;);</span> - <span class="p">}</span> - -<span class="n">protected</span><span class="p">:</span> - <span class="n">SharedStruct</span><span class="p">[</span><span class="n">int</span><span class="p">]</span> <span class="nb">log</span><span class="p">;</span> -<span class="p">}</span> - -<span class="n">void</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> - <span class="n">auto</span> <span class="n">protocolFactory</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBinaryProtocolFactory</span>!<span class="p">();</span> - <span class="n">auto</span> <span class="n">processor</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TServiceProcessor</span>!<span class="n">Calculator</span><span class="p">(</span><span class="n">new</span> <span class="n">CalculatorHandler</span><span class="p">);</span> - <span class="n">auto</span> <span class="n">serverTransport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TServerSocket</span><span class="p">(</span>9090<span class="p">);</span> - <span class="n">auto</span> <span class="n">transportFactory</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBufferedTransportFactory</span><span class="p">;</span> +<span class="nt"><span</span> <span class="na">class=</span><span class="s">"k"</span><span class="nt">></span>return<span class="nt"></span></span> <span class="nt"><span</span> <span class="na">class=</span><span class="s">"n"</span><span class="nt">></span>val<span class="nt"></span><span</span> <span class="na">class=</span><span class="s">"p"</span><span class="nt">></span>;<span class="nt"></span></span> +</pre></div> - <span class="n">auto</span> <span class="n">server</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TSimpleServer</span><span class="p">(</span> - <span class="n">processor</span><span class="p">,</span> <span class="n">serverTransport</span><span class="p">,</span> <span class="n">transportFactory</span><span class="p">,</span> <span class="n">protocolFactory</span><span class="p">);</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">Starting</span> <span class="n">the</span> <span class="n">server</span> <span class="n">on</span> <span class="n">port</span> 9090<span class="p">...</span><span class="o">&</span><span class="n">quot</span><span class="p">;);</span> +<p><span class="p">}</span></p> +<p><span class="n">SharedStruct</span> <span class="n">getStruct</span><span class="p">(</span><span class="kt">int</span> <span class="n">logid</span><span class="p">)</span> <span class="p">{</span> + <span class="n">writefln</span><span class="p">(</span><span class="s">"getStruct(%s)"</span><span class="p">,</span> <span class="n">logid</span><span class="p">);</span> + <span class="k">return</span> <span class="n">log</span><span class="p">[</span><span class="n">logid</span><span class="p">];</span> + <span class="p">}</span></p> +<p><span class="kt">void</span> <span class="n">zip</span><span class="p">()</span> <span class="p">{</span> + <span class="n">writeln</span><span class="p">(</span><span class="s">"zip()"</span><span class="p">);</span> + <span class="p">}</span></p> +<p><span class="k">protected</span><span class="o">:</span> + <span class="n">SharedStruct</span><span class="p">[</span><span class="kt">int</span><span class="p">]</span> <span class="n">log</span><span class="p">;</span> +<span class="p">}</span></p> +<p><span class="kt">void</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> + <span class="k">auto</span> <span class="n">protocolFactory</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TBinaryProtocolFactory</span><span class="o">!</span><span class="p">();</span> + <span class="k">auto</span> <span class="n">processor</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TServiceProcessor</span><span class="o">!</span><span class="n">Calculator</span><span class="p">(</span><span class="k">new</span> <span class="n">CalculatorHandler</span><span class="p">);</span> + <span class="k">auto</span> <span class="n">serverTransport</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TServerSocket</span><span class="p">(</span><span class="mi">9090</span><span class="p">);</span> + <span class="k">auto</span> <span class="n">transportFactory</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TBufferedTransportFactory</span><span class="p">;</span></p> +<p><span class="k">auto</span> <span class="n">server</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TSimpleServer</span><span class="p">(</span> + <span class="n">processor</span><span class="p">,</span> <span class="n">serverTransport</span><span class="p">,</span> <span class="n">transportFactory</span><span class="p">,</span> <span class="n">protocolFactory</span><span class="p">);</span></p> +<p><span class="n">writeln</span><span class="p">(</span><span class="s">"Starting the server on port 9090..."</span><span class="p">);</span> <span class="n">server</span><span class="p">.</span><span class="n">serve</span><span class="p">();</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">done</span><span class="p">.</span><span class="o">&</span><span class="n">quot</span><span class="p">;);</span> + <span class="n">writeln</span><span class="p">(</span><span class="s">"done."</span><span class="p">);</span> <span class="p">}</span> -</pre></div> - - +</pre></div></p> <h3 id="server">Server</h3> -<div class="codehilite"><pre> <span class="p">:::</span><span class="n">cpp</span> -<span class="n">module</span> <span class="n">client</span><span class="p">;</span> - -<span class="n">import</span> <span class="n">std</span><span class="p">.</span><span class="n">stdio</span><span class="p">;</span> +<p><div class="codehilite"><pre><span class="n">module</span> <span class="n">client</span><span class="p">;</span></p> +<p><span class="n">import</span> <span class="n">std</span><span class="p">.</span><span class="n">stdio</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">base</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">codegen</span><span class="p">.</span><span class="n">client</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">protocol</span><span class="p">.</span><span class="n">binary</span><span class="p">;</span> <span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">transport</span><span class="p">.</span><span class="n">buffered</span><span class="p">;</span> -<span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">transport</span><span class="p">.</span><span class="n">socket</span><span class="p">;</span> - -<span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">Calculator</span><span class="p">;</span> -<span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">tutorial_types</span><span class="p">;</span> - -<span class="n">void</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> - <span class="n">auto</span> <span class="n">socket</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TSocket</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">localhost</span><span class="o">&</span><span class="n">quot</span><span class="p">;,</span> 9090<span class="p">);</span> - <span class="n">auto</span> <span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBufferedTransport</span><span class="p">(</span><span class="n">socket</span><span class="p">);</span> - <span class="n">auto</span> <span class="n">protocol</span> <span class="p">=</span> <span class="n">tBinaryProtocol</span><span class="p">(</span><span class="n">transport</span><span class="p">);</span> - <span class="n">auto</span> <span class="n">client</span> <span class="p">=</span> <span class="n">tClient</span>!<span class="n">Calculator</span><span class="p">(</span><span class="n">protocol</span><span class="p">);</span> - - <span class="n">transport</span><span class="p">.</span><span class="n">open</span><span class="p">();</span> - - <span class="n">client</span><span class="p">.</span><span class="n">ping</span><span class="p">();</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">ping</span><span class="p">()</span><span class="o">&</span><span class="n">quot</span><span class="p">;);</span> - - <span class="n">int</span> <span class="n">sum</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">add</span><span class="p">(</span>1<span class="p">,</span> 1<span class="p">);</span> - <span class="n">writefln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span>1 <span class="o">+</span> 1 <span class="p">=</span> <span class="c">%s&quot;, sum);</span> - - <span class="n">auto</span> <span class="n">work</span> <span class="p">=</span> <span class="n">Work</span><span class="p">();</span> - <span class="n">work</span><span class="p">.</span><span class="n">op</span> <span class="p">=</span> <span class="n">Operation</span><span class="p">.</span><span class="n">DIVIDE</span><span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="p">=</span> 1<span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="p">=</span> 0<span class="p">;</span> +<span class="n">import</span> <span class="n">thrift</span><span class="p">.</span><span class="n">transport</span><span class="p">.</span><span class="n">socket</span><span class="p">;</span></p> +<p><span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">Calculator</span><span class="p">;</span> +<span class="n">import</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">tutorial_types</span><span class="p">;</span></p> +<p><span class="kt">void</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> + <span class="k">auto</span> <span class="n">socket</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TSocket</span><span class="p">(</span><span class="s">"localhost"</span><span class="p">,</span> <span class="mi">9090</span><span class="p">);</span> + <span class="k">auto</span> <span class="n">transport</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TBufferedTransport</span><span class="p">(</span><span class="n">socket</span><span class="p">);</span> + <span class="k">auto</span> <span class="n">protocol</span> <span class="o">=</span> <span class="n">tBinaryProtocol</span><span class="p">(</span><span class="n">transport</span><span class="p">);</span> + <span class="k">auto</span> <span class="n">client</span> <span class="o">=</span> <span class="n">tClient</span><span class="o">!</span><span class="n">Calculator</span><span class="p">(</span><span class="n">protocol</span><span class="p">);</span></p> +<p><span class="n">transport</span><span class="p">.</span><span class="n">open</span><span class="p">();</span></p> +<p><span class="n">client</span><span class="p">.</span><span class="n">ping</span><span class="p">();</span> + <span class="n">writeln</span><span class="p">(</span><span class="s">"ping()"</span><span class="p">);</span></p> +<p><span class="kt">int</span> <span class="n">sum</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> + <span class="n">writefln</span><span class="p">(</span><span class="s">"1 + 1 = %s"</span><span class="p">,</span> <span class="n">sum</span><span class="p">);</span></p> +<p><span class="k">auto</span> <span class="n">work</span> <span class="o">=</span> <span class="n">Work</span><span class="p">();</span> + <span class="n">work</span><span class="p">.</span><span class="n">op</span> <span class="o">=</span> <span class="n">Operation</span><span class="p">.</span><span class="n">DIVIDE</span><span class="p">;</span> + <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> + <span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="k">try</span> <span class="p">{</span> - <span class="n">int</span> <span class="n">quotient</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">calculate</span><span class="p">(</span>1<span class="p">,</span> <span class="n">work</span><span class="p">);</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">Whoa</span> <span class="n">we</span> <span class="n">can</span> <span class="n">divide</span> <span class="n">by</span> 0<span class="o">&</span><span class="n">quot</span><span class="p">;);</span> + <span class="kt">int</span> <span class="n">quotient</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="n">calculate</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">work</span><span class="p">);</span> + <span class="n">writeln</span><span class="p">(</span><span class="s">"Whoa we can divide by 0"</span><span class="p">);</span> <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">InvalidOperation</span> <span class="n">io</span><span class="p">)</span> <span class="p">{</span> - <span class="n">writeln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">Invalid</span> <span class="n">operation</span><span class="p">:</span> <span class="o">&</span><span class="n">quot</span><span class="p">;</span> <span class="o">~</span> <span class="n">io</span><span class="p">.</span><span class="nb">why</span><span class="p">);</span> - <span class="p">}</span> - - <span class="n">work</span><span class="p">.</span><span class="n">op</span> <span class="p">=</span> <span class="n">Operation</span><span class="p">.</span><span class="n">SUBTRACT</span><span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="p">=</span> 15<span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="p">=</span> 10<span class="p">;</span> - <span class="n">int</span> <span class="n">diff</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">calculate</span><span class="p">(</span>1<span class="p">,</span> <span class="n">work</span><span class="p">);</span> - <span class="n">writefln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span>15 <span class="o">-</span> 10 <span class="p">=</span> <span class="c">%s&quot;, diff);</span> - - <span class="n">auto</span> <span class="nb">log</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">getStruct</span><span class="p">(</span>1<span class="p">);</span> - <span class="n">writefln</span><span class="p">(</span><span class="o">&</span><span class="n">quot</span><span class="p">;</span><span class="n">Check</span> <span class="nb">log</span><span class="p">:</span> <span class="c">%s&quot;, log.value);</span> + <span class="n">writeln</span><span class="p">(</span><span class="s">"Invalid operation: "</span> <span class="o">~</span> <span class="n">io</span><span class="p">.</span><span class="n">why</span><span class="p">);</span> + <span class="p">}</span></p> +<p><span class="n">work</span><span class="p">.</span><span class="n">op</span> <span class="o">=</span> <span class="n">Operation</span><span class="p">.</span><span class="n">SUBTRACT</span><span class="p">;</span> + <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="o">=</span> <span class="mi">15</span><span class="p">;</span> + <span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="o">=</span> <span class="mi">10</span><span class="p">;</span> + <span class="kt">int</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="n">calculate</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">work</span><span class="p">);</span> + <span class="n">writefln</span><span class="p">(</span><span class="s">"15 - 10 = %s"</span><span class="p">,</span> <span class="n">diff</span><span class="p">);</span></p> +<p><span class="k">auto</span> <span class="n">log</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="n">getStruct</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> + <span class="n">writefln</span><span class="p">(</span><span class="s">"Check log: %s"</span><span class="p">,</span> <span class="n">log</span><span class="p">.</span><span class="n">value</span><span class="p">);</span> <span class="p">}</span> -</pre></div> - - +</pre></div></p> <h2 id="additional-information">Additional Information</h2> </div>