# Handling ruby types and CallSiteStorage in std library

**URL:** <https://www.ruby-forum.com/t/handling-ruby-types-and-callsitestorage-in-std-library/179538>\
**Category:** IronRuby\
**Created:** [November 27, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/handling-ruby-types-and-callsitestorage-in-std-library/179538 "2009-11-27T18:33:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [November 27, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/handling-ruby-types-and-callsitestorage-in-std-library/179538/1 "2009-11-27T18:33:59Z")

</div>

I’m working on adding code to the OpenSSL extension of the standard  
library and I need to understand the design for invoking and typing Ruby  
code. I read the ‘Modifying the sources’ github page and it mentions  
using CallSiteStorage to call into Ruby code.

Specifically, the Cipher ruby class has a dependency on the Digest ruby  
classes for the pkcs5\_keyivgen method. An optional parameter for this  
method is an instance of the Ruby class Digest::Base. How would the  
type look, maybe Digest.Digest.Base digest/_optional_/? Or would it be  
an object and I’d also need to pass in CallSiteStorage to call methods  
on the object?

An example in the standard library of such behavior would be much  
appreciated, thanks for any help.

---

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [November 27, 2009, 11:38pm UTC](https://www.ruby-forum.com/t/handling-ruby-types-and-callsitestorage-in-std-library/179538/2 "2009-11-27T23:38:36Z")

</div>

It depends whether the method is supposed to invoke Digest’s methods  
dynamically or not. Does pkcs5\_keyivgen method accept any Ruby object  
that implements the methods pkcs5\_keyivgen calls? Or does it need to be  
an instance of Digest class?  
If the former is true than you need to use “object” as the parameter  
type and use dynamic call sites to invoke those methods. An example of  
such dynamic behavior would be MutableStringOps.Compare. If the latter  
is true you can just type the parameter to Digest CLR type and call its  
methods directly.

Tomas

---

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [November 27, 2009, 11:47pm UTC](https://www.ruby-forum.com/t/handling-ruby-types-and-callsitestorage-in-std-library/179538/3 "2009-11-27T23:47:22Z")

</div>

BTW: Since parts of the OpenSSL library are already written in Ruby (see  
ruby-1.8.6p368\lib\ruby\1.8\openssl directory) it might be easier to  
write the rest in Ruby as well. With calls to .NET implementation of the  
cryptographic algorithms, of course.  
If you chose to go that way you can add the scripts to  
Merlin\Main\Languages\Ruby\Libs.

Tomas

---

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [December 16, 2009, 5:01am UTC](https://www.ruby-forum.com/t/handling-ruby-types-and-callsitestorage-in-std-library/179538/4 "2009-12-16T05:01:21Z")

</div>

Writing it in Ruby worked well for me in this case, thanks Tomas.
