LuaLS / LuaLS/lua-language-server

Standard way to annotate ffi.cdef

Đang mở
#2,154 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

question
Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I have some ffi that looks like this

---@type ffilib
Connector.ffi = package.preload["ffi"]()
Connector.ffi.cdef [[
	 void curl_free_pointer(const char* string);
   const char* curl_get(const char* query);
   const char* curl_patch(const char* query, const char* body, bool return_patched);
   const char* curl_post(const char* query, const char* body, bool merge_duplicates, bool ignore_duplicates, bool return_post);
]]

I am able to get nice typing on the Connector.ffi part through ---@type ffilib, but am not sure if there is a nice way to annotate the returns from these functions. A could wrap the c functions to lua functions and then annotate the lua functions, but I wasn't sure if there was a nice way to do it directly.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Start by reviewing how ffi.cdef and the ffilib type are currently handled, then trace whether return types can be represented directly in that path. Done means there is a documented annotation approach for these C functions, with coverage showing that their return types are recognized without Lua wrapper functions.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
lua
Lĩnh vực
devtools
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.