ThorRussell
asked on
Calling a C++ dll with ColdFusion, ColdFusion cannot pass pointers as required
We have an existing C++ dll for processing data the has been used for a few years in our products. We are not develolping a web based SAAS version of our product, and need to integrate ColdFusion in with the .dll. The trouble is the C++ dll expects an array of data, passed as a pointer to the start of the array, but ColdFusion cannot deal with pointers.
The dll function prototype is
void SpeechAnalyseRT::storeAndA nalyseChun k(short int* data, unsigned long dataLength)
and has virtual function
virtual void CALL storeAndAnalyseChunk(short int* data, unsigned long dataLength) = 0;
How do we change this to pass by value? it has been suggested that we use a struct with an array inside. What is the syntax to make this work, i.e. declaring the struct etc?
Is this the right thing to do?
Thanks
Thor
The dll function prototype is
void SpeechAnalyseRT::storeAndA
and has virtual function
virtual void CALL storeAndAnalyseChunk(short
How do we change this to pass by value? it has been suggested that we use a struct with an array inside. What is the syntax to make this work, i.e. declaring the struct etc?
Is this the right thing to do?
Thanks
Thor
...or
data Data[1];
// fill struct
storeAndAnalyseChunk(Data, 1);
respectively.
data Data[1];
// fill struct
storeAndAnalyseChunk(Data,
respectively.
um, make the last one
data Data[1];
// fill struct
Data[0].nSampleMember = 42;
storeAndAnalyseChunk(Data, 1);
data Data[1];
// fill struct
Data[0].nSampleMember = 42;
storeAndAnalyseChunk(Data,
ASKER
The array needs to be of size somewhere between 44,100 to 441,000 size 1 definitely wont do!
If you cannot supply such aq range, there definitely is a problem... a conceptional one. Pointers and arrays are interchangeable in C/C++, so you should be fine with both. Changing an existing function is out of question, unfortunately.
ASKER
Are you trying to say it cant be done? There must be a way to let coldfusion call a C++ dll.
What do you mean by changing an existing function is out of the question? The dll is mine, so I can change it how I like. I want it to accept the array by value rather than pointer.
What do you mean by changing an existing function is out of the question? The dll is mine, so I can change it how I like. I want it to accept the array by value rather than pointer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"There must be a way to let coldfusion call a C++ dll. "
i'm not familiar with the internals of c++ but i do know how to use them with cf...
just register a cfx custom tag
cfadmin -> cfx tags -> Register C++ CFX -> name tag cfx_yourDLLName -> choose path to dll
note that if your dll is called foo you need to name the tag cfx_foo
then call the dll like so
<cfx_foo expectedInputparameter1="# somevar1#"
expectedInputparameter2="# somevar2#" >
then the output would be something like
<cfoutput>
#outputParamStuct.outputPa ram1#
</cfoutput>
where outputParamStruct is the struct containing value or values returned by the dll and outputParam1 is the value itself.
i'm not familiar with the internals of c++ but i do know how to use them with cf...
just register a cfx custom tag
cfadmin -> cfx tags -> Register C++ CFX -> name tag cfx_yourDLLName -> choose path to dll
note that if your dll is called foo you need to name the tag cfx_foo
then call the dll like so
<cfx_foo expectedInputparameter1="#
expectedInputparameter2="#
then the output would be something like
<cfoutput>
#outputParamStuct.outputPa
</cfoutput>
where outputParamStruct is the struct containing value or values returned by the dll and outputParam1 is the value itself.
"note that if your dll is called foo you need to name the tag cfx_foo"
to be more specific
note that if your dll is called FOO.DLL you need to name the tag CFX_FOO (no extension)
to be more specific
note that if your dll is called FOO.DLL you need to name the tag CFX_FOO (no extension)
I'd say http:#20423624 clears up the issue, so I tend to object to a delete.
data Data;
// fill struct
storeAndAnalyseChunk(&Data