On Mon, 2 Oct 2000, Christoph Egger wrote:
> /* allocates sizeof(struct mydata) bytes memory
> * and set it to the visual
> * struct mydata can be any kind of a structure
> */
> ggiOpenMetaData(vis, sizeof(struct mydata));
The extra parameter is just so more than one layer of library
can use metadata on the same visual without collision. For simple
use like you want, we would just add convenience macros to the
extension header:
#define ggiOpenMetaData(vis, size) ggiMetaDataAlloc(vis, &"", size)
> /* fill the private data allocated with ggiOpenMetaData()
> * with the data given by the &mydata
> */
> ggiSetMetaData(vis, &mydata);
#define ggiSetMetaData(vis, src) bcopy(ggiMetaDataPtr(vis, ""), src, \
ggiMetaDataSize(vis, ""))
> /* read out the private data, set by ggiSetMetaData()
> */
> ggiGetMetaData(vis, &mydata);
...same deal.
> /* removes the private data and free()'s the memory
> * allocated by ggiOpenMetaData()
> */
> ggiCloseMetaData(vis);
#define ggiCloseMetaData(vis) ggiMetaDataFree(vis, "");
> Well, it's more than a simple program.
If it's a library above the extension level, then you wouldn't use
"" above, but "3dtk", so that other people could store their own
data in a visual that was in use by 3dtk (assuming they can get to
the visual object and 3dtk doesn't sheild it under it's own opaque
object)
So the remaining question is, is it worth the effort to code?
How many people would use it, and would their using it make their
code more, or less, reusable? If you were later to convert
some 3dtk functions from a high level library to a full extension,
would this gum up the process or make it easier?
--
Brian