Beispiel #1
0
 def descr__call__(self, space, args_w):
     h_args = support.emjs_make_array(len(args_w))
     _check_error(space, h_args)
     for i in xrange(len(args_w)):
         with _unwrap_handle(space, args_w[i]) as h_arg:
             support.emjs_prop_set_int(h_args, i, h_arg)
     w_ctx = self.w_context
     if w_ctx is None:
         w_ctx = undefined
     with _unwrap_handle(space, w_ctx) as h_ctx:
         h_res = support.emjs_apply(self.handle, h_ctx, h_args)
     return _wrap_handle(space, h_res)
Beispiel #2
0
 def descr__call__(self, space, args_w):
     h_args = support.emjs_make_array(len(args_w))
     _check_error(space, h_args)
     for i in xrange(len(args_w)):
         with _unwrap_handle(space, args_w[i]) as h_arg:
             support.emjs_prop_set_int(h_args, i, h_arg)
     w_ctx = self.w_context
     if w_ctx is None:
         w_ctx = undefined
     with _unwrap_handle(space, w_ctx) as h_ctx:
         h_res = support.emjs_apply(self.handle, h_ctx, h_args)
     return _wrap_handle(space, h_res)
Beispiel #3
0
 def descr__setitem__(self, space, w_prop, w_value):
     with _unwrap_handle(space, w_value) as h_value:
         if space.isinstance_w(w_prop, space.w_str):
             prop = space.str_w(w_prop)
             res = support.emjs_prop_set_str(self.handle, prop, h_value)
         elif space.isinstance_w(w_prop, space.w_int):
             prop = space.int_w(w_prop)
             res = support.emjs_prop_set_int(self.handle, prop, h_value)
         elif space.isinstance_w(w_prop, space.w_long):
             prop = space.int_w(w_prop)
             res = support.emjs_prop_set_int(self.handle, prop, h_value)
         else:
             with _unwrap_handle(space, w_prop) as h_prop:
                 res = support.emjs_prop_set(self.handle, h_prop, h_value)
     _check_error(space, res)
Beispiel #4
0
 def descr__setitem__(self, space, w_prop, w_value):
     with _unwrap_handle(space, w_value) as h_value:
         if space.isinstance_w(w_prop, space.w_str):
             prop = space.str_w(w_prop)
             res = support.emjs_prop_set_str(self.handle, prop, h_value)
         elif space.isinstance_w(w_prop, space.w_int):
             prop = space.int_w(w_prop)
             res = support.emjs_prop_set_int(self.handle, prop, h_value)
         elif space.isinstance_w(w_prop, space.w_long):
             prop = space.int_w(w_prop)
             res = support.emjs_prop_set_int(self.handle, prop, h_value)
         else:
             with _unwrap_handle(space, w_prop) as h_prop:
                 res = support.emjs_prop_set(self.handle, h_prop, h_value)
     _check_error(space, res)
Beispiel #5
0
def new(space, w_fn, args_w):
    with _unwrap_handle(space, w_fn) as h_fn:
        h_args = support.emjs_make_array(len(args_w))
        _check_error(space, h_args)
        for i in xrange(len(args_w)):
            with _unwrap_handle(space, args_w[i]) as h_arg:
                res = support.emjs_prop_set_int(h_args, i, h_arg)
            _check_error(space, res)
        h_res = support.emjs_new(h_fn, h_args)
    return _wrap_handle(space, h_res)
Beispiel #6
0
def new(space, w_fn, args_w):
    with _unwrap_handle(space, w_fn) as h_fn:
        h_args = support.emjs_make_array(len(args_w))
        _check_error(space, h_args)
        for i in xrange(len(args_w)):
            with _unwrap_handle(space, args_w[i]) as h_arg:
                res = support.emjs_prop_set_int(h_args, i, h_arg)
            _check_error(space, res)
        h_res = support.emjs_new(h_fn, h_args)
    return _wrap_handle(space, h_res)
Beispiel #7
0
def W_Array_descr__new__(space, w_subtype, w_items, w_size):
    # XXX TODO: default arguments, somehow...
    size = space.int_w(w_size)
    h_self = support.emjs_make_array(size)
    _check_error(space, h_self)
    if space.is_true(w_items):
        w_iterator = space.iter(w_items)
        idx = 0
        # XXX TODO: baseobjspace uses a jit merge point in this loop...?
        while True:
            try:
                w_item = space.next(w_iterator)
            except OperationError, e:
                if not e.match(space, space.w_StopIteration):
                    raise
                break
            else:
                with _unwrap_handle(space, w_item) as h_item:
                    res = support.emjs_prop_set_int(h_self, idx, h_item)
                    _check_error(space, res)
                idx += 1
Beispiel #8
0
def W_Array_descr__new__(space, w_subtype, w_items, w_size):
    # XXX TODO: default arguments, somehow...
    size = space.int_w(w_size)
    h_self = support.emjs_make_array(size)
    _check_error(space, h_self)
    if space.is_true(w_items):
        w_iterator = space.iter(w_items)
        idx = 0
        # XXX TODO: baseobjspace uses a jit merge point in this loop...?
        while True:
            try:
                w_item = space.next(w_iterator)
            except OperationError, e:
                if not e.match(space, space.w_StopIteration):
                    raise
                break
            else:
                with _unwrap_handle(space, w_item) as h_item:
                    res = support.emjs_prop_set_int(h_self, idx, h_item)
                    _check_error(space, res)
                idx += 1