Markus,
That would be fine. The following two usage perform the same thing:
1. Yours
image = load_bitmap(filename, NULL);
mb_check(mb_push_usertype(s, l, image));
2. Same as
image = load_bitmap(filename, NULL);
mb_value_t ret;
mb_make_usertype(ret, image);
mb_check(mb_push_value(s, l, ret));
After that, it's able to retrieve a bitmap as:
1.
BITMAP* image = NULL;
mb_check(mb_pop_usertype(s, l, (void**)&image));
2.
BITMAP* image = NULL;
mb_value_t arg;
mb_check(mb_pop_value(s, l, &arg));
image = (BITMAP*)arg.value.usertype;
You don't need to call mb_ref_value or ??_ref_?? things for usertypes created from above, only mb_make_ref_value generates a referenced usertype. So I think you need some releasing functions for non-referenced usertype.
BTW. if you use the BITMAP* or other resources directly as the usertype data, it won't carry any type information representing for if it's a BITMAP, or an IMAGE, or something else... Why not use a struct wrapper:
// Pseudo code
struct AllegroBASICObject {
enum type;
void* data;
};
Then you could do different things according to different type.
Best.