This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository ego.

View the commit online.

commit 13f65ff468b2682e5000f5310a1069a9cda57238
Author: [email protected] <[email protected]>
AuthorDate: Mon Mar 30 14:05:20 2026 -0600

    feat(ego-gen): add unsigned char mapping and isMultiValueCompatible
    
    Map unsigned char to byte in CTypeToGo, and add isMultiValueCompatible
    which accepts strings, enum typedefs, and Eo pointers alongside simple
    scalar types for multi-value property support.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 cmd/ego-gen/generator_test.go | 30 ++++++++++++++++++++++++++++++
 cmd/ego-gen/main.go           | 19 +++++++++++++++++++
 cmd/ego-gen/typemap.go        |  2 +-
 cmd/ego-gen/typemap_test.go   | 14 ++++++++++++++
 4 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/cmd/ego-gen/generator_test.go b/cmd/ego-gen/generator_test.go
index 8c5a741..803bde8 100644
--- a/cmd/ego-gen/generator_test.go
+++ b/cmd/ego-gen/generator_test.go
@@ -591,3 +591,33 @@ func TestBuildIndexedPropertyData_SingleKeyString(t *testing.T) {
 		})
 	}
 }
+
+func TestIsMultiValueCompatible(t *testing.T) {
+	tests := []struct {
+		ctype string
+		want  bool
+	}{
+		{"int", true},
+		{"double", true},
+		{"Eina_Bool", true},
+		{"unsigned char", true},
+		{"const char *", true},
+		{"Eina_Stringshare", true},
+		{"Efl_Gfx_Color_Class_Layer", true},
+		{"Efl_Ui_Win_Urgent_Mode", true},
+		{"Eo *", true},
+		{"Efl_Canvas_Object *", true},
+		{"void *", false},
+		{"Eina_Rect", false},
+		{"Eina_File *", false},
+	}
+
+	for _, tc := range tests {
+		t.Run(tc.ctype, func(t *testing.T) {
+			got := isMultiValueCompatible(tc.ctype)
+			if got != tc.want {
+				t.Errorf("isMultiValueCompatible(%q) = %v, want %v", tc.ctype, got, tc.want)
+			}
+		})
+	}
+}
diff --git a/cmd/ego-gen/main.go b/cmd/ego-gen/main.go
index 79323d1..7044ea7 100644
--- a/cmd/ego-gen/main.go
+++ b/cmd/ego-gen/main.go
@@ -955,6 +955,25 @@ func isSimpleCgoType(ctype string) bool {
 	return false
 }
 
+// isMultiValueCompatible reports whether a C type can appear as a value
+// parameter in a multi-value property. This is a superset of isSimpleCgoType
+// that also accepts strings, enum typedefs, and Eo class pointers.
+func isMultiValueCompatible(ctype string) bool {
+	if isSimpleCgoType(ctype) {
+		return true
+	}
+	if NeedsStringConversion(ctype) {
+		return true
+	}
+	if IsEnumTypedefKey(ctype) {
+		return true
+	}
+	if IsEoType(ctype) {
+		return true
+	}
+	return false
+}
+
 // buildMultiValueData converts a slice of Eolian property value Parameters into
 // a []MultiValueData. Returns (data, true) when all params are simple cgo types,
 // or (nil, false) if any param has an unsupported type (string, pointer, struct).
diff --git a/cmd/ego-gen/typemap.go b/cmd/ego-gen/typemap.go
index 19df9fd..64fd3e4 100644
--- a/cmd/ego-gen/typemap.go
+++ b/cmd/ego-gen/typemap.go
@@ -78,7 +78,7 @@ func CTypeToGo(ctype string) string {
 		return "float32"
 	case "bool", "Eina_Bool":
 		return "bool"
-	case "char":
+	case "char", "unsigned char":
 		return "byte"
 	case "short":
 		return "int16"
diff --git a/cmd/ego-gen/typemap_test.go b/cmd/ego-gen/typemap_test.go
index 9a76688..38fb1c2 100644
--- a/cmd/ego-gen/typemap_test.go
+++ b/cmd/ego-gen/typemap_test.go
@@ -232,6 +232,20 @@ func TestGetStructInfo(t *testing.T) {
 	}
 }
 
+func TestCTypeToGo_UnsignedChar(t *testing.T) {
+	got := CTypeToGo("unsigned char")
+	if got != "byte" {
+		t.Errorf("CTypeToGo(\"unsigned char\") = %q, want \"byte\"", got)
+	}
+}
+
+func TestCTypeToCgo_UnsignedChar(t *testing.T) {
+	got := CTypeToCgo("unsigned char")
+	if got != "uchar" {
+		t.Errorf("CTypeToCgo(\"unsigned char\") = %q, want \"uchar\"", got)
+	}
+}
+
 func TestIsEnumTypedefKey(t *testing.T) {
 	tests := []struct {
 		ctype string

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to