这是indexloc提供的服务,不要输入任何密码
Skip to content

ffi string not working as expected #653

@KaruroChori

Description

@KaruroChori
//import type from '@txikijs/types';

const sopath = './libcfltk.so';
import FFI from 'tjs:ffi';
const testlib = new FFI.Lib(sopath);

const cfltk ={
    Fl_Window_new: new FFI.CFunction(testlib.symbol('Fl_Window_new'), FFI.types.pointer, [FFI.types.sint,FFI.types.sint,FFI.types.sint,FFI.types.sint,FFI.types.string]),
    Fl_Window_end: new FFI.CFunction(testlib.symbol('Fl_Window_end'), FFI.types.void, [FFI.types.pointer]),
    Fl_Window_show: new FFI.CFunction(testlib.symbol('Fl_Window_show'), FFI.types.void, [FFI.types.pointer]),
    Fl_run: new FFI.CFunction(testlib.symbol('Fl_run'),FFI.types.void, [])
}

const handle = cfltk.Fl_Window_new.call(0, 0, 300, 400, "AAAAA");
cfltk.Fl_Window_end.call(handle);
cfltk.Fl_Window_show.call(handle);
cfltk.Fl_run.call();

The window should show "AAAAA" as title. The same (adapted) code run in Bun results in the expected behaviour.
According to code I have seen in test this should be valid.

I attached the library in case you want to try it youself. It is derived from https://github.com/MoAlyousef/cfltk for linux amd64.
libcfltk.so.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions