mirror of
https://github.com/robertkrimen/otto
synced 2025-10-26 20:28:49 +08:00
Add enumeration for Arguments (argumentsEnumerate)
This commit is contained in:
parent
1b469aefc1
commit
8b16ca18d8
|
|
@ -83,7 +83,7 @@ func init() {
|
||||||
objectHasOwnProperty,
|
objectHasOwnProperty,
|
||||||
argumentsDefineOwnProperty,
|
argumentsDefineOwnProperty,
|
||||||
argumentsDelete,
|
argumentsDelete,
|
||||||
objectEnumerate,
|
argumentsEnumerate,
|
||||||
}
|
}
|
||||||
|
|
||||||
_classGoStruct = &_objectClass{
|
_classGoStruct = &_objectClass{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
package otto
|
package otto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func (runtime *_runtime) newArgumentsObject(indexOfParameterName []string, environment _environment, length int) *_object {
|
func (runtime *_runtime) newArgumentsObject(indexOfParameterName []string, environment _environment, length int) *_object {
|
||||||
self := runtime.newClassObject("Arguments")
|
self := runtime.newClassObject("Arguments")
|
||||||
|
|
||||||
|
|
@ -83,3 +87,15 @@ func argumentsDelete(self *_object, name string, throw bool) bool {
|
||||||
}
|
}
|
||||||
return objectDelete(self, name, throw)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user