/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/java/li_cdata_cpp_runme.java
24 строки
738 B
Erez Geva
Fixes of STRING/BYTES LENGTH typemaps.
29 фев 2024, 04:09
29 фев 2024, 04:09
1bf59e0
Код
Авторство
О чём код?
import li_cdata_cpp.*; public class li_cdata_cpp_runme { static { try { System.loadLibrary("li_cdata_cpp"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) throws Throwable { byte[] s = "ABC\0abc".getBytes("UTF-8"); SWIGTYPE_p_void m = li_cdata_cpp.malloc(256); li_cdata_cpp.memmove(m, s); byte[] ss = li_cdata_cpp.cdata(m, 7); String ss_string = new String(ss, "UTF-8"); if (!ss_string.equals("ABC\0abc")) throw new RuntimeException("failed got: " + ss_string); } }