Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 09-28-2018, 10:30 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default Can ReaScript API provided by C++ extensions use reaper.array as parameter or return?

Is it possible to use a reaper.array as parameter type or return type in a ReaScript API function that is provided by a C++ extension?

The SWS documentation doesn't mention anything about reaper.arrays, but in my C++ extension, if I use "double*" as parameter type or return type, the ReaScript IDE displays it as "reaper.array", which makes me optimistic!

What is a reaper.array? Simply an array of double*?

How do I know the size of the array?

If the size isn't inherent in the array (like a 0-terminated char array), how do I pass the size of the array between the script and the extension?

Do reaper.arrays have a maximum size?
juliansader is offline   Reply With Quote
Old 09-28-2018, 04:57 PM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

A few answers for myself:

* reaper.array is indeed an array of 64-bit doubles,

* except for the first 64 bits, which stores the array size and consists of two 32-bit long ints:

* The currently used size ({reaper.array}.resize) is stored in the the first int (the lower 32 bits, if the first entry is taken as one 64-bit long long int) and the maximum allocated size ({reaper.array}.get_alloc) and is stored in the second int / higher 32 bits.


reaper.arrays can be passed from ReaScript to C++ extension API as void*. However, the other direction doesn't work: when returning a pointer to a reaper.array as void*, REAPER doesn't recognize it as a reaper.array.

Therefore, if an API function is supposed to return information in the forms of a reaper.array, an existing reaper.array into which the API function may write should be included as one of the arguments.


If an extension declares a "double*" argument type in plugin_register(APIdef_funcName), REAPER translates this as "reaper.array" in the auto-generated website help and IDE context help. Unfortunately, if a script tries to pass a reaper.array for the argument, the IDE complains about wrong type.
juliansader 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 07:03 AM.


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