Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tools-mirror
Micropython
提交
6e30f96b
M
Micropython
项目概览
tools-mirror
/
Micropython
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Micropython
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e30f96b
编写于
1月 30, 2019
作者:
D
Damien George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ports: Convert legacy uppercase macro names to lowercase.
上级
f0360177
变更
46
隐藏空白更改
内联
并排
Showing
46 changed file
with
77 addition
and
77 deletion
+77
-77
ports/cc3200/hal/cc3200_hal.c
ports/cc3200/hal/cc3200_hal.c
+2
-2
ports/cc3200/mods/modmachine.c
ports/cc3200/mods/modmachine.c
+1
-1
ports/cc3200/mods/moduos.c
ports/cc3200/mods/moduos.c
+1
-1
ports/cc3200/mods/modwlan.c
ports/cc3200/mods/modwlan.c
+1
-1
ports/cc3200/mods/pybpin.c
ports/cc3200/mods/pybpin.c
+1
-1
ports/cc3200/mods/pybrtc.c
ports/cc3200/mods/pybrtc.c
+1
-1
ports/esp32/modnetwork.c
ports/esp32/modnetwork.c
+2
-2
ports/esp32/modsocket.c
ports/esp32/modsocket.c
+1
-1
ports/esp8266/modesp.c
ports/esp8266/modesp.c
+1
-1
ports/esp8266/modnetwork.c
ports/esp8266/modnetwork.c
+1
-1
ports/nrf/boards/microbit/modules/microbitdisplay.c
ports/nrf/boards/microbit/modules/microbitdisplay.c
+2
-2
ports/nrf/boards/microbit/modules/microbitimage.c
ports/nrf/boards/microbit/modules/microbitimage.c
+1
-1
ports/nrf/modules/machine/pin.c
ports/nrf/modules/machine/pin.c
+3
-3
ports/nrf/modules/machine/pwm.c
ports/nrf/modules/machine/pwm.c
+1
-1
ports/nrf/modules/machine/rtcounter.c
ports/nrf/modules/machine/rtcounter.c
+1
-1
ports/nrf/modules/machine/spi.c
ports/nrf/modules/machine/spi.c
+1
-1
ports/nrf/modules/machine/timer.c
ports/nrf/modules/machine/timer.c
+1
-1
ports/nrf/modules/music/modmusic.c
ports/nrf/modules/music/modmusic.c
+1
-1
ports/nrf/modules/ubluepy/ubluepy_characteristic.c
ports/nrf/modules/ubluepy/ubluepy_characteristic.c
+1
-1
ports/nrf/modules/ubluepy/ubluepy_peripheral.c
ports/nrf/modules/ubluepy/ubluepy_peripheral.c
+2
-2
ports/nrf/modules/ubluepy/ubluepy_service.c
ports/nrf/modules/ubluepy/ubluepy_service.c
+2
-2
ports/nrf/modules/ubluepy/ubluepy_uuid.c
ports/nrf/modules/ubluepy/ubluepy_uuid.c
+3
-3
ports/stm32/adc.c
ports/stm32/adc.c
+1
-1
ports/stm32/bufhelper.c
ports/stm32/bufhelper.c
+2
-2
ports/stm32/can.c
ports/stm32/can.c
+4
-4
ports/stm32/dac.c
ports/stm32/dac.c
+1
-1
ports/stm32/extint.c
ports/stm32/extint.c
+2
-2
ports/stm32/machine_i2c.c
ports/stm32/machine_i2c.c
+1
-1
ports/stm32/machine_uart.c
ports/stm32/machine_uart.c
+1
-1
ports/stm32/main.c
ports/stm32/main.c
+1
-1
ports/stm32/pin.c
ports/stm32/pin.c
+2
-2
ports/stm32/pyb_i2c.c
ports/stm32/pyb_i2c.c
+1
-1
ports/stm32/spi.c
ports/stm32/spi.c
+3
-3
ports/stm32/timer.c
ports/stm32/timer.c
+3
-3
ports/teensy/main.c
ports/teensy/main.c
+3
-3
ports/teensy/reg.c
ports/teensy/reg.c
+1
-1
ports/teensy/timer.c
ports/teensy/timer.c
+2
-2
ports/teensy/uart.c
ports/teensy/uart.c
+1
-1
ports/unix/coverage.c
ports/unix/coverage.c
+1
-1
ports/unix/file.c
ports/unix/file.c
+1
-1
ports/unix/modffi.c
ports/unix/modffi.c
+4
-4
ports/unix/modjni.c
ports/unix/modjni.c
+2
-2
ports/unix/modtermios.c
ports/unix/modtermios.c
+1
-1
ports/unix/moduselect.c
ports/unix/moduselect.c
+2
-2
ports/unix/modusocket.c
ports/unix/modusocket.c
+5
-5
ports/zephyr/machine_pin.c
ports/zephyr/machine_pin.c
+1
-1
未找到文件。
ports/cc3200/hal/cc3200_hal.c
浏览文件 @
6e30f96b
...
...
@@ -148,7 +148,7 @@ void mp_hal_stdout_tx_str(const char *str) {
void
mp_hal_stdout_tx_strn
(
const
char
*
str
,
size_t
len
)
{
if
(
MP_STATE_PORT
(
os_term_dup_obj
))
{
if
(
MP_OBJ_IS_TYPE
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
,
&
pyb_uart_type
))
{
if
(
mp_obj_is_type
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
,
&
pyb_uart_type
))
{
uart_tx_strn
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
,
str
,
len
);
}
else
{
MP_STATE_PORT
(
os_term_dup_obj
)
->
write
[
2
]
=
mp_obj_new_str_of_type
(
&
mp_type_str
,
(
const
byte
*
)
str
,
len
);
...
...
@@ -184,7 +184,7 @@ int mp_hal_stdin_rx_chr(void) {
if
(
telnet_rx_any
())
{
return
telnet_rx_char
();
}
else
if
(
MP_STATE_PORT
(
os_term_dup_obj
))
{
// then the stdio_dup
if
(
MP_OBJ_IS_TYPE
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
,
&
pyb_uart_type
))
{
if
(
mp_obj_is_type
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
,
&
pyb_uart_type
))
{
if
(
uart_rx_any
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
))
{
return
uart_rx_char
(
MP_STATE_PORT
(
os_term_dup_obj
)
->
stream_o
);
}
...
...
ports/cc3200/mods/modmachine.c
浏览文件 @
6e30f96b
...
...
@@ -122,7 +122,7 @@ STATIC mp_obj_t machine_unique_id(void) {
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
machine_unique_id_obj
,
machine_unique_id
);
STATIC
mp_obj_t
machine_main
(
mp_obj_t
main
)
{
if
(
MP_OBJ_IS_STR
(
main
))
{
if
(
mp_obj_is_str
(
main
))
{
MP_STATE_PORT
(
machine_config_main
)
=
main
;
}
else
{
mp_raise_ValueError
(
mpexception_value_invalid_arguments
);
...
...
ports/cc3200/mods/moduos.c
浏览文件 @
6e30f96b
...
...
@@ -133,7 +133,7 @@ STATIC mp_obj_t os_dupterm(uint n_args, const mp_obj_t *args) {
if
(
stream_o
==
mp_const_none
)
{
MP_STATE_PORT
(
os_term_dup_obj
)
=
MP_OBJ_NULL
;
}
else
{
if
(
!
MP_OBJ_IS_TYPE
(
stream_o
,
&
pyb_uart_type
))
{
if
(
!
mp_obj_is_type
(
stream_o
,
&
pyb_uart_type
))
{
// must be a stream-like object providing at least read and write methods
mp_load_method
(
stream_o
,
MP_QSTR_read
,
os_term_dup_obj
.
read
);
mp_load_method
(
stream_o
,
MP_QSTR_write
,
os_term_dup_obj
.
write
);
...
...
ports/cc3200/mods/modwlan.c
浏览文件 @
6e30f96b
...
...
@@ -1012,7 +1012,7 @@ STATIC mp_obj_t wlan_ifconfig(size_t n_args, const mp_obj_t *pos_args, mp_map_t
};
return
mp_obj_new_tuple
(
4
,
ifconfig
);
}
else
{
// set the configuration
if
(
MP_OBJ_IS_TYPE
(
args
[
1
].
u_obj
,
&
mp_type_tuple
))
{
if
(
mp_obj_is_type
(
args
[
1
].
u_obj
,
&
mp_type_tuple
))
{
// set a static ip
mp_obj_t
*
items
;
mp_obj_get_array_fixed_n
(
args
[
1
].
u_obj
,
4
,
&
items
);
...
...
ports/cc3200/mods/pybpin.c
浏览文件 @
6e30f96b
...
...
@@ -131,7 +131,7 @@ pin_obj_t *pin_find(mp_obj_t user_obj) {
pin_obj_t
*
pin_obj
;
// if a pin was provided, use it
if
(
MP_OBJ_IS_TYPE
(
user_obj
,
&
pin_type
))
{
if
(
mp_obj_is_type
(
user_obj
,
&
pin_type
))
{
pin_obj
=
user_obj
;
return
pin_obj
;
}
...
...
ports/cc3200/mods/pybrtc.c
浏览文件 @
6e30f96b
...
...
@@ -367,7 +367,7 @@ STATIC mp_obj_t pyb_rtc_alarm(size_t n_args, const mp_obj_t *pos_args, mp_map_t
uint32_t
f_seconds
;
uint16_t
f_mseconds
;
bool
repeat
=
args
[
2
].
u_bool
;
if
(
MP_OBJ_IS_TYPE
(
args
[
1
].
u_obj
,
&
mp_type_tuple
))
{
// datetime tuple given
if
(
mp_obj_is_type
(
args
[
1
].
u_obj
,
&
mp_type_tuple
))
{
// datetime tuple given
// repeat cannot be used with a datetime tuple
if
(
repeat
)
{
mp_raise_ValueError
(
mpexception_value_invalid_arguments
);
...
...
ports/esp32/modnetwork.c
浏览文件 @
6e30f96b
...
...
@@ -461,7 +461,7 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
return
mp_obj_new_tuple
(
4
,
tuple
);
}
else
{
// set
if
(
MP_OBJ_IS_TYPE
(
args
[
1
],
&
mp_type_tuple
)
||
MP_OBJ_IS_TYPE
(
args
[
1
],
&
mp_type_list
))
{
if
(
mp_obj_is_type
(
args
[
1
],
&
mp_type_tuple
)
||
mp_obj_is_type
(
args
[
1
],
&
mp_type_list
))
{
mp_obj_t
*
items
;
mp_obj_get_array_fixed_n
(
args
[
1
],
4
,
&
items
);
netutils_parse_ipv4_addr
(
items
[
0
],
(
void
*
)
&
info
.
ip
,
NETUTILS_BIG
);
...
...
@@ -518,7 +518,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
if
(
kwargs
->
used
!=
0
)
{
for
(
size_t
i
=
0
;
i
<
kwargs
->
alloc
;
i
++
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
kwargs
,
i
))
{
if
(
mp_map_slot_is_filled
(
kwargs
,
i
))
{
int
req_if
=
-
1
;
#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
...
...
ports/esp32/modsocket.c
浏览文件 @
6e30f96b
...
...
@@ -157,7 +157,7 @@ static int _socket_getaddrinfo2(const mp_obj_t host, const mp_obj_t portx, struc
};
mp_obj_t
port
=
portx
;
if
(
MP_OBJ_IS_SMALL_INT
(
port
))
{
if
(
mp_obj_is_small_int
(
port
))
{
// This is perverse, because lwip_getaddrinfo promptly converts it back to an int, but
// that's the API we have to work with ...
port
=
mp_obj_str_binary_op
(
MP_BINARY_OP_MODULO
,
mp_obj_new_str_via_qstr
(
"%s"
,
2
),
port
);
...
...
ports/esp8266/modesp.c
浏览文件 @
6e30f96b
...
...
@@ -87,7 +87,7 @@ STATIC mp_obj_t esp_flash_read(mp_obj_t offset_in, mp_obj_t len_or_buf_in) {
mp_int_t
len
;
byte
*
buf
;
bool
alloc_buf
=
MP_OBJ_IS_INT
(
len_or_buf_in
);
bool
alloc_buf
=
mp_obj_is_int
(
len_or_buf_in
);
if
(
alloc_buf
)
{
len
=
mp_obj_get_int
(
len_or_buf_in
);
...
...
ports/esp8266/modnetwork.c
浏览文件 @
6e30f96b
...
...
@@ -347,7 +347,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
if
(
kwargs
->
used
!=
0
)
{
for
(
mp_uint_t
i
=
0
;
i
<
kwargs
->
alloc
;
i
++
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
kwargs
,
i
))
{
if
(
mp_map_slot_is_filled
(
kwargs
,
i
))
{
#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
switch
((
uintptr_t
)
kwargs
->
table
[
i
].
key
)
{
case
QS
(
MP_QSTR_mac
):
{
...
...
ports/nrf/boards/microbit/modules/microbitdisplay.c
浏览文件 @
6e30f96b
...
...
@@ -88,7 +88,7 @@ mp_obj_t microbit_display_show_func(mp_uint_t n_args, const mp_obj_t *pos_args,
bool
wait
=
args
[
3
].
u_bool
;
bool
loop
=
args
[
4
].
u_bool
;
if
(
MP_OBJ_IS_STR
(
image
))
{
if
(
mp_obj_is_str
(
image
))
{
// arg is a string object
mp_uint_t
len
;
const
char
*
str
=
mp_obj_str_get_data
(
image
,
&
len
);
...
...
@@ -296,7 +296,7 @@ static void draw_object(mp_obj_t obj) {
}
}
else
if
(
mp_obj_get_type
(
obj
)
==
&
microbit_image_type
)
{
microbit_display_show
(
display
,
(
microbit_image_obj_t
*
)
obj
);
}
else
if
(
MP_OBJ_IS_STR
(
obj
))
{
}
else
if
(
mp_obj_is_str
(
obj
))
{
mp_uint_t
len
;
const
char
*
str
=
mp_obj_str_get_data
(
obj
,
&
len
);
if
(
len
==
1
)
{
...
...
ports/nrf/boards/microbit/modules/microbitimage.c
浏览文件 @
6e30f96b
...
...
@@ -214,7 +214,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
}
case
1
:
{
if
(
MP_OBJ_IS_STR
(
args
[
0
]))
{
if
(
mp_obj_is_str
(
args
[
0
]))
{
// arg is a string object
mp_uint_t
len
;
const
char
*
str
=
mp_obj_str_get_data
(
args
[
0
],
&
len
);
...
...
ports/nrf/modules/machine/pin.c
浏览文件 @
6e30f96b
...
...
@@ -126,7 +126,7 @@ void pin_init0(void) {
const
pin_obj_t
*
pin_find
(
mp_obj_t
user_obj
)
{
const
pin_obj_t
*
pin_obj
;
// If pin is SMALL_INT
if
(
MP_OBJ_IS_SMALL_INT
(
user_obj
))
{
if
(
mp_obj_is_small_int
(
user_obj
))
{
uint8_t
value
=
MP_OBJ_SMALL_INT_VALUE
(
user_obj
);
for
(
uint8_t
i
=
0
;
i
<
machine_pin_num_of_pins
;
i
++
)
{
if
(
machine_pin_obj
[
i
].
pin
==
value
)
{
...
...
@@ -136,7 +136,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
}
// If a pin was provided, then use it
if
(
MP_OBJ_IS_TYPE
(
user_obj
,
&
pin_type
))
{
if
(
mp_obj_is_type
(
user_obj
,
&
pin_type
))
{
pin_obj
=
user_obj
;
if
(
pin_class_debug
)
{
printf
(
"Pin map passed pin "
);
...
...
@@ -149,7 +149,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
if
(
MP_STATE_PORT
(
pin_class_mapper
)
!=
mp_const_none
)
{
pin_obj
=
mp_call_function_1
(
MP_STATE_PORT
(
pin_class_mapper
),
user_obj
);
if
(
pin_obj
!=
mp_const_none
)
{
if
(
!
MP_OBJ_IS_TYPE
(
pin_obj
,
&
pin_type
))
{
if
(
!
mp_obj_is_type
(
pin_obj
,
&
pin_type
))
{
mp_raise_ValueError
(
"Pin.mapper didn't return a Pin object"
);
}
if
(
pin_class_debug
)
{
...
...
ports/nrf/modules/machine/pwm.c
浏览文件 @
6e30f96b
...
...
@@ -93,7 +93,7 @@ void pwm_init0(void) {
STATIC
int
hard_pwm_find
(
mp_obj_t
id
)
{
if
(
MP_OBJ_IS_INT
(
id
))
{
if
(
mp_obj_is_int
(
id
))
{
// given an integer id
int
pwm_id
=
mp_obj_get_int
(
id
);
if
(
pwm_id
>=
0
&&
pwm_id
<
MP_ARRAY_SIZE
(
machine_hard_pwm_obj
))
{
...
...
ports/nrf/modules/machine/rtcounter.c
浏览文件 @
6e30f96b
...
...
@@ -159,7 +159,7 @@ STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, s
if
(
args
[
ARG_callback
].
u_obj
==
mp_const_none
)
{
config
->
callback
=
NULL
;
}
else
if
(
MP_OBJ_IS_FUN
(
args
[
ARG_callback
].
u_obj
))
{
}
else
if
(
mp_obj_is_fun
(
args
[
ARG_callback
].
u_obj
))
{
config
->
callback
=
args
[
ARG_callback
].
u_obj
;
}
else
{
mp_raise_ValueError
(
"callback must be a function"
);
...
...
ports/nrf/modules/machine/spi.c
浏览文件 @
6e30f96b
...
...
@@ -131,7 +131,7 @@ void spi_init0(void) {
}
STATIC
int
spi_find
(
mp_obj_t
id
)
{
if
(
MP_OBJ_IS_STR
(
id
))
{
if
(
mp_obj_is_str
(
id
))
{
// given a string id
const
char
*
port
=
mp_obj_str_get_str
(
id
);
if
(
0
)
{
...
...
ports/nrf/modules/machine/timer.c
浏览文件 @
6e30f96b
...
...
@@ -126,7 +126,7 @@ STATIC mp_obj_t machine_timer_make_new(const mp_obj_type_t *type, size_t n_args,
machine_timer_obj_t
*
self
=
(
machine_timer_obj_t
*
)
&
machine_timer_obj
[
timer_id
];
if
(
MP_OBJ_IS_FUN
(
args
[
ARG_callback
].
u_obj
))
{
if
(
mp_obj_is_fun
(
args
[
ARG_callback
].
u_obj
))
{
machine_timer_callbacks
[
timer_id
]
=
args
[
ARG_callback
].
u_obj
;
}
else
if
(
args
[
ARG_callback
].
u_obj
==
mp_const_none
)
{
machine_timer_callbacks
[
timer_id
]
=
NULL
;
...
...
ports/nrf/modules/music/modmusic.c
浏览文件 @
6e30f96b
...
...
@@ -320,7 +320,7 @@ STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_args,
// get either a single note or a list of notes
mp_uint_t
len
;
mp_obj_t
*
items
;
if
(
MP_OBJ_IS_STR_OR_BYTES
(
args
[
0
].
u_obj
))
{
if
(
mp_obj_is_str_or_bytes
(
args
[
0
].
u_obj
))
{
len
=
1
;
items
=
&
args
[
0
].
u_obj
;
}
else
{
...
...
ports/nrf/modules/ubluepy/ubluepy_characteristic.c
浏览文件 @
6e30f96b
...
...
@@ -59,7 +59,7 @@ STATIC mp_obj_t ubluepy_characteristic_make_new(const mp_obj_type_t *type, size_
return
MP_OBJ_FROM_PTR
(
s
);
}
if
(
MP_OBJ_IS_TYPE
(
uuid_obj
,
&
ubluepy_uuid_type
))
{
if
(
mp_obj_is_type
(
uuid_obj
,
&
ubluepy_uuid_type
))
{
s
->
p_uuid
=
MP_OBJ_TO_PTR
(
uuid_obj
);
// (void)sd_characterstic_add(s);
}
else
{
...
...
ports/nrf/modules/ubluepy/ubluepy_peripheral.c
浏览文件 @
6e30f96b
...
...
@@ -193,7 +193,7 @@ STATIC mp_obj_t peripheral_advertise(mp_uint_t n_args, const mp_obj_t *pos_args,
ubluepy_advertise_data_t
adv_data
;
memset
(
&
adv_data
,
0
,
sizeof
(
ubluepy_advertise_data_t
));
if
(
device_name_obj
!=
mp_const_none
&&
MP_OBJ_IS_STR
(
device_name_obj
))
{
if
(
device_name_obj
!=
mp_const_none
&&
mp_obj_is_str
(
device_name_obj
))
{
GET_STR_DATA_LEN
(
device_name_obj
,
str_data
,
str_len
);
adv_data
.
p_device_name
=
(
uint8_t
*
)
str_data
;
...
...
@@ -361,7 +361,7 @@ STATIC mp_obj_t peripheral_connect(mp_uint_t n_args, const mp_obj_t *pos_args, m
ble_drv_gap_event_handler_set
(
MP_OBJ_FROM_PTR
(
self
),
gap_event_handler
);
if
(
MP_OBJ_IS_STR
(
dev_addr
))
{
if
(
mp_obj_is_str
(
dev_addr
))
{
GET_STR_DATA_LEN
(
dev_addr
,
str_data
,
str_len
);
if
(
str_len
==
17
)
{
// Example "11:22:33:aa:bb:cc"
...
...
ports/nrf/modules/ubluepy/ubluepy_service.c
浏览文件 @
6e30f96b
...
...
@@ -61,7 +61,7 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg
return
MP_OBJ_FROM_PTR
(
s
);
}
if
(
MP_OBJ_IS_TYPE
(
uuid_obj
,
&
ubluepy_uuid_type
))
{
if
(
mp_obj_is_type
(
uuid_obj
,
&
ubluepy_uuid_type
))
{
s
->
p_uuid
=
MP_OBJ_TO_PTR
(
uuid_obj
);
uint8_t
type
=
args
[
ARG_NEW_TYPE
].
u_int
;
...
...
@@ -124,7 +124,7 @@ STATIC mp_obj_t service_get_characteristic(mp_obj_t self_in, mp_obj_t uuid) {
ubluepy_uuid_obj_t
*
p_uuid
=
MP_OBJ_TO_PTR
(
uuid
);
// validate that there is an UUID object passed in as parameter
if
(
!
(
MP_OBJ_IS_TYPE
(
uuid
,
&
ubluepy_uuid_type
)))
{
if
(
!
(
mp_obj_is_type
(
uuid
,
&
ubluepy_uuid_type
)))
{
mp_raise_ValueError
(
"Invalid UUID parameter"
);
}
...
...
ports/nrf/modules/ubluepy/ubluepy_uuid.c
浏览文件 @
6e30f96b
...
...
@@ -66,11 +66,11 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args,
return
MP_OBJ_FROM_PTR
(
s
);
}
if
(
MP_OBJ_IS_INT
(
uuid_obj
))
{
if
(
mp_obj_is_int
(
uuid_obj
))
{
s
->
type
=
UBLUEPY_UUID_16_BIT
;
s
->
value
[
1
]
=
(((
uint16_t
)
mp_obj_get_int
(
uuid_obj
))
>>
8
)
&
0xFF
;
s
->
value
[
0
]
=
((
uint8_t
)
mp_obj_get_int
(
uuid_obj
))
&
0xFF
;
}
else
if
(
MP_OBJ_IS_STR
(
uuid_obj
))
{
}
else
if
(
mp_obj_is_str
(
uuid_obj
))
{
GET_STR_DATA_LEN
(
uuid_obj
,
str_data
,
str_len
);
if
(
str_len
==
6
)
{
// Assume hex digit prefixed with 0x
s
->
type
=
UBLUEPY_UUID_16_BIT
;
...
...
@@ -124,7 +124,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args,
}
else
{
mp_raise_ValueError
(
"Invalid UUID string length"
);
}
}
else
if
(
MP_OBJ_IS_TYPE
(
uuid_obj
,
&
ubluepy_uuid_type
))
{
}
else
if
(
mp_obj_is_type
(
uuid_obj
,
&
ubluepy_uuid_type
))
{
// deep copy instance
ubluepy_uuid_obj_t
*
p_old
=
MP_OBJ_TO_PTR
(
uuid_obj
);
s
->
type
=
p_old
->
type
;
...
...
ports/stm32/adc.c
浏览文件 @
6e30f96b
...
...
@@ -395,7 +395,7 @@ STATIC mp_obj_t adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
uint32_t
channel
;
if
(
MP_OBJ_IS_INT
(
pin_obj
))
{
if
(
mp_obj_is_int
(
pin_obj
))
{
channel
=
adc_get_internal_channel
(
mp_obj_get_int
(
pin_obj
));
}
else
{
const
pin_obj_t
*
pin
=
pin_find
(
pin_obj
);
...
...
ports/stm32/bufhelper.c
浏览文件 @
6e30f96b
...
...
@@ -28,7 +28,7 @@
#include "bufhelper.h"
void
pyb_buf_get_for_send
(
mp_obj_t
o
,
mp_buffer_info_t
*
bufinfo
,
byte
*
tmp_data
)
{
if
(
MP_OBJ_IS_INT
(
o
))
{
if
(
mp_obj_is_int
(
o
))
{
tmp_data
[
0
]
=
mp_obj_get_int
(
o
);
bufinfo
->
buf
=
tmp_data
;
bufinfo
->
len
=
1
;
...
...
@@ -39,7 +39,7 @@ void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, byte *tmp_data)
}
mp_obj_t
pyb_buf_get_for_recv
(
mp_obj_t
o
,
vstr_t
*
vstr
)
{
if
(
MP_OBJ_IS_INT
(
o
))
{
if
(
mp_obj_is_int
(
o
))
{
// allocate a new bytearray of given length
vstr_init_len
(
vstr
,
mp_obj_get_int
(
o
));
return
MP_OBJ_NULL
;
...
...
ports/stm32/can.c
浏览文件 @
6e30f96b
...
...
@@ -409,7 +409,7 @@ STATIC mp_obj_t pyb_can_make_new(const mp_obj_type_t *type, size_t n_args, size_
// work out port
mp_uint_t
can_idx
;
if
(
MP_OBJ_IS_STR
(
args
[
0
]))
{
if
(
mp_obj_is_str
(
args
[
0
]))
{
const
char
*
port
=
mp_obj_str_get_str
(
args
[
0
]);
if
(
0
)
{
#ifdef MICROPY_HW_CAN1_NAME
...
...
@@ -540,7 +540,7 @@ STATIC mp_obj_t pyb_can_info(size_t n_args, const mp_obj_t *args) {
if
(
n_args
==
1
)
{
list
=
MP_OBJ_TO_PTR
(
mp_obj_new_list
(
8
,
NULL
));
}
else
{
if
(
!
MP_OBJ_IS_TYPE
(
args
[
1
],
&
mp_type_list
))
{
if
(
!
mp_obj_is_type
(
args
[
1
],
&
mp_type_list
))
{
mp_raise_TypeError
(
NULL
);
}
list
=
MP_OBJ_TO_PTR
(
args
[
1
]);
...
...
@@ -709,7 +709,7 @@ STATIC mp_obj_t pyb_can_recv(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
items
[
3
]
=
mp_obj_new_bytes
(
&
rx_msg
.
Data
[
0
],
rx_msg
.
DLC
);
}
else
{
// User should provide a list of length at least 4 to hold the values
if
(
!
MP_OBJ_IS_TYPE
(
ret_obj
,
&
mp_type_list
))
{
if
(
!
mp_obj_is_type
(
ret_obj
,
&
mp_type_list
))
{
mp_raise_TypeError
(
NULL
);
}
mp_obj_list_t
*
list
=
MP_OBJ_TO_PTR
(
ret_obj
);
...
...
@@ -719,7 +719,7 @@ STATIC mp_obj_t pyb_can_recv(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
items
=
list
->
items
;
// Fourth element must be a memoryview which we assume points to a
// byte-like array which is large enough, and then we resize it inplace
if
(
!
MP_OBJ_IS_TYPE
(
items
[
3
],
&
mp_type_memoryview
))
{
if
(
!
mp_obj_is_type
(
items
[
3
],
&
mp_type_memoryview
))
{
mp_raise_TypeError
(
NULL
);
}
mp_obj_array_t
*
mv
=
MP_OBJ_TO_PTR
(
items
[
3
]);
...
...
ports/stm32/dac.c
浏览文件 @
6e30f96b
...
...
@@ -238,7 +238,7 @@ STATIC mp_obj_t pyb_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_
// get pin/channel to output on
mp_int_t
dac_id
;
if
(
MP_OBJ_IS_INT
(
args
[
0
]))
{
if
(
mp_obj_is_int
(
args
[
0
]))
{
dac_id
=
mp_obj_get_int
(
args
[
0
]);
}
else
{
const
pin_obj_t
*
pin
=
pin_find
(
args
[
0
]);
...
...
ports/stm32/extint.c
浏览文件 @
6e30f96b
...
...
@@ -163,7 +163,7 @@ uint extint_register(mp_obj_t pin_obj, uint32_t mode, uint32_t pull, mp_obj_t ca
const
pin_obj_t
*
pin
=
NULL
;
uint
v_line
;
if
(
MP_OBJ_IS_INT
(
pin_obj
))
{
if
(
mp_obj_is_int
(
pin_obj
))
{
// If an integer is passed in, then use it to identify lines 16 thru 22
// We expect lines 0 thru 15 to be passed in as a pin, so that we can
// get both the port number and line number.
...
...
@@ -234,7 +234,7 @@ void extint_register_pin(const pin_obj_t *pin, uint32_t mode, bool hard_irq, mp_
// Check if the ExtInt line is already in use by another Pin/ExtInt
mp_obj_t
*
cb
=
&
MP_STATE_PORT
(
pyb_extint_callback
)[
line
];
if
(
*
cb
!=
mp_const_none
&&
MP_OBJ_FROM_PTR
(
pin
)
!=
pyb_extint_callback_arg
[
line
])
{
if
(
MP_OBJ_IS_SMALL_INT
(
pyb_extint_callback_arg
[
line
]))
{
if
(
mp_obj_is_small_int
(
pyb_extint_callback_arg
[
line
]))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_OSError
,
"ExtInt vector %d is already in use"
,
line
));
}
else
{
...
...
ports/stm32/machine_i2c.c
浏览文件 @
6e30f96b
...
...
@@ -197,7 +197,7 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
// work out i2c bus
int
i2c_id
=
0
;
if
(
MP_OBJ_IS_STR
(
args
[
ARG_id
].
u_obj
))
{
if
(
mp_obj_is_str
(
args
[
ARG_id
].
u_obj
))
{
const
char
*
port
=
mp_obj_str_get_str
(
args
[
ARG_id
].
u_obj
);
if
(
0
)
{
#ifdef MICROPY_HW_I2C1_NAME
...
...
ports/stm32/machine_uart.c
浏览文件 @
6e30f96b
...
...
@@ -350,7 +350,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
// work out port
int
uart_id
=
0
;
if
(
MP_OBJ_IS_STR
(
args
[
0
]))
{
if
(
mp_obj_is_str
(
args
[
0
]))
{
const
char
*
port
=
mp_obj_str_get_str
(
args
[
0
]);
if
(
0
)
{
#ifdef MICROPY_HW_UART1_NAME
...
...
ports/stm32/main.c
浏览文件 @
6e30f96b
...
...
@@ -132,7 +132,7 @@ STATIC mp_obj_t pyb_main(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
{
MP_QSTR_opt
,
MP_ARG_INT
,
{.
u_int
=
0
}
}
};
if
(
MP_OBJ_IS_STR
(
pos_args
[
0
]))
{
if
(
mp_obj_is_str
(
pos_args
[
0
]))
{
MP_STATE_PORT
(
pyb_config_main
)
=
pos_args
[
0
];
// parse args
...
...
ports/stm32/pin.c
浏览文件 @
6e30f96b
...
...
@@ -105,7 +105,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
const
pin_obj_t
*
pin_obj
;
// If a pin was provided, then use it
if
(
MP_OBJ_IS_TYPE
(
user_obj
,
&
pin_type
))
{
if
(
mp_obj_is_type
(
user_obj
,
&
pin_type
))
{
pin_obj
=
MP_OBJ_TO_PTR
(
user_obj
);
if
(
pin_class_debug
)
{
printf
(
"Pin map passed pin "
);
...
...
@@ -118,7 +118,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
if
(
MP_STATE_PORT
(
pin_class_mapper
)
!=
mp_const_none
)
{
mp_obj_t
o
=
mp_call_function_1
(
MP_STATE_PORT
(
pin_class_mapper
),
user_obj
);
if
(
o
!=
mp_const_none
)
{
if
(
!
MP_OBJ_IS_TYPE
(
o
,
&
pin_type
))
{
if
(
!
mp_obj_is_type
(
o
,
&
pin_type
))
{
mp_raise_ValueError
(
"Pin.mapper didn't return a Pin object"
);
}
if
(
pin_class_debug
)
{
...
...
ports/stm32/pyb_i2c.c
浏览文件 @
6e30f96b
...
...
@@ -636,7 +636,7 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
// work out i2c bus
int
i2c_id
=
0
;
if
(
MP_OBJ_IS_STR
(
args
[
0
]))
{
if
(
mp_obj_is_str
(
args
[
0
]))
{
const
char
*
port
=
mp_obj_str_get_str
(
args
[
0
]);
if
(
0
)
{
#ifdef MICROPY_HW_I2C1_NAME
...
...
ports/stm32/spi.c
浏览文件 @
6e30f96b
...
...
@@ -121,7 +121,7 @@ void spi_init0(void) {
}
int
spi_find_index
(
mp_obj_t
id
)
{
if
(
MP_OBJ_IS_STR
(
id
))
{
if
(
mp_obj_is_str
(
id
))
{
// given a string id
const
char
*
port
=
mp_obj_str_get_str
(
id
);
if
(
0
)
{
...
...
@@ -583,10 +583,10 @@ void spi_print(const mp_print_t *print, const spi_t *spi_obj, bool legacy) {
}
const
spi_t
*
spi_from_mp_obj
(
mp_obj_t
o
)
{
if
(
MP_OBJ_IS_TYPE
(
o
,
&
pyb_spi_type
))
{
if
(
mp_obj_is_type
(
o
,
&
pyb_spi_type
))
{
pyb_spi_obj_t
*
self
=
MP_OBJ_TO_PTR
(
o
);
return
self
->
spi
;
}
else
if
(
MP_OBJ_IS_TYPE
(
o
,
&
machine_hard_spi_type
))
{
}
else
if
(
mp_obj_is_type
(
o
,
&
machine_hard_spi_type
))
{
machine_hard_spi_obj_t
*
self
=
MP_OBJ_TO_PTR
(
o
);
return
self
->
spi
;
}
else
{
...
...
ports/stm32/timer.c
浏览文件 @
6e30f96b
...
...
@@ -275,7 +275,7 @@ STATIC uint32_t compute_prescaler_period_from_freq(pyb_timer_obj_t *self, mp_obj
uint32_t
period
;
if
(
0
)
{
#if MICROPY_PY_BUILTINS_FLOAT
}
else
if
(
MP_OBJ_IS_TYPE
(
freq_in
,
&
mp_type_float
))
{
}
else
if
(
mp_obj_is_type
(
freq_in
,
&
mp_type_float
))
{
float
freq
=
mp_obj_get_float
(
freq_in
);
if
(
freq
<=
0
)
{
goto
bad_freq
;
...
...
@@ -370,7 +370,7 @@ STATIC uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent
uint32_t
cmp
;
if
(
0
)
{
#if MICROPY_PY_BUILTINS_FLOAT
}
else
if
(
MP_OBJ_IS_TYPE
(
percent_in
,
&
mp_type_float
))
{
}
else
if
(
mp_obj_is_type
(
percent_in
,
&
mp_type_float
))
{
mp_float_t
percent
=
mp_obj_get_float
(
percent_in
);
if
(
percent
<=
0
.
0
)
{
cmp
=
0
;
...
...
@@ -988,7 +988,7 @@ STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *pos_args, mp_ma
mp_obj_t
pin_obj
=
args
[
2
].
u_obj
;
if
(
pin_obj
!=
mp_const_none
)
{
if
(
!
MP_OBJ_IS_TYPE
(
pin_obj
,
&
pin_type
))
{
if
(
!
mp_obj_is_type
(
pin_obj
,
&
pin_type
))
{
mp_raise_ValueError
(
"pin argument needs to be be a Pin type"
);
}
const
pin_obj_t
*
pin
=
MP_OBJ_TO_PTR
(
pin_obj
);
...
...
ports/teensy/main.c
浏览文件 @
6e30f96b
...
...
@@ -194,7 +194,7 @@ STATIC mp_obj_t pyb_config_main = MP_OBJ_NULL;
STATIC
mp_obj_t
pyb_config_usb_mode
=
MP_OBJ_NULL
;
mp_obj_t
pyb_source_dir
(
mp_obj_t
source_dir
)
{
if
(
MP_OBJ_IS_STR
(
source_dir
))
{
if
(
mp_obj_is_str
(
source_dir
))
{
pyb_config_source_dir
=
source_dir
;
}
return
mp_const_none
;
...
...
@@ -203,7 +203,7 @@ mp_obj_t pyb_source_dir(mp_obj_t source_dir) {
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_source_dir_obj
,
pyb_source_dir
);
mp_obj_t
pyb_main
(
mp_obj_t
main
)
{
if
(
MP_OBJ_IS_STR
(
main
))
{
if
(
mp_obj_is_str
(
main
))
{
pyb_config_main
=
main
;
}
return
mp_const_none
;
...
...
@@ -212,7 +212,7 @@ mp_obj_t pyb_main(mp_obj_t main) {
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_main_obj
,
pyb_main
);
STATIC
mp_obj_t
pyb_usb_mode
(
mp_obj_t
usb_mode
)
{
if
(
MP_OBJ_IS_STR
(
usb_mode
))
{
if
(
mp_obj_is_str
(
usb_mode
))
{
pyb_config_usb_mode
=
usb_mode
;
}
return
mp_const_none
;
...
...
ports/teensy/reg.c
浏览文件 @
6e30f96b
...
...
@@ -18,7 +18,7 @@ mp_obj_t reg_cmd(void *base, reg_t *reg, mp_uint_t num_regs, uint n_args, const
mp_uint_t
addr
=
0
;
if
(
MP_OBJ_IS_STR
(
args
[
0
]))
{
if
(
mp_obj_is_str
(
args
[
0
]))
{
const
char
*
name
=
mp_obj_str_get_str
(
args
[
0
]);
mp_uint_t
reg_idx
;
for
(
reg_idx
=
0
;
reg_idx
<
num_regs
;
reg_idx
++
,
reg
++
)
{
...
...
ports/teensy/timer.c
浏览文件 @
6e30f96b
...
...
@@ -142,7 +142,7 @@ STATIC uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent
uint32_t
cmp
;
if
(
0
)
{
#if MICROPY_PY_BUILTINS_FLOAT
}
else
if
(
MP_OBJ_IS_TYPE
(
percent_in
,
&
mp_type_float
))
{
}
else
if
(
mp_obj_is_type
(
percent_in
,
&
mp_type_float
))
{
float
percent
=
mp_obj_get_float
(
percent_in
);
if
(
percent
<=
0
.
0
)
{
cmp
=
0
;
...
...
@@ -496,7 +496,7 @@ STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *args, mp_map_t
mp_obj_t
pin_obj
=
vals
[
1
].
u_obj
;
if
(
pin_obj
!=
mp_const_none
)
{
if
(
!
MP_OBJ_IS_TYPE
(
pin_obj
,
&
pin_type
))
{
if
(
!
mp_obj_is_type
(
pin_obj
,
&
pin_type
))
{
mp_raise_ValueError
(
"pin argument needs to be be a Pin type"
);
}
const
pin_obj_t
*
pin
=
pin_obj
;
...
...
ports/teensy/uart.c
浏览文件 @
6e30f96b
...
...
@@ -316,7 +316,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, uint n_args, uint n
// work out port
o
->
uart_id
=
0
;
#if 0
if (
MP_OBJ_IS_STR
(args[0])) {
if (
mp_obj_is_str
(args[0])) {
const char *port = mp_obj_str_get_str(args[0]);
if (0) {
#if defined(PYBV10)
...
...
ports/unix/coverage.c
浏览文件 @
6e30f96b
...
...
@@ -250,7 +250,7 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf
(
&
mp_plat_print
,
"# str
\n
"
);
// intern string
mp_printf
(
&
mp_plat_print
,
"%d
\n
"
,
MP_OBJ_IS_QSTR
(
mp_obj_str_intern
(
mp_obj_new_str
(
"intern me"
,
9
))));
mp_printf
(
&
mp_plat_print
,
"%d
\n
"
,
mp_obj_is_qstr
(
mp_obj_str_intern
(
mp_obj_new_str
(
"intern me"
,
9
))));
}
// bytearray
...
...
ports/unix/file.c
浏览文件 @
6e30f96b
...
...
@@ -192,7 +192,7 @@ STATIC mp_obj_t fdfile_open(const mp_obj_type_t *type, mp_arg_val_t *args) {
mp_obj_t
fid
=
args
[
0
].
u_obj
;
if
(
MP_OBJ_IS_SMALL_INT
(
fid
))
{
if
(
mp_obj_is_small_int
(
fid
))
{
o
->
fd
=
MP_OBJ_SMALL_INT_VALUE
(
fid
);
return
MP_OBJ_FROM_PTR
(
o
);
}
...
...
ports/unix/modffi.c
浏览文件 @
6e30f96b
...
...
@@ -126,7 +126,7 @@ STATIC ffi_type *char2ffi_type(char c)
STATIC
ffi_type
*
get_ffi_type
(
mp_obj_t
o_in
)
{
if
(
MP_OBJ_IS_STR
(
o_in
))
{
if
(
mp_obj_is_str
(
o_in
))
{
const
char
*
s
=
mp_obj_str_get_str
(
o_in
);
ffi_type
*
t
=
char2ffi_type
(
*
s
);
if
(
t
!=
NULL
)
{
...
...
@@ -370,9 +370,9 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
#endif
}
else
if
(
a
==
mp_const_none
)
{
values
[
i
]
=
0
;
}
else
if
(
MP_OBJ_IS_INT
(
a
))
{
}
else
if
(
mp_obj_is_int
(
a
))
{
values
[
i
]
=
mp_obj_int_get_truncated
(
a
);
}
else
if
(
MP_OBJ_IS_STR
(
a
))
{
}
else
if
(
mp_obj_is_str
(
a
))
{
const
char
*
s
=
mp_obj_str_get_str
(
a
);
values
[
i
]
=
(
ffi_arg
)(
intptr_t
)
s
;
}
else
if
(((
mp_obj_base_t
*
)
MP_OBJ_TO_PTR
(
a
))
->
type
->
buffer_p
.
get_buffer
!=
NULL
)
{
...
...
@@ -383,7 +383,7 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
goto
error
;
}
values
[
i
]
=
(
ffi_arg
)(
intptr_t
)
bufinfo
.
buf
;
}
else
if
(
MP_OBJ_IS_TYPE
(
a
,
&
fficallback_type
))
{
}
else
if
(
mp_obj_is_type
(
a
,
&
fficallback_type
))
{
mp_obj_fficallback_t
*
p
=
MP_OBJ_TO_PTR
(
a
);
values
[
i
]
=
(
ffi_arg
)(
intptr_t
)
p
->
func
;
}
else
{
...
...
ports/unix/modjni.c
浏览文件 @
6e30f96b
...
...
@@ -658,12 +658,12 @@ STATIC mp_obj_t mod_jni_array(mp_obj_t type_in, mp_obj_t size_in) {
mp_int_t
size
=
mp_obj_get_int
(
size_in
);
jobject
res
=
NULL
;
if
(
MP_OBJ_IS_TYPE
(
type_in
,
&
jclass_type
))
{
if
(
mp_obj_is_type
(
type_in
,
&
jclass_type
))
{
mp_obj_jclass_t
*
jcls
=
MP_OBJ_TO_PTR
(
type_in
);
res
=
JJ
(
NewObjectArray
,
size
,
jcls
->
cls
,
NULL
);
}
else
if
(
MP_OBJ_IS_STR
(
type_in
))
{
}
else
if
(
mp_obj_is_str
(
type_in
))
{
const
char
*
type
=
mp_obj_str_get_str
(
type_in
);
switch
(
*
type
)
{
case
'Z'
:
...
...
ports/unix/modtermios.c
浏览文件 @
6e30f96b
...
...
@@ -77,7 +77,7 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t
when
=
TCSANOW
;
}
assert
(
MP_OBJ_IS_TYPE
(
attrs_in
,
&
mp_type_list
));
assert
(
mp_obj_is_type
(
attrs_in
,
&
mp_type_list
));
mp_obj_list_t
*
attrs
=
MP_OBJ_TO_PTR
(
attrs_in
);
term
.
c_iflag
=
mp_obj_get_int
(
attrs
->
items
[
0
]);
...
...
ports/unix/moduselect.c
浏览文件 @
6e30f96b
...
...
@@ -66,7 +66,7 @@ typedef struct _mp_obj_poll_t {
}
mp_obj_poll_t
;
STATIC
int
get_fd
(
mp_obj_t
fdlike
)
{
if
(
MP_OBJ_IS_OBJ
(
fdlike
))
{
if
(
mp_obj_is_obj
(
fdlike
))
{
const
mp_stream_p_t
*
stream_p
=
mp_get_stream_raise
(
fdlike
,
MP_STREAM_OP_IOCTL
);
int
err
;
mp_uint_t
res
=
stream_p
->
ioctl
(
fdlike
,
MP_STREAM_GET_FILENO
,
0
,
&
err
);
...
...
@@ -80,7 +80,7 @@ STATIC int get_fd(mp_obj_t fdlike) {
/// \method register(obj[, eventmask])
STATIC
mp_obj_t
poll_register
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_poll_t
*
self
=
MP_OBJ_TO_PTR
(
args
[
0
]);
bool
is_fd
=
MP_OBJ_IS_INT
(
args
[
1
]);
bool
is_fd
=
mp_obj_is_int
(
args
[
1
]);
int
fd
=
get_fd
(
args
[
1
]);
mp_uint_t
flags
;
...
...
ports/unix/modusocket.c
浏览文件 @
6e30f96b
...
...
@@ -299,7 +299,7 @@ STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) {
const
void
*
optval
;
socklen_t
optlen
;
int
val
;
if
(
MP_OBJ_IS_INT
(
args
[
3
]))
{
if
(
mp_obj_is_int
(
args
[
3
]))
{
val
=
mp_obj_int_get_truncated
(
args
[
3
]);
optval
=
&
val
;
optlen
=
sizeof
(
val
);
...
...
@@ -391,13 +391,13 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, siz
int
proto
=
0
;
if
(
n_args
>
0
)
{
assert
(
MP_OBJ_IS_SMALL_INT
(
args
[
0
]));
assert
(
mp_obj_is_small_int
(
args
[
0
]));
family
=
MP_OBJ_SMALL_INT_VALUE
(
args
[
0
]);
if
(
n_args
>
1
)
{
assert
(
MP_OBJ_IS_SMALL_INT
(
args
[
1
]));
assert
(
mp_obj_is_small_int
(
args
[
1
]));
type
=
MP_OBJ_SMALL_INT_VALUE
(
args
[
1
]);
if
(
n_args
>
2
)
{
assert
(
MP_OBJ_IS_SMALL_INT
(
args
[
2
]));
assert
(
mp_obj_is_small_int
(
args
[
2
]));
proto
=
MP_OBJ_SMALL_INT_VALUE
(
args
[
2
]);
}
}
...
...
@@ -494,7 +494,7 @@ STATIC mp_obj_t mod_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
memset
(
&
hints
,
0
,
sizeof
(
hints
));
// getaddrinfo accepts port in string notation, so however
// it may seem stupid, we need to convert int to str
if
(
MP_OBJ_IS_SMALL_INT
(
args
[
1
]))
{
if
(
mp_obj_is_small_int
(
args
[
1
]))
{
unsigned
port
=
(
unsigned
short
)
MP_OBJ_SMALL_INT_VALUE
(
args
[
1
]);
snprintf
(
buf
,
sizeof
(
buf
),
"%u"
,
port
);
serv
=
buf
;
...
...
ports/zephyr/machine_pin.c
浏览文件 @
6e30f96b
...
...
@@ -84,7 +84,7 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
MP_OBJ_FUN_ARGS_MAX
,
true
);
// get the wanted port
if
(
!
MP_OBJ_IS_TYPE
(
args
[
0
],
&
mp_type_tuple
))
{
if
(
!
mp_obj_is_type
(
args
[
0
],
&
mp_type_tuple
))
{
mp_raise_ValueError
(
"Pin id must be tuple of (
\"
GPIO_x
\"
, pin#)"
);
}
mp_obj_t
*
items
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录