On Mon, 06 Oct 2014 13:34:23 +0200 Martin Drašar via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> Ok, thanks for your answers. If you get your code to publishable > state, I am sure a lot of people will be interested. as i can't publish my current version of cmdcon, i decided to write another one from scratch. it contains alot less of mixin() codegens, can do everything cmdcon.d can do and has structs/classes already working. this is the excerpt from testing code: import cong; // our console module @ConName("intVar00") @ConHelp("simple int variable") @ConDescription("this is just an int variable.\nordinary one, nothing special.") __gshared int v0 = 42; __gshared string v1 = "hi!"; class A { int i = 42; string s = "hello"; this () {} this (string v) { s = v; } int bar () { writeln("BAR: s=", s); return 666; } void foo (float[] ff) {} } __gshared A a; // yes, this can be null void foo (int n, string s="hi", double d=0.666) { writefln("n=%s; s=[%s]; d=%s", n, s, d); } struct S { int i = 666; string s = "bye"; int sbar () { writeln("SBAR: s=", s); return 666; } void sfoo (float[] ff) {} } __gshared S s; S s1; void main (string[] args) { writeln("known commands:"); foreach (auto n; conGetKnownNames()) writeln(" ", n); writeln("---"); a = new A(); conExecute("a bar"); // virtual method call for object instance a.s = "first change"; conExecute("a bar"); a = new A("second change"); conExecute("a bar"); // virtual method call for ANOTHER object instance foreach (auto arg; args[1..$]) { try { writeln("# ", arg); conExecute(arg); } catch (Exception e) { writeln("***ERROR: ", e.msg); } } } mixin(ConRegisterAll); // register 'em all! ========== known commands: intVar00 a foo v1 s --- (autoregistration rocks!) some sample commands and results: # intVar00 intVar00 42 (Int) # foo 42 n=42; s=[hi]; d=0.666 # a i a.i 42 (Int) # a bar BAR: s=second change # s sbar SBAR: s=bye by default `mixin(ConRegisterAll);` tries to register all suitable public symbols. one can use @ConIgnore UDA to ignore symbol and some other UDAs to change name, add help and so on. alas, there is no way to get Ddoc info in compile-time (what a pity!). you can't register pointer objects (i.e. `__gshared int *a` will not pass). it's doable (class fields are such objects internally), but i just don't need this. i also found some bugs in compilers (both dmd and gdc), but aren't ready to dustmite and report 'em yet. GDC just segfaults now, but DMD works. there is also bug in CDGC, which took me a whole day of useless code motion (i forgot that i'm using DMD built with CDGC ;-). so the base mechanics is in place, i need to debug some things and write simple sample with eventloop and telnet. new code includes only WTFPL'ed parts, so it probably will be WTFPLed too. hope to finish this until weekend.
signature.asc
Description: PGP signature