digitalmars.D - how to hide sources?
- Wakie (4/4) Sep 15 2005 Hello! Help me, pls. I don't understand how I can distribute my libs w/o
- Derek Parnell (45/49) Sep 15 2005 For each module in the library you need to create a 'header' module. Thi...
- Newbie (7/8) Sep 15 2005 OK, Derek, thank you very much for excellent answer! I tried, it works. ...
- Burton Radons (8/12) Sep 16 2005 Try digc:
Hello! Help me, pls. I don't understand how I can distribute my libs w/o sources? When I produce .OBJ files and try to link them to main program DMD wants access to original *.D files!
Sep 15 2005
On Thu, 15 Sep 2005 10:05:09 +0000 (UTC), Wakie wrote:Hello! Help me, pls. I don't understand how I can distribute my libs w/o sources? When I produce .OBJ files and try to link them to main program DMD wants access to original *.D files!For each module in the library you need to create a 'header' module. This is identical to the original module source code, except that it only contains public IDENTIFIERS and no executable code. You then distribute your library and the header modules. For example, if you have a module file called foo_m.d, like this ... <code> module foo_m; private { import std.string; int myValue; } class Foo { private { int _x; long _y; } this() { _x = 1; _y = 1; } char[] toString() { return std.string.format("[%d:%d]", _x, _y); } int x() {return _x + myValue;} long y() {return _y + myValue;} } </code> You would create a header file, ALSO called foo_m.d but obviously in a different folder, like this ... <code> module foo_m; class Foo { this(); char[] toString(); int x(); long y(); } </code> You would create the library and distribute the library file AND the cut-down 'header' source file. -- Derek Parnell Melbourne, Australia 15/09/2005 8:09:48 PM
Sep 15 2005
For each module in the library you need to create a 'header' module.OK, Derek, thank you very much for excellent answer! I tried, it works. :) What you think about to add some tool which will do this automatically? (like h->.d) And second question: I found a lot of docs for D, but still not sure I have FULL description of the language. For example I frequently see things like "private import". I know directive "import" but never met explanation for "private import". Where I can found full spec for D?
Sep 15 2005
private means private same as it does as a class attribute you can: private { import something; } or private import something; it means import it into the current module only, then other modules that import this module wont also import somethig Newbie wrote:For each module in the library you need to create a 'header' module.OK, Derek, thank you very much for excellent answer! I tried, it works. :) What you think about to add some tool which will do this automatically? (like h->.d) And second question: I found a lot of docs for D, but still not sure I have FULL description of the language. For example I frequently see things like "private import". I know directive "import" but never met explanation for "private import". Where I can found full spec for D?
Sep 15 2005
it means import it into the current module only, then other modules that import this module wont also import somethigStrange behaviour, but it goes as you say. :) Thanks.
Sep 15 2005
Wakie wrote:Hello! Help me, pls. I don't understand how I can distribute my libs w/o sources? When I produce .OBJ files and try to link them to main program DMD wants access to original *.D files!Try digc: http://www.smocky.com/index.php/Digc It helps with creating library files and it appends a stripped source to the end of the library so that you only need to distribute one file. During compilation of other programs, if it detects that the library is used (through an import) it recreates the headers and links in what's needed.
Sep 16 2005