goplus / goplus/llcppg

feat:gen a named func type for anonymous func pointer in struct.

Open
#448 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
33
Forks
11
Avg merge
1h 17m
Merged PRs (30d)
51

Description

typedef struct Hooks {
    void *(*malloc_fn)(size_t sz);
    void (*free_fn)(void *ptr);
} Hooks;
type Hooks struct {
	MallocFn c.Pointer
	FreeFn   c.Pointer
}

Due to the characteristics of LLGo, an anonymous function type cannot be directly declared as a Field Type. Currently, the Field Type for an anonymous function is only mapped to c.Pointer, but this causes the original type information to be lost. To solve this problem, we can additionally declare a function type annotated with llgo:type C and reference it.

 typedef struct Hooks {
     void *(*malloc_fn)(size_t sz);
     void (*free_fn)(void *ptr);
 } Hooks;
// llgo:type C
type LLGO_HOOKS_MallocFn func(c.SizeT) c.Pointer

// llgo:type C
type LLGO_HOOKS_FreeFn func(c.Pointer)

type Hooks struct {
	MallocFn LLGO_HOOKS_MallocFn
	FreeFn   LLGO_HOOKS_FreeFn
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start by locating LLGo's handling of C anonymous function-pointer field types and the existing llgo:type C conversion path. Done means generated bindings use named function types for these fields while preserving their C signatures instead of mapping them only to c.Pointer.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, go
Domain
compilers, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.