Re: Get UDA of unit tests during Runtime.moduleUnitTester
On Wednesday, 26 July 2017 at 03:27:30 UTC, Matthew Remmel wrote: I'd like to print out the name given to a unit test via a UDA, as the tests are being ran by the Runtime.moduleUnitTester. I'm working on writing a custom unit test runner. It would seem that the ModuleInfo.unitTest property is an aggregated function of all the individual unit test blocks in a module, and therefore the UDA value is lost. [...] Do you know https://github.com/atilaneves/unit-threaded?
Get UDA of unit tests during Runtime.moduleUnitTester
I'd like to print out the name given to a unit test via a UDA, as the tests are being ran by the Runtime.moduleUnitTester. I'm working on writing a custom unit test runner. It would seem that the ModuleInfo.unitTest property is an aggregated function of all the individual unit test blocks in a module, and therefore the UDA value is lost. I've been attempting to use the __traits(getUnitTests, m) function, but that doesn't seem to work with ModuleInfo because it is a variable and not a symbol. Additionally, if you run __traits(getUnitTests, m) against a module, that doesn't retrieve any unit tests that are nested inside classes or structs. So even if it did work with ModuleInfo, there may still be problems. What I would like is to have a module like: ___ module app; int square(int x) { return x*x; } @name("square test 1") unittest { assert(square(10) == 100); } @name("square test 2") unittest { assert(square(5) == 25); } class Foo { void someFunc() { return; } @name("Foo test") unittest { assert(someFunc() == something); } } ___ So as mentioned above, the first problem is that using ModuleInfo.unitTest returns an aggregated function of all 3 unit tests for that module, instead of each one individually, so the UDA information is lost. The second problem is that running __traits(getUnitTests, app) only returns the 2 tests at module scope, and not the one nested inside Foo. Even then, I haven't been able to figure out how to dynamically get the module symbol to pass to __traits inside of the Runtime.moduleUnitTester function. Its possible that I've got some of this backwards and there is an easy solution. Its also possible that what i'm trying to do isn't currently possible. Thanks in advance for any help. --Matt
Re: I feel the dynamic array .sizeof property is kind of a bait and switch
On Wednesday, 26 July 2017 at 02:24:06 UTC, WhatMeForget wrote: Static Arrays have property .sizeof which returns the array length multiplied by the number of bytes per array element. Dynamic Arrays have property .sizeof which returns the size of the dynamic array reference, which is 8 in 32-bit builds and 16 on 64-bit builds. Both actually already do exactly the same thing: .sizeof returns the size of the variable. Same thing with pointers, class references, and everything else. I've hand rolled a function which is working for me currently, but with my coding ability, I'd feel much safer with something official :) You could also do (cast(ubyte[]) array).length. It just seems like something this basic regarding dynamic arrays should just be built-in. What are you using it for?
Re: I feel the dynamic array .sizeof property is kind of a bait and switch
On Wednesday, 26 July 2017 at 02:24:06 UTC, WhatMeForget wrote: Static Arrays have property .sizeof which returns the array length multiplied by the number of bytes per array element. Dynamic Arrays have property .sizeof which returns the size of the dynamic array reference, which is 8 in 32-bit builds and 16 on 64-bit builds. Why not have dynamic arrays with a .sizeof identical to static arrays and say another property called .sizeref which handles the 32 or 64 bit references. Maybe Phobos has something that I'm not aware of? I've hand rolled a function which is working for me currently, but with my coding ability, I'd feel much safer with something official :) It just seems like something this basic regarding dynamic arrays should just be built-in. Because .sizeof has nothing to do with how many elements are in the array. It tells you how much space the array itself takes up. With static arrays, the memory for the elements if part of the array itself, so it is counted in the size. For dynamic arrays, it is not. For .sizeof to report the size of the allocated memory would be incorrect.
I feel the dynamic array .sizeof property is kind of a bait and switch
Static Arrays have property .sizeof which returns the array length multiplied by the number of bytes per array element. Dynamic Arrays have property .sizeof which returns the size of the dynamic array reference, which is 8 in 32-bit builds and 16 on 64-bit builds. Why not have dynamic arrays with a .sizeof identical to static arrays and say another property called .sizeref which handles the 32 or 64 bit references. Maybe Phobos has something that I'm not aware of? I've hand rolled a function which is working for me currently, but with my coding ability, I'd feel much safer with something official :) It just seems like something this basic regarding dynamic arrays should just be built-in.
Re: Cast to subclass in the dmd compiler
On Tuesday, 25 July 2017 at 21:06:25 UTC, unDEFER wrote: I have found the answer in the code. Right code is: Import imp = m.isImport(); if (imp !is null) Thank you. grep for kluge in code, you'll find all the places it does its own RTTI.
Re: Crypto.lib and ssl.lib for Win32
On Tuesday, 25 July 2017 at 12:11:08 UTC, MGW wrote: Where can I find the ready made for usage or how to create cryptro.lib and ssl.lib for Windows 32 that are necessary for my project? Do you have the crypto.dll and ssl.dll? If so, implib can make the lib files. If you don't have implib, email the dlls to me and I'll get it to you (destructiona...@gmail.com)
Re: Cast to subclass in the dmd compiler
I have found the answer in the code. Right code is: Import imp = m.isImport(); if (imp !is null) Thank you.
Re: Cast to subclass in the dmd compiler
On 7/25/17 4:36 PM, unDEFER wrote: Hello! I'm hacking dmd compiler and trying to look on members array just after parse module. for(uint i = 0; i < members.dim; i++) { Dsymbol m = (*members)[i]; // It is good, but further: Import imp = cast(Import) m; if (imp !is null) { printf(" import %s.%s\n", imp.packages.toChars(), imp.id.toChars()); } // ... } For really imports casting doing well. But for not imports it again casts, imp not is null and the compiler crashes. What I'm doing wrong? I think it's likely that these are actually C++ classes, and probably there is no RTTI, so this is a reinterpret cast. This is a wild guess, but much of the compiler still needs to interface with C++ backend. I would look elsewhere in the compiler to see how they handle this type of thing. Not sure of dynamic_cast support? -Steve
Cast to subclass in the dmd compiler
Hello! I'm hacking dmd compiler and trying to look on members array just after parse module. for(uint i = 0; i < members.dim; i++) { Dsymbol m = (*members)[i]; // It is good, but further: Import imp = cast(Import) m; if (imp !is null) { printf(" import %s.%s\n", imp.packages.toChars(), imp.id.toChars()); } // ... } For really imports casting doing well. But for not imports it again casts, imp not is null and the compiler crashes. What I'm doing wrong?
Re: unittest-cov - results?
On Wednesday, 5 July 2017 at 19:13:21 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 19:01:06 UTC, Jonathan M Davis wrote: On Wednesday, July 05, 2017 18:50:32 Jolly James via Digitalmars-d-learn wrote: On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote: > [...] I have changed the 'build' to 'test' in the command. Now at least I get the following message: "All unit tests have been run successfully." which should not actually happen, as my code contains an 'assert(false);' unittest. If you don't run the tests, you won't get any code coverage. Building with dub test --coverage The following command does not change anything: dub test --coverage --arch=x86_64 --compiler=ldc2 All I get is "All unit tests have been run successfully." in the command line. should do it. As for your assert(false) test failing, was it in the same module with your main in it? No, this test is actually in module 'tools.array'. Hello, I faced a similar issue today. In my case the utests weren't run because they were part of a templated class. They don't get executed in such a case because a valid utest mustn't be templated.
Re: GtkD on android?
On Saturday, 22 July 2017 at 18:59:44 UTC, FoxyBrown wrote: With LDC's new ability to do android/arm, we are missing the ability to do GUI's? Can any of the current D solutions work such as GtkD or QtD? I'm looking for something somewhat lightweight, easy to use(I find GtkD a bit funky but it does seem to work and is relatively easy once one gets through the basics). I think having a GUI builder is crucial though as it makes it so much easier in the long run. Glade is a bit funky but functional and works. Ideally I'd like to be able to make portable apps that just work across the board(mac, linux, windows, android) without much hassle. Mike said maybe later, when I asked him in January: http://forum.dlang.org/post/o4rq0i$dur$1...@digitalmars.com In the meantime, you can try DlangUI, as Seb pointed out, but I get the impression it's not touch-optimized, just like Gtk.
Re: Prevent destroy() from calling base deconstructor of a derived class?
On Tuesday, 25 July 2017 at 17:50:18 UTC, Dragonson wrote: I need to call only the deconstructor of the derived class I have an instance of, not every deconstructor in the inheritance chain. Putting `override` before the destructor doesn't compile so I'm not sure how to achieve this? Call the finalizer directly: --- import std.stdio; import std.experimental.allocator; import std.experimental.allocator.mallocator; class A { ~this() { writeln("A.~this"); } } class B : A { ~this() { writeln("B.~this"); } } void main() { B b = Mallocator.instance.make!B; b.__dtor(); } --- You're violating how inheritance is designed to work, though, so this will leave the object in an alive state (the finalizer may be called a second time on manual destroy call or GC finalization, at which point the parent class' finalizer will still be called).
Prevent destroy() from calling base deconstructor of a derived class?
I need to call only the deconstructor of the derived class I have an instance of, not every deconstructor in the inheritance chain. Putting `override` before the destructor doesn't compile so I'm not sure how to achieve this?
Re: Why structs and classes instanciations are made differently ?
On Tuesday, 25 July 2017 at 15:56:45 UTC, Houdini wrote: Yes, but it isn't the default way in C++ to do dynamic instanciation. https://github.com/isocpp/CppCoreGuidelines this? It's only 2 years old. The new operator predates it by decades.
Re: Why structs and classes instanciations are made differently ?
On Tuesday, 25 July 2017 at 15:15:59 UTC, Kagamin wrote: C++ is big, there's always something you don't know about it. Java actually instantiates classes the C++ way: http://en.cppreference.com/w/cpp/language/new Yes, but it isn't the default way in C++ to do dynamic instanciation. Usually, you do static initialization, except when the situation make taht impossible.
Re: VibeD - takeing out value from json
There was need to change one line from: auto header = result["heading"].to!string; to: auto header = result[0]["heading"].to!string;
Re: Why structs and classes instanciations are made differently ?
On Monday, 24 July 2017 at 15:21:54 UTC, Houdini wrote: D is very similar to C++ (and also grabs godd ideas from Python), but I have a naive question : why does Walter Bright chose to instanciate classes like in Java ? C++ is big, there's always something you don't know about it. Java actually instantiates classes the C++ way: http://en.cppreference.com/w/cpp/language/new
Re: unittest blocks not being run inside of class and struct templates
On Tuesday, 25 July 2017 at 02:48:57 UTC, NoBigDeal256 wrote: What is the standard way of testing class templates in the context of a library where some of the classes may never actually be used by the library itself? Write a test and instantiate whatever templates you want to test. class Test(T) { } unittest { auto t=new Test!int; assert(t.method1()==1); }
Re: Append to dynamic array that was allocated via calloc
On 7/25/17 8:40 AM, John Burton wrote: I can create a "slice" using non-gc allocated memory. int* ptr = cast(int*)calloc(int.sizeof, 10); int[] data = ptr[0..10]; If I don't want a memory leak I have to call free(ptr) somewhere as it won't be GC collected when data or ptr go out of scope. I presume there is nothing wrong with doing the above, other than perhaps there being better ways (and the memory leak if not free'd) If I then write this :- data ~= 1; What happens? It seems to successfully append an extra value to the array. It appears to "work" when I try it in my compiler but I don't understand how. Will this be trying to write beyond the memory I calloc'ed? What happens is the runtime detects that data is NOT pointing at an appendable GC-allocated block. So it reallocates the whole block in the GC, and appends your element. The original pointer is lost from data, and leaked (assuming you aren't manually freeing ptr somewhere). I'd recommend using std.container.Array[1], which should do the right thing with malloc'd memory, and give you the nice operators such as ~=. Or you have to resort to C calls for everything, if you don't want to deal with that. Optionally, if you have a defined lifetime for this array in a scope, you can do this: int *ptr = ...; // your calloc call scope(exit) free(ptr); // ensure it is freed. Make SURE you don't change ptr inside the function. Now you can use ~= on data, and it should still free the ptr at the end of the scope/function. -Steve [1] http://dlang.org/phobos/std_container_array.html#.Array
Re: unittest blocks not being run inside of class and struct templates
On 7/24/17 11:13 PM, NoBigDeal256 wrote: On Tuesday, 25 July 2017 at 02:18:41 UTC, Adam D. Ruppe wrote: On Tuesday, 25 July 2017 at 02:11:20 UTC, NoBigDeal256 wrote: it passes when it should fail because the unittest block is never executed. Why is this? Did you actually instantiate the class somewhere? A template has no concrete code unless created with an argument somewhere... What if it's instantiated in another module? Right now I'm having issues where if I run 'dmd a.d b.d -unittest' and the class template in b.d is instantiated in a.d and it compiles and the tests inside my class template run as they should, but when using 'dub test' the tests in my class template don't run at all as if it isn't instantiated in a.d even though it is. This is the original issue that I had that prompted me to create this thread. There is a whole can of worms to be dealt with if you put unit tests inside template classes or structs. For instance: struct Foo(T) { T foo() { return T.init; } unittest { Foo!int f; assert(is(typeof(f.foo()) == int)); } } the unit test is instantiated EVERY TIME Foo is instantiated, so if you have Foo!int and Foo!string both instantiated, BOTH will run this unit test. Obviously, there is no need to run both. And yes, user code will also add unit tests unwittingly to their code. In some cases, this can be useful. If you write like this: struct Foo(T) { T foo() { return T.init; } unittest { Foo f; // note the lack of ! assert(is(typeof(f.foo()) == T)); } } This means that for every instantiation, the unit test is checking that Foo.foo returns T. But this comes at a cost. Generally unit tests deal with concrete data, not abstract concepts. This means, you really only want to unit test for some instantiations, not all. In phobos, I did this for RedBlackTree. It works well, in that test coverage is nearly complete over all integral types of elements. However, there are drawbacks: 1. RedBlackTree with -unittest *will* add unit tests to user modules (unavoidable). 2. There are some tricky mechanisms to make it work properly (see the code) 3. It comes back to bite me every once in a while, bugs are filed about this. The unfortunate thing is that if you want to have non-templated unit tests, you have to put them outside the struct itself. This sucks for documented unit tests, and for tests being close to the thing being tested. I'd love to have a way to specify that a unit test is really outside the struct, but still have it written inside. I'm not sure if it would be accepted though. -Steve
Re: Append to dynamic array that was allocated via calloc
On Tuesday, 25 July 2017 at 13:24:36 UTC, Mike Parker wrote: On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote: [...] This should give you the answer: writefln("Before: ptr = %s capacity = %s", slice.ptr, slice.capacity); slice ~= 1; writefln("After: ptr = %s capacity = %s", slice.ptr, slice.capacity); It shows that before the append, the capacity is 0. That indicates that any append will cause a new allocation -- from the GC. The next writefln verifies this by showing a different value for ptr and a new capacity of 15. In order for this to work, you'll need to manually manage the length and track the capacity yourself. If all you want is to allocate space for 10 ints, but not 10 actual ints, then something like this: size_t capacity = 10; int* ints = cast(int*)malloc(int.sizeof * capacity); int[] slice = ints[0 .. 10]; slice.length = 0; slice ~= 1; --capacity; Then reallocate the array when capacity reaches 0. Or just use std.container.array.Array which does all this for you. Ok so it sounds like this is "safe" in that it will copy my data into GC memory and all work safely. I'll need to somehow keep track of my original memory and free it to avoid a memory leak... (I don't plan to do any of this, but I wanted to understand)(
Re: Append to dynamic array that was allocated via calloc
On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote: I can create a "slice" using non-gc allocated memory. int* ptr = cast(int*)calloc(int.sizeof, 10); int[] data = ptr[0..10]; If I don't want a memory leak I have to call free(ptr) somewhere as it won't be GC collected when data or ptr go out of scope. I presume there is nothing wrong with doing the above, other than perhaps there being better ways (and the memory leak if not free'd) If I then write this :- data ~= 1; What happens? It seems to successfully append an extra value to the array. It appears to "work" when I try it in my compiler but I don't understand how. Will this be trying to write beyond the memory I calloc'ed? This should give you the answer: writefln("Before: ptr = %s capacity = %s", slice.ptr, slice.capacity); slice ~= 1; writefln("After: ptr = %s capacity = %s", slice.ptr, slice.capacity); It shows that before the append, the capacity is 0. That indicates that any append will cause a new allocation -- from the GC. The next writefln verifies this by showing a different value for ptr and a new capacity of 15. In order for this to work, you'll need to manually manage the length and track the capacity yourself. If all you want is to allocate space for 10 ints, but not 10 actual ints, then something like this: size_t capacity = 10; int* ints = cast(int*)malloc(int.sizeof * capacity); int[] slice = ints[0 .. 10]; slice.length = 0; slice ~= 1; --capacity; Then reallocate the array when capacity reaches 0. Or just use std.container.array.Array which does all this for you.
Re: Append to dynamic array that was allocated via calloc
On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote: What happens? It seems to successfully append an extra value to the array. It appears to "work" when I try it in my compiler but I don't understand how. Will this be trying to write beyond the memory I calloc'ed? The language makes no guarantee. It may append in-place if the operating system finds out that the memory after it is not in use. But it may also allocate a whole new array (with gc) and copy the whole thing there. And since the original array was allocated manually, that results in a memory leak. Unless you check for that by storing the appended array in a new variable and compare their pointers. The why part here is for efficiency reasons. We do not want to copy every time one appends, but if there's something in way that just needs to be done. I think the correct way here is to use realloc(). Or std.container.Array. It is well possible there are other good options too.
Append to dynamic array that was allocated via calloc
I can create a "slice" using non-gc allocated memory. int* ptr = cast(int*)calloc(int.sizeof, 10); int[] data = ptr[0..10]; If I don't want a memory leak I have to call free(ptr) somewhere as it won't be GC collected when data or ptr go out of scope. I presume there is nothing wrong with doing the above, other than perhaps there being better ways (and the memory leak if not free'd) If I then write this :- data ~= 1; What happens? It seems to successfully append an extra value to the array. It appears to "work" when I try it in my compiler but I don't understand how. Will this be trying to write beyond the memory I calloc'ed?
Crypto.lib and ssl.lib for Win32
I want to make an application with use http2.d from packet arsd. Where can I find the ready made for usage or how to create cryptro.lib and ssl.lib for Windows 32 that are necessary for my project?
Re: traits compiles does not work for symbols from other modules
On Tuesday, 25 July 2017 at 11:34:23 UTC, Andre Pany wrote: On Tuesday, 25 July 2017 at 08:30:43 UTC, ag0aep6g wrote: Works for me. What compiler are you using? I reduced the example too lot. The issue is occuring if there is also a package.d is involved. m1.d --- module m1; import sub; // Does not throw if replaced with: import sub.m2; class Foo { int foo; } void main() { static assert(__traits(compiles, m1.Foo.foo)); mixin(`static assert(__traits(compiles, sub.m2.Bar.bar));`); } sub/m2.d -- module sub.m2; class Bar { int bar; } sub/package.d -- module sub; public import sub.m2; I use DMD master (as I already need the static foreach) on windows 10. DMD32 D Compiler v2.075.0-rc1-master-af3eacf [...] Kind regards André Issue created: https://issues.dlang.org/show_bug.cgi?id=17683 Is there a known workaround? Kind regards André
Re: traits compiles does not work for symbols from other modules
On Tuesday, 25 July 2017 at 08:30:43 UTC, ag0aep6g wrote: Works for me. What compiler are you using? I reduced the example too lot. The issue is occuring if there is also a package.d is involved. m1.d --- module m1; import sub; // Does not throw if replaced with: import sub.m2; class Foo { int foo; } void main() { static assert(__traits(compiles, m1.Foo.foo)); mixin(`static assert(__traits(compiles, sub.m2.Bar.bar));`); } sub/m2.d -- module sub.m2; class Bar { int bar; } sub/package.d -- module sub; public import sub.m2; I use DMD master (as I already need the static foreach) on windows 10. DMD32 D Compiler v2.075.0-rc1-master-af3eacf dmd -run m1.d sub/package.d sub/m2.d Kind regards André
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:42:40 UTC, Basile B. wrote: I think that you underestimate the amount of work needed and your solution which is to use the compiler with -o- looks bad. What you really need is a compiler front-end which is basically what libdparse + DSymbol are. DCD uses them. No, with feature like auto func() and void templ(T)(T a) if (is(a)) {} It is impossible to consider all it by myself. It means write the second compiler. So I just want to use the ready compiler.
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:35:14 UTC, Andrea Fontana wrote: If you want to add UFCS suggestions to DCD it would be useful for your project and all other IDEs too! Andrea Thank you, I will think. But if it was easy, authors self would do it :-)
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:32:11 UTC, unDEFER wrote: On Tuesday, 25 July 2017 at 10:24:13 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:23:33 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:06:47 UTC, unDEFER wrote: Any ideas? I think you should use/contribute to DCD project https://github.com/dlang-community/DCC Andrea Sorry, this is the right link: https://github.com/dlang-community/DCD Yes this project where "Not working: UFCS suggestions and That one feature that you REALLY needed".. I want to have all features that I really need :-) But If I will not find how do UFCS suggestions fast, I probably will use DCD for all other things.. I think that you underestimate the amount of work needed and your solution which is to use the compiler with -o- looks bad. What you really need is a compiler front-end which is basically what libdparse + DSymbol are. DCD uses them.
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:32:11 UTC, unDEFER wrote: Yes this project where "Not working: UFCS suggestions and That one feature that you REALLY needed".. I want to have all features that I really need :-) But If I will not find how do UFCS suggestions fast, I probably will use DCD for all other things.. If you want to add UFCS suggestions to DCD it would be useful for your project and all other IDEs too! Andrea
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:24:13 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:23:33 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:06:47 UTC, unDEFER wrote: Any ideas? I think you should use/contribute to DCD project https://github.com/dlang-community/DCC Andrea Sorry, this is the right link: https://github.com/dlang-community/DCD Yes this project where "Not working: UFCS suggestions and That one feature that you REALLY needed".. I want to have all features that I really need :-) But If I will not find how do UFCS suggestions fast, I probably will use DCD for all other things..
VibeD - takeing out value from json
Hello I wrote such code to test restAPI client: /// //app.d /// import vibe.d; import sites.frontpage; import msfrontpage; shared static this() { // the router will match incoming HTTP requests to the proper routes auto router = new URLRouter; // registers each method of WebChat in the router auto api = new RestInterfaceClient!IfFrontPageAPI("http://127.0.0.1:8090/;); router.registerWebInterface(new SilesianCloud(api)); // match incoming requests to files in the public/ folder router.get("*", serveStaticFiles("public/")); auto settings = new HTTPServerSettings; settings.port = 8080; settings.bindAddresses = ["::1", "127.0.0.1"]; listenHTTP(settings, router); logInfo("Please open http://127.0.0.1:8080/ in your browser."); } // //frontpage.d // module sites.frontpage; import vibe.d; import msfrontpage; final class SilesianCloud { this(RestInterfaceClient!(IfFrontPageAPI) tmp) { this.frontpageapi = tmp; } public: // GET / void get() { Json result = frontpageapi.getHome(); logInfo(result.toString); auto header = result["heading"].get!string; logInfo(result["heading"].get!string); render!("frontpage.dt",header); } private: RestInterfaceClient!(IfFrontPageAPI) frontpageapi; } But it looks like my value is not "extracted" from Json in proper string, even logInfo(header) shows "nothing" and in web broser im getting: 500 - Internal Server Error Internal Server Error Internal error information: std.json.JSONException@std/json.d(1330): Got JSON of type array, expected object. ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/data/json.d:1054 const(pure @safe void function(immutable(char)[])) vibe.data.json.Json.checkType!(vibe.data.json.Json[immutable(char)[]]).checkType [0x88f762] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/data/json.d:339 ref vibe.data.json.Json vibe.data.json.Json.opIndex(immutable(char)[]) [0x977d4e] source/sites/frontpage.d:20 void sites.frontpage.SilesianCloud.get() [0x7d129c] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/web/web.d:822 void vibe.web.web.handleRequest!("get", void sites.frontpage.SilesianCloud.get(), sites.frontpage.SilesianCloud).handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse, sites.frontpage.SilesianCloud, vibe.web.web.WebInterfaceSettings) [0x7bd220] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/web/web.d:185 void vibe.web.web.__T20registerWebInterfaceHTC5sites9frontpage13SilesianCloudVE4vibe3web6common11MethodStylei5Z.registerWebInterface(vibe.http.router.URLRouter, sites.frontpage.SilesianCloud, vibe.web.web.WebInterfaceSettings).__lambda4!(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse).__lambda4(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) [0x7bca20] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/router.d:268 _D4vibe4http6router9URLRouter13handleRequestMFC4vibe4http6server17HTTPServerRequestC4vibe4http6server18HTTPServerResponseZ21__T9__lambda4TmTAAyaZ9__lambda4MFmMAAyaZb [0x864a0e] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/router.d:595 const(bool function(immutable(char)[], scope bool delegate(ulong, scope immutable(char)[][]))) vibe.http.router.MatchTree!(vibe.http.router.Route).MatchTree.doMatch [0x8657f5] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/router.d:528 bool vibe.http.router.MatchTree!(vibe.http.router.Route).MatchTree.match(immutable(char)[], scope bool delegate(ulong, scope immutable(char)[][])) [0x865047] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/router.d:261 void vibe.http.router.URLRouter.handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) [0x8646ad] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/server.d:1981 bool vibe.http.server.handleRequest(vibe.core.stream.Stream, vibe.core.net.TCPConnection, vibe.http.server.HTTPListenInfo, ref vibe.http.server.HTTPServerSettings, ref bool) [0x8a7490] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/server.d:1737 void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPListenInfo) [0x8a5a9a] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/server.d:1618 void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings).doListen(vibe.http.server.HTTPListenInfo, bool, bool).__lambda4(vibe.core.net.TCPConnection) [0x8a5538] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/core/drivers/libevent2_tcp.d:618 void vibe.core.drivers.libevent2_tcp.ClientTask.execute() [0x964098] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/core/core.d:595 void vibe.core.core.makeTaskFuncInfo!(void delegate()).makeTaskFuncInfo(ref void delegate()).callDelegate(vibe.core.core.TaskFuncInfo*) [0x81193f]
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:23:33 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:06:47 UTC, unDEFER wrote: Any ideas? I think you should use/contribute to DCD project https://github.com/dlang-community/DCC Andrea Sorry, this is the right link: https://github.com/dlang-community/DCD
Re: How to make autocompletion for IDE?
On Tuesday, 25 July 2017 at 10:06:47 UTC, unDEFER wrote: Any ideas? I think you should use/contribute to DCD project https://github.com/dlang-community/DCC Andrea
How to make autocompletion for IDE?
Hello! I have written my text editor with highlighting, and now I want to add IDE features to it. I want to make autocompletion, but not only complete members of class/struct, but also all functions which maybe used with type, if the first argument of the function is this type. I.e. in "a".fromStringz() style instead of fromStringz(a). For it I will take editable now sources, add to it lines like this: foreach(d; __traits(allMembers, std.string)) { if (is(typeof(mixin("\"abc\"."~d~"()" pragma(msg, "\"abc\"."~d~"()" ); } So it will print all methods which can be called for strings as "abc".function(). And I want to compile this file with options "-c -o-". The problem that compilation for files with avarage count of imports may take e.g. 7 seconds.. 7 seconds is too long to wait autocompletion. But compiler really do this "task" with autocompletion requests very fast. And I think how to implement the next: Add the task to some other file task.d. import it to the first file with mixin(import("task.d")). Change syscall open() to my function which if will see that it opens "task.d" waiting the time when user will ask autocomplete (press Ctrl-space), and then write the task to "task.d" and continue execution of compiler... The problem that I see in this conception is that seems not possible write such import which will be imported only when compiler starts handle templates and simultaneously in the place where will be accessed all local variables of a function. Any ideas?
Re: traits compiles does not work for symbols from other modules
On 07/24/2017 11:40 PM, Andre Pany wrote: m1.d - module m1; import m2; class Foo { int foo; } void main() { static assert(__traits(compiles, m1.Foo.foo)); static assert(__traits(compiles, m2.Bar.bar)); } m2.d --- module m2; class Bar { int bar; } Why does the second assert throws? What can I use instead of __traits(compiles,...) ? Works for me. What compiler are you using?
Re: Why structs and classes instanciations are made differently ?
On Monday, 24 July 2017 at 17:42:30 UTC, Steven Schveighoffer wrote: In D, I would use classes for any time I need polymorphism, and use structs otherwise. OK, I'll adhere to this method. :) Thanks to all for your answers.
Re: How does one determine the UDAs of all symbols contained in a given module?
On 2017-07-21 06:16, Andrew Edwards wrote: Thanks... Minus the AliasSeq bit, this is pretty much what I've been working with since talking to Brain. The main problem I'm facing is that it fails to compileif any of the symbols in the imported module is marked private. Ah, yes. That's a known problem. I think it was agreed that everything should be accessible through introspection. -- /Jacob Carlborg