code generation of MEX marshalling functions

4 Ansichten (letzte 30 Tage)
Thierry Bernier
Thierry Bernier am 7 Sep. 2021
Bearbeitet: Thierry Bernier am 7 Sep. 2021
Hi, (my first one)
I have a MEX function made of C/C++/Fortran legacy code, and I want to mexCallMATLAB() from it a MATLAB function.
So I have to write (a lot of) marshalling code between C/C++ data structs and mxArray data.
There is a straight naming scheme between C/C++ struct fields and MATLAB struct()'s fields. E.g :
----- C/C++ types/datas :
struct rep { float x, y; };
struct sxx { struct rep rep; int n; } sxx;
struct syy { struct rep rep; int m; } syy;
...
mxArray *foo = <marshalling code to/from sxx and syy>
mexCallMATLAB(..., 'fn');
---- versus MATLAB datas :
sxx.rep.x = single(0);
sxx.rep.y = single(0);
sxx.n = int32(0);
syy.rep.x = single(0);
syy.rep.y = single(0);
syy.m = int32(0);
...
function fn (sxx, syy) ...
For some modules, the C/C++ types are made of codegen'd source code, because in some configuration the MATLAB function is codegen'ed to C/C++ and the MEX Function is a native executable.
Is it possible to codegen the marshalling code ? I would like it to use only mex.h API, not EMLRT.

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by