MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / compile

Method compile

source/core/StarLua.cpp:447–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447ByteArray LuaEngine::compile(char const* contents, size_t size, char const* name) {
448 lua_checkstack(m_state, 1);
449
450 handleError(m_state, luaL_loadbuffer(m_state, contents, size, name));
451
452 ByteArray compiledScript;
453 lua_Writer writer = [](lua_State*, void const* data, size_t size, void* byteArrayPtr) -> int {
454 ((ByteArray*)byteArrayPtr)->append((char const*)data, size);
455 return 0;
456 };
457 lua_dump(m_state, writer, &compiledScript, false);
458 lua_pop(m_state, 1);
459
460 return compiledScript;
461}
462
463ByteArray LuaEngine::compile(String const& contents, String const& name) {
464 return compile(contents.utf8Ptr(), contents.utf8Size(), name.empty() ? nullptr : name.utf8Ptr());

Callers 3

loadScriptMethod · 0.80
TESTFunction · 0.80
TESTFunction · 0.80

Calls 8

lua_checkstackFunction · 0.85
lua_dumpFunction · 0.85
appendMethod · 0.45
utf8PtrMethod · 0.45
utf8SizeMethod · 0.45
emptyMethod · 0.45
ptrMethod · 0.45
sizeMethod · 0.45

Tested by 2

TESTFunction · 0.64
TESTFunction · 0.64