View Full Version : Function Parameter lookup
Ebobtron
24th May 2007, 18:31
Hello,
I have a question:The following provides a list of function names internal to AviSynth or a list of external(plug-in) funcition names.
GetVar("$InternalFunctions$");
GetVar("$PluginFunctions$");
Using below returns a parameter string for "FUNCTIONNAME"
GetVar("$Plugin!""FUNCTIONNAME""!Param$");
Frequently the external or plug-in function is not housed in the AviSynth folder and LoadPlugin is used inside the script.
Question:
Is there a method to use LoadPlugin within the scriptEnvironment before a script is loaded or is there a method to return the parameter string for a function whose dll is housed elsewhere.
:)
Thanks
Rob
foxyshadis
24th May 2007, 19:55
Sure! Just call LoadPlugin yourself, and it'll be added without needing a script. Or you can copy whatever you need out of the implementation of LoadPlugin, I suppose, in case it isn't exposed in the C API. (No idea.)
AVSValue return_val = env->Invoke("LoadPlugin", szDllName)Note the 2nd arg is a single AVSValue so if you want to invoke a function with more than 1 arg you will need to pack up an AVSValue array type with each element holding each argument.
Ebobtron
25th May 2007, 05:21
Thank you gentlemen,
Note the 2nd arg is a single AVSValue so if you want to invoke a function with more than 1 arg you will need to pack up an AVSValue array type with each element holding each argument.
Are you talking about something like below, or did I miss it by a mile? In either case what does return_val become, can I get a frame from a clip?
AVSValue myParams(300,720,480,"RGB32",29.970,0,0);
AVSValue return_val = env->Invoke("BlankClip", AVSValue(&myParams,7);
AVSValue return_val = env->Invoke("LoadPlugin", szDllName);In the above case what is returned? Not a clip, for sure.
:thanks:
Robert
More likeAVSValue myParams[] = {300,720,480,"RGB32",29.970,0,0};Search the source for calls to Invoke...
typedef const char* (__stdcall *AvisynthPluginInitFunc)(IScriptEnvironment* env);
AvisynthPluginInitFunc AvisynthPluginInit =
(AvisynthPluginInitFunc)GetProcAddress(plugin, "AvisynthPluginInit2");
...
result = AvisynthPluginInit(env);
...
return result ? AVSValue(result) : AVSValue();So it is either the void AVSValue or the string returned from the plugin. Use ...IsString() to check.
If you env->Invoke something that returned a clip, like BlankClip or AviSource, then yes you could return_val.AsClip()->GetFrame(n, env);
Ebobtron
27th May 2007, 19:37
@Ian
Hello,
Thanks for the help.I have worked with this a little.
AVSValue ret_Val = env->Invoke("LoadPlugin","Plugin.dll path and name")Results:
ret_Val.Defined() returns falseso of course "ret_Val.IsString()" returns false
AVSValue external = env->GetVar("$PluginFunctions$")
or
AVSValue internal = env->GetVar("$InternalFunctions$")Neither internal.AsString or external.AsString contain the function or functions that reside in "Plugin.dll path and name" after using LoadPlugin.
The above would have been my assumption but I wish to verify.
With env->Invoke("LoadPlugin","somePlace\dgdecode.dll")
AVSValue par = env->GetVar("$Plugin!Mpeg2Source!Param$") throws an exception.
try
{
par = env->GetVar("$Plugin!Mpeg2Source!Param$");
}
catch(AvisynthError err)
{
return err.msg;
}
catch(...)
{
return "Error Unknow"
}
The above returns "Error Unknow". Again I am not supprised as Mpeg2Source is in neither the internal or external function lists.
Sorry but a lack of time and my GW Basic programming skills make gleaming these answers from the AviSynth source code very difficult.
(Caution the following is full of shameless self promotion)
Although VirtualDubMod uses the external (GetVar("$PluginFunctions$")) functions list provided by AviSynth for syntax coloring, avsFilmCutter (http://forum.doom9.org/showthread.php?p=687842#post687842) tries to fully use the interface.
Instead of just using the Plug-in function names, FilmCutter (http://www.avsfilmcutter.com) also uses the internal function name look up and the function parameter lookup feature of the interface. This allows FilmCutter to provide syntax highlighting and function argument (parameter) help, and a lame attempt at an auto complete feature.
My intentions at start were just a reasonably competent frame number getter and launch interface for other programs, like a good editor. Then Fizick temped me, like the snake in the garden. ;) And now I am still at it.
I am trying to provide syntax and parameter help for plug-ins not included in Avisynth's plug-in folder. I am also wishing to provide that support with as little amount of ongoing support as necessary. If would be easy to add a list of somewhere else Dlls and the resident functions and parameter strings but when version next comes out, the info is wrong. The somewhere else Dlls list thing becomes very useful if I can list the functions and then call the parameters.
I have a messy solution. I need a better one.
Got any ideas?
:thanks:
Rob
If the plugin returns a signature string then LoadPlugin will return that string. If not then it will return the void AVSValue i.e. ret_Val.Defined() == false and of course ret_Val.IsString() == false.
$PluginFunctions$ should contain the new entry. I will check it next time I am coding.
GetVar() throws IScriptEnvironment::NotFound
LoadPlugin throws AvisynthError you should code for this.
What you are trying to do is correct.
Hmm looks like we need some non-throw versions of the calls for use in other languages.
Ebobtron
28th May 2007, 04:44
$PluginFunctions$ should contain the new entry. I will check it next time I am coding.Thank you.GetVar() throws IScriptEnvironment::NotFoundYes, GetVar("Function",argStringArray)
if Funciton unknow, IScriptEnvironment::NotFound and if Function know on error returns AvisynthError LoadPlugin throws AvisynthError you should code for this.already do.
first I code(;)), then I test, then I break, then I test again.Missed the IScriptEnvironment::NotFound, thanks alot. Then I thought, are there more things to catch?
:( Sure don't look like it.
:thanks:
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.