ScriptAPIDump.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "../Core/Context.h"
  23. #include "../IO/File.h"
  24. #include "../IO/FileSystem.h"
  25. #include "../IO/Log.h"
  26. #include "../Script/Script.h"
  27. #include <AngelScript/angelscript.h>
  28. #include "../DebugNew.h"
  29. namespace Urho3D
  30. {
  31. /// %Object property info for scripting API dump.
  32. struct PropertyInfo
  33. {
  34. /// Construct.
  35. PropertyInfo() :
  36. read_(false),
  37. write_(false),
  38. indexed_(false)
  39. {
  40. }
  41. /// Property name.
  42. String name_;
  43. /// Property data type.
  44. String type_;
  45. /// Reading supported flag.
  46. bool read_;
  47. /// Writing supported flag.
  48. bool write_;
  49. /// Indexed flag.
  50. bool indexed_;
  51. };
  52. /// Header information for dumping events.
  53. struct HeaderFile
  54. {
  55. /// Full path to header file.
  56. String fileName;
  57. /// Event section name.
  58. String sectionName;
  59. };
  60. bool CompareHeaderFiles(const HeaderFile& lhs, const HeaderFile& rhs)
  61. {
  62. return lhs.sectionName < rhs.sectionName;
  63. }
  64. void ExtractPropertyInfo(const String& functionName, const String& declaration, Vector<PropertyInfo>& propertyInfos)
  65. {
  66. String propertyName = functionName.Substring(4);
  67. PropertyInfo* info = 0;
  68. for (unsigned k = 0; k < propertyInfos.Size(); ++k)
  69. {
  70. if (propertyInfos[k].name_ == propertyName)
  71. {
  72. info = &propertyInfos[k];
  73. break;
  74. }
  75. }
  76. if (!info)
  77. {
  78. propertyInfos.Resize(propertyInfos.Size() + 1);
  79. info = &propertyInfos.Back();
  80. info->name_ = propertyName;
  81. }
  82. if (functionName.Contains("get_"))
  83. {
  84. info->read_ = true;
  85. // Extract type from the return value
  86. Vector<String> parts = declaration.Split(' ');
  87. if (parts.Size())
  88. {
  89. if (parts[0] != "const")
  90. info->type_ = parts[0];
  91. else if (parts.Size() > 1)
  92. info->type_ = parts[1];
  93. }
  94. // If get method has parameters, it is indexed
  95. if (!declaration.Contains("()"))
  96. {
  97. info->indexed_ = true;
  98. info->type_ += "[]";
  99. }
  100. // Sanitate the reference operator away
  101. info->type_.Replace("&", "");
  102. }
  103. if (functionName.Contains("set_"))
  104. {
  105. info->write_ = true;
  106. if (info->type_.Empty())
  107. {
  108. // Extract type from parameters
  109. unsigned begin = declaration.Find(',');
  110. if (begin == String::NPOS)
  111. begin = declaration.Find('(');
  112. else
  113. info->indexed_ = true;
  114. if (begin != String::NPOS)
  115. {
  116. ++begin;
  117. unsigned end = declaration.Find(')');
  118. if (end != String::NPOS)
  119. {
  120. info->type_ = declaration.Substring(begin, end - begin);
  121. // Sanitate const & reference operator away
  122. info->type_.Replace("const ", "");
  123. info->type_.Replace("&in", "");
  124. info->type_.Replace("&", "");
  125. }
  126. }
  127. }
  128. }
  129. }
  130. bool ComparePropertyStrings(const String& lhs, const String& rhs)
  131. {
  132. int spaceLhs = lhs.Find(' ');
  133. int spaceRhs = rhs.Find(' ');
  134. if (spaceLhs != String::NPOS && spaceRhs != String::NPOS)
  135. return String::Compare(lhs.CString() + spaceLhs, rhs.CString() + spaceRhs, true) < 0;
  136. else
  137. return String::Compare(lhs.CString(), rhs.CString(), true) < 0;
  138. }
  139. bool ComparePropertyInfos(const PropertyInfo& lhs, const PropertyInfo& rhs)
  140. {
  141. return String::Compare(lhs.name_.CString(), rhs.name_.CString(), true) < 0;
  142. }
  143. void Script::OutputAPIRow(DumpMode mode, const String& row, bool removeReference, String separator)
  144. {
  145. String out(row);
  146. ///\todo We need C++11 <regex> in String class to handle REGEX whole-word replacement correctly. Can't do that since we still support VS2008.
  147. // Commenting out to temporary fix property name like 'doubleClickInterval' from being wrongly replaced.
  148. // Fortunately, there is no occurence of type 'double' in the API at the moment.
  149. //out.Replace("double", "float"); // s/\bdouble\b/float/g
  150. out.Replace("&in", "&");
  151. out.Replace("&out", "&");
  152. if (removeReference)
  153. out.Replace("&", "");
  154. if (mode == DOXYGEN)
  155. Log::WriteRaw("- " + out + "\n");
  156. else if (mode == C_HEADER)
  157. {
  158. out.Replace("@", "");
  159. out.Replace("?&", "void*");
  160. // s/(\w+)\[\]/Array<\1>/g
  161. unsigned posBegin = String::NPOS;
  162. while (1) // Loop to cater for array of array of T
  163. {
  164. unsigned posEnd = out.Find("[]");
  165. if (posEnd == String::NPOS)
  166. break;
  167. if (posBegin > posEnd)
  168. posBegin = posEnd - 1;
  169. while (posBegin < posEnd && isalnum(out[posBegin]))
  170. --posBegin;
  171. ++posBegin;
  172. out.Replace(posBegin, posEnd - posBegin + 2, "Array<" + out.Substring(posBegin, posEnd - posBegin) + ">");
  173. }
  174. Log::WriteRaw(out + separator + "\n");
  175. }
  176. }
  177. void Script::DumpAPI(DumpMode mode, const String& sourceTree)
  178. {
  179. // Does not use LOGRAW macro here to ensure the messages are always dumped regardless of URHO3D_LOGGING compiler directive
  180. // and of Log subsystem availability
  181. // Dump event descriptions and attribute definitions in Doxygen mode. For events, this means going through the header files,
  182. // as the information is not available otherwise.
  183. /// \todo Dump events + attributes before the actual script API because the remarks (readonly / writeonly) seem to throw off
  184. // Doxygen parsing and the following page definition(s) may not be properly recognized
  185. if (mode == DOXYGEN)
  186. {
  187. Log::WriteRaw("namespace Urho3D\n{\n\n/**\n");
  188. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  189. Vector<String> headerFileNames;
  190. String path = AddTrailingSlash(sourceTree);
  191. if (!path.Empty())
  192. path.Append("Source/Urho3D/");
  193. fileSystem->ScanDir(headerFileNames, path, "*.h", SCAN_FILES, true);
  194. /// \hack Rename any Events2D to 2DEvents to work with the event category creation correctly (currently PhysicsEvents2D)
  195. Vector<HeaderFile> headerFiles;
  196. for (unsigned i = 0; i < headerFileNames.Size(); ++i)
  197. {
  198. HeaderFile entry;
  199. entry.fileName = headerFileNames[i];
  200. entry.sectionName = GetFileNameAndExtension(entry.fileName).Replaced("Events2D", "2DEvents");
  201. if (entry.sectionName.EndsWith("Events.h"))
  202. headerFiles.Push(entry);
  203. }
  204. if (!headerFiles.Empty())
  205. {
  206. Log::WriteRaw("\n\\page EventList Event list\n");
  207. Sort(headerFiles.Begin(), headerFiles.End(), CompareHeaderFiles);
  208. for (unsigned i = 0; i < headerFiles.Size(); ++i)
  209. {
  210. SharedPtr<File> file(new File(context_, path + headerFiles[i].fileName, FILE_READ));
  211. if (!file->IsOpen())
  212. continue;
  213. const String& sectionName = headerFiles[i].sectionName;
  214. unsigned start = sectionName.Find('/') + 1;
  215. unsigned end = sectionName.Find("Events.h");
  216. Log::WriteRaw("\n## %" + sectionName.Substring(start, end - start) + " events\n");
  217. while (!file->IsEof())
  218. {
  219. String line = file->ReadLine();
  220. if (line.StartsWith("EVENT"))
  221. {
  222. Vector<String> parts = line.Split(',');
  223. if (parts.Size() == 2)
  224. Log::WriteRaw("\n### " + parts[1].Substring(0, parts[1].Length() - 1).Trimmed() + "\n");
  225. }
  226. if (line.Contains("PARAM"))
  227. {
  228. Vector<String> parts = line.Split(',');
  229. if (parts.Size() == 2)
  230. {
  231. String paramName = parts[1].Substring(0, parts[1].Find(')')).Trimmed();
  232. String paramType = parts[1].Substring(parts[1].Find("// ") + 3);
  233. if (!paramName.Empty() && !paramType.Empty())
  234. Log::WriteRaw("- %" + paramName + " : " + paramType + "\n");
  235. }
  236. }
  237. }
  238. }
  239. Log::WriteRaw("\n");
  240. }
  241. Log::WriteRaw("\n\\page AttributeList Attribute list\n");
  242. const HashMap<StringHash, Vector<AttributeInfo> >& attributes = context_->GetAllAttributes();
  243. Vector<String> objectTypes;
  244. for (HashMap<StringHash, Vector<AttributeInfo> >::ConstIterator i = attributes.Begin(); i != attributes.End();
  245. ++i)
  246. objectTypes.Push(context_->GetTypeName(i->first_));
  247. Sort(objectTypes.Begin(), objectTypes.End());
  248. for (unsigned i = 0; i < objectTypes.Size(); ++i)
  249. {
  250. const Vector<AttributeInfo>& attrs = attributes.Find(objectTypes[i])->second_;
  251. unsigned usableAttrs = 0;
  252. for (unsigned j = 0; j < attrs.Size(); ++j)
  253. {
  254. // Attributes that are not shown in the editor are typically internal and not usable for eg. attribute
  255. // animation
  256. if (attrs[j].mode_ & AM_NOEDIT)
  257. continue;
  258. ++usableAttrs;
  259. }
  260. if (!usableAttrs)
  261. continue;
  262. Log::WriteRaw("\n### " + objectTypes[i] + "\n");
  263. for (unsigned j = 0; j < attrs.Size(); ++j)
  264. {
  265. if (attrs[j].mode_ & AM_NOEDIT)
  266. continue;
  267. // Prepend each word in the attribute name with % to prevent unintended links
  268. Vector<String> nameParts = attrs[j].name_.Split(' ');
  269. for (unsigned k = 0; k < nameParts.Size(); ++k)
  270. {
  271. if (nameParts[k].Length() > 1 && IsAlpha(nameParts[k][0]))
  272. nameParts[k] = "%" + nameParts[k];
  273. }
  274. String name;
  275. name.Join(nameParts, " ");
  276. String type = Variant::GetTypeName(attrs[j].type_);
  277. // Variant typenames are all uppercase. Convert primitive types to the proper lowercase form for the documentation
  278. if (type == "Int" || type == "Bool" || type == "Float")
  279. type[0] = ToLower(type[0]);
  280. Log::WriteRaw("- " + name + " : " + type + "\n");
  281. }
  282. }
  283. Log::WriteRaw("\n");
  284. }
  285. if (mode == DOXYGEN)
  286. Log::WriteRaw("\n\\page ScriptAPI Scripting API\n\n");
  287. else if (mode == C_HEADER)
  288. Log::WriteRaw("// Script API header intended to be 'force included' in IDE for AngelScript content assist / code completion\n\n"
  289. "#define int8 signed char\n"
  290. "#define int16 signed short\n"
  291. "#define int64 long\n"
  292. "#define uint8 unsigned char\n"
  293. "#define uint16 unsigned short\n"
  294. "#define uint64 unsigned long\n"
  295. "#define null 0\n");
  296. unsigned types = scriptEngine_->GetObjectTypeCount();
  297. Vector<Pair<String, unsigned> > sortedTypes;
  298. for (unsigned i = 0; i < types; ++i)
  299. {
  300. asIObjectType* type = scriptEngine_->GetObjectTypeByIndex(i);
  301. if (type)
  302. {
  303. String typeName(type->GetName());
  304. sortedTypes.Push(MakePair(typeName, i));
  305. }
  306. }
  307. Sort(sortedTypes.Begin(), sortedTypes.End());
  308. if (mode == DOXYGEN)
  309. {
  310. Log::WriteRaw("\\section ScriptAPI_TableOfContents Table of contents\n"
  311. "\\ref ScriptAPI_ClassList \"Class list\"<br>\n"
  312. "\\ref ScriptAPI_Classes \"Classes\"<br>\n"
  313. "\\ref ScriptAPI_Enums \"Enumerations\"<br>\n"
  314. "\\ref ScriptAPI_GlobalFunctions \"Global functions\"<br>\n"
  315. "\\ref ScriptAPI_GlobalProperties \"Global properties\"<br>\n"
  316. "\\ref ScriptAPI_GlobalConstants \"Global constants\"<br>\n\n");
  317. Log::WriteRaw("\\section ScriptAPI_ClassList Class list\n\n");
  318. for (unsigned i = 0; i < sortedTypes.Size(); ++i)
  319. {
  320. asIObjectType* type = scriptEngine_->GetObjectTypeByIndex(sortedTypes[i].second_);
  321. if (type)
  322. {
  323. String typeName(type->GetName());
  324. Log::WriteRaw("<a href=\"#Class_" + typeName + "\"><b>" + typeName + "</b></a>\n");
  325. }
  326. }
  327. Log::WriteRaw("\n\\section ScriptAPI_Classes Classes\n");
  328. }
  329. else if (mode == C_HEADER)
  330. Log::WriteRaw("\n// Classes\n");
  331. for (unsigned i = 0; i < sortedTypes.Size(); ++i)
  332. {
  333. asIObjectType* type = scriptEngine_->GetObjectTypeByIndex(sortedTypes[i].second_);
  334. if (type)
  335. {
  336. String typeName(type->GetName());
  337. Vector<String> methodDeclarations;
  338. Vector<PropertyInfo> propertyInfos;
  339. if (mode == DOXYGEN)
  340. {
  341. Log::WriteRaw("<a name=\"Class_" + typeName + "\"></a>\n");
  342. Log::WriteRaw("\n### " + typeName + "\n");
  343. }
  344. else if (mode == C_HEADER)
  345. {
  346. ///\todo Find a cleaner way to do this instead of hardcoding
  347. if (typeName == "Array")
  348. Log::WriteRaw("\ntemplate <class T> class " + typeName + "\n{\n");
  349. else
  350. Log::WriteRaw("\nclass " + typeName + "\n{\n");
  351. }
  352. unsigned methods = type->GetMethodCount();
  353. for (unsigned j = 0; j < methods; ++j)
  354. {
  355. asIScriptFunction* method = type->GetMethodByIndex(j);
  356. String methodName(method->GetName());
  357. String declaration(method->GetDeclaration());
  358. // Recreate tab escape sequences
  359. declaration.Replace("\t", "\\t");
  360. if (methodName.Contains("get_") || methodName.Contains("set_"))
  361. ExtractPropertyInfo(methodName, declaration, propertyInfos);
  362. else
  363. {
  364. // Sanitate the method name. \todo For now, skip the operators
  365. if (!declaration.Contains("::op"))
  366. {
  367. String prefix(typeName + "::");
  368. declaration.Replace(prefix, "");
  369. ///\todo Is there a better way to mark deprecated API bindings for AngelScript?
  370. unsigned posBegin = declaration.FindLast("const String&in = \"deprecated:");
  371. if (posBegin != String::NPOS)
  372. {
  373. // Assume this 'mark' is added as the last parameter
  374. unsigned posEnd = declaration.Find(')', posBegin);
  375. if (posBegin != String::NPOS)
  376. {
  377. declaration.Replace(posBegin, posEnd - posBegin, "");
  378. posBegin = declaration.Find(", ", posBegin - 2);
  379. if (posBegin != String::NPOS)
  380. declaration.Replace(posBegin, 2, "");
  381. if (mode == DOXYGEN)
  382. declaration += " // deprecated";
  383. else if (mode == C_HEADER)
  384. declaration = "/* deprecated */\n" + declaration;
  385. }
  386. }
  387. methodDeclarations.Push(declaration);
  388. }
  389. }
  390. }
  391. // Assume that the same property is never both an accessor property, and a direct one
  392. unsigned properties = type->GetPropertyCount();
  393. for (unsigned j = 0; j < properties; ++j)
  394. {
  395. const char* propertyName;
  396. const char* propertyDeclaration;
  397. int typeId;
  398. type->GetProperty(j, &propertyName, &typeId);
  399. propertyDeclaration = scriptEngine_->GetTypeDeclaration(typeId);
  400. PropertyInfo newInfo;
  401. newInfo.name_ = String(propertyName);
  402. newInfo.type_ = String(propertyDeclaration);
  403. newInfo.read_ = newInfo.write_ = true;
  404. propertyInfos.Push(newInfo);
  405. }
  406. Sort(methodDeclarations.Begin(), methodDeclarations.End(), ComparePropertyStrings);
  407. Sort(propertyInfos.Begin(), propertyInfos.End(), ComparePropertyInfos);
  408. if (!methodDeclarations.Empty())
  409. {
  410. if (mode == DOXYGEN)
  411. Log::WriteRaw("\nMethods:\n\n");
  412. else if (mode == C_HEADER)
  413. Log::WriteRaw("// Methods:\n");
  414. for (unsigned j = 0; j < methodDeclarations.Size(); ++j)
  415. OutputAPIRow(mode, methodDeclarations[j]);
  416. }
  417. if (!propertyInfos.Empty())
  418. {
  419. if (mode == DOXYGEN)
  420. Log::WriteRaw("\nProperties:\n\n");
  421. else if (mode == C_HEADER)
  422. Log::WriteRaw("\n// Properties:\n");
  423. for (unsigned j = 0; j < propertyInfos.Size(); ++j)
  424. {
  425. String remark;
  426. String cppdoc;
  427. if (!propertyInfos[j].write_)
  428. remark = "readonly";
  429. else if (!propertyInfos[j].read_)
  430. remark = "writeonly";
  431. if (!remark.Empty())
  432. {
  433. if (mode == DOXYGEN)
  434. {
  435. remark = " // " + remark;
  436. }
  437. else if (mode == C_HEADER)
  438. {
  439. cppdoc = "/* " + remark + " */\n";
  440. remark.Clear();
  441. }
  442. }
  443. OutputAPIRow(mode, cppdoc + propertyInfos[j].type_ + " " + propertyInfos[j].name_ + remark);
  444. }
  445. }
  446. if (mode == DOXYGEN)
  447. Log::WriteRaw("\n");
  448. else if (mode == C_HEADER)
  449. Log::WriteRaw("};\n");
  450. }
  451. }
  452. Vector<PropertyInfo> globalPropertyInfos;
  453. Vector<String> globalFunctions;
  454. unsigned functions = scriptEngine_->GetGlobalFunctionCount();
  455. for (unsigned i = 0; i < functions; ++i)
  456. {
  457. asIScriptFunction* function = scriptEngine_->GetGlobalFunctionByIndex(i);
  458. String functionName(function->GetName());
  459. String declaration(function->GetDeclaration());
  460. // Recreate tab escape sequences
  461. declaration.Replace("\t", "\\t");
  462. if (functionName.Contains("set_") || functionName.Contains("get_"))
  463. ExtractPropertyInfo(functionName, declaration, globalPropertyInfos);
  464. else
  465. globalFunctions.Push(declaration);
  466. }
  467. Sort(globalFunctions.Begin(), globalFunctions.End(), ComparePropertyStrings);
  468. Sort(globalPropertyInfos.Begin(), globalPropertyInfos.End(), ComparePropertyInfos);
  469. if (mode == DOXYGEN)
  470. Log::WriteRaw("\\section ScriptAPI_Enums Enumerations\n");
  471. else if (mode == C_HEADER)
  472. Log::WriteRaw("\n// Enumerations\n");
  473. unsigned enums = scriptEngine_->GetEnumCount();
  474. Vector<Pair<String, unsigned> > sortedEnums;
  475. for (unsigned i = 0; i < enums; ++i)
  476. {
  477. int typeId;
  478. sortedEnums.Push(MakePair(String(scriptEngine_->GetEnumByIndex(i, &typeId)), i));
  479. }
  480. Sort(sortedEnums.Begin(), sortedEnums.End());
  481. for (unsigned i = 0; i < sortedEnums.Size(); ++i)
  482. {
  483. int typeId = 0;
  484. if (mode == DOXYGEN)
  485. Log::WriteRaw("\n### " + String(scriptEngine_->GetEnumByIndex(sortedEnums[i].second_, &typeId)) + "\n\n");
  486. else if (mode == C_HEADER)
  487. Log::WriteRaw("\nenum " + String(scriptEngine_->GetEnumByIndex(sortedEnums[i].second_, &typeId)) + "\n{\n");
  488. for (unsigned j = 0; j < (unsigned)scriptEngine_->GetEnumValueCount(typeId); ++j)
  489. {
  490. int value = 0;
  491. const char* name = scriptEngine_->GetEnumValueByIndex(typeId, j, &value);
  492. OutputAPIRow(mode, String(name), false, ",");
  493. }
  494. if (mode == DOXYGEN)
  495. Log::WriteRaw("\n");
  496. else if (mode == C_HEADER)
  497. Log::WriteRaw("};\n");
  498. }
  499. if (mode == DOXYGEN)
  500. Log::WriteRaw("\\section ScriptAPI_GlobalFunctions Global functions\n");
  501. else if (mode == C_HEADER)
  502. Log::WriteRaw("\n// Global functions\n");
  503. for (unsigned i = 0; i < globalFunctions.Size(); ++i)
  504. OutputAPIRow(mode, globalFunctions[i]);
  505. if (mode == DOXYGEN)
  506. Log::WriteRaw("\\section ScriptAPI_GlobalProperties Global properties\n");
  507. else if (mode == C_HEADER)
  508. Log::WriteRaw("\n// Global properties\n");
  509. for (unsigned i = 0; i < globalPropertyInfos.Size(); ++i)
  510. OutputAPIRow(mode, globalPropertyInfos[i].type_ + " " + globalPropertyInfos[i].name_, true);
  511. if (mode == DOXYGEN)
  512. Log::WriteRaw("\\section ScriptAPI_GlobalConstants Global constants\n");
  513. else if (mode == C_HEADER)
  514. Log::WriteRaw("\n// Global constants\n");
  515. Vector<String> globalConstants;
  516. unsigned properties = scriptEngine_->GetGlobalPropertyCount();
  517. for (unsigned i = 0; i < properties; ++i)
  518. {
  519. const char* propertyName;
  520. const char* propertyDeclaration;
  521. int typeId;
  522. scriptEngine_->GetGlobalPropertyByIndex(i, &propertyName, 0, &typeId);
  523. propertyDeclaration = scriptEngine_->GetTypeDeclaration(typeId);
  524. String type(propertyDeclaration);
  525. globalConstants.Push(type + " " + String(propertyName));
  526. }
  527. Sort(globalConstants.Begin(), globalConstants.End(), ComparePropertyStrings);
  528. for (unsigned i = 0; i < globalConstants.Size(); ++i)
  529. OutputAPIRow(mode, globalConstants[i], true);
  530. if (mode == DOXYGEN)
  531. Log::WriteRaw("*/\n\n}\n");
  532. }
  533. }