Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import std.stdio;
  2. import std.typecons;
  3.  
  4. private immutable auto extensionTable = [
  5.         ["WGL_ARB_make_current_read",
  6.         "void function(int, int, int)", "wglMakeContextCurrentARB",
  7.         "void function()", "wglGetCurrentReadDCARB"],
  8.        
  9.         ["WGL_ARB_pixel_format_float"],
  10.        
  11.         ["WGL_ARB_create_context",
  12.         "void function(int, int, int)", "wglCreateContextAttribsARB"],
  13. ];
  14.  
  15. private template genTypes()
  16. {
  17.     string eval()
  18.     {
  19.         string code;
  20.         foreach (array; extensionTable)
  21.         {
  22.             for (int index = 1; index < array.length; index += 2)
  23.             {
  24.                 code ~= "alias nothrow " ~ array[index] ~ " da_" ~ array[index + 1] ~ ";";
  25.             }
  26.         }
  27.         return code;
  28.     }
  29.     string genTypes = eval();
  30.     //const(char[]) genTypes = eval(); // fix
  31. }
  32.  
  33. mixin(genTypes!()); // Error: variable genTypes cannot be read at compile time
  34.  
  35. void main()
  36. {
  37.     assert(is(da_wglCreateContextAttribsARB));
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement