예제 #1
0
bool DSPServer::crossCompileFactory(MHD_Connection* connection, dsp_server_connection_info* info)
{
    dsp_factory* factory;
    
    if ((factory = info->crossCompileFactory(this, info->fAnswer))) {
        fFactories.insert(factory);
        
        // Return machine_code to client, and keep the new compiled target, so that is it "cached"
    #ifdef LLVM_DSP_FACTORY
        string machine_code = writeDSPFactoryToMachine(dynamic_cast<llvm_dsp_factory*>(factory), info->fTarget);
        dsp_factory* new_factory = readDSPFactoryFromMachine(machine_code, info->fTarget);
    #else
        string machine_code = writeInterpreterDSPFactoryToMachine(dynamic_cast<interpreter_dsp_factory*>(factory));
        dsp_factory* new_factory = readInterpreterDSPFactoryFromMachine(machine_code);
    #endif
        
        if (new_factory) {
            fFactories.insert(new_factory);
            if (fCreateDSPFactoryCb) {
                // Possibly call callback
                fCreateDSPFactoryCb(new_factory, fCreateDSPFactoryCb_arg);
            }
        }
        
        return sendPage(connection, machine_code, MHD_HTTP_OK, "text/html");
    } else {
        return sendPage(connection, info->fAnswer, MHD_HTTP_BAD_REQUEST, "text/html");
    }
}
예제 #2
0
bool DSPServer::crossCompileFactory(MHD_Connection* connection, dsp_server_connection_info* info)
{
    llvm_dsp_factory* factory;
    
    if ((factory = info->crossCompileFactory(this, info->fAnswer))) {
        fFactories.insert(factory);
        
        // Return machine_code to client
        string machine_code = writeDSPFactoryToMachine(factory, info->fTarget);
        //char* machine_code = writeCDSPFactoryToMachine(factory, info->fTarget.c_str());
         
        // And keep the new compiled target, so that is it "cached"
        llvm_dsp_factory* new_factory = readDSPFactoryFromMachine(machine_code, info->fTarget);
        //llvm_dsp_factory* new_factory = readCDSPFactoryFromMachine(machine_code, info->fTarget.c_str());
        
        //freeCDSP(machine_code);  // TODO
        
        if (new_factory) {
            fFactories.insert(new_factory);
            if (fCreateDSPFactoryCb) {
                // Possibly call callback
                fCreateDSPFactoryCb(new_factory, fCreateDSPFactoryCb_arg);
           }
        }
         
        //return sendPage(connection, writeDSPFactoryToMachine(factory, ""), MHD_HTTP_OK, "text/html");
        return sendPage(connection, machine_code, MHD_HTTP_OK, "text/html");
    } else {
        return sendPage(connection, info->fAnswer, MHD_HTTP_BAD_REQUEST, "text/html");
    }
}
예제 #3
0
// Create DSP Factory 
llvm_dsp_factory* dsp_server_connection_info::createFactory(DSPServer* server, string& error) 
{
    // Sort out compilation options
    int argc = fCompilationOptions.size();
    const char* argv[argc];
    for (int i = 0; i < argc; i++) {
        argv[i] = fCompilationOptions[i].c_str();
    }
    
    llvm_dsp_factory* factory = NULL;
     
    if (isopt(argc, argv, "-lm")) {
        // Machine code
        factory = readDSPFactoryFromMachine(fFaustCode, loptions(argv, "-lm", ""));
        //factory = readCDSPFactoryFromMachine(fFaustCode.c_str(), loptions(argv, "-lm", ""));
    } else {
        // DSP code
        string error1;
        factory = createDSPFactoryFromString(fNameApp,
                                            fFaustCode, 
                                            argc, argv, "", 
                                            error, atoi(fOptLevel.c_str()));
    
        /*
        char error1[256];
        factory = createCDSPFactoryFromString(fNameApp.c_str(),
                                            fFaustCode.c_str(),
                                            argc, argv, "",
                                            error1, atoi(fOptLevel.c_str()));
        */
        
        error = error1;
    }
    
    if (factory && server->fCreateDSPFactoryCb) {
        // Possibly call callback
        server->fCreateDSPFactoryCb(factory, server->fCreateDSPFactoryCb_arg);
    } 
   
    return factory;
}
예제 #4
0
// Create DSP Factory 
dsp_factory* dsp_server_connection_info::crossCompileFactory(DSPServer* server, string& error) 
{
    dsp_factory* factory;
  
    // Already in the cache...
#ifdef LLVM_DSP_FACTORY
    if ((factory = getDSPFactoryFromSHAKey(fSHAKey))) {
#else
    if ((factory = getInterpreterDSPFactoryFromSHAKey(fSHAKey))) {
#endif
        return factory;
    } else {
        // Sort out compilation options
        int argc = int(fCompilationOptions.size());
        const char* argv[argc];
        for (int i = 0; i < argc; i++) {
            argv[i] = fCompilationOptions[i].c_str();
        }
   
        string error1;
    #ifdef LLVM_DSP_FACTORY
        factory = createDSPFactoryFromString(fNameApp, fFaustCode, argc, argv, fTarget, error1, atoi(fOptLevel.c_str()));
    #else
        factory = createInterpreterDSPFactoryFromString(fNameApp, fFaustCode, argc, argv, error1);
    #endif
        
        error = error1;                                                    
        if (factory && server->fCreateDSPFactoryCb) {
            // Possibly call callback
            server->fCreateDSPFactoryCb(factory, server->fCreateDSPFactoryCb_arg);
        } 
        return factory;
    }
}

// Create DSP Factory 
dsp_factory* dsp_server_connection_info::createFactory(DSPServer* server, string& error) 
{
    // Sort out compilation options
    int argc = fCompilationOptions.size();
    const char* argv[argc];
    for (int i = 0; i < argc; i++) {
        argv[i] = fCompilationOptions[i].c_str();
    }
    
    dsp_factory* factory = NULL;
     
    if (isopt(argc, argv, "-lm")) {
        // Machine code
    #ifdef LLVM_DSP_FACTORY
        factory = readDSPFactoryFromMachine(fFaustCode, loptions(argv, "-lm", ""));
    #else
        factory = readInterpreterDSPFactoryFromMachine(fFaustCode);
    #endif
    } else {
        // DSP code
        string error1;
        
    #ifdef LLVM_DSP_FACTORY
        factory = createDSPFactoryFromString(fNameApp,fFaustCode, argc, argv, "", error, atoi(fOptLevel.c_str()));
    #else
        factory = createInterpreterDSPFactoryFromString(fNameApp, fFaustCode, argc, argv, error);
    #endif
        error = error1;
    }
    
    if (factory && server->fCreateDSPFactoryCb) {
        // Possibly call callback
        server->fCreateDSPFactoryCb(factory, server->fCreateDSPFactoryCb_arg);
    } 
   
    return factory;
}