[Gridflow-cvs] [svn] commit: r3489 - in /trunk: base/grid.c base/grid.h rubyext.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Apr 14 15:19:51 EDT 2008


Author: matju
Date: Mon Apr 14 15:19:49 2008
New Revision: 3489

Log:
remove FObject::rself

Modified:
    trunk/base/grid.c
    trunk/base/grid.h
    trunk/rubyext.c

Modified: trunk/base/grid.c
==============================================================================
--- trunk/base/grid.c (original)
+++ trunk/base/grid.c Mon Apr 14 15:19:49 2008
@@ -37,7 +37,6 @@
 static Ruby Pointer_s_new (void *ptr) {
 	Pointer *self = new Pointer(ptr);
 	Ruby rself = Data_Wrap_Struct(EVAL("GridFlow::Pointer"), 0, CObject_free, self);
-	self->rself = rself;
 	return rself;
 }
 static void *Pointer_get (Ruby rself) {
@@ -451,5 +450,6 @@
 #define FOO(S) foo.give(0,(S *)0);
 EACH_NUMBER_TYPE(FOO)
 #undef FOO
-}
-
+	//foo.send(0,(float64 *)0); // this doesn't work, when trying to fix the new link problem in --lite mode.
+}
+

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Mon Apr 14 15:19:49 2008
@@ -316,8 +316,7 @@
 
 struct CObject {
 	int32 refcount;
-	Ruby rself; // point to Ruby peer
-	CObject() : refcount(0), rself(0) {}
+	CObject() : refcount(0) {}
 	virtual ~CObject() {}
 };
 void CObject_free (void *);
@@ -829,14 +828,11 @@
 \class FObject : CObject {
 	BFObject *bself; // point to PD peer
 	FObject() : bself(0) {}
-	\decl void send_in (...);
-	\decl void send_out (...);
 	template <class T> void send_out(int outlet, int argc, T *argv) {
 		t_atom foo[argc];
 		for (int i=0; i<argc; i++) SETFLOAT(&foo[i],argv[i]);
 		outlet_list(bself->out[outlet],&s_list,argc,foo);
 	}
-	\decl void delete_m ();
 };
 \end class FObject
 
@@ -860,7 +856,7 @@
 extern "C" void Init_gridflow ();
 extern Numop *op_add,*op_sub,*op_mul,*op_div,*op_mod,*op_shl,*op_and,*op_put;
 
-#define ARGS(OBJ) rb_str_ptr(rb_funcall(OBJ->rself,SI(args),0))
+#define ARGS(OBJ) "(some object...)"
 #define NOTEMPTY(_a_) if (!(_a_)) RAISE("in [%s], '%s' is empty",ARGS(this), #_a_);
 #define SAME_TYPE(_a_,_b_) \
 	if ((_a_)->nt != (_b_)->nt) RAISE("%s: same type please (%s has %s; %s has %s)", ARGS(this), \

Modified: trunk/rubyext.c
==============================================================================
--- trunk/rubyext.c (original)
+++ trunk/rubyext.c Mon Apr 14 15:19:49 2008
@@ -79,20 +79,12 @@
 #include <setjmp.h>
 #define rb_sym_name rb_sym_name_r4j
 static const char *rb_sym_name(Ruby sym) {return rb_id2name(SYM2ID(sym));}
-
-void CObject_free (void *victim) {
-	CObject *self = (CObject *)victim;
-	if (!self->rself) {fprintf(stderr,"attempt to free object that has no rself\n"); abort();}
-	self->rself = 0; /* paranoia */
-	delete self;
-}
+void CObject_free (void *victim) {delete (CObject *)victim;}
 
 Ruby cPointer=0;
 Ruby Pointer_s_new (void *ptr) {
 	Pointer *self = new Pointer(ptr);
-	self->rself = Data_Wrap_Struct(cPointer, 0, CObject_free, self);
-	//fprintf(stderr,"making rself=%p self=%p, a Pointer to %p\n",self->rself,self,ptr);
-	return self->rself;
+	return Data_Wrap_Struct(cPointer, 0, CObject_free, self);
 }
 void *Pointer_get (Ruby rself) {
 	DGS(Pointer);
@@ -298,10 +290,9 @@
 
 Ruby Clock_s_new (Ruby qlass, Ruby owner) {
 	Clock *self = new Clock();
-	self->rself = Data_Wrap_Struct(qlass, Clock_mark, Clock_free, self);
 	self->serf = clock_new((void*)owner,(t_method)Clock_fn);
 	self->owner = owner;
-	return self->rself;
+	return Data_Wrap_Struct(qlass, Clock_mark, Clock_free, self);
 }
 
 \def void set  (double   systime) {   clock_set(serf,  systime); }
@@ -360,15 +351,6 @@
 }
 
 #include "bundled/pd/g_canvas.h"
-
-static Ruby FObject_patcherargs (Ruby rself) {
-	DGS(FObject);
-	if (!self->bself) RAISE("can't use this in initialize");
-	_canvasenvironment *env = canvas_getenv(self->bself->mom);
-	Ruby ar = rb_ary_new();
-	for (int i=0; i<env->ce_argc; i++) rb_ary_push(ar, Bridge_import_value(env->ce_argv+i));
-	return ar;
-}
 
 static void BFObject_undrawio (BFObject *bself) {
 #ifndef HAVE_DESIREDATA
@@ -558,24 +540,26 @@
 }
 
 static void send_in_3 (Helper *h) {}
-\def void send_in (...) {
-	Helper h = {argc,argv,this,rself};
+void FObject_send_in (int argc, Ruby *argv, Ruby rself) {
+	DGS(FObject);
+	Helper h = {argc,argv,self,rself};
 	rb_ensure(
 		(RMethod)send_in_2,(Ruby)&h,
 		(RMethod)send_in_3,(Ruby)&h);
 }
 
-\def void send_out (...) {
+void FObject_send_out (int argc, Ruby *argv, Ruby rself) {
+	DGS(FObject);
 	if (argc<1) RAISE("not enough args");
 	int outlet = INT(*argv);
 	if (outlet<0 || outlet>=64) RAISE("invalid outlet number: %d",outlet);
 	argc--, argv++;
 	Ruby sym;
-	FObject_prepare_message(argc,argv,sym,this);
+	FObject_prepare_message(argc,argv,sym,self);
 	t_atom sel, at[argc];
 	Bridge_export_value(sym,&sel);
 	for (int i=0; i<argc; i++) Bridge_export_value(argv[i],at+i);
-	outlet_anything(bself->out[outlet],atom_getsymbol(&sel),argc,at);
+	outlet_anything(self->bself->out[outlet],atom_getsymbol(&sel),argc,at);
 }
 
 Ruby FObject_s_new(Ruby argc, Ruby *argv, Ruby qlass) {
@@ -592,7 +576,7 @@
 	}
 	Ruby keep = rb_ivar_get(mGridFlow, SI(@fobjects));
 	self->bself = 0;
-	Ruby rself = self->rself = Data_Wrap_Struct(qlass, CObject_mark, CObject_free, self);
+	Ruby rself = Data_Wrap_Struct(qlass, CObject_mark, CObject_free, self);
 	rb_hash_aset(keep,rself,Qtrue); // prevent sweeping
 	rb_funcall2(rself,SI(initialize),argc,argv);
 	return rself;
@@ -618,10 +602,12 @@
 	return Qnil;
 }
 
-\def void delete_m () {
+Ruby FObject_delete (Ruby rself) {
+	DGS(FObject);
 	rb_funcall(rb_ivar_get(mGridFlow, SI(@fobjects)),SI(delete),1,rself);
 	DATA_PTR(rself) = 0; // really!
-	delete this; // really!
+	delete self; // really!
+	return Qnil;
 }
 
 Ruby GridFlow_s_rdtsc (Ruby rself) {return R(rdtsc()).r;}
@@ -773,8 +759,10 @@
 	rb_define_method(fo,"noutlets",    (RMethod)FObject_noutlets, 0);
 	rb_define_method(fo,"ninlets=",    (RMethod)FObject_ninlets_set,  1);
 	rb_define_method(fo,"noutlets=",   (RMethod)FObject_noutlets_set, 1);
-	rb_define_method(fo,"patcherargs", (RMethod)FObject_patcherargs,0);
 	rb_define_method(fo,"args",        (RMethod)FObject_args,0);
+	rb_define_method(fo,"send_in",     (RMethod)FObject_send_in,-1);
+	rb_define_method(fo,"send_out",    (RMethod)FObject_send_out,-1);
+	rb_define_method(fo,"delete",      (RMethod)FObject_delete,0);
 	\startall
 	rb_define_singleton_method(EVAL("GridFlow::Clock"  ),"new", (RMethod)Clock_s_new, 1);
 	rb_define_singleton_method(EVAL("GridFlow::Pointer"),"new", (RMethod)Pointer_s_new, 1);



More information about the Gridflow-cvs mailing list