Forum: Ruby-dev Ruby Extension - Issue with arguments received in method_missing()

9b1a56162496bd47293fccce1abbdb47?d=identicon&s=25 Aarti Mahajan (aartimahajan)
on 2013-08-23 15:09
Hi All,

We have implemented Ruby extension using CPP as described here
http://www.ruby-doc.org/docs/ProgrammingRuby/html/...
This Ruby extension works as UNO-Ruby Bridge which allows implementation
of Uno components using
Ruby(https://github.com/hanya/RUNO/blob/master/doc/runo...).
However I encountered a corner case in the following scenario. I have a
uno struct (i.e Book) containing a member of the type UNO Sequence (i.e
data).

1. When we use following approach to assign values to Book.data member,
it works:

setValue = Svc::Rubyunobridge::Test::Book.new
setValue.No = 1
setValue.Name = "ABC"
dataElements = Array.new
dataElements << 0x40 << 0x0 << 0x07 << 0x0
setValue.data = dataElements

Following is the reason why above assignment works:
a. UNO-Ruby Bridge is built upon method_missing(). Whenever any new
construct is encountered in Ruby script, Ruby invokes method_missing()
by passing appropriate arguments to this method.
b. In above scenario, method_missing() gets parameter methodName as
"data=" and args as "dataElements". If methodName ends with a '=' (in
this case it does), value of args is assigned to methodName.

2. When we use following approach to assign values to Book.data member,
it gives unexpected result.

setValue.data[0] = 0x40
setValue.data[1] = 0x0
setValue.data[2] = 0x07
setValue.data[3] = 0x0

In this case, Ruby invokes method_missing(), however arguments to this
method_missing() are not getting populated correctly from Ruby.
In this case inside method_missing(), we get parameter methodName as
"data" and args as empty. Thus the assignment fails.

Our interest is to make above mentioned second approach work.

The implementation of method_missing() is very similar to the
runo_proxy_method_missing() in
https://github.com/hanya/RUNO/blob/master/src/module.cxx

Is there any way this can be achieved?
Any help/pointers are much appreciated.


Thanks & Regards,
Aarti
This topic is locked and can not be replied to.