Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
d1b93ced
Commit
d1b93ced
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/objtype: Use size_t where appropriate, instead of mp_uint_t or uint.
parent
bfb48c16
Branches
gohu
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/objtype.c
+16
-16
16 additions, 16 deletions
py/objtype.c
with
16 additions
and
16 deletions
py/objtype.c
+
16
−
16
View file @
d1b93ced
...
@@ -48,7 +48,7 @@ STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_
...
@@ -48,7 +48,7 @@ STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_
/******************************************************************************/
/******************************************************************************/
// instance object
// instance object
STATIC
mp_obj_t
mp_obj_new_instance
(
const
mp_obj_type_t
*
class
,
uin
t
subobjs
)
{
STATIC
mp_obj_t
mp_obj_new_instance
(
const
mp_obj_type_t
*
class
,
size_
t
subobjs
)
{
mp_obj_instance_t
*
o
=
m_new_obj_var
(
mp_obj_instance_t
,
mp_obj_t
,
subobjs
);
mp_obj_instance_t
*
o
=
m_new_obj_var
(
mp_obj_instance_t
,
mp_obj_t
,
subobjs
);
o
->
base
.
type
=
class
;
o
->
base
.
type
=
class
;
mp_map_init
(
&
o
->
members
,
0
);
mp_map_init
(
&
o
->
members
,
0
);
...
@@ -57,11 +57,11 @@ STATIC mp_obj_t mp_obj_new_instance(const mp_obj_type_t *class, uint subobjs) {
...
@@ -57,11 +57,11 @@ STATIC mp_obj_t mp_obj_new_instance(const mp_obj_type_t *class, uint subobjs) {
}
}
STATIC
int
instance_count_native_bases
(
const
mp_obj_type_t
*
type
,
const
mp_obj_type_t
**
last_native_base
)
{
STATIC
int
instance_count_native_bases
(
const
mp_obj_type_t
*
type
,
const
mp_obj_type_t
**
last_native_base
)
{
mp_uint
_t
len
=
type
->
bases_tuple
->
len
;
size
_t
len
=
type
->
bases_tuple
->
len
;
mp_obj_t
*
items
=
type
->
bases_tuple
->
items
;
mp_obj_t
*
items
=
type
->
bases_tuple
->
items
;
int
count
=
0
;
int
count
=
0
;
for
(
uin
t
i
=
0
;
i
<
len
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
len
;
i
++
)
{
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
const
mp_obj_type_t
*
bt
=
(
const
mp_obj_type_t
*
)
MP_OBJ_TO_PTR
(
items
[
i
]);
const
mp_obj_type_t
*
bt
=
(
const
mp_obj_type_t
*
)
MP_OBJ_TO_PTR
(
items
[
i
]);
if
(
bt
==
&
mp_type_object
)
{
if
(
bt
==
&
mp_type_object
)
{
...
@@ -96,7 +96,7 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
...
@@ -96,7 +96,7 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
struct
class_lookup_data
{
struct
class_lookup_data
{
mp_obj_instance_t
*
obj
;
mp_obj_instance_t
*
obj
;
qstr
attr
;
qstr
attr
;
mp_uint
_t
meth_offset
;
size
_t
meth_offset
;
mp_obj_t
*
dest
;
mp_obj_t
*
dest
;
bool
is_type
;
bool
is_type
;
};
};
...
@@ -165,12 +165,12 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
...
@@ -165,12 +165,12 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
return
;
return
;
}
}
mp_uint
_t
len
=
type
->
bases_tuple
->
len
;
size
_t
len
=
type
->
bases_tuple
->
len
;
mp_obj_t
*
items
=
type
->
bases_tuple
->
items
;
mp_obj_t
*
items
=
type
->
bases_tuple
->
items
;
if
(
len
==
0
)
{
if
(
len
==
0
)
{
return
;
return
;
}
}
for
(
uin
t
i
=
0
;
i
<
len
-
1
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
len
-
1
;
i
++
)
{
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
mp_obj_type_t
*
bt
=
(
mp_obj_type_t
*
)
MP_OBJ_TO_PTR
(
items
[
i
]);
mp_obj_type_t
*
bt
=
(
mp_obj_type_t
*
)
MP_OBJ_TO_PTR
(
items
[
i
]);
if
(
bt
==
&
mp_type_object
)
{
if
(
bt
==
&
mp_type_object
)
{
...
@@ -239,7 +239,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size
...
@@ -239,7 +239,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size
assert
(
mp_obj_is_instance_type
(
self
));
assert
(
mp_obj_is_instance_type
(
self
));
const
mp_obj_type_t
*
native_base
;
const
mp_obj_type_t
*
native_base
;
uin
t
num_native_bases
=
instance_count_native_bases
(
self
,
&
native_base
);
size_
t
num_native_bases
=
instance_count_native_bases
(
self
,
&
native_base
);
assert
(
num_native_bases
<
2
);
assert
(
num_native_bases
<
2
);
mp_obj_instance_t
*
o
=
MP_OBJ_TO_PTR
(
mp_obj_new_instance
(
self
,
num_native_bases
));
mp_obj_instance_t
*
o
=
MP_OBJ_TO_PTR
(
mp_obj_new_instance
(
self
,
num_native_bases
));
...
@@ -477,7 +477,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
...
@@ -477,7 +477,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
// it will not result in modifications to the actual instance members.
// it will not result in modifications to the actual instance members.
mp_map_t
*
map
=
&
self
->
members
;
mp_map_t
*
map
=
&
self
->
members
;
mp_obj_t
attr_dict
=
mp_obj_new_dict
(
map
->
used
);
mp_obj_t
attr_dict
=
mp_obj_new_dict
(
map
->
used
);
for
(
mp_uint
_t
i
=
0
;
i
<
map
->
alloc
;
++
i
)
{
for
(
size
_t
i
=
0
;
i
<
map
->
alloc
;
++
i
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
map
,
i
))
{
if
(
MP_MAP_SLOT_IS_FILLED
(
map
,
i
))
{
mp_obj_dict_store
(
attr_dict
,
map
->
table
[
i
].
key
,
map
->
table
[
i
].
value
);
mp_obj_dict_store
(
attr_dict
,
map
->
table
[
i
].
key
,
map
->
table
[
i
].
value
);
}
}
...
@@ -688,7 +688,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
...
@@ -688,7 +688,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
.
dest
=
member
,
.
dest
=
member
,
.
is_type
=
false
,
.
is_type
=
false
,
};
};
uin
t
meth_args
;
size_
t
meth_args
;
if
(
value
==
MP_OBJ_NULL
)
{
if
(
value
==
MP_OBJ_NULL
)
{
// delete item
// delete item
lookup
.
attr
=
MP_QSTR___delitem__
;
lookup
.
attr
=
MP_QSTR___delitem__
;
...
@@ -919,7 +919,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
...
@@ -919,7 +919,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
mp_uint_t
len
;
mp_uint_t
len
;
mp_obj_t
*
items
;
mp_obj_t
*
items
;
mp_obj_tuple_get
(
bases_tuple
,
&
len
,
&
items
);
mp_obj_tuple_get
(
bases_tuple
,
&
len
,
&
items
);
for
(
uin
t
i
=
0
;
i
<
len
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
len
;
i
++
)
{
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
mp_obj_type_t
*
t
=
MP_OBJ_TO_PTR
(
items
[
i
]);
mp_obj_type_t
*
t
=
MP_OBJ_TO_PTR
(
items
[
i
]);
// TODO: Verify with CPy, tested on function type
// TODO: Verify with CPy, tested on function type
...
@@ -957,7 +957,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
...
@@ -957,7 +957,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
o
->
locals_dict
=
MP_OBJ_TO_PTR
(
locals_dict
);
o
->
locals_dict
=
MP_OBJ_TO_PTR
(
locals_dict
);
const
mp_obj_type_t
*
native_base
;
const
mp_obj_type_t
*
native_base
;
uin
t
num_native_bases
=
instance_count_native_bases
(
o
,
&
native_base
);
size_
t
num_native_bases
=
instance_count_native_bases
(
o
,
&
native_base
);
if
(
num_native_bases
>
1
)
{
if
(
num_native_bases
>
1
)
{
mp_raise_msg
(
&
mp_type_TypeError
,
"multiple bases have instance lay-out conflict"
);
mp_raise_msg
(
&
mp_type_TypeError
,
"multiple bases have instance lay-out conflict"
);
}
}
...
@@ -1020,7 +1020,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
...
@@ -1020,7 +1020,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
return
;
return
;
}
}
mp_uint
_t
len
=
type
->
bases_tuple
->
len
;
size
_t
len
=
type
->
bases_tuple
->
len
;
mp_obj_t
*
items
=
type
->
bases_tuple
->
items
;
mp_obj_t
*
items
=
type
->
bases_tuple
->
items
;
struct
class_lookup_data
lookup
=
{
struct
class_lookup_data
lookup
=
{
.
obj
=
MP_OBJ_TO_PTR
(
self
->
obj
),
.
obj
=
MP_OBJ_TO_PTR
(
self
->
obj
),
...
@@ -1029,7 +1029,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
...
@@ -1029,7 +1029,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
.
dest
=
dest
,
.
dest
=
dest
,
.
is_type
=
false
,
.
is_type
=
false
,
};
};
for
(
uin
t
i
=
0
;
i
<
len
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
len
;
i
++
)
{
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
assert
(
MP_OBJ_IS_TYPE
(
items
[
i
],
&
mp_type_type
));
mp_obj_class_lookup
(
&
lookup
,
(
mp_obj_type_t
*
)
MP_OBJ_TO_PTR
(
items
[
i
]));
mp_obj_class_lookup
(
&
lookup
,
(
mp_obj_type_t
*
)
MP_OBJ_TO_PTR
(
items
[
i
]));
if
(
dest
[
0
]
!=
MP_OBJ_NULL
)
{
if
(
dest
[
0
]
!=
MP_OBJ_NULL
)
{
...
@@ -1079,14 +1079,14 @@ bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) {
...
@@ -1079,14 +1079,14 @@ bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) {
}
}
// get the base objects (they should be type objects)
// get the base objects (they should be type objects)
mp_uint
_t
len
=
self
->
bases_tuple
->
len
;
size
_t
len
=
self
->
bases_tuple
->
len
;
mp_obj_t
*
items
=
self
->
bases_tuple
->
items
;
mp_obj_t
*
items
=
self
->
bases_tuple
->
items
;
if
(
len
==
0
)
{
if
(
len
==
0
)
{
return
false
;
return
false
;
}
}
// iterate through the base objects
// iterate through the base objects
for
(
uin
t
i
=
0
;
i
<
len
-
1
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
len
-
1
;
i
++
)
{
if
(
mp_obj_is_subclass_fast
(
items
[
i
],
classinfo
))
{
if
(
mp_obj_is_subclass_fast
(
items
[
i
],
classinfo
))
{
return
true
;
return
true
;
}
}
...
@@ -1109,7 +1109,7 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
...
@@ -1109,7 +1109,7 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
mp_raise_msg
(
&
mp_type_TypeError
,
"issubclass() arg 2 must be a class or a tuple of classes"
);
mp_raise_msg
(
&
mp_type_TypeError
,
"issubclass() arg 2 must be a class or a tuple of classes"
);
}
}
for
(
uin
t
i
=
0
;
i
<
len
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
len
;
i
++
)
{
// We explicitly check for 'object' here since no-one explicitly derives from it
// We explicitly check for 'object' here since no-one explicitly derives from it
if
(
items
[
i
]
==
MP_OBJ_FROM_PTR
(
&
mp_type_object
)
||
mp_obj_is_subclass_fast
(
object
,
items
[
i
]))
{
if
(
items
[
i
]
==
MP_OBJ_FROM_PTR
(
&
mp_type_object
)
||
mp_obj_is_subclass_fast
(
object
,
items
[
i
]))
{
return
mp_const_true
;
return
mp_const_true
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment