template<class T>\r
void Return(RValue<Pointer<T> > ret);\r
\r
- template<class R = Void, class A1 = Void, class A2 = Void, class A3 = Void, class A4 = Void>\r
- class Function\r
+ // Generic template, leave undefined!\r
+ template<typename FunctionType>\r
+ class Function;\r
+\r
+ // Specialized for function types\r
+ template<typename Return, typename... Arguments>\r
+ class Function<Return(Arguments...)>\r
{\r
public:\r
Function();\r
Nucleus::setInsertBlock(Nucleus::createBasicBlock());\r
}\r
\r
- template<class R, class A1, class A2, class A3, class A4>\r
- Function<R, A1, A2, A3, A4>::Function()\r
+ template<typename Return, typename... Arguments>\r
+ Function<Return(Arguments...)>::Function()\r
{\r
core = new Nucleus();\r
\r
- if(!A1::isVoid()) arguments.push_back(A1::getType());\r
- if(!A2::isVoid()) arguments.push_back(A2::getType());\r
- if(!A3::isVoid()) arguments.push_back(A3::getType());\r
- if(!A4::isVoid()) arguments.push_back(A4::getType());\r
+ llvm::Type *types[] = {Arguments::getType()...};\r
+ for(llvm::Type *type : types)\r
+ {\r
+ arguments.push_back(type);\r
+ } \r
\r
- function = Nucleus::createFunction(R::getType(), arguments);\r
+ function = Nucleus::createFunction(Return::getType(), arguments);\r
Nucleus::setFunction(function);\r
}\r
\r
- template<class R, class A1, class A2, class A3, class A4>\r
- Function<R, A1, A2, A3, A4>::~Function()\r
+ template<typename Return, typename... Arguments>\r
+ Function<Return(Arguments...)>::~Function()\r
{\r
delete core;\r
}\r
\r
- template<class R, class A1, class A2, class A3, class A4>\r
- llvm::Argument *Function<R, A1, A2, A3, A4>::arg(int index)\r
+ template<typename Return, typename... Arguments>\r
+ llvm::Argument *Function<Return(Arguments...)>::arg(int index)\r
{\r
return Nucleus::getArgument(function, index);\r
}\r
\r
- template<class R, class A1, class A2, class A3, class A4>\r
- Routine *Function<R, A1, A2, A3, A4>::operator()(const wchar_t *name, ...)\r
+ template<typename Return, typename... Arguments>\r
+ Routine *Function<Return(Arguments...)>::operator()(const wchar_t *name, ...)\r
{\r
wchar_t fullName[1024 + 1];\r
\r