示例#1
0
文件: loader.cpp 项目: Blei/clay
EnvPtr ForeignStatement::getEnv() {
    if (!foreignEnv) {
        assert(moduleName.size() > 0);
        foreignEnv = loadedModule(moduleName)->env;
    }
    return foreignEnv;
}
示例#2
0
文件: linker.cpp 项目: redstar/ldc
/// Insert an LLVM bitcode file into the module
static void insertBitcodeIntoModule(const char *bcFile, llvm::Module &M,
                                    llvm::LLVMContext &Context) {
  Logger::println("*** Linking-in bitcode file %s ***", bcFile);

  llvm::SMDiagnostic Err;
  std::unique_ptr<llvm::Module> loadedModule(
      getLazyIRFileModule(bcFile, Err, Context));
  if (!loadedModule) {
    error(Loc(), "Error when loading LLVM bitcode file: %s", bcFile);
    fatal();
  }
#if LDC_LLVM_VER >= 308
  llvm::Linker(M).linkInModule(std::move(loadedModule));
#else
  llvm::Linker(&M).linkInModule(loadedModule.release());
#endif
}
示例#3
0
FSHost::FSHost(QObject *parent) :
    QThread(parent)
{
    /* Initialize libs & globals */
    qDebug() << "Initializing globals..." << endl;
    switch_core_setrlimits();
    switch_core_set_globals();

    qRegisterMetaType<QSharedPointer<Call> >("QSharedPointer<Call>");
    qRegisterMetaType<QSharedPointer<switch_event_t> >("QSharedPointer<switch_event_t>");
    qRegisterMetaType<QSharedPointer<switch_log_node_t> >("QSharedPointer<switch_log_node_t>");
    qRegisterMetaType<switch_log_level_t>("switch_log_level_t");
    qRegisterMetaType<QSharedPointer<Channel> >("QSharedPointer<Channel>");
    qRegisterMetaType<QSharedPointer<Account> >("QSharedPointer<Account>");

    connect(this, SIGNAL(loadedModule(QString,QString)), this, SLOT(minimalModuleLoaded(QString,QString)));

}
示例#4
0
void FSHost::generalEventHandler(QSharedPointer<switch_event_t>event)
{
    QString uuid = switch_event_get_header_nil(event.data(), "Unique-ID");

    emit newEvent(event);

    switch(event.data()->event_id) {
    case SWITCH_EVENT_CHANNEL_CREATE: /*1A - 17B*/
        {
            eventChannelCreate(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_ANSWER: /*2A - 31B*/
        {
            eventChannelAnswer(event, uuid);
            break;
        }
    case SWITCH_EVENT_CODEC:/*3/4A - 24/25B*/
        {
            eventCodec(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_STATE:/*6/7/8/37/44/46A - 20/21/22/28/38/40/42B*/
        {
            eventChannelState(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_EXECUTE:/*9/11/13/15A*/
        {
            eventChannelExecute(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE:/*10/12/14/16/35A*/
        {
            eventChannelExecuteComplete(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_OUTGOING:/*18B*/
        {
            eventChannelOutgoing(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_ORIGINATE:/*19B*/
        {
            eventChannelOriginate(event, uuid);
            break;
        }
    case SWITCH_EVENT_CALL_UPDATE:/*23/29/30B*/
        {
            eventCallUpdate(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_PROGRESS:
        {
            eventChannelProgress(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA:/*26B*/
        {
            eventChannelProgressMedia(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_BRIDGE:/*27A*/
        {
            eventChannelBridge(event, uuid);
            break;
        }
    /*32?*/
    /*case SWITCH_EVENT_RECV_INFO:
        {
            eventRecvInfo(event, uuid);
            break;
        }*/
    case SWITCH_EVENT_CHANNEL_HANGUP:/*36A-33B*/
        {
            eventChannelHangup(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_UNBRIDGE:/*34A*/
        {
            eventChannelUnbridge(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:/*39/43B*/
        {
            eventChannelHangupComplete(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_DESTROY:/*45A-41B*/
        {
            eventChannelDestroy(event, uuid);
            break;
        }
    case SWITCH_EVENT_CUSTOM:/*5A*/
        {
            if (strcmp(event.data()->subclass_name, "sofia::gateway_state") == 0)
            {
                QString state = switch_event_get_header_nil(event.data(), "State");
                QString gw = switch_event_get_header_nil(event.data(), "Gateway");
                QSharedPointer<Account> acc = _accounts.value(gw);
                if (acc.isNull())
                    return;

                if (state == "TRYING") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_TRYING);
                    emit accountStateChange(acc);
                } else if (state == "REGISTER") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_REGISTER);
                    emit accountStateChange(acc);
                } else if (state == "REGED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_REGED);
                    emit accountStateChange(acc);
                } else if (state == "UNREGED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_UNREGED);
                    emit accountStateChange(acc);
                } else if (state == "UNREGISTER") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_UNREGISTER);
                    emit accountStateChange(acc);
                } else if (state =="FAILED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_FAILED);
                    emit accountStateChange(acc);
                } else if (state == "FAIL_WAIT") {
                    acc.data()->setState(FSCOMM_GW_STATE_FAIL_WAIT);
                    emit accountStateChange(acc);
                } else if (state == "EXPIRED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_EXPIRED);
                    emit accountStateChange(acc);
                } else if (state == "NOREG") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_NOREG);
                    emit accountStateChange(acc);
                }
            }
            else if (strcmp(event.data()->subclass_name, "sofia::gateway_add") == 0)
            {
                QString gw = switch_event_get_header_nil(event.data(), "Gateway");
                Account * accPtr = new Account(gw);
                QSharedPointer<Account> acc = QSharedPointer<Account>(accPtr);
                acc.data()->setState(FSCOMM_GW_STATE_NOAVAIL);
                _accounts.insert(gw, acc);
                emit newAccount(acc);
            }
            else if (strcmp(event.data()->subclass_name, "sofia::gateway_delete") == 0)
            {
                QSharedPointer<Account> acc = _accounts.take(switch_event_get_header_nil(event.data(), "Gateway"));
                if (!acc.isNull())
                    emit delAccount(acc);
            }
            else
            {
                //printEventHeaders(event);
            }
            break;
        }
    case SWITCH_EVENT_MODULE_LOAD:
        {
            QString modType = switch_event_get_header_nil(event.data(), "type");
            QString modKey = switch_event_get_header_nil(event.data(), "key");
            emit loadedModule(modType, modKey);
            break;
        }
    default:
        break;
    }
}
示例#5
0
文件: loader.cpp 项目: Blei/clay
ModulePtr preludeModule() {
    static ModulePtr cached;
    if (!cached)
        cached = loadedModule("prelude");
    return cached;
}
示例#6
0
文件: loader.cpp 项目: Blei/clay
ModulePtr operatorsModule() {
    static ModulePtr cached;
    if (!cached)
        cached = loadedModule("__operators__");
    return cached;
}
示例#7
0
文件: loader.cpp 项目: Blei/clay
ModulePtr intrinsicsModule() {
    static ModulePtr cached;
    if (!cached)
        cached = loadedModule("__intrinsics__");
    return cached;
}
示例#8
0
文件: loader.cpp 项目: Blei/clay
ModulePtr primitivesModule() {
    static ModulePtr cached;
    if (!cached)
        cached = loadedModule("__primitives__");
    return cached;
}