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 871fd1fbf21be7e56ff01881f3da81692a6ad2f0
Author: [email protected] <[email protected]>
AuthorDate: Mon Mar 30 15:22:56 2026 -0600

    feat(ego-gen): add iterator.go with build function
    
    Add the iterator.go file that was missed in the previous commit.
    Contains isIteratorReturnType and buildIteratorMethodData functions.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 cmd/ego-gen/iterator.go | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/cmd/ego-gen/iterator.go b/cmd/ego-gen/iterator.go
new file mode 100644
index 0000000..8e31782
--- /dev/null
+++ b/cmd/ego-gen/iterator.go
@@ -0,0 +1,79 @@
+package main
+
+import "fmt"
+
+// isIteratorReturnType reports whether a method's return type is an
+// Eina_Iterator (i.e., the Eolian built-in iterator<T> type).
+func isIteratorReturnType(f *Function) bool {
+	rt := f.ReturnType(FunctionMethod)
+	if rt == nil {
+		return false
+	}
+	return rt.IsIterator()
+}
+
+// buildIteratorMethodData converts an Eolian method that returns iterator<T>
+// into an IteratorMethodData. Returns an error if the inner element type is
+// unsupported (unknown struct, opaque pointer, etc.).
+func buildIteratorMethodData(f *Function) (IteratorMethodData, error) {
+	methodName := f.Name()
+	goName := SnakeToCamel(methodName)
+	cName := f.FullCName(FunctionMethod)
+
+	// Extract input parameters (same as buildMethodData).
+	var params []ParamData
+	for _, p := range f.Parameters() {
+		if p.Direction() != ParamIn {
+			continue
+		}
+		params = append(params, buildParamData(p))
+	}
+
+	// Get the inner element type from iterator<T>.
+	rt := f.ReturnType(FunctionMethod)
+	if rt == nil {
+		return IteratorMethodData{}, fmt.Errorf("method %q has nil return type", methodName)
+	}
+	bt := rt.BaseType()
+	if bt == nil {
+		return IteratorMethodData{}, fmt.Errorf("method %q iterator has no base type", methodName)
+	}
+
+	elemCType := bt.CType()
+	elemGoType := CTypeToGo(elemCType)
+	elemIsEo := bt.IsClass()
+	elemIsString := NeedsStringConversion(elemCType)
+	elemIsStruct := IsKnownStruct(elemCType)
+
+	// Reject unsupported element types: unknown structs and opaque pointers.
+	if !elemIsEo && !elemIsString && !elemIsStruct {
+		if IsStructType(elemCType) {
+			return IteratorMethodData{}, fmt.Errorf("method %q iterator over unknown struct %q", methodName, elemCType)
+		}
+		// Allow scalars and enum typedefs.
+	}
+
+	imd := IteratorMethodData{
+		GoName:       goName,
+		CName:        cName,
+		Params:       params,
+		ElemGoType:   elemGoType,
+		ElemCType:    elemCType,
+		ElemIsEo:     elemIsEo,
+		ElemIsString: elemIsString,
+		ElemIsStruct: elemIsStruct,
+	}
+
+	if elemIsStruct {
+		si := GetStructInfo(elemCType)
+		imd.ElemGoType = si.GoType
+		imd.StructGoType = si.GoType
+		imd.StructCType = si.CType
+		imd.StructGoFields = si.GoFields
+		imd.StructCFields = si.CFields
+		imd.StructCFieldTypes = si.CFieldTypes
+		imd.StructCAccessPrefix = si.CAccessPrefix
+	}
+
+	return imd, nil
+}

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

Reply via email to