/**
 * Allegro's got some global variables (like mouse_x, etc.) that are declared
 * 'volatile'.  D doesn't have a volatile type qualifier.  The workaround is
 * to wrap those globals in functions.
 */
 
module allegro.internal._volatile;

import allegro.internal.dversion;


private const string prefix = "allegro.internal.dintern.";


/// Getter.
string _volatile(string type, string name)
{
   version (NoVolatile) {
      return "alias " ~ prefix ~ name ~ " " ~ name ~ ";";
   }
   else {
      return type ~ " " ~ name ~ "() { volatile return " ~ prefix ~ name ~ "; }";
   }
}

/// Setter.
string _volatile_setter(string type, string name)
{
	version (NoVolatile) {
	   return "";
	}
	else {
      return "void " ~ name ~ "(" ~ type ~ " v) { volatile " ~ prefix ~ name ~ " = v; }";
   }
}
