示例#1
0
/**
 * Runs the `eval` function defined by the given library, passing it the
 * given `env` argument. This function returns whatever the library's
 * `eval` returns. If `eval` is not found, this terminates the runtime with
 * an error message.
 */
static zvalue evalLibrary(void *libHandle, zvalue env) {
    // The circumlocution used to assign `evalFn` is required, because
    // directly assigning a `void *` to a function pointer type is
    // an undefined operation in ISO C. Reference:
    //     <http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html>
    evalFunction *evalFn;
    *(void **)(&evalFn) = dlsym(libHandle, "eval");

    if (evalFn == NULL) {
        die("Trouble looking up `eval`: %s\n", dlerror());
    }

    return evalFn(env);
}
示例#2
0
int Engine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: onEnginePanic((*reinterpret_cast< Atom(*)>(_a[1])),(*reinterpret_cast< Word(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])),(*reinterpret_cast< const QString(*)>(_a[4]))); break;
        case 1: onLine((*reinterpret_cast< Atom(*)>(_a[1])),(*reinterpret_cast< Word(*)>(_a[2]))); break;
        case 2: onExecutionFinished(); break;
        case 3: onEngineStarted(); break;
        case 4: onEngineStopped(); break;
        case 5: eval((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< bool(*)>(_a[3]))); break;
        case 6: evalFn((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< Atom(*)>(_a[2]))); break;
        case 7: fullstop(); break;
        default: ;
        }
        _id -= 8;
    }
    return _id;
}