示例#1
0
STATIC mp_obj_t extint_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
    // type_in == extint_obj_type

    // parse args
    mp_arg_val_t vals[PYB_EXTINT_MAKE_NEW_NUM_ARGS];
    mp_arg_parse_all_kw_array(n_args, n_kw, args, PYB_EXTINT_MAKE_NEW_NUM_ARGS, pyb_extint_make_new_args, vals);

    extint_obj_t *self = m_new_obj(extint_obj_t);
    self->base.type = type;
    self->line = extint_register(vals[0].u_obj, vals[1].u_int, vals[2].u_int, vals[3].u_obj, false);

    return self;
}
示例#2
0
STATIC mp_obj_t ubluepy_scanner_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
    static const mp_arg_t allowed_args[] = {

    };

    // parse args
    mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
    mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);

    ubluepy_scanner_obj_t * s = m_new_obj(ubluepy_scanner_obj_t);
    s->base.type = type;

    return MP_OBJ_FROM_PTR(s);
}
示例#3
0
STATIC mp_obj_t mod_sf2d_RenderTarget_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args_in) {
    mp_arg_check_num(n_args, n_kw, 2, NEW_ARG_COUNT, true);

    static const mp_arg_t allowed_args[] = {
            {MP_QSTR_width,  MP_ARG_INT | MP_ARG_REQUIRED},
            {MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED},
    };

    mp_arg_val_t args[NEW_ARG_COUNT];
    mp_arg_parse_all_kw_array(n_args, n_kw, args_in, NEW_ARG_COUNT, allowed_args, args);

    mod_sf2d_RenderTarget_t *obj = m_new_obj(mod_sf2d_RenderTarget_t);
    obj->base.type = (mp_obj_t) &mod_sf2d_RenderTarget_type;

    int width = args[NEW_ARG_WIDTH].u_int;
    int height = args[NEW_ARG_HEIGHT].u_int;

    obj->target = sf2d_create_rendertarget(width, height);
    //obj->texture = _mod_sf2d_Texture_from_ptr(&obj->target->texture);

    return obj;
}
示例#4
0
STATIC ICACHE_FLASH_ATTR mp_obj_t mod_esp_queue_make_new(const mp_obj_type_t *type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
    mp_arg_val_t vals[ESP_MUTEX_INIT_NUM_ARGS];
    mp_arg_parse_all_kw_array(n_args, n_kw, args, ESP_MUTEX_INIT_NUM_ARGS, mod_esp_queue_init_args, vals);

    if (!MP_OBJ_IS_TYPE(vals[0].u_obj,  &mp_type_list)) {
        nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "storage needs to be a list"));
    }
    esp_queue_obj_t *self = m_new_obj(esp_queue_obj_t);

    self->base.type = &esp_queue_type;
    mp_obj_list_t *list = (mp_obj_list_t *)vals[0].u_obj;
	self->items = 0;
	self->first = 0;
	self->last = 0;
    self->max_items = list->len;
    self->obj_instances = list->items;
    if (vals[1].u_obj != mp_const_none) {
        if (MP_OBJ_IS_TYPE(vals[1].u_obj, &esp_mutex_type)) {
            self->mutex = vals[1].u_obj;
        } else {
            nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "mutex needs to be an esp.mutex type"));
        }
    } else {
        self->mutex = mp_const_none;
    }
    if (vals[2].u_obj != mp_const_none) {
        if (MP_OBJ_IS_TYPE(vals[2].u_obj, &esp_os_task_type)) {
            self->os_task = vals[2].u_obj;
        } else {
            nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "os_task needs to be an esp.os_task type"));
        }
    } else {
        self->os_task = mp_const_none;
    }
    return (mp_obj_t)self;
}
示例#5
0
STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
    mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS];
    mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
    return fdfile_open(type_in, arg_vals);
}
示例#6
0
STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
    mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS];
    mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
    return file_open(type, arg_vals);
}