[cfe-dev] automatic constructors a la GLSL?

Dominic Laflamme flamz3d at hotmail.com
Thu Sep 9 04:23:45 PDT 2010


Hello,
Please excuse the newbiness of this post. 
I am porting a bunch of GLSL code over to LLVM and am wondering how I can setup constructors for a certain type. 

example:

<snip>
typedef float float4 __attribute__((ext_vector_type(4)));

float4 float4(float r, float g, float b, float a )
{
float4 ret = {r,g,b,a};
return ret;
}

float4 float4(float r, float g, float b )

{
float4 ret = {r,g,b,1.0};

return ret;
}
</snip>

Of course this wont work since the function are using the same name, but any idea how I can setup these types of constructors? Should I declare float4 as a struct and overload the constructors? Can the ext_vector_type extension provide some help?

cheers.

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100909/1377a933/attachment.html>


More information about the cfe-dev mailing list