LuaJNA не нужен, ибо он куда медленнее
This commit is contained in:
parent
4e01eddfac
commit
da6e5aa694
@ -1,84 +0,0 @@
|
||||
package ru.dbotthepony.kstarbound.lua;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.ptr.LongByReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
@SuppressWarnings({"UnnecessaryModifier", "SpellCheckingInspection", "unused"})
|
||||
public interface LuaJNA extends Library {
|
||||
public int lua_pcallk(@NotNull Pointer luaState, int numArgs, int numResults, int msgh, Pointer ctx, lua_KFunction callback);
|
||||
public int lua_callk(@NotNull Pointer luaState, int numArgs, int numResults, Pointer ctx, lua_KFunction callback);
|
||||
public Pointer lua_atpanic(@NotNull Pointer luaState, @NotNull lua_CFunction fn);
|
||||
|
||||
@Nullable
|
||||
public Pointer luaL_newstate();
|
||||
public void lua_close(@NotNull Pointer luaState);
|
||||
|
||||
// Стандартные библиотеки
|
||||
public void luaopen_base(@NotNull Pointer luaState);
|
||||
public void luaopen_package(@NotNull Pointer luaState);
|
||||
public void luaopen_coroutine(@NotNull Pointer luaState);
|
||||
public void luaopen_table(@NotNull Pointer luaState);
|
||||
public void luaopen_io(@NotNull Pointer luaState);
|
||||
public void luaopen_os(@NotNull Pointer luaState);
|
||||
public void luaopen_string(@NotNull Pointer luaState);
|
||||
public void luaopen_math(@NotNull Pointer luaState);
|
||||
public void luaopen_utf8(@NotNull Pointer luaState);
|
||||
public void luaopen_debug(@NotNull Pointer luaState);
|
||||
|
||||
public Pointer lua_tolstring(@NotNull Pointer luaState, int index, @NotNull LongByReference size);
|
||||
|
||||
public int lua_load(@NotNull Pointer luaState, @NotNull lua_Reader reader, @Nullable Pointer userData, @NotNull String chunkName, @NotNull String mode);
|
||||
|
||||
public interface lua_CFunction extends Callback {
|
||||
int invoke(@NotNull Pointer luaState);
|
||||
}
|
||||
|
||||
public interface lua_Reader extends Callback {
|
||||
@Nullable
|
||||
Pointer readNextChunk(@NotNull Pointer luaState, @Nullable Pointer userData, @NotNull LongByReference sizeToRead);
|
||||
}
|
||||
|
||||
public interface lua_KFunction extends Callback {
|
||||
int invoke(@NotNull Pointer luaState, int status, Pointer context);
|
||||
}
|
||||
|
||||
// Операции над стаком
|
||||
// загрузка значений из Java на стек
|
||||
public void lua_createtable(@NotNull Pointer luaState, int arraySize, int hashSize);
|
||||
public void lua_pushnil(@NotNull Pointer luaState);
|
||||
public void lua_pushnumber(@NotNull Pointer luaState, double value);
|
||||
public void lua_pushinteger(@NotNull Pointer luaState, long value);
|
||||
public void lua_pushboolean(@NotNull Pointer luaState, int value);
|
||||
|
||||
// NUL терминированная строка
|
||||
public void lua_pushstring(@NotNull Pointer luaState, @NotNull String value);
|
||||
|
||||
// двоичная строка
|
||||
@Nullable
|
||||
public Pointer lua_pushlstring(@NotNull Pointer luaState, long stringPointer, long length);
|
||||
|
||||
// Загрузка Lua значений на стек
|
||||
public int lua_getglobal(@NotNull Pointer luaState, @NotNull String name);
|
||||
|
||||
// запись значений со стека
|
||||
public void lua_settable(@NotNull Pointer luaState, int stackIndex);
|
||||
public void lua_setglobal(@NotNull Pointer luaState, @NotNull String name);
|
||||
|
||||
public int lua_checkstack(@NotNull Pointer luaState, int value);
|
||||
public int lua_absindex(@NotNull Pointer luaState, int value);
|
||||
|
||||
/**
|
||||
* Returns the index of the top element in the stack.
|
||||
* Because indices start at 1, this result is equal to the number of elements in the stack; in particular, 0 means an empty stack.
|
||||
*/
|
||||
public int lua_gettop(@NotNull Pointer luaState);
|
||||
|
||||
public static final LuaJNA INSTANCE = Native.load("lua54", LuaJNA.class);
|
||||
}
|
@ -31,7 +31,7 @@ fun main() {
|
||||
if (true) {
|
||||
val lua = LuaState()
|
||||
|
||||
//Thread.sleep(5_000L)
|
||||
Thread.sleep(5_000L)
|
||||
|
||||
lua.load(File("test.lua").readText())
|
||||
//lua.load("print('hello world!', ...)")
|
||||
|
Loading…
Reference in New Issue
Block a user