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 5d8b0a9fa2824933118035f4421c67782d32e121
Author: [email protected] <[email protected]>
AuthorDate: Mon Mar 30 15:21:45 2026 -0600
feat(ego-gen): add IteratorMethodData and build function
Add IteratorMethodData struct, ClassData.IteratorMethods field,
and buildIteratorMethodData that detects iterator<T> return types
and extracts the inner element type from Eolian.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
cmd/ego-gen/generator.go | 21 ++++++++++++++++
cmd/ego-gen/generator_test.go | 58 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/cmd/ego-gen/generator.go b/cmd/ego-gen/generator.go
index bc86c77..3e12258 100644
--- a/cmd/ego-gen/generator.go
+++ b/cmd/ego-gen/generator.go
@@ -33,6 +33,8 @@ type ClassData struct {
Constructors []ConstructorData
PropertyOptions []ConstructorData // With* options for struct-typed settable properties
IndexedProperties []IndexedPropertyData // indexed properties with key params
+ IteratorMethods []IteratorMethodData // methods returning Eina_Iterator
+ HasIterators bool // true if IteratorMethods is non-empty (controls import)
}
// ConstructorData describes a constructor option for an EFL class. Each entry
@@ -143,6 +145,25 @@ type IndexedPropertyData struct {
MultiSetValues []MultiValueData
}
+// IteratorMethodData describes an EFL method that returns an Eina_Iterator.
+// The generated Go method returns iter.Seq[T] wrapping the C iterator lifecycle.
+type IteratorMethodData struct {
+ GoName string // e.g. "ChildrenIteratorNew"
+ CName string // e.g. "efl_children_iterator_new"
+ Params []ParamData // method input parameters (may be empty)
+ ElemGoType string // e.g. "unsafe.Pointer", "string", "uint", "efl.Rect"
+ ElemCType string // e.g. "Eo *", "const char *", "unsigned int", "Eina_Rect"
+ ElemIsEo bool // true for Eo class pointers
+ ElemIsString bool // true for string types
+ ElemIsStruct bool // true for known struct types
+ StructGoType string // e.g. "efl.Rect" (only when ElemIsStruct)
+ StructCType string // e.g. "Eina_Rect"
+ StructGoFields []string
+ StructCFields []string
+ StructCFieldTypes []string
+ StructCAccessPrefix string
+}
+
// 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 88dbfd6..05c89a7 100644
--- a/cmd/ego-gen/generator_test.go
+++ b/cmd/ego-gen/generator_test.go
@@ -745,3 +745,61 @@ func TestGenerateClass_MultiValueMixedTypes(t *testing.T) {
}
}
}
+
+func TestGenerateClass_IteratorMethod(t *testing.T) {
+ g, outDir := newTestGenerator(t)
+
+ data := ClassData{
+ PackageName: "eo",
+ GoName: "Object",
+ EolianName: "Efl.Object",
+ CClassName: "EFL_OBJECT_CLASS",
+ CClassGetFunc: "efl_object_class_get",
+ CPrefix: "efl_object",
+ EOHeaderFile: "efl_object.eo.h",
+ IsAbstract: true,
+ HasIterators: true,
+ IteratorMethods: []IteratorMethodData{
+ {
+ GoName: "ChildrenIteratorNew",
+ CName: "efl_children_iterator_new",
+ Params: nil,
+ ElemGoType: "unsafe.Pointer",
+ ElemCType: "Eo *",
+ ElemIsEo: true,
+ },
+ },
+ }
+
+ if err := g.GenerateClass(data); err != nil {
+ t.Fatalf("GenerateClass: %v", err)
+ }
+
+ outFile := filepath.Join(outDir, "eo", "object.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{
+ `"iter"`,
+ "_ego_iter_next",
+ "eina_iterator_next",
+ "_ego_iter_free",
+ "eina_iterator_free",
+ "func (o *Object) ChildrenIteratorNew() iter.Seq[unsafe.Pointer]",
+ "return func(yield func(unsafe.Pointer) bool)",
+ "efl_children_iterator_new",
+ "C._ego_iter_next",
+ "C._ego_iter_free",
+ "if !yield(",
+ }
+
+ for _, want := range mustContain {
+ if !strings.Contains(src, want) {
+ t.Errorf("output missing expected pattern %q\nfile content:\n%s", want, src)
+ }
+ }
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.