| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Argument.h"
 | 
					
						
							|  |  |  | #include "ReturnValue.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace wrap { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct GlobalFunction { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   typedef std::vector<std::string> StrVec; | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   bool verbose_; | 
					
						
							|  |  |  |   std::string name; | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // each overload, regardless of namespace
 | 
					
						
							|  |  |  |   std::vector<ArgumentList> argLists;       ///< arugments for each overload
 | 
					
						
							|  |  |  |   std::vector<ReturnValue> returnVals;      ///< returnVals for each overload
 | 
					
						
							|  |  |  |   std::vector<StrVec> namespaces;           ///< Stack of namespaces
 | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // Constructor only used in Module
 | 
					
						
							|  |  |  |   GlobalFunction(bool verbose = true) : verbose_(verbose) {} | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // Used to reconstruct
 | 
					
						
							|  |  |  |   GlobalFunction(const std::string& name_, bool verbose = true) | 
					
						
							|  |  |  |   : verbose_(verbose), name(name_) {} | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // adds an overloaded version of this function
 | 
					
						
							|  |  |  |   void addOverload(bool verbose, const std::string& name, | 
					
						
							|  |  |  |     const ArgumentList& args, const ReturnValue& retVal, const StrVec& ns_stack); | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  |   void matlab_proxy(const std::string& toolboxPath, const std::string& wrapperName, | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |       const TypeAttributesTable& typeAttributes,  FileWriter& wrapperFile, | 
					
						
							|  |  |  |       std::vector<std::string>& functionNames) const; | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Creates a single global function - all in same namespace
 | 
					
						
							|  |  |  |   void generateSingleFunction(const std::string& toolboxPath, const std::string& wrapperName, | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |       const TypeAttributesTable& typeAttributes,  FileWriter& wrapperFile, | 
					
						
							|  |  |  |       std::vector<std::string>& functionNames) const; | 
					
						
							| 
									
										
										
										
											2012-07-24 02:24:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // \namespace wrap
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |