[Gridflow-cvs] [svn] commit: r3656 - in /trunk: base/source_filter.rb format/main.c format/x11.c gridflow.c gridflow.h optional/gem.c optional/opencv.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 25 15:11:58 EDT 2008


Author: matju
Date: Fri Apr 25 15:11:57 2008
New Revision: 3656

Log:
initialize self->bself before running \constructor

Modified:
    trunk/base/source_filter.rb
    trunk/format/main.c
    trunk/format/x11.c
    trunk/gridflow.c
    trunk/gridflow.h
    trunk/optional/gem.c
    trunk/optional/opencv.c

Modified: trunk/base/source_filter.rb
==============================================================================
--- trunk/base/source_filter.rb (original)
+++ trunk/base/source_filter.rb Fri Apr 25 15:11:57 2008
@@ -182,7 +182,7 @@
 	frame = $stack[-1]
 	raise "missing \\class #{where}" if not frame or not ClassDecl===frame
 	m = parse_methoddecl("void constructor"+line,"(.*)$")
-	Out.print "#{frame.name}(MESSAGE) : #{frame.supername}(MESSAGE2) {"
+	Out.print "#{frame.name}(BFObject *bself, MESSAGE) : #{frame.supername}(bself,MESSAGE2) {"
 	Out.print "static const char *methodspec = \"#{frame.name}::#{m.selector}(#{unparse_arglist m.arglist,false})\";"
 
 	Out.print "if (argc<#{m.minargs}"
@@ -207,7 +207,7 @@
 	cl = frame.name
 	line="{}" if /^\s*$/ =~ line
 	Out.print "static void #{cl}_startup (FClass *fclass);"
-	Out.print "static void *#{cl}_allocator (MESSAGE) {return new #{cl}(sel,argc,argv);}"
+	Out.print "static void *#{cl}_allocator (BFObject *bself, MESSAGE) {return new #{cl}(bself,sel,argc,argv);}"
 	Out.print "static MethodDecl #{cl}_methods[] = {"
 	Out.print frame.methods.map {|foo,method| "{ \"#{method.selector}\",(Method)#{frame.name}::#{method.selector}_wrap }" }.join(",")
 	Out.print "}; static FClass ci#{cl} = { #{cl}_allocator, #{cl}_startup,"

Modified: trunk/format/main.c
==============================================================================
--- trunk/format/main.c (original)
+++ trunk/format/main.c Fri Apr 25 15:11:57 2008
@@ -100,7 +100,7 @@
 \end class FormatLookup {install("gf.format_lookup",1,1);}
 
 \class Format : FObject
-Format::Format (MESSAGE) : FObject(MESSAGE2) {
+Format::Format (BFObject *bself, MESSAGE) : FObject(bself,MESSAGE2) {
 	mode=0; fd=-1; f=0; cast=int32_e; frame=0;
 	if (argv[0]==gensym("out")) this->mode=2; else
 	if (argv[0]==gensym("in"))  this->mode=4; else RAISE("unknown mode");

Modified: trunk/format/x11.c
==============================================================================
--- trunk/format/x11.c (original)
+++ trunk/format/x11.c Fri Apr 25 15:11:57 2008
@@ -42,9 +42,6 @@
 #include <X11/extensions/Xv.h>
 #include <X11/extensions/Xvlib.h>
 #endif
-
-#undef L
-#define L post("%s:%d in %s",__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
 /* X11 Error Handler type */
 typedef int (*XEH)(Display *, XErrorEvent *);
@@ -191,7 +188,7 @@
 			uint32 masks[3] = { 0x07, 0x38, 0xC0 };
 			bit_packing = new BitPacking(disp_is_le, bpp/8, 3, masks);
 		} break;
-		default: { RAISE("huh?"); }
+		default: RAISE("huh?");
 		}
 		clock = clock_new(this,(t_method)FormatX11_call);
 		clock_delay(clock,0);

Modified: trunk/gridflow.c
==============================================================================
--- trunk/gridflow.c (original)
+++ trunk/gridflow.c Fri Apr 25 15:11:57 2008
@@ -550,7 +550,6 @@
 	BFObject_anything(self->parent,self->id,s,argc,argv);
 }
 
-typedef void *(*t_constructor)(MESSAGE);
 static void *BFObject_init (t_symbol *classsym, int ac, t_atom *at) {
     string name = string(classsym->s_name);
     if (fclasses.find(name)==fclasses.end()) {post("GF: class not found: '%s'",classsym->s_name); return 0;}
@@ -570,11 +569,8 @@
 #endif
 	int j;
 	for (j=0; j<argc; j++) if (argv[j].a_type==A_COMMA) break;
-	t_constructor alloc = fclasses[string(classsym->s_name)]->allocator;
-	FObject *self = (FObject *)alloc(0,j,(t_atom2 *)argv);
-	self->bself = 0;
-
-	self->bself = bself;
+	t_allocator alloc = fclasses[string(classsym->s_name)]->allocator;
+	FObject *self = (FObject *)alloc(bself,0,j,(t_atom2 *)argv);
 	bself->self = self;
 	bself->mom = 0;
 #ifdef HAVE_GEM

Modified: trunk/gridflow.h
==============================================================================
--- trunk/gridflow.h (original)
+++ trunk/gridflow.h Fri Apr 25 15:11:57 2008
@@ -741,13 +741,16 @@
 #endif // HAVE_LITE
 #define MESSAGE t_symbol *sel, int argc, t_atom2 *argv
 #define MESSAGE2 sel,argc,argv
+#define MESSAGE3 t_symbol *, int, t_atom2 *
 struct AttrDecl {
 	string name;
 	string type;
 	AttrDecl(string name_, string type_) {name=name_; type=type_;}
 };
+struct BFObject;
+typedef void *(*t_allocator)(BFObject *,MESSAGE3);
 struct FClass {
-	void *(*allocator)(MESSAGE); // returns a new C++ object
+	t_allocator allocator; // returns a new C++ object
 	void (*startup)(FClass *);
 	const char *cname; // C++ name (not PD name)
 	int methodsn; MethodDecl *methods;
@@ -839,7 +842,7 @@
 	BFObject *bself; // point to PD peer
 	std::vector<P<GridInlet> > in;
 	P<GridOutlet> out;
-	FObject(MESSAGE) : bself(0) {}
+	FObject(BFObject *bself, MESSAGE) : bself(bself) {}
 	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]);
@@ -887,7 +890,7 @@
 	FILE *f;
 	NumberTypeE cast;
 	long frame;
-	Format(MESSAGE);
+	Format(BFObject *, MESSAGE);
 	\decl 0 open (t_symbol *mode, string filename);
 	\decl 0 close ();
 	\decl 0 cast (NumberTypeE nt);

Modified: trunk/optional/gem.c
==============================================================================
--- trunk/optional/gem.c (original)
+++ trunk/optional/gem.c Fri Apr 25 15:11:57 2008
@@ -46,8 +46,8 @@
 	pixBlock m_pixBlock;
 	\attr bool yflip;
 
-	GridExportPix () : FObject(0,0,0) {RAISE("what?");}
-	GridExportPix (MESSAGE) : FObject(MESSAGE2) {
+	GridExportPix () : FObject(0,0,0,0) {RAISE("don't call this. this exists only to make GEM happy.");}
+	GridExportPix (BFObject *bself, MESSAGE) : FObject(bself,MESSAGE2) {
 		yflip = false;
 		imageStruct &im = m_pixBlock.image = imageStruct();
 		im.ysize = 1;
@@ -123,8 +123,8 @@
 public:
 	P<BitPacking> bit_packing;
 	\attr bool yflip;
-	GridImportPix () : FObject(0,0,0) {RAISE("what?");}
-	GridImportPix (MESSAGE) : FObject(MESSAGE2) {
+	GridImportPix () : FObject(0,0,0,0) {RAISE("don't call this. this exists only to make GEM happy.");}
+	GridImportPix (BFObject *bself, MESSAGE) : FObject(bself,MESSAGE2) {
 		uint32 mask[4] = {0x0000ff,0x00ff00,0xff0000,0x000000};
 		bit_packing = new BitPacking(is_le(),4,4,mask);
 		yflip = false;

Modified: trunk/optional/opencv.c
==============================================================================
--- trunk/optional/opencv.c (original)
+++ trunk/optional/opencv.c Fri Apr 25 15:11:57 2008
@@ -155,7 +155,7 @@
 GRID_INPUT2(CvOp2,1,r) {} GRID_END
 \end class {}
 
-#define FUNC(CLASS) CLASS(MESSAGE):CvOp2(MESSAGE2) {} virtual void func(CvArr *l, CvArr *r, CvArr *o)
+#define FUNC(CLASS) CLASS(BFObject *bself, MESSAGE):CvOp2(bself,MESSAGE2) {} virtual void func(CvArr *l, CvArr *r, CvArr *o)
 
 \class CvAdd : CvOp2 {FUNC(CvAdd) {cvAdd(l,r,o,0);}};
 \end class {install("cv.Add",2,1);}



More information about the Gridflow-cvs mailing list