ruby-rice / rice

Ruby Interface for C++ Extensions
http://ruby-rice.github.io/
Other
378 stars 63 forks source link

Can't Call Methods on Ancestor Classes #178

Closed cfis closed 1 year ago

cfis commented 1 year ago

While implementing std::map, I discovered that Rice doesn't support calling methods that are defined on ancestor classes.

For example, calling std::map#size does not work because std::map itself does not define size, but instead its parent class. This causes Rice to fail because when it tires to retrieve the C++ object from the Ruby object, its doesn't ask for From_Ruby<std::map<T1, T2>> but instead asks for From_Ruby. It does that because when you take a pointer to the member function size, C++ returns a function pointer where the class is std::_tree and not std::map.

The std::_tree class however is not registered in the Type Registry and thus Rice throws an error.

Thus NativeFunction::Self_T may not be the actual type of the Class that Rice wrapped. Since there is now way to extract that information after the fact (at least that I know about), a new typename parameter needs to be added to the NativeFunction template.

Will push a change with that fix.