Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
91108960
Commit
91108960
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
Remove older import helpers, no longer used.
parent
630d8512
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/lexerunix.c
+0
-20
0 additions, 20 deletions
py/lexerunix.c
stm/lexerfatfs.c
+0
-33
0 additions, 33 deletions
stm/lexerfatfs.c
unix/main.c
+0
-12
0 additions, 12 deletions
unix/main.c
with
0 additions
and
65 deletions
py/lexerunix.c
+
0
−
20
View file @
91108960
...
...
@@ -30,24 +30,4 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
return
mp_lexer_new_from_str_len
(
qstr_from_str
(
filename
),
data
,
size
,
size
);
}
/******************************************************************************/
/* unix implementation of import */
// TODO properly!
static
const
char
*
import_base_dir
=
NULL
;
void
mp_import_set_directory
(
const
char
*
dir
)
{
import_base_dir
=
dir
;
}
mp_lexer_t
*
mp_import_open_file
(
qstr
mod_name
)
{
vstr_t
*
vstr
=
vstr_new
();
if
(
import_base_dir
!=
NULL
)
{
vstr_printf
(
vstr
,
"%s/"
,
import_base_dir
);
}
vstr_printf
(
vstr
,
"%s.py"
,
qstr_str
(
mod_name
));
return
mp_lexer_new_from_file
(
vstr_str
(
vstr
));
// TODO does lexer need to copy the string? can we free it here?
}
#endif // MICROPY_ENABLE_LEXER_UNIX
This diff is collapsed.
Click to expand it.
stm/lexerfatfs.c
+
0
−
33
View file @
91108960
...
...
@@ -51,36 +51,3 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
fb
->
pos
=
0
;
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
);
}
/******************************************************************************/
// implementation of import
#include
"ff.h"
mp_lexer_t
*
mp_import_open_file
(
qstr
mod_name
)
{
vstr_t
*
vstr
=
vstr_new
();
FRESULT
res
;
// look for module in src/
vstr_printf
(
vstr
,
"0:/src/%s.py"
,
qstr_str
(
mod_name
));
res
=
f_stat
(
vstr_str
(
vstr
),
NULL
);
if
(
res
==
FR_OK
)
{
// found file
return
mp_lexer_new_from_file
(
vstr_str
(
vstr
));
// TODO does lexer need to copy the string? can we free it here?
}
// look for module in /
vstr_reset
(
vstr
);
vstr_printf
(
vstr
,
"0:/%s.py"
,
qstr_str
(
mod_name
));
res
=
f_stat
(
vstr_str
(
vstr
),
NULL
);
if
(
res
==
FR_OK
)
{
// found file
return
mp_lexer_new_from_file
(
vstr_str
(
vstr
));
// TODO does lexer need to copy the string? can we free it here?
}
// could not find file
vstr_free
(
vstr
);
printf
(
"import %s: could not find file in src/ or /
\n
"
,
qstr_str
(
mod_name
));
return
NULL
;
}
This diff is collapsed.
Click to expand it.
unix/main.c
+
0
−
12
View file @
91108960
...
...
@@ -147,18 +147,6 @@ static void do_repl(void) {
}
static
void
do_file
(
const
char
*
file
)
{
// hack: set dir for import based on where this file is
{
const
char
*
s
=
strrchr
(
file
,
'/'
);
if
(
s
!=
NULL
)
{
int
len
=
s
-
file
;
char
*
dir
=
m_new
(
char
,
len
+
1
);
memcpy
(
dir
,
file
,
len
);
dir
[
len
]
=
'\0'
;
mp_import_set_directory
(
dir
);
}
}
mp_lexer_t
*
lex
=
mp_lexer_new_from_file
(
file
);
execute_from_lexer
(
lex
,
MP_PARSE_FILE_INPUT
,
false
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment