示例#1
0
int Start(char* src) {
  if (!InitJerry()) {
    DLOG("InitJerry failed");
    return 1;
  }

  JObject* process = InitModules();

  // FIXME: this should be moved to seperate function
  {
    JObject argv;
    argv.SetProperty("1", JObject(src));
    process->SetProperty("argv", argv);
  }

  if (!StartIoTjs(process)) {
    DLOG("StartIoTJs failed");
    return 1;
  }

  CleanupModules();

  ReleaseJerry();

  return 0;
}
示例#2
0
/**
**  Load a game to file.
**
**  @param filename  File name to be loaded.
*/
void LoadGame(const std::string &filename)
{
	// log will be enabled if found in the save game
	CommandLogDisabled = true;
	SaveGameLoading = true;

	//Wyrmgus start
//	SetDefaultTextColors(FontYellow, FontWhite);
	SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor);
	//Wyrmgus end
	LoadFonts();

	LuaGarbageCollect();
	InitUnitTypes(1);
	LuaLoadFile(filename);
	LuaGarbageCollect();

	PlaceUnits();

	const unsigned long game_cycle = GameCycle;
	const unsigned syncrand = SyncRandSeed;
	const unsigned synchash = SyncHash;

	InitModules();
	LoadModules();

	GameCycle = game_cycle;
	SyncRandSeed = syncrand;
	SyncHash = synchash;
	SelectionChanged();
}
    void LuaLibrary::VInit()
    {
        // Always load the debug module and the module
        // that enables to load further modules in the script

        AddModule("base");
        AddModule("debug");
        AddModule("module_loading");
    
        InitModules();
    }
示例#4
0
void main()
{
    InitModules();

    while(1)
    {
        ReadSensor();
        CalculatePPM();
        DisplayAirQValue( ppm );
        Delay_ms(500);
    }
}
示例#5
0
/**
 * Initialize the hardware, libraries and modules (called by the System thread in systemmod.c)
 */
void OpenPilotInit()
{

	/* Architecture dependant Hardware and
	 * core subsystem initialisation
	 * (see pios_board.c for your arch)
	 * */
	
	PIOS_Board_Init();
	
	/* Initialize modules */
	InitModules();
}
示例#6
0
/**
**  Load a game to file.
**
**  @param filename  File name to be loaded.
*/
void LoadGame(const std::string &filename)
{
	//Wyrmgus start
	CleanPlayers(); //clean players, as they may not have been cleansed after a scenario
	CurrentCustomHero = nullptr; //otherwise the loaded game will have an extra hero for the current custom hero
	//Wyrmgus end
	
	// log will be enabled if found in the save game
	CommandLogDisabled = true;
	SaveGameLoading = true;

	//Wyrmgus start
//	SetDefaultTextColors(FontYellow, FontWhite);
	SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor);
	//Wyrmgus end
	LoadFonts();
	
	//Wyrmgus start
	InitPlayers();
	//Wyrmgus end

	LuaGarbageCollect();
	InitUnitTypes(1);
	//Wyrmgus start
	CalculateItemsToLoad();
	//Wyrmgus end
	LuaLoadFile(filename);
	LuaGarbageCollect();

	PlaceUnits();

	const unsigned long game_cycle = GameCycle;
	const unsigned long long current_total_hours = CDate::CurrentTotalHours;
	const unsigned syncrand = SyncRandSeed;
	const unsigned synchash = SyncHash;

	InitModules();
	LoadModules();

	GameCycle = game_cycle;
	CDate::CurrentTotalHours = current_total_hours;
	SyncRandSeed = syncrand;
	SyncHash = synchash;
	SelectionChanged();
}
示例#7
0
文件: iotjs.cpp 项目: bozzmob/iotjs
static bool StartIoTjs(Environment* env) {
  // Get jerry global object.
  JObject global = JObject::Global();

  // Bind environment to global object.
  global.SetNative((uintptr_t)(env), NULL);

  // Initialize builtin modules.
  JObject* process = InitModules();

  // Call the entry.
  // load and call iotjs.js
  env->GoStateRunningMain();

  RunIoTjs(process);

  // Run event loop.
  env->GoStateRunningLoop();

  bool more;
  do {
    more = uv_run(env->loop(), UV_RUN_ONCE);
    more |= ProcessNextTick();
    if (more == false) {
      more = uv_loop_alive(env->loop());
    }
  } while (more);

  env->GoStateExiting();

  // Emit 'exit' event.
  ProcessEmitExit(0);

  // Release bulitin modules.
  CleanupModules();

  return true;
}
示例#8
0
void SHM_Init ( void )
{
    // check that we do this only once per process
    if(inited)
    {
        MessageBox(0,"SHM_Init was called twice or more!","FUN", MB_OK);
        return;
    }
    inited = true;
    
    
    char clmutexname [256];
    char clsmutexname [256];
    char shmname [256];
    sprintf(shmname,"DFShm-%d",OS_getPID());    
    
    // create a locked server mutex
    char svmutexname [256];
    sprintf(svmutexname,"DFSVMutex-%d",OS_getPID());
    DFSVMutex = CreateMutex( 0, 1, svmutexname);
    if(DFSVMutex == 0)
    {
        MessageBox(0,"Server mutex creation failed. Further communication disabled!","Error", MB_OK);
        errorstate = 1;
        return;
    }
    // the mutex already existed. we don't want to know.
    if(GetLastError() == ERROR_ALREADY_EXISTS)
    {
        MessageBox(0,"Server mutex already existed. Further communication disabled!","Error", MB_OK);
        errorstate = 1;
        return;
    }
    
    // create client and suspend mutexes
    for(int i = 0; i < SHM_MAX_CLIENTS; i++)
    {
        sprintf(clmutexname,"DFCLMutex-%d-%d",OS_getPID(),i);
        sprintf(clsmutexname,"DFCLSuspendMutex-%d-%d",OS_getPID(),i);
        
        DFCLMutex[i] = CreateMutex( 0, 0, clmutexname); // client mutex, not held
        DFCLSuspendMutex[i] = CreateMutex( 0, 1, clsmutexname); // suspend mutexes held on start
        held_DFCLSuspendMutex[i] = 1;
        
        if(DFCLMutex[i] == 0 || DFCLSuspendMutex[i] == 0 || GetLastError() == ERROR_ALREADY_EXISTS)
        {
            MessageBox(0,"Client mutex creation failed. Close all tools before starting DF.","Error", MB_OK);
            errorstate = 1;
            return;
        }
    }

    // create virtual memory mapping
    shmHandle = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,SHM_SIZE,shmname);
    // if can't create or already exists -> nothing happens
    if(GetLastError() == ERROR_ALREADY_EXISTS)
    {
        MessageBox(0,"SHM bridge already in use","Error", MB_OK);
        errorstate = 1;
        return;
    }
    if(!shmHandle)
    {
        MessageBox(0,"Couldn't create SHM bridge","Error", MB_OK);
        errorstate = 1;
        return;
    }
    // attempt to attach the created mapping
    shm = (char *) MapViewOfFile(shmHandle,FILE_MAP_ALL_ACCESS, 0,0, SHM_SIZE);
    if(shm)
    {
        // make sure we don't stall or do crazy stuff
        for(int i = 0; i < SHM_MAX_CLIENTS;i++)
        {
            ((uint32_t *)shm)[i] = CORE_RUNNING;
        }
        // init modules :)
        InitModules();
    }
    else
    {
        MessageBox(0,"Couldn't attach SHM bridge","Error", MB_OK);
        errorstate = 1;
        return;
    }
}
void CPDF_ModuleMgr::Initialize()
{
    InitModules();
    m_FileBufSize = 512;
}