Skip to content

Commit

Permalink
Merge pull request #5177 from yebblies/cppinterface
Browse files Browse the repository at this point in the history
Clean up C++ interface problems that prevent automatic header generation from working
  • Loading branch information
9rnsr committed Oct 9, 2015
2 parents 8ce7819 + 26f6144 commit 00c66e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/builtin.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ import ddmd.root.port;
import ddmd.root.stringtable;
import ddmd.tokens;

private:

extern (C++) alias builtin_fp = Expression function(Loc loc, FuncDeclaration fd, Expressions* arguments);

extern (C++) __gshared StringTable builtins;
__gshared StringTable builtins;

extern (C++) void add_builtin(const(char)* mangle, builtin_fp fp)
public extern (C++) void add_builtin(const(char)* mangle, builtin_fp fp)
{
builtins.insert(mangle, strlen(mangle)).ptrvalue = cast(void*)fp;
}

extern (C++) builtin_fp builtin_lookup(const(char)* mangle)
builtin_fp builtin_lookup(const(char)* mangle)
{
if (StringValue* sv = builtins.lookup(mangle, strlen(mangle)))
return cast(builtin_fp)sv.ptrvalue;
Expand Down Expand Up @@ -168,7 +170,7 @@ extern (C++) Expression eval_yl2xp1(Loc loc, FuncDeclaration fd, Expressions* ar
return new RealExp(loc, result, arg0.type);
}

extern (C++) void builtin_init()
public extern (C++) void builtin_init()
{
builtins._init(47);
// @safe @nogc pure nothrow real function(real)
Expand Down Expand Up @@ -272,7 +274,7 @@ extern (C++) void builtin_init()
* Determine if function is a builtin one that we can
* evaluate at compile time.
*/
extern (C++) BUILTIN isBuiltin(FuncDeclaration fd)
public extern (C++) BUILTIN isBuiltin(FuncDeclaration fd)
{
if (fd.builtin == BUILTINunknown)
{
Expand All @@ -286,7 +288,7 @@ extern (C++) BUILTIN isBuiltin(FuncDeclaration fd)
* Evaluate builtin function.
* Return result; NULL if cannot evaluate it.
*/
extern (C++) Expression eval_builtin(Loc loc, FuncDeclaration fd, Expressions* arguments)
public extern (C++) Expression eval_builtin(Loc loc, FuncDeclaration fd, Expressions* arguments)
{
if (fd.builtin == BUILTINyes)
{
Expand Down
4 changes: 2 additions & 2 deletions src/complex.d
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ struct complex_t
}
}

real creall(complex_t x)
extern (C++) real creall(complex_t x)
{
return x.re;
}

real cimagl(complex_t x)
extern (C++) real cimagl(complex_t x)
{
return x.im;
}
4 changes: 3 additions & 1 deletion src/entity.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module ddmd.entity;

import core.stdc.ctype;

private:

/*********************************************
* Convert from named entity to its encoding.
* For reference:
Expand Down Expand Up @@ -2371,7 +2373,7 @@ immutable NameId[][] namesTable =
namesS, namesT, namesU, namesV, namesW, namesX, namesY, namesZ
];

extern (C++) int HtmlNamedEntity(const(char)* p, size_t length)
public int HtmlNamedEntity(const(char)* p, size_t length)
{
int tableIndex = tolower(*p) - 'a';
if (tableIndex >= 0 && tableIndex < 26)
Expand Down

0 comments on commit 00c66e1

Please sign in to comment.