From 7c8dd5f50153b938f3af024f8f0985e9abd835be Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 1 Sep 2026 21:08:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(fltk):=20gen=5Fffi=20=E6=97=A0=E5=90=8D=20C?= =?UTF-8?q?=20=E7=B1=BB=E5=9E=8B=E5=8F=82=E6=95=B0=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=88Fl=5Fcolor=5Faverage=20=E5=8F=82=E6=95=B0=E5=90=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=EF=BC=89+=20ViperFLProject=20=E8=A1=A5?= =?UTF-8?q?=E9=BD=90=20FLTK=20Windows=20=E7=B3=BB=E7=BB=9F=E5=BA=93?= =?UTF-8?q?=EF=BC=88gdiplus/advapi32/shell32/ws2=5F32/user32/winspool?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ViperFLProject/project.vpj | 8 +++++++- includes/fltk/_cfl.vp | 2 +- includes/fltk/_cfl_draw.vp | 2 +- includes/fltk/_enums.vp | 14 -------------- includes/fltk/gen_ffi.py | 11 ++++++++++- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ViperFLProject/project.vpj b/ViperFLProject/project.vpj index b487de1..0d45763 100644 --- a/ViperFLProject/project.vpj +++ b/ViperFLProject/project.vpj @@ -24,7 +24,13 @@ "-lole32", "-luuid", "-lwinmm", - "-lgdi32" + "-lgdi32", + "-lgdiplus", + "-ladvapi32", + "-lshell32", + "-lws2_32", + "-luser32", + "-lwinspool" ], "static_libs": [ "../includes/fltk/cfltk/build/libcfltk2.a", diff --git a/includes/fltk/_cfl.vp b/includes/fltk/_cfl.vp index e9e4a2f..ec2afcc 100644 --- a/includes/fltk/_cfl.vp +++ b/includes/fltk/_cfl.vp @@ -159,7 +159,7 @@ extern def Fl_darker(c: t.CUInt32T) -> t.CUInt32T extern def Fl_set_box_type_cb(a0: int, cb1: bytes, a2: int, a3: int, a4: int, a5: int) extern def Fl_draw_box_active() -> int extern def Fl_gray_ramp(i: int) -> t.CUInt32T -extern def Fl_color_average(int_: bytes, int_: bytes, f: t.CFloat) -> t.CUInt32T +extern def Fl_color_average(a0: t.CUInt32T, a1: t.CUInt32T, f: t.CFloat) -> t.CUInt32T extern def Fl_contrast(c1: t.CUInt32T, c2: t.CUInt32T) -> t.CUInt32T extern def Fl_rgb_color(r: t.CUInt8T, g: t.CUInt8T, b: t.CUInt8T) -> t.CUInt32T extern def Fl_rgb_color_grayscale(g: t.CUInt8T) -> t.CUInt32T diff --git a/includes/fltk/_cfl_draw.vp b/includes/fltk/_cfl_draw.vp index a146176..cb2f6bc 100644 --- a/includes/fltk/_cfl_draw.vp +++ b/includes/fltk/_cfl_draw.vp @@ -94,7 +94,7 @@ extern def Fl_measure(str_: str, x: bytes, y: bytes, draw_symbols: int) extern def Fl_draw5(str_: str, x: int, y: int, w: int, h: int, align: int, img: bytes, draw_symbols: int) extern def Fl_frame(s: str, x: int, y: int, w: int, h: int) extern def Fl_frame2(s: str, x: int, y: int, w: int, h: int) -extern def Fl_draw_box(box_type: int, x: int, y: int, w: int, h: int, int_: bytes) +extern def Fl_draw_box(box_type: int, x: int, y: int, w: int, h: int, a5: t.CUInt32T) extern def Fl_draw_image(buf: bytes, X: int, Y: int, W: int, H: int, D: int, L: int) extern def Fl_draw_image_mono(buf: bytes, X: int, Y: int, W: int, H: int, D: int, L: int) extern def Fl_can_do_alpha_blending() -> t.CChar diff --git a/includes/fltk/_enums.vp b/includes/fltk/_enums.vp index 69aa21f..1eea21b 100644 --- a/includes/fltk/_enums.vp +++ b/includes/fltk/_enums.vp @@ -445,17 +445,3 @@ Fl_Table_RESIZE_COL_LEFT: t.CInt = 1 Fl_Table_RESIZE_COL_RIGHT: t.CInt = 2 Fl_Table_RESIZE_ROW_ABOVE: t.CInt = 3 Fl_Table_RESIZE_ROW_BELOW: t.CInt = 4 - -# ---- Fl_Native_File_Chooser 类型/选项(FLTK Fl_Native_File_Chooser.H,与 -# Fl_FileDialogType_*/Fl_FileDialogOptions_* 同值,按 FLTK 原名提供)---- -Fl_Native_File_Chooser_BROWSE_FILE: t.CInt = 0 -Fl_Native_File_Chooser_BROWSE_DIRECTORY: t.CInt = 1 -Fl_Native_File_Chooser_BROWSE_MULTI_FILE: t.CInt = 2 -Fl_Native_File_Chooser_BROWSE_MULTI_DIRECTORY: t.CInt = 3 -Fl_Native_File_Chooser_BROWSE_SAVE_FILE: t.CInt = 4 -Fl_Native_File_Chooser_BROWSE_SAVE_DIRECTORY: t.CInt = 5 -Fl_Native_File_Chooser_NO_OPTIONS: t.CInt = 0 -Fl_Native_File_Chooser_SAVEAS_CONFIRM: t.CInt = 1 -Fl_Native_File_Chooser_NEW_FOLDER: t.CInt = 2 -Fl_Native_File_Chooser_PREVIEW: t.CInt = 4 -Fl_Native_File_Chooser_USE_FILTER_EXT: t.CInt = 8 diff --git a/includes/fltk/gen_ffi.py b/includes/fltk/gen_ffi.py index 9c2b3ca..432e3d9 100644 --- a/includes/fltk/gen_ffi.py +++ b/includes/fltk/gen_ffi.py @@ -40,6 +40,13 @@ _KEYWORDS = { "int", "str", "float", "bool", "len", } +# C 类型关键字:作无名参数末尾单词时属于类型的一部分而非参数名 +# (`unsigned int` → 末尾 int 不是参数名;`Fl_color_average(unsigned int, ...)`)。 +_C_TYPE_WORDS = { + "int", "char", "short", "long", "unsigned", "signed", "float", "double", + "void", "size_t", "uintptr_t", +} + def map_type(t: str) -> str | None: """返回 Viper 注解类型;void 返回 None。""" @@ -129,7 +136,9 @@ def split_args(args: str) -> list[tuple[str, str]]: if m: typ = p[:m.start()].strip() nm = m.group(1) - if not typ: # 纯类型参数(如 `int`、`Fl_Widget *` 无名) + # 纯类型(无名)参数:无类型部分(`int`)或末尾单词本身是 C 类型 + # 关键字(`unsigned int` → 末尾 int 是类型的一部分,非参数名)。 + if not typ or nm in _C_TYPE_WORDS: typ, nm = p, "a%d" % len(out) if nm in _KEYWORDS: nm = nm + "_"