[haXe] Canonical example

blackdog blackdog at ipowerhouse.com
Wed Aug 1 16:45:54 CEST 2007


I think i ffound my issue

	r = val_ocall0(utils,val_id("testing"));

i thought you could call a field, like it's an object, obvisuly not

Cheers

bd.



On Wed, 1 Aug 2007 10:11:34 -0400
blackdog <blackdog at ipowerhouse.com> wrote:

> 
> Hi Nicolas, sorry to be a PITA but I can't get this to work, can you
> give me a canonical example of how I call method testing from neko FFI
> once its been initialised as a module from neko, i.e. main() has been
> called, so utils static should exist.
> 
> class HxDevUtils {
> 
> 	public static var utils:HxDevUtils;
> 	
> 	public static function main() {
> 		trace("initialised utils");
> 		utils = new HxDevUtils();
> 	}
> 	
> 	public function new() {
> 		
> 	}
> 	
> 	public function testing():String {
> 		return "boo";
> 	}
> 
> }
> 
> my effort so far is this but it segfaults on the call after I've
> checked everything is ok.
> 
>    // printf("got something here %d",cl);
>   val_check(hxLocalData.utilModule,object);
>   val_iter_fields( hxLocalData.utilModule,check, val_null);
>     field classes =
> val_field(hxLocalData.utilModule,val_id("__classes")) ;
> printf("_classes-----\n"); val_iter_fields( classes,check, val_null);
>     if (classes == val_null) {
>     	printf("can't find function\n");
>     	return val_false;
>     }
>     
>     field hxdev = val_field(classes,val_id("HxDevUtils")) ;
>     printf("HXDevUtils-----\n");
>     val_iter_fields( hxdev,check, val_null);
>     
>     field utils = val_field(hxdev,val_id("utils"));
> 	printf("calling \n");
> 	
> 	if (utils == val_null) {
> 		printf("mmm, utils is null\n");
> 		return val_false;
> 	}
> 	
> 	if (!val_is_object (utils)) {
> 		printf("utils is not object\n");
> 		return val_false;
> 	}
> 	
> 	printf("utils-----\n");
> 	val_iter_fields( utils,check, val_null);
> 	
> 	field process = val_field(utils,val_id("testing"));
> 	
> 	if (process == val_null || !val_is_function(process)) {
> 		printf("testing is not a function\n");
> 		return val_false; 
> 	}
> 	
> 	if (!val_is_object(utils)) {
> 		printf("aha util is not an object\n");
> 		return val_false;
> 	}
> 		
> 	
> 	value r;
> 	if (utils != val_null){
> 		printf("call the function\n");
> 		r = val_ocall0(utils,process);      
> 		printf("got!  %s\n",val_string(r));
> 	}
> 
>     return val_true;
> 
> Thanks
> 
> bd
> 


-- 
http://www.blackdog-haxe.com/

"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti


-- 
http://www.blackdog-haxe.com/

"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti



More information about the Haxe mailing list