Giter VIP home page Giter VIP logo

Comments (5)

vitaminwater avatar vitaminwater commented on June 26, 2024

I'm not so familiar with the new cgo rules, but I could reproduce the crash.
As I understood my tests, the main issue here is that we have to pass **C.char, with the *C.char being created with the make function of go. ie. make([]C.char, 0, len(ws)*4), which obviously creates a pointer to a go pointer, which falls in the restriction of the new cgo pointer rules.

What I think of as a solution is replacing all make([]C.char, 0, len(ws)*4) to C.malloc calls:

vitaminwater@4a627dc

Which is a problem when it comes to putting data in inputAsCChars, because *C.char is not indexable.
So I created a putWcharAt in the C preamble, but it feels bad to make so many cgo calls.

Anyway I can't test it right now, I need a HID device first, this afternoon, or tomorrow.

from cgo.wchar.

vitaminwater avatar vitaminwater commented on June 26, 2024

Still trying to fix it, this fork doesn't crash cgo anymore: https://github.com/vitaminwater/cgo.wchar/

But now the whole iconv thing is broken, output for tests is:


--- FAIL: TestStringConversion (0.00s)
        wchar_test.go:18: Error on conversion. invalid argument
--- FAIL: TestWcharStringConversion (0.00s)
        wchar_test.go:43: Error on conversion. illegal byte sequence
--- FAIL: TestRuneConversion (0.00s)
        wchar_test.go:74: Error on conversion. invalid argument

(last test not displayed hangs forever)

Still lacking knowledge, if you could provide me with some input I might create a good pull request to fix it.

from cgo.wchar.

vitaminwater avatar vitaminwater commented on June 26, 2024

The first test says invalid argument, when I check the desired conversions in convertGoStringToWcharString I see that the tocode parameter for iconv_open is wchar_t, which is not listed when I do a iconv -l, how is that meant to work ?

from cgo.wchar.

vitaminwater avatar vitaminwater commented on June 26, 2024

Looks like the wchar_t type does not exist on OSX: http://www.firstobject.com/wchar_t-string-on-linux-osx-windows.htm

from cgo.wchar.

vitaminwater avatar vitaminwater commented on June 26, 2024

Further readings tend to make me think that cgo.wchar could be avoided thanks to golang's unicode package. Is that right ?

Maybe it would be wise to remove cgo.wchar from go.hid ?

from cgo.wchar.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.