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

[wip] gogensig #813

Open
wants to merge 122 commits into
base: main
Choose a base branch
from
Open

[wip] gogensig #813

wants to merge 122 commits into from

Conversation

luoliwoshang
Copy link
Contributor

@luoliwoshang luoliwoshang commented Sep 30, 2024

child pr list in this pr list

  • basic type
  • pointer
  • array
    • pointer in func param
  • funcdecl
    • variadic
  • struct
    • Forward Declaration
  • union
  • typedef
    • typedef anonymous enum
  • enum
    • anonymous
  • use the llcppg.cfg 's libs as the LLGoPackage link const
  • In the current project, we don't care about the absolute paths of header files. For an individual header file, its include path serves as a unique identifier and is used to generate its name (e.g., sys/dirent.h -> sys_dirent.go, sys/_pthread/_pthread_types.h -> sys__pthread__pthread_types.go)._types.h -> X_types.go
  • remove prefix only in llcppg'package 's include file
  • 更统一的类型名生成处理逻辑

文件依赖处理

llcppg.cfg 增加一个新的配置项
deps 用于指明当前转换工程依赖了哪些已经转换完毕的llgo c package

{
    "deps":[
        "github.com/goplus/llgo/chore/gogensig/convert/testdata/stdint"
    ]
}

读取这个对于一个llcppg的处理完毕的工程,配置项中对应的标准路径,也指明当前转换完成的包是来自于哪几个标准搜索路径,比如我需要引用一个stdint这个包的时候,之前这个stdint是转换来自对应的头文件,那么在当前引用了这个stdint包的时候,根据其include就可以直接跳过那些头文件

{
    "include":[
        "sys/_types/_int8_t.h",
        "sys/_types/_int16_t.h",
        "sys/_types/_int32_t.h",
        "sys/_types/_int64_t.h",
        "sys/_types/_u_int8_t.h",
        "sys/_types/_u_int16_t.h",
        "sys/_types/_u_int32_t.h",
        "sys/_types/_u_int64_t.h"
    ]
}

对于转换完成的包新增一个配置项 llcppg.pub
用于存放当前包中完成映射的符号名,左边为C中的符号名,右边为转换完毕后Go中的名称,对于引用该包的转换工程一旦访问到这些名称,就可以直接从该包中获取对应的类型

int8_t Int8_t
uint8_t Uint8_t
u_int8_t U_int8_t
int16_t Int16_t
uint16_t Uint16_t
u_int16_t U_int16_t
u_int64_t U_int64_t

在文件的依赖处理中,则由头文件标准引用路径作为key,具体生成逻辑参考 #853

  • llcppg.pub generate

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 99.18939% with 11 lines in your changes missing coverage. Please review.

Project coverage is 97.91%. Comparing base (cfdbb86) to head (189ea7b).

Files with missing lines Patch % Lines
chore/gogensig/convert/package.go 97.96% 4 Missing and 2 partials ⚠️
chore/gogensig/convert/type.go 97.83% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #813      +/-   ##
==========================================
+ Coverage   97.62%   97.91%   +0.29%     
==========================================
  Files          20       31      +11     
  Lines        5971     7328    +1357     
==========================================
+ Hits         5829     7175    +1346     
- Misses        120      128       +8     
- Partials       22       25       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@luoliwoshang luoliwoshang force-pushed the gogensig/update branch 2 times, most recently from f754570 to 980d1cc Compare October 16, 2024 10:47
@luoliwoshang luoliwoshang force-pushed the gogensig/update branch 2 times, most recently from a3a8371 to 6bb3d81 Compare October 24, 2024 01:51
@luoliwoshang luoliwoshang force-pushed the gogensig/update branch 4 times, most recently from 7ed439f to 09b765e Compare November 7, 2024 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants