summaryrefslogtreecommitdiff
path: root/unix/lexerunix.c
diff options
context:
space:
mode:
authorDamien <damien.p.george@gmail.com>2013-12-21 18:17:45 +0000
committerDamien <damien.p.george@gmail.com>2013-12-21 18:17:45 +0000
commitd99b05282d14ceb0163cbcd059aa37bdb415af43 (patch)
tree978135f9fe83d3c4d5b3c95f84cb104c0092936a /unix/lexerunix.c
parente2880aa2fdc75298df487df7519d483acb03959c (diff)
Change object representation from 1 big union to individual structs.
A big change. Micro Python objects are allocated as individual structs with the first element being a pointer to the type information (which is itself an object). This scheme follows CPython. Much more flexible, not necessarily slower, uses same heap memory, and can allocate objects statically. Also change name prefix, from py_ to mp_ (mp for Micro Python).
Diffstat (limited to 'unix/lexerunix.c')
-rw-r--r--unix/lexerunix.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/unix/lexerunix.c b/unix/lexerunix.c
index e76d7f2c2..ac07781b5 100644
--- a/unix/lexerunix.c
+++ b/unix/lexerunix.c
@@ -17,7 +17,7 @@ unichar str_buf_next_char(str_buf_t *sb) {
if (sb->src_cur < sb->src_end) {
return *sb->src_cur++;
} else {
- return PY_LEXER_CHAR_EOF;
+ return MP_LEXER_CHAR_EOF;
}
}
@@ -30,16 +30,16 @@ void str_buf_free(str_buf_t *sb) {
}
}
-py_lexer_t *py_lexer_new_from_str_len(const char *src_name, const char *str, uint len, bool free_str) {
+mp_lexer_t *mp_lexer_new_from_str_len(const char *src_name, const char *str, uint len, bool free_str) {
str_buf_t *sb = m_new(str_buf_t, 1);
sb->free = free_str;
sb->src_beg = str;
sb->src_cur = str;
sb->src_end = str + len;
- return py_lexer_new(src_name, sb, (py_lexer_stream_next_char_t)str_buf_next_char, (py_lexer_stream_close_t)str_buf_free);
+ return mp_lexer_new(src_name, sb, (mp_lexer_stream_next_char_t)str_buf_next_char, (mp_lexer_stream_close_t)str_buf_free);
}
-py_lexer_t *py_lexer_new_from_file(const char *filename) {
+mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
int fd = open(filename, O_RDONLY);
if (fd < 0) {
printf("cannot open file %s\n", filename);
@@ -51,5 +51,5 @@ py_lexer_t *py_lexer_new_from_file(const char *filename) {
read(fd, data, size);
close(fd);
- return py_lexer_new_from_str_len(filename, data, size, true);
+ return mp_lexer_new_from_str_len(filename, data, size, true);
}