Code Monkey home page Code Monkey logo

pythontocpp's People

Contributors

jordan-cottle avatar

Stargazers

 avatar

Watchers

 avatar

pythontocpp's Issues

Support `dict` literals

dictionaries can map nicely to std::unordered_map. The std::unordered_map has an initializer that can probably be used to imitate the python dict syntax.

Support imports

Automatically convert import statements to #includes

#includes are a lot less intelligent than the python import system. Do not attempt to automatically handle including the same thing multiple times across multiple files at this time.

Design comprehensive type engine

Type information is critical in c++. For the converter to support a wider array of features and contexts a more robust method for tracking and expressing the type of a variable needs to be implemented.

Support properties

Properties are not going to be natively supported in c++.

Translating them to a private attribute with a public getter/setter should be possible though.

If there is a mechanism to support an accessor interface that won't require explicit function/method calls (preserve the way the python code looks) then do that.

Split generated source

It is common for c++ source to be split into header and cpp files.

The output from converting a python file should generate a header file with just the declarations (and some include guards) and the cpp file with just the implementations.

Any private module functions can be defined in the cpp file only. Since they aren't in the header, they shouldn't be included when the header is used.

Consider implementing a set of base classes to map the python data model to

To support easily translating python classes to c++ classes, each dunder method could be an abstract interface.

Then when a class is parsed and translated, it can multiply inherit from each of the bases it implements. If one of its super classes already inherits from one of the bases, it should be ommitted from the subclass declaration.

Support common builtins

Automated conversion will be nearly impossible without at least some of the built-ins.

range will be critical for writing standard c style for loops.

str will be important for explicitly invoking __str__.

A good number of the dunder methods would be valuable as well.

I might be worthwhile to implement a base PyBase class/struct that implements a lot of the same interfaces python objects expect to have. Then all new classes that don't have an explicit super class can extend from that predefined base to make parsing/converting much easier.

A similar approach that defines a series of functions with the same(ish) signatures as the python built-ins may be valuable as well. Then functions wouldn't need to be mapped to another name/signature.

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.