Opaque handles...
Manu
turkeyman at gmail.com
Wed Sep 18 09:25:37 PDT 2013
Here's an example of a typical C API that's begging to be wrapped up all
nice:
http://fujiengine.org/docs/group___m_f_material.html
And it's counterpart:
https://github.com/TurkeyMan/fuji/blob/master/dist/include/d2/fuji/material.d
You can see some initial experiments I toyed with down the bottom. Abusing
the class syntax, and implementing a range interface for the material
parameters, but this sucks in a variety of ways...
On 19 September 2013 02:19, Manu <turkeyman at gmail.com> wrote:
> On 19 September 2013 02:14, Andrej Mitrovic <andrej.mitrovich at gmail.com>wrote:
>
>> On 9/18/13, Manu <turkeyman at gmail.com> wrote:
>> > And in D:
>> >
>> > struct Thing;
>> > extern (C) Thing* MakeThing();
>> >
>> > The question is, does this suck?
>> > D currently can't allocate an array of Thing*'s for some weird reason.
>>
>> This is just a current bug that will be fixed. As a workaround you can
>> use this:
>>
>> struct Thing
>> {
>> @disable this();
>> @disable this(this);
>> }
>>
>> This will ensure "Thing" will never be copied by value, and you can
>> only use it with a pointer.
>>
>
> But since I'm always dealing with a pointer rather than a real type, I
> can't implement logic to inc/dec the ref-count on assignment. And how do I
> handle destruction/garbage collection?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130919/63485553/attachment.html>
More information about the Digitalmars-d
mailing list