| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file GlobalFunction.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @brief Implements codegen for a global function wrapped in matlab | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * @date Jul 22, 2012 | 
					
						
							|  |  |  |  * @author Alex Cunningham | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:41 +08:00
										 |  |  | #include "Function.h"
 | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace wrap { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  | struct GlobalFunction: public Function, public SignatureOverloads { | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:41 +08:00
										 |  |  |   std::vector<Qualified> overloads; ///< Stack of qualified names
 | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // Constructor only used in Module
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:01:30 +08:00
										 |  |  |   GlobalFunction(bool verbose = true) : | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:41 +08:00
										 |  |  |       Function(verbose) { | 
					
						
							| 
									
										
										
										
											2014-05-26 04:01:30 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // Used to reconstruct
 | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:41 +08:00
										 |  |  |   GlobalFunction(const std::string& name, bool verbose = true) : | 
					
						
							|  |  |  |       Function(name,verbose) { | 
					
						
							| 
									
										
										
										
											2014-05-26 04:01:30 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   void verifyArguments(const std::vector<std::string>& validArgs) const { | 
					
						
							|  |  |  |     SignatureOverloads::verifyArguments(validArgs, name_); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void verifyReturnTypes(const std::vector<std::string>& validtypes) const { | 
					
						
							|  |  |  |     SignatureOverloads::verifyReturnTypes(validtypes, name_); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:41 +08:00
										 |  |  |   // adds an overloaded version of this function,
 | 
					
						
							| 
									
										
										
										
											2014-11-12 09:49:23 +08:00
										 |  |  |   void addOverload(bool verbose, const Qualified& overload, | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:41 +08:00
										 |  |  |       const ArgumentList& args, const ReturnValue& retVal, | 
					
						
							|  |  |  |       const Qualified& instName = Qualified()); | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // codegen function called from Module to build the cpp and matlab versions of the function
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:01:30 +08:00
										 |  |  |   void matlab_proxy(const std::string& toolboxPath, | 
					
						
							|  |  |  |       const std::string& wrapperName, const TypeAttributesTable& typeAttributes, | 
					
						
							|  |  |  |       FileWriter& file, std::vector<std::string>& functionNames) const; | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Creates a single global function - all in same namespace
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:01:30 +08:00
										 |  |  |   void generateSingleFunction(const std::string& toolboxPath, | 
					
						
							|  |  |  |       const std::string& wrapperName, const TypeAttributesTable& typeAttributes, | 
					
						
							|  |  |  |       FileWriter& file, std::vector<std::string>& functionNames) const; | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // \namespace wrap
 | 
					
						
							|  |  |  | 
 |