digitalmars.D.learn - Method doesn't compile when defined in a mixin, but is fine without?
- pineapple (41/41) May 01 2016 I'm working on an SDL wrapper based on the derelict sdl2 and
- pineapple (4/4) May 01 2016 Strangely, though I'm getting this error when wrapping
- ag0aep6g (4/9) May 01 2016 Should the second one be "SDL_SetWindowMinimumSize" here? ("Set" instead...
- pineapple (4/15) May 01 2016 See, of course it was going to be something stupid like that.
- Stefan Koch (2/18) May 02 2016 Write code into a file or wait for my ctfe-debug tool.
I'm working on an SDL wrapper based on the derelict sdl2 and opengl3 bindings and so I've got a method like this I wrote: property Vector2!int minsize(){ int x, y; SDL_GetWindowMinimumSize(this.window, &x, &y); return Vector2!int(x, y); } I've got several almost identical methods for maximum size, and window size, and window position, and so I thought I'd make a mixin to cut down on the redundancy. So I made my mixin, which looks like this - having definitions for both the getter above and also setters that seem to work fine: static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){ return " property Vector2!int " ~ name ~ "(){ int x, y; " ~ SDL_getter ~ "(this.window, &x, &y); return Vector2!int(x, y); } property void " ~ name ~ "(in Vector2!int vector){ this.set" ~ name ~ "(vector.x, vector.y); } void set" ~ name ~ "(in int x, in int y){ " ~ SDL_setter ~ "(this.window, x, y); } "; } And then I put this in the class body, replacing the non-mixin getters that compiled without incident: mixin(vectorpropertymixin( "minsize", "SDL_GetWindowMinimumSize", "SDL_GetWindowMinimumSize" )); And using the mixin I get this error when attempting to compile: E:\Dropbox\Projects\d\mach\sdl\window.d-mixin-285(295): Error: function pointer SDL_GetWindowMinimumSize (SDL_Window*, int*, int*) is not callable using argument types (SDL_Window*, const(int), const(int)) What's going on here? I feel like I must be making a really stupid obvious oversight.
May 01 2016
Strangely, though I'm getting this error when wrapping SDL_GetWindowMinimumSize and SDL_GetWindowMaximumSize, I don't get any compilation errors wrapping the identically-signatured SDL_GetWindowSize and SDL_GetWindowPosition using the same mixin.
May 01 2016
On 01.05.2016 15:32, pineapple wrote:static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){[...]mixin(vectorpropertymixin( "minsize", "SDL_GetWindowMinimumSize", "SDL_GetWindowMinimumSize" ));Should the second one be "SDL_SetWindowMinimumSize" here? ("Set" instead of "Get".)
May 01 2016
On Sunday, 1 May 2016 at 13:46:14 UTC, ag0aep6g wrote:On 01.05.2016 15:32, pineapple wrote:See, of course it was going to be something stupid like that. Would be nice if compile errors were kinder to mixins, might've realized where the error actually was. Any tips on that?static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){[...]mixin(vectorpropertymixin( "minsize", "SDL_GetWindowMinimumSize", "SDL_GetWindowMinimumSize" ));Should the second one be "SDL_SetWindowMinimumSize" here? ("Set" instead of "Get".)
May 01 2016
On Sunday, 1 May 2016 at 14:01:51 UTC, pineapple wrote:On Sunday, 1 May 2016 at 13:46:14 UTC, ag0aep6g wrote:Write code into a file or wait for my ctfe-debug tool.On 01.05.2016 15:32, pineapple wrote:See, of course it was going to be something stupid like that. Would be nice if compile errors were kinder to mixins, might've realized where the error actually was. Any tips on that?static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){[...]mixin(vectorpropertymixin( "minsize", "SDL_GetWindowMinimumSize", "SDL_GetWindowMinimumSize" ));Should the second one be "SDL_SetWindowMinimumSize" here? ("Set" instead of "Get".)
May 02 2016