code generation of MEX marshalling functions

4 ビュー (過去 30 日間)
Thierry Bernier
Thierry Bernier 2021 年 9 月 7 日
編集済み: Thierry Bernier 2021 年 9 月 7 日
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.

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by