ref/ruby/classes/Vpi/Handle.src/M000040.html in ruby-vpi-12.1.0 vs ref/ruby/classes/Vpi/Handle.src/M000040.html in ruby-vpi-13.0.0

- old
+ new

@@ -3,16 +3,66 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>z? (Vpi::Handle)</title> + <title>method_missing (Vpi::Handle)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> - <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/vpi.rb, line 63</span> -63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">z?</span> -64: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">hexStrVal</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/z/i</span> -65: <span class="ruby-keyword kw">end</span></pre> + <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/vpi.rb, line 223</span> +223: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span> <span class="ruby-identifier">aMeth</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">aArgs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">aBlockArg</span> +224: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> = <span class="ruby-identifier">vpi_handle_by_name</span>(<span class="ruby-identifier">aMeth</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">self</span>) +225: <span class="ruby-comment cmt"># cache the child for future accesses, in order to cut down number of calls to method_missing</span> +226: (<span class="ruby-keyword kw">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">end</span>).<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span> +227: <span class="ruby-identifier">define_method</span> <span class="ruby-identifier">aMeth</span> <span class="ruby-keyword kw">do</span> +228: <span class="ruby-identifier">child</span> +229: <span class="ruby-keyword kw">end</span> +230: <span class="ruby-keyword kw">end</span> +231: +232: <span class="ruby-identifier">child</span> +233: +234: <span class="ruby-keyword kw">else</span> +235: <span class="ruby-identifier">prop</span> = <span class="ruby-ivar">@@propCache</span>[<span class="ruby-identifier">aMeth</span>] +236: +237: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">operation</span> +238: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">operation</span>, <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">aArgs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">aBlockArg</span>) +239: +240: <span class="ruby-keyword kw">else</span> +241: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">accessor</span> +242: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:d</span> <span class="ruby-comment cmt"># delay values</span> +243: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">'processing of delay values is not yet implemented.'</span> +244: <span class="ruby-comment cmt"># TODO: vpi_put_delays</span> +245: <span class="ruby-comment cmt"># TODO: vpi_get_delays</span> +246: +247: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:l</span> <span class="ruby-comment cmt"># logic values</span> +248: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span> +249: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">aArgs</span>.<span class="ruby-identifier">shift</span> +250: <span class="ruby-identifier">put_value</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">aArgs</span>) +251: <span class="ruby-keyword kw">else</span> +252: <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>) +253: <span class="ruby-keyword kw">end</span> +254: +255: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:i</span> <span class="ruby-comment cmt"># integer values</span> +256: <span class="ruby-identifier">vpi_get</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span> +257: +258: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:b</span> <span class="ruby-comment cmt"># boolean values</span> +259: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span> +260: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">vpi_get</span>(<span class="ruby-identifier">prop</span>, <span class="ruby-keyword kw">self</span>) +261: <span class="ruby-identifier">value</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">value</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>) <span class="ruby-comment cmt"># zero is false in C</span> +262: <span class="ruby-keyword kw">end</span> +263: +264: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:s</span> <span class="ruby-comment cmt"># string values</span> +265: <span class="ruby-identifier">vpi_get_str</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span> +266: +267: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:h</span> <span class="ruby-comment cmt"># handle values</span> +268: <span class="ruby-identifier">vpi_handle</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span> +269: +270: <span class="ruby-keyword kw">else</span> +271: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>, <span class="ruby-node">&quot;unable to access VPI property #{prop.name.inspect} through method #{aMeth.inspect} with arguments #{aArgs.inspect} for handle #{self}&quot;</span> +272: <span class="ruby-keyword kw">end</span> +273: <span class="ruby-keyword kw">end</span> +274: <span class="ruby-keyword kw">end</span> +275: <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file