Skip to content

Commit

Permalink
Minor cleanup in Matlab-C-Conversion in both directions
Browse files Browse the repository at this point in the history
  • Loading branch information
hkbinaurics committed Nov 24, 2023
1 parent 2bf302e commit 26299a4
Show file tree
Hide file tree
Showing 22 changed files with 884 additions and 652 deletions.
24 changes: 12 additions & 12 deletions software/codeFragments/jvxHosts/mex/src/mexJvxHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "mexJvxHost.h"
#include "mexCmdMapperJvxHost.h"
#include "HjvxMex2CConverter.h"
#include "CjvxMatlabToCConverter.h"
#include "jvx-helpers.h"
#include "realtimeViewer_helpers.h"
extern "C"
Expand Down Expand Up @@ -161,7 +161,7 @@ mexJvxHost::parseInput(int nlhs, mxArray *plhs[],
}
else if(mxIsChar(arr))
{
std::string token = jvx_mex_2_cstring(arr);
std::string token = CjvxMatlabToCConverter::jvx_mex_2_cstring(arr);
bool foundit = false;
for(i = 0; i < JVX_HOST_COMMAND_LIMIT; i++)
{
Expand Down Expand Up @@ -601,7 +601,7 @@ mexJvxHost::initialize(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[
const mxArray* arr = prhs[i + 1];
if (mxIsChar(arr))
{
strList.push_back(jvx_mex_2_cstring(arr));
strList.push_back(CjvxMatlabToCConverter::jvx_mex_2_cstring(arr));
}
else if (mxIsStruct(arr))
{
Expand All @@ -613,7 +613,7 @@ mexJvxHost::initialize(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[
mxArray* arrWork = mxGetFieldByNumber(arr, 0, ii);
if (!mxIsChar(arrWork))
{
strList.push_back(jvx_mex_2_cstring(arrWork));
strList.push_back(CjvxMatlabToCConverter::jvx_mex_2_cstring(arrWork));
}
}
}
Expand Down Expand Up @@ -951,7 +951,7 @@ mexJvxHost::write_config(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prh

if(nrhs >= 2)
{
res = mexArgument2String(fName, prhs, 1, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(fName, prhs, 1, nrhs);
}

if(res == JVX_NO_ERROR)
Expand Down Expand Up @@ -1290,7 +1290,7 @@ mexJvxHost::lookup_type_id__name(int nlhs, mxArray* plhs[], int nrhs, const mxAr
{
return_options_lookup = false;

res = mexArgument2String(type_category, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(type_category, prhs, paramId, nrhs);
if (res != JVX_NO_ERROR)
{
parametersOk = false;
Expand All @@ -1300,7 +1300,7 @@ mexJvxHost::lookup_type_id__name(int nlhs, mxArray* plhs[], int nrhs, const mxAr
{
return_options_names = false;
paramId = 2;
res = mexArgument2String(type_name, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(type_name, prhs, paramId, nrhs);
if (res != JVX_NO_ERROR)
{
parametersOk = false;
Expand Down Expand Up @@ -1929,21 +1929,21 @@ mexJvxHost::lookup_type_name__value(int nlhs, mxArray* plhs[], int nrhs, const m
jvxBitField valC;
jvxBitField cmpBtfld;

res = mexArgument2String(type_category, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(type_category, prhs, paramId, nrhs);
if (res != JVX_NO_ERROR)
{
parametersOk = false;
}

paramId = 2;
res = mexArgument2Index(id, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2Index(id, prhs, paramId, nrhs);
if (res == JVX_NO_ERROR)
{
inputIsSize = true;
}
else
{
res = mexArgument2String(bfld, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(bfld, prhs, paramId, nrhs);
{
if (res == JVX_NO_ERROR)
{
Expand Down Expand Up @@ -2387,7 +2387,7 @@ mexJvxHost::lookup_const__name(int nlhs, mxArray* plhs[], int nrhs, const mxArra
}
else
{
res = mexArgument2String(type_category, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(type_category, prhs, paramId, nrhs);
if (res != JVX_NO_ERROR)
{
parametersOk = false;
Expand Down Expand Up @@ -2471,7 +2471,7 @@ mexJvxHost::set_callback_msgq(int nlhs, mxArray* plhs[], int nrhs, const mxArray
{
if(mxIsChar(prhs[1]))
{
this->msg_queue.callback_prefix = jvx_mex_2_cstring(prhs[1]);
this->msg_queue.callback_prefix = CjvxMatlabToCConverter::jvx_mex_2_cstring(prhs[1]);
if(nlhs > 0)
{
this->mexReturnBool(plhs[0], true);
Expand Down
22 changes: 11 additions & 11 deletions software/codeFragments/jvxHosts/mex/src/mexJvxHost_components.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "mexJvxHost.h"
#include "realtimeViewer_helpers.h"
#include "HjvxMex2CConverter.h"
#include "CjvxMatlabToCConverter.h"

jvxErrorType
mexJvxHost::select_component(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
Expand All @@ -23,7 +23,7 @@ mexJvxHost::select_component(int nlhs, mxArray* plhs[], int nrhs, const mxArray*

paramId = 1;

res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand All @@ -46,7 +46,7 @@ mexJvxHost::select_component(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
}

paramId = 2;
res = mexArgument2Index<jvxInt32>(idx, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2Index<jvxInt32>(idx, prhs, paramId, nrhs);
if(res != JVX_NO_ERROR)
{
MEX_PARAMETER_ERROR("component_index", paramId, "numeric");
Expand Down Expand Up @@ -133,7 +133,7 @@ mexJvxHost::activate_component(int nlhs, mxArray* plhs[], int nrhs, const mxArra
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -236,7 +236,7 @@ mexJvxHost::isready_component(int nlhs, mxArray* plhs[], int nrhs, const mxArray
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -327,7 +327,7 @@ mexJvxHost::status_component(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -418,7 +418,7 @@ mexJvxHost::commands_component(int nlhs, mxArray* plhs[], int nrhs, const mxArra
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -509,7 +509,7 @@ mexJvxHost::conditions_component(int nlhs, mxArray* plhs[], int nrhs, const mxAr
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -600,7 +600,7 @@ mexJvxHost::rel_jumps_component(int nlhs, mxArray* plhs[], int nrhs, const mxArr
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -692,7 +692,7 @@ mexJvxHost::deactivate_component(int nlhs, mxArray* plhs[], int nrhs, const mxAr
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -795,7 +795,7 @@ mexJvxHost::unselect_component(int nlhs, mxArray* plhs[], int nrhs, const mxArra
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down
15 changes: 8 additions & 7 deletions software/codeFragments/jvxHosts/mex/src/mexJvxHost_config.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "mexJvxHost.h"
#include "jvxHost_config.h"
#include "CjvxMatlabToCConverter.h"
#include "realtimeViewer_helpers.h"

jvxErrorType
Expand Down Expand Up @@ -265,17 +266,17 @@ mexJvxHost::set_config_entry(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
paramId = 1;
if(mxIsChar(prhs[paramId]))
{
entryname = jvx_mex_2_cstring(prhs[paramId]);
entryname = CjvxMatlabToCConverter::jvx_mex_2_cstring(prhs[paramId]);

paramId++;
resL = mexArgument2String(content, prhs, paramId,nrhs);
resL = CjvxMatlabToCConverter::mexArgument2String(content, prhs, paramId,nrhs);
if(resL == JVX_NO_ERROR)
{
tp = JVX_CONFIG_SECTION_TYPE_ASSIGNMENTSTRING;
}
else
{
resL = mexArgument2StringList(content_list, prhs, paramId,nrhs);
resL = CjvxMatlabToCConverter::mexArgument2StringList(content_list, prhs, paramId,nrhs);
if(resL == JVX_NO_ERROR)
{
tp = JVX_CONFIG_SECTION_TYPE_STRINGLIST;
Expand Down Expand Up @@ -509,7 +510,7 @@ mexJvxHost::get_config_entry(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
paramId = 1;
if(mxIsChar(prhs[paramId]))
{
entryname = jvx_mex_2_cstring(prhs[paramId]);
entryname = CjvxMatlabToCConverter::jvx_mex_2_cstring(prhs[paramId]);
tp = JVX_CONFIG_SECTION_TYPE_UNKNOWN;

res = involvedComponents.theHost.hFHost->request_hidden_interface(JVX_INTERFACE_CONFIGURATION_EXTENDER, (jvxHandle**)&cfgExt);
Expand Down Expand Up @@ -720,7 +721,7 @@ mexJvxHost::export_config_struct(int nlhs, mxArray* plhs[], int nrhs, const mxAr
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -900,7 +901,7 @@ mexJvxHost::export_config_string(int nlhs, mxArray* plhs[], int nrhs, const mxAr
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
res = CjvxMatlabToCConverter::mexArgument2Type<jvxComponentType>(tpC, prhs, paramId, nrhs, JVX_COMPONENT_UNKNOWN, JVX_COMPONENT_ALL_LIMIT, jvxComponentType_str());
switch (res)
{
case JVX_NO_ERROR:
Expand Down Expand Up @@ -1078,7 +1079,7 @@ mexJvxHost::convert_string_config_struct(int nlhs, mxArray* plhs[], int nrhs, co
jvxInt32 paramId = 0;

paramId = 1;
res = mexArgument2String(configStr, prhs, paramId, nrhs);
res = CjvxMatlabToCConverter::mexArgument2String(configStr, prhs, paramId, nrhs);
if (res != JVX_NO_ERROR)
{
parametersOk = false;
Expand Down
Loading

0 comments on commit 26299a4

Please sign in to comment.