Regex replace followed by number.

2016-06-01 Thread Taylor Hillegeist via Digitalmars-d-learn
So I have ran into an issue where I want to replace a string with regex. but i cant figure out how to replace items followed by a number. i use "$1001" to do paste first match but this thinks I'm trying using match 1001 but if i try ${1}001 it gives me an error saying that it cant match the

Re: Calling C++ code with pointer** argument

2016-06-01 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 07:29:56 UTC, abad wrote: That does work, though I have to explicitly cast it in my caller as well. Like this: doesNotLink(cast(const(char)**)baz2); It's a bit troublesome as my code will include quite a lot of calls like this. Casting is not necessary with the

Unittests run without error when done individually, but when unittesting the package some fail

2016-06-01 Thread pineapple via Digitalmars-d-learn
How this could possibly be happening is confounding me and I have no idea if it's something I missed or some contrived compiler bug. This is the package.d that previously I've compiled with unittest every so often as a way of doing regression testing -

Quite sure a simple basic problem...

2016-06-01 Thread WhatMeWorry via Digitalmars-d-learn
I've got a fairly complex D project (25+ modules) that has grown haphazardly over time. So it is not well designed. But I want to get the thing fully ported before refining the code. (that's called refactoring, I believe?) Anyway, there is a new module called audio.d which which has all the

Re: Quite sure a simple basic problem...

2016-06-01 Thread docandrew via Digitalmars-d-learn
On Thursday, 2 June 2016 at 00:37:58 UTC, WhatMeWorry wrote: I've got a fairly complex D project (25+ modules) that has grown haphazardly over time. So it is not well designed. But I want to get the thing fully ported before refining the code. (that's called refactoring, I believe?) Anyway,

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread ZILtoid1991 via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 23:35:40 UTC, Era Scarecrow wrote: On Wednesday, 1 June 2016 at 23:23:49 UTC, ZILtoid1991 wrote: After some debugging, I found out that the p pointer becomes null at the end instead of pointing to a value. I have no experience with using in-line assemblers

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread ZILtoid1991 via Digitalmars-d-learn
On Thursday, 2 June 2016 at 00:51:15 UTC, ZILtoid1991 wrote: On Wednesday, 1 June 2016 at 23:35:40 UTC, Era Scarecrow wrote: On Wednesday, 1 June 2016 at 23:23:49 UTC, ZILtoid1991 wrote: I could get the code working with a bug after replacing pmulhuw with pmullw, but due to integer overflow

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 2 June 2016 at 00:52:48 UTC, ZILtoid1991 wrote: On Thursday, 2 June 2016 at 00:51:15 UTC, ZILtoid1991 wrote: I could get the code working with a bug after replacing pmulhuw with pmullw, but due to integer overflow I get a glitched image. I try to get around the fact that pmulhuw

Using referenceCounters

2016-06-01 Thread Begah via Digitalmars-d-learn
I started using reference counters for my assets in my application : - Images - Models - Such as : alias ModelType = RefCounted!Model; struct Model { static ModelType create(Mesh mesh, Shader shader) { ModelType model = ModelType(); model.mesh

Re: Calling C++ code with pointer** argument

2016-06-01 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 16:16:26 UTC, Kagamin wrote: Can you declare it as const char*const* one the C++ side? Just to state the problem clearly, D's const is transitive, C++ it is not. C linkage doesn't care about const, so you can specify it however you want. In C++ the const is

Re: Is there any overhead iterating over a pointer using a slice?

2016-06-01 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 31 May 2016 at 20:52:20 UTC, Johan Engelen wrote: On Tuesday, 31 May 2016 at 18:55:18 UTC, Gary Willoughby wrote: If I have a pointer and iterate over it using a slice, like this: T* foo = foreach (element; foo[0 .. length]) { ...

Re: Using referenceCounters

2016-06-01 Thread Begah via Digitalmars-d-learn
I can see two option but neither of them is really portable : I can set _store public in std.typecons or i could create a setter method. Neither of these options is portable because i need to directly edit the librarie's source code so i can't jump from one computer to the next without having

Creating a "fixed-range int" with opDispatch and/or alias this?

2016-06-01 Thread Mark Isaacson via Digitalmars-d-learn
I'm trying to create a type that for all intents and purposes behaves exactly like an int except that it limits its values to be within a certain range [a,b]. Theoretically, I would think this looks something like: struct FixedRangeInt { this(int min, int max, int value=0) { this.min =

Re: Using referenceCounters

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 18:14:33 UTC, Begah wrote: I started using reference counters for my assets in my application : - Images - Models - For my resource manager I started out with something similar to what you're describing, but I eventually changed the design which turned

Re: Creating a "fixed-range int" with opDispatch and/or alias this?

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 19:59:51 UTC, Mark Isaacson wrote: FWIW, the fixed range int part of this question is just an example, I'm mostly just interested in whether this idea is possible without a lot of bloat/duplication. I suspect not.. Here's how std.typecons.Proxy is doing it:

adamdruppe: Drawing scaled image

2016-06-01 Thread Pie? via Digitalmars-d-learn
I found your git hub and tried simpledisplay and png. I had virtually no problems getting them working from the get go! Thanks for your hard work!!! You deserve a cookie, or a million bucks! I'm curious about how to draw a scaled image. I would like to have a "global" scale for my image

Re: Speed up `dub`.

2016-06-01 Thread ciechowoj via Digitalmars-d-learn
Hahahaa. Who could possibly think that `build.sh` builds dub in debug mode? With -release -O -inline -m64 it runs 5 times faster : P. It made my day...

Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread ZILtoid1991 via Digitalmars-d-learn
Here's the assembly code for my alpha-blending routine: ubyte[4] src = *cast(ubyte[4]*)(palette.ptr + 4 * *c); ubyte[4] *p = cast(ubyte[4]*)(workpad + (offsetX + x)*4 + offsetY); asm{//moving the values to their destinations movdMM0, p; movdMM1, src; movqMM5, alpha; movqMM7,

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 23:23:49 UTC, ZILtoid1991 wrote: After some debugging, I found out that the p pointer becomes null at the end instead of pointing to a value. I have no experience with using in-line assemblers (although I made a few Hello World programs for MS-Dos with a

Re: Unittests run without error when done individually, but when unittesting the package some fail

2016-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 01, 2016 23:58:52 pineapple via Digitalmars-d-learn wrote: > How this could possibly be happening is confounding me and I have > no idea if it's something I missed or some contrived compiler bug. > > This is the package.d that previously I've compiled with unittest > every so

Re: adamdruppe: Drawing scaled image

2016-06-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 2 June 2016 at 03:19:20 UTC, Pie? wrote: I'm curious about how to draw a scaled image. There's a few general options: 1) Scale it yourself in-memory then draw. This is a pain, I don't think my public libraries have a scale method 2) If on MS Windows, you can resize the

Asio Bindings?

2016-06-01 Thread Pie? via Digitalmars-d-learn
Does anyone know if there is any Asio bindings or direct D available that allows for IO?

Re: adamdruppe: Drawing scaled image

2016-06-01 Thread Pie? via Digitalmars-d-learn
On Thursday, 2 June 2016 at 03:37:01 UTC, Adam D. Ruppe wrote: On Thursday, 2 June 2016 at 03:19:20 UTC, Pie? wrote: I'm curious about how to draw a scaled image. There's a few general options: 1) Scale it yourself in-memory then draw. This is a pain, I don't think my public libraries have

Re: Asio Bindings?

2016-06-01 Thread Mithun Hunsur via Digitalmars-d-learn
On Thursday, 2 June 2016 at 04:02:36 UTC, Pie? wrote: Does anyone know if there is any Asio bindings or direct D available that allows for IO? Check out vibe.d: https://vibed.org/ - it includes a fairly complete implementation of asynchronous I/O, among other things.

Calling C++ code with pointer** argument

2016-06-01 Thread abad via Digitalmars-d-learn
D source: extern(C++) void thisWorks(const char* test); extern(C++) void doesNotLink(const char** test); void main() { char* baz1; char** baz2; thisWorks(baz1); doesNotLink(baz2); } CPP source: #include void thisWorks(const char* test) { printf("hi\n"); } void

Re: Calling C++ code with pointer** argument

2016-06-01 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 07:09:16 UTC, abad wrote: D source: extern(C++) void thisWorks(const char* test); extern(C++) void doesNotLink(const char** test); void main() { char* baz1; char** baz2; thisWorks(baz1); doesNotLink(baz2); } CPP source: #include void

Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Anthony Monterrosa via Digitalmars-d-learn
I've recently been trying to convince a friend of mine that D has at least the functionality of C++, and have been learning the language over C++ for a few months. Memory management is pretty important to him, and a subject I'm honestly curious about as well. I was wondering: what's the

Re: Calling C++ code with pointer** argument

2016-06-01 Thread abad via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 07:17:04 UTC, Mike Parker wrote: On Wednesday, 1 June 2016 at 07:09:16 UTC, abad wrote: Try this: extern(C++) void DoesNotLink(const(char)**); That does work, though I have to explicitly cast it in my caller as well. Like this:

Re: D, GTK, Qt, wx,…

2016-06-01 Thread MGW via Digitalmars-d-learn
How can we build QtE5 and/or the examples? Download qte5.zip from github. Unzip it to qte5-master. If you have Windows 32 then copy qte5-master/windows32/QtE5Widgets32.dll to folder qte5-master. Copy RunTime Qt-5 (all files and folders from qte5-master/windows32/rt_Qt5_windows32.zip) to

Re: Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Seb via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 07:59:50 UTC, Anthony Monterrosa wrote: I've recently been trying to convince a friend of mine that D has at least the functionality of C++, and have been learning the language over C++ for a few months. Memory management is pretty important to him, and a subject

Re: Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
I was wondering: what's the preferred method for deterministic memory management? You may be interested in RefCounted. It only works for structs, not classes, but it's still useful. - Classes/Structs have constructors and destructors. I am unconfident with my knowledge as to how this works

Re: Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread rikki cattermole via Digitalmars-d-learn
On 01/06/2016 7:59 PM, Anthony Monterrosa wrote: I've recently been trying to convince a friend of mine that D has at least the functionality of C++, and have been learning the language over C++ for a few months. Memory management is pretty important to him, and a subject I'm honestly curious

Base64 of String without casting

2016-06-01 Thread tcak via Digitalmars-d-learn
I understand that Base64 uses Ranges, and since String is seen and used as unicode by Ranges (please tell me if I am wrong). I am guessing, for this reason, auto btoa = std.base64.Base64.encode("Blah"); doesn't work. You need to be casting the string to ubyte[] to make it work which doesn't

Re: Base64 of String without casting

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 09:31:51 UTC, tcak wrote: I understand that Base64 uses Ranges, and since String is seen and used as unicode by Ranges (please tell me if I am wrong). I am guessing, for this reason, auto btoa = std.base64.Base64.encode("Blah"); doesn't work. You need to be

Re: Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 08:53:01 UTC, Rene Zwanenburg wrote: I was wondering: what's the preferred method for deterministic memory management? You can annotate your functions as @nogc. The compiler will disallow any potential GC use, including calling other functions that are not