From 8b16ca18d816c4a1aad28becefd6b05dca7a4716 Mon Sep 17 00:00:00 2001 From: Robert Krimen Date: Sun, 2 Jun 2013 16:21:49 -0700 Subject: [PATCH] Add enumeration for Arguments (argumentsEnumerate) --- object_class.go | 2 +- type_arguments.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/object_class.go b/object_class.go index d620d6e..3b17339 100644 --- a/object_class.go +++ b/object_class.go @@ -83,7 +83,7 @@ func init() { objectHasOwnProperty, argumentsDefineOwnProperty, argumentsDelete, - objectEnumerate, + argumentsEnumerate, } _classGoStruct = &_objectClass{ diff --git a/type_arguments.go b/type_arguments.go index d34e7eb..f953f48 100644 --- a/type_arguments.go +++ b/type_arguments.go @@ -1,5 +1,9 @@ package otto +import ( + "strconv" +) + func (runtime *_runtime) newArgumentsObject(indexOfParameterName []string, environment _environment, length int) *_object { self := runtime.newClassObject("Arguments") @@ -83,3 +87,15 @@ func argumentsDelete(self *_object, name string, throw bool) bool { } return objectDelete(self, name, throw) } + +func argumentsEnumerate(self *_object, all bool, each func(string)) { + { + object := self.value.(*_argumentsObject) + for index, value := range object.indexOfParameterName { + if value != "" { + each(strconv.FormatInt(int64(index), 10)) + } + } + objectEnumerate(self, all, each) + } +}