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 !=
"")
virtual void EmitCSharpStructMemberAccessUnitTest(gxsys_ios::ostream &os, const cable::Class *c)
void Emit(gxsys_ios::ostream &os, const char *s)
virtual const char * GetArgName(cable::FunctionType *ftype, unsigned int i)
virtual gxsys_stl::string GetExtraCsharpUnitTestCode(const cable::Class *c)
MummyCsharpGenerator * CsharpGenerator
virtual void EmitCSharpPropertyUnitTest(gxsys_ios::ostream &os, const cable::Class *c, const cable::Method *mGet, const cable::Method *mSet)
virtual void EmitCSharpMethodUnitTest(gxsys_ios::ostream &os, const cable::Class *c, const cable::Method *m)
gxsys_stl::string GetFullyQualifiedNameForCPlusPlus(const cable::Named *n)
gxsys_stl::string GetFullyQualifiedNameForCSharp(const cable::Named *n)
bool IsUtilityClass(const cable::Class *c)
gxsys_stl::string ExtractMapToType(const cable::SourceObject *o)
virtual void BuildPropGetsAndSetsMap(gxsys_stl::vector< cable::Method * > &wrapped_methods, gxsys_stl::map< gxsys_stl::string, gxsys_stl::pair< cable::Method *, cable::Method * > > &wrapped_properties)
virtual void GetReferences(gxsys_stl::vector< gxsys_stl::string > &references)
virtual bool GetVerbose()
gxsys_stl::string GetWrappedClassName(const cable::Class *c)
virtual void EmitCSharpFactoryMethodUnitTest(gxsys_ios::ostream &os, const cable::Class *c)
virtual const char * GetArgName(cable::FunctionType *ftype, unsigned int i)
virtual const cable::Class * GetTargetClass()
Get the current target class.
MummyCsharpUnitTestGenerator()
virtual MummyCsharpGenerator * GetCsharpGenerator()
void EmitFile(gxsys_ios::ostream &os, const char *filename)
virtual void SetCsharpGenerator(MummyCsharpGenerator *generator)
virtual void GatherWrappedMethods(const cable::Class *c, gxsys_stl::vector< cable::Method * > &wrapped_methods, cable::Method *&factoryM, cable::Method *&disposalM, cable::Method *®isterM, cable::Method *&unRegisterM, bool includeParentMethods)
virtual void EmitMummyVersionComments(gxsys_ios::ostream &os, const char *lineCommentString)
virtual bool GenerateWrappers()
virtual void EmitClass(gxsys_ios::ostream &os, const cable::Class *c)
virtual ~MummyCsharpUnitTestGenerator()
virtual MummySettings * GetSettings()
Get the associated settings object.