Beispiel #1
0
 Variant MathFunction::run(const List<Variant>& args)
 {
     return theFunction(args);
 }
FunctionModel FunctionFind(std::vector<Token>::const_iterator& it, std::vector<Token>::const_iterator end, bool TimeDefault)
{
    // we should be at start of function

    std::string returnType = it->GetValue();
    ++it;
    bool Volatile = false;
    bool time =TimeDefault;
    bool threadsafe = false;

    if (it == end)
        throw("function half declared at end of file");

    std::string functionDesc("too lazy to comment this function");

    if (it->GetType() == Token::comment)
    {
        functionDesc = it->GetValue();
        ++it;
    }

    if (it == end)
        throw("function half declared at end of file");

    while (it->GetType() == Token::comment)
    {
        std::string commentString = it->GetValue();

        if (LeftString(commentString,5UL) != "<xlw:")
            throw("unexpected comment in function definition before function name");

        bool found = false;
        if (commentString == "<xlw:volatile")
        {
            Volatile =true;
            ++it;
            found = true;
            if (it == end)
                throw("function half declared at end of file");
        }
        if (commentString == "<xlw:time")
        {
            time = true;
            ++it;
            found = true;
            if (it == end)
                throw("function half declared at end of file");
        }
        if (commentString == "<xlw:threadsafe")
        {
            threadsafe = true;
            ++it;
            found = true;
            if (it == end)
                throw("function half declared at end of file");
        }
        if (!found)
            throw("unknown xlw command: "+commentString);
    }

    if (it->GetType() != Token::identifier)
        throw("function name expected after return type");
    
    std::string functionName(it->GetValue());

    FunctionModel theFunction(returnType,functionName,functionDesc,Volatile,time,threadsafe);

    ++it;
    if (it == end)
        throw("function half declared at end of file");

    if ( it->GetType() != Token::left)
        throw("left parenthesis expected after function name: "+functionName);

    ++it;
    if (it == end)
        throw("function half declared at end of file "+functionName);

    while ( it->GetType() != Token::right)
    {
        if (it->GetType() != Token::identifier)
            throw("return type expected in arg list "+functionName);

        std::string argType = it->GetValue(); 

        ++it;
        if (it == end)
            throw("function half declared at end of file "+functionName);

        if (it->GetType() != Token::identifier)
            throw("argument name expected in arg list "+functionName);

        std::string argName = it->GetValue(); 

        ++it;
        if (it == end)
            throw("function half declared at end of file "+functionName);

        std::string argComment("too lazy to comment this one");

        if (it->GetType() == Token::comment)
        {
            argComment = it->GetValue();
            ++it;
            if (it == end)
                throw("function half declared at end of file "+functionName);
        }

        // ok got this argument's data

        theFunction.AddArgument(argType,argName,argComment);

        if (it->GetType() == Token::comma)
        {
            ++it;
            if (it == end)
                throw("function half declared at end of file "+functionName);
        }

    }
    ++it; // get past final right bracket
    return theFunction;

}
Beispiel #3
0
void f0ext_float(t_f0ext *x, double val) {
	x->valLeft= val;
	theFunction(x);
}
Beispiel #4
0
void f0ext_int(t_f0ext *x, long val) {
	x->valLeft= val;
	theFunction(x);
}
Beispiel #5
0
void f0ext_bang(t_f0ext *x) {
	x->valOut= theFunction(x->valIn, x->valMin, x->valMax, x->intswitch);
	outlet_float(x->out, x->valOut);
}