Paul Sokolovsky
9e29666bf9
py: Implement proper separation between io.FileIO and io.TextIOWrapper.
...
io.FileIO is binary I/O, ans actually optional. Default file type is
io.TextIOWrapper, which provides str results. CPython3 explicitly describes
io.TextIOWrapper as buffered I/O, but we don't have buffering support yet
anyway.
2014-05-19 21:56:07 +03:00
Paul Sokolovsky
767e45c290
modos: Clean 64-bit issues.
2014-05-15 18:38:54 +03:00
Paul Sokolovsky
0c124c3123
unix: Add "_os" module with stat().
...
stat() is bad function to use using FFI, because its ABI is largely private.
To start with, Glibc .so doesn't even have "stat" symbol. Then, layout of
struct stat is too implementation-dependent. So, introduce _os to deal
with stat() and other similar cases.
2014-05-14 22:08:45 +03:00
Damien George
f6e430f77f
Merge pull request #600 from stinos/unix-exitcode
...
unix: Use standard return codes for main
2014-05-13 22:39:35 +01:00
Paul Sokolovsky
da9f0924ef
py, unix: Add copyright for modules I worked closely on.
2014-05-13 18:41:25 +03:00
Damien George
cc97446ca5
unix: Implement -O option to turn off __debug__ flag.
2014-05-12 23:14:52 +01:00
Damien George
96f137b24a
py: Rename BYTE_CODE to BYTECODE (this was missed in previous rename).
2014-05-12 22:35:37 +01:00
stijn
f42dbb98d1
unix: Fix linker errors when time/ffi modules are disabled
...
When disabling these via mpconfigport.mk or on the commandline,
the correspoding build options are not set and the sources are not
built so the modules should not be added to the
MICROPY_EXTRA_BUILTIN_MODULES list since they are undefined.
2014-05-13 00:03:24 +03:00
Antonin ENFRUN
da1fffaa09
Fix some unused variables, and silence a clang warning about initialization override in vmentrytable.h
2014-05-12 09:06:18 +02:00
Antonin ENFRUN
ceac71f1f5
unix: Add asm statements needed to read registers with clang. Code generated by gcc 4.9.0 is unchanged (same statements, different order).
...
Both are inefficient, saving unmodified registers on the stack.
2014-05-12 09:06:18 +02:00
Antonin ENFRUN
6caae0bcb1
unix: Create __bss_start and _end symbols for Mach-O targets.
...
It's a hack, but can't find a cleaner way to do it.
2014-05-12 00:13:10 +02:00
stijn
9e040b7cd8
unix: Use standard return codes for main
...
As in the CPython manual: "Unix programs generally use 2 for
command line syntax errors and 1 for all other kind of errors"
2014-05-11 19:23:30 +02:00
Damien George
89755ae67f
py: Rename MICROPY_SYS_EXIT to MICROPY_MOD_SYS_EXIT.
...
For consistency with MICROPY_MOD_SYS_STDFILES, etc.
2014-05-11 17:35:43 +01:00
Damien George
bd651d1a67
Merge pull request #597 from stinos/mingw-compilation
...
mingw: Fix compilation issues
2014-05-11 15:06:26 +01:00
Paul Sokolovsky
deaeaac469
modsys: Enable sys.exit() per port after all.
2014-05-10 17:26:47 +03:00
Paul Sokolovsky
d99e9083cb
modsys, unix: Add sys.exit(), should be implemented by a port.
2014-05-10 16:56:21 +03:00
Paul Sokolovsky
d80e2476c7
py: Disable frozenset by default, enable on unix.
...
Takes 416 text bytes on x86.
2014-05-10 16:56:20 +03:00
stijn
f45a83d7fc
mingw: Fix compilation issues
...
- use lowercase windows.h
- fix for mingw32 using preprocessor-unfriendly definition of CLOCKS_PER_SEC
2014-05-10 10:42:40 +02:00
stijn
5ed284a15e
windows: Add modtime implementation
2014-05-09 13:58:15 +02:00
Damien George
7c6c843965
unix: Add missing stdio.h header for readline.
2014-05-07 15:33:15 +01:00
Dave Hylands
117c46d9eb
Add input command for unix
2014-05-07 07:19:51 -07:00
Paul Sokolovsky
0ef015b253
stream: Make non-blcoking stream support configurable.
...
Enable only on unix. To avoid unpleasant surprises with error codes.
2014-05-07 02:25:45 +03:00
Paul Sokolovsky
6c62e7257f
unix modsocket: Add comments re: recv() vs read(), etc. semantics.
2014-05-07 02:17:14 +03:00
Paul Sokolovsky
f9e54e0ea5
modgc: Add new module for GC-related functionality.
2014-05-06 02:28:49 +03:00
Paul Sokolovsky
6b344d7816
py, unix: Add -v option, print bytecode dump if used.
...
This will work if MICROPY_DEBUG_PRINTERS is defined, which is only for
unix/windows ports. This makes it convenient to user uPy normally, but
easily get bytecode dump on the spot if needed, without constant recompiles
back and forth.
TODO: Add more useful debug output, adjust verbosity level on which
specifically bytecode dump happens.
2014-05-05 00:57:00 +03:00
Damien George
c327c0de5d
unix: Remove test class and code.
2014-05-04 12:24:26 +01:00
Damien George
04b9147e15
Add license header to (almost) all files.
...
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Damien George
d5f5b2f766
py, stream: Implement readlines for a stream.
2014-05-03 22:01:32 +01:00
Damien George
6ec835dfef
Don't print git hash as well as git tag in banner.
2014-05-03 19:08:02 +01:00
Damien George
1549f17038
Merge branch 'master' of github.com:micropython/micropython
2014-05-03 19:02:47 +01:00
Damien George
977a0ce287
py: Print tag/version/git describe in uPy banner.
2014-05-03 19:02:14 +01:00
Paul Sokolovsky
fb9ca7c3aa
Merge pull request #554 from stinos/mingw-realpath
...
mingw: Add implementation of realpath()
2014-05-03 21:01:34 +03:00
Damien George
e69b7e8288
unix, file.c: adhere to coding conventions.
2014-05-03 17:04:31 +01:00
stijn
4cd21deebc
mingw: Add implementation of realpath()
...
The mingw port used _fullpath() until now, but the behaviour is not exactly
the same as realpath()'s on unix; major difference being that it doesn't
return an error for non-existing files, which would bypass main's error
checking and bail out without any error message.
Also realpath() will return forward slashes only since main() relies on that.
2014-05-03 17:38:08 +02:00
stijn
a89e93e050
CPython compatibility: raise an error for operations on a closed file descriptor
...
In CPython any operations on a file that has been closed already reaises
a ValueError with message "I/O operation on closed file"
2014-05-03 14:05:56 +02:00
Paul Sokolovsky
9b71b16a94
unix,stmhal: Make "mpconfig.h" be first included, as other headers depend on it.
2014-05-02 18:08:16 +03:00
Paul Sokolovsky
f54bcbf099
py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
...
Specifically, nlr.h does.
2014-05-02 17:48:40 +03:00
Paul Sokolovsky
1f85d6255d
py: Add tentative scheme for error messages configuration.
2014-05-01 01:50:35 +03:00
Paul Sokolovsky
27f5bdd6d4
py: "read" & "write" are so common that make them core.
...
Few other strings move to core, but make depend on "io" module.
2014-04-26 21:15:56 +03:00
Damien George
6d3c5e4301
Add ARRAY_SIZE macro, and use it where possible.
2014-04-26 10:47:29 +01:00
Paul Sokolovsky
12a9cfed76
modsocket: Make .send() support arbitrary objects with buffer interface.
...
This is CPython-compliant (except that CPython doesn't support buffer
protocol for str).
2014-04-26 05:54:22 +03:00
Paul Sokolovsky
fa6f0506c1
unix: Workaround MP_OBJ_NEW_SMALL_INT() 64-bit issues.
2014-04-22 00:16:46 +03:00
Paul Sokolovsky
5d3a830171
modsocket: Clean up OSError-like exception a bit.
...
Some BSD socket functions don't return error numbers in errno namespace, but
rather in other error namespaces. CPython resolves this by using OSError
subclasses for them. We don't do that so far, so there's ambiguity here.
2014-04-22 00:02:51 +03:00
Paul Sokolovsky
acb13886fc
unix: OSError's args[0] should be errno numeric value.
...
Well, Python3 also defines an attribute for that, but that's bloat.
2014-04-22 00:02:51 +03:00
Paul Sokolovsky
b418b6fb0d
modffi: Don't use OSError for clearly unrelated errors.
2014-04-22 00:02:51 +03:00
Paul Sokolovsky
88972b0d94
modffi: Describe typecodes where they differ from used by struct module.
...
Exact behavior of typecodes may be not yet enforced.
2014-04-22 00:02:51 +03:00
Damien George
c7d2b10b85
Merge pull request #513 from errordeveloper/misc_fix/modffi_pkg_config
...
modffi: Fix how we call `pkg-config`
2014-04-21 01:22:27 +01:00
Paul Sokolovsky
a196d08dfc
unix windows: mingw32 doesn't have realpath(), use _fullpath() instead.
2014-04-20 22:24:44 +03:00
Paul Sokolovsky
1f2ca1c1f9
unix file: mingw32 has STDIN_FILENO and friends in stdio.h .
...
TODO: Never "optimize" includes any more!
2014-04-20 22:24:44 +03:00
Paul Sokolovsky
b76fd842f0
unix mem_info(): Dump GC info only if it's enabled.
2014-04-20 22:24:43 +03:00
Paul Sokolovsky
9fd02e186d
modsocket: Add setblocking() method.
2014-04-20 13:08:33 +03:00
Ilya Dmitrichenko
8e998ed280
modffi: Fix how we call `pkg-config`
2014-04-20 09:30:46 +01:00
Paul Sokolovsky
9ae0912496
modffi: Update for MP_OBJ_STOP_ITERATION refactor.
2014-04-19 20:05:47 +03:00
Paul Sokolovsky
752d2080b7
modffi: Mark 'p' type spec deprecated, replace with 'P'.
...
'p' in struct module is "pascal string". 'P' is void*.
2014-04-19 03:18:14 +03:00
Damien George
b11b85adaa
py: Allow to pass buffer protocol flags to get_buffer helper funcs.
2014-04-18 22:59:24 +01:00
Damien George
738bdeb73a
unix: Update to use new buffer protocol interface with typecode.
2014-04-18 22:31:24 +01:00
Damien George
5b65f0c7d3
py: Rename USE_COMPUTED_GOTOS to USE_COMPUTED_GOTO and enable on stmhal.
...
On stmhal, computed gotos make the binary about 1k bigger, but makes it
run faster, and we have the room, so why not. All tests pass on
pyboard using computed gotos.
2014-04-17 23:24:13 +01:00
Paul Sokolovsky
4abaa1b12b
unix modffi: Convert to static module structures.
2014-04-18 00:05:27 +03:00
Paul Sokolovsky
e1e4249a67
unix modsocket: Convert to static module structures.
2014-04-17 20:34:04 +03:00
Paul Sokolovsky
59a2f4828d
unix: Make mem_info() dump GC info too.
...
mem_info() is already pretty hacky, let it be more hacky.
2014-04-17 20:27:01 +03:00
Paul Sokolovsky
eb2fc9787a
unix modtime: Convert to static module structures.
2014-04-17 20:27:01 +03:00
Paul Sokolovsky
de8292202e
unix modtime: Adhere to MICROPY_ENABLE_FLOAT better.
2014-04-17 20:27:00 +03:00
Damien George
d553be5982
build: Simplify build directory layout by putting all headers in genhdr.
...
Any generated headers go in $(BUILD)/genhdr/, and are #included as
'genhdr/xxx.h'.
2014-04-17 18:03:27 +01:00
Damien George
2d1f865d16
Merge branch 'relocatable-build-dir' of github.com:lurch/micropython into lurch-relocatable-build-dir
2014-04-17 17:44:52 +01:00
Damien George
594d0ddbb2
Merge pull request #505 from lurch/patch-5
...
Add 'test' target to unix/Makefile
2014-04-17 17:24:42 +01:00
Damien George
5f82b50324
Merge branch 'master' of github.com:micropython/micropython
2014-04-17 17:11:58 +01:00
Damien George
dbdfee15a1
py: Add cmath module, for complex math. Disabled by default.
...
Not all functions implemented. Not enabled on pyboard.
2014-04-17 17:11:03 +01:00
Paul Sokolovsky
f200c30d53
modffi: Support float types.
2014-04-17 03:38:45 +03:00
Andrew Scheller
e02b77bf6b
Updated the envvar used by ./run-tests
...
As discussed in #504
2014-04-17 01:26:25 +01:00
Andrew Scheller
70a7d7a943
build directory can now be renamed
...
The autogenerated header files have been moved about, and an extra
include dir has been added, which means you can give a custom
BUILD=newbuilddir option to make, and everything "just works"
Also tidied up the way the different Makefiles build their include-
directory flags
2014-04-16 22:16:28 +01:00
Andrew Scheller
d5ce916f26
Add 'test' target to unix/Makefile
...
In conjunction with #504 this allows you to do things like:
```shell
make -C unix clean && make -C unix test CC=gcc-4.7
```
all from the top-level micropython directory :-)
Something similar could probably be done for windows/Makefile too, but I don't have a cygwin setup to test with.
2014-04-16 20:38:16 +01:00
Andrew Scheller
571d5a3363
New config option MICROPY_FORCE_32BIT (defaulted to 0)
...
Makes it easier for 64-bit unix hosts to build 32-bit unix
binaries (for testing)
2014-04-16 01:46:01 +01:00
AZ Huang
9309d9982f
Move entry_table to separated header file.
2014-04-15 17:08:42 +08:00
Damien George
3bb8bd899b
Make USE_COMPUTED_GOTO a config option in mpconfig.h.
...
Disabled by default. Enabled in unix port.
2014-04-14 21:20:30 +01:00
AZ Huang
b1f692e82e
Use computed goto instead of switching op-codes.
2014-04-15 02:40:28 +08:00
Damien George
777b0f32f4
py: Add property object, with basic functionality.
...
Enabled by MICROPY_ENABLE_PROPERTY.
2014-04-13 18:59:45 +01:00
Paul Sokolovsky
4165cd1c0c
stmhal: Update for static mod sys.
2014-04-13 07:02:57 +03:00
Paul Sokolovsky
a3e50eacca
py: Move sys attribute qstrs's to core.
2014-04-13 07:02:57 +03:00
Paul Sokolovsky
5500cdeec7
py, unix: Convert sys module to static representation.
2014-04-13 07:02:56 +03:00
Paul Sokolovsky
9a092831f7
unix: Enable modffi by default.
...
ffi is needed to use micropython-lib, so let's have it enabled by default,
then folks who have troubles with libffi can disable it, instead of everyone
doing manual actions again and again.
2014-04-13 00:01:40 +03:00
xbe
a36a55d2cf
unix: Update comment in gccollect.c
2014-04-11 06:42:17 -07:00
Paul Sokolovsky
263853ef84
modffi: Update for latest binary API refactors.
2014-04-11 05:17:41 +03:00
Damien George
f22626ee4f
unix: Add option to only compile, and not execute code.
2014-04-10 11:30:35 +01:00
Paul Sokolovsky
3aa8ee7c9e
py: Add mp_get_buffer(), mp_get_buffer_raise() convenience functions to API.
2014-04-09 01:07:37 +03:00
Paul Sokolovsky
f898a95cba
unix modffi: Support any object implementing buffer protocol as a native arg.
2014-04-08 19:08:34 +03:00
Damien George
72cfc6ef0a
unix: Oops, remove nlr_jump test in main.
2014-04-08 15:10:21 +01:00
Damien George
26cf55ae05
Add a check for NULL nlr_top in nlr_jump.
...
If no nlr_buf has been pushed, and an nlr_jump is called, then control
is transferred to nlr_jump_fail (which should bail out with a fatal
error).
2014-04-08 14:08:14 +00:00
Damien George
97790455fe
Improve REPL detecting when input needs to continue.
...
Full CPython compatibility with this requires actually parsing the
input so far collected, and if it fails parsing due to lack of tokens,
then continue collecting input. It's not worth doing it this way. Not
having compatibility at this level does not hurt the goals of Micro
Python.
2014-04-08 11:04:29 +00:00
Paul Sokolovsky
72d70cb045
unix, stmhal: Consistently use "FileIO" as class name for file objects.
...
They correspond to io.FileIO in io module hierarchy (with small caveat
that io.FileIO is raw file and works with bytes, not strings).
2014-04-08 04:08:16 +03:00
Paul Sokolovsky
b8cf948550
unix, windows: There's no "help" builtin.
2014-04-08 04:07:02 +03:00
Damien George
6827f9fc55
Add uPy welcome message to UNIX and Windows ports; update Teensy port.
...
Partly addresses issue #154 .
2014-04-07 13:27:50 +01:00
Damien George
65cad12d38
py: Add option to compiler to specify default code emitter.
...
Also add command line option to unix port to select emitter.
2014-04-06 11:48:15 +01:00
Damien George
27e735fd18
py: Replace stream_p with *stream_p in mp_obj_type_t.
...
This is to reduce ROM usage. stream_p is used in file and socket types
only (at the moment), so seems a good idea to make the protocol
functions a pointer instead of the actual structure.
It saves 308 bytes of ROM in the stmhal/ port, 928 in unix/.
2014-04-05 23:02:23 +01:00
Damien George
7efc5b3f34
py: Make globals and locals proper dictionary objects.
...
Finishes addressing issue #424 .
In the end this was a very neat refactor that now makes things a lot
more consistent across the py code base. It allowed some
simplifications in certain places, now that everything is a dict object.
Also converted builtins tables to dictionaries. This will be useful
when we need to turn builtins into a proper module.
2014-04-05 22:36:42 +01:00
Damien George
12bab72d93
Improve GC finalisation code; add option to disable it.
2014-04-05 20:35:48 +01:00
Damien George
ea13f407a3
py: Change nlr_jump to nlr_raise, to aid in debugging.
...
This does not affect code size or performance when debugging turned off.
To address issue #420 .
2014-04-05 18:32:08 +01:00
Paul Sokolovsky
c39368427c
unix: Rename module sources per latest naming conventions (mod*.c).
2014-04-04 20:34:10 +03:00
Paul Sokolovsky
cd31d826bf
unix: Use STATIC modifier to enable code size analysis via map file.
2014-04-04 20:34:02 +03:00
Paul Sokolovsky
70193b2b4c
unix: Routines related to terminal reading should use system malloc.
...
Otherwise we have mixup between system and GC alloc.
2014-04-04 17:50:02 +03:00
Damien George
bd17e1b3ae
unix: Allocate more heap memory by default on 64 bit machines.
...
Pointers are 2x bigger on 64 bit machines, so we should allocate twice
the memory to have a comparable heap size.
2014-04-04 14:29:00 +01:00
Damien George
4b34c76fd6
Changes to get unix/ port compiling on Cygwin.
2014-04-03 23:51:16 +01:00
Paul Sokolovsky
c61ce96590
unix file: Implement context manager protocol (for "with" statement).
2014-04-03 22:09:05 +03:00
Paul Sokolovsky
78e8e30c87
unix: Enable GC.
...
GC support for "unix" port was implemented some time ago, but still not
enabled.
2014-04-02 20:57:19 +03:00
Paul Sokolovsky
d440dc0513
unix: Use argv[0] for command name in usage.
2014-04-02 20:31:18 +03:00
Paul Sokolovsky
a55a5469c3
unix: Support #if-able impl-specific cmdline options.
...
For example, we still build w/o GC enabled, so cannot really set heap size.
2014-04-02 20:29:18 +03:00
Paul Sokolovsky
d4e7e06d7f
unix: Properly recognize and report when script on cmdline not found.
...
Previosuly just silently exited.
2014-04-02 20:25:01 +03:00
Damien George
15d18069c5
py: Remove old "run time" functions that were 1 liners.
2014-03-31 16:28:13 +01:00
Damien George
df6567e634
Merge map.h into obj.h.
...
Pretty much everyone needs to include map.h, since it's such an integral
part of the Micro Python object implementation. Thus, the definitions
are now in obj.h instead. map.h is removed.
2014-03-30 13:54:02 +01:00
Damien George
d17926db71
Rename rt_* to mp_*.
...
Mostly just a global search and replace. Except rt_is_true which
becomes mp_obj_is_true.
Still would like to tidy up some of the names, but this will do for now.
2014-03-30 13:35:08 +01:00
Damien George
918638ec6e
unix: Fix ffi.c to compile with latest changes to API.
2014-03-29 13:48:32 +00:00
Damien George
3e1a5c10c5
py: Rename old const type objects to mp_type_* for consistency.
2014-03-29 13:43:38 +00:00
Damien George
9b196cddab
Remove mp_obj_type_t.methods entry and use .locals_dict instead.
...
Originally, .methods was used for methods in a ROM class, and
locals_dict for methods in a user-created class. That distinction is
unnecessary, and we can use locals_dict for ROM classes now that we have
ROMable maps.
This removes an entry in the bloated mp_obj_type_t struct, saving a word
for each ROM object and each RAM object. ROM objects that have a
methods table (now a locals_dict) need an extra word in total (removed
the methods pointer (1 word), no longer need the sentinel (2 words), but
now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a
word because they never used the methods entry.
Overall the ROM usage is down by a few hundred bytes, and RAM usage is
down 1 word per user-defined type/class.
There is less code (no need to check 2 tables), and now consistent with
the way ROM modules have their tables initialised.
Efficiency is very close to equivaluent.
2014-03-26 21:47:19 +00:00
Damien George
c12b2213c1
Change mp_method_t.name from const char * to qstr.
...
Addresses issue #377 .
2014-03-26 20:15:40 +00:00
xbe
c93a22197b
unix: Clean up includes.
...
Remove unnecessary includes. Add includes that improve portability.
2014-03-16 12:14:15 -07:00
Damien George
5e34909a12
unix: Make usage info reflect actual usage of -X option.
2014-03-08 19:04:47 +00:00
Damien George
0c36da0b59
Implement ROMable modules. Add math module.
...
mp_module_obj_t can now be put in ROM.
Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.
math module has basic math functions. For STM port, these are not yet
implemented (they are just stub functions).
2014-03-08 15:24:39 +00:00
Damien George
635927bbce
unix: Add to usage print-out telling about -X option.
2014-03-04 08:39:47 +00:00
Paul Sokolovsky
a374d9c860
unix: Allow to set heap size using "-X heapsize=N" option.
2014-03-04 10:56:52 +08:00
Paul Sokolovsky
61f9b1c621
unix: Add GC support for ARM architecture.
2014-03-03 11:35:45 +08:00
Paul Sokolovsky
793838a919
MICROPY_USE_READLINE: Selects link lib, so should be defined in mpconfigport.mk
...
This change allows to build unix version without libreadline installed.
2014-02-28 11:09:29 +02:00
Damien George
ce1162ab15
GC: Fix printf formats for debugging; add gc_dump_alloc_table.
2014-02-26 22:55:59 +00:00
Damien George
438c88dd2f
Add arbitrary precision integer support.
...
Some functionality is still missing (eg and, or, bit shift), and some
things are buggy (eg subtract).
2014-02-22 19:25:23 +00:00
Paul Sokolovsky
44739e280e
Make DEBUG_printf() a proper function, implementation is port-dependent.
...
In particular, unix outputs to stderr, to allow to run testsuite against
micropython built with debug output (by redirecting stderr to /dev/null).
2014-02-16 18:20:49 +02:00
Damien George
c5966128c7
Implement proper exception type hierarchy.
...
Each built-in exception is now a type, with base type BaseException.
C exceptions are created by passing a pointer to the exception type to
make an instance of. When raising an exception from the VM, an
instance is created automatically if an exception type is raised (as
opposed to an exception instance).
Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper.
Handling of parse error changed to match new exceptions.
mp_const_type renamed to mp_type_type for consistency.
2014-02-15 16:10:44 +00:00
Damien George
a71c83a1d1
Change mp_obj_type_t.name from const char * to qstr.
...
Ultimately all static strings should be qstr. This entry in the type
structure is only used for printing error messages (to tell the type of
the bad argument), and printing objects that don't supply a .print method.
2014-02-15 11:34:50 +00:00
Damien George
9307ef46ca
Merge pull request #291 from GordonMcGregor/osx_build
...
OS X compatible -map syntax for LDFLAGS
2014-02-14 23:08:29 +00:00
Damien George
7ef098000a
Merge pull request #288 from pfalcon/port-builtins
...
Allow ports to define statically builtin functions.
2014-02-14 23:05:50 +00:00
Gordon McGregor
3890ec48e7
OS X compatible -map syntax for LDFLAGS
2014-02-14 16:38:05 -06:00
Paul Sokolovsky
8bc3516389
ffi: Implement ffivar.get()/set() methods.
...
Done by introducing another factored out helper API in binary.c. This API
can be reused also by array and struct modules.
2014-02-14 20:38:35 +02:00
Paul Sokolovsky
910843e86d
Allow ports to define statically builtin functions.
...
Convert unix open() to such.
2014-02-14 12:13:34 +02:00
Paul Sokolovsky
5be1b2873b
unix Makefile: Split off optimization options to COPT variable.
...
To allow easily try different optimization and configuration options
without patching any files.
2014-02-12 20:20:39 +02:00
Damien George
323f39a2b3
Merge pull request #278 from pfalcon/unix-gc
...
Enable GC for Unix port
2014-02-11 21:42:09 +00:00
Paul Sokolovsky
723a6ed371
More GC debugging improvements.
2014-02-11 18:09:50 +02:00
Paul Sokolovsky
e7db8171d8
unix: Implement garbage collection support.
2014-02-11 16:20:02 +02:00
Paul Sokolovsky
287d9620fc
Enable link map file generation.
2014-02-11 14:42:20 +02:00
Paul Sokolovsky
a075741c90
Rename str_join -> strjoin to make it not clash with objstr's one.
2014-02-11 14:39:10 +02:00
Damien George
d46ca25757
Fix some int casting that failed on 64 bit architecture.
2014-02-10 21:46:47 +00:00
Paul Sokolovsky
2e24ee8d80
socket: Tighten up int-to-str conversion.
2014-02-10 18:39:10 +02:00
Paul Sokolovsky
8c25201d9d
socket: Make sure that symbol definitions are const.
2014-02-10 18:39:06 +02:00
Paul Sokolovsky
f766264582
unix: Implement time.sleep().
2014-02-09 12:52:04 +02:00
Paul Sokolovsky
557c9d5264
unix microsocket: Add dummy makefile() method.
...
Unlike CPython socket, microsocket object already implements stream protocol
(read/write methods), so makefile() just returns object itself. TODO: this
doesn't take care of arguments CPython's makefile() may accept.
2014-02-08 22:00:20 +02:00
Paul Sokolovsky
21c51f0bde
ffi: Fix mp_obj_str_get_data() return type.
2014-02-08 22:00:15 +02:00
Paul Sokolovsky
1e19b24ea0
io.File, socket types: Add fileno() method.
...
Implementation is duplicated, but tolerate this for now, because there's
no clear idea how to de-dup it.
2014-02-08 21:20:32 +02:00
Paul Sokolovsky
9945f33886
Rename "rawsocket" module to "microsocket".
...
It's no longer intended to provide just "raw" socket interface, may include
some convenience methods for compatibility with CPython socket - but anyway
just minimal set required to deal with socket client and servers, not wider
network functionality.
2014-02-08 21:20:32 +02:00
Damien George
698ec21e46
Make mp_obj_str_get_data return char* instead of byte*.
...
Can't decide which is better for string type, char or byte pointer.
Changing to char removes a few casts. Really need to do proper unicode.
2014-02-08 18:17:23 +00:00
Damien George
354d15a964
Implement fixed buffer vstrs; use them for import path.
2014-02-06 21:11:19 +00:00
Damien George
e09ffa1400
Search paths properly on import and execute __init__.py if it exists.
2014-02-05 23:57:48 +00:00
Paul Sokolovsky
9110896063
Remove older import helpers, no longer used.
2014-02-05 02:03:23 +02:00
Paul Sokolovsky
630d85120f
unix: Be sure to add current/base dir of a script to sys.path.
...
This mirrors CPython behavior and makes possible to run scripts which
import other modules not from script's directory.
2014-02-05 01:53:44 +02:00
Paul Sokolovsky
625d08a93e
unix: Initialize sys.path from MICROPYPATH environment variable.
...
If it's not available, "~/.micropython/lib:/usr/lib/micropython" is used
as a fallback.
2014-02-05 01:40:41 +02:00
Paul Sokolovsky
0c59db1973
Use qstr id to create sys module.
2014-02-04 19:36:00 +02:00
Paul Sokolovsky
6964422cf4
unix time.clock(): Actually return float value.
2014-02-02 08:58:16 +02:00
Paul Sokolovsky
a9459bc723
unix: Add basic time module (with time() and clock() functions).
...
Both return int so far (single-precision float doesn't have enough
bits to represent int32 precisely).
2014-02-02 01:34:11 +02:00
Damien George
a908202d60
unix: libffi include path now found using pkg-config.
...
Hopefully this works for other people as well :)
2014-02-01 18:48:19 +00:00
Paul Sokolovsky
ed1239fce6
Add mpconfigport.mk file to configure which modules to include into build.
...
Proof of concept, controls "ffi" module as one which requires external
dependencies.
2014-02-01 20:09:45 +02:00
Damien George
62ad189a65
py: Add compile option to enable/disable source line numbers.
2014-01-29 21:51:51 +00:00
Damien George
4d5b28cd08
Add qstr_info() function and bindings for unix port.
2014-01-29 18:56:46 +00:00
Damien George
8bf91f2a87
unix: Fix compile warnings for ffi module on 64-bit machine.
2014-01-28 23:08:11 +00:00
Paul Sokolovsky
60a9fac8d4
unix: Initial implementation of FFI module.
...
Foreign Function Interface module allows to load native dynamic libraries,
call functions and access variables in them. This makes possible to write
interface modules in pure Python.
This module provides thin wrapper around libffi. ctypes compatibility might
be possible to implement on top of this module (though ctypes allow to call
functions without prototypes, which is not supported by libffi (i.e.
implementation would be inefficient))).
2014-01-29 00:24:00 +02:00
Damien George
56bb636014
Change -Og to -O0 in unix-cpy/Makefile; cast to small int in socket.c.
2014-01-26 17:52:23 +00:00
Damien George
554a75b689
Merge pull request #226 from pfalcon/make-debug
...
unix Makefile: -Og doesn't work (at least) with gcc 4.6 below.
2014-01-26 09:53:31 -08:00
Paul Sokolovsky
a88c30c64a
unix socket: Add setsockopt() method.
2014-01-26 02:03:07 +02:00
Paul Sokolovsky
5d362d3209
unix socket: Add few more socket constants.
2014-01-26 02:03:07 +02:00
Paul Sokolovsky
db0b282d45
unix socket: Store module constants in data structure.
...
-147 bytes on x86.
2014-01-26 02:03:07 +02:00
Paul Sokolovsky
e2febe90e3
unix Makefile: -Og doesn't work (at least) with gcc 4.6 below.
...
Also, don't try to force debug info format, use native.
2014-01-25 19:49:38 +02:00
Damien George
b829b5caec
Implement mp_parse_node_free; print properly repr(string).
2014-01-25 13:51:19 +00:00
Paul Sokolovsky
aee2ba70de
Add parse_node_free_struct() and use it to free parse tree after compilation.
...
TODO: Check lexer/parse/compile error path for leaks too.
2014-01-25 02:11:59 +02:00
Dave Hylands
c89c681a9f
Rework makefiles. Add proper dependency checking.
2014-01-24 08:46:48 -08:00
Paul Sokolovsky
2b2cb7b7f4
unix main: Free input line.
...
Also, readline uses system malloc, so for symmetry, use the same for
non-readline case.
2014-01-24 16:29:49 +02:00
Damien George
5fa93b6755
Second stage of qstr revamp: uPy str object can be qstr or not.
2014-01-22 14:35:10 +00:00
Damien George
12eaccacda
Merge branch 'master' of github.com:micropython/micropython
...
Conflicts:
py/objstr.c
py/py.mk
py/stream.c
unix/main.c
unix/socket.c
2014-01-21 21:54:15 +00:00
Damien George
55baff4c9b
Revamp qstrs: they now include length and hash.
...
Can now have null bytes in strings. Can define ROM qstrs per port using
qstrdefsport.h
2014-01-21 21:40:13 +00:00
Paul Sokolovsky
51ee44a718
unix file: Refactor and add sys.stdout/stdin/stderr.
2014-01-20 23:50:55 +02:00
Paul Sokolovsky
f0cfb8cb45
Don't preimport socket module.
2014-01-20 20:37:01 +02:00
Paul Sokolovsky
fc35aa6828
unix socket: Add send() and recv() methods.
...
CPython _socket actually have only those and doesn't provide stream
interface (higher-level CPython "socket" what adds this).
+516 bytes x86.
2014-01-20 20:37:01 +02:00
Paul Sokolovsky
decd597273
unix io.FileIO: Add iteration support.
...
A file cannot be iterated concurrently, so we make io.FileIO its own
iterator.
2014-01-20 18:42:08 +02:00
Damien George
7d08935458
Rename unix binary to 'micropython'.
2014-01-20 00:02:39 +00:00
Paul Sokolovsky
fe2690da0a
unix: Implement sys.argv.
2014-01-20 01:00:28 +02:00
Damien George
a11ceca807
Change int to uint for n_args in function with variable arguments.
2014-01-19 16:02:09 +00:00
Damien George
136b149e41
py: Add full traceback to exception printing.
2014-01-19 12:38:49 +00:00
Damien George
49f6a99c65
Merge branch 'master' of github.com:micropython/micropython
2014-01-19 11:50:14 +00:00
Damien George
cbd2f7482c
py: Add module/function/class name to exceptions.
...
Exceptions know source file, line and block name.
Also tidy up some debug printing functions and provide a global
flag to enable/disable them.
2014-01-19 11:48:48 +00:00
Paul Sokolovsky
50a2d6ff59
Fix incorrect prototype of mp_builtin_open() after args refactor.
2014-01-19 07:50:45 +02:00
Damien George
a8a6db2a1d
Fix warnings about int/pointer casting.
2014-01-18 23:50:12 +00:00
Damien George
8fce5b42a2
Merge pull request #194 from pfalcon/socket
...
Add lean ("raw") socket module.
2014-01-18 15:34:30 -08:00
Damien George
08335004cf
Add source file name and line number to error messages.
...
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
2014-01-18 23:24:36 +00:00
Paul Sokolovsky
fc92608237
Add lean ("raw") socket module.
2014-01-19 00:16:39 +02:00
Damien George
20006dbba9
Make VM stack grow upwards, and so no reversed args arrays.
...
Change state layout in VM so the stack starts at state[0] and grows
upwards. Locals are at the top end of the state and number downwards.
This cleans up a lot of the interface connecting the VM to C: now all
functions that take an array of Micro Python objects are in order (ie no
longer in reverse).
Also clean up C API with keyword arguments (call_n and call_n_kw
replaced with single call method that takes keyword arguments). And now
make_new takes keyword arguments.
emitnative.c has not yet been changed to comply with the new order of
stack layout.
2014-01-18 14:10:48 +00:00
Paul Sokolovsky
966879cf59
Add long int implementation using C long long type, enable for unix port.
2014-01-17 20:05:02 +02:00
Damien George
5573f9f150
Merge branch 'str2int' of github.com:xyb/micropython into xyb-str2int
...
Conflicts:
py/objint.c
unix-cpy/Makefile
unix/Makefile
2014-01-15 22:58:39 +00:00
Damien George
4899ff9470
Merge branch 'str-repr' of github.com:pfalcon/micropython into pfalcon-str-repr
...
Conflicts:
tests/basics/tests/exception1.py
2014-01-15 22:39:03 +00:00
Damien George
11507f4074
Merge branch 'master' of github.com:dpgeorge/micropython
2014-01-15 22:14:18 +00:00
Paul Sokolovsky
9953ca432b
Add unbuffered readline() implementation for Raw I/O files.
2014-01-15 23:43:25 +02:00
Damien George
9528cd66d7
Convert parse errors to exceptions.
...
Parser no longer prints an error, but instead returns an exception ID
and message.
2014-01-15 21:23:31 +00:00
Paul Sokolovsky
76d982ef34
type->print(): Distinguish str() and repr() variety by passing extra param.
2014-01-15 02:15:38 +02:00
Damien George
c6920d31e2
Merge pull request #170 from chipaca/master
...
made DEBUG control CFLAGS in Makefiles other than stm as well.
2014-01-14 15:54:31 -08:00
xyb
c178ea471e
Implemented int(str) in UNIX
2014-01-14 21:39:05 +08:00
Paul Sokolovsky
5225450b9f
Add generic impl of stream .readall() method. Use one for unix io.FileIO.
2014-01-13 23:31:06 +02:00
John R. Lenton
9549919349
made DEBUG control CFLAGS in Makefiles oter than stm as well.
2014-01-13 13:25:10 +00:00
Damien George
004cdcebfe
py: Implement base class lookup, issubclass, isinstance.
2014-01-09 21:43:51 +00:00
Damien George
062478e66d
Improved type/class/instance code; mp_obj_type_t now has load_attr, store_attr.
...
Creating of classes (types) and instances is much more like CPython now.
You can use "type('name', (), {...})" to create classes.
2014-01-09 20:57:50 +00:00
Dave Hylands
4646801181
Make build output quieter.
...
Use make V=1e make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
This should fix issue #117
2014-01-08 10:30:06 -08:00
Damien George
6c73ca1e75
py: add variable argument exception constructor function.
...
Addresses issue #104 .
2014-01-08 18:11:23 +00:00
Paul Sokolovsky
e0e79ae6d6
unix: Add basic implementation of io.FileIO object.
...
Note: only read/write/close methods are defined so far, and class
is not exposed (use open() factory function, as usual).
2014-01-08 17:39:06 +02:00
Damien George
97209d38e1
Merge branch 'cplusplus' of https://github.com/ian-v/micropython into ian-v-cplusplus
...
Conflicts:
py/objcomplex.c
2014-01-07 15:58:30 +00:00
Damien George
d3ebe4829d
Factor and simplify Makefile's and mpconfig, part 2.
2014-01-07 15:20:33 +00:00
Damien George
136f67523b
Factor and simplify Makefile's and mpconfig.
2014-01-07 14:54:15 +00:00
ian-v
5fd8fd2c16
Revert MP_BOOL, etc. and use <stdbool.h> instead
2014-01-06 13:51:53 -08:00
ian-v
7a16fadbf8
Co-exist with C++ (issue #85 )
2014-01-06 09:52:29 -08:00
Paul Sokolovsky
860ffb0a43
Convert many object types structs to use C99 tagged initializer syntax.
2014-01-05 22:34:09 +02:00
Damien George
71c5181a8d
Convert Python types to proper Python type hierarchy.
...
Now much more inline with how CPython does types.
2014-01-04 20:21:15 +00:00
Paul Sokolovsky
d674bd5989
Convert USE_READLINE config option to be consistent with others.
2014-01-04 19:38:19 +02:00
Damien George
eb7bfcb286
Split qstr into pools, and put initial pool in ROM.
...
Qstr's are now split into a linked-list of qstr pools. This has 2
benefits: the first pool can be in ROM (huge benefit, since we no longer
use RAM for the core qstrs), and subsequent pools use m_new for the next
pool instead of m_renew (thus avoiding a huge single table for all the
qstrs).
Still would be better to use a hash table, but this scheme takes us part
of the way (eventually convert the pools to hash tables).
Also fixed bug with import.
Also improved the way the module code is referenced (not magic number 1
anymore).
2014-01-04 15:57:35 +00:00
Damien George
e67ed5d285
Improve configurability for native x64/thumb emitter.
...
With MICROPY_EMIT_X64 and MICROPY_EMIT_THUMB disabled, the respective
emitters and assemblers will not be included in the code. This can
significantly reduce binary size for unix version.
2014-01-04 13:55:24 +00:00
Paul Sokolovsky
1c6de11f77
Add basic implementation of slice object.
...
So far, only start and stop integer indexes are supported. Step is
not supported, as well as objects of arbitrary types.
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
c90c0f68a2
Move INT_FMT, etc. declaration into global mpconfig.h .
...
This in particular makes it available for stm port.
2014-01-04 01:57:00 +02:00
Paul Sokolovsky
b372bfca21
Rename default config file to mpconfig.h, and port's to mpconfigport.h.
...
mpconfig.h will automatically pull mpconfigport.h.
2014-01-03 19:03:11 +02:00
Damien George
1fb031744f
Change mp_compile so that it returns a function object for the module.
2014-01-03 14:22:03 +00:00
Damien George
66028ab6dc
Basic implementation of import.
...
import works for simple cases. Still work to do on finding the right
script, and setting globals/locals correctly when running an imported
function.
2014-01-03 14:03:48 +00:00
Damien George
2870862601
Add module object, to be used eventually for import.
2014-01-02 21:30:26 +00:00
Damien George
210a02e105
unix: revert Makefile to not use -ltermcap.
...
termcap is not needed on Linux. Need to work out how to automatically
configure the Makefile...
2014-01-02 15:50:33 +00:00
Edd Barrett
0d02eb178a
Fix undefined termcap symbols on OpenBSD.
...
E.g.:
/usr/lib/libreadline.so.4.0: undefined reference to `tgetnum'
/usr/lib/libreadline.so.4.0: undefined reference to `tgoto'
/usr/lib/libreadline.so.4.0: undefined reference to `tgetflag'
/usr/lib/libreadline.so.4.0: undefined reference to `tputs'
/usr/lib/libreadline.so.4.0: undefined reference to `tgetent'
/usr/lib/libreadline.so.4.0: undefined reference to `tgetstr'
Tested on linux too, works.
2014-01-01 23:26:36 +00:00
Edd Barrett
8146aea8ef
malloc.h is obsolete.
2014-01-01 23:14:36 +00:00
Paul Sokolovsky
fa027672da
Make GNU Readline usage optional (USE_READLINE define). Still enabled.
...
Readline is GPL, so linking with it casts the binary GPL.
2014-01-01 18:28:01 +02:00
Paul Sokolovsky
903b24f041
Add readline history support.
2014-01-01 14:54:39 +02:00
Paul Sokolovsky
e1151e463d
Use rm -rf to remove build dir, so it doesn't error out if dir doesn't exist.
2013-12-30 21:02:10 +02:00
Damien George
8cc96a35e5
Put unicode functions in unicode.c, and tidy their names.
2013-12-30 18:23:50 +00:00
Damien George
212c296c0b
Make unix-cpy cross platform; remove dependency of asmx64 on mpconfig.
2013-12-30 12:52:32 +00:00
Paul Sokolovsky
e85c38992d
Make "unix" target be crossplatform and support x86, x64, ARM hosts.
2013-12-30 03:38:32 +02:00
Damien
732407f1bf
Change memory allocation API to require size for free and realloc.
2013-12-29 19:33:23 +00:00
Paul Sokolovsky
729fd12fbf
Don't error out if build/ directory already exists.
2013-12-29 20:12:33 +02:00
Damien
de690d128b
Add unix-cpy, used to test Micro Python byte code against CPython.
2013-12-29 18:01:01 +00:00
Damien
b86e3f9293
py: implement some basic exception matching.
2013-12-29 17:17:43 +00:00
Damien
d99b05282d
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).
2013-12-21 18:17:45 +00:00
Damien
e2880aa2fd
Fix a few compiler warnings.
2013-12-20 14:22:59 +00:00
Damien
0f08267fa4
unix: include obj.h, and build additional py files.
2013-12-17 18:33:53 +00:00
Damien
1895cf91af
Link showbc.o in unix version.
2013-11-17 13:20:13 +00:00
Damien
087d218d95
Unix: add machine-specific sqrt support.
2013-11-09 20:14:30 +00:00
Damien
014e19fc4d
Fix compiler warnings in unix/main.c.
2013-11-03 14:26:21 +00:00
Damien
a53f694dc3
Test code for user objects.
2013-11-02 23:58:38 +00:00
Damien
7410e440ab
Add basic complex number support.
2013-11-02 19:47:57 +00:00
Damien
8b3a7c2237
Fix func decls with no arguments: () -> (void).
2013-10-23 20:20:17 +01:00
Damien
92c06561a3
Improve REPL compount statement detection.
2013-10-22 22:32:27 +01:00
Damien
d276f6357e
Get unix version compling.
2013-10-22 16:05:47 +01:00
Damien
fa2162bc77
Integrate new lexer stream with stm framework.
2013-10-20 17:42:00 +01:00
Damien
a5185f4bc8
Abstract out back-end stream functionality from lexer.
2013-10-20 14:41:27 +01:00
Damien
5ac1b2efbd
Implement REPL.
2013-10-18 19:58:12 +01:00
Damien
d2755ec538
Add iterators and comprehension to emitnative.
2013-10-16 23:58:48 +01:00
Damien
c9f91976e1
Crude try-except working.
2013-10-15 23:46:01 +01:00
Damien
ce89a21ea4
Implement basic exception framework, and simple for loop.
2013-10-15 22:25:17 +01:00
Damien
3ef4abb446
Change ifdef/if defined to simple if's.
2013-10-12 16:53:13 +01:00
Damien
c025ebb2dc
Separate out mpy core and unix version.
2013-10-12 14:30:21 +01:00