Re: WindowsAPI Binding - Linker Errors

2011-06-13 Thread Mike Parker
On 6/13/2011 9:00 PM, Loopback wrote: Hello! I've been test programming win32 applications recently, and since the phobos win32 library is so limited, I decided to download and test the WindowsAPI Binding (http://www.dsource.org/projects/bindings/wiki/WindowsApi). Using the latest snapshot (as o

Should I bother porting Win32 threading examples?

2011-06-13 Thread Andrej Mitrovic
I'm in the process of porting WinAPI examples from Petzold's Windows Programming book to D. In the book there's a chapter on multithreading. It covers thread creation, messaging queues, critical sections, TLS (heh..), and event signaling. Since we pretty much have all of this in D already (+ its m

Re: Is it reasonable to learn D

2011-06-13 Thread Jose Armando Garcia
On Mon, Jun 13, 2011 at 6:33 AM, Lloyd Dupont wrote: > Let's learn together then! :P > http://galador.net/codeblog/?tag=/D > > While my blog post are only about setting up the environment so far.. I have > delved in the code for 2 weeks now! (Although I had some day off (work and > programing) in

Re: Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread Jonathan M Davis
On 2011-06-13 17:38, Andrej Mitrovic wrote: > So why's it in core.stdc.string, instead of say.. core.memory? > > Btw, I've had some imports already in the module and it seems these > two conflict: > > import core.thread; > import core.stdc.string; > > void main() > { > int* p, x; > memcp

Re: Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread bearophile
Andrej Mitrovic: > Right, haven't thought about the C functions at all (silly me). > Thanks, this did the trick: > extern (C) void* memcpy(void*, const void*, size_t); Maybe you are able to wrap that memcpy in a templated D function (named copyMemory) that does what you want in a bit safer way,

Re: Undefined function, even though imported

2011-06-13 Thread bearophile
Trass3r Wrote: > > Shouldn't the linker/compiler be able to solve this on its own then? > > Use rdmd or xfBuild to automatically compile all needed modules. Everyone we'll keep asking that question forever until the D compiler does this by itself :-) Bye, bearophile

Re: Undefined function, even though imported

2011-06-13 Thread Loopback
Thanks for all the answers! Seems like rdmd did the trick. I don't see why this isn't built in to dmd though, or does it cause overhead when you are using rdmd? Benefits, Drawbacks? I've also stumbled upon an additional error with the win32 DirectX bindings, but this seems D related actually. Whe

Re: Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread Andrej Mitrovic
So why's it in core.stdc.string, instead of say.. core.memory? Btw, I've had some imports already in the module and it seems these two conflict: import core.thread; import core.stdc.string; void main() { int* p, x; memcpy(p, x, 1); } test.d(9): Error: core.stdc.string.memcpy at D:\DMD\d

Re: Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread Jonathan M Davis
On 2011-06-13 17:01, Andrej Mitrovic wrote: > Right, haven't thought about the C functions at all (silly me). > Thanks, this did the trick: > extern (C) void* memcpy(void*, const void*, size_t); core.stdc.string has memcpy's declaration in it. You should be able to just import it rather than decl

Re: Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread Andrej Mitrovic
Right, haven't thought about the C functions at all (silly me). Thanks, this did the trick: extern (C) void* memcpy(void*, const void*, size_t);

Re: Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread Jonathan M Davis
On 2011-06-13 16:27, Andrej Mitrovic wrote: > Apparently in the Windows API there's a whole lot of byte-copying going > around. > > Here's an example: > > int CALLBACK EnhMetaFileProc (HDC hdc, HANDLETABLE * pHandleTable, > CONST ENHMETARECORD * pEmfRecord, > int iHandles, LPARAM pData) > { > ENH

Is there any convenient CopyMemory function in Phobos?

2011-06-13 Thread Andrej Mitrovic
Apparently in the Windows API there's a whole lot of byte-copying going around. Here's an example: int CALLBACK EnhMetaFileProc (HDC hdc, HANDLETABLE * pHandleTable, CONST ENHMETARECORD * pEmfRecord, int iHandles, LPARAM pData) { EN

Re: So how exactly does one make a persistent range object?

2011-06-13 Thread Ali Çehreli
On Sat, 04 Jun 2011 20:27:16 +0200, Andrej Mitrovic wrote: > This is my #1 problem with ranges right now: > > import std.range; > > int[3] a = [1, 2, 3]; > shared range = cycle(a[]); // nope > > void main() > { > foo(); > } > > void foo() > { > // do something with range > } > > test

Re: Undefined function, even though imported

2011-06-13 Thread Trass3r
Shouldn't the linker/compiler be able to solve this on its own then? Use rdmd or xfBuild to automatically compile all needed modules.

Re: Undefined function, even though imported

2011-06-13 Thread Andrej Mitrovic
sc.ini is going to get overwritten when you upgrade DMD so changing it is a bad idea. An alternative is to copy sc.ini to your projects local directory, this way DMD will use that one instead of its own. But this is all working around the issue that you should be passing import directories via a bu

Re: Undefined function, even though imported

2011-06-13 Thread Loopback
On 2011-06-13 23:51, Jonathan M Davis wrote: On 2011-06-13 14:44, Loopback wrote: Thanks for your answer! Seems like supplying with the file location solved the problem, though I still wonder about one thing. The imported module is located in "c:/d/dmd2/import/win32/windef.d" and I have used th

Running DMD tests

2011-06-13 Thread Peter Alexander
I'm trying to run the test suite for DMD, but I'm running into issues. I've cloned dmd from github, and successfully built dmd, but when I run 'make' from the dmd/test dir, I get: $ make Creating output directory: test_results Building d_do_test tool object.d: Error: module object is i

Re: Undefined function, even though imported

2011-06-13 Thread Jonathan M Davis
On 2011-06-13 14:44, Loopback wrote: > Thanks for your answer! > > Seems like supplying with the file location solved the problem, though I > still wonder about one thing. The imported module is located in > "c:/d/dmd2/import/win32/windef.d" and I have used this command line to > the DMD compiler:

Re: Undefined function, even though imported

2011-06-13 Thread Loopback
Thanks for your answer! Seems like supplying with the file location solved the problem, though I still wonder about one thing. The imported module is located in "c:/d/dmd2/import/win32/windef.d" and I have used this command line to the DMD compiler: -I"c:/d/dmd2/import/". Shouldn't the linker/

Re: Undefined function, even though imported

2011-06-13 Thread Jonathan M Davis
On 2011-06-13 14:18, Loopback wrote: > Hi! > > Let me begin by saying, I'm sorry if this is caused of some obvious > error but since I am new to D, I am not aware of all the tricks and > treats it offers. > > I am working with the WindowsAPI binding at dsource.org (though I do not > believe this

Re: Clear big AAs

2011-06-13 Thread bearophile
useo: > toRender is my AA which contains the textures as key (instances of my > class "Texture") and the tiles (position of them) as values. When I > remove the first two lines (clear and set null) it doesn't drops down > to 1 FPS, it runs normal. > > I hope anyone know a solution :) Try to disa

Re: Undefined function, even though imported

2011-06-13 Thread Trass3r
Importing it means dmd knows about the function and emits a call but doesn't automatically generate the function code. This is only done if you also pass the file containing it to dmd.

Re: Undefined function, even though imported

2011-06-13 Thread Mafi
Am 13.06.2011 23:18, schrieb Loopback: Hi! Let me begin by saying, I'm sorry if this is caused of some obvious error but since I am new to D, I am not aware of all the tricks and treats it offers. I am working with the WindowsAPI binding at dsource.org (though I do not believe this is related t

Undefined function, even though imported

2011-06-13 Thread Loopback
Hi! Let me begin by saying, I'm sorry if this is caused of some obvious error but since I am new to D, I am not aware of all the tricks and treats it offers. I am working with the WindowsAPI binding at dsource.org (though I do not believe this is related to the binding itself). However, in m

Re: WindowsAPI Binding - Linker Errors

2011-06-13 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:it5ui1$1l75$1...@digitalmars.com... > "Loopback" wrote in message > news:it4ud4$1kf5$1...@digitalmars.com... >> Hello! >> >> I've been test programming win32 applications recently, and since the >> phobos win32 library is so limited, I decided to downloa

Re: WindowsAPI Binding - Linker Errors

2011-06-13 Thread Nick Sabalausky
"Loopback" wrote in message news:it4ud4$1kf5$1...@digitalmars.com... > Hello! > > I've been test programming win32 applications recently, and since the > phobos win32 library is so limited, I decided to download and test the > WindowsAPI Binding > (http://www.dsource.org/projects/bindings/wiki

Re: Int within ranges

2011-06-13 Thread nrgyzer
== Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel > On Mon, 13 Jun 2011 15:44:01 -0400, nrgyzer wrote: > >> On Mon, 13 Jun 2011 14:52:24 -0400, nrgyzer > > wrote: > >> >> On Mon, 13 Jun 2011 12:15:40 -0400, nrgyzer > >> > wrote: > >> >> > Hi there, > >> >> > > >> >> > is there a

Re: Int within ranges

2011-06-13 Thread Steven Schveighoffer
On Mon, 13 Jun 2011 15:44:01 -0400, nrgyzer wrote: On Mon, 13 Jun 2011 14:52:24 -0400, nrgyzer wrote: >> On Mon, 13 Jun 2011 12:15:40 -0400, nrgyzer > wrote: >> > Hi there, >> > >> > is there any possibility to get a sliced array from another array >> > between two ranges like: >> > >> >

Re: Int within ranges

2011-06-13 Thread nrgyzer
> On Mon, 13 Jun 2011 14:52:24 -0400, nrgyzer wrote: > >> On Mon, 13 Jun 2011 12:15:40 -0400, nrgyzer > > wrote: > >> > Hi there, > >> > > >> > is there any possibility to get a sliced array from another array > >> > between two ranges like: > >> > > >> > int[uint] myArray; > >> > myArray[10] = 1

Re: Int within ranges

2011-06-13 Thread Steven Schveighoffer
On Mon, 13 Jun 2011 14:52:24 -0400, nrgyzer wrote: On Mon, 13 Jun 2011 12:15:40 -0400, nrgyzer wrote: > Hi there, > > is there any possibility to get a sliced array from another array > between two ranges like: > > int[uint] myArray; > myArray[10] = 1000; > myArray[20] = 2000; > myArray[30]

Re: Int within ranges

2011-06-13 Thread nrgyzer
> On Mon, 13 Jun 2011 12:15:40 -0400, nrgyzer wrote: > > Hi there, > > > > is there any possibility to get a sliced array from another array > > between two ranges like: > > > > int[uint] myArray; > > myArray[10] = 1000; > > myArray[20] = 2000; > > myArray[30] = 3000; > > myArray[40] = 4000; > > m

Re: Int within ranges

2011-06-13 Thread Jonathan M Davis
On 2011-06-13 09:15, nrgyzer wrote: > Hi there, > > is there any possibility to get a sliced array from another array > between two ranges like: > > int[uint] myArray; > myArray[10] = 1000; > myArray[20] = 2000; > myArray[30] = 3000; > myArray[40] = 4000; > myArray[50] = 5000; > > int[] newArray

Re: Int within ranges

2011-06-13 Thread Steven Schveighoffer
On Mon, 13 Jun 2011 13:25:39 -0400, bearophile < wrote: Steven Schveighoffer: But the dcollections.TreeMap API is more polished. I think most people will want to use just Phobos, to avoid a dependency, even if the Phobos one is less polished... Sure, but it's difficult to demonstrate

Re: Int within ranges

2011-06-13 Thread bearophile
Steven Schveighoffer: > But the dcollections.TreeMap API is more polished. I think most people will want to use just Phobos, to avoid a dependency, even if the Phobos one is less polished... Bye, bearophile

Re: Int within ranges

2011-06-13 Thread Steven Schveighoffer
On Mon, 13 Jun 2011 12:15:40 -0400, nrgyzer wrote: Hi there, is there any possibility to get a sliced array from another array between two ranges like: int[uint] myArray; myArray[10] = 1000; myArray[20] = 2000; myArray[30] = 3000; myArray[40] = 4000; myArray[50] = 5000; int[] newArray = myAr

Int within ranges

2011-06-13 Thread nrgyzer
Hi there, is there any possibility to get a sliced array from another array between two ranges like: int[uint] myArray; myArray[10] = 1000; myArray[20] = 2000; myArray[30] = 3000; myArray[40] = 4000; myArray[50] = 5000; int[] newArray = myArray[>= 20 .. <= 40]; // not able to do this writeln(new

Re: simple syntax issue with template

2011-06-13 Thread Joshua Niehus
> I'm trying to create 2 extra method for arrays ("range" would be > better, though I don't quite understand what is a "range") > Although I have some indecipherable (to me) compiler error... > > What's wrong with the code below? > == > import std.algorithm; > > public: > > void rem

Re: simple syntax issue with template

2011-06-13 Thread Dmitry Olshansky
On 13.06.2011 16:49, Lloyd Dupont wrote: ho.. plenty of silly mistake indeed.. thanks for spotting them! (maybe I should take a break and play the witcher 2 hey!?!? :) Why not ? ;-) however I still have a problem with removeAt now! :( === void removeAt(T)(ref T[] array, int index) { if(ind

Re: dmd vs rdmd

2011-06-13 Thread Joshua Niehus
Thanks Jonathan, that cleared things up for me. Josh On Sat, Jun 11, 2011 at 12:00 PM, wrote: > Send Digitalmars-d-learn mailing list submissions to >digitalmars-d-learn@puremagic.com > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.puremagic.com/cgi-bin/ma

Re: introspection woes (2)

2011-06-13 Thread Lloyd Dupont
Works a treat! Thanks for your detailed sample! :) "Robert Clipsham" wrote in message news:it5395$2028$1...@digitalmars.com... See: http://www.digitalmars.com/d/2.0/traits.html class MyClass { void method1(){} void method2(){} } import std.stdio; void main() { foreach (me

Re: introspection woes (2)

2011-06-13 Thread Robert Clipsham
On 13/06/2011 13:56, Lloyd Dupont wrote: Thanks Robert! Mm.. can you (per chance!) share some code? I'm a newbie and compile time reflection is something which eludes me (so far...)! See: http://www.digitalmars.com/d/2.0/traits.html class MyClass { void method1(){} void method2(){

Re: introspection woes (2)

2011-06-13 Thread Lloyd Dupont
Thanks Robert! Mm.. can you (per chance!) share some code? I'm a newbie and compile time reflection is something which eludes me (so far...)! "Robert Clipsham" wrote in message news:it4vp1$1n5q$1...@digitalmars.com... Anyway of ... making the runtime update xgetMembers? My understanding

Re: simple syntax issue with template

2011-06-13 Thread Lloyd Dupont
ho.. plenty of silly mistake indeed.. thanks for spotting them! (maybe I should take a break and play the witcher 2 hey!?!? :) however I still have a problem with removeAt now! :( === void removeAt(T)(ref T[] array, int index) { if(index < 0 || index >= array.length) return; array.re

Re: introspection woes (2)

2011-06-13 Thread Robert Clipsham
On 13/06/2011 13:11, Lloyd Dupont wrote: Interesting... I think I understand... Thanks! :) However an other problem arise with getMembers() it always returns null! Looking at the code it seems (from my beginner's perspective) that getMembers() rely on the member field (function) xgetMembers whic

Re: simple syntax issue with template

2011-06-13 Thread Lloyd Dupont
removed some obvious error, still stumped on the templated syntax ... so.. why is it not compiling? (error: Error: template std.algorithm.countUntil(alias pred = "a == b",R1,R2) if (is(typeof(startsWith!(pred)(haystack,needle does not match any function template declaration ) = import s

Re: simple syntax issue with template

2011-06-13 Thread Dmitry Olshansky
On 13.06.2011 16:03, Lloyd Dupont wrote: I'm trying to create 2 extra method for arrays ("range" would be better, though I don't quite understand what is a "range") Although I have some indecipherable (to me) compiler error... What's wrong with the code below? == import std.algo

Re: introspection woes (2)

2011-06-13 Thread Lloyd Dupont
Interesting... I think I understand... Thanks! :) However an other problem arise with getMembers() it always returns null! Looking at the code it seems (from my beginner's perspective) that getMembers() rely on the member field (function) xgetMembers which is always null, as far as I can tell (

simple syntax issue with template

2011-06-13 Thread Lloyd Dupont
I'm trying to create 2 extra method for arrays ("range" would be better, though I don't quite understand what is a "range") Although I have some indecipherable (to me) compiler error... What's wrong with the code below? == import std.algorithm; public: void remove(T)(ref T[] ar

Re: introspection woes (2)

2011-06-13 Thread Johannes Pfau
Lloyd Dupont wrote: >trying to learn introspection, I have this simple test method: > >=== >static void dumpelement(Object o) >{ >if (!o) >return; > >auto ci = o.classinfo; >foreach(mi ; ci.getMembers(null)) >{ >writefln("%s . %s", ci.name, mi.name())

WindowsAPI Binding - Linker Errors

2011-06-13 Thread Loopback
Hello! I've been test programming win32 applications recently, and since the phobos win32 library is so limited, I decided to download and test the WindowsAPI Binding (http://www.dsource.org/projects/bindings/wiki/WindowsApi). Using the latest snapshot (as of this writing) I receive the follo

introspection woes (2)

2011-06-13 Thread Lloyd Dupont
trying to learn introspection, I have this simple test method: === static void dumpelement(Object o) { if (!o) return; auto ci = o.classinfo; foreach(mi ; ci.getMembers(null)) { writefln("%s . %s", ci.name, mi.name()); } } == However

Re: Is it reasonable to learn D

2011-06-13 Thread Lloyd Dupont
Let's learn together then! :P http://galador.net/codeblog/?tag=/D While my blog post are only about setting up the environment so far.. I have delved in the code for 2 weeks now! (Although I had some day off (work and programing) in Darwin) I'm right into it now, should have a new blog post so

Re: Object

2011-06-13 Thread Lloyd Dupont
I see mm Thanks for the info! "Jonathan M Davis" wrote in message news:mailman.866.1307943671.14074.digitalmars-d-le...@puremagic.com... Object is not currently const-correct: http://d.puremagic.com/issues/show_bug.cgi?id=1824 As a result, a number of basic functions do not currently

introspection woes...

2011-06-13 Thread Lloyd Dupont
Trying to play with introspection. trying o, for a given object, to check its property by name. Experimenting with the function below. 1. it doesn't compile! mi.name() seems to be a problem? 2. match is always null! even though I pass the name of an existing property and / or field! ==