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

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Wed Mar 19 16:45:52 EDT 2008


Author: matju
Date: Wed Mar 19 16:45:51 2008
New Revision: 3239

Log:
moved Pointer decl from rubyext to grid.h; also added t_symbol*-to-ruby converter.

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 Wed Mar 19 16:45:51 2008
@@ -30,12 +30,6 @@
 #include <sys/time.h>
 #include "grid.h.fcs"
 #include <ctype.h>
-
-/* copied from rubyext.c (sorry: linkage issue) */
-struct Pointer : CObject {
-	void *p;
-	Pointer(void *_p) : p(_p) {}
-};
 
 #define Pointer_s_new Pointer_s_new_2
 #define Pointer_get   Pointer_get_2

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Wed Mar 19 16:45:51 2008
@@ -166,6 +166,7 @@
 		r = rb_funcall(UINT2NUM((uint32)(x>>32)),SI(<<),1,INT2FIX(32));
 		r = rb_funcall(r,SI(+),1,UINT2NUM((uint32)x));}
 	R(Numop *x);
+	R(t_symbol *x) {r = ID2SYM(rb_intern(x->s_name));}
 
 	operator bool () const {
 		if (r==Qtrue) return true;
@@ -429,8 +430,7 @@
 #undef FOO
 };
 
-\class BitPacking < CObject
-struct BitPacking : CObject {
+\class BitPacking < CObject {
 	Packer   *  packer;
 	Unpacker *unpacker;
 	unsigned int endian; // 0=big, 1=little, 2=same, 3=different
@@ -684,8 +684,7 @@
 } GridHandler;
 
 struct GridObject;
-\class GridInlet < CObject
-struct GridInlet : CObject {
+\class GridInlet < CObject {
 	GridObject *parent;
 	const GridHandler *gh;
 private:
@@ -742,8 +741,7 @@
 
 //****************************************************************
 // GridOutlet represents a grid-aware outlet
-\class GridOutlet < CObject
-struct GridOutlet : CObject {
+\class GridOutlet < CObject {
 // number of (minimum,maximum) BYTES to send at once
 // starting with version 0.8, this is amount of BYTES, not amount of NUMBERS.
 	static const long MIN_PACKET_SIZE = 1<<8;
@@ -810,10 +808,8 @@
 	void noutlets_set(int n);
 };
 
-
 // represents objects that have inlets/outlets
-\class FObject < CObject
-struct FObject : CObject {
+\class FObject < CObject {
 	BFObject *bself; // point to PD peer
 	FObject() : bself(0) {}
 	const char *args() {
@@ -832,9 +828,8 @@
 };
 \end class FObject
 
-\class GridObject < FObject
-struct GridObject : FObject {
-	std::vector<P<GridInlet> >  in;
+\class GridObject < FObject {
+	std::vector<P<GridInlet> > in;
 	P<GridOutlet> out;
 	// Make sure you distinguish #close/#delete, and C++'s delete. The first
 	// two are quite equivalent and should never make an object "crashable".
@@ -880,4 +875,12 @@
 
 typedef GridObject Format;
 
+\class Pointer < CObject {
+	void *p;
+	Pointer() { RAISE("trying to construct a (ruby) Pointer without an argument"); }
+	Pointer(void *_p) : p(_p) {}
+	\decl Ruby ptr ();
+};
+\end class Pointer
+
 #endif // __GF_GRID_H

Modified: trunk/rubyext.c
==============================================================================
--- trunk/rubyext.c (original)
+++ trunk/rubyext.c Wed Mar 19 16:45:51 2008
@@ -111,12 +111,6 @@
 static Ruby mPointer=0;
 
 \class Pointer < CObject
-struct Pointer : CObject {
-	void *p;
-	Pointer() { RAISE("trying to construct a (ruby) Pointer without an argument"); }
-	Pointer(void *_p) : p(_p) {}
-	\decl Ruby ptr ();
-};
 \def Ruby ptr () { return LONG2NUM(((long)p)); }
 \classinfo {
 	IEVAL(rself,
@@ -535,6 +529,22 @@
 	//self->bself = pd_newest;
 	return Pointer_s_new((void *)pd_newest);
 }
+
+static t_pd *rp_to_pd (Ruby pointer) {
+	Pointer *foo;
+	Data_Get_Struct(pointer,Pointer,foo);
+	return (t_pd *)foo->p;
+}
+
+/*
+static Ruby GridFlow_s_connect (Ruby from, Ruby outlet, Ruby to, Ruby inlet) {
+	if (CLASS_OF(from)!=mPointer) RAISE("'from' is not a Pointer");
+	if (CLASS_OF(to  )!=mPointer) RAISE(  "'to' is not a Pointer");
+	if (TYPE(outlet)!=T_FIXNUM) RAISE("'outlet' is not a Fixnum");
+	if (TYPE( inlet)!=T_FIXNUM) RAISE( "'inlet' is not a Fixnum");
+	obj_connect(rp_to_pd(from),NUM2INT(outlet),rp_to_pd(to),NUM2INT(inlet));
+}
+*/
 
 #ifndef HAVE_DESIREDATA
 static Ruby FObject_s_gui_enable (Ruby rself) {
@@ -812,6 +822,7 @@
 	SDEF("gui",gui,-1);
 	SDEF("bind",bind,2);
 	SDEF("objectmaker",objectmaker,-1);
+	//SDEF("connect",connect,4);
 	// SDEF("add_to_menu",add_to_menu,-1);
 
 	\startall
@@ -893,11 +904,9 @@
 	ruby_options(COUNT(foo),foo);
 	post("we are using Ruby version %s",rb_str_ptr(EVAL("RUBY_VERSION")));
 	Ruby cData = rb_const_get(rb_cObject,SI(Data));
-	BFProxy_class = class_new(gensym("ruby_proxy"),
-		NULL,NULL,sizeof(BFProxy),CLASS_PD|CLASS_NOINLET, A_NULL);
+	BFProxy_class = class_new(gensym("ruby_proxy"), NULL,NULL,sizeof(BFProxy),CLASS_PD|CLASS_NOINLET, A_NULL);
 	class_addanything(BFProxy_class,BFProxy_method_missing);
-	rb_define_singleton_method(cData,"gf_bridge_init",
-		(RMethod)gf_bridge_init,0);
+	rb_define_singleton_method(cData,"gf_bridge_init",(RMethod)gf_bridge_init,0);
 
 	mGridFlow2 = EVAL(
 		"module GridFlow; class<<self; attr_reader :bridge_name; end; Pd=GridFlow; "



More information about the Gridflow-cvs mailing list