int ScilabGateway::getRepresentation(char * fname, const int envId, void * pvApiCtx)
{
    SciErr err;
    int * addr = 0;
    int tmpvar[2] = {0, 0};
    int idObj = 0;

    CheckInputArgument(pvApiCtx, 1, 1);

    ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
    ScilabGatewayOptions & options = env.getGatewayOptions();
    OptionsHelper::setCopyOccurred(false);
    ScilabObjects::initialization(env, pvApiCtx);
    options.setIsNew(false);

    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
    if (err.iErr)
    {
        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
    }

    if (!ScilabObjects::isExternalObjOrClass(addr, pvApiCtx))
    {
        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: An External Object expected."), 1);
    }

    idObj = ScilabObjects::getArgumentId(addr, tmpvar, false, false, envId, pvApiCtx);

    env.getrepresentation(idObj, ScilabStringStackAllocator(pvApiCtx, Rhs + 1));

    LhsVar(1) = Rhs + 1;
    PutLhsVar();

    return 0;
}
Esempio n. 2
0
int ScilabGateway::getClasspath(char * fname, const int envId, void * pvApiCtx)
{
    CheckInputArgument(pvApiCtx, 0, 0);

    ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
    ScilabGatewayOptions & options = env.getGatewayOptions();
    OptionsHelper::setCopyOccurred(false);
    ScilabObjects::initialization(env, pvApiCtx);
    options.setIsNew(false);

    env.getclasspath(ScilabStringStackAllocator(pvApiCtx, Rhs + 1));

    LhsVar(1) = Rhs + 1;
    PutLhsVar();

    return 0;
}
Esempio n. 3
0
bool ScilabObjects::unwrap(int idObj, int pos, const int envId, void * pvApiCtx)
{
    if (idObj == 0)
    {
        if (createEmptyMatrix(pvApiCtx, pos))
        {
            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot create data"));
        }
        return true;
    }

    VariableType type = Nothing;
    ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
    const ScilabAbstractEnvironmentWrapper & wrapper = env.getWrapper();

    type = env.isunwrappable(idObj);

    switch (type)
    {
        case Nothing:
            return false;
        case Null:
            if (createEmptyMatrix(pvApiCtx, pos))
            {
                throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot create data"));
            }
        case SingleDouble:
            wrapper.unwrapdouble(idObj, ScilabDoubleStackAllocator(pvApiCtx, pos));
            break;
        case RowDouble:
            wrapper.unwraprowdouble(idObj, ScilabDoubleStackAllocator(pvApiCtx, pos));
            break;
        case MatDouble:
            wrapper.unwrapmatdouble(idObj, ScilabDoubleStackAllocator(pvApiCtx, pos));
            break;
        case SingleString:
            wrapper.unwrapstring(idObj, ScilabStringStackAllocator(pvApiCtx, pos));
            break;
        case RowString:
            wrapper.unwraprowstring(idObj, ScilabStringStackAllocator(pvApiCtx, pos));
            break;
        case MatString:
            wrapper.unwrapmatstring(idObj, ScilabStringStackAllocator(pvApiCtx, pos));
            break;
        case SingleBoolean:
            wrapper.unwrapboolean(idObj, ScilabBooleanStackAllocator(pvApiCtx, pos));
            break;
        case RowBoolean:
            wrapper.unwraprowboolean(idObj, ScilabBooleanStackAllocator(pvApiCtx, pos));
            break;
        case MatBoolean:
            wrapper.unwrapmatboolean(idObj, ScilabBooleanStackAllocator(pvApiCtx, pos));
            break;
        case SingleChar:
            wrapper.unwrapchar(idObj, ScilabCharStackAllocator(pvApiCtx, pos));
            break;
        case RowChar:
            wrapper.unwraprowchar(idObj, ScilabCharStackAllocator(pvApiCtx, pos));
            break;
        case MatChar:
            wrapper.unwrapmatchar(idObj, ScilabCharStackAllocator(pvApiCtx, pos));
            break;
        case SingleUChar:
            wrapper.unwrapuchar(idObj, ScilabUCharStackAllocator(pvApiCtx, pos));
            break;
        case RowUChar:
            wrapper.unwraprowuchar(idObj, ScilabUCharStackAllocator(pvApiCtx, pos));
            break;
        case MatUChar:
            wrapper.unwrapmatuchar(idObj, ScilabUCharStackAllocator(pvApiCtx, pos));
            break;
        case SingleShort:
            wrapper.unwrapshort(idObj, ScilabShortStackAllocator(pvApiCtx, pos));
            break;
        case RowShort:
            wrapper.unwraprowshort(idObj, ScilabShortStackAllocator(pvApiCtx, pos));
            break;
        case MatShort:
            wrapper.unwrapmatshort(idObj, ScilabShortStackAllocator(pvApiCtx, pos));
            break;
        case SingleUShort:
            wrapper.unwrapushort(idObj, ScilabUShortStackAllocator(pvApiCtx, pos));
            break;
        case RowUShort:
            wrapper.unwraprowushort(idObj, ScilabUShortStackAllocator(pvApiCtx, pos));
            break;
        case MatUShort:
            wrapper.unwrapmatushort(idObj, ScilabUShortStackAllocator(pvApiCtx, pos));
            break;
        case SingleInt:
            wrapper.unwrapint(idObj, ScilabIntStackAllocator(pvApiCtx, pos));
            break;
        case RowInt:
            wrapper.unwraprowint(idObj, ScilabIntStackAllocator(pvApiCtx, pos));
            break;
        case MatInt:
            wrapper.unwrapmatint(idObj, ScilabIntStackAllocator(pvApiCtx, pos));
            break;
        case SingleUInt:
            wrapper.unwrapuint(idObj, ScilabUIntStackAllocator(pvApiCtx, pos));
            break;
        case RowUInt:
            wrapper.unwraprowuint(idObj, ScilabUIntStackAllocator(pvApiCtx, pos));
            break;
        case MatUInt:
            wrapper.unwrapmatuint(idObj, ScilabUIntStackAllocator(pvApiCtx, pos));
            break;
        case SingleLong:
            wrapper.unwraplong(idObj, ScilabLongStackAllocator(pvApiCtx, pos));
            break;
        case RowLong:
            wrapper.unwraprowlong(idObj, ScilabLongStackAllocator(pvApiCtx, pos));
            break;
        case MatLong:
            wrapper.unwrapmatlong(idObj, ScilabLongStackAllocator(pvApiCtx, pos));
            break;
        case SingleULong:
            wrapper.unwrapulong(idObj, ScilabULongStackAllocator(pvApiCtx, pos));
            break;
        case RowULong:
            wrapper.unwraprowulong(idObj, ScilabULongStackAllocator(pvApiCtx, pos));
            break;
        case MatULong:
            wrapper.unwrapmatulong(idObj, ScilabULongStackAllocator(pvApiCtx, pos));
            break;
        case SingleFloat:
            wrapper.unwrapfloat(idObj, ScilabFloatStackAllocator(pvApiCtx, pos));
            break;
        case RowFloat:
            wrapper.unwraprowfloat(idObj, ScilabFloatStackAllocator(pvApiCtx, pos));
            break;
        case MatFloat:
            wrapper.unwrapmatfloat(idObj, ScilabFloatStackAllocator(pvApiCtx, pos));
            break;
        case SingleComplex:
            wrapper.unwrapcomplex(idObj, ScilabComplexStackAllocator(pvApiCtx, pos));
            break;
        case RowComplex:
            wrapper.unwraprowcomplex(idObj, ScilabComplexStackAllocator(pvApiCtx, pos));
            break;
        case MatComplex:
            wrapper.unwrapmatcomplex(idObj, ScilabComplexStackAllocator(pvApiCtx, pos));
            break;
        default:
            return false;
    }

    return true;
}