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 ff69e44315a147df765e8693faf180bf6d3e6cc7
Author: [email protected] <[email protected]>
AuthorDate: Sun Mar 29 21:56:19 2026 -0600
feat(ego-gen): add IndexedPropertyData to data model
Add the IndexedPropertyData struct and ClassData.IndexedProperties
field to support codegen for Eolian indexed properties. Includes
a test for the template output (currently expected to fail until
the template is added in a follow-up commit).
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
cmd/ego-gen/generator.go | 34 +++++++++++++++++++++++-
cmd/ego-gen/generator_test.go | 61 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/cmd/ego-gen/generator.go b/cmd/ego-gen/generator.go
index 17fa64d..f6df61f 100644
--- a/cmd/ego-gen/generator.go
+++ b/cmd/ego-gen/generator.go
@@ -31,7 +31,8 @@ type ClassData struct {
Interfaces []string
ExtraEOHeaders []string // .eo.h headers from mixin/interface extensions
Constructors []ConstructorData
- PropertyOptions []ConstructorData // With* options for struct-typed settable properties
+ PropertyOptions []ConstructorData // With* options for struct-typed settable properties
+ IndexedProperties []IndexedPropertyData // indexed properties with key params
}
// ConstructorData describes a constructor option for an EFL class. Each entry
@@ -110,6 +111,37 @@ type PropertyData struct {
MultiSetValues []MultiValueData
}
+// IndexedPropertyData describes an EFL indexed property — a property that
+// requires one or more key parameters to access. Each indexed property
+// generates an unexported accessor struct with Get/Set methods.
+type IndexedPropertyData struct {
+ GoAccessorMethod string // e.g. "ColorClass" — the method on the class
+ AccessorTypeName string // e.g. "colorClassProperty" — unexported struct name
+ CGetName string // e.g. "efl_gfx_color_class_get"
+ CSetName string // e.g. "efl_gfx_color_class_set"
+ HasGet bool
+ HasSet bool
+ Keys []ParamData // index parameters
+
+ // Single-value fields (when IsMultiValue is false):
+ GoType string
+ CType string
+ IsEo bool
+ IsStruct bool
+ StructGoType string
+ StructCType string
+ StructGoFields []string
+ StructCFields []string
+ StructCFieldTypes []string
+ StructCMacro string
+ StructCAccessPrefix string
+
+ // Multi-value fields:
+ IsMultiValue bool
+ MultiGetValues []MultiValueData
+ MultiSetValues []MultiValueData
+}
+
// EventData describes a single event on an EFL class.
type EventData struct {
GoName string
diff --git a/cmd/ego-gen/generator_test.go b/cmd/ego-gen/generator_test.go
index e65d44f..5daff44 100644
--- a/cmd/ego-gen/generator_test.go
+++ b/cmd/ego-gen/generator_test.go
@@ -395,6 +395,67 @@ func TestGenerateEnum(t *testing.T) {
}
}
+func TestGenerateClass_IndexedProperty(t *testing.T) {
+ g, outDir := newTestGenerator(t)
+
+ data := ClassData{
+ PackageName: "layout",
+ GoName: "Group",
+ EolianName: "Efl.Layout.Group",
+ CClassName: "EFL_LAYOUT_GROUP_CLASS",
+ CClassGetFunc: "efl_layout_group_class_get",
+ CPrefix: "efl_layout_group",
+ EOHeaderFile: "efl_layout_group.eo.h",
+ IsAbstract: true,
+ IndexedProperties: []IndexedPropertyData{
+ {
+ GoAccessorMethod: "GroupData",
+ AccessorTypeName: "groupDataProperty",
+ CGetName: "efl_layout_group_data_get",
+ CSetName: "",
+ HasGet: true,
+ HasSet: false,
+ Keys: []ParamData{
+ {GoName: "key", GoType: "string", CType: "const char *"},
+ },
+ GoType: "string",
+ CType: "const char *",
+ },
+ },
+ }
+
+ if err := g.GenerateClass(data); err != nil {
+ t.Fatalf("GenerateClass: %v", err)
+ }
+
+ outFile := filepath.Join(outDir, "layout", "group.go")
+ content, err := os.ReadFile(outFile)
+ if err != nil {
+ t.Fatalf("output file not found at %s: %v", outFile, err)
+ }
+
+ src := string(content)
+
+ mustContain := []string{
+ // Accessor struct (unexported).
+ "type groupDataProperty struct",
+ // Accessor method on the class.
+ "func (o *Group) GroupData(key string) groupDataProperty",
+ // Getter method on the accessor.
+ "func (p groupDataProperty) Get() string",
+ // C call with key argument.
+ "efl_layout_group_data_get",
+ // String key conversion.
+ "C.CString(p.key)",
+ }
+
+ for _, want := range mustContain {
+ if !strings.Contains(src, want) {
+ t.Errorf("output missing expected pattern %q\nfile content:\n%s", want, src)
+ }
+ }
+}
+
func TestToSnake(t *testing.T) {
tests := []struct {
input string
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.