I have a problem with D

2016-06-27 Thread Adam Sansier via Digitalmars-d
Hi, I have designed a class based system that involves self-delegation instead of override. It is similar to event based programming. I have defined an event as a container type that holds functions(or possibly delegates, but the desire is to avoid them). class Base { alias

Re: Walter: D asm syntax not consistent nor calling convention with C++

2016-07-17 Thread Adam Sansier via Digitalmars-d
I should point out that the code still doesn't work. It simply doesn't crash. It seems to jump to another code location that fails silently. I might not be fixing up the stack frame correctly or or doing something D expects. Hard to no because when I try to step over the `call` instruction it

Re: Walter: D asm syntax not consistent nor calling convention with C++

2016-07-17 Thread Adam Sansier via Digitalmars-d
2. C++ defaults to dword ptr, D to word ptr. Copying and pasting the code results in hard to find bugs. It would seem to me that that D should default to the pointer size for indirect accessing when pushing and popping. push [3] should push a size of void*.sizeof.

Re: Walter: D asm syntax not consistent nor calling convention with C++

2016-07-17 Thread Adam Sansier via Digitalmars-d
On Sunday, 17 July 2016 at 06:27:46 UTC, Adam Sansier wrote: On Sunday, 17 July 2016 at 06:23:34 UTC, Walter Bright wrote: On 7/16/2016 11:10 PM, Adam Sansier wrote: D is not consistent with C++ in asm and calling convention. In general, it is a *lot* easier to debug inline asm issues if

Re: Walter: D asm syntax not consistent nor calling convention with C++

2016-07-17 Thread Adam Sansier via Digitalmars-d
On Sunday, 17 July 2016 at 06:23:34 UTC, Walter Bright wrote: On 7/16/2016 11:10 PM, Adam Sansier wrote: D is not consistent with C++ in asm and calling convention. In general, it is a *lot* easier to debug inline asm issues if you're willing to run obj2asm on the output and compare. No

D's exact stack convention for D and C/C++

2016-07-16 Thread Adam Sansier via Digitalmars-d
I am trying to debug some really messed up code that makes no sense. It calls in some code that doesn't seem to be using the standard calling convention. The function definitions are exactly the same in both D and C++. ->func(param1, param2, param3, param4); The call stack setup by C++

Walter: D asm syntax not consistent nor calling convention with C++

2016-07-17 Thread Adam Sansier via Digitalmars-d
D is not consistent with C++ in asm and calling convention. I have the exact same code in both C++ and D, the exact same assembler code, but. D's enum VS = (void*).sizeof; enum SA = 6; enum OF = 0; void

Re: Walter: D asm syntax not consistent nor calling convention with C++

2016-07-17 Thread Adam Sansier via Digitalmars-d
On Sunday, 17 July 2016 at 06:23:34 UTC, Walter Bright wrote: On 7/16/2016 11:10 PM, Adam Sansier wrote: D is not consistent with C++ in asm and calling convention. In general, it is a *lot* easier to debug inline asm issues if you're willing to run obj2asm on the output and compare. No

Re: I can has @nogc and throw Exceptions?

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:39:11 UTC, Lodovico Giaretta wrote: On Wednesday, 13 July 2016 at 00:57:38 UTC, Adam Sansier wrote: [...] You shall use a static per-thread Region allocator[1] backed by Mallocator[2]. Then you just make[3] exceptions inside it and throw them. So you can

Re: C++ interface vs D and com

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 08:34:55 UTC, John wrote: On Wednesday, 13 July 2016 at 07:31:57 UTC, Adam Sansier wrote: void** ptr = null; auto res = CoCreateInstance(_ID, cast(IUnknown)null, CLSCTX_INPROC_SERVER, _ID, cast(void**)); How are you casting your "ptr" variable

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
So, the problem now, is how to take the interface, which is simple, no implementation, and either create the implementation or create a sort of simple empty proxy that can be used to instantiate the interface? I mean automatically of course. I believe D already has some library solution

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 17:17:31 UTC, Kagamin wrote: On Tuesday, 12 July 2016 at 16:30:05 UTC, Adam Sansier wrote: Doesn't matter, it's not what I asked. Yeah, I'm not confident I understood your problem right. You can try to describe your problem better. Criteria: 1. At most 2 one

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:12:21 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:13:02 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: I marked the interface extern(C++) so it's a C++ style interface. The first field of a COM object is a pointer to its vtable. If it is a COM interface, you should

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 18:52:08 UTC, Meta wrote: On Tuesday, 12 July 2016 at 04:23:07 UTC, Adam Sansier wrote: Now, I could simply make Do a template method but then this prevents it being a virtual function. void Do(T)(T name) if (is(T == string) || is(T == int)) { Init_Data();

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 22:55:05 UTC, Adam Sansier wrote: So, the problem now, is how to take the interface, which is simple, no implementation, and either create the implementation or create a sort of simple empty proxy that can be used to instantiate the interface? I mean

Re: I can has @nogc and throw Exceptions?

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Friday, 13 February 2015 at 21:08:58 UTC, Marc Schütz wrote: On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath wrote: 1. Throw preallocated exceptions is the way to go ... and because noone has yet shown an explicit example: void myThrowingNogcFunc() @nogc { static

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: On Tuesday, 12 July 2016 at 23:55:55 UTC, Adam Sansier wrote: Ok, Another hack: iInterface x; void** y = cast(void**) *y = malloc(iInterface.sizeof);

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:25:35 UTC, Jesse Phillips wrote: On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link

Re: Some asm help for the 'thiscall' calling convention?

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 22:09:05 UTC, flamencofantasy wrote: On Wednesday, 13 July 2016 at 20:39:00 UTC, Adam Sansier wrote: On Sunday, 24 April 2011 at 22:09:24 UTC, Kagamin wrote: Andrej Mitrovic Wrote: But trying to use functions which take parameters will fail with an access

Re: I can has @nogc and throw Exceptions?

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 21:27:16 UTC, Lodovico Giaretta wrote: On Wednesday, 13 July 2016 at 21:12:29 UTC, Adam Sansier wrote: [...] Ok, I like! [...] I like too! But I'll have to assume you are right since I have no proof. [...] Well, one could do this with malloc because one

Re: C++ interface vs D and com

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 03:38:03 UTC, Mike Parker wrote: On Wednesday, 13 July 2016 at 02:49:54 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: What happens when you declare an interface that extends from IUnknown (and not extern(C++)), then cast

Re: C++ interface vs D and com

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 06:44:36 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 03:38:03 UTC, Mike Parker wrote: On Wednesday, 13 July 2016 at 02:49:54 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: What happens when you declare an

Re: C++ interface vs D and com

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 19:22:44 UTC, Kagamin wrote: On Wednesday, 13 July 2016 at 16:48:53 UTC, Adam Sansier wrote: There's a lot of misinformation on the net. Nope, it's just you. COM support in D and in general works fine for everyone else. For anyone else having similar problems

Re: C++ interface vs D and com

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 20:02:50 UTC, Jesse Phillips wrote: On Wednesday, 13 July 2016 at 02:41:22 UTC, Adam Sansier wrote: If you can convince me to try it out, I might... but doing com isn't my primary goal here and I seem to have finished up what I was trying to achieve(my use case is

Re: Some asm help for the 'thiscall' calling convention?

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 24 April 2011 at 22:09:24 UTC, Kagamin wrote: Andrej Mitrovic Wrote: But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention.

Re: I can has @nogc and throw Exceptions?

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 16:28:23 UTC, Lodovico Giaretta wrote: On Wednesday, 13 July 2016 at 16:13:21 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 11:39:11 UTC, Lodovico Giaretta wrote: On Wednesday, 13 July 2016 at 00:57:38 UTC, Adam Sansier wrote: [...] You shall use a

Re: I can has @nogc and throw Exceptions?

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 20:57:49 UTC, Lodovico Giaretta wrote: On Wednesday, 13 July 2016 at 20:44:52 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 16:28:23 UTC, Lodovico Giaretta wrote: It's actually quite easy. Here's the code (untested):

Re: C++ interface vs D and com

2016-07-13 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 20:47:21 UTC, John wrote: On Wednesday, 13 July 2016 at 20:28:40 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 19:22:44 UTC, Kagamin wrote: On Wednesday, 13 July 2016 at 16:48:53 UTC, Adam Sansier wrote: There's a lot of misinformation on the net.

Re: adding toString to struct

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:29:12 UTC, Jesse Phillips wrote: On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: windows libs have a lot of structs and it would be nice to have the ability to convert them to a string to see them in the debugger(e.g., CLSID). Is there a way to

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 08:52:26 UTC, Kagamin wrote: Extract functions for shared parts: void Do(string name) { DoStuff(); int i = find(name); DoStuffWithIndex(i); } void Do(int name) { DoStuff(); DoStuffWithIndex(i); } I don't like it, creates an extra function for

Re: structure alignment

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:26:54 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 00:20:31 UTC, Adam Sansier wrote: I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous. Why are these structs needing

Re: adding toString to struct

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:27:49 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: Is there a way to do this? write a new function that prints them and call that This doesn't work to display them in visual D though. Requires a lot of hoops just to

C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link them up so I can call the functions? I marked the interface extern(C++) so it's a C++ style interface. The first field of a

Re: structure alignment

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:08:29 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 14:54:25 UTC, Adam Sansier wrote: Um, because that's the way they were defined! So your telling me that D is going to make me mark every member align(n) when C++ has a global pragma align that does it

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 13:54:16 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 13:44:02 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 08:52:26 UTC, Kagamin wrote: Extract functions for shared parts: void Do(string name) { DoStuff(); int i = find(name);

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:03:15 UTC, Kagamin wrote: On Tuesday, 12 July 2016 at 13:44:02 UTC, Adam Sansier wrote: I don't like it, creates an extra function for no apparent reason except to get around the problem of not having a yield type of semantic. Again, I wasn't asking for any ol'

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:42:52 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 16:30:05 UTC, Adam Sansier wrote: Doesn't matter, it's not what I asked. Trying to provide answers to a question that wasn't asked and was clearly stated I wasn't interested in those types of

structure alignment

2016-07-11 Thread Adam Sansier via Digitalmars-d-learn
I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous. I could search and paste, but then D is missing a relatively important aspect of alignment. I have about 100 struct's to align, member wise. From what I've

Re: how to mark an extern function @nogc?

2016-07-11 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 15:54:02 UTC, Seb wrote: On Monday, 11 July 2016 at 01:59:51 UTC, Adam Sansier wrote: On Monday, 11 July 2016 at 01:58:23 UTC, Adam Sansier wrote: I'm using some win functions that don't use the gc and are not marked, specifically CLSIDFromString that I imported

Simple overloading without complications

2016-07-11 Thread Adam Sansier via Digitalmars-d-learn
I have a function that does some weird stuff, and can't really change it to make life easier(due to how windows work, COM, etc..). The function normally takes a string, a name, and does its think(which is the complex part that I can't change). But I also want to overload it so the function

adding toString to struct

2016-07-11 Thread Adam Sansier via Digitalmars-d-learn
windows libs have a lot of structs and it would be nice to have the ability to convert them to a string to see them in the debugger(e.g., CLSID). Is there a way to do this? I've tried to pull out the code from the libs but it if a total clusterfuck.

Re: Some asm help for the 'thiscall' calling convention?

2016-07-16 Thread Adam Sansier via Digitalmars-d-learn
On Thursday, 14 July 2016 at 14:01:29 UTC, Kagamin wrote: On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote: Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything. My word is not COM specification of course,

Re: Some asm help for the 'thiscall' calling convention?

2016-07-16 Thread Adam Sansier via Digitalmars-d-learn
On Thursday, 14 July 2016 at 00:51:16 UTC, ethgeh wrote: On Wednesday, 13 July 2016 at 23:06:44 UTC, flamencofantasy wrote: On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 22:09:05 UTC, flamencofantasy wrote: On Wednesday, 13 July 2016 at 20:39:00

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since it was generated from a buffer and the length wasn't set

Re: How to create nogc code?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
Also, When dealing with a complex tree like structure, is there an easy way to recursively free it by free'ing all the sub elements? Also, since I'm dealing with simple structs and strings, maybe I more intelligent string type can be used? One that uses opAssign to do reference counting? I

Re: How to create nogc code?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 01:08:16 UTC, Jonathan M Davis wrote: On Monday, July 11, 2016 00:37:39 Adam Sansier via Digitalmars-d-learn wrote: [...] When manually managing memory, you're dealing with basically the same constructs that you would have in C/C++. I mean, you're even using

how to mark an extern function @nogc?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
I'm using some win functions that don't use the gc and are not marked, specifically CLSIDFromString that I imported myself(it's not marked nogc in objbase).

Re: how to mark an extern function @nogc?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 01:58:23 UTC, Adam Sansier wrote: I'm using some win functions that don't use the gc and are not marked, specifically CLSIDFromString that I imported myself(it's not marked nogc in objbase). I went ahead and copied the import and added nogc. Shouldn't someone add

Re: How to create nogc code?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 02:35:13 UTC, Jonathan M Davis wrote: On Monday, July 11, 2016 01:16:11 Adam Sansier via Digitalmars-d-learn wrote: [...] It's more a case that you're just making life harder for yourself if you avoid the GC. Some programs (like AAA games) are going to need

mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? I'm working with win32 and have to use char*'s. This requires a lot of in place case conversions and comparisons and such. I want to avoid the gc too. I could use

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? What string functions in particular? If

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 20:31:34 UTC, Lodovico Giaretta wrote: On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:26:29 UTC, Adam Sansier wrote: For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since