Back Forum Reply New

Help on Invoke needed

I'm trying to use Invoke() from Visual Basic. It is defined as:Code:
AVS_Value avs_invoke(AVS_ScriptEnvironment *, const char * name, AVS_Value args, const char** arg_names);
The deal is to find out which data types are expected.

For example: FunctionExists():

Code:
int avs_function_exists(AVS_ScriptEnvironment *, const char * name);
exptects 2 pointers as long = 8bytes, resulting to this working Visual Basic declaration:
Code:
Declare Function avs_function_exists Lib quot;AVISYNTH.DLLquot; (ByVal pEnv As Long, ByVal sFunction As String) As Long
You'll see int in C becomes long in VB.

So what are the other two parameters in Invoke()?
Dependency walker tells me a total of 20 bytes is expexted.
What is the return data type (AVS-VALUE)?
And by the way what is a quot;fat pointerquot;.

And by the way what is a quot;fat pointerquot;.

I guess it's a type who holds more info that just a pointer to the object.
Some things I read on msdn hinted than msvc do that for multiple inheritance hierarchies...

These are the interesting lines from avisynth_c.api, now compiled with AviSynth.Code:
/////////////////////////////////////////////////////////////////////
//
// AVS_Value
//

// Treat AVS_Value as a fat pointer.  That is use avs_copy_value
// and avs_release_value appropiaty as you would if AVS_Value was
// a pointer.

// To maintain source code compatibility with future versions of the
// avisynth_c API don't use the AVS_Value directly.  Use the helper
// functions below.

// AVS_Value is layed out identicly to AVSValue
typedef struct AVS_Value AVS_Value;
struct AVS_Value { short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong   // for some function e'rror short array_size; union {   void * clip; // do not use directly, use avs_take_clip   char boolean;   int integer;   float floating_pt;   const char * string;   const AVS_Value * array; } d;
};
I can't translate quot;unionquot;, quot;shortquot; and quot;const char**quot;, what is ment?

Unions are a way to cleanly allow to consider the same area of memory as of distincts types. (I say cleanly coz you could always do it with lots of ugly casts)

In your case, when you write d.clip, you are considering d as void *, d.integer as an int....
but they all occupy the same location.

Unions are a legacy from C, and in C++ they are not that useful since they are limited to primitives types.
In this case, one would have liked to use PClip clip, instead of void * clip, but that can't be done with unions.

There are still ways to achieve it for C++ classes and actually I do it in 3.0. (There AVSValue is typedefed as boost::variantlt;void, int, double, bool, PClip, std::stringgt;)short is an integer type coded on two bytes.
range goes from -32768 to 32767Read it from the right:
const char ** = pointer to const char * = pointer to pointer to const char

THX for explanations, it gives me an idea what to do.

3rd parameter uses 8 bytes and char** needs 4
with first and second param sums up to 20 bytes.

And I can expand my translation table:

short (c) -gt; integer (basic)
integer (c) -gt; long (basic)
¥
Back Forum Reply New