<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='color:#1F497D'>Magic thanks! I knew you needed
this for Singleton methods but the fact that it was a private instance method as
well threw me.<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Now I can start hitting the
rubyspec tests for BigDecimal.<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Pete<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] <b>On Behalf Of </b>Curt
Hagenlocher<br>
<b>Sent:</b> Sunday,13 July 13, 2008 21:48<br>
<b>To:</b> ironruby-core@rubyforge.org<br>
<b>Subject:</b> Re: [Ironruby-core] Adding methods to Kernel<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>You need to declare a
&#8220;self&#8221; parameter, even though it will be unused.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> ironruby-core-bounces@rubyforge.org [mailto:ironruby-core-bounces@rubyforge.org]
<b>On Behalf Of </b>Peter Bacon Darwin<br>
<b>Sent:</b> Sunday, July 13, 2008 1:46 PM<br>
<b>To:</b> ironruby-core@rubyforge.org<br>
<b>Subject:</b> [Ironruby-core] Adding methods to Kernel<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal>I am still having problems adding the BigDecimal method into
the Kernel module.&nbsp; As I understand it the correct method is to create a
new class that extends Kernel and adds the methods as both Private-Instance and
Public-Singleton.&nbsp; This is the code:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>namespace Ruby.StandardLibrary.BigDecimal {<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp; [RubyModule(Extends = typeof(Kernel))]<o:p></o:p></p>

<p class=MsoNormal>&nbsp; &nbsp;&nbsp;public static class KernelOps {<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[RubyMethod(&quot;BigDecimal&quot;, RubyMethodAttributes.PrivateInstance)]<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[RubyMethod(&quot;BigDecimal&quot;, RubyMethodAttributes.PublicSingleton)]<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static
BigDecimal/*!*/ CreateBigDecimal(CodeContext/*!*/ context,
[NotNull]MutableString/*!*/ value, [Optional]int n) {<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return BigDecimalOps.CreateBigDecimal(value, n);<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[RubyMethod(&quot;BigDecimal&quot;, RubyMethodAttributes.PrivateInstance)]<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[RubyMethod(&quot;BigDecimal&quot;, RubyMethodAttributes.PublicSingleton)]<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static
BigDecimal/*!*/ CreateBigDecimal(CodeContext/*!*/ context, object value,
[Optional]int n) {<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return BigDecimalOps.CreateBigDecimal(context, value, n);<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoNormal>}<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>This appears to create the methods (you can see them in
Kernel.methods)&nbsp; but it is not possible to call them.&nbsp; You always get
an ArgumentError thrown with &#8220;incorrect type or number of parameters&#8221; as a
message.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I have been digging through the code but I can&#8217;t work out
why this is happening.&nbsp; One thing that seems a little worrying but not
necessarily wrong is that it appears that the target (self) has a RubyClass of
type Ruby.Builtins. BuiltinsLibraryInitializer, which seems rather bizarre.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Currently I am able to get around this by defining the
methods in Ruby itself, I changed the bigdecimal.rb file in the libs folder to:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>load_assembly 'IronRuby.Libraries',
'Ruby.StandardLibrary.BigDecimal'<o:p></o:p></p>

<p class=MsoNormal>class Object<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
def BigDecimal(v, n = 0)<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
BigDecimal.new(v,n)<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
end<o:p></o:p></p>

<p class=MsoNormal>end<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Any ideas?<o:p></o:p></p>

<p class=MsoNormal>Pete<o:p></o:p></p>

</div>

</body>

</html>