Merge branch 'master' of github.com:xbe/micropython

This commit is contained in:
Damien George 2014-03-17 10:31:03 +00:00
commit c44115f831
63 changed files with 36 additions and 123 deletions

View File

@ -1,4 +1,3 @@
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>

View File

@ -1,4 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>

View File

@ -1,8 +1,4 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,9 +1,4 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,7 +1,6 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>

View File

@ -1,4 +1,3 @@
#include <stdint.h>
#include <math.h>
#include "misc.h"

View File

@ -1,4 +1,3 @@
#include <stdint.h>
#include "misc.h"
#include "mpconfig.h"

View File

@ -1,5 +1,4 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View File

@ -1,5 +1,4 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View File

@ -1,7 +1,5 @@
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "misc.h"

View File

@ -1,5 +1,4 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View File

@ -1,5 +1,3 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View File

@ -16,8 +16,7 @@
// for x in l[0:8]: can be compiled into a native loop if l has pointer type
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View File

@ -1,8 +1,5 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "misc.h"

View File

@ -13,7 +13,6 @@
***********************************************************************/
#include <stdint.h>
#include <stdlib.h>
#include "mpconfig.h"

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "mpconfig.h"

View File

@ -1,9 +1,9 @@
/* lexer.c -- simple tokeniser for Python implementation
*/
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "misc.h"

View File

@ -1,5 +1,3 @@
#include <stdint.h>
#include <stdio.h>
#include "misc.h"
#include "mpconfig.h"

View File

@ -1,4 +1,3 @@
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
@ -11,6 +10,9 @@
#if MICROPY_ENABLE_LEXER_UNIX
#include <sys/stat.h>
#include <sys/types.h>
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
int fd = open(filename, O_RDONLY);
if (fd < 0) {

View File

@ -1,3 +1,4 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -1,6 +1,4 @@
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include "misc.h"
#include "mpconfig.h"

View File

@ -1,8 +1,5 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,7 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,7 +1,4 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,6 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,7 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>

View File

@ -1,4 +1,3 @@
#include <stdlib.h>
#include <assert.h>
#include "misc.h"

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>

View File

@ -1,4 +1,3 @@
#include <stdlib.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,5 +1,5 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,7 +1,5 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,7 +1,5 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>

View File

@ -1,4 +1,3 @@
#include <stdlib.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
@ -286,8 +284,8 @@ STATIC mp_obj_t str_find(uint n_args, const mp_obj_t *args) {
GET_STR_DATA_LEN(args[0], haystack, haystack_len);
GET_STR_DATA_LEN(args[1], needle, needle_len);
size_t start = 0;
size_t end = haystack_len;
machine_uint_t start = 0;
machine_uint_t end = haystack_len;
/* TODO use a non-exception-throwing mp_get_index */
if (n_args >= 3 && args[2] != mp_const_none) {
start = mp_get_index(&str_type, haystack_len, args[2], true);
@ -320,8 +318,8 @@ STATIC mp_obj_t str_startswith(mp_obj_t self_in, mp_obj_t arg) {
return MP_BOOL(memcmp(str, prefix, prefix_len) == 0);
}
STATIC bool chr_in_str(const byte* const str, const size_t str_len, int c) {
for (size_t i = 0; i < str_len; i++) {
STATIC bool chr_in_str(const byte* const str, const machine_uint_t str_len, int c) {
for (machine_uint_t i = 0; i < str_len; i++) {
if (str[i] == c) {
return true;
}
@ -349,10 +347,10 @@ STATIC mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
GET_STR_DATA_LEN(args[0], orig_str, orig_str_len);
size_t first_good_char_pos = 0;
machine_uint_t first_good_char_pos = 0;
bool first_good_char_pos_set = false;
size_t last_good_char_pos = 0;
for (size_t i = 0; i < orig_str_len; i++) {
machine_uint_t last_good_char_pos = 0;
for (machine_uint_t i = 0; i < orig_str_len; i++) {
if (!chr_in_str(chars_to_del, chars_to_del_len, orig_str[i])) {
last_good_char_pos = i;
if (!first_good_char_pos_set) {
@ -369,7 +367,7 @@ STATIC mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
assert(last_good_char_pos >= first_good_char_pos);
//+1 to accomodate the last character
size_t stripped_len = last_good_char_pos - first_good_char_pos + 1;
machine_uint_t stripped_len = last_good_char_pos - first_good_char_pos + 1;
return mp_obj_new_str(orig_str + first_good_char_pos, stripped_len, false);
}

View File

@ -1,6 +1,4 @@
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>

View File

@ -1,9 +1,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include "misc.h"

View File

@ -1,3 +1,4 @@
#include <stdbool.h>
#include <stdlib.h>
#include "misc.h"

View File

@ -2,8 +2,6 @@
// mp_xxx functions are safer and can be called by anyone
// note that rt_assign_xxx are called only from emit*, and maybe we can rename them to reflect this
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

View File

@ -1,6 +1,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "misc.h"

View File

@ -1,7 +1,5 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,7 +1,4 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "misc.h"

View File

@ -1,4 +1,4 @@
#include <string.h>
#include <unistd.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,7 +1,4 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "nlr.h"

View File

@ -1,3 +1,4 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

View File

@ -1,7 +1,8 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "nlr.h"
#include "misc.h"

View File

@ -1,4 +1,3 @@
#include <stdint.h>
#include <stdio.h>
#include "misc.h"

View File

@ -1,8 +1,11 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "nlr.h"
#include "misc.h"
@ -391,8 +394,6 @@ int main(int argc, char **argv) {
return 0;
}
#include <sys/stat.h>
uint mp_import_stat(const char *path) {
struct stat st;
if (stat(path, &st) == 0) {

View File

@ -2,7 +2,10 @@
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>

View File

@ -1,3 +1,4 @@
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>