omegahat / RDCOMClient

GNU General Public License v2.0
77 stars 34 forks source link

Calling R_convertDCOMObjectToR #5

Closed BadJerry closed 6 years ago

BadJerry commented 6 years ago

New to R programming so bear with me.

I am trying to call a function defined in converters.cpp file inside your package called R_convertDCOMObjectToR. I try to call it like this:

.Call("R_convertDCOMObjectToR", varQuestionNames, PACKAGE = "RDCOMClient")

But I get the following error:

Error in .Call("R_convertDCOMObjectToR", varQuestionNames, PACKAGE = "RDCOMClient") : "R_convertDCOMObjectToR" not available for .Call() for package "RDCOMClient"

Is there anyway to make that function visible?

Thanks for any pointer!

varQuestionNames <- asCOMArray(1:2);
names <-  .Call("R_getDynamicVariantValue", varQuestionNames, PACKAGE = "RDCOMClient");

But I get an error :

Argument to R_getVariantRef does not have the correct tag.

duncantl commented 6 years ago

R_convertDCOMObjectToR() takes a VARIANT * as its parameter. You cannot invoke this via the .Call() interface as that passes R objects to the routine with type SEXP.

R_getDynamicVariantValue() can be called as you do above. Here we check the tag symbol on the external pointer asCOMArray() sets this to R_VARIANT, whereas R_getDynamicVariantValue() checks for VARIANTReference. You might try changing the "R_VARIANT" in the R_create2DArray() routine to "VARIANTReference".

BadJerry commented 6 years ago

Thank you very much for taking the time to reply. I really appreciate. My problem is that the COM object I use needs a VARIANT pointer (therefore a R_VARIANT). I will try to write a function that converts a SEXP object from a R_VARIANT to a VARIANTReference. I might call for help at one point ;) What is the etiquette regarding github code? Should I create branch? Or should I write that converter in my own R Code? Thanks again!