Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
4d917235
Commit
4d917235
authored
Aug 30, 2014
by
Damien George
Browse files
py: Remove use of int type in obj.h.
Part of code cleanup, working towards resolving issue #50.
parent
d182b98a
Changes
6
Hide whitespace changes
Inline
Side-by-side
py/obj.c
View file @
4d917235
...
...
@@ -111,7 +111,7 @@ void mp_obj_print_exception(mp_obj_t exc) {
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
)
{
return
0
;
}
else
if
(
arg
==
mp_const_true
)
{
...
...
@@ -414,7 +414,7 @@ mp_obj_t mp_identity(mp_obj_t self) {
}
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
);
if
(
type
->
buffer_p
.
get_buffer
==
NULL
)
{
return
false
;
...
...
@@ -426,7 +426,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
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
))
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"object with buffer protocol required"
));
}
...
...
py/obj.h
View file @
4d917235
...
...
@@ -212,8 +212,8 @@ typedef struct _mp_buffer_info_t {
//int ver; // ?
void
*
buf
;
// can be NULL if len == 0
mp_int_t
len
;
// in bytes
int
typecode
;
// as per binary.h
mp_int_t
len
;
// in bytes
; TODO should it be mp_uint_t?
int
typecode
;
// as per binary.h
; TODO what is the correct type to use?
// Rationale: to load arbitrary-sized sprites directly to LCD
// Cons: a bit adhoc usecase
...
...
@@ -223,10 +223,10 @@ typedef struct _mp_buffer_info_t {
#define MP_BUFFER_WRITE (2)
#define MP_BUFFER_RW (MP_BUFFER_READ | MP_BUFFER_WRITE)
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
;
bool
mp_get_buffer
(
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
,
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
,
mp_uint_
t
flags
);
// Stream protocol
#define MP_STREAM_ERROR (-1)
...
...
@@ -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
(
*
write
)(
mp_obj_t
obj
,
const
void
*
buf
,
mp_uint_t
size
,
int
*
errcode
);
// 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
;
struct
_mp_obj_type_t
{
...
...
@@ -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_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
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
#endif
#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)); }
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_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_bytes
(
mp_uint_
t
op
,
const
byte
*
data1
,
mp_uint_t
len1
,
const
byte
*
data2
,
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_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
);
...
...
py/objarray.c
View file @
4d917235
...
...
@@ -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_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_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 */
...
...
@@ -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
;
bufinfo
->
buf
=
o
->
items
;
bufinfo
->
len
=
o
->
len
*
mp_binary_get_size
(
'@'
,
o
->
typecode
,
NULL
);
...
...
py/objstr.c
View file @
4d917235
...
...
@@ -1618,7 +1618,7 @@ STATIC mp_obj_t str_encode(mp_uint_t n_args, const mp_obj_t *args) {
}
#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
)
{
GET_STR_DATA_LEN
(
self_in
,
str_data
,
str_len
);
bufinfo
->
buf
=
(
void
*
)
str_data
;
...
...
py/objstr.h
View file @
4d917235
...
...
@@ -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_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
,
mp_obj_t
index
,
bool
is_slice
);
...
...
py/sequence.c
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
// Special-case comparison function for sequences of bytes
// 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
)
{
return
false
;
}
...
...
@@ -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
// 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
)
{
return
false
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment