Re: Writing Postgresql extension in D

2018-11-15 Thread Radu via Digitalmars-d-learn
On Friday, 16 November 2018 at 02:18:11 UTC, Ranjan wrote: On Thursday, 15 November 2018 at 17:03:55 UTC, Andrea Fontana wrote: On Thursday, 15 November 2018 at 13:05:59 UTC, Ranjan wrote: This is my first time on the Dlang forum. I like the language but my usecase is a bit different. I want

Re: Writing Postgresql extension in D

2018-11-15 Thread rikki cattermole via Digitalmars-d-learn
On 16/11/2018 3:18 PM, Ranjan wrote: On Thursday, 15 November 2018 at 17:03:55 UTC, Andrea Fontana wrote: On Thursday, 15 November 2018 at 13:05:59 UTC, Ranjan wrote: This is my first time on the Dlang forum. I like the language but my usecase is a bit different. I want to write Postgresql ex

Re: Writing Postgresql extension in D

2018-11-15 Thread Ranjan via Digitalmars-d-learn
On Thursday, 15 November 2018 at 17:03:55 UTC, Andrea Fontana wrote: On Thursday, 15 November 2018 at 13:05:59 UTC, Ranjan wrote: This is my first time on the Dlang forum. I like the language but my usecase is a bit different. I want to write Postgresql extension in D. Currently extension can

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread pineapple via Digitalmars-d-learn
Well, for anyone who is tangling with similar mysteries, I finally got something to work the way I wanted it to. Thank you for the help, Adam and kinke! The first "x" argument was stored in R8. The second "y" argument was stored in RDX. The invisible return value pointer was stored in RCX.

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template. Well, the general "rule" is, if it's code that must be available to the compiler when it's called, the

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread pineapple via Digitalmars-d-learn
Ah, I've got something working! It's not exactly what I wanted, but it's good enough for now. Instead of using an invisible output pointer, the output pointer is passed in explicitly. struct Result { ulong low; ulong high; } void retTest(Result* result) { v

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread pineapple via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:48:46 UTC, kinke wrote: The MS docs are complete IIRC. The pointer to the pre-allocated result of your 16-bytes struct is passed in RCX. If unsure, just reverse-engineer what you need: type it down in normal D and analyze the generated assembly. You can even d

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread kinke via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:32:10 UTC, pineapple wrote: On the less positive side: I still have no clue how to return my 16-byte struct. The Microsoft x64 ABI documentation I've seen so far explains how return values of 8 bytes and fewer work, but haven't explained how larger return val

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread pineapple via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:12:39 UTC, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:07:51 UTC, pineapple wrote: Is there a way to access this pointer? It is passed as.. I think the final argument to the function. (unless it is the first, do a quick test to find out). Als

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:07:51 UTC, pineapple wrote: Is there a way to access this pointer? It is passed as.. I think the final argument to the function. (unless it is the first, do a quick test to find out). Also, the calling convention documentation there doesn't mention anythi

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template.

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread pineapple via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:00:10 UTC, Adam D. Ruppe wrote: It would be part of the abi: https://dlang.org/spec/abi.html#function_calling_conventions though it references C so you might need to look that up too. That's helpful, thank you! For other sized structs and static arrays, the

what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread ikod via Digitalmars-d-learn
Hello, what are the rules for @nogc inference? It looks like sometimes compiler can infer @nogc, but not in this simplest case: int x() { return 1; } void main() @nogc { x(); } Thanks!

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 20:57:59 UTC, pineapple wrote: My issue is that I can't figure out how to access a function's arguments from within inline asm or how to ensure that the correct value is returned. I haven't found a single piece of documentation about this so far! It would be p

Where is there documentation on how to write inline asm?

2018-11-15 Thread pineapple via Digitalmars-d-learn
I've managed to get a few functions working before mostly by copying whatever Phobos was doing for a similar purpose, but now that I'm trying to do something different I am really hitting a wall. My issue is that I can't figure out how to access a function's arguments from within inline asm o

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Ali Çehreli via Digitalmars-d-learn
On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > opDispatch is special in that it allows for functions to be added to a > class or struct when undefined overtly but used elsewhere but it seems > those functions sadly are final. > > Can anything useful be done to remedy the situation? For the com

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 15 November 2018 at 18:04:42 UTC, Adam D. Ruppe wrote: Right, all templates are final, including opDispatch. What I've done in the past is to forward them to a virtual function with runtime arguments instead of compile time arguments. Kinda like: void opDispatch(string name)()

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 17:14:21 UTC, Carl Sturtivant wrote: opDispatch is special in that it allows for functions to be added to a class or struct when undefined overtly but used elsewhere but it seems those functions sadly are final. Right, all templates are final, including opDispa

opDispatch doesn't play nice with inheritance

2018-11-15 Thread Carl Sturtivant via Digitalmars-d-learn
//Consider this: import std.stdio; void main() { X obj = new Y; writeln( obj._f() ); } class Proxy { X x; this(X x) { this.x = x; } string _f() { return "Proxy._f called"; } } class X { auto opDispatch(string f, Args...)(Args args) { Proxy p = new Proxy(this);

Re: Writing Postgresql extension in D

2018-11-15 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 15 November 2018 at 13:05:59 UTC, Ranjan wrote: This is my first time on the Dlang forum. I like the language but my usecase is a bit different. I want to write Postgresql extension in D. Currently extension can be written in C or C linked languages. Has anyone done this or can p

Writing Postgresql extension in D

2018-11-15 Thread Ranjan via Digitalmars-d-learn
This is my first time on the Dlang forum. I like the language but my usecase is a bit different. I want to write Postgresql extension in D. Currently extension can be written in C or C linked languages. Has anyone done this or can point me to some code. Thanks

Re: Inherit from class based on bool value

2018-11-15 Thread bauss via Digitalmars-d-learn
On Thursday, 15 November 2018 at 08:46:36 UTC, Bienlein wrote: On Tuesday, 13 November 2018 at 07:10:26 UTC, Jamie wrote: I would like my class to inherit from one of two classes based on a boolean value known at compile time. Something like this: void main() { Top!(OPTION.FALSE) top = new

Re: Inherit from class based on bool value

2018-11-15 Thread Bienlein via Digitalmars-d-learn
On Tuesday, 13 November 2018 at 07:10:26 UTC, Jamie wrote: I would like my class to inherit from one of two classes based on a boolean value known at compile time. Something like this: void main() { Top!(OPTION.FALSE) top = new Top!(OPTION.FALSE); } enum OPTION { FALSE = 0., TRUE =