summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp
diff options
context:
space:
mode:
authorrupak2019-09-13 14:28:13 +0530
committerrupak2019-09-13 14:28:13 +0530
commit5389ebb4ebe79b95418d0a3d26c9e091080a2562 (patch)
tree730c5be02fd02113b38068c946e62e0ac707f33b /sci_gateway/cpp
parent74a2b6c725d09877fbc33103454932c4c005a016 (diff)
downloadfossee-scilab-octave-toolbox-5389ebb4ebe79b95418d0a3d26c9e091080a2562.tar.gz
fossee-scilab-octave-toolbox-5389ebb4ebe79b95418d0a3d26c9e091080a2562.tar.bz2
fossee-scilab-octave-toolbox-5389ebb4ebe79b95418d0a3d26c9e091080a2562.zip
intermediate push for string input
Diffstat (limited to 'sci_gateway/cpp')
-rwxr-xr-xsci_gateway/cpp/libscilab_toolbox.sobin17600 -> 17144 bytes
-rw-r--r--sci_gateway/cpp/sci_matrix.cpp96
2 files changed, 67 insertions, 29 deletions
diff --git a/sci_gateway/cpp/libscilab_toolbox.so b/sci_gateway/cpp/libscilab_toolbox.so
index d336448..9fcddc9 100755
--- a/sci_gateway/cpp/libscilab_toolbox.so
+++ b/sci_gateway/cpp/libscilab_toolbox.so
Binary files differ
diff --git a/sci_gateway/cpp/sci_matrix.cpp b/sci_gateway/cpp/sci_matrix.cpp
index 1edbf16..b41026c 100644
--- a/sci_gateway/cpp/sci_matrix.cpp
+++ b/sci_gateway/cpp/sci_matrix.cpp
@@ -21,12 +21,12 @@ static const char fname[] = "octave_fun";
int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* opt, int nout, scilabVar* out)
{
- if (nin < 3)
+ if (nin < 2)
{
- Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), fname, 3);
+ Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), fname, 2);
return STATUS_ERROR;
}
-
+/*
int typ=0;
for(int i=1;i<nin+1;i++)
{
@@ -37,6 +37,8 @@ printf("%s\n","1 - sci_matrix: a matrix of doubles");
printf("%s\n","10 - sci_strings: a matrix of strings");
printf("%s\n", "=================================");
+*/
+
/*
printf("%d\n", nin);
int row = 0;
@@ -47,6 +49,10 @@ printf("%s\n", "=================================");
printf("%d\n", col);
int i=3;
*/
+
+ octf ins;
+
+ octf *inptr = &ins;
///////////////////First Input/////////////////////
double* n = NULL;
int row = 0;
@@ -54,12 +60,20 @@ printf("%s\n", "=================================");
int size = 0;
size = scilab_getDim2d(env, in[0], &row, &col);
scilab_getDoubleArray(env, in[0], &n);
- double ar[(int)n[0]];//output size can be defined here
+// double ar[(int)n[0]];//output size can be defined here
// if((int)n[0]!=NULL)
// if(in[i]!=NULL)
// printf("\nInput %d is not null\n",i);
+//double inp[col];
+ins.input1 = new double[col];
+ins.size_input1[2]=col;
+
+ for(int i=0; i<col; i++)
+ {
+ ins.input1[i] = n[i];//.float_value();
+ }
////////////////Second Input/////////////////////
wchar_t* in1 = 0;
@@ -77,27 +91,47 @@ printf("%s\n", "=================================");
wcstombs(str, in1, sizeof(str));
//printf("%s\n", str);
+ if(str)
+ ins.name1 = str;
}
////////////////Third Input/////////////////////
- wchar_t* in4 = 0;
+if(nin<3)
+{
+ ins.name2 = NULL;
+}
+else
+{
- char str2[20];
- if (scilab_isString(env, in[2]) == 0 || nin < 3)
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), fname, 3);
- return STATUS_ERROR;
- }
- else
- {
- scilab_getString(env, in[2], &in4);
- //printf("%S\n", in1);
- wcstombs(str2, in4, sizeof(str2));
- //printf("%s\n", str);
- }
+ wchar_t* in4 = 0;
+
+ char str2[20];
+
+ if (scilab_isString(env, in[2]) == 0)
+ {
+ printf("Here----------------");
+ ins.name2 = NULL;
+ Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), fname, 3);
+
+ return STATUS_ERROR;
+ }
+ else
+ {
+ scilab_getString(env, in[2], &in4);
+ //printf("%S\n", in1);
+
+ wcstombs(str2, in4, sizeof(str2));
+ //printf("%s\n", str);
+ if(!*str2)
+ ins.name2 = str2;
+ else
+ ins.name2 = NULL;
+ }
+}
+
//if (nin != 0)
// {
// Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), fname, 1);
@@ -110,24 +144,28 @@ if (nout != 1)
return 1;
}
- double inp[col];
-
- for(int i=0; i<col; i++)
- {
- inp[i] = n[i];//.float_value();
- }
+
- fun(ar, inp, col, str, str2);
- out[0] = scilab_createDoubleMatrix2d(env, n[0], 1, 0);
+ //fun(ar, inp, col, str, str2);
+ int status_fun = fun(inptr);
+ if(status_fun==1)
+ {
+ return 1;
+ }
+ else
+ {
+ out[0] = scilab_createDoubleMatrix2d(env, ins.size_output1[1], 1, 0);
double* out1 = NULL;
scilab_getDoubleArray(env, out[0], &out1);
- for(int i=0; i<n[0]; i++)
+ for(int i=0; i<ins.size_output1[1]; i++)
{
- out1[i] = ar[i];//.float_value();
+ out1[i] = ins.output1[i];//.float_value();
}
-
+ free(ins.output1);
+ free(ins.input1);
+ }
return 0;
}