Giter Club home page Giter Club logo

micropython-extmod-generator's Introduction

micropython-extmod-generator

Generator for Micropython external modules written in C

Usage

extmod-generator [-f] module

Program will look for file named module/module.py and generate the following files:

  • module/modmodule.c - external module source code - to be put in micropython/extmod
  • module/qstrdefs.h - needs to be merged manually with micropython/py/qstrdefs.h

If a module argument is not provided, the default example will be used.

Example

example/example.py โ‡’ example/modexample.c + example/qstrdefs.h

License

Licensed under MIT License.

micropython-extmod-generator's People

Contributors

prusnak avatar spotlightkid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

micropython-extmod-generator's Issues

Use Type Hints (PEP 0484) for module definition

We can use Type Hints (described in PEP 0484) to provide even more metadata for the module (types of arguments and return value).

With this metadata we can generate extra code that deals with argument parsing and returned objects creation.

Input module needs to be on PYTHONPATH

Maybe the path of the input module should be added to sys.path in the generate script?

$ ./micropython-extmod-generator/generate testmod1
Looking for module "testmod1":
Traceback (most recent call last):
  File "./micropython-extmod-generator/generate", line 241, in <module>
    main()
  File "./micropython-extmod-generator/generate", line 234, in main
    module = Module(sys.argv[1])
  File "./micropython-extmod-generator/generate", line 66, in __init__
    self.module = importlib.import_module(name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'testmod1'

$ PYTHONPATH=. ./micropython-extmod-generator/generate testmod1
Looking for module "testmod1":
Found <module 'testmod1' from '/[...]/testmod1.py'>
Parsed OK ... loaded 1 functions and 1 classes with 1 methods
Generating source code:
Done
Saved source as modtestmod1.c
Saved qstrdefs as modtestmod1-qstrdefs.h

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.