コード例 #1
0
ファイル: LuaRegManLib.cpp プロジェクト: NIT-Warangal/LibSys
static int GetRegs(lua_State * L) {
	if(lua_gettop(L) != 0) {
        luaL_error(L, "bad argument count to 'GetRegs' (0 expected, got %d)", lua_gettop(L));
        lua_settop(L, 0);
        lua_pushnil(L);
        return 1;
    }
    
    lua_newtable(L);
    int t = lua_gettop(L), i = 0;

    RegUser *next = clsRegManager::mPtr->RegListS;

    while(next != NULL) {
        RegUser *curReg = next;
		next = curReg->next;

#if LUA_VERSION_NUM < 503
		lua_pushnumber(L, ++i);
#else
        lua_pushunsigned(L, ++i);
#endif

		PushReg(L, curReg); 
    
        lua_rawset(L, t);
    }

    return 1;
}
コード例 #2
0
ファイル: LuaRegManLib.cpp プロジェクト: NIT-Warangal/LibSys
static int GetRegsByOpStatus(lua_State * L, const bool &bOperator) {
	if(lua_gettop(L) != 0) {
        if(bOperator == true) {
            luaL_error(L, "bad argument count to 'GetOps' (0 expected, got %d)", lua_gettop(L));
        } else {
            luaL_error(L, "bad argument count to 'GetNonOps' (0 expected, got %d)", lua_gettop(L));
        }
        lua_settop(L, 0);
        lua_pushnil(L);
        return 1;
    }
    
    lua_newtable(L);
    int t = lua_gettop(L), i = 0;

    RegUser *next = clsRegManager::mPtr->RegListS;

    while(next != NULL) {
        RegUser *curReg = next;
		next = curReg->next;

        if(clsProfileManager::mPtr->IsProfileAllowed(curReg->ui16Profile, clsProfileManager::HASKEYICON) == bOperator) {
#if LUA_VERSION_NUM < 503
			lua_pushnumber(L, ++i);
#else
            lua_pushunsigned(L, ++i);
#endif
			PushReg(L, curReg);
            lua_rawset(L, t);
        }
    }

    return 1;
}
コード例 #3
0
ファイル: LuaRegManLib.cpp プロジェクト: hjpotter92/PtokaX
static int GetRegsByProfile(lua_State * L) {
	if(lua_gettop(L) != 1) {
        luaL_error(L, "bad argument count to 'GetRegsByProfile' (1 expected, got %d)", lua_gettop(L));
        lua_settop(L, 0);
        lua_pushnil(L);
        return 1;
    }

    if(lua_type(L, 1) != LUA_TNUMBER) {
        luaL_checktype(L, 1, LUA_TNUMBER);
		lua_settop(L, 0);
		lua_pushnil(L);
        return 1;
    }

#if LUA_VERSION_NUM < 503
	uint16_t iProfile = (uint16_t)lua_tonumber(L, 1);
#else
    uint16_t iProfile = (uint16_t)lua_tointeger(L, 1);
#endif

    lua_settop(L, 0);

    lua_newtable(L);
    int t = lua_gettop(L), i = 0;

	RegUser * cur = NULL,
        * next = clsRegManager::mPtr->pRegListS;
        
    while(next != NULL) {
        cur = next;
        next = cur->pNext;
        
		if(cur->ui16Profile == iProfile) {
#if LUA_VERSION_NUM < 503
			lua_pushnumber(L, ++i);
#else
            lua_pushinteger(L, ++i);
#endif
            PushReg(L, cur);
            lua_rawset(L, t);
        }
    }
    
    return 1;
}
コード例 #4
0
ファイル: bench_l.cpp プロジェクト: pkrusche/bsponmpi
double measure_l_localshift() {
	int right, 
		oversample= measure_sync_oversample();
	int junk;

	PushReg(&junk,sizeof(int));
	Sync();
	for (int i=0; i<10;i++) 
		Sync(); /* Warm things up ;-) */
  
 	right = (Pid+1)%(P);
	double time_clockA = bsp_dtime(), time_clockB;
	for (int i=0; i < oversample; i++) {
		HpPut(right,&junk,&junk,0,sizeof(int));
		Sync();  
	}
	time_clockA = bsp_dtime();
	Fold( &time_clockA,&time_clockB,sizeof(double), 
  		  BSP_OPFUN dbl_min);
 
	PopReg(&junk);
	return (time_clockB / oversample);
}
コード例 #5
0
ファイル: bench_l.cpp プロジェクト: pkrusche/bsponmpi
double measure_l_alltoall() 
{
	int oversample= measure_sync_oversample();
	int junk[P];

	PushReg(junk,sizeof(int)*P);
	Sync();
	for (int i=0; i<10;i++) 
		Sync(); /* Warm things up ;-) */
  
	double time_clockA = bsp_dtime(), time_clockB;
	for (int i=0; i < oversample; i++) {
		for(int j= 0; j < P; ++j)
			HpPut(j,&junk[j],&junk, j*sizeof(int), sizeof(int));
		Sync(); 
	}
	time_clockA = bsp_dtime();
	Fold( &time_clockA,&time_clockB,sizeof(double), 
  		  BSP_OPFUN dbl_min);
 
	PopReg(junk);
	return (time_clockB / oversample);
}
コード例 #6
0
ファイル: LuaRegManLib.cpp プロジェクト: NIT-Warangal/LibSys
static int GetReg(lua_State * L) {
	if(lua_gettop(L) != 1) {
        luaL_error(L, "bad argument count to 'GetReg' (1 expected, got %d)", lua_gettop(L));
        lua_settop(L, 0);
        lua_pushnil(L);
        return 1;
    }

    if(lua_type(L, 1) != LUA_TSTRING) {
        luaL_checktype(L, 1, LUA_TSTRING);
		lua_settop(L, 0);
		lua_pushnil(L);
        return 1;
    }

    size_t szLen;
    char * sNick = (char *)lua_tolstring(L, 1, &szLen);

    if(szLen == 0) {
		lua_settop(L, 0);
		lua_pushnil(L);
        return 1;
    }

    RegUser * r = clsRegManager::mPtr->Find(sNick, szLen);

    lua_settop(L, 0);

    if(r == NULL) {
		lua_pushnil(L);
        return 1;
    }

    PushReg(L, r);

    return 1;
}