| 363 | } |
| 364 | |
| 365 | bool FLuaEnv::LoadBuffer(const char* Buffer, const size_t Size, const char* InName) |
| 366 | { |
| 367 | // TODO: env support |
| 368 | // TODO: return value support |
| 369 | |
| 370 | #if UNLUA_LEGACY_ALLOW_BOM || WITH_EDITOR |
| 371 | if (Size > 3 && Buffer[0] == static_cast<char>(0xEF) && Buffer[1] == static_cast<char>(0xBB) && Buffer[2] == static_cast<char>(0xBF)) |
| 372 | { |
| 373 | #if !UNLUA_LEGACY_ALLOW_BOM |
| 374 | UE_LOG(LogUnLua, Warning, TEXT("Lua chunk with utf-8 BOM:%s"), UTF8_TO_TCHAR(InName)); |
| 375 | #endif |
| 376 | return LoadBuffer(Buffer + 3, Size - 3, InName); |
| 377 | } |
| 378 | #endif |
| 379 | |
| 380 | // loads the buffer as a Lua chunk |
| 381 | const int32 Code = luaL_loadbufferx(L, Buffer, Size, InName, nullptr); |
| 382 | if (Code != LUA_OK) |
| 383 | { |
| 384 | UE_LOG(LogUnLua, Warning, TEXT("Failed to call luaL_loadbufferx, error code: %d"), Code); |
| 385 | ReportLuaCallError(L); // report pcall error |
| 386 | lua_pushnil(L); /* error (message is on top of the stack) */ |
| 387 | lua_insert(L, -2); /* put before error message */ |
| 388 | return false; |
| 389 | } |
| 390 | |
| 391 | return true; |
| 392 | } |
| 393 | |
| 394 | void FLuaEnv::GC() |
| 395 | { |
nothing calls this directly
no test coverage detected