JSBModule.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  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 <Atomic/IO/Log.h>
  23. #include <Atomic/IO/File.h>
  24. #include <Atomic/IO/FileSystem.h>
  25. #include <Atomic/Resource/JSONFile.h>
  26. #include "Atomic/Core/ProcessUtils.h"
  27. #include "JSBind.h"
  28. #include "JSBPackage.h"
  29. #include "JSBModule.h"
  30. #include "JSBHeader.h"
  31. #include "JSBClass.h"
  32. #include "JSBEnum.h"
  33. #include "JSBModuleWriter.h"
  34. #include "JSBType.h"
  35. #include "JSBEvent.h"
  36. #include "JavaScript/JSModuleWriter.h"
  37. #include "CSharp/CSModuleWriter.h"
  38. namespace ToolCore
  39. {
  40. JSBModule::JSBModule(Context* context, JSBPackage* package) : Object(context),
  41. package_(package),
  42. dotNetModule_(false)
  43. {
  44. }
  45. JSBModule::~JSBModule()
  46. {
  47. }
  48. Vector<SharedPtr<JSBClass>> JSBModule::GetClasses(bool includeInterfaces)
  49. {
  50. if (includeInterfaces)
  51. return classes_.Values();
  52. Vector<SharedPtr<JSBClass>> retValue;
  53. Vector<SharedPtr<JSBClass>> classes = classes_.Values();
  54. for (unsigned i = 0; i < classes.Size(); i++)
  55. if (!classes[i]->IsInterface())
  56. retValue.Push(classes[i]);
  57. return retValue;
  58. }
  59. Vector<SharedPtr<JSBEnum>> JSBModule::GetEnums()
  60. {
  61. return enums_.Values();
  62. }
  63. void JSBModule::PreprocessHeaders()
  64. {
  65. for (unsigned i = 0; i < headers_.Size(); i++)
  66. {
  67. headers_[i]->VisitPreprocess();
  68. }
  69. }
  70. void JSBModule::VisitHeaders()
  71. {
  72. for (unsigned i = 0; i < headers_.Size(); i++)
  73. {
  74. headers_[i]->VisitHeader();
  75. }
  76. // validate that all classes found
  77. for (unsigned i = 0; i < classnames_.Size(); i++)
  78. {
  79. JSBClass* cls = GetClass(classnames_[i]);
  80. if (!cls)
  81. {
  82. ErrorExit(ToString("Module class not found %s", classnames_[i].CString()));
  83. }
  84. }
  85. ProcessOverloads();
  86. ProcessExcludes();
  87. ProcessClassExcludes();
  88. ProcessTypeScriptDecl();
  89. ProcessHaxeDecl();
  90. ProcessCSharpDecl();
  91. }
  92. void JSBModule::PreprocessClasses()
  93. {
  94. HashMap<StringHash, SharedPtr<JSBClass> >::Iterator itr;
  95. for (itr = classes_.Begin(); itr != classes_.End(); itr++)
  96. {
  97. itr->second_->Preprocess();
  98. }
  99. }
  100. void JSBModule::ProcessClasses()
  101. {
  102. HashMap<StringHash, SharedPtr<JSBClass> >::Iterator itr;
  103. for (itr = classes_.Begin(); itr != classes_.End(); itr++)
  104. {
  105. itr->second_->Process();
  106. }
  107. }
  108. void JSBModule::PostProcessClasses()
  109. {
  110. HashMap<StringHash, SharedPtr<JSBClass> >::Iterator itr;
  111. for (itr = classes_.Begin(); itr != classes_.End(); itr++)
  112. {
  113. itr->second_->PostProcess();
  114. }
  115. }
  116. void JSBModule::ProcessOverloads()
  117. {
  118. // overloads
  119. JSONValue& root = moduleJSON_->GetRoot();
  120. JSONValue overloads = root.Get("overloads");
  121. if (overloads.IsObject())
  122. {
  123. Vector<String> childNames = overloads.GetObject().Keys();
  124. for (unsigned j = 0; j < childNames.Size(); j++)
  125. {
  126. String classname = childNames.At(j);
  127. JSBClass* klass = GetClass(classname);
  128. if (!klass)
  129. {
  130. ErrorExit("Bad overload klass");
  131. }
  132. JSONValue classoverloads = overloads.Get(classname);
  133. Vector<String> functionNames = classoverloads.GetObject().Keys();
  134. for (unsigned k = 0; k < functionNames.Size(); k++)
  135. {
  136. JSONValue _sig = classoverloads.Get(functionNames[k]);
  137. if (!_sig.IsArray())
  138. {
  139. ErrorExit("Bad overload definition");
  140. }
  141. JSONArray sig = _sig.GetArray();
  142. Vector<String> values;
  143. for (unsigned x = 0; x < sig.Size(); x++)
  144. {
  145. values.Push(sig[x].GetString());
  146. }
  147. JSBFunctionSignature* fo = new JSBFunctionSignature(functionNames[k], values);
  148. klass->AddFunctionOverride(fo);
  149. }
  150. }
  151. }
  152. }
  153. void JSBModule::ProcessExcludes(const JSONValue& excludes, BindingLanguage language)
  154. {
  155. Vector<String> childNames = excludes.GetObject().Keys();
  156. for (unsigned j = 0; j < childNames.Size(); j++)
  157. {
  158. String classname = childNames.At(j);
  159. if (classname == "CSharp")
  160. {
  161. JSONValue sharpexcludes = excludes.Get("CSharp");
  162. if (sharpexcludes.IsObject())
  163. {
  164. ProcessExcludes(sharpexcludes, BINDINGLANGUAGE_CSHARP);
  165. }
  166. continue;
  167. }
  168. JSBClass* klass = GetClass(classname);
  169. if (!klass)
  170. {
  171. ErrorExit("Bad exclude klass");
  172. }
  173. JSONValue classexcludes = excludes.Get(classname);
  174. Vector<String> functionNames = classexcludes.GetObject().Keys();
  175. for (unsigned k = 0; k < functionNames.Size(); k++)
  176. {
  177. JSONValue _sig = classexcludes.Get(functionNames[k]);
  178. if (!_sig.IsArray())
  179. {
  180. ErrorExit("Bad exclude defintion");
  181. }
  182. JSONArray sig = _sig.GetArray();
  183. Vector<String> values;
  184. for (unsigned x = 0; x < sig.Size(); x++)
  185. {
  186. values.Push(sig[x].GetString());
  187. }
  188. JSBFunctionSignature* fe = new JSBFunctionSignature(functionNames[k], values);
  189. if (language != BINDINGLANGUAGE_ANY)
  190. fe->associatedBindings_.Push(language);
  191. klass->AddFunctionExclude(fe);
  192. }
  193. }
  194. }
  195. void JSBModule::ProcessExcludes()
  196. {
  197. // excludes
  198. JSONValue& root = moduleJSON_->GetRoot();
  199. JSONValue excludes = root.Get("excludes");
  200. if (excludes.IsObject())
  201. {
  202. ProcessExcludes(excludes);
  203. }
  204. }
  205. void JSBModule::ProcessClassExcludes()
  206. {
  207. JSONValue& root = moduleJSON_->GetRoot();
  208. JSONValue excludes = root.Get("classExcludes");
  209. if (excludes.IsObject())
  210. {
  211. Vector<String> classes = excludes.GetObject().Keys();
  212. for (unsigned i = 0; i < classes.Size(); i++)
  213. {
  214. const String& classname = classes[i];
  215. if (!classExcludes_.Contains(classname))
  216. {
  217. classExcludes_[classname] = Vector<String>();
  218. }
  219. JSONArray platforms = excludes[classname].GetArray();
  220. for (unsigned j = 0; j < platforms.Size(); j++)
  221. {
  222. classExcludes_[classname].Push(platforms[j].GetString());
  223. }
  224. }
  225. }
  226. }
  227. void JSBModule::ProcessTypeScriptDecl()
  228. {
  229. // TypeScript declarations
  230. JSONValue& root = moduleJSON_->GetRoot();
  231. JSONValue decl = root.Get("typescript_decl");
  232. if (decl.IsObject())
  233. {
  234. Vector<String> childNames = decl.GetObject().Keys();
  235. for (unsigned j = 0; j < childNames.Size(); j++)
  236. {
  237. String classname = childNames.At(j);
  238. JSBClass* klass = GetClass(classname);
  239. if (!klass)
  240. {
  241. ErrorExit("Bad TypeScript decl klass");
  242. }
  243. JSONArray classdecl = decl.Get(classname).GetArray();
  244. for (unsigned k = 0; k < classdecl.Size(); k++)
  245. {
  246. klass->AddTypeScriptDecl(classdecl[k].GetString());
  247. }
  248. }
  249. }
  250. }
  251. void JSBModule::ProcessHaxeDecl()
  252. {
  253. // Haxe declarations
  254. JSONValue& root = moduleJSON_->GetRoot();
  255. JSONValue decl = root.Get("haxe_decl");
  256. if (decl.IsObject())
  257. {
  258. Vector<String> childNames = decl.GetObject().Keys();
  259. for (unsigned j = 0; j < childNames.Size(); j++)
  260. {
  261. String classname = childNames.At(j);
  262. JSBClass* klass = GetClass(classname);
  263. if (!klass)
  264. {
  265. ErrorExit("Bad Haxe decl class");
  266. }
  267. JSONArray classdecl = decl.Get(classname).GetArray();
  268. for (unsigned k = 0; k < classdecl.Size(); k++)
  269. {
  270. klass->AddHaxeDecl(classdecl[k].GetString());
  271. }
  272. }
  273. }
  274. }
  275. void JSBModule::ProcessCSharpDecl()
  276. {
  277. // C# declarations
  278. JSONValue& root = moduleJSON_->GetRoot();
  279. JSONValue interfaceDecl = root.Get("csharp_interface_decl");
  280. if (interfaceDecl.IsObject())
  281. {
  282. Vector<String> childNames = interfaceDecl.GetObject().Keys();
  283. for (unsigned j = 0; j < childNames.Size(); j++)
  284. {
  285. String classname = childNames.At(j);
  286. JSBClass* klass = GetClass(classname);
  287. if (!klass)
  288. {
  289. ErrorExit("Bad csharp decl class");
  290. }
  291. JSONArray interfaces = interfaceDecl.Get(classname).GetArray();
  292. for (unsigned k = 0; k < interfaces.Size(); k++)
  293. {
  294. klass->AddCSharpInterface(interfaces[k].GetString());
  295. }
  296. }
  297. }
  298. }
  299. void JSBModule::ScanHeaders()
  300. {
  301. JSBind* jsbind = GetSubsystem<JSBind>();
  302. FileSystem* fs = GetSubsystem<FileSystem>();
  303. const String& sourceRoot = jsbind->GetSourceRootFolder();
  304. for (unsigned i = 0; i < sourceDirs_.Size(); i++)
  305. {
  306. const String& dir = sourceRoot + sourceDirs_[i] + "/";
  307. Vector<String> fileNames;
  308. fs->ScanDir(fileNames, dir, "*.h", SCAN_FILES, false);
  309. for (unsigned k = 0; k < fileNames.Size(); k++)
  310. {
  311. String filepath = dir + fileNames[k];
  312. SharedPtr<JSBHeader> header(new JSBHeader(context_, this, filepath));
  313. // Parse the C++ header
  314. header->Parse();
  315. headers_.Push(header);
  316. }
  317. }
  318. }
  319. JSBClass* JSBModule::GetClass(const String& name, bool includeInterfaces)
  320. {
  321. if (classes_.Contains(name))
  322. {
  323. JSBClass* klass = classes_[name];
  324. if (!includeInterfaces && klass->IsInterface())
  325. return 0;
  326. return klass;
  327. }
  328. return 0;
  329. }
  330. void JSBModule::RegisterClass(String name)
  331. {
  332. String nativeName = name;
  333. if (classnames_.Contains(name) || interfaceNames_.Contains(name))
  334. {
  335. if (classRenames_.Contains(name))
  336. {
  337. name = classRenames_[name];
  338. }
  339. if (JSBPackage::GetClassAllPackages(nativeName, true))
  340. {
  341. ErrorExit(ToString("Class collision: %s", name.CString()));
  342. }
  343. bool interface = false;
  344. if (interfaceNames_.Contains(nativeName))
  345. {
  346. interface = true;
  347. }
  348. JSBClass* cls = new JSBClass(context_, this, name, nativeName, interface);
  349. if (genericClassnames_.Contains(name))
  350. {
  351. cls->SetGeneric();
  352. }
  353. classes_[nativeName] = cls;
  354. package_->RegisterClass(cls);
  355. }
  356. }
  357. void JSBModule::RegisterEvent(JSBEvent* event)
  358. {
  359. if (JSBPackage::GetEventAllPackages(event->GetEventID(), event->GetEventName()))
  360. {
  361. ErrorExit(ToString("Event collision: %s : %s", event->GetEventID().CString(), event->GetEventName().CString()));
  362. }
  363. events_.Push(SharedPtr<JSBEvent>(event));
  364. }
  365. JSBEvent* JSBModule::GetEvent(const String& eventID, const String& eventName)
  366. {
  367. for (unsigned i = 0; i < events_.Size(); i++)
  368. {
  369. if (events_[i]->GetEventName() == eventName || events_[i]->GetEventID() == eventID)
  370. {
  371. return events_[i];
  372. }
  373. }
  374. return 0;
  375. }
  376. const Vector<SharedPtr<JSBEvent>>& JSBModule::GetEvents()
  377. {
  378. return events_;
  379. }
  380. void JSBModule::RegisterEnum(JSBEnum* jenum)
  381. {
  382. if (JSBPackage::GetClassAllPackages(jenum->GetName()))
  383. {
  384. ErrorExit(ToString("Enum collision: %s", jenum->GetName().CString()));
  385. }
  386. enums_[jenum->GetName()] = jenum;
  387. }
  388. JSBEnum* JSBModule::GetEnum(const String& name)
  389. {
  390. if (enums_.Contains(name))
  391. {
  392. return enums_[name];
  393. }
  394. return 0;
  395. }
  396. String JSBModule::GetClassDefineGuard(const String& name, const String& language) const
  397. {
  398. StringVector platforms;
  399. if (!classExcludes_.TryGetValue(name, platforms) || !platforms.Size())
  400. return String::EMPTY;
  401. Vector<String> defines;
  402. for (unsigned i = 0; i < platforms.Size(); i++)
  403. {
  404. String platform = platforms[i].ToLower();
  405. if (platform == "windows")
  406. {
  407. if (language == "csharp")
  408. {
  409. if (!defines.Contains("!ATOMIC_DESKTOP"))
  410. defines.Push("!ATOMIC_DESKTOP");
  411. }
  412. else
  413. {
  414. defines.Push("!defined(ATOMIC_PLATFORM_WINDOWS)");
  415. }
  416. }
  417. else if (platform == "macosx")
  418. {
  419. if (language == "csharp")
  420. {
  421. if (!defines.Contains("!ATOMIC_DESKTOP"))
  422. defines.Push("!ATOMIC_DESKTOP");
  423. }
  424. else
  425. {
  426. defines.Push("!defined(ATOMIC_PLATFORM_OSX)");
  427. }
  428. }
  429. else if (platform == "linux")
  430. {
  431. if (language == "csharp")
  432. {
  433. if (!defines.Contains("!ATOMIC_DESKTOP"))
  434. defines.Push("!ATOMIC_DESKTOP");
  435. }
  436. else
  437. {
  438. defines.Push("!defined(ATOMIC_PLATFORM_LINUX)");
  439. }
  440. }
  441. else if (platform == "android")
  442. {
  443. if (language == "csharp")
  444. {
  445. defines.Push("!ATOMIC_ANDROID");
  446. }
  447. else
  448. {
  449. defines.Push("!defined(ATOMIC_PLATFORM_ANDROID)");
  450. }
  451. }
  452. else if (platform == "ios")
  453. {
  454. if (language == "csharp")
  455. {
  456. defines.Push("!ATOMIC_IOS");
  457. }
  458. else
  459. {
  460. defines.Push("!defined(ATOMIC_PLATFORM_IOS)");
  461. }
  462. }
  463. else if (platform == "web")
  464. {
  465. if (language == "csharp")
  466. {
  467. defines.Push("!ATOMIC_WEB");
  468. }
  469. else
  470. {
  471. defines.Push("!defined(ATOMIC_PLATFORM_WEB)");
  472. }
  473. }
  474. else
  475. {
  476. ATOMIC_LOGERRORF("Unknown package platform: %s", platform.CString());
  477. }
  478. }
  479. if (!defines.Size())
  480. return String::EMPTY;
  481. String defineString = "#if " + String::Joined(defines, " && ");
  482. return defineString;
  483. }
  484. String JSBModule::GetModuleDefineGuard() const
  485. {
  486. // platform -> vector of modules
  487. const HashMap<String, Vector<String>>& platformExcludes = package_->GetModuleExcludes();
  488. HashMap<String, Vector<String>>::ConstIterator itr = platformExcludes.Begin();
  489. Vector<String> defines;
  490. while (itr != platformExcludes.End())
  491. {
  492. const String& platform = itr->first_;
  493. const Vector<String>& modules = itr->second_;
  494. for (unsigned i = 0; i < modules.Size(); i++)
  495. {
  496. if (modules[i].ToLower() == name_.ToLower())
  497. {
  498. if (platform.ToLower() == "windows")
  499. defines.Push("!defined(ATOMIC_PLATFORM_WINDOWS)");
  500. else if (platform.ToLower() == "macosx")
  501. defines.Push("!defined(ATOMIC_PLATFORM_OSX)");
  502. else if (platform.ToLower() == "linux")
  503. defines.Push("!defined(ATOMIC_PLATFORM_LINUX)");
  504. else if (platform.ToLower() == "android")
  505. defines.Push("!defined(ATOMIC_PLATFORM_ANDROID)");
  506. else if (platform.ToLower() == "ios")
  507. defines.Push("!defined(ATOMIC_PLATFORM_IOS)");
  508. else if (platform.ToLower() == "web")
  509. defines.Push("!defined(ATOMIC_PLATFORM_WEB)");
  510. else
  511. {
  512. ATOMIC_LOGERRORF("Unknown package platform: %s", platform.CString());
  513. }
  514. break;
  515. }
  516. }
  517. itr++;
  518. }
  519. if (!defines.Size())
  520. return String::EMPTY;
  521. String defineString = "#if " + String::Joined(defines, " && ");
  522. return defineString;
  523. }
  524. bool JSBModule::ContainsConstant(const String& constantName)
  525. {
  526. return constants_.Contains(constantName);
  527. }
  528. void JSBModule::RegisterConstant(const String& constantName, const String& value, unsigned type, bool isUnsigned)
  529. {
  530. // MAX_CASCADE_SPLITS is defined differently for desktop/mobile
  531. if (constantName == "MAX_CASCADE_SPLITS" && JSBPackage::ContainsConstantAllPackages(constantName))
  532. {
  533. return;
  534. }
  535. if (JSBPackage::ContainsConstantAllPackages(constantName))
  536. {
  537. ErrorExit(ToString("Constant collision: %s", constantName.CString()));
  538. }
  539. Constant c;
  540. c.type = new JSBPrimitiveType(type, isUnsigned);
  541. c.value = value;
  542. constants_[constantName] = c;
  543. }
  544. bool JSBModule::Load(const String& jsonFilename)
  545. {
  546. ATOMIC_LOGINFOF("Loading Module: %s", jsonFilename.CString());
  547. JSBind* jsbind = GetSubsystem<JSBind>();
  548. SharedPtr<File> jsonFile(new File(context_, jsonFilename));
  549. if (!jsonFile->IsOpen())
  550. {
  551. ATOMIC_LOGERRORF("Unable to open module json: %s", jsonFilename.CString());
  552. return false;
  553. }
  554. moduleJSON_ = new JSONFile(context_);
  555. if (!moduleJSON_->BeginLoad(*jsonFile))
  556. {
  557. ATOMIC_LOGERRORF("Unable to parse module json: %s", jsonFilename.CString());
  558. return false;
  559. }
  560. JSONValue& root = moduleJSON_->GetRoot();
  561. name_ = root.Get("name").GetString();
  562. JSONValue requires = root.Get("requires");
  563. if (requires.IsArray())
  564. {
  565. for (unsigned j = 0; j < requires.GetArray().Size(); j++)
  566. {
  567. requirements_.Push(requires[j].GetString());
  568. }
  569. }
  570. JSONArray classes = root.Get("classes").GetArray();
  571. for (unsigned i = 0; i < classes.Size(); i++)
  572. {
  573. classnames_.Push(classes[i].GetString());
  574. }
  575. JSONArray classesGeneric = root.Get("classes_generic").GetArray();
  576. for (unsigned i = 0; i < classesGeneric.Size(); i++)
  577. {
  578. genericClassnames_.Push(classesGeneric[i].GetString());
  579. }
  580. JSONValue classes_rename = root.Get("classes_rename");
  581. if (classes_rename.IsObject())
  582. {
  583. Vector<String> childNames = classes_rename.GetObject().Keys();
  584. for (unsigned j = 0; j < childNames.Size(); j++)
  585. {
  586. String classname = childNames.At(j);
  587. String crename = classes_rename.Get(classname).GetString();
  588. classRenames_[classname] = crename;
  589. }
  590. }
  591. JSONArray interfaces = root.Get("interfaces").GetArray();
  592. for (unsigned i = 0; i < interfaces.Size(); i++)
  593. {
  594. interfaceNames_.Push(interfaces[i].GetString());
  595. }
  596. JSONValue includes = root.Get("includes");
  597. if (includes.IsArray())
  598. {
  599. for (unsigned j = 0; j < includes.GetArray().Size(); j++)
  600. {
  601. includes_.Push(includes.GetArray()[j].GetString());
  602. }
  603. }
  604. JSONValue jsmodulepreamble = root.Get("jsmodulepreamble");
  605. if (jsmodulepreamble.IsArray())
  606. {
  607. for (unsigned j = 0; j < jsmodulepreamble.GetArray().Size(); j++)
  608. {
  609. jsmodulePreamble_.Push(jsmodulepreamble.GetArray()[j].GetString());
  610. }
  611. }
  612. JSONValue sources = root.Get("sources");
  613. for (unsigned i = 0; i < sources.GetArray().Size(); i++)
  614. {
  615. sourceDirs_.Push(sources.GetArray()[i].GetString());
  616. }
  617. ScanHeaders();
  618. return true;
  619. }
  620. }