Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 05-21-2020, 11:22 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default API help docs: double* parameter and reaper.array

If the type of an input parameter of an extension-provided function is defined as "double*", the IDE's inline help as well as the auto-generated HTML help file interpret this as "reaper.array". However, if a script tries to pass a reaper.array to the function, the IDE raises an error, stating that a number is required.
juliansader is offline   Reply With Quote
Old 05-26-2020, 10:54 AM   #2
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I think this came with the recent changes to the Reaper IDE. It was not like that before
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-26-2020, 12:29 PM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by amagalma View Post
I think this came with the recent changes to the Reaper IDE. It was not like that before
It was also there before the recent IDE changes.
Here's my FR thread from 2018 talking about it:
https://forum.cockos.com/showthread.php?t=212695

To elaborate:
In my own SWS exported function NF_AnalyzeMediaItemPeakAndRMS() which is supposed to take a reaper.array as argument I use void* instead (as passing a reaper.array doesn't work as stated above) which works but being able to take a reaper.array explicitly would be nicer for type safety etc.
But then I suppose there'd be a problem with the other (except Lua) Reaper scripting languages which don't provide a reaper.array (afaik).

edit:
Being able to define/pass double* instead of reaper.array as mentioned by js would probably be better indeed for compatibilty with the other scripting languages.

Last edited by nofish; 05-26-2020 at 12:48 PM.
nofish is offline   Reply With Quote
Old 05-26-2020, 12:44 PM   #4
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,749
Default

Can you give an example of a function that displays the variable type wrong, and the exact defstring that the extension passes to reaper via register("API_...") please?
schwa is offline   Reply With Quote
Old 05-26-2020, 01:44 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Here's runnable code (courtesy of cfillion, potential errors probably because of my adaption ) registering functionName(char*, double*) and auto-generated ReaScript help displaying
Code:
Lua: number retval, string str = reaper.functionName(string str, reaper.array flag)
.

Code:
static const char* definition = "double\0char*,double*\0str,flag\0help text for myfunction";
static double cImpl(char* str, double* flag)
{
	return 0;
}

static void* reascriptImpl(void** argv, double* argc)
{
	// argument count check is already done by reaper
	return (void*)(intptr_t)cImpl((char*)argv[0], (double*)(intptr_t)argv[1]);
}

void registerAPI()
{
	// called when initializing the extension
	plugin_register("API_functionName", (void*)&cImpl);
	plugin_register("APIvararg_functionName", (void*)&reascriptImpl);
	plugin_register("APIdef_functionName", (void*)definition);
}
ReaScript help screenshot:


Does this help?

edit:
Now when calling this function in Lua and trying to pass a reaper.array this error occurs as mentioned in OP:


edit2:
Not related to this issue directly, but there's a similar problem for passing HWND:
https://forum.cockos.com/showthread.php?t=208090

Though this may be more of a FR.

Last edited by nofish; 05-26-2020 at 03:05 PM.
nofish is offline   Reply With Quote
Old 05-26-2020, 05:00 PM   #6
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,749
Default

Ah thanks. It's more undocumented behavior than a bug, but the variable name needs to be either flagOut or flagInOptional so the parser knows what to do with it, otherwise it punts to calling it an array.
schwa is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.