Example #1
0
static void ekValueTypeRegisterRegex(struct ekContext * E)
{
    // This is only used as a closure variable during a gmatch, no need to implement
    // all of the type routines.
    ekValueType * type = ekValueTypeCreate(E, "regex", 'R');
    type->funcClear      = regexFuncClear;
    type->funcDump       = regexFuncDump;

    ekValueTypeRegister(E, type);
}
Example #2
0
void ekValueTypeRegisterInt(struct ekContext * E)
{
    ekValueType * type = ekValueTypeCreate(E, "int", 'i');
    type->funcClone      = intFuncClone;
    type->funcToBool     = intFuncToBool;
    type->funcToInt      = intFuncToInt;
    type->funcToFloat    = intFuncToFloat;
    type->funcToString   = intFuncToString;
    type->funcArithmetic = intFuncArithmetic;
    type->funcCmp        = intFuncCmp;
    type->funcDump       = intFuncDump;
    ekValueTypeRegister(E, type);
    ekAssert(type->id == EVT_INT);

    ekContextAddIntrinsic(E, "int", ekiInt);
}
Example #3
0
void ekValueTypeRegisterFloat(struct ekContext * E)
{
    ekValueType * type = ekValueTypeCreate(E, "float", 'f');
    type->funcClone      = floatFuncClone;
    type->funcToBool     = floatFuncToBool;
    type->funcToInt      = floatFuncToInt;
    type->funcToFloat    = floatFuncToFloat;
    type->funcToString   = floatFuncToString;
    type->funcArithmetic = floatFuncArithmetic;
    type->funcCmp        = floatFuncCmp;
    type->funcDump       = floatFuncDump;
    ekValueTypeRegister(E, type);
    ekAssert(type->id == EVT_FLOAT);

    ekContextAddIntrinsic(E, "float", ekiFloat);
}
Example #4
0
static void ekValueTypeRegisterFile(struct ekContext *E)
{
    ekValueType *type = ekValueTypeCreate(E, "file", 'F');
    type->funcClear      = fileFuncClear;
    type->funcClone      = fileFuncClone;
    type->funcToBool     = fileFuncToBool;
    type->funcToInt      = fileFuncToInt;
    type->funcToFloat    = fileFuncToFloat;
    type->funcToString   = fileFuncToString;
    type->funcIter       = fileFuncIter;
    type->funcDump       = fileFuncDump;

    ekValueTypeAddIntrinsic(E, type, "read", fileRead);
    ekValueTypeAddIntrinsic(E, type, "readline", fileReadLine);
    ekValueTypeAddIntrinsic(E, type, "iterate", fileIterate);
    ekValueTypeAddIntrinsic(E, type, "lines", fileLines);
    ekValueTypeAddIntrinsic(E, type, "write", fileWrite);
    ekValueTypeAddIntrinsic(E, type, "size", fileSize);
    ekValueTypeAddIntrinsic(E, type, "close", fileClose);

    ekValueTypeRegister(E, type);
}