CSFunctionWriter.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #include <Atomic/IO/FileSystem.h>
  8. #include "../JSBind.h"
  9. #include "../JSBModule.h"
  10. #include "../JSBPackage.h"
  11. #include "../JSBEnum.h"
  12. #include "../JSBClass.h"
  13. #include "../JSBFunction.h"
  14. #include "CSTypeHelper.h"
  15. #include "CSFunctionWriter.h"
  16. /*
  17. *
  18. C# getters/setters
  19. local instance storage so we're not constantly creating managed Vector3, etc
  20. Vector2/Vector3/BoundingBox, etc C# structs so assign by value
  21. Object lifetime
  22. C# enum of module types for type info?
  23. C# version of push class instance?
  24. new instance from C# needs constructor
  25. wrapping does not, wrapping doesn't use constructors at all (JS needs this for prototype)
  26. Store GCHandle to keep an object alive (Component, UI) C# side?
  27. typedef const void* ClassID;
  28. which changed based on address, so need register at startup
  29. so at package startup time, need to setup mapping between
  30. IntPtr and C# class, we also need to be able to new a class
  31. instance with existing native or create a native when new'ing from C#
  32. IntPtr to RefCounted native side is the "ID", like JSHeapPtr
  33. Lifetime:
  34. // you cannot derive from native engine classes, other than script components
  35. a C# instance can be new'd, handed to native, stored in native, the C# side could be GC'd
  36. future access to this instance would be a new instance
  37. */
  38. /*
  39. // struct marshal Vector2, Vector3, BoundingBox, etc
  40. // RefCounted*
  41. // primitive bool, int, uint, float, double
  42. // String
  43. RefCounted* csb_Node_Constructor()
  44. {
  45. return new Node(NETCore::GetContext());
  46. }
  47. void csb_Node_GetPosition(Node* self, Vector3* out)
  48. {
  49. *out = self->GetPosition();
  50. }
  51. void csb_Node_SetPosition(Node* self, Vector3*__arg0)
  52. {
  53. self->SetPosition(*__arg0);
  54. }
  55. void csb_Node_SetPosition(Node* self, Vector3*__arg0)
  56. {
  57. self->SetPosition(*__arg0);
  58. }
  59. bool csb_Audio_Play(Audio* self)
  60. {
  61. bool retValue = self->Play();
  62. return retValue;
  63. }
  64. const RefCounted* csb_Node_GetParent(Node* self)
  65. {
  66. const RefCounted* retValue = self->GetParent();
  67. return RefCounted;
  68. }
  69. RefCounted* csb_ObjectAnimation_Constructor()
  70. {
  71. return new ObjectAnimation(NETCore::GetContext());
  72. }
  73. */
  74. namespace ToolCore
  75. {
  76. CSFunctionWriter::CSFunctionWriter(JSBFunction *function) : JSBFunctionWriter(function)
  77. {
  78. }
  79. void CSFunctionWriter::WriteNativeParameterMarshal(String& source)
  80. {
  81. }
  82. void CSFunctionWriter::WriteNativeConstructor(String& source)
  83. {
  84. }
  85. void CSFunctionWriter::GenNativeCallParameters(String& sig)
  86. {
  87. JSBClass* klass = function_->GetClass();
  88. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  89. Vector<String> args;
  90. if (parameters.Size())
  91. {
  92. for (unsigned int i = 0; i < parameters.Size(); i++)
  93. {
  94. JSBFunctionType* ptype = parameters.At(i);
  95. // ignore "Context" parameters
  96. if (ptype->type_->asClassType())
  97. {
  98. JSBClassType* classType = ptype->type_->asClassType();
  99. JSBClass* klass = classType->class_;
  100. if (klass->GetName() == "Context")
  101. {
  102. continue;
  103. }
  104. if (klass->IsNumberArray())
  105. args.Push(ToString("*%s", ptype->name_.CString()));
  106. else
  107. args.Push(ToString("%s", ptype->name_.CString()));
  108. }
  109. else
  110. {
  111. args.Push(ToString("%s", ptype->name_.CString()));
  112. }
  113. }
  114. }
  115. sig.Join(args, ", ");
  116. }
  117. void CSFunctionWriter::GenNativeThunkCallParameters(String& sig)
  118. {
  119. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  120. Vector<String> args;
  121. if (!function_->IsConstructor())
  122. args.Push("self");
  123. if (parameters.Size())
  124. {
  125. for (unsigned int i = 0; i < parameters.Size(); i++)
  126. {
  127. JSBFunctionType* ptype = parameters.At(i);
  128. // ignore "Context" parameters
  129. if (ptype->type_->asClassType())
  130. {
  131. JSBClassType* classType = ptype->type_->asClassType();
  132. JSBClass* klass = classType->class_;
  133. if (klass->GetName() == "Context")
  134. {
  135. continue;
  136. }
  137. args.Push(ToString("%s", ptype->name_.CString()));
  138. }
  139. else
  140. {
  141. args.Push(ToString("%s", ptype->name_.CString()));
  142. }
  143. }
  144. }
  145. if (function_->GetReturnClass() && function_->GetReturnClass()->IsNumberArray())
  146. args.Push("returnValue");
  147. sig.Join(args, ", ");
  148. }
  149. void CSFunctionWriter::WriteNativeFunction(String& source)
  150. {
  151. JSBClass* klass = function_->GetClass();
  152. JSBPackage* package = klass->GetPackage();
  153. String fname = function_->IsConstructor() ? "Constructor" : function_->GetName();
  154. String returnType;
  155. String functionSig = CSTypeHelper::GetNativeFunctionSignature(function_, returnType);
  156. String line;
  157. line = ToString("ATOMIC_EXPORT_API %s %s\n",
  158. returnType.CString(), functionSig.CString());
  159. source += IndentLine(line);
  160. source += IndentLine("{\n");
  161. Indent();
  162. source += "\n";
  163. line = ToString("if ( AtomicNET%sThunkEnabled )\n", package->GetName().CString());
  164. source += IndentLine(line);
  165. source += IndentLine("{\n");
  166. Indent();
  167. // write the thunk
  168. line = returnType == "void" ? "" : "return ";
  169. String thunkCallSig;
  170. GenNativeThunkCallParameters(thunkCallSig);
  171. line += ToString("AtomicNET%sThunk.__%s_%s_%s(%s);\n", package->GetName().CString(), package->GetName().CString(), klass->GetName().CString(),
  172. fname.CString(), thunkCallSig.CString());
  173. source += IndentLine(line);
  174. Dedent();
  175. source += IndentLine("}\n");
  176. source += IndentLine("else\n");
  177. source += IndentLine("{\n");
  178. Indent();
  179. bool returnValue = false;
  180. bool sharedPtrReturn = false;
  181. String returnStatement;
  182. if (returnType == "const char*")
  183. {
  184. returnValue = true;
  185. source += IndentLine("static String returnValue;\n");
  186. returnStatement = "returnValue = ";
  187. }
  188. else if (function_->GetReturnClass() && function_->GetReturnClass()->IsNumberArray())
  189. {
  190. returnStatement = "*returnValue = ";
  191. }
  192. else if (function_->GetReturnClass() && function_->GetReturnType()->isSharedPtr_)
  193. {
  194. returnStatement = ToString("SharedPtr<%s> returnValue = ", function_->GetReturnClass()->GetNativeName().CString());
  195. sharedPtrReturn = true;
  196. }
  197. else
  198. {
  199. if (returnType != "void")
  200. {
  201. returnStatement = "return ";
  202. }
  203. }
  204. String callSig;
  205. GenNativeCallParameters(callSig);
  206. if (!function_->isConstructor_)
  207. line = ToString("%sself->%s(%s);\n", returnStatement.CString(), function_->GetName().CString(), callSig.CString());
  208. else
  209. {
  210. if (klass->IsAbstract())
  211. {
  212. line = "return 0; // Abstract Class\n";
  213. }
  214. else if (klass->IsObject())
  215. {
  216. if (callSig.Length())
  217. line = ToString("return new %s(NETCore::GetContext(), %s);\n", klass->GetNativeName().CString(), callSig.CString());
  218. else
  219. line = ToString("return new %s(NETCore::GetContext());\n", klass->GetNativeName().CString());
  220. }
  221. else
  222. {
  223. line = ToString("return new %s(%s);\n", klass->GetNativeName().CString(), callSig.CString());
  224. }
  225. }
  226. source += IndentLine(line);
  227. if (sharedPtrReturn)
  228. {
  229. source += IndentLine("returnValue->AddRef();\n");
  230. source += IndentLine("return returnValue;\n");
  231. }
  232. else if (returnType == "const char*")
  233. {
  234. source += IndentLine("return returnValue.CString();\n");
  235. }
  236. Dedent();
  237. source += IndentLine("}\n");
  238. Dedent();
  239. source += IndentLine("}\n");
  240. source += "\n";
  241. }
  242. void CSFunctionWriter::GenerateNativeSource(String& sourceOut)
  243. {
  244. String source = "";
  245. WriteNativeFunction(source);
  246. sourceOut += source;
  247. }
  248. // MANAGED----------------------------------------------------------------------------------------
  249. void CSFunctionWriter::WriteDefaultStructParameters(String& source)
  250. {
  251. for (unsigned i = 0; i < defaultStructParameters_.Size(); i++)
  252. {
  253. const DefaultStructParameter& dparm = defaultStructParameters_[i];
  254. String line = ToString("if (default(%s).Equals(%s)) %s = %s;\n",
  255. dparm.type.CString(), dparm.parameterName.CString(), dparm.parameterName.CString(),
  256. dparm.assignment.CString());
  257. source += IndentLine(line);
  258. }
  259. }
  260. void CSFunctionWriter::WriteManagedPInvokeFunctionSignature(String& source)
  261. {
  262. source += "\n";
  263. String line = "[DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]\n";
  264. source += IndentLine(line);
  265. JSBClass* klass = function_->GetClass();
  266. JSBPackage* package = klass->GetPackage();
  267. String returnType = CSTypeHelper::GetPInvokeTypeString(function_->GetReturnType());
  268. if (returnType == "string")
  269. returnType = "IntPtr";
  270. if (function_->IsConstructor())
  271. returnType = "IntPtr";
  272. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  273. Vector<String> args;
  274. if (!function_->IsConstructor())
  275. {
  276. args.Push("IntPtr self");
  277. }
  278. if (parameters.Size())
  279. {
  280. for (unsigned int i = 0; i < parameters.Size(); i++)
  281. {
  282. JSBFunctionType* ptype = parameters.At(i);
  283. String name = ptype->name_;
  284. if (name == "object")
  285. name = "_object";
  286. else if (name == "readonly")
  287. name = "readOnly";
  288. else if (name == "params")
  289. name = "parameters";
  290. // ignore "Context" parameters
  291. if (ptype->type_->asClassType())
  292. {
  293. JSBClassType* classType = ptype->type_->asClassType();
  294. JSBClass* klass = classType->class_;
  295. if (klass->GetName() == "Context")
  296. {
  297. continue;
  298. }
  299. if (klass->IsNumberArray())
  300. {
  301. args.Push("ref " + klass->GetName() + " " + name);
  302. }
  303. else
  304. {
  305. args.Push("IntPtr " + name);
  306. }
  307. }
  308. else
  309. {
  310. args.Push(CSTypeHelper::GetPInvokeTypeString(ptype) + " " + name);
  311. }
  312. }
  313. }
  314. if (function_->GetReturnClass())
  315. {
  316. JSBClass* retClass = function_->GetReturnClass();
  317. if (retClass->IsNumberArray())
  318. {
  319. args.Push("ref " + retClass->GetName() + " retValue");
  320. }
  321. }
  322. String pstring;
  323. pstring.Join(args, ", ");
  324. String fname = function_->IsConstructor() ? "Constructor" : function_->GetName();
  325. line = ToString("private static extern %s csb_%s_%s_%s(%s);\n",
  326. returnType.CString(), package->GetName().CString(), klass->GetName().CString(),
  327. fname.CString(), pstring.CString());
  328. source += IndentLine(line);
  329. source += "\n";
  330. }
  331. void CSFunctionWriter::GenManagedFunctionParameters(String& sig)
  332. {
  333. // generate args
  334. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  335. if (parameters.Size())
  336. {
  337. for (unsigned int i = 0; i < parameters.Size(); i++)
  338. {
  339. JSBFunctionType* ptype = parameters.At(i);
  340. // ignore "Context" parameters
  341. if (ptype->type_->asClassType())
  342. {
  343. JSBClassType* classType = ptype->type_->asClassType();
  344. JSBClass* klass = classType->class_;
  345. if (klass->GetName() == "Context")
  346. {
  347. continue;
  348. }
  349. }
  350. sig += CSTypeHelper::GetManagedTypeString(ptype);
  351. String init = ptype->initializer_;
  352. if (init.Length())
  353. {
  354. init = MapDefaultParameter(ptype);
  355. if (init.Length())
  356. sig += " = " + init;
  357. }
  358. if (i + 1 != parameters.Size())
  359. sig += ", ";
  360. }
  361. }
  362. }
  363. void CSFunctionWriter::WriteManagedConstructor(String& source)
  364. {
  365. JSBClass* klass = function_->GetClass();
  366. JSBPackage* package = klass->GetPackage();
  367. if (klass->GetName() == "RefCounted")
  368. return;
  369. // wrapping constructor
  370. String line;
  371. line = ToString("public %s (IntPtr native) : base (native)\n", klass->GetName().CString());
  372. source += IndentLine(line);
  373. source += IndentLine("{\n");
  374. source += IndentLine("}\n\n");
  375. String sig;
  376. GenManagedFunctionParameters(sig);
  377. line = ToString("public %s (%s)\n", klass->GetName().CString(), sig.CString());
  378. source += IndentLine(line);
  379. source += IndentLine("{\n");
  380. Indent();
  381. WriteDefaultStructParameters(source);
  382. line = ToString("if (typeof(%s) == this.GetType()", klass->GetName().CString());
  383. line += ToString(" || (this.GetType().BaseType == typeof(%s) && !NativeCore.GetNativeType(this.GetType())))\n", klass->GetName().CString());
  384. source += IndentLine(line);
  385. source += IndentLine("{\n");
  386. Indent();
  387. String callSig;
  388. GenPInvokeCallParameters(callSig);
  389. line = ToString("nativeInstance = NativeCore.RegisterNative (csb_%s_%s_Constructor(%s), this);\n",
  390. package->GetName().CString(), klass->GetName().CString(), callSig.CString());
  391. source += IndentLine(line);
  392. Dedent();
  393. source += IndentLine("}\n");
  394. Dedent();
  395. source += IndentLine("}\n");
  396. }
  397. void CSFunctionWriter::GenPInvokeCallParameters(String& sig)
  398. {
  399. // generate args
  400. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  401. if (parameters.Size())
  402. {
  403. for (unsigned int i = 0; i < parameters.Size(); i++)
  404. {
  405. JSBFunctionType* ptype = parameters.At(i);
  406. // ignore "Context" parameters
  407. if (ptype->type_->asClassType())
  408. {
  409. JSBClassType* classType = ptype->type_->asClassType();
  410. JSBClass* klass = classType->class_;
  411. if (klass->GetName() == "Context")
  412. {
  413. continue;
  414. }
  415. }
  416. String name = ptype->name_;
  417. if (name == "object")
  418. name = "_object";
  419. else if (name == "readonly")
  420. name = "readOnly";
  421. else if (name == "params")
  422. name = "parameters";
  423. if (ptype->type_->asClassType())
  424. {
  425. JSBClass* pclass = ptype->type_->asClassType()->class_;
  426. if (pclass->IsNumberArray())
  427. {
  428. sig += "ref " + name;
  429. }
  430. else
  431. {
  432. sig += name + " == null ? IntPtr.Zero : " + name + ".nativeInstance";
  433. }
  434. }
  435. else
  436. {
  437. sig += name;
  438. }
  439. if (i + 1 != parameters.Size())
  440. sig += ", ";
  441. }
  442. }
  443. // data marshaller
  444. if (function_->GetReturnType() && !CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  445. {
  446. if (function_->GetReturnClass()->IsNumberArray())
  447. {
  448. if (sig.Length())
  449. sig += ", ";
  450. JSBClass* klass = function_->GetClass();
  451. sig += ToString("ref %s%sReturnValue", klass->GetName().CString(), function_->GetName().CString());
  452. }
  453. }
  454. }
  455. void CSFunctionWriter::WriteManagedFunction(String& source)
  456. {
  457. JSBClass* klass = function_->GetClass();
  458. JSBPackage* package = klass->GetPackage();
  459. String sig;
  460. String returnType = CSTypeHelper::GetManagedTypeString(function_->GetReturnType());
  461. GenManagedFunctionParameters(sig);
  462. String line = ToString("public %s %s (%s)\n", returnType.CString(), function_->GetName().CString(), sig.CString());
  463. source += IndentLine(line);
  464. source += IndentLine("{\n");
  465. Indent();
  466. WriteDefaultStructParameters(source);
  467. line.Clear();
  468. if (function_->GetReturnType())
  469. {
  470. if (function_->GetReturnType()->type_->asStringType() || function_->GetReturnType()->type_->asStringHashType())
  471. {
  472. line += "return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(";
  473. }
  474. else if (CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  475. line += "return ";
  476. else
  477. {
  478. if (function_->GetReturnClass())
  479. {
  480. if (!function_->GetReturnClass()->IsNumberArray())
  481. line += "IntPtr retNativeInstance = ";
  482. }
  483. }
  484. }
  485. String callSig;
  486. GenPInvokeCallParameters(callSig);
  487. line += ToString("csb_%s_%s_%s(nativeInstance",
  488. package->GetName().CString(), klass->GetName().CString(), function_->GetName().CString());
  489. if (callSig.Length())
  490. {
  491. line += ", " + callSig;
  492. }
  493. if (function_->GetReturnType())
  494. {
  495. if (function_->GetReturnType()->type_->asStringType() || function_->GetReturnType()->type_->asStringHashType())
  496. line += ")";
  497. }
  498. line += ");\n";
  499. source += IndentLine(line);
  500. if (function_->GetReturnType() && !CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  501. {
  502. if (function_->GetReturnType()->type_->asClassType())
  503. {
  504. JSBClass* retClass = function_->GetReturnClass();
  505. JSBClass* klass = function_->GetClass();
  506. if (retClass->IsNumberArray())
  507. {
  508. line = ToString("return %s%sReturnValue;", klass->GetName().CString(), function_->GetName().CString());
  509. }
  510. else
  511. {
  512. line = ToString("return retNativeInstance == IntPtr.Zero ? null : NativeCore.WrapNative<%s> (retNativeInstance);", retClass->GetName().CString());
  513. }
  514. source += IndentLine(line);
  515. }
  516. }
  517. source+= "\n";
  518. Dedent();
  519. source += IndentLine("}\n");
  520. }
  521. void CSFunctionWriter::GenerateManagedSource(String& sourceOut)
  522. {
  523. String source = "";
  524. Indent();
  525. Indent();
  526. Indent();
  527. if (function_->GetDocString().Length())
  528. {
  529. // monodocer -assembly:NETCore.dll -path:en -pretty
  530. // mdoc export-html -o htmldocs en
  531. source += IndentLine("/// <summary>\n");
  532. source += IndentLine("/// " + function_->GetDocString() + "\n");
  533. source += IndentLine("/// </summary>\n");
  534. }
  535. if (function_->IsConstructor())
  536. WriteManagedConstructor(source);
  537. else
  538. WriteManagedFunction(source);
  539. WriteManagedPInvokeFunctionSignature(source);
  540. // data marshaller
  541. if (function_->GetReturnType() && !CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  542. {
  543. if (function_->GetReturnClass())
  544. {
  545. JSBClass* retClass = function_->GetReturnClass();
  546. if (retClass->IsNumberArray())
  547. {
  548. JSBClass* klass = function_->GetClass();
  549. String managedType = CSTypeHelper::GetManagedTypeString(function_->GetReturnType());
  550. String marshal = "private " + managedType + " ";
  551. marshal += ToString("%s%sReturnValue = new %s();\n", klass->GetName().CString(), function_->GetName().CString(), managedType.CString());
  552. sourceOut += IndentLine(marshal);
  553. }
  554. }
  555. }
  556. Dedent();
  557. Dedent();
  558. Dedent();
  559. sourceOut += source;
  560. }
  561. void CSFunctionWriter::GenerateSource(String& sourceOut)
  562. {
  563. }
  564. String CSFunctionWriter::MapDefaultParameter(JSBFunctionType* parameter)
  565. {
  566. String init = parameter->initializer_;
  567. if (!init.Length())
  568. return init;
  569. if (parameter->type_->asClassType())
  570. {
  571. if (init == "0")
  572. return "null";
  573. }
  574. if (parameter->type_->asEnumType())
  575. {
  576. return parameter->type_->asEnumType()->enum_->GetName() + "." + init;
  577. }
  578. if (function_->class_->GetPackage()->ContainsConstant(init))
  579. return "Constants." + init;
  580. if (init == "true" || init == "false")
  581. return init;
  582. if (init == "0.0f")
  583. return init;
  584. if (init == "1.0f")
  585. return init;
  586. if (init == "0.1f")
  587. return init;
  588. if (init == "0")
  589. return init;
  590. if (init == "-1")
  591. return init;
  592. if (init == "\"\\t\"")
  593. return init;
  594. if (init == "NULL")
  595. return "null";
  596. if (init == "M_MAX_UNSIGNED")
  597. return "0xffffffff";
  598. if (init == "String::EMPTY")
  599. return "\"\"";
  600. // this kind of sucks, can't define const structs
  601. // and default parameters need to be const :/
  602. DefaultStructParameter dparm;
  603. dparm.parameterName = parameter->name_;
  604. if (init == "Vector3::ZERO")
  605. {
  606. dparm.type = "Vector3";
  607. dparm.assignment = "Vector3.Zero";
  608. defaultStructParameters_.Push(dparm);
  609. return "default(Vector3)";
  610. }
  611. if (init == "Vector3::ONE")
  612. {
  613. dparm.type = "Vector3";
  614. dparm.assignment = "Vector3.One";
  615. defaultStructParameters_.Push(dparm);
  616. return "default(Vector3)";
  617. }
  618. if (init == "Vector3::UP")
  619. {
  620. dparm.type = "Vector3";
  621. dparm.assignment = "Vector3.Up";
  622. defaultStructParameters_.Push(dparm);
  623. return "default(Vector3)";
  624. }
  625. if (init == "IntVector2::ZERO")
  626. {
  627. dparm.type = "IntVector2";
  628. dparm.assignment = "IntVector2.Zero";
  629. defaultStructParameters_.Push(dparm);
  630. return "default(IntVector2)";
  631. }
  632. if (init == "Quaternion::IDENTITY")
  633. {
  634. dparm.type = "Quaternion";
  635. dparm.assignment = "Quaternion.Identity";
  636. defaultStructParameters_.Push(dparm);
  637. return "default(Quaternion)";
  638. }
  639. LOGINFOF("HEY! %s", init.CString());
  640. return String::EMPTY;
  641. }
  642. }