Package permission and symbol resolution
Manu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 22 01:14:16 PDT 2014
On 22 April 2014 18:07, Manu <turkeyman at gmail.com> wrote:
> So I've restructured one of my projects which is a C library bindings,
> but also with some D-ification.
>
> I separated it into 2 parts, the raw binding parts, and the api
> enhancements, the module structure looks like this:
>
> The Raw C binding part:
>
> pkg/c/module.d:
>
> pkg.c.module;
Should read: module pkg.c.module;
> struct ModuleStruct
> {
> package:
> int privateParts;
> }
>
> extern (C) void func(const(char)* pString);
>
>
> And the wrapping layer; public import's the raw C bindings, which is
> meant to make the C API available too while adding some sugar for
> convenience.
>
> pkg/module.d:
>
> pkg.module;
And: module pkg.module;
> public import pkg.c.module;
>
> void func(const(char)[] str)
> {
> pkg.c.module.func(str.toStringz);
> }
>
> void func2(ref ModuleStruct s)
> {
> s.privateParts += 10;
> }
More information about the Digitalmars-d
mailing list