from hippy.builtin_klass import k_Iterator
from hippy.builtin import ThisUnwrapper, Optional, wrap_method
from hippy.klass import def_class
from hippy.objects.base import W_Root
from hippy.objects.instanceobject import W_InstanceObject
from hippy import consts


class W_ApplevelArrayIterator(W_InstanceObject):
    pass


@wrap_method(['interp', ThisUnwrapper(W_ApplevelArrayIterator),
              Optional(W_Root)],
             name='ArrayIterator::__construct')
def ArrayIterator_construct(interp, this, w_arr=None):
    if w_arr is None:
        w_arr = interp.space.new_array_from_list([])
    this.setattr(interp, "storage", w_arr, k_ArrayIterator)


@wrap_method([], name='ArrayIterator::current')
def ArrayIterator_current():
    pass


@wrap_method([], name='ArrayIterator::next')
def ArrayIterator_next():
    pass


@wrap_method([], name='ArrayIterator::key')
def ArrayIterator_key():
    pass


@wrap_method([], name='ArrayIterator::rewind')
def ArrayIterator_rewind():
    pass


@wrap_method([], name='ArrayIterator::valid')
def ArrayIterator_valid():
    pass


k_ArrayIterator = def_class(
    'ArrayIterator',
    [ArrayIterator_construct,
     ArrayIterator_current,
     ArrayIterator_next,
     ArrayIterator_key,
     ArrayIterator_rewind,
     ArrayIterator_valid],
    [('storage', consts.ACC_PRIVATE)],
    instance_class=W_ApplevelArrayIterator,
    implements=[k_Iterator])

@@ -66,44 +66,16 @@
 ort 
-ThisUnwrapper, Optional, wrap_method
+Optional
 %0Afro
@@ -236,24 +236,16 @@
 class W_
-Applevel
 ArrayIte
@@ -284,56 +284,42 @@
 s%0A%0A%0A
-@wrap_method(%5B'interp', ThisUnwrapper(W_Applevel
+k_ArrayIterator = def_class(%0A    '
 Arra
@@ -331,48 +331,120 @@
 ator
-)
+'
 ,%0A    
-          Optional(W_Root
+%5B'__construct', 'current', 'next', 'key', 'rewind', 'valid'%5D,%0A    %5B('storage', consts.ACC_PRIVATE
 )%5D,%0A    
     
@@ -443,69 +443,142 @@
     
-   
-      name='ArrayIterator::__construct')%0Adef ArrayIterator
+instance_class=W_ArrayIterator,%0A    implements=%5Bk_Iterator%5D)%0A%0A%0A@k_ArrayIterator.def_method(%5B'interp', 'this', Optional(W_Root)%5D)%0Adef _
 _con
@@ -753,411 +753,215 @@
 %0A%0A%0A@
-wrap_method(%5B%5D, name='ArrayIterator::current')%0Adef ArrayIterator_current():%0A    pass%0A%0A%0A@wrap_method(%5B%5D, name='ArrayIterator::next')%0Adef ArrayIterator_next():%0A    pass%0A%0A%0A@wrap_method(%5B%5D, name='ArrayIterator::key')%0Adef ArrayIterator_key():%0A    pass%0A%0A%0A@wrap_method(%5B%5D, name='ArrayIterator::rewind')%0Adef ArrayIterator_rewind():%0A    pass%0A%0A%0A@wrap_method(%5B%5D, name='ArrayIterator::valid')%0Adef ArrayIterator_vali
+k_ArrayIterator.def_method(%5B%5D)%0Adef current():%0A    pass%0A%0A%0A@k_ArrayIterator.def_method(%5B%5D)%0Adef next():%0A    pass%0A%0A%0A@k_ArrayIterator.def_method(%5B%5D)%0Adef key():%0A    pass%0A%0A%0A@k_ArrayIterator.def_method(%5B%5D)%0Adef rewin
 d():
@@ -964,32 +964,33 @@
 d():%0A    pass%0A%0A%0A
+@
 k_ArrayIterator 
@@ -992,312 +992,42 @@
 ator
- = 
+.
 def_
-class(%0A    'ArrayIterator',%0A    %5BArrayIterator_construct,%0A     ArrayIterator_current,%0A     ArrayIterator_next,%0A     ArrayIterator_key,%0A     ArrayIterator_rewind,%0A     ArrayIterator_valid%5D,%0A    %5B('storage', consts.ACC_PRIVATE)%5D,%0A    instance_class=W_ApplevelArrayIterator,%0A    implements=%5Bk_Iterator%5D)
+method(%5B%5D)%0Adef valid():%0A    pass
 %0A

Use def_method() for ArrayIterator