magicport2's Introduction
====== Magicport Manual ====== Magicport is a terrible hack. Source: magicport.d - Contains entry point. - First loads the json settings file - prefixes all the imports with 'ddmd.' - Translates the list of modules into a D format - Loads tables of basic types, structs, 'root' classes (base classes), functions that need 'override', functions that don't need 'final' - For each source file - Loads and lexes the file - Scans for class and struct names - Parses and runs 'scanner' on each file - Collapses the AST (combining member functions declarations with definitions, etc) - Builds a map of all symbols using a mangling scheme - Walks the AST to write the output files tokens.d - Lexes C++ source files parser.d - Parses C++ source files ast.d - Containts C++ AST definitions dprinter.d - Contains D output AST walker namer.d - Contains symbol mangler printerast.d - Debug ast printer printercpp.d - Debug C++ ast printer, not maintained and probably doesn't work scanner.d - Contains an AST visitor that builds lists of structs, classes, etc - Used for locating declarations to merge with definitions - A collection of functions to: - Merge member function prototypes and definitions - Transfer default arguments from function prototypes to definitions - Transfer static member initializers to the declarations - Drop duplicate typedefs (aliases conflict in D) - Drop FILE_H include guards - Build a new constructor for Scope (special case) - Delete dead code - unused prototypes - #undef - #define LOG - Default ctors - extern(C) function prototypes - backend typedefs - assert macro definition typenames.d - Lists of names of types, mostly moved into magicport.json visitor.d - Visitor implementation Config: "src" List of C++ source files (.c and .h) "mapping" List of modules containing - "module" - module name - "package" - package name - "imports" - list of imports - "extra" - list of special stuff to copy-paste into the generated file - "members" - list of mangled names of symbols to include "basicTypes" list of 'basic' types, pretty much anything that isn't a struct/class/enum "structTypes" List of struct/enum types that the scanner doesn't pick up - mostly ones defined in weird places "classTypes" ditto "rootclasses" Base classes "overriddenfuncs" List of classname, functionname pairs of functions that can't be final "nonfinalclasses" List of classes that can't be final. Usage: - Build magicport (all .d source files together) - Update magicport.json - Run magicport - takes two arguments (sourcedir, destdir) - I usually just run it in the source directory and generate the D source there - i.e. path/to/magicport . . - It will look for magicport.json in the current directory
magicport2's People
magicport2's Issues
building from newmagic branch
As in title, i'm building from newmagic branch in your dmd fork, using win32.mak ddmd (this was just a convenient place to raise issue).
Had some issues building:
https://github.com/D-Programming-Language/dmd/blob/master/src/mars.c#L142 has an #include directive in the expression, which the magicport parser doesn't like. I hard-coded a version to work around.
Some string literals like: https://github.com/D-Programming-Language/dmd/blob/master/src/doc.c#L132 have unterminated back-slashes, to escape the line endings. DMD didn't like it, so in dprinter.d, I added a string escaper to the LitExpr visitor:
override void visit(LitExpr ast)
{
if (ast.val.endsWith("L", "l"))
{
print(ast.val[0..$-1]);
} else {
print(escapeBackslash(ast.val));
}
}
auto escapeBackslash(string s) {
import std.regex;
return s.replaceAll(regex(`\\\r\n`), ``);
}
which doesn't actually escape the string, it just removes the unterminated char constants.
Anyhoo, I'm wondering how you build this make target, if you are not seeing these issues, or is magicport in the newmagic branch not up to date, or am I missing some dmd patches?
cheers
nonFinalClass not in settings.json
I just tried to run magicport on dmd but It gets range violations because there are fields missing in settings.json
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.