13 #ifndef MLPACK_BINDINGS_GO_PRINT_CLASS_DEFN_HPP 14 #define MLPACK_BINDINGS_GO_PRINT_CLASS_DEFN_HPP 29 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
31 const typename boost::disable_if<std::is_same<T,
32 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
43 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
54 const typename boost::enable_if<std::is_same<T,
55 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
66 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
71 std::string goStrippedType, strippedType, printedType, defaultsType;
72 StripType(d.
cppType, goStrippedType, strippedType, printedType, defaultsType);
85 std::cout <<
"extern \"C\" void mlpackSet" << strippedType
86 <<
"Ptr(" << std::endl;
87 std::cout <<
" const char* identifier, " << std::endl;
88 std::cout <<
" void* value)" << std::endl;
89 std::cout <<
"{" << std::endl;
90 std::cout <<
" SetParamPtr<" << printedType
91 <<
">(identifier," << std::endl;
92 std::cout <<
" static_cast<" << printedType
93 <<
"*>(value));" << std::endl;
94 std::cout <<
"}" << std::endl;
95 std::cout << std::endl;
107 std::cout <<
"extern \"C\" void *mlpackGet" << strippedType
108 <<
"Ptr(const char* identifier)" << std::endl;
109 std::cout <<
"{" << std::endl;
110 std::cout <<
" " << printedType <<
" *modelptr = GetParamPtr<" 111 << printedType <<
">(identifier);" << std::endl;
112 std::cout <<
" return modelptr;" << std::endl;
113 std::cout <<
"}" << std::endl;
114 std::cout << std::endl;
129 PrintModelUtilCPP<typename std::remove_pointer<T>::type>(d);
140 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
142 const typename boost::disable_if<std::is_same<T,
143 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
155 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
166 const typename boost::enable_if<std::is_same<T,
167 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
178 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
183 std::string goStrippedType, strippedType, printedType, defaultsType;
184 StripType(d.
cppType, goStrippedType, strippedType, printedType, defaultsType);
192 std::cout <<
"extern void mlpackSet" << strippedType
193 <<
"Ptr(const char* identifier, void* value);" << std::endl;
194 std::cout << std::endl;
202 std::cout <<
"extern void *mlpackGet" << strippedType
203 <<
"Ptr(const char* identifier);" << std::endl;
204 std::cout << std::endl;
219 PrintModelUtilH<typename std::remove_pointer<T>::type>(d);
229 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
231 const typename boost::disable_if<std::is_same<T,
232 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
243 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
254 const typename boost::enable_if<std::is_same<T,
255 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
266 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
271 std::string goStrippedType, strippedType, printedType, defaultsType;
272 StripType(d.
cppType, goStrippedType, strippedType, printedType, defaultsType);
282 std::cout <<
"type " << goStrippedType <<
" struct {" << std::endl;
283 std::cout <<
" mem unsafe.Pointer" << std::endl;
284 std::cout <<
"}" << std::endl;
285 std::cout << std::endl;
296 std::cout <<
"func (m *" << goStrippedType <<
") alloc" 297 << strippedType <<
"(identifier string) {" << std::endl;
298 std::cout <<
" m.mem = C.mlpackGet" << strippedType
299 <<
"Ptr(C.CString(identifier))" << std::endl;
300 std::cout <<
" runtime.KeepAlive(m)" << std::endl;
301 std::cout <<
"}" << std::endl;
302 std::cout << std::endl;
312 std::cout <<
"func (m *" << goStrippedType <<
") get" 313 << strippedType <<
"(identifier string) {" << std::endl;
314 std::cout <<
" m.alloc" << strippedType <<
"(identifier)" << std::endl;
315 std::cout <<
"}" << std::endl;
316 std::cout << std::endl;
319 std::cout <<
"func set" << strippedType
320 <<
"(identifier string, ptr *" << goStrippedType <<
") {" 322 std::cout <<
" C.mlpackSet" << strippedType
323 <<
"Ptr(C.CString(identifier), (unsafe.Pointer)(ptr.mem))" 325 std::cout <<
"}" << std::endl;
326 std::cout << std::endl;
342 PrintModelUtilGo<typename std::remove_pointer<T>::type>(d);
void StripType(const std::string &inputType, std::string &goStrippedType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return four types that can be used in Go code...
This structure holds all of the information about a single parameter, including its value (which is s...
void PrintModelUtilGo(const util::ParamData &, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
Non-serializable models don't require any special definitions, so this prints nothing.
void PrintModelUtilCPP(const util::ParamData &, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
Non-serializable models don't require any special definitions, so this prints nothing.
void PrintModelUtilH(const util::ParamData &, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
Non-serializable models don't require any special definitions, so this prints nothing.
std::string cppType
The true name of the type, as it would be written in C++.