~evantj/hare-raylib

9ac6696b1ef4ce9a4e9a10887197d6b86148d17c — Evan Johnston 1 year, 10 months ago 98ca63f
represent c arrays as *[*]type instead of *type
2 files changed, 30 insertions(+), 26 deletions(-)

M hare-raylib.py
M raylib/raylib.ha
M hare-raylib.py => hare-raylib.py +7 -3
@@ 39,7 39,7 @@ def name(value):
def is_string(ctype):
    return ctype.endswith("char *") and "unsigned" not in ctype

def ctype_to_hare(ctype, unsigned = False, wrapping = False):
def ctype_to_hare(ctype, unsigned = False, wrapping = False, pointer_array = False):
    if ctype.startswith('const '):
        return 'const ' + ctype_to_hare(ctype[6:], unsigned = unsigned, wrapping = wrapping)
    if wrapping and is_string(ctype):


@@ 51,7 51,11 @@ def ctype_to_hare(ctype, unsigned = False, wrapping = False):
    if ctype[-1] == ']':
        return ctype[ctype.index('['):] + ctype_to_hare(ctype[:ctype.index('[')], unsigned = unsigned)
    if ctype[-1] == '*':
        return ctype[ctype.index('*'):] + ctype_to_hare(ctype[:ctype.index('*')].strip(), unsigned = unsigned)
        base = ctype_to_hare(ctype[:ctype.index('*')].strip(), unsigned = unsigned)
        modifier = ctype[ctype.index('*'):]
        if pointer_array:
            modifier = modifier.replace('*', '*[*]')
        return modifier + base
    if ctype in types:
        if type(types[ctype]) is str:
            return types[ctype]


@@ 98,7 102,7 @@ def structs(structs):
            print(document(field, indent = True), end = '')
            print("\t%s: %s," % (
                name(field),
                ctype_to_hare(field["type"])))
                ctype_to_hare(field["type"], pointer_array = True)))
        print("};\n")

def aliases(aliases):

M raylib/raylib.ha => raylib/raylib.ha +23 -23
@@ 193,7 193,7 @@ export type Rectangle = struct {
// Image, pixel data stored in CPU memory (RAM)
export type Image = struct {
	// Image raw data
	data: *void,
	data: *[*]void,
	// Image base width
	width: int,
	// Image base height


@@ 269,9 269,9 @@ export type Font = struct {
	// Texture atlas containing the glyphs
	texture: Texture2D,
	// Rectangles in texture for the glyphs
	recs: *Rectangle,
	recs: *[*]Rectangle,
	// Glyphs info data
	glyphs: *GlyphInfo,
	glyphs: *[*]GlyphInfo,
};

// Camera, defines position/orientation in 3d space


@@ 307,27 307,27 @@ export type Mesh = struct {
	// Number of triangles stored (indexed or not)
	triangleCount: int,
	// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
	vertices: *f32,
	vertices: *[*]f32,
	// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
	texcoords: *f32,
	texcoords: *[*]f32,
	// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
	texcoords2: *f32,
	texcoords2: *[*]f32,
	// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
	normals: *f32,
	normals: *[*]f32,
	// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
	tangents: *f32,
	tangents: *[*]f32,
	// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
	colors: *char,
	// Vertex indices (in case vertex data comes indexed)
	indices: *u16,
	// Animated vertex positions (after bones transformations)
	animVertices: *f32,
	animVertices: *[*]f32,
	// Animated normals (after bones transformations)
	animNormals: *f32,
	animNormals: *[*]f32,
	// Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning)
	boneIds: *char,
	// Vertex bone weight, up to 4 bones influence by vertex (skinning)
	boneWeights: *f32,
	boneWeights: *[*]f32,
	// OpenGL Vertex Array Object id
	vaoId: uint,
	// OpenGL Vertex Buffer Objects id (default vertex data)


@@ 339,7 339,7 @@ export type Shader = struct {
	// Shader program id
	id: uint,
	// Shader locations array (RL_MAX_SHADER_LOCATIONS)
	locs: *int,
	locs: *[*]int,
};

// MaterialMap


@@ 357,7 357,7 @@ export type Material = struct {
	// Material shader
	shader: Shader,
	// Material maps array (MAX_MATERIAL_MAPS)
	maps: *MaterialMap,
	maps: *[*]MaterialMap,
	// Material generic parameters (if required)
	params: [4]f32,
};


@@ 389,17 389,17 @@ export type Model = struct {
	// Number of materials
	materialCount: int,
	// Meshes array
	meshes: *Mesh,
	meshes: *[*]Mesh,
	// Materials array
	materials: *Material,
	materials: *[*]Material,
	// Mesh material number
	meshMaterial: *int,
	meshMaterial: *[*]int,
	// Number of bones
	boneCount: int,
	// Bones information (skeleton)
	bones: *BoneInfo,
	bones: *[*]BoneInfo,
	// Bones base transformation (pose)
	bindPose: *Transform,
	bindPose: *[*]Transform,
};

// ModelAnimation


@@ 409,9 409,9 @@ export type ModelAnimation = struct {
	// Number of animation frames
	frameCount: int,
	// Bones information (skeleton)
	bones: *BoneInfo,
	bones: *[*]BoneInfo,
	// Poses array by frame
	framePoses: **Transform,
	framePoses: *[*]*[*]Transform,
};

// Ray, ray for raycasting


@@ 453,13 453,13 @@ export type Wave = struct {
	// Number of channels (1-mono, 2-stereo, ...)
	channels: uint,
	// Buffer data pointer
	data: *void,
	data: *[*]void,
};

// AudioStream, custom audio stream
export type AudioStream = struct {
	// Pointer to internal data used by the audio system
	buffer: *rAudioBuffer,
	buffer: *[*]rAudioBuffer,
	// Frequency (samples per second)
	sampleRate: uint,
	// Bit depth (bits per sample): 8, 16, 32 (24 not supported)


@@ 487,7 487,7 @@ export type Music = struct {
	// Type of music context (audio filetype)
	ctxType: int,
	// Audio context data, depends on type
	ctxData: *void,
	ctxData: *[*]void,
};

// VrDeviceInfo, Head-Mounted-Display device parameters