If only your number crunching function was operating on ints! Then you would be able to use CModule.writeIntVector to write vector contents to DomainMemory and just pass over a pointer to the C++ code.
But since it's doubles, you will have to iterate through Vector and convert each element from AS3 Number to C++ double using CModule.writeDouble. Then you can manually expose your function to AS3 with an interface that accepts a DomainMemory pointer:
void doNumberCrunchingAS() __attribute__((used,
annotate("as3sig:public function doNumberCrunching(inputPtr:int):Number"),
annotate("as3package:mypackage"))
));
double doNumberCrunching( double* input )
{
// Actual implementation here
return 0;
}
void doNumberCrunchingAS()
{
// Read the AS3 argument and convert it to a convenient C++ form.
int memoryOffset = 0;
AS3_GetScalarFromVar(memoryOffset, inputPtr);
double* inputPtr = reinterpret_cast<double*>( memoryOffset );
// Call an implementation routine.
double result = doNumberCrunching( inputPtr );
// Return result to AS3 code.
AS3_Return( result );
}
AS3 code:
package
{
using mypackage.doNumberCrunching;
function testNumberCrunching():void
{
var ptr:int = CModule.malloc(blobSize);
// a loop of writeDouble should be here
doNumberCrunching(ptr);
CModule.free(ptr);
}
}