Skip to content

Instantly share code, notes, and snippets.

@gaffo
Created February 28, 2013 03:58
Show Gist options
  • Save gaffo/5054055 to your computer and use it in GitHub Desktop.
Save gaffo/5054055 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <stdio.h>
using namespace std;
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/value.h>
class CTest{
public:
CTest() {}
void do(){
printf("DO!\n");
}
};
mrb_value CTest_initialize(mrb_state * mrb, mrb_value self){
CTest * pC = new CTest();
// Store that somehow
return ???
}
mrb_value CTest_do(mrb_state * mrb, mrb_value self){
CTest * pC = self.???
pC->do();
return self;
}
int main() {
mrb_state *mrb = mrb_open();
struct RClass * handle = mrb_define_class(mrb, "CTest", mrb->object_class);
mrb_define_method(mrb, handle, "initialize", CTest_initialize, ARGS_NONE());
mrb_define_method(mrb, handle, "do", CTest_do, ARGS_NONE());
mrb_load_string(mrb, "CTest.new.do");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment