Using mex and clibgen
Mostra commenti meno recenti
When using a shared library in matlab, that uses structs as data types they will be included in the library definition as classes.
% Example C code
%
% ...
%
% struct dummy
% {
% ...
% };
%
% double doSomething(dummy* handle)
% {
% ...
% }
clibgen.generateLibraryDefinition('example.dll')
summary(defineexample)
% Console output:
% Class clib.example.dummy
%
% Constructors:
% clib.example.dummy()
% clib.example.dummy(clib.example.dummy)
%
% No Methods defined
% No Properties defined
%
% Functions
% double clib.example.doSomething(clib.example.dummy)
So MATLAB basically creates a matlab class in the well known style from the struct out of the dll.
Does anyone know how i get back to the original class/struct when calling a mex function?
Or even if you know how exactly matlab converts this struct to a class would be helpfull.
For example:
dummy could be a collection of user data contained in a struct. A pointer to an instance of that struct is passed to a function inside the dll. Of course there are no pointers in MATLAB so an instance of the newly created (handle?) class will be used as the argument to the function generated by clibgen.
When i now pass that instance of the matlab class to a mex function is there a way of retreiving the original type 'dummy' from the object of type clib.example.dummy?
1 Commento
Jonas Steiner
il 18 Feb 2022
Modificato: Jonas Steiner
il 18 Feb 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Build MATLAB Interface to C++ Library in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!