public static VALUE Initialize(int nargs, VALUE[] args, VALUE self) { try { if (nargs > 1) { Ruby.rb_raise(Ruby.rb_eArgError, "wrong number of arguments"); return(Ruby.Qnil); } string name = ""; if (nargs == 1) { VALUE arg0 = args[0]; Ruby.Check_Type(arg0, Ruby.T_STRING); name = Ruby.StringValuePtr(arg0); } MainWindowWrapper instance = new MainWindowWrapper(name); GCHandle handle = GCHandle.Alloc(instance, GCHandleType.Normal); IntPtr pointer = GCHandle.ToIntPtr(handle); Ruby.SET_DATA_PTR(self, pointer); return(self); } catch (Exception exception) { Ruby.rb_raise(Ruby.rb_eException, exception.Message); return(Ruby.Qnil); } }
public static VALUE SetName(VALUE self, VALUE val) { IntPtr pointer = Ruby.Data_Get_Struct(self); GCHandle handle = GCHandle.FromIntPtr(pointer); MainWindowWrapper instance = (MainWindowWrapper)handle.Target; if (instance != null) { Ruby.Check_Type(val, Ruby.T_STRING); instance.Name = Ruby.StringValuePtr(val); return(val); } return(Ruby.Qnil); }