@inc: it is not to be able to assign structures or use them without pointers. It is to return a pointer and be able to use that instead of having to create a pointer variable from which to access the members.
Thats the workout for Purebasic for finally getting the purpose but in C/C++ you can return a structured variable directly instead of just a pointer like shown in your link. And thats what Nik is trying to point out - like me too.
Lets have a look at this one as it shows how it can be achieved in C and C++:
Code: Select all
// The Structure
struct AVS_Value {
short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
short array_size;
union {
void * clip
char boolean;
int integer;
float floating_pt;
const char * string;
const AVS_Value * array;
} d;
};
// The function accepting a structure variable as argument and also returning a structure (NOT a pointer to) as well.
AVS_Value avs_invoke(AVS_ScriptEnvironment * p, const char * name, AVS_Value args, const char * * arg_names)
{
AVS_Value v = {0,0};
p->error = 0;
try {
AVSValue v0 = p->env->Invoke(name, *(AVSValue *)&args, arg_names);
new ((AVSValue *)&v) AVSValue(v0);
} catch (IScriptEnvironment::NotFound) {
p->error = "Function Not Found";
} catch (AvisynthError err) {
p->error = err.msg;
}
if (p->error)
v = avs_new_value_error(p->error);
return v;
}
So its exactly what I did point out above
Here the main details pointed out where you can see that actually no pointer is used...
AVS_Value avs_invoke(AVS_ScriptEnvironment* p, const char* name,
AVS_Value args, const char** arg_names)
{
__AVS_Value v = {0,0};
__... AVSValue v0 = p->env->Invoke(name, *(AVSValue*)&
args, arg_names);
__...
__...
__return v;
}