[Gambas-devel] Returning a reference to an array ...

Benoit Minisini gambas at ...1...
Mon Jan 12 19:06:59 CET 2009


On lundi 12 janvier 2009, Gareth Bult wrote:
> Ok,
>
> I'm obviously being a bit dull .. however, the following code now seems to
> compile OK, however then I try to run it, Gambas reports "No return value".
> [so GB.ReturnObject(array) isn't working??]
>
> BEGIN_METHOD_VOID(CCONNECTION_audio_devices)
>
> 	struct iaxc_audio_device *devs;
> 	int ndevs,input,output,ring,i;
>
> 	GB_ARRAY array;
> 	CIAX2DEVICE *dev;
>
> 	iaxc_audio_devices_get(&devs,&ndevs,&input,&output,&ring);
>
> 	GB.Array.New(&array, (GB_TYPE)GB.FindClass("IAX2Device"), 1);
>
> 	for (i = 0; i < ndevs; i++)
> 	{
> 		GB.New((void**)&dev,GB.FindClass("IAX2Device"),NULL,NULL);
> 		GB.Ref(dev);
> 		GB.NewString(&dev->name,devs[i].name,0);
> 	  	*((void **)GB.Array.Get(array, i)) = dev;
> 	}
> 	GB.ReturnObject(array);
> 	return;
>
> END_METHOD
>
> Does the above seem "sane"?
> Am I missing something critical??
>
> I think I've had this code before and had the same problem, been trying
> lots of different approaches ...
>
> Gareth.
>

Did you check that you have declared the method as returning something in the 
class declaration?

-- 
Benoit Minisini




More information about the Devel mailing list