Skip to content

Commit

Permalink
Fix cimport: function pointers void(void) are passed as void function().
Browse files Browse the repository at this point in the history
  • Loading branch information
FeepingCreature committed Aug 1, 2022
1 parent d3b20ea commit 9580666
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
19 changes: 5 additions & 14 deletions hellogl.nt
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
module hellogl;

extern(C) void glClear(int);
extern(C) void glBegin(int);
extern(C) void glVertex3f(float, float, float);
extern(C) void glEnd();
extern(C) void glFlush();

extern(C) void glutInit(int* argc, char** argv);
extern(C) void glutInitDisplayMode(int);
extern(C) void glutInitWindowSize(int, int);
extern(C) void glutCreateWindow(char*);
extern(C) void glutDisplayFunc(void function());
extern(C) void glutMainLoop();
macro import std.macro.cimport;
import c_header("GL/gl.h");
import c_header("GL/glut.h");

pragma(lib, "GL");
pragma(lib, "glut");

void displayMe()
{
glClear(0x4000);
glBegin(0x0009);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, 0.0f);
Expand Down
7 changes: 7 additions & 0 deletions src/std/macro/cimport.nt
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ class CParserHelper {
}
params ~= notNull!ASTSymbol(arg.type);
}
if (params.length == 1) {
if (auto basicType = params[0].instanceOf(ASTBasicType)) {
if (basicType.name == "void") {
params = [];
}
}
}
parser.commit;
return (new ASTFunctionPointer(current, params, start), name);
}
Expand Down

0 comments on commit 9580666

Please sign in to comment.