コード例 #1
0
ファイル: libs_package.cpp プロジェクト: actboy168/YDWE
	int searcher_dll(lua_State *L) {
		size_t      size = 0;
		const char *name = luaL_checklstring(L, 1, &size);
		const char *filename = findfile(L, name, "cpath", false);
		if (filename == NULL) return 1;
		return checkload(L, (loadfunc(L, filename, name) == 0), filename);
	}	
コード例 #2
0
ファイル: loadlib.c プロジェクト: AMDmi3/widelands
static int searcher_Lua (lua_State *L) {
  const char *filename;
  const char *name = luaL_checkstring(L, 1);
  filename = findfile(L, name, "path", LUA_LSUBSEP);
  if (filename == NULL) return 1;  /* module not found in this path */
  return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename);
}
コード例 #3
0
ファイル: loadlib.c プロジェクト: lvshaco/ejoy2d
static int searcher_Pack (lua_State *L) {
    const char *name = luaL_checkstring(L,1); 
    lua_getfield(L, lua_upvalueindex(1), "packpath");
    const char *ppath = lua_tostring(L, -1);
    if (ppath == NULL) {
        lua_pop(L,1);
        return 0;
    }
    lua_getfield(L, lua_upvalueindex(1), "path");
    const char *lpath = lua_tostring(L, -1);
    if (lpath == NULL) {
        lua_pop(L,2);
        return 0;
    }
    lua_pop(L,2);
    char *buf;
    size_t sz;
    char *p = loadpack(L, ppath, lpath, name, &buf, &sz);
    if (p == NULL)
        return 1;
    const char *fname = lua_tostring(L, -1);
    int status = luaL_loadbuffer(L, buf, sz, fname);
    free(p);
    return checkload(L, status==LUA_OK, fname);
}
コード例 #4
0
ファイル: uloadlib52.c プロジェクト: CyberShadow/FAR
static int searcher_C(lua_State *L)
{
	const char *name = luaL_checkstring(L, 1);
	const wchar_t *filename = findfile(L, name, "cpath", LUA_CSUBSEP);

	if(filename == NULL) return 1;   /* module not found in this path */

	return checkload(L, (loadfunc(L, filename, name) == 0), filename);
}
コード例 #5
0
ファイル: libs_package.cpp プロジェクト: l327253678/YDWE
	int searcher_storm(lua_State *L) {
		const char *filename;
		size_t      size = 0;
		const char *name = luaL_checklstring(L, 1, &size);
		filename = findfile(L, name, "path", LUA_LSUBSEP, false);
		if (filename == NULL) return 1;  /* module not found in this path */
		const char* buffer = nullptr;
		storm_dll& s = storm_s::instance();
		size = 0;
		s.load_file(filename, (const void**)&buffer, &size);
		int stat = (luaL_loadbuffer(L, buffer, size, name) == LUA_OK);
		s.unload_file(buffer);
		return checkload(L, stat, filename);
	}
コード例 #6
0
ファイル: libs_package.cpp プロジェクト: l327253678/YDWE
	int searcher_file(lua_State *L) {
		const char *filename;
		size_t      size = 0;
		const char *name = luaL_checklstring(L, 1, &size);
		filename = findfile(L, name, "path", LUA_LSUBSEP, true);
		if (filename == NULL) return 1;  /* module not found in this path */
		int stat = 0;
		try {
			std::wstring wfilename = base::u2w(filename);
			std::string buffer = base::file::read_stream(wfilename).read<std::string>();
			stat = (luaL_loadbuffer(L, buffer.c_str(), buffer.size(), name) == LUA_OK);
		}
		catch (...) {}
		return checkload(L, stat, filename);
	}
コード例 #7
0
ファイル: loadlib.c プロジェクト: chenniaoc/GeminiSDK
/* files with different suffixes based on current device, i.e., @2x, @ipad */
static int searcher_Lua (lua_State *L) {
  const char *filename;
    const char *name = luaL_checkstring(L, 1);
    for (int i=0; i<gem_suffix_count; i++) {
        const char *suffix = gem_suffixes[i];
        char *tmp_name = (char *)malloc(strlen(name) + strlen(suffix) + 1);
        strcpy(tmp_name, name);
        strcpy(tmp_name + strlen(name), suffix);
        filename = findfile(L, tmp_name, "path", LUA_LSUBSEP);
        if (filename != NULL) {
            printf("Lua: Using file %s", filename);
            break;
        }
    }
  
  if (filename == NULL) return 1;  /* module not found in this path */
  return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename);
}
コード例 #8
0
ファイル: loadlib.c プロジェクト: littlesome/xLua
static int searcher_Croot (lua_State *L) {
  const char *filename;
  const char *name = luaL_checkstring(L, 1);
  const char *p = strchr(name, '.');
  int stat;
  if (p == NULL) return 0;  /* is root */
  lua_pushlstring(L, name, p - name);
  filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP);
  if (filename == NULL) return 1;  /* root not found */
  if ((stat = loadfunc(L, filename, name)) != 0) {
    if (stat != ERRFUNC)
      return checkload(L, 0, filename);  /* real error */
    else {  /* open function not found */
      lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename);
      return 1;
    }
  }
  lua_pushstring(L, filename);  /* will be 2nd argument to module */
  return 2;
}
コード例 #9
0
ファイル: images.cpp プロジェクト: DZB-Team/tdesktop
const QPixmap &Image::pixBlurred(int32 w, int32 h) const {
	restore();
	checkload();

	if (w <= 0 || !width() || !height()) {
		w = width() * cIntRetinaFactor();
	} else if (cRetina()) {
		w *= cIntRetinaFactor();
		h *= cIntRetinaFactor();
	}
	uint64 k = 0x8000000000000000L | (uint64(w) << 32) | uint64(h);
	Sizes::const_iterator i = _sizesCache.constFind(k);
	if (i == _sizesCache.cend()) {
		QPixmap p(pixBlurredNoCache(w, h));
		if (cRetina()) p.setDevicePixelRatio(cRetinaFactor());
		i = _sizesCache.insert(k, p);
		if (!p.isNull()) {
			globalAquiredSize += int64(p.width()) * p.height() * 4;
		}
	}
	return i.value();
}