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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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 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 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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

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 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: 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

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 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

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

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.

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

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

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

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

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 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

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: 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

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: 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 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

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