CSFunctionWriter.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  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(AtomicSharp::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(AtomicSharp::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::GenNativeFunctionSignature(String& sig)
  118. {
  119. JSBClass* klass = function_->GetClass();
  120. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  121. Vector<String> args;
  122. if (!function_->IsConstructor())
  123. {
  124. args.Push(ToString("%s* self", klass->GetNativeName().CString()));
  125. }
  126. if (parameters.Size())
  127. {
  128. for (unsigned int i = 0; i < parameters.Size(); i++)
  129. {
  130. JSBFunctionType* ptype = parameters.At(i);
  131. // ignore "Context" parameters
  132. if (ptype->type_->asClassType())
  133. {
  134. JSBClassType* classType = ptype->type_->asClassType();
  135. JSBClass* klass = classType->class_;
  136. if (klass->GetName() == "Context")
  137. {
  138. continue;
  139. }
  140. args.Push(ToString("%s* %s", klass->GetNativeName().CString(), ptype->name_.CString()));
  141. }
  142. else
  143. {
  144. args.Push(CSTypeHelper::GetNativeTypeString(ptype) + " " + ptype->name_);
  145. }
  146. }
  147. }
  148. if (function_->GetReturnClass() && function_->GetReturnClass()->IsNumberArray())
  149. {
  150. args.Push(ToString("%s* returnValue", function_->GetReturnClass()->GetNativeName().CString()));
  151. }
  152. sig.Join(args, ", ");
  153. }
  154. void CSFunctionWriter::WriteNativeFunction(String& source)
  155. {
  156. JSBClass* klass = function_->GetClass();
  157. JSBPackage* package = klass->GetPackage();
  158. String fname = function_->IsConstructor() ? "Constructor" : function_->GetName();
  159. String returnType = "void";
  160. bool simpleReturn = true;
  161. if (function_->IsConstructor())
  162. {
  163. returnType = "RefCounted*";
  164. }
  165. else if (function_->GetReturnType())
  166. {
  167. if (function_->IsConstructor())
  168. {
  169. returnType = ToString("%s*", klass->GetNativeName().CString());
  170. }
  171. else if (function_->GetReturnClass())
  172. {
  173. if (!function_->GetReturnClass()->IsNumberArray())
  174. {
  175. returnType = ToString("const %s*", function_->GetReturnClass()->GetNativeName().CString());
  176. }
  177. }
  178. else if (function_->GetReturnType()->type_->asStringHashType())
  179. {
  180. returnType = "unsigned";
  181. }
  182. else
  183. {
  184. returnType = ToString("%s", CSTypeHelper::GetNativeTypeString(function_->GetReturnType()).CString());
  185. }
  186. }
  187. String line;
  188. String sig;
  189. GenNativeFunctionSignature(sig);
  190. line = ToString("ATOMIC_EXPORT_API %s csb_%s_%s_%s(%s)\n",
  191. returnType.CString(), package->GetName().CString(), klass->GetName().CString(),
  192. fname.CString(), sig.CString());
  193. source += IndentLine(line);
  194. source += IndentLine("{\n");
  195. Indent();
  196. bool returnValue = false;
  197. bool sharedPtrReturn = false;
  198. String returnStatement;
  199. if (returnType == "const char*")
  200. {
  201. returnValue = true;
  202. source += IndentLine("static String returnValue;\n");
  203. returnStatement = "returnValue = ";
  204. }
  205. else if (function_->GetReturnClass() && function_->GetReturnClass()->IsNumberArray())
  206. {
  207. returnStatement = "*returnValue = ";
  208. }
  209. else if (function_->GetReturnClass() && function_->GetReturnType()->isSharedPtr_)
  210. {
  211. returnStatement = ToString("SharedPtr<%s> returnValue = ", function_->GetReturnClass()->GetNativeName().CString());
  212. sharedPtrReturn = true;
  213. }
  214. else
  215. {
  216. if (returnType != "void")
  217. {
  218. if (simpleReturn)
  219. returnStatement = "return ";
  220. }
  221. }
  222. String callSig;
  223. GenNativeCallParameters(callSig);
  224. if (!function_->isConstructor_)
  225. line = ToString("%sself->%s(%s);\n", returnStatement.CString(), function_->GetName().CString(), callSig.CString());
  226. else
  227. {
  228. if (klass->IsAbstract())
  229. {
  230. line = "return 0; // Abstract Class\n";
  231. }
  232. else if (klass->IsObject())
  233. {
  234. if (callSig.Length())
  235. line = ToString("return new %s(AtomicSharp::GetContext(), %s);\n", klass->GetNativeName().CString(), callSig.CString());
  236. else
  237. line = ToString("return new %s(AtomicSharp::GetContext());\n", klass->GetNativeName().CString());
  238. }
  239. else
  240. {
  241. line = ToString("return new %s(%s);\n", klass->GetNativeName().CString(), callSig.CString());
  242. }
  243. }
  244. source += IndentLine(line);
  245. if (sharedPtrReturn)
  246. {
  247. source += IndentLine("returnValue->AddRef();\n");
  248. source += IndentLine("return returnValue;\n");
  249. }
  250. else if (returnType == "const char*")
  251. {
  252. source += IndentLine("return returnValue.CString();\n");
  253. }
  254. Dedent();
  255. source += IndentLine("}\n");
  256. source += "\n";
  257. }
  258. void CSFunctionWriter::GenerateNativeSource(String& sourceOut)
  259. {
  260. String source = "";
  261. WriteNativeFunction(source);
  262. sourceOut += source;
  263. }
  264. // MANAGED----------------------------------------------------------------------------------------
  265. void CSFunctionWriter::WriteDefaultStructParameters(String& source)
  266. {
  267. for (unsigned i = 0; i < defaultStructParameters_.Size(); i++)
  268. {
  269. const DefaultStructParameter& dparm = defaultStructParameters_[i];
  270. String line = ToString("if (default(%s).Equals(%s)) %s = %s;\n",
  271. dparm.type.CString(), dparm.parameterName.CString(), dparm.parameterName.CString(),
  272. dparm.assignment.CString());
  273. source += IndentLine(line);
  274. }
  275. }
  276. void CSFunctionWriter::WriteManagedPInvokeFunctionSignature(String& source)
  277. {
  278. source += "\n";
  279. String line = "[DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]\n";
  280. source += IndentLine(line);
  281. JSBClass* klass = function_->GetClass();
  282. JSBPackage* package = klass->GetPackage();
  283. String returnType = CSTypeHelper::GetPInvokeTypeString(function_->GetReturnType());
  284. if (returnType == "string")
  285. returnType = "IntPtr";
  286. if (function_->IsConstructor())
  287. returnType = "IntPtr";
  288. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  289. Vector<String> args;
  290. if (!function_->IsConstructor())
  291. {
  292. args.Push("IntPtr self");
  293. }
  294. if (parameters.Size())
  295. {
  296. for (unsigned int i = 0; i < parameters.Size(); i++)
  297. {
  298. JSBFunctionType* ptype = parameters.At(i);
  299. String name = ptype->name_;
  300. if (name == "object")
  301. name = "_object";
  302. // ignore "Context" parameters
  303. if (ptype->type_->asClassType())
  304. {
  305. JSBClassType* classType = ptype->type_->asClassType();
  306. JSBClass* klass = classType->class_;
  307. if (klass->GetName() == "Context")
  308. {
  309. continue;
  310. }
  311. if (klass->IsNumberArray())
  312. {
  313. args.Push("ref " + klass->GetName() + " " + name);
  314. }
  315. else
  316. {
  317. args.Push("IntPtr " + name);
  318. }
  319. }
  320. else
  321. {
  322. args.Push(CSTypeHelper::GetPInvokeTypeString(ptype) + " " + name);
  323. }
  324. }
  325. }
  326. if (function_->GetReturnClass())
  327. {
  328. JSBClass* retClass = function_->GetReturnClass();
  329. if (retClass->IsNumberArray())
  330. {
  331. args.Push("ref " + retClass->GetName() + " retValue");
  332. }
  333. }
  334. String pstring;
  335. pstring.Join(args, ", ");
  336. String fname = function_->IsConstructor() ? "Constructor" : function_->GetName();
  337. line = ToString("private static extern %s csb_%s_%s_%s(%s);\n",
  338. returnType.CString(), package->GetName().CString(), klass->GetName().CString(),
  339. fname.CString(), pstring.CString());
  340. source += IndentLine(line);
  341. source += "\n";
  342. }
  343. void CSFunctionWriter::GenManagedFunctionParameters(String& sig)
  344. {
  345. // generate args
  346. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  347. if (parameters.Size())
  348. {
  349. for (unsigned int i = 0; i < parameters.Size(); i++)
  350. {
  351. JSBFunctionType* ptype = parameters.At(i);
  352. // ignore "Context" parameters
  353. if (ptype->type_->asClassType())
  354. {
  355. JSBClassType* classType = ptype->type_->asClassType();
  356. JSBClass* klass = classType->class_;
  357. if (klass->GetName() == "Context")
  358. {
  359. continue;
  360. }
  361. }
  362. sig += CSTypeHelper::GetManagedTypeString(ptype);
  363. String init = ptype->initializer_;
  364. if (init.Length())
  365. {
  366. init = MapDefaultParameter(ptype);
  367. if (init.Length())
  368. sig += " = " + init;
  369. }
  370. if (i + 1 != parameters.Size())
  371. sig += ", ";
  372. }
  373. }
  374. }
  375. void CSFunctionWriter::WriteManagedConstructor(String& source)
  376. {
  377. JSBClass* klass = function_->GetClass();
  378. JSBPackage* package = klass->GetPackage();
  379. if (klass->GetName() == "RefCounted")
  380. return;
  381. // wrapping constructor
  382. String line;
  383. line = ToString("public %s (IntPtr native) : base (native)\n", klass->GetName().CString());
  384. source += IndentLine(line);
  385. source += IndentLine("{\n");
  386. source += IndentLine("}\n\n");
  387. String sig;
  388. GenManagedFunctionParameters(sig);
  389. line = ToString("public %s (%s)\n", klass->GetName().CString(), sig.CString());
  390. source += IndentLine(line);
  391. source += IndentLine("{\n");
  392. Indent();
  393. WriteDefaultStructParameters(source);
  394. line = ToString("if (typeof(%s) == this.GetType()", klass->GetName().CString());
  395. line += ToString(" || (this.GetType().BaseType == typeof(%s) && !NativeCore.GetNativeType(this.GetType())))\n", klass->GetName().CString());
  396. source += IndentLine(line);
  397. source += IndentLine("{\n");
  398. Indent();
  399. String callSig;
  400. GenPInvokeCallParameters(callSig);
  401. line = ToString("nativeInstance = NativeCore.RegisterNative (csb_%s_%s_Constructor(%s), this);\n",
  402. package->GetName().CString(), klass->GetName().CString(), callSig.CString());
  403. source += IndentLine(line);
  404. Dedent();
  405. source += IndentLine("}\n");
  406. Dedent();
  407. source += IndentLine("}\n");
  408. }
  409. void CSFunctionWriter::GenPInvokeCallParameters(String& sig)
  410. {
  411. // generate args
  412. Vector<JSBFunctionType*>& parameters = function_->GetParameters();
  413. if (parameters.Size())
  414. {
  415. for (unsigned int i = 0; i < parameters.Size(); i++)
  416. {
  417. JSBFunctionType* ptype = parameters.At(i);
  418. // ignore "Context" parameters
  419. if (ptype->type_->asClassType())
  420. {
  421. JSBClassType* classType = ptype->type_->asClassType();
  422. JSBClass* klass = classType->class_;
  423. if (klass->GetName() == "Context")
  424. {
  425. continue;
  426. }
  427. }
  428. String name = ptype->name_;
  429. if (name == "object")
  430. name = "_object";
  431. if (ptype->type_->asClassType())
  432. {
  433. JSBClass* pclass = ptype->type_->asClassType()->class_;
  434. if (pclass->IsNumberArray())
  435. {
  436. sig += "ref " + name;
  437. }
  438. else
  439. {
  440. sig += name + " == null ? IntPtr.Zero : " + name + ".nativeInstance";
  441. }
  442. }
  443. else
  444. {
  445. sig += name;
  446. }
  447. if (i + 1 != parameters.Size())
  448. sig += ", ";
  449. }
  450. }
  451. // data marshaller
  452. if (function_->GetReturnType() && !CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  453. {
  454. if (function_->GetReturnClass()->IsNumberArray())
  455. {
  456. if (sig.Length())
  457. sig += ", ";
  458. JSBClass* klass = function_->GetClass();
  459. sig += ToString("ref %s%sReturnValue", klass->GetName().CString(), function_->GetName().CString());
  460. }
  461. }
  462. }
  463. void CSFunctionWriter::WriteManagedFunction(String& source)
  464. {
  465. JSBClass* klass = function_->GetClass();
  466. JSBPackage* package = klass->GetPackage();
  467. String sig;
  468. String returnType = CSTypeHelper::GetManagedTypeString(function_->GetReturnType());
  469. GenManagedFunctionParameters(sig);
  470. String line = ToString("public %s %s (%s)\n", returnType.CString(), function_->GetName().CString(), sig.CString());
  471. source += IndentLine(line);
  472. source += IndentLine("{\n");
  473. Indent();
  474. WriteDefaultStructParameters(source);
  475. line.Clear();
  476. if (function_->GetReturnType())
  477. {
  478. if (function_->GetReturnType()->type_->asStringType() || function_->GetReturnType()->type_->asStringHashType())
  479. {
  480. line += "return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(";
  481. }
  482. else if (CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  483. line += "return ";
  484. else
  485. {
  486. if (function_->GetReturnClass())
  487. {
  488. if (!function_->GetReturnClass()->IsNumberArray())
  489. line += "IntPtr retNativeInstance = ";
  490. }
  491. }
  492. }
  493. String callSig;
  494. GenPInvokeCallParameters(callSig);
  495. line += ToString("csb_%s_%s_%s(nativeInstance",
  496. package->GetName().CString(), klass->GetName().CString(), function_->GetName().CString());
  497. if (callSig.Length())
  498. {
  499. line += ", " + callSig;
  500. }
  501. if (function_->GetReturnType())
  502. {
  503. if (function_->GetReturnType()->type_->asStringType() || function_->GetReturnType()->type_->asStringHashType())
  504. line += ")";
  505. }
  506. line += ");\n";
  507. source += IndentLine(line);
  508. if (function_->GetReturnType() && !CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
  509. {
  510. if (function_->GetReturnType()->type_->asClassType())
  511. {
  512. JSBClass* retClass = function_->GetReturnClass();
  513. JSBClass* klass = function_->GetClass();
  514. if (retClass->IsNumberArray())
  515. {
  516. line = ToString("return %s%sReturnValue;", klass->GetName().CString(), function_->GetName().CString());
  517. }
  518. else
  519. {
  520. line = ToString("return retNativeInstance == IntPtr.Zero ? null : NativeCore.WrapNative<%s> (retNativeInstance);", retClass->GetName().CString());
  521. }
  522. source += IndentLine(line);
  523. }
  524. }
  525. source+= "\n";
  526. Dedent();
  527. source += IndentLine("}\n");
  528. }
  529. void CSFunctionWriter::GenerateManagedSource(String& sourceOut)
  530. {
  531. String source = "";
  532. Indent();
  533. Indent();
  534. Indent();
  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. return "Quaternion.Identity";
  634. LOGINFOF("HEY! %s", init.CString());
  635. return String::EMPTY;
  636. }
  637. }