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); }
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); }
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); }
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); }
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); }
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); }
/* 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); }
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; }
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(); }