Jump to page: 1 27  
Page
Thread overview
DStep - Bindings Generator 0.0.1
Jul 07, 2012
Jacob Carlborg
Jul 07, 2012
Walter Bright
Jul 07, 2012
so
Jul 08, 2012
Artur Skawina
Jul 08, 2012
Walter Bright
Jul 08, 2012
Jacob Carlborg
Jul 08, 2012
Walter Bright
Jul 08, 2012
Jacob Carlborg
Jul 08, 2012
Walter Bright
Jul 08, 2012
Jacob Carlborg
Jul 08, 2012
Roman D. Boiko
Jul 08, 2012
Roman D. Boiko
Jul 08, 2012
Dmitry Olshansky
Jul 09, 2012
Walter Bright
Jul 09, 2012
Jonathan M Davis
Jul 09, 2012
Walter Bright
Jul 09, 2012
Jacob Carlborg
Jul 09, 2012
Christophe Travert
Jul 09, 2012
Andrea Fontana
Jul 09, 2012
Jacob Carlborg
Jan 30, 2015
Chris
Jan 30, 2015
Jacob Carlborg
Jan 30, 2015
Chris
Jan 30, 2015
Jacob Carlborg
Jan 30, 2015
Chris
Jan 30, 2015
Jacob Carlborg
Jan 31, 2015
Chris
Jan 31, 2015
Jacob Carlborg
Feb 02, 2015
Chris
Feb 03, 2015
Paul O'Neil
Feb 03, 2015
Chris
Feb 03, 2015
Mike Parker
Feb 03, 2015
FG
Feb 04, 2015
Jacob Carlborg
Jul 08, 2012
Leandro Lucarella
Jul 10, 2012
Jakob Ovrum
Jul 08, 2012
Walter Bright
Jul 08, 2012
Bernard Helyer
Jul 08, 2012
Jonathan M Davis
Jul 08, 2012
Jonathan Andrew
Jul 09, 2012
Jacob Carlborg
Jul 11, 2012
Jonathan Andrew
Jul 11, 2012
Jonathan Andrew
Jul 11, 2012
Jacob Carlborg
Jul 09, 2012
Jacob Carlborg
Jul 09, 2012
Andrea Fontana
Jul 09, 2012
Jacob Carlborg
Jul 10, 2012
Andrea Fontana
Jul 10, 2012
Jacob Carlborg
Jul 10, 2012
Andrea Fontana
Jul 20, 2012
Andrej Mitrovic
Jul 20, 2012
Jacob Carlborg
Jul 20, 2012
Jacob Carlborg
Jul 20, 2012
Andrej Mitrovic
Jul 22, 2012
Jacob Carlborg
Jan 30, 2015
data man
Jan 30, 2015
Jacob Carlborg
Jan 30, 2015
data man
July 07, 2012
DStep is a tool for translating C and Objective-C headers to D modules. It uses libclang for lexing/parsing and AST traversal. This means it handles everything that Clang itself can handle, although this doesn't mean it will correctly translate everything.

I would consider this release alpha or beta. I'm releasing this now in hope I get some feedback on what language features the tool can't handle.

The tool is available at github:
https://github.com/jacob-carlborg/dstep

Binaries are available for Mac OS X and Ubuntu 11.10 32bit:
https://github.com/jacob-carlborg/dstep/downloads

Unfortunately I haven't been able to successfully compile it on Windows due to Optlink not cooperating. I'll most likely provide Linux binaries with better compatibility later.

Build instructions are available at github.

Usage:

dstep <input-file.h> -o output_file.d

For Objective-C

dstep <input-file.h> -o output_file.d -ObjC

Tests:

DStep uses Cucumber and Aruba (Ruby tools) to run its tests. It will basically run the tool on all *.h files in the "test_files" directory and compare the results to the corresponding *.d files.

Known issues/missing functionality:

* Multiple input files
* Framework as input file
* Add module declaration
* Option for specifying before and after code
* Option for specifying package
* Windows support

C:
    * Self includes
    * Out of order typedefs of structs
    * Bitfields
    * Non-standard extensions
    * Preprocessor
    * Arrays with no size marked as "extern".

Objective-C:
    * Protocols
    * Properties
    * Blocks
    * Categories
    * Actions
    * Outlets
    * Selectors

This is basically what's on the todo list:

https://raw.github.com/jacob-carlborg/dstep/master/todo.taskpaper

There's no point in reporting issues which are listed above.

-- 
/Jacob Carlborg
July 07, 2012
On 7/7/2012 7:47 AM, Jacob Carlborg wrote:
> DStep is a tool for translating C and Objective-C headers to D modules. It uses
> libclang for lexing/parsing and AST traversal. This means it handles everything
> that Clang itself can handle, although this doesn't mean it will correctly
> translate everything.
>
> I would consider this release alpha or beta. I'm releasing this now in hope I
> get some feedback on what language features the tool can't handle.

I think this is potentially a big deal.

If it can be made complete enough, I'd like to add support into D for it, so you could do things like:

    import "stdio.h";

and the D compile would fork/exec Dstep, generate the corresponding .d file, and import the .d file.

Some issues:

1. Passing macro definitions to Dstep

2. The name "Dstep" has no obvious relationship to what it does.

3. The -o flag is not necessary. Just "do the right thing" when you see the filename extension.


In fact, we could make it a general facility, where if D sees:

    import "filename.ext";

that it fork/exec's the program:

    ext_to_D filename.ext tmpfile.d

and them imports tmpfile.d.
July 07, 2012
Wow at long last!

On Saturday, 7 July 2012 at 21:20:53 UTC, Walter Bright wrote:
> On 7/7/2012 7:47 AM, Jacob Carlborg wrote:
>> DStep is a tool for translating C and Objective-C headers to D modules. It uses
>> libclang for lexing/parsing and AST traversal. This means it handles everything
>> that Clang itself can handle, although this doesn't mean it will correctly
>> translate everything.
>>
>> I would consider this release alpha or beta. I'm releasing this now in hope I
>> get some feedback on what language features the tool can't handle.
>
> I think this is potentially a big deal.
>
> If it can be made complete enough, I'd like to add support into D for it, so you could do things like:
>
>     import "stdio.h";
>
> and the D compile would fork/exec Dstep, generate the corresponding .d file, and import the .d file.
>
> Some issues:
>
> 1. Passing macro definitions to Dstep
>
> 2. The name "Dstep" has no obvious relationship to what it does.
>
> 3. The -o flag is not necessary. Just "do the right thing" when you see the filename extension.
>
>
> In fact, we could make it a general facility, where if D sees:
>
>     import "filename.ext";
>
> that it fork/exec's the program:
>
>     ext_to_D filename.ext tmpfile.d
>
> and them imports tmpfile.d.

July 08, 2012
On 07/07/12 23:20, Walter Bright wrote:
> In fact, we could make it a general facility, where if D sees:
> 
>     import "filename.ext";
> 
> that it fork/exec's the program:
> 
>     ext_to_D filename.ext tmpfile.d
> 
> and them imports tmpfile.d.

   import extern (C) "stdio.h";

which execs

   dimport_C "stdio.h"

which returns a filename of a D module, which is then imported.

This way the importer can cache the result and doesn't need to regenerate the D module until "stdio.h" or any dependency changes.


artur
July 08, 2012
On 7/7/12 5:20 PM, Walter Bright wrote:
> In fact, we could make it a general facility, where if D sees:
>
> import "filename.ext";
>
> that it fork/exec's the program:
>
> ext_to_D filename.ext tmpfile.d
>
> and them imports tmpfile.d.

(Aside) This has an obvious security risk.

Andrei
July 08, 2012
On 7/7/12 10:47 AM, Jacob Carlborg wrote:
> DStep is a tool for translating C and Objective-C headers to D modules.

Awesome! On reddit:

http://www.reddit.com/r/programming/comments/w7hbg/dstep_tool_for_translating_c_and_objc_headers/


Andrei
July 08, 2012
On 7/7/2012 7:59 PM, Andrei Alexandrescu wrote:
> On 7/7/12 5:20 PM, Walter Bright wrote:
>> In fact, we could make it a general facility, where if D sees:
>>
>> import "filename.ext";
>>
>> that it fork/exec's the program:
>>
>> ext_to_D filename.ext tmpfile.d
>>
>> and them imports tmpfile.d.
>
> (Aside) This has an obvious security risk.

Yup. It's similar to the import arbitrary file as string feature. We can leave it disabled unless -J is used.


July 08, 2012
On 7/7/2012 8:40 PM, Andrei Alexandrescu wrote:
> http://www.reddit.com/r/programming/comments/w7hbg/dstep_tool_for_translating_c_and_objc_headers/


Gotta change the name:


http://www.reddit.com/r/programming/comments/w7hbg/dstep_tool_for_translating_c_and_objc_headers/c5az51y
July 08, 2012
On Sunday, 8 July 2012 at 08:36:34 UTC, Walter Bright wrote:
> On 7/7/2012 8:40 PM, Andrei Alexandrescu wrote:
>> http://www.reddit.com/r/programming/comments/w7hbg/dstep_tool_for_translating_c_and_objc_headers/
>
>
> Gotta change the name:
>
>
> http://www.reddit.com/r/programming/comments/w7hbg/dstep_tool_for_translating_c_and_objc_headers/c5az51y

Just make it drop when you're done translating the file.
July 08, 2012
On 2012-07-07 23:20, Walter Bright wrote:

> I think this is potentially a big deal.
>
> If it can be made complete enough, I'd like to add support into D for
> it, so you could do things like:
>
>      import "stdio.h";
>
> and the D compile would fork/exec Dstep, generate the corresponding .d
> file, and import the .d file.

How is this going to work, is it going to be an optional feature? I mean, this will add DStep (D and Clang) as dependencies to DMD.

DStep is built to be used as a library, I can easily create a C API which can be used directly by DMD. No need for creating a new process. I can also make DStep give back the translate D code, no need for creating temporarily D files.

BTW, how would you indicate that the header file is an Objective-C file? Since both C and Objective-C uses the same extension for header files, this is required by Clang, otherwise it will treat the file as a C file.

> Some issues:
>
> 1. Passing macro definitions to Dstep

Yeah, this will be the hardest. The main problem now is that libclang (the stable C API) doesn't have an API for handling macros.

> 2. The name "Dstep" has no obvious relationship to what it does.

No it does not, but I'm tired of trying to come up with cleaver names for tools and libraries.

Here's the story behind the name for those who are interested:

DStep started out as another project, as a D-Objective-C bridge:

http://dsource.org/projects/dstep

In that project I had a tool for converting C/Objective-c headers to D modules. This tool was a Ruby script based on BridgeSupport. This is a complete rewrite of that tool. The whole project was called DStep and the name fit among other Objective-C related names like NeXTSTEP, OpenStep and GNUStep.

> 3. The -o flag is not necessary. Just "do the right thing" when you see
> the filename extension.

That can be easily fixed.

> In fact, we could make it a general facility, where if D sees:
>
>      import "filename.ext";
>
> that it fork/exec's the program:
>
>      ext_to_D filename.ext tmpfile.d
>
> and them imports tmpfile.d.


-- 
/Jacob Carlborg


« First   ‹ Prev
1 2 3 4 5 6 7