-
-
Save jasonroelofs/234094 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mkmf-rice' | |
| create_makefile('virtual') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'virtual' | |
| class Toto < VirtualBase | |
| def initialize | |
| super | |
| puts "init" | |
| end | |
| end | |
| b = Toto.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class VirtualBase { | |
| public: | |
| VirtualBase(); | |
| // virtual int doWork() {return 0;} | |
| // virtual int processWorker() = 0; | |
| }; | |
| #include "rice/Director.hpp" | |
| using namespace Rice; | |
| class VirtualBaseProxy : public VirtualBase, public Rice::Director { | |
| public: | |
| VirtualBaseProxy(Object self) : Rice::Director(self) { } | |
| /* | |
| virtual int doWork() { | |
| if(callIsFromRuby("do_work")) { | |
| return VirtualBase::doWork(); | |
| } else { | |
| return from_ruby<int>( getSelf().call("do_work") ); | |
| } | |
| } | |
| virtual int processWorker() { | |
| if(callIsFromRuby("process_worker")) { | |
| raisePureVirtual(); | |
| } else { | |
| return from_ruby<int>( getSelf().call("process_worker") ); | |
| } | |
| }*/ | |
| }; | |
| #include "rice/Constructor.hpp" | |
| extern "C" | |
| void Init_virtual() { | |
| // See Caveat below | |
| define_class<VirtualBase>("__VirtualBase__"); | |
| define_class<VirtualBaseProxy, VirtualBase>("VirtualBase") | |
| .define_constructor(Constructor<VirtualBaseProxy, Object>()); | |
| // .define_method("do_work", &VirtualBaseProxy::doWork); | |
| // .define_method("process_worker", &VirtualBaseProxy::processWorker); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment