Thread overview
D bindings for Bonjour
Oct 28, 2015
Vincent R
Oct 28, 2015
Cauterite
Oct 28, 2015
Vincent R
Oct 28, 2015
Vincent R
Oct 28, 2015
Daniel Kozák
Oct 28, 2015
Vincent R
Oct 28, 2015
Adam D. Ruppe
October 28, 2015
Hi,

I am starting my first project in D and I would like to do a Bonjour(Zeroconf) browser app.
My first task is to write a binding to the dns_sd library but I have an issue with the following macro:

#define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault)

It justs takes some enum (defined above but not shown here) and do a OR operation on it.

How can I express that in D ?

Do I need to use a template  as shown here http://wiki.dlang.org/D_binding_for_C or a varg function ?

Thanks
October 28, 2015
On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote:
> Hi,
>
> I am starting my first project in D and I would like to do a Bonjour(Zeroconf) browser app.
> My first task is to write a binding to the dns_sd library but I have an issue with the following macro:
>
> #define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault)
>
> It justs takes some enum (defined above but not shown here) and do a OR operation on it.
>
> How can I express that in D ?
>
> Do I need to use a template  as shown here http://wiki.dlang.org/D_binding_for_C or a varg function ?
>
> Thanks

enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault);

Good luck :)
October 28, 2015
On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote:
> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote:
>> [...]
>
> enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault);
>
> Good luck :)

I wanted to delete my post when I realize the stupidity of my question. Actually I ask my question before really looking at it.
Sorry
October 28, 2015
On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote:
> On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote:
>> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote:
>>> [...]
>>
>> enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault);
>>
>> Good luck :)
>
> I wanted to delete my post when I realize the stupidity of my question. Actually I ask my question before really looking at it.
> Sorry

Is there any central place where you store bindings ?
October 28, 2015
V Wed, 28 Oct 2015 16:36:32 +0000
Vincent R via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
napsáno:

> On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote:
> > On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote:
> >> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote:
> >>> [...]
> >>
> >> enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault);
> >>
> >> Good luck :)
> >
> > I wanted to delete my post when I realize the stupidity of my
> > question. Actually I ask my question before really looking at
> > it.
> > Sorry
> 
> Is there any central place where you store bindings ?

code.dlang.org -- general place for every d project


October 28, 2015
On Wednesday, 28 October 2015 at 16:53:15 UTC, Daniel Kozák wrote:
> V Wed, 28 Oct 2015 16:36:32 +0000
> Vincent R via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
> napsáno:
>
>> On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote:
>> > On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote:
>> >> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote:
>> >>> [...]
>> >>
>> >> enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault);
>> >>
>> >> Good luck :)
>> >
>> > I wanted to delete my post when I realize the stupidity of my
>> > question. Actually I ask my question before really looking at
>> > it.
>> > Sorry
>> 
>> Is there any central place where you store bindings ?
>
> code.dlang.org -- general place for every d project

Ok thanks.
Sorry to ask so much question but how do you declare different calling conventions like the following macro:


#if defined(_WIN32)
#define DNSSD_API __stdcall
#else
#define DNSSD_API
#endif


From what I understand I could write:

version (Windows)
{
	extern (Windows)
	{
		int DNSServiceGetProperty
		(
		 in char *property,
		 void       *result,
		 uint       *size
		 );
	}
}
else
{
	extern (C)
	{
		int DNSServiceGetProperty
			(
			 in char *property,
			 void       *result,
			 uint       *size
				 );
	}
}

but I don't want to write it once.
How can I solve this ?
And if there is an easy fix what about writing it inside the wiki page:
http://wiki.dlang.org/D_binding_for_C

Thanks


October 28, 2015
On Wednesday, 28 October 2015 at 17:07:32 UTC, Vincent R wrote:
> Sorry to ask so much question but how do you declare different calling conventions like the following macro:

This specific case is common enough to be built into the language: use `extern(System)` instead of Windows or C and the one declaration will work on both.

> And if there is an easy fix what about writing it inside the wiki page:
> http://wiki.dlang.org/D_binding_for_C

You can edit a wiki yourself!