Skip to content

Commit 9110896

Browse files
committed
Remove older import helpers, no longer used.
1 parent 630d851 commit 9110896

3 files changed

Lines changed: 0 additions & 65 deletions

File tree

py/lexerunix.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,4 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
3030
return mp_lexer_new_from_str_len(qstr_from_str(filename), data, size, size);
3131
}
3232

33-
/******************************************************************************/
34-
/* unix implementation of import */
35-
36-
// TODO properly!
37-
38-
static const char *import_base_dir = NULL;
39-
40-
void mp_import_set_directory(const char *dir) {
41-
import_base_dir = dir;
42-
}
43-
44-
mp_lexer_t *mp_import_open_file(qstr mod_name) {
45-
vstr_t *vstr = vstr_new();
46-
if (import_base_dir != NULL) {
47-
vstr_printf(vstr, "%s/", import_base_dir);
48-
}
49-
vstr_printf(vstr, "%s.py", qstr_str(mod_name));
50-
return mp_lexer_new_from_file(vstr_str(vstr)); // TODO does lexer need to copy the string? can we free it here?
51-
}
52-
5333
#endif // MICROPY_ENABLE_LEXER_UNIX

stm/lexerfatfs.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,3 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
5151
fb->pos = 0;
5252
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);
5353
}
54-
55-
/******************************************************************************/
56-
// implementation of import
57-
58-
#include "ff.h"
59-
60-
mp_lexer_t *mp_import_open_file(qstr mod_name) {
61-
vstr_t *vstr = vstr_new();
62-
FRESULT res;
63-
64-
// look for module in src/
65-
vstr_printf(vstr, "0:/src/%s.py", qstr_str(mod_name));
66-
res = f_stat(vstr_str(vstr), NULL);
67-
if (res == FR_OK) {
68-
// found file
69-
return mp_lexer_new_from_file(vstr_str(vstr)); // TODO does lexer need to copy the string? can we free it here?
70-
}
71-
72-
// look for module in /
73-
vstr_reset(vstr);
74-
vstr_printf(vstr, "0:/%s.py", qstr_str(mod_name));
75-
res = f_stat(vstr_str(vstr), NULL);
76-
if (res == FR_OK) {
77-
// found file
78-
return mp_lexer_new_from_file(vstr_str(vstr)); // TODO does lexer need to copy the string? can we free it here?
79-
}
80-
81-
// could not find file
82-
vstr_free(vstr);
83-
printf("import %s: could not find file in src/ or /\n", qstr_str(mod_name));
84-
85-
return NULL;
86-
}

unix/main.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,6 @@ static void do_repl(void) {
147147
}
148148

149149
static void do_file(const char *file) {
150-
// hack: set dir for import based on where this file is
151-
{
152-
const char * s = strrchr(file, '/');
153-
if (s != NULL) {
154-
int len = s - file;
155-
char *dir = m_new(char, len + 1);
156-
memcpy(dir, file, len);
157-
dir[len] = '\0';
158-
mp_import_set_directory(dir);
159-
}
160-
}
161-
162150
mp_lexer_t *lex = mp_lexer_new_from_file(file);
163151
execute_from_lexer(lex, MP_PARSE_FILE_INPUT, false);
164152
}

0 commit comments

Comments
 (0)