I have published a native function ( with PP as parameters type ), that requires two parameters of pointer type :
Is it right to recall the function like this ?
sprintf(espressione, "myfunction(%lld,%lld)", (long long)elemDPP, (long long)&featureCorrente);
when i try to access the pointer in published function, it seems invalid
( using %p as format , it's an alphanumeric value that can't be used in espression string )
Greetings,
Alessandro Trebbi
What version (e.g. v10.x.y.z) of MicroStation, or other product, are you using?
Alessandro Trebbi said:I have published a native function
Please show your code.
Your tag MDL is confusing. In which DLL is the 'native function' supplied? Why do you want to invoke your function in a C expression?
Regards, Jon Summers LA Solutions
it's a plugin system, i have an mdl application that registers as plugin to another mdl application (both native): child's functions are published and then called by parent app
microstation is not the last release, was there a bug that has been fixed ?
Jon Summers said:What version (e.g. v10.x.y.z) of MicroStation, or other product, are you using?
Alessandro Trebbi said:microstation is not the last release
What does that mean?
Alessandro Trebbi said:i have an mdl application that registers as plugin to another mdl application (both native)
If you're building DLLs for MicroStation CONNECT, then don't use 'MDL' because MDL is a V8-era technology. You have two Windows DLLs. One DLL can call exported functions in another DLL. You don't need to 'publish' pointers to MicroStation C expressions.
Read about Windows DLL technology on a Microsoft web site.
Ok i know, but my problem is simply that i can't find a reliable way to pass parameters such as pointers to a function called through mdlCExpression_getValue() ; is it a Microstation bug or did i do something wrong ?
this is the function
typedef int fPrimaDiInserimentoElemento( MSElementDescrH, CfgFeature *);
i publish the function :
mdlCExpression_publishFunction (funzioniPubbliche, "myfunction", "PP", mdlCExpression_getType (TYPECODE_LONG), primaDiInserimentoElemento);
and this is the expression i'm using for mdlCExpression_getValue()
sprintf(espressione, "myfunction(%lld,%lld)", featureCorrente.plugin, (long long)elemDPP, (long long)&featureCorrente);
the pointers are non valid and dll crashes
sorry this is the code to build expression ( the relevant thing is how i should write the 2 pointers )
sprintf(espressione, "myfunction(%lld,%lld)",(long long)elemDPP,(long long)&featureCorrente);
Alessandro Trebbi said:i publish the function :
Please post all relevant code! For example, where do you initialise funzioniPubbliche?
funzioniPubbliche
Alessandro Trebbi said:mdlCExpression_getType (TYPECODE_LONG)
If you're publishing pointers, shouldn't that be mdlCExpression_getType (TYPECODE_POINTER)?
mdlCExpression_getType (TYPECODE_POINTER)
that parameter is related to returned value, that is an int, so should be corrected
i have found another couple of functions for expressions,
mdlCExpression_publishTrustedFunction , mdlCExpression_restrictedGetValue
but i have the same problem
and this is "funzioniPubbliche" :
SymbolSet *funzioniPubbliche;
funzioniPubbliche = mdlCExpression_initializeSet(VISIBILITY_CALCULATOR, 0, TRUE);
Alessandro Trebbi said:mdlCExpression_publishFunction (funzioniPubbliche, "myfunction", "PP", mdlCExpression_getType (TYPECODE_LONG), primaDiInserimentoElemento);
The argument "PP" informs mdlCExpression_publishFunction that your function takes two pointers.
mdlCExpression_publishFunction
However, MSElementDescrH is a pointer-to-pointer (MSElementDescr**). I don't think that mdlCExpression_publishFunction comprehends pointer-to-pointer.
MSElementDescrH
MSElementDescr**
Alessandro Trebbi said: i can't find a reliable way to pass parameters such as pointers to a function called through mdlCExpression_getValue()
I still don't understand why you want to use that 20th century technology. Where will you use mdlCExpression_getValue()?
mdlCExpression_getValue()
I have printed values that i'm trying to pass and values I read in the called function
primaDiInserimentoElemento(359481202760,140722086683472)primaDiInserimentoElemento(-1296050104,1778197328)
the values are completely different, i suppose that the values I read are truncated to 32b