Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-08 Thread cc via Digitalmars-d-learn
Sample output: Initializing. User logged on: true Starting request. hid: 4838393704146785693 .. Request completed: NumberOfCurrentPlayers_t(1, 5828) Terminating. Not present: any indication that the registered callresult was executed.

Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-08 Thread cc via Digitalmars-d-learn
On Saturday, 9 June 2018 at 03:07:39 UTC, cc wrote: I've put together a simplified test program here (124KB): Here is a pastebin of the D source file updated with some additional comments at the end with the callback class definitions from the original header files

Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-08 Thread cc via Digitalmars-d-learn
On Friday, 8 June 2018 at 07:32:54 UTC, evilrat wrote: On Friday, 8 June 2018 at 06:59:51 UTC, cc wrote: On Friday, 8 June 2018 at 02:52:10 UTC, Mike Parker wrote: On Friday, 8 June 2018 at 00:55:35 UTC, cc wrote: class CImpl : CCallbackBase { extern(C++) { If anyone has any

Re: I want delete or change class's member name on compile-time

2018-06-08 Thread Ali Çehreli via Digitalmars-d-learn
On 06/08/2018 11:13 AM, Brian wrote: > Like: > > class A > { > string b; > string c; > } > > compile-time to: > > class A > { > string _b; > string c; > } > > or: > > class A > { > string c; > } > If these are your classes you can use static if or version: version = Z;

Re: I want delete or change class's member name on compile-time

2018-06-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/8/18 2:13 PM, Brian wrote: Like: class A {     string b;     string c; } compile-time to: class A {     string _b;     string c; } or: class A {     string c; } Not possible in D. What you are looking for is an AST macro, and D does not have those. However, you can

File.put()

2018-06-08 Thread Bastiaan Veelo via Digitalmars-d-learn
Writing a single value to binary file can be done in (at least) two ways. Let `f` be a `File`: ``` f.rawWrite(()[0 .. 1]); ``` or ``` f.lockingBinaryWriter.put(value); ``` The former way is little talked about, the latter is not even documented. As far as I can see, the latter resolves to

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 08, 2018 03:51:11 David Bennett via Digitalmars-d-learn wrote: > On Thursday, 7 June 2018 at 04:58:40 UTC, Jonathan M Davis wrote: > > It would be trivial enough to create a wrapper template so that > > you can do something like > > > > immutable n = ctfe!(foo()); > > > > e.g. > >

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread jmh530 via Digitalmars-d-learn
On Friday, 8 June 2018 at 17:09:54 UTC, H. S. Teoh wrote: I would, if I had the time to spare to make such a chart. Perhaps you (or somebody here) could do it? It *is* a wiki, after all. Y'all don't have to wait for me to get around to it, the edit button is right there. T Fair

Re: WTF! new in class is static?!?!

2018-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 22:43:50 aliak via Digitalmars-d-learn wrote: > On Thursday, 7 June 2018 at 21:32:54 UTC, Jonathan M Davis wrote: > > struct S > > { > > > > int* ptr = new int(42); > > > > } > > Is that supposed to compile? -> https://run.dlang.io/is/SjUEOu > > Error: cannot use

I want delete or change class's member name on compile-time

2018-06-08 Thread Brian via Digitalmars-d-learn
Like: class A { string b; string c; } compile-time to: class A { string _b; string c; } or: class A { string c; }

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 08, 2018 at 02:57:26PM +, jmh530 via Digitalmars-d-learn wrote: [...] > May I suggest that you add a flow chart that gives a very high level > understanding of the compiler steps. Like how Rust's introduction to > MIR has: > https://blog.rust-lang.org/2016/04/19/MIR.html I would,

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 08, 2018 at 02:36:01PM +, Gopan via Digitalmars-d-learn wrote: > On Friday, 8 June 2018 at 05:10:16 UTC, H. S. Teoh wrote: > > All this talk of CTFE and "compile-time", along with the confusion > > that arises from conflating everything done by the compiler into the > > blanket

allMembers trait does not work correctly for packages during recursion

2018-06-08 Thread Gokhan Yegit via Digitalmars-d-learn
I'm trying to create a template class that can be parameterized with a module and will be able to serialize and deserialize (and more) all types in that module and submodules that have a specific UDA or superclass. My initial idea was to do a recursive search for types by starting from the

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread jmh530 via Digitalmars-d-learn
On Friday, 8 June 2018 at 05:10:16 UTC, H. S. Teoh wrote: All this talk of CTFE and "compile-time", along with the confusion that arises from conflating everything done by the compiler into the blanket term "compile-time" makes me want to scream:

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread Gopan via Digitalmars-d-learn
On Friday, 8 June 2018 at 05:10:16 UTC, H. S. Teoh wrote: All this talk of CTFE and "compile-time", along with the confusion that arises from conflating everything done by the compiler into the blanket term "compile-time" makes me want to scream:

Re: how to sort the container Array from std.container

2018-06-08 Thread ag0aep6g via Digitalmars-d-learn
On 06/08/2018 10:52 AM, Flaze07 wrote: ah...well thank you, well...I did finds another way, but it is probably better to use linearRemove I used arr = make!( Array!uint )( remove( arr[], 2 ); so linearRemove is probably better Instead of creating a new array, you could update the length of

Re: how to sort the container Array from std.container

2018-06-08 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 14:46:56 UTC, ag0aep6g wrote: On 06/06/2018 04:20 PM, Flaze07 wrote: hmm, and sorry for asking more, what about removing an element from it ? I found no remove operation that can remove from the middle ( removeAny and removeBack both removes the latest element,

Re: Runtime introspection, or how to get class members at runtime Fin D

2018-06-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 June 2018 at 08:06:27 UTC, Arafel wrote: On Thursday, 7 June 2018 at 13:07:21 UTC, evilrat wrote: I don't think so. It clearly states that children must mixin too, which can mean it just grabs symbols in scope only, and base class has no way of knowing about its subclasses. It

Re: Using stdin/out in a windows application bugs only when compiled to 64bit.

2018-06-08 Thread realhet via Digitalmars-d-learn
On Friday, 8 June 2018 at 03:08:21 UTC, Mike Franklin wrote: I recall similar issues with a project I was working on, but I don't remember all the details now. Anyway, I ended up with this in the end. Using main() instead of WinMain() did the trick too. Also it's simpler, so I choose this

Re: Runtime introspection, or how to get class members at runtime Fin D

2018-06-08 Thread Arafel via Digitalmars-d-learn
On Thursday, 7 June 2018 at 13:07:21 UTC, evilrat wrote: I don't think so. It clearly states that children must mixin too, which can mean it just grabs symbols in scope only, and base class has no way of knowing about its subclasses. It also has "agressive mode" that will make metadata for

Re: Using stdin/out in a windows application bugs only when compiled to 64bit.

2018-06-08 Thread realhet via Digitalmars-d-learn
On Friday, 8 June 2018 at 02:44:13 UTC, Mike Parker wrote: ...you can get it with this: dmd -m64 -L/SUBSYSTEM:console -L/ENTRY:WinMainCRTStartup foo.d Thank You! It works with LDC -m64 as well. And now that I repaired my VCRedist2015 the bat file test (my second code example) is working too.

Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 June 2018 at 06:59:51 UTC, cc wrote: On Friday, 8 June 2018 at 02:52:10 UTC, Mike Parker wrote: On Friday, 8 June 2018 at 00:55:35 UTC, cc wrote: class CImpl : CCallbackBase { extern(C++) { If anyone has any insight to provide it would be greatly appreciated, thanks!

Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-08 Thread cc via Digitalmars-d-learn
On Friday, 8 June 2018 at 02:52:10 UTC, Mike Parker wrote: On Friday, 8 June 2018 at 00:55:35 UTC, cc wrote: class CImpl : CCallbackBase { extern(C++) { If anyone has any insight to provide it would be greatly appreciated, thanks! I've not used any of the C++ interfacing features

Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 June 2018 at 00:55:35 UTC, cc wrote: I've defined it in D, as per https://dlang.org/spec/cpp_interface.html#classes : change this to class, or even abstract class as shown in example extern(C++) { interface CCallbackBase { //this() { m_nCallbackFlags