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

Gareth Bult gareth at ...560...
Mon Jan 12 14:17:41 CET 2009


Hi, 

I'm getting a little bogged down with arrays, any help much appreciated. 

I have a connection object; 

typedef struct 
{ 
GB_BASE ob; // inherited from Gambas 
char* host; // server host name or IP 
char* user; // user name 
char* password; // user password 
int id; // registration id 
int reply; // registration reply 
int count; // connection counter 
CIAX2DEVICE** devices; // array of devices + caps 

} CIAX2CONNECTION; 

With a device object; 

typedef struct 
{ 
GB_BASE ob; // inherited from Gambas 
int id; 
char* name; 
long capabilities; 

} CIAX2DEVICE; 

So the connection contains an array of device objects. 
I need to return this information to Gambas so gambas can see the available devices. 

I have a routine to create the array; 

char ***devices = &THIS->devices; 
CIAX2DEVICE *device; 

GB.NewArray(devices,sizeof(CIAX2DEVICE),ndevs); 
GB.New(POINTER(&(*devices)[0]),GB.FindClass("IAX2Device"),NULL,NULL); 
device = (CIAX2DEVICE *)&(*devices)[0]; 
GB.NewString(&(device->name),"MyName",0); 
GB.ReturnObject(devices); 

But the returning object is untyped .. how do I specify the return type as an array of "CIAX2Device[]" 

Can it be done?? 
Or do I need to code part of this in Gambas and call that ? 

Gareth. 
-- 
Managing Director, Encryptec Limited 
Tel: 0845 5082719, Mob: 0785 3305393 
Email: gareth at ...560... 
Statements made are at all times subject to Encryptec's Terms and Conditions of Business, which are available upon request. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20090112/9e0ac2e3/attachment.html>


More information about the Devel mailing list