Re: [ctypes-users] where is the struct info stored in?
Brought to you by:
theller
From: Lenard L. <le...@te...> - 2007-12-09 17:55:06
|
oyster wrote: > iup(http://www.tecgraf.puc-rio.br/iup/) supplies the .H and .lib file > for user. include\iup.h writes > [include\iup.h] > typedef struct Ihandle_ Ihandle; > typedef int (*Icallback)(Ihandle*); > Ihandle* IupText (char* action); > Icallback IupSetFunction (const char *name, Icallback func); > [/include\iup.h] > So, a user can write his application like this: > #include "iup.h" > campo = IupText("acao_numero"); /* creates TEXT field */ > IupSetFunction ( > "acao_numero", > (Icallback)acao_numero > ); /* registers callback */ > > But, the deinfination of Ihandle_ lives in src\iglobal.h, > [src\iglobal.h] > struct Ihandle_ > { > int serialnumber; /* serial number */ > char* type; /* type of interface element */ > Itable* enviroment; > Iclass* iclass; > void* handle; /* native handle */ > int usersize; /* the configuration of expand and fill */ > > int posx,posy; /* upper-left corner */ > Isize natural; /* the calculated size based in the control contents */ > > Isize current; /* the actual size of the control */ > Iattrib attrib; > Ihandle* brother; /* next control in the container */ > Ihandle* firstchild; > Ihandle* parent; > }; > [/src\iglobal.h] > > which is not supplied to the user. So why a compiler can find it and > compile the sourecifle to exe file without the presentation of > Ihandle_ details? > > Currently, I read *.C and *.h, then copy and convert all the > defination of structure into my iup.py. As you may guess, it is a hard > work! > So, can we use Ihandle_ in ctypes without giving its _fileds_? Thanx > > The C compiler only needs full structure declarations when the code allocates memory for the structure or accesses a field of the structure. This information is unnecessary when only pointers are used. All that is needed is an incomplete structure declaration: typedef struct Ihandle_ Ihandle; In ctypes this would just be: class Ihandle(Structure): pass That's it. src\iglobal.h is probably used only by the iup library itself, since the library actually accesses the structure fields. These are internal details meant to be hidden from the user. It is the way modules C handles modular programming. -- Lenard Lindstrom <le...@te...> |