Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-uing binding issues #22886

Open
trufae opened this issue Nov 17, 2024 · 0 comments
Open

v-uing binding issues #22886

trufae opened this issue Nov 17, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@trufae
Copy link
Contributor

trufae commented Nov 17, 2024

Describe the bug

I'm writing the bindings for the UI-ng library, which is a thin wrapper around mac, windows and gtk graphical widget APIs. It can compile statically and I think it could be a great base for writing native looking apps for those platforms in V.

The problem I'm facing is that the API takes uiControl types as a generic cast (union like) for all the type of widgets, no matter if they are boxes, labels or buttons. So to make this typable in the V side I use an union type using this:

type Control = C.uiButton | C.uiLabel | C.uiBox | Button | Label | Box

Which results in a problem because V uses a HEAP cast when tranalsting this to C instead of just passing the pointer with a bare cast. To keep the V usage as simple as possible I didn't wanted to create a full abstraction of all this, and i think it will be doable if V could express that kind of uses somehow without an unboxing.

Reproduction Steps

The commit ec0951ac4405aaf7152c491ad925accfec5f625b shows the problem because i managed to get it to work by using unsafe voidptr

Expected Behavior

make the api typable iinstead of depending on voidptr

Current Behavior

segfault if i use typed variables

Possible Solution

i'm not as good as i would about the V internals to understand which should be the right behaviour on using an union type with multiple C types which end up 1:1 mapped with V. So i'm filling a ticket here as requested in the Discord to find a better solution before continue working on finishing the bindings.

Additional Information/Context

to install libuing i used r2pm -ci libuing

V version

V 0.4.8 70112d8

Environment details (OS name and version, etc.)

0$ v doctor
V full version: V 0.4.8 584cedd.70112d8
OS: macos, macOS, 15.1, 24B83
Processor: 10 cpus, 64bit, little endian, Apple M1 Max

getwd: /Users/pancake/prg/v-uing
vexe: /Users/pancake/prg/v/v
vexe mtime: 2024-11-13 07:54:10

vroot: OK, value: /Users/pancake/prg/v
VMODULES: OK, value: /Users/pancake/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.5 (Apple Git-154)
Git vroot status: weekly.2024.13-1383-g70112d84 (41 commit(s) behind V master)
.git/config present: true

CC version: Apple clang version 16.0.0 (clang-1600.0.26.3)
emcc version: N/A
thirdparty/tcc status: thirdparty-macos-arm64 713692d4

Huly®: V_0.6-21329

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@trufae trufae added the Bug This tag is applied to issues which reports bugs. label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant