18 #include "cableClass.h"
19 #include "cableClassType.h"
20 #include "cableFunctionType.h"
21 #include "cableMethod.h"
22 #include "cablePointerType.h"
23 #include "cableReferenceType.h"
24 #include "cxxCvQualifiedType.h"
25 #include "cxxFunctionType.h"
26 #include "cxxPointerType.h"
28 #include "gxsys/stl/algorithm"
29 #include "gxsys/SystemTools.hxx"
112 Emit(os,
"// EmitCSharpFactoryMethodUnitTest\n");
119 Emit(os,
"// EmitCSharpMethodUnitTest\n");
126 Emit(os,
"// EmitCSharpPropertyUnitTest\n");
133 Emit(os,
"// EmitCSharpStructMemberAccessUnitTest\n");
142 gxsys_stl::vector<cable::Method*> wrapped_methods;
143 gxsys_stl::vector<cable::Method*>::iterator mit;
144 cable::Method *factoryM = 0;
145 cable::Method *disposalM = 0;
146 cable::Method *registerM = 0;
147 cable::Method *unRegisterM = 0;
149 gxsys_stl::string atts(c->GetAttributes());
155 gxsys_stl::string target_namespace;
156 gxsys_stl::string base_namespace(this->
GetSettings()->GetPackage());
161 if (class_namespace ==
"::")
163 class_namespace =
"";
166 if (base_namespace ==
"")
168 target_namespace = class_namespace;
170 else if (class_namespace ==
"")
172 target_namespace = base_namespace;
176 target_namespace = base_namespace +
"." + class_namespace;
179 if (target_namespace !=
"")
181 target_namespace = target_namespace +
".UnitTests";
196 Emit(os,
"//----------------------------------------------------------------------------\n");
197 Emit(os,
"// Unmanaged class '");
199 Emit(os,
"' maps directly to type '");
200 Emit(os, mapToType.c_str());
202 Emit(os,
"// No code generated for '");
216 Emit(os,
"//----------------------------------------------------------------------------\n");
217 Emit(os,
"using System;\n");
218 Emit(os,
"using System.Runtime.InteropServices; // DllImport and HandleRef both live here\n");
225 gxsys_stl::vector<gxsys_stl::string> refs;
229 Emit(os,
"// References\n");
230 gxsys_stl::vector<gxsys_stl::string>::iterator rit;
231 for (rit = refs.begin(); rit != refs.end(); ++rit)
234 Emit(os, rit->c_str());
243 if (target_namespace !=
"")
245 Emit(os,
"namespace ");
246 Emit(os, target_namespace.c_str());
255 Emit(os,
"/// <summary>\n");
256 Emit(os,
"/// Automatically generated unit test\n");
257 Emit(os,
"/// </summary>\n");
280 gxsys_stl::map<gxsys_stl::string, gxsys_stl::pair<cable::Method*, cable::Method*> > wrapped_properties;
286 gxsys_stl::map<gxsys_stl::string, gxsys_stl::pair<cable::Method*, cable::Method*> >::iterator gsit;
287 for (gsit = wrapped_properties.begin(); gsit != wrapped_properties.end(); ++gsit)
289 if (gsit->second.first)
291 mit = gxsys_stl::find(wrapped_methods.begin(), wrapped_methods.end(),
293 if (mit != wrapped_methods.end())
295 wrapped_methods.erase(mit);
303 if (gsit->second.second)
305 mit = gxsys_stl::find(wrapped_methods.begin(), wrapped_methods.end(),
306 gsit->second.second);
307 if (mit != wrapped_methods.end())
309 wrapped_methods.erase(mit);
328 Emit(os,
"UnitTest");
340 if (factoryM || this->
GetSettings()->GetUseShadow(c))
350 for (gsit = wrapped_properties.begin(); gsit != wrapped_properties.end(); ++gsit)
360 for (mit = wrapped_methods.begin(); mit != wrapped_methods.end(); ++mit)
380 Emit(os,
"// Begin extraCSharpCode\n");
384 Emit(os,
"// End extraCSharpCode\n");
396 if (target_namespace !=
"")