Re: Any sample for DFL library?
No, win32 only. It didn't seem relevant in first post, but I am screen reader user and GTK is totally inaccessible / unusable on Windows. Dňa 7. 10. 2012 21:18 Michael wrote / napísal(a): gtkD ?
Re: Any sample for DFL library?
Thank you. Dňa 7. 10. 2012 21:26 Andrej Mitrovic wrote / napísal(a): On 10/7/12, Lubos Pintes lubos.pin...@gmail.com wrote: Hi, There are at least two interesting GUI libraries for Windows: DGUI and DFL. But there seems to be no sample code for DFL. Does someone have any samples for DFL? And yes, I know about DWT, but it is a bit heavy-weight. There are older ones here: http://www.dprogramming.com/dfl/snapshots/dfl-20110523.zip Look in packages/dfl/examples. I don't know why they're not on the new github page yet https://github.com/Rayerd/dfl
Re: Any sample for DFL library?
I fixed that for myself after checkout, it only needed some cast(WNDPROC) etc. on some places. Don't know however if it doesn't have another problems, I ran some random samples and from screen reader's point of view, it worked fine. (besides owner-drawn labels, which are not so fine. :-)) Dňa 7. 10. 2012 22:47 Mike James wrote / napísal(a): Lubos Pintes wrote in message news:k4skro$n6q$1...@digitalmars.com... Hi, There are at least two interesting GUI libraries for Windows: DGUI and DFL. But there seems to be no sample code for DFL. Does someone have any samples for DFL? And yes, I know about DWT, but it is a bit heavy-weight. DGUI doesn't compile with the latest D compiler - it's not been updated for nearly a year.
Unicode encodings and string literals
Hi, I am playing with samples from Petzold's Programming Windows converted by Andrej Mitrovic. Many thanks, Andrej. :-) My question is about string conversion. There is a function in virtually every sample named toUTF16z, which if I understand properly, converts string to UTF-16, so that they can be sent to various Windows API functions. But string literals, for example in MessageBox, are fine, no conversion is needed. I don't understand the magic, what is converted, and when? If some variable was used e.g. appName.toUTF16z, and not Error.toUTF16z
Re: Unicode encodings and string literals
On 2012-10-08 10:06, Lubos Pintes wrote: Hi, I am playing with samples from Petzold's Programming Windows converted by Andrej Mitrovic. Many thanks, Andrej. :-) My question is about string conversion. There is a function in virtually every sample named toUTF16z, which if I understand properly, converts string to UTF-16, so that they can be sent to various Windows API functions. But string literals, for example in MessageBox, are fine, no conversion is needed. I don't understand the magic, what is converted, and when? If some variable was used e.g. appName.toUTF16z, and not Error.toUTF16z Without looking at the code, this is my guess: The toUTF16z function converts a D string, of any Unicode encoding, to UTF-16 and converts that to a C string. String literals in D have a trailing null character \0 included making them compatible with functions expecting C strings. String variables on the other do not have the trailing null character and therefore needs a conversion. -- /Jacob Carlborg
Growing multidimensional dynamic arrays
Hi all, This seems like something that should be possible: how do I grow multidimensional arrays? I want something like this: struct X{ ... }; X*[][] listOfLists; foreach ( x ; otherListOfX ) { if ( newListForArbitraryReason ) { listOfLists ~= new X*[]; } listOfLists[$] ~= x; } Now, this doesn't compile, because I _have_ to give a size to new X*[](arbitrary_number), and the listOfLists[$] ~= x; line never works (hangs at runtime). So, how would I go about doing this? My apologies if this is something really obvious.
CFTE+DevIL=?
Hi! I need to load some textures for my game,but I woud like to do it in compile time. I know that CTFE imposes restrictions on functions.So can I execute some DevIL(Derelict3) functions?
Re: Growing multidimensional dynamic arrays
On 10/08/2012 06:12 AM, KillerSponge wrote: Hi all, This seems like something that should be possible: how do I grow multidimensional arrays? I want something like this: struct X{ ... }; X*[][] listOfLists; foreach ( x ; otherListOfX ) { if ( newListForArbitraryReason ) { listOfLists ~= new X*[]; } listOfLists[$] ~= x; } Now, this doesn't compile, because I _have_ to give a size to new X*[](arbitrary_number), and the listOfLists[$] ~= x; line never works (hangs at runtime). So, how would I go about doing this? My apologies if this is something really obvious. I don't see the need for 'new' nor the use of a pointer, so I will not use them (yet): :) import std.stdio; struct X { int i; } void main() { X[][] listOfLists; auto otherListOfX = [ X(1), X(2), X(3) ]; auto newListForArbitraryReason = true; foreach (x; otherListOfX) { if (newListForArbitraryReason) { X[] newList = [ x ]; listOfLists ~= newList; } } writeln(listOfLists); } The body of foreach can be shorter: listOfLists ~= [ x ]; Also note that - There is no need for the semicolon at the end of the struct definition. - $ is not a valid index value. The last element is indexed by $-1. Ali -- D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html
Re: CFTE+DevIL=?
Zhenya wrote: Hi! I need to load some textures for my game,but I woud like to do it in compile time. I know that CTFE imposes restrictions on functions.So can I execute some DevIL(Derelict3) functions? CTFE can only evaluate D functions that have their bodies available. It means that external code coming from C or D external library can't be evaluated.
Re: Growing multidimensional dynamic arrays
On Monday, 8 October 2012 at 13:56:00 UTC, Ali Çehreli wrote: I don't see the need for 'new' nor the use of a pointer, so I will not use them (yet): :) import std.stdio; struct X { int i; } void main() { X[][] listOfLists; auto otherListOfX = [ X(1), X(2), X(3) ]; auto newListForArbitraryReason = true; foreach (x; otherListOfX) { if (newListForArbitraryReason) { X[] newList = [ x ]; listOfLists ~= newList; } } writeln(listOfLists); } The body of foreach can be shorter: listOfLists ~= [ x ]; Also note that - There is no need for the semicolon at the end of the struct definition. - $ is not a valid index value. The last element is indexed by $-1. Ali Ah, that works great (even with pointers ;)! Thanks a lot! :) It seems so obvious now. And the use of $ was indeed a stupid mistake on my part. I guess I was confused because of the way it is often used in slicing. I really should pay attention to that :)
Re: Struct polymorphism?
Perhaps someone can help explain this mystery. I've got a working system, except when it's coming to an unknown function inside my structs. Perhaps to note opDispatch is added via a mixin template, not sure if that makes a difference. Error: function expected before (), not 'this.polyBase.opDispatch!(orig)' struct Base { PolyMorph polyBase; alias polyBase this; string callsOrig() { return orig(); //dies here } } //opDispatch signature auto ref opDispatch(string fun, Args ...)(auto ref Args args);
Re: ddoc - documenting private variables
On 10/07/2012 12:33 PM, Adam D. Ruppe wrote: On Sunday, 7 October 2012 at 19:36:39 UTC, Charles Hixson wrote: FWIW, I have absolutely NO knowledge of JSON, except that it's something to do with web pages (well, and it's a language or possibly a library). I haven't actually used that project (I just saw the link and figured it might help) but you can make json with dmd. Run dmd -X -D yourfile.d and it spits out yourfile.json. But another option might be to just modify your copy of dmd to output private things too. Open the file dmd2/src/dmd/doc.c and search for the term PROTprivate. Simply comment that part so it doesn't return. For example: void EnumDeclaration::emitComment(Scope *sc) { if (prot() == PROTprivate) return; Just comment that out and repeat for each time you see it. I count six occurrences of that in the dmd source. And then there's this: void Declaration::emitComment(Scope *sc) { //printf(Declaration::emitComment(%p '%s'), comment = '%s'\n, this, toChars(), comment); //printf(type = %p\n, type); if (protection == PROTprivate || !ident || (!type !isCtorDeclaration() !isAliasDeclaration())) return; And you can probably just comment that protection clause there too. Then recompile the dmd (make -f posix.mak on linux and I think make -f win32.mak on windows) and use your customized compiler. That seems, to me, a much more reasonable solution. I'm going to flag this important. But I'll probably use DOxygen, because I don't like the on-going maintenance, and because ddoc comments are too verbose (more in vertical space than in horizontal space). I'll certainly keep that option in mind, however, in case I run into too many limits with DOxygen.
Re: CFTE+DevIL=?
On 2012-10-08 15:24, Zhenya wrote: Hi! I need to load some textures for my game,but I woud like to do it in compile time. I know that CTFE imposes restrictions on functions.So can I execute some DevIL(Derelict3) functions? What you can do is importing the textures into the executable, at compile time, if that helps: http://dlang.org/expression.html#ImportExpression -- /Jacob Carlborg
VisualD: Is keyboard navigation in project properties broken?
Hi, I installed VisualD, together with VS Shell, because I have only express versions of VS 2008 on my system, win 7 64 bit. As a screen reader user, I heavily depend on keyboard. I successfully set up a testing project, dependend on windows api bindings. I needed to set a version identifier, so I went to project properties, set configuration to all, and platform to win32. Then I went to the options tree view, expanded the Compiler/General and I was unable to tab to options I could possibly set. Only Ok, Cancel, Configuration combo box etc. was available... So is this a bug? Or something weird only on my system?
Re: Using inout in delegates
On 10/05/2012 04:09 PM, Ali Çehreli wrote: ... This workaround makes the compiler happy: void foo (inout(int)[] arr) { auto a = (inout int) { auto b = arr[0]; }; } But probably not what you want. :/ IIRC, inout has bugs and incomplete implementation. I think this should be in the bug database. Ali The original behaviour is to be expected and the workaround exploits a compiler bug. The correct way to get rid of the compile error is: void foo(inout(int)[] arr){ auto a = { const b = arr[0]; } // or int b = arr[0]; }
Re: Struct polymorphism?
On Monday, 8 October 2012 at 15:23:58 UTC, Era Scarecrow wrote: Error: function expected before (), not 'this.polyBase.opDispatch!(orig)' I think this is a compiler bug. It complains about calling opDispatch, however it doesn't complain if you explicitly call 'this'. Should adding 'this' be required? I am using the -property switch so it's a little more strict, but that doesn't seem to change the results. I can't just start adding 'this' to all my function as outside normal functions/variables won't ever be seen. struct S { Something polyBase; alias polyBase this; //opDispatch string callsOrig() { return orig;//works but misleading return orig(); //breaks return orig(1); //breaks too return this.orig(); //works } } struct Something { auto ref opDispatch(string fun, Args ...)(auto ref Args args) @property; } My experiments concentrating on this part rather than with arguments, those will come later when this works.
Re: Struct polymorphism?
On 10/08/2012 03:19 PM, Era Scarecrow wrote: On Monday, 8 October 2012 at 15:23:58 UTC, Era Scarecrow wrote: Error: function expected before (), not 'this.polyBase.opDispatch!(orig)' I think this is a compiler bug. It complains about calling opDispatch, however it doesn't complain if you explicitly call 'this'. Should adding 'this' be required? I don't know all of the design decisions behind opDispatch, but I would be happier to have to type this. when inside the struct. Otherwise, any struct that defined opDispatch would miss out on compiler's static name checking. What if orig() has actually been a mistyped free-standing function name? Being forced to type this.orig() makes it explicit. And to me, this seems even better: return polyBase.orig(1); I can't just start adding 'this' to all my function as outside normal functions/variables won't ever be seen. Sorry, I can't understand the problem that you describe in that sentence. Ali
Re: Struct polymorphism?
On Monday, 8 October 2012 at 22:57:04 UTC, Ali Çehreli wrote: I don't know all of the design decisions behind opDispatch, but I would be happier to have to type this. when inside the struct. Otherwise, any struct that defined opDispatch would miss out on compiler's static name checking. What if orig() has actually been a mistyped free-standing function name? Being forced to type this.orig() makes it explicit. And to me, this seems even better: return polyBase.orig(1); Yes likely this is what will happen.. Just seems like it isn't needed. I can't just start adding 'this' to all my function as outside normal functions/variables won't ever be seen. Sorry, I can't understand the problem that you describe in that sentence. Hmmm added a this.writeln() and it worked fine without calling opDispatch. How odd. Still seems like a compiler bug to me. The idea behind that i'm experimenting with is in reality the struct contained two functions. So.. struct S { Something polyBase; alias polyBase this; //opDispatch string orig() { return some string; } string callsOrig() { return orig(); } } With that everything is happy. Now if I rename orig to Poly_orig, then callsOrig complains and the issue comes up. The polyBase will check among the rules it has and adds Poly_ to the functions while it's checking them (among other ones), before finally calling S.Poly_orig() with all it's arguments. So it will look something like this. struct Data { string msg; } struct Something { Data data; //shared data auto ref opDispatch(string op, Args ...)(auto ref Args args) { static if (op == orig) { return (cast(S) data).Poly_orig(); } else { static assert(0, op ~ - Not found); //205 } } } struct S { Something polyBase; alias polyBase this; //opDispatch //string orig() {//statically assigned string Poly_orig() { //opDispatch calls now return some string; } string callsOrig() { return orig(); //220 return this.orig(); return polyBase.orig(); } string oddball() { //asserts can't find blarg or Poly_blarg in opDispatch return blarg(); //227 return this.blarg(); //228 } } test.d(220): Error: function expected before (), not 'this.polyBase.opDispatch!(orig)' test.d(227): Error: function expected before (), not 'this.polyBase.opDispatch!(blarg)' test.d(205): Error: static assert blarg - Not found test.d(228):instantiated from here: opDispatch!(blarg,) I'd rather have where once I get my code debugged for a struct that I don't have to suddenly add this. or polyBase to all my functions after I rename the functions to Poly_. If it's a necessary evil than I'll accept it.
Re: CFTE+DevIL=?
On Monday, 8 October 2012 at 18:07:49 UTC, Jacob Carlborg wrote: On 2012-10-08 15:24, Zhenya wrote: Hi! I need to load some textures for my game,but I woud like to do it in compile time. I know that CTFE imposes restrictions on functions.So can I execute some DevIL(Derelict3) functions? What you can do is importing the textures into the executable, at compile time, if that helps: http://dlang.org/expression.html#ImportExpression That can bring the image into the app as an array of bytes. Then at runtime, you can use DevIL to load the image data from the byte array. I've got a blog post[1] about doing this very thing (with SDL rather than DevIL, but it's all the same). [1] http://www.gamedev.net/blog/1140/entry-2254294-compiling-data-into-a-d-executable/
Re: std.algorithm.skipOver broken / misbehaving?
On Friday, 5 October 2012 at 08:53:22 UTC, Era Scarecrow wrote: Mmmm glancing at the notes again, maybe I misread it and it only skips if the beginning equals, rather than if it contains... Kinda annoying since it sounds like what I wanted would work... Pretty sure the semantics you want are in, findSkip.