[PD-cvs] externals/clr clr.c,1.6,1.7

dmorelli morellid at users.sourceforge.net
Mon Jan 16 12:30:28 CET 2006


Update of /cvsroot/pure-data/externals/clr
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1204

Modified Files:
	clr.c 
Log Message:
errors loading the assembly will no more crash pd

Index: clr.c
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/clr.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** clr.c	14 Jan 2006 02:34:17 -0000	1.6
--- clr.c	16 Jan 2006 11:30:26 -0000	1.7
***************
*** 142,153 ****
  	//mono_jit_init (random_name_str);
  	x->domain = mono_domain_get();
- 
  	x->assembly = mono_domain_assembly_open (x->domain, x->filename->s_name);
- 
  	x->assemblyPureData = mono_domain_assembly_open (x->domain, "PureData.dll");
  
  	if (!x->assembly)
  	{
! 		error("clr: assembly not found!");
  	}
  
--- 142,158 ----
  	//mono_jit_init (random_name_str);
  	x->domain = mono_domain_get();
  	x->assembly = mono_domain_assembly_open (x->domain, x->filename->s_name);
  	x->assemblyPureData = mono_domain_assembly_open (x->domain, "PureData.dll");
  
  	if (!x->assembly)
  	{
! 		error("clr: file %s not found!", x->filename->s_name);
! 		return;
! 	}
! 
! 	if (!x->assemblyPureData)
! 	{
! 		error("clr: assembly PureData.dll not found! it is necessary!");
! 		return;
  	}
  
***************
*** 159,164 ****
  	x->klass = mono_class_from_name (x->image, "PureData", x->assemblyname->s_name);
  	if (!x->klass) {
! 		error("Can't find MyType in assembly %s\n", mono_image_get_filename (x->image));
! 		//exit (1);
  	}
  	x->obj = mono_object_new (x->domain, x->klass);
--- 164,169 ----
  	x->klass = mono_class_from_name (x->image, "PureData", x->assemblyname->s_name);
  	if (!x->klass) {
! 		error("Can't find %s in assembly %s\n", x->assemblyname->s_name, mono_image_get_filename (x->image));
! 		return;
  	}
  	x->obj = mono_object_new (x->domain, x->klass);
***************
*** 198,203 ****
  	{
  		error("clr: the provided assembly is not valid! the SetUp function is missing");
  	}
! 
  
  }
--- 203,210 ----
  	{
  		error("clr: the provided assembly is not valid! the SetUp function is missing");
+ 		return;
  	}
! 	// all done without errors
! 	x->loaded = 1;
  
  }
***************
*** 251,254 ****
--- 258,266 ----
  static void clr_bang(t_clr *x) 
  {
+ 	if (x->loaded == 0)
+ 	{
+ 		error("assembly not specified");
+ 		return;
+ 	}
  	if (x->manageBang)
  	{
***************
*** 263,266 ****
--- 275,283 ----
  	strmono = mono_string_new (x->domain, sl->s_name);
  	args[0] = &strmono;
+ 	if (x->loaded == 0)
+ 	{
+ 		error("assembly not specified");
+ 		return;
+ 	}
  	if (x->manageSymbol)
  	{
***************
*** 273,276 ****
--- 290,298 ----
  	gpointer args [1];
  	args [0] = &f;
+ 	if (x->loaded == 0)
+ 	{
+ 		error("assembly not specified");
+ 		return;
+ 	}
  	if (x->manageFloat)
  	{
***************
*** 289,293 ****
  	// first i extract the first atom which should be a symbol
  post("clr_manage_list, got symbol = %s", sl->s_name);
! 
  	for (i=0; i<MAX_SELECTORS; i++)
  	{
--- 311,319 ----
  	// first i extract the first atom which should be a symbol
  post("clr_manage_list, got symbol = %s", sl->s_name);
! 	if (x->loaded == 0)
! 	{
! 		error("assembly not specified");
! 		return;
! 	}
  	for (i=0; i<MAX_SELECTORS; i++)
  	{
***************
*** 406,410 ****
  	if (selectorString->length == 0)
  	{
- printf("selectorString->length == 0");
  		switch (type)
  		{
--- 432,435 ----
***************
*** 460,464 ****
      selCstring = mono_string_to_utf8 (selectorString);	
  	x = (t_clr *)x1;
! 
  	switch (type)
  	{
--- 485,493 ----
      selCstring = mono_string_to_utf8 (selectorString);	
  	x = (t_clr *)x1;
! 	if (x->loaded == 0)
! 	{
! 		error("assembly not specified");
! 		return;
! 	}
  	switch (type)
  	{
***************
*** 490,494 ****
  	char typeString[256];
  	x = (t_clr *)x1;
! 
  	// public enum ParametersType {None = 0, Float=1, Symbol=2, List=3, Bang=4, Generic=5};
  	switch (type)
--- 519,527 ----
  	char typeString[256];
  	x = (t_clr *)x1;
! 	if (x->loaded == 0)
! 	{
! 		error("assembly not specified");
! 		return;
! 	}
  	// public enum ParametersType {None = 0, Float=1, Symbol=2, List=3, Bang=4, Generic=5};
  	switch (type)
***************
*** 533,536 ****
--- 566,574 ----
  	atom_simple *atoms;
  	int n;
+ 	if (x->loaded == 0)
+ 	{
+ 		error("assembly not specified");
+ 		return;
+ 	}
  	if ((outlet>MAX_OUTLETS) || (outlet<0))
  	{
***************
*** 603,608 ****
  	time_t a;
      t_clr *x = (t_clr *)pd_new(clr_class);
- //	x->l_out = outlet_new(&x->x_obj, &s_list);
- //	x->l_out = outlet_new(&x->x_obj, gensym("float"));
  
  	char strtmp[256];
--- 641,644 ----
***************
*** 615,619 ****
  	{
  		x->loaded = 0;
! 		error("clr: you must provide an assembly as the first argument");
  		return (x);
  	}
--- 651,655 ----
  	{
  		x->loaded = 0;
! 		error("clr: you must provide a class name as the first argument");
  		return (x);
  	}
***************
*** 621,634 ****
  	x->assemblyname = atom_gensym(argv);
  	
! 	if (argc==1)
  	{
  		// only main class passed
  		// filename by default
  		sprintf(strtmp, "%s.dll", x->assemblyname->s_name);
! 		x->filename = atom_gensym(strtmp);
  	}
  
- 	x->filename = atom_gensym(argv+1);
- 
  	// load mono, init the needed vars
  	mono_load(x);
--- 657,672 ----
  	x->assemblyname = atom_gensym(argv);
  	
! 	if (argc<2)
  	{
  		// only main class passed
  		// filename by default
  		sprintf(strtmp, "%s.dll", x->assemblyname->s_name);
! 		x->filename = gensym(strtmp);
! printf(" used did not specified filename, I guess it is %s\n", strtmp);
! 	} else
! 	{
! 		x->filename = atom_gensym(argv+1);
  	}
  
  	// load mono, init the needed vars
  	mono_load(x);





More information about the Pd-cvs mailing list