Comments (2)
Oh, there is nothing that can help with guessing the length of the returning array, and as you know there is no Go analog for for (; *shaper_list; shaper_list++)
and never will be one. With plain types that are stored contiguously in memory like []float32
a pack method just creates a slice-view with quite large cap, the length can be later set by user with slicing.
As for this case, that's an array of complex types and they need to be packed one-by-one, and only you know the limit. So, the only option here is to actually copy that snippet generated by cgogen into a separate file and complete it, like that:
// BufferGetGlyphInfos function as declared in harfbuzz/hb-buffer.h:372
func BufferGetGlyphInfos(buffer *Buffer, length *uint32) []GlyphInfo {
cbuffer, _ := (*C.hb_buffer_t)(unsafe.Pointer(buffer)), cgoAllocsUnknown
clength, _ := (*C.uint)(unsafe.Pointer(length)), cgoAllocsUnknown
__ret := C.hb_buffer_get_glyph_infos(cbuffer, clength)
var __v = make([]GlyphInfo, *length)
packSGlyphInfo(__v, __ret)
return __v
}
Voilá! An exercise to the reader: make the original method private, so it won't cause a name collision while still triggering the required helper func generation (like packSGlyphInfo
).
from c-for-go.
This seems to be occuring in other places as well. Here is another example of a nil slice being sent to the packing function (which will effectively return an empty slice as a return value):
// BufferGetGlyphInfos function as declared in harfbuzz/hb-buffer.h:372
func BufferGetGlyphInfos(buffer *Buffer, length *uint32) []GlyphInfo {
cbuffer, _ := (*C.hb_buffer_t)(unsafe.Pointer(buffer)), cgoAllocsUnknown
clength, _ := (*C.uint)(unsafe.Pointer(length)), cgoAllocsUnknown
__ret := C.hb_buffer_get_glyph_infos(cbuffer, clength)
var __v []GlyphInfo
packSGlyphInfo(__v, __ret)
return __v
}
from c-for-go.
Related Issues (20)
- How to handle callback functions HOT 2
- unexpected identifier strtof32 HOT 2
- Best way to handle different include paths for different operating systems? HOT 1
- How to add a Framework? HOT 5
- How to keep int as int? HOT 2
- How to make int8_t from c to int8 in golang? HOT 1
- With the latest commit (c95ebd03aba931e7248a6011f86d822ab878d00c), c-for-go can no longer generate defines HOT 10
- Go Integer overflows translated from large C enum numbers HOT 5
- define pointer to function HOT 1
- type C.struct_ in strut and func HOT 1
- How to handle a function returning a struct as value
- Type translation does not respect systems data model HOT 1
- Verbose argument to print more logs
- Avoid lock / unlock for some function call
- Wiki need to be updated
- panic: unknown type _Float128 HOT 2
- Non int return function pointer not recognized
- Generator uses underlying type of typedef when used as a parameter
- Website down HOT 3
- It would be nice to at least have an example of the YML required in the readme since the website does not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c-for-go.