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
GitLab 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
4d917235
Commit
4d917235
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Remove use of int type in obj.h.
Part of code cleanup, working towards resolving issue #50.
parent
d182b98a
No related branches found
No related tags found
No related merge requests found
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
py/obj.c
+3
-3
3 additions, 3 deletions
py/obj.c
py/obj.h
+9
-9
9 additions, 9 deletions
py/obj.h
py/objarray.c
+2
-2
2 additions, 2 deletions
py/objarray.c
py/objstr.c
+1
-1
1 addition, 1 deletion
py/objstr.c
py/objstr.h
+1
-1
1 addition, 1 deletion
py/objstr.h
py/sequence.c
+2
-2
2 additions, 2 deletions
py/sequence.c
with
18 additions
and
18 deletions
py/obj.c
+
3
−
3
View file @
4d917235
...
@@ -111,7 +111,7 @@ void mp_obj_print_exception(mp_obj_t exc) {
...
@@ -111,7 +111,7 @@ void mp_obj_print_exception(mp_obj_t exc) {
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
int
mp_obj_is_true
(
mp_obj_t
arg
)
{
bool
mp_obj_is_true
(
mp_obj_t
arg
)
{
if
(
arg
==
mp_const_false
)
{
if
(
arg
==
mp_const_false
)
{
return
0
;
return
0
;
}
else
if
(
arg
==
mp_const_true
)
{
}
else
if
(
arg
==
mp_const_true
)
{
...
@@ -414,7 +414,7 @@ mp_obj_t mp_identity(mp_obj_t self) {
...
@@ -414,7 +414,7 @@ mp_obj_t mp_identity(mp_obj_t self) {
}
}
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_identity_obj
,
mp_identity
);
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_identity_obj
,
mp_identity
);
bool
mp_get_buffer
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
)
{
bool
mp_get_buffer
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
)
{
mp_obj_type_t
*
type
=
mp_obj_get_type
(
obj
);
mp_obj_type_t
*
type
=
mp_obj_get_type
(
obj
);
if
(
type
->
buffer_p
.
get_buffer
==
NULL
)
{
if
(
type
->
buffer_p
.
get_buffer
==
NULL
)
{
return
false
;
return
false
;
...
@@ -426,7 +426,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
...
@@ -426,7 +426,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
return
true
;
return
true
;
}
}
void
mp_get_buffer_raise
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
)
{
void
mp_get_buffer_raise
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
)
{
if
(
!
mp_get_buffer
(
obj
,
bufinfo
,
flags
))
{
if
(
!
mp_get_buffer
(
obj
,
bufinfo
,
flags
))
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"object with buffer protocol required"
));
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"object with buffer protocol required"
));
}
}
...
...
This diff is collapsed.
Click to expand it.
py/obj.h
+
9
−
9
View file @
4d917235
...
@@ -212,8 +212,8 @@ typedef struct _mp_buffer_info_t {
...
@@ -212,8 +212,8 @@ typedef struct _mp_buffer_info_t {
//int ver; // ?
//int ver; // ?
void
*
buf
;
// can be NULL if len == 0
void
*
buf
;
// can be NULL if len == 0
mp_int_t
len
;
// in bytes
mp_int_t
len
;
// in bytes
; TODO should it be mp_uint_t?
int
typecode
;
// as per binary.h
int
typecode
;
// as per binary.h
; TODO what is the correct type to use?
// Rationale: to load arbitrary-sized sprites directly to LCD
// Rationale: to load arbitrary-sized sprites directly to LCD
// Cons: a bit adhoc usecase
// Cons: a bit adhoc usecase
...
@@ -223,10 +223,10 @@ typedef struct _mp_buffer_info_t {
...
@@ -223,10 +223,10 @@ typedef struct _mp_buffer_info_t {
#define MP_BUFFER_WRITE (2)
#define MP_BUFFER_WRITE (2)
#define MP_BUFFER_RW (MP_BUFFER_READ | MP_BUFFER_WRITE)
#define MP_BUFFER_RW (MP_BUFFER_READ | MP_BUFFER_WRITE)
typedef
struct
_mp_buffer_p_t
{
typedef
struct
_mp_buffer_p_t
{
mp_int_t
(
*
get_buffer
)(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
);
mp_int_t
(
*
get_buffer
)(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
);
}
mp_buffer_p_t
;
}
mp_buffer_p_t
;
bool
mp_get_buffer
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
);
bool
mp_get_buffer
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
);
void
mp_get_buffer_raise
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
);
void
mp_get_buffer_raise
(
mp_obj_t
obj
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
);
// Stream protocol
// Stream protocol
#define MP_STREAM_ERROR (-1)
#define MP_STREAM_ERROR (-1)
...
@@ -236,7 +236,7 @@ typedef struct _mp_stream_p_t {
...
@@ -236,7 +236,7 @@ typedef struct _mp_stream_p_t {
mp_uint_t
(
*
read
)(
mp_obj_t
obj
,
void
*
buf
,
mp_uint_t
size
,
int
*
errcode
);
mp_uint_t
(
*
read
)(
mp_obj_t
obj
,
void
*
buf
,
mp_uint_t
size
,
int
*
errcode
);
mp_uint_t
(
*
write
)(
mp_obj_t
obj
,
const
void
*
buf
,
mp_uint_t
size
,
int
*
errcode
);
mp_uint_t
(
*
write
)(
mp_obj_t
obj
,
const
void
*
buf
,
mp_uint_t
size
,
int
*
errcode
);
// add seek() ?
// add seek() ?
in
t
is_text
:
1
;
// default is bytes, set this for text stream
mp_uint_
t
is_text
:
1
;
// default is bytes, set this for text stream
}
mp_stream_p_t
;
}
mp_stream_p_t
;
struct
_mp_obj_type_t
{
struct
_mp_obj_type_t
{
...
@@ -403,7 +403,7 @@ void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *e
...
@@ -403,7 +403,7 @@ void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *e
void
mp_obj_print
(
mp_obj_t
o
,
mp_print_kind_t
kind
);
void
mp_obj_print
(
mp_obj_t
o
,
mp_print_kind_t
kind
);
void
mp_obj_print_exception
(
mp_obj_t
exc
);
void
mp_obj_print_exception
(
mp_obj_t
exc
);
int
mp_obj_is_true
(
mp_obj_t
arg
);
bool
mp_obj_is_true
(
mp_obj_t
arg
);
// TODO make these all lower case when they have proven themselves
// TODO make these all lower case when they have proven themselves
static
inline
bool
MP_OBJ_IS_OBJ
(
mp_const_obj_t
o
)
{
return
((((
mp_int_t
)(
o
))
&
3
)
==
0
);
}
static
inline
bool
MP_OBJ_IS_OBJ
(
mp_const_obj_t
o
)
{
return
((((
mp_int_t
)(
o
))
&
3
)
==
0
);
}
...
@@ -575,8 +575,8 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
...
@@ -575,8 +575,8 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
#endif
#endif
#define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
#define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
#define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
#define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
bool
mp_seq_cmp_bytes
(
in
t
op
,
const
byte
*
data1
,
mp_uint_t
len1
,
const
byte
*
data2
,
mp_uint_t
len2
);
bool
mp_seq_cmp_bytes
(
mp_uint_
t
op
,
const
byte
*
data1
,
mp_uint_t
len1
,
const
byte
*
data2
,
mp_uint_t
len2
);
bool
mp_seq_cmp_objs
(
in
t
op
,
const
mp_obj_t
*
items1
,
mp_uint_t
len1
,
const
mp_obj_t
*
items2
,
mp_uint_t
len2
);
bool
mp_seq_cmp_objs
(
mp_uint_
t
op
,
const
mp_obj_t
*
items1
,
mp_uint_t
len1
,
const
mp_obj_t
*
items2
,
mp_uint_t
len2
);
mp_obj_t
mp_seq_index_obj
(
const
mp_obj_t
*
items
,
mp_uint_t
len
,
mp_uint_t
n_args
,
const
mp_obj_t
*
args
);
mp_obj_t
mp_seq_index_obj
(
const
mp_obj_t
*
items
,
mp_uint_t
len
,
mp_uint_t
n_args
,
const
mp_obj_t
*
args
);
mp_obj_t
mp_seq_count_obj
(
const
mp_obj_t
*
items
,
mp_uint_t
len
,
mp_obj_t
value
);
mp_obj_t
mp_seq_count_obj
(
const
mp_obj_t
*
items
,
mp_uint_t
len
,
mp_obj_t
value
);
mp_obj_t
mp_seq_extract_slice
(
mp_uint_t
len
,
const
mp_obj_t
*
seq
,
mp_bound_slice_t
*
indexes
);
mp_obj_t
mp_seq_extract_slice
(
mp_uint_t
len
,
const
mp_obj_t
*
seq
,
mp_bound_slice_t
*
indexes
);
...
...
This diff is collapsed.
Click to expand it.
py/objarray.c
+
2
−
2
View file @
4d917235
...
@@ -52,7 +52,7 @@ typedef struct _mp_obj_array_t {
...
@@ -52,7 +52,7 @@ typedef struct _mp_obj_array_t {
STATIC
mp_obj_t
array_iterator_new
(
mp_obj_t
array_in
);
STATIC
mp_obj_t
array_iterator_new
(
mp_obj_t
array_in
);
STATIC
mp_obj_array_t
*
array_new
(
char
typecode
,
uint
n
);
STATIC
mp_obj_array_t
*
array_new
(
char
typecode
,
uint
n
);
STATIC
mp_obj_t
array_append
(
mp_obj_t
self_in
,
mp_obj_t
arg
);
STATIC
mp_obj_t
array_append
(
mp_obj_t
self_in
,
mp_obj_t
arg
);
STATIC
mp_int_t
array_get_buffer
(
mp_obj_t
o_in
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
);
STATIC
mp_int_t
array_get_buffer
(
mp_obj_t
o_in
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
);
/******************************************************************************/
/******************************************************************************/
/* array */
/* array */
...
@@ -223,7 +223,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
...
@@ -223,7 +223,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
}
}
}
}
STATIC
mp_int_t
array_get_buffer
(
mp_obj_t
o_in
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
)
{
STATIC
mp_int_t
array_get_buffer
(
mp_obj_t
o_in
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
)
{
mp_obj_array_t
*
o
=
o_in
;
mp_obj_array_t
*
o
=
o_in
;
bufinfo
->
buf
=
o
->
items
;
bufinfo
->
buf
=
o
->
items
;
bufinfo
->
len
=
o
->
len
*
mp_binary_get_size
(
'@'
,
o
->
typecode
,
NULL
);
bufinfo
->
len
=
o
->
len
*
mp_binary_get_size
(
'@'
,
o
->
typecode
,
NULL
);
...
...
This diff is collapsed.
Click to expand it.
py/objstr.c
+
1
−
1
View file @
4d917235
...
@@ -1618,7 +1618,7 @@ STATIC mp_obj_t str_encode(mp_uint_t n_args, const mp_obj_t *args) {
...
@@ -1618,7 +1618,7 @@ STATIC mp_obj_t str_encode(mp_uint_t n_args, const mp_obj_t *args) {
}
}
#endif
#endif
mp_int_t
mp_obj_str_get_buffer
(
mp_obj_t
self_in
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
)
{
mp_int_t
mp_obj_str_get_buffer
(
mp_obj_t
self_in
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
)
{
if
(
flags
==
MP_BUFFER_READ
)
{
if
(
flags
==
MP_BUFFER_READ
)
{
GET_STR_DATA_LEN
(
self_in
,
str_data
,
str_len
);
GET_STR_DATA_LEN
(
self_in
,
str_data
,
str_len
);
bufinfo
->
buf
=
(
void
*
)
str_data
;
bufinfo
->
buf
=
(
void
*
)
str_data
;
...
...
This diff is collapsed.
Click to expand it.
py/objstr.h
+
1
−
1
View file @
4d917235
...
@@ -54,7 +54,7 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args);
...
@@ -54,7 +54,7 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args);
mp_obj_t
mp_obj_new_str_of_type
(
const
mp_obj_type_t
*
type
,
const
byte
*
data
,
uint
len
);
mp_obj_t
mp_obj_new_str_of_type
(
const
mp_obj_type_t
*
type
,
const
byte
*
data
,
uint
len
);
mp_obj_t
mp_obj_str_binary_op
(
mp_uint_t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
);
mp_obj_t
mp_obj_str_binary_op
(
mp_uint_t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
);
mp_int_t
mp_obj_str_get_buffer
(
mp_obj_t
self_in
,
mp_buffer_info_t
*
bufinfo
,
in
t
flags
);
mp_int_t
mp_obj_str_get_buffer
(
mp_obj_t
self_in
,
mp_buffer_info_t
*
bufinfo
,
mp_uint_
t
flags
);
const
byte
*
str_index_to_ptr
(
const
mp_obj_type_t
*
type
,
const
byte
*
self_data
,
uint
self_len
,
const
byte
*
str_index_to_ptr
(
const
mp_obj_type_t
*
type
,
const
byte
*
self_data
,
uint
self_len
,
mp_obj_t
index
,
bool
is_slice
);
mp_obj_t
index
,
bool
is_slice
);
...
...
This diff is collapsed.
Click to expand it.
py/sequence.c
+
2
−
2
View file @
4d917235
...
@@ -125,7 +125,7 @@ mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice
...
@@ -125,7 +125,7 @@ mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice
// Special-case comparison function for sequences of bytes
// Special-case comparison function for sequences of bytes
// Don't pass MP_BINARY_OP_NOT_EQUAL here
// Don't pass MP_BINARY_OP_NOT_EQUAL here
bool
mp_seq_cmp_bytes
(
in
t
op
,
const
byte
*
data1
,
mp_uint_t
len1
,
const
byte
*
data2
,
mp_uint_t
len2
)
{
bool
mp_seq_cmp_bytes
(
mp_uint_
t
op
,
const
byte
*
data1
,
mp_uint_t
len1
,
const
byte
*
data2
,
mp_uint_t
len2
)
{
if
(
op
==
MP_BINARY_OP_EQUAL
&&
len1
!=
len2
)
{
if
(
op
==
MP_BINARY_OP_EQUAL
&&
len1
!=
len2
)
{
return
false
;
return
false
;
}
}
...
@@ -169,7 +169,7 @@ bool mp_seq_cmp_bytes(int op, const byte *data1, mp_uint_t len1, const byte *dat
...
@@ -169,7 +169,7 @@ bool mp_seq_cmp_bytes(int op, const byte *data1, mp_uint_t len1, const byte *dat
// Special-case comparison function for sequences of mp_obj_t
// Special-case comparison function for sequences of mp_obj_t
// Don't pass MP_BINARY_OP_NOT_EQUAL here
// Don't pass MP_BINARY_OP_NOT_EQUAL here
bool
mp_seq_cmp_objs
(
in
t
op
,
const
mp_obj_t
*
items1
,
mp_uint_t
len1
,
const
mp_obj_t
*
items2
,
mp_uint_t
len2
)
{
bool
mp_seq_cmp_objs
(
mp_uint_
t
op
,
const
mp_obj_t
*
items1
,
mp_uint_t
len1
,
const
mp_obj_t
*
items2
,
mp_uint_t
len2
)
{
if
(
op
==
MP_BINARY_OP_EQUAL
&&
len1
!=
len2
)
{
if
(
op
==
MP_BINARY_OP_EQUAL
&&
len1
!=
len2
)
{
return
false
;
return
false
;
}
}
...
...
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