summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-05-21 20:32:59 +0100
committerDamien George <damien.p.george@gmail.com>2014-05-21 20:32:59 +0100
commit58ebde46646dd49d22b2accfa9c7a78e15921e48 (patch)
treebdb130a761309e138cd9d3ff60f4639c897a8808 /py
parentaa7cf6f72f4e8a553f892629bb3338ab8c982d57 (diff)
downloadmicropython-58ebde46646dd49d22b2accfa9c7a78e15921e48.tar.gz
micropython-58ebde46646dd49d22b2accfa9c7a78e15921e48.zip
Tidy up some configuration options.
MP_ALLOC_* -> MICROPY_ALLOC_* MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX MICROPY_EXTRA_* -> MICROPY_PORT_* See issue #35.
Diffstat (limited to 'py')
-rw-r--r--py/builtinimport.c2
-rw-r--r--py/builtintables.c4
-rw-r--r--py/compile.c6
-rw-r--r--py/lexer.c6
-rw-r--r--py/lexerunix.c4
-rw-r--r--py/mpconfig.h84
-rw-r--r--py/parse.c12
-rw-r--r--py/repl.c4
-rw-r--r--py/repl.h2
-rw-r--r--py/scope.c6
-rw-r--r--py/vm.c6
11 files changed, 71 insertions, 65 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index e758158a64..d2b18701b4 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -278,7 +278,7 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
DEBUG_printf("Module not yet loaded\n");
uint last = 0;
- VSTR_FIXED(path, MICROPY_PATH_MAX)
+ VSTR_FIXED(path, MICROPY_ALLOC_PATH_MAX)
module_obj = MP_OBJ_NULL;
mp_obj_t top_module_obj = MP_OBJ_NULL;
mp_obj_t outer_module_obj = MP_OBJ_NULL;
diff --git a/py/builtintables.c b/py/builtintables.c
index 133c14a269..d51c0198b2 100644
--- a/py/builtintables.c
+++ b/py/builtintables.c
@@ -140,7 +140,7 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
// TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation
// Extra builtins as defined by a port
- MICROPY_EXTRA_BUILTINS
+ MICROPY_PORT_BUILTINS
};
const mp_obj_dict_t mp_builtin_object_dict_obj = {
@@ -183,7 +183,7 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
#endif
// extra builtin modules as defined by a port
- MICROPY_EXTRA_BUILTIN_MODULES
+ MICROPY_PORT_BUILTIN_MODULES
};
const mp_obj_dict_t mp_builtin_module_dict_obj = {
diff --git a/py/compile.c b/py/compile.c
index cdd3a5b030..0c43d939e1 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -104,7 +104,7 @@ STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const cha
STATIC const mp_map_elem_t mp_constants_table[] = {
// Extra constants as defined by a port
- MICROPY_EXTRA_CONSTANTS
+ MICROPY_PORT_CONSTANTS
};
STATIC const mp_map_t mp_constants_map = {
@@ -119,7 +119,7 @@ STATIC const mp_map_t mp_constants_map = {
STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_map_t *consts) {
if (0) {
// dummy
-#if MICROPY_ENABLE_CONST
+#if MICROPY_COMP_CONST
} else if (MP_PARSE_NODE_IS_ID(pn)) {
// lookup identifier in table of dynamic constants
qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
@@ -133,7 +133,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
// fold some parse nodes before folding their arguments
switch (MP_PARSE_NODE_STRUCT_KIND(pns)) {
-#if MICROPY_ENABLE_CONST
+#if MICROPY_COMP_CONST
case PN_expr_stmt:
if (!MP_PARSE_NODE_IS_NULL(pns->nodes[1])) {
mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
diff --git a/py/lexer.c b/py/lexer.c
index e2dfea78c8..42f755ed98 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -218,8 +218,8 @@ STATIC void next_char(mp_lexer_t *lex) {
void indent_push(mp_lexer_t *lex, uint indent) {
if (lex->num_indent_level >= lex->alloc_indent_level) {
// TODO use m_renew_maybe and somehow indicate an error if it fails... probably by using MP_TOKEN_MEMORY_ERROR
- lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MP_ALLOC_LEXEL_INDENT_INC);
- lex->alloc_indent_level += MP_ALLOC_LEXEL_INDENT_INC;
+ lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC);
+ lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC;
}
lex->indent_level[lex->num_indent_level++] = indent;
}
@@ -731,7 +731,7 @@ mp_lexer_t *mp_lexer_new(qstr src_name, void *stream_data, mp_lexer_stream_next_
lex->column = 1;
lex->emit_dent = 0;
lex->nested_bracket_level = 0;
- lex->alloc_indent_level = MP_ALLOC_LEXER_INDENT_INIT;
+ lex->alloc_indent_level = MICROPY_ALLOC_LEXER_INDENT_INIT;
lex->num_indent_level = 1;
lex->indent_level = m_new_maybe(uint16_t, lex->alloc_indent_level);
vstr_init(&lex->vstr, 32);
diff --git a/py/lexerunix.c b/py/lexerunix.c
index 4631cacaf7..89dc80b004 100644
--- a/py/lexerunix.c
+++ b/py/lexerunix.c
@@ -27,7 +27,7 @@
#include "misc.h"
#include "mpconfig.h"
-#if MICROPY_ENABLE_LEXER_UNIX
+#if MICROPY_HELPER_LEXER_UNIX
#include <stdio.h>
#include <unistd.h>
@@ -81,4 +81,4 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
return mp_lexer_new(qstr_from_str(filename), fb, (mp_lexer_stream_next_char_t)file_buf_next_char, (mp_lexer_stream_close_t)file_buf_close);
}
-#endif // MICROPY_ENABLE_LEXER_UNIX
+#endif // MICROPY_HELPER_LEXER_UNIX
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 445fc78b04..5104f39721 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -37,43 +37,49 @@
/* Memory allocation policy */
// Initial amount for lexer indentation level
-#ifndef MP_ALLOC_LEXER_INDENT_INIT
-#define MP_ALLOC_LEXER_INDENT_INIT (10)
+#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
+#define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
#endif
// Increment for lexer indentation level
-#ifndef MP_ALLOC_LEXEL_INDENT_INC
-#define MP_ALLOC_LEXEL_INDENT_INC (8)
+#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
+#define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
#endif
// Initial amount for parse rule stack
-#ifndef MP_ALLOC_PARSE_RULE_INIT
-#define MP_ALLOC_PARSE_RULE_INIT (64)
+#ifndef MICROPY_ALLOC_PARSE_RULE_INIT
+#define MICROPY_ALLOC_PARSE_RULE_INIT (64)
#endif
// Increment for parse rule stack
-#ifndef MP_ALLOC_PARSE_RULE_INC
-#define MP_ALLOC_PARSE_RULE_INC (16)
+#ifndef MICROPY_ALLOC_PARSE_RULE_INC
+#define MICROPY_ALLOC_PARSE_RULE_INC (16)
#endif
// Initial amount for parse result stack
-#ifndef MP_ALLOC_PARSE_RESULT_INIT
-#define MP_ALLOC_PARSE_RESULT_INIT (32)
+#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
+#define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
#endif
// Increment for parse result stack
-#ifndef MP_ALLOC_PARSE_RESULT_INC
-#define MP_ALLOC_PARSE_RESULT_INC (16)
+#ifndef MICROPY_ALLOC_PARSE_RESULT_INC
+#define MICROPY_ALLOC_PARSE_RESULT_INC (16)
#endif
// Initial amount for ids in a scope
-#ifndef MP_ALLOC_SCOPE_ID_INIT
-#define MP_ALLOC_SCOPE_ID_INIT (4)
+#ifndef MICROPY_ALLOC_SCOPE_ID_INIT
+#define MICROPY_ALLOC_SCOPE_ID_INIT (4)
#endif
// Increment for ids in a scope
-#ifndef MP_ALLOC_SCOPE_ID_INC
-#define MP_ALLOC_SCOPE_ID_INC (6)
+#ifndef MICROPY_ALLOC_SCOPE_ID_INC
+#define MICROPY_ALLOC_SCOPE_ID_INC (6)
+#endif
+
+// Maximum length of a path in the filesystem
+// So we can allocate a buffer on the stack for path manipulation in import
+#ifndef MICROPY_ALLOC_PATH_MAX
+#define MICROPY_ALLOC_PATH_MAX (512)
#endif
/*****************************************************************************/
@@ -101,6 +107,14 @@
#endif
/*****************************************************************************/
+/* Compiler configuration */
+
+// Whether to enable constant optimisation; id = const(value)
+#ifndef MICROPY_COMP_CONST
+#define MICROPY_COMP_CONST (1)
+#endif
+
+/*****************************************************************************/
/* Internal debugging stuff */
// Whether to collect memory allocation stats
@@ -119,11 +133,6 @@
/*****************************************************************************/
/* Fine control over Python features */
-// Whether to enable constant optimisation; id = const(value)
-#ifndef MICROPY_ENABLE_CONST
-#define MICROPY_ENABLE_CONST (1)
-#endif
-
// Whether to include the garbage collector
#ifndef MICROPY_ENABLE_GC
#define MICROPY_ENABLE_GC (0)
@@ -135,13 +144,13 @@
#endif
// Whether to include REPL helper function
-#ifndef MICROPY_ENABLE_REPL_HELPERS
-#define MICROPY_ENABLE_REPL_HELPERS (0)
+#ifndef MICROPY_HELPER_REPL
+#define MICROPY_HELPER_REPL (0)
#endif
// Whether to include lexer helper function for unix
-#ifndef MICROPY_ENABLE_LEXER_UNIX
-#define MICROPY_ENABLE_LEXER_UNIX (0)
+#ifndef MICROPY_HELPER_LEXER_UNIX
+#define MICROPY_HELPER_LEXER_UNIX (0)
#endif
// Long int implementation
@@ -277,12 +286,6 @@ typedef double mp_float_t;
#define MICROPY_CPYTHON_COMPAT (1)
#endif
-// Maximum length of a path in the filesystem
-// So we can allocate a buffer on the stack for path manipulation in import
-#ifndef MICROPY_PATH_MAX
-#define MICROPY_PATH_MAX (512)
-#endif
-
// Whether POSIX-semantics non-blocking streams are supported
#ifndef MICROPY_STREAMS_NON_BLOCK
#define MICROPY_STREAMS_NON_BLOCK (0)
@@ -290,23 +293,26 @@ typedef double mp_float_t;
// Whether to use computed gotos in the VM, or a switch
// Computed gotos are roughly 10% faster, and increase VM code size by a little
-#ifndef MICROPY_USE_COMPUTED_GOTO
-#define MICROPY_USE_COMPUTED_GOTO (0)
+#ifndef MICROPY_OPT_COMPUTED_GOTO
+#define MICROPY_OPT_COMPUTED_GOTO (0)
#endif
+/*****************************************************************************/
+/* Hooks for a port to add builtins */
+
// Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
-#ifndef MICROPY_EXTRA_BUILTINS
-#define MICROPY_EXTRA_BUILTINS
+#ifndef MICROPY_PORT_BUILTINS
+#define MICROPY_PORT_BUILTINS
#endif
// Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
-#ifndef MICROPY_EXTRA_BUILTIN_MODULES
-#define MICROPY_EXTRA_BUILTIN_MODULES
+#ifndef MICROPY_PORT_BUILTIN_MODULES
+#define MICROPY_PORT_BUILTIN_MODULES
#endif
// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
-#ifndef MICROPY_EXTRA_CONSTANTS
-#define MICROPY_EXTRA_CONSTANTS
+#ifndef MICROPY_PORT_CONSTANTS
+#define MICROPY_PORT_CONSTANTS
#endif
/*****************************************************************************/
diff --git a/py/parse.c b/py/parse.c
index f5efd7a4f4..4bc78f14a9 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -134,13 +134,13 @@ STATIC void push_rule(parser_t *parser, int src_line, const rule_t *rule, int ar
return;
}
if (parser->rule_stack_top >= parser->rule_stack_alloc) {
- rule_stack_t *rs = m_renew_maybe(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MP_ALLOC_PARSE_RULE_INC);
+ rule_stack_t *rs = m_renew_maybe(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC);
if (rs == NULL) {
memory_error(parser);
return;
}
parser->rule_stack = rs;
- parser->rule_stack_alloc += MP_ALLOC_PARSE_RULE_INC;
+ parser->rule_stack_alloc += MICROPY_ALLOC_PARSE_RULE_INC;
}
rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++];
rs->src_line = src_line;
@@ -263,13 +263,13 @@ STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
return;
}
if (parser->result_stack_top >= parser->result_stack_alloc) {
- mp_parse_node_t *pn = m_renew_maybe(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MP_ALLOC_PARSE_RESULT_INC);
+ mp_parse_node_t *pn = m_renew_maybe(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC);
if (pn == NULL) {
memory_error(parser);
return;
}
parser->result_stack = pn;
- parser->result_stack_alloc += MP_ALLOC_PARSE_RESULT_INC;
+ parser->result_stack_alloc += MICROPY_ALLOC_PARSE_RESULT_INC;
}
parser->result_stack[parser->result_stack_top++] = pn;
}
@@ -350,11 +350,11 @@ mp_parse_node_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_p
parser.had_memory_error = false;
- parser.rule_stack_alloc = MP_ALLOC_PARSE_RULE_INIT;
+ parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT;
parser.rule_stack_top = 0;
parser.rule_stack = m_new_maybe(rule_stack_t, parser.rule_stack_alloc);
- parser.result_stack_alloc = MP_ALLOC_PARSE_RESULT_INIT;
+ parser.result_stack_alloc = MICROPY_ALLOC_PARSE_RESULT_INIT;
parser.result_stack_top = 0;
parser.result_stack = m_new_maybe(mp_parse_node_t, parser.result_stack_alloc);
diff --git a/py/repl.c b/py/repl.c
index 4aff80018c..457ce165b7 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -28,7 +28,7 @@
#include "mpconfig.h"
#include "repl.h"
-#if MICROPY_ENABLE_REPL_HELPERS
+#if MICROPY_HELPER_REPL
bool str_startswith_word(const char *str, const char *head) {
int i;
@@ -107,4 +107,4 @@ bool mp_repl_continue_with_input(const char *input) {
return false;
}
-#endif // MICROPY_ENABLE_REPL_HELPERS
+#endif // MICROPY_HELPER_REPL
diff --git a/py/repl.h b/py/repl.h
index 36acfc321e..92688f9f9a 100644
--- a/py/repl.h
+++ b/py/repl.h
@@ -24,6 +24,6 @@
* THE SOFTWARE.
*/
-#if MICROPY_ENABLE_REPL_HELPERS
+#if MICROPY_HELPER_REPL
bool mp_repl_continue_with_input(const char *input);
#endif
diff --git a/py/scope.c b/py/scope.c
index ab29af78ab..839e8216c1 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -71,7 +71,7 @@ scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, uint
}
scope->raw_code = mp_emit_glue_new_raw_code();
scope->emit_options = emit_options;
- scope->id_info_alloc = MP_ALLOC_SCOPE_ID_INIT;
+ scope->id_info_alloc = MICROPY_ALLOC_SCOPE_ID_INIT;
scope->id_info = m_new(id_info_t, scope->id_info_alloc);
return scope;
@@ -92,8 +92,8 @@ id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added) {
// make sure we have enough memory
if (scope->id_info_len >= scope->id_info_alloc) {
- scope->id_info = m_renew(id_info_t, scope->id_info, scope->id_info_alloc, scope->id_info_alloc + MP_ALLOC_SCOPE_ID_INC);
- scope->id_info_alloc += MP_ALLOC_SCOPE_ID_INC;
+ scope->id_info = m_renew(id_info_t, scope->id_info, scope->id_info_alloc, scope->id_info_alloc + MICROPY_ALLOC_SCOPE_ID_INC);
+ scope->id_info_alloc += MICROPY_ALLOC_SCOPE_ID_INC;
}
// add new id to end of array of all ids; this seems to match CPython
diff --git a/py/vm.c b/py/vm.c
index 123f520280..ee2ec23607 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -222,7 +222,7 @@ mp_vm_return_kind_t mp_execute_bytecode2(const byte *code_info, const byte **ip_
mp_obj_t *fastn, mp_obj_t **sp_in_out,
mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out,
volatile mp_obj_t inject_exc) {
-#if MICROPY_USE_COMPUTED_GOTO
+#if MICROPY_OPT_COMPUTED_GOTO
#include "vmentrytable.h"
#define DISPATCH() do { \
TRACE(ip); \
@@ -276,7 +276,7 @@ outer_dispatch_loop:
// loop to execute byte code
for (;;) {
dispatch_loop:
-#if MICROPY_USE_COMPUTED_GOTO
+#if MICROPY_OPT_COMPUTED_GOTO
DISPATCH();
#else
TRACE(ip);
@@ -982,7 +982,7 @@ yield:
fastn[0] = obj1;
return MP_VM_RETURN_EXCEPTION;
-#if !MICROPY_USE_COMPUTED_GOTO
+#if !MICROPY_OPT_COMPUTED_GOTO
} // switch
#endif
} // for loop