ScriptFile.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. //
  2. // Copyright (c) 2008-2013 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 "Precompiled.h"
  23. #include "ArrayPtr.h"
  24. #include "Context.h"
  25. #include "CoreEvents.h"
  26. #include "FileSystem.h"
  27. #include "Log.h"
  28. #include "Profiler.h"
  29. #include "ResourceCache.h"
  30. #include "Script.h"
  31. #include "ScriptFile.h"
  32. #include "ScriptInstance.h"
  33. #include <angelscript.h>
  34. #include <cstring>
  35. #include "DebugNew.h"
  36. namespace Urho3D
  37. {
  38. /// Helper class for saving AngelScript bytecode.
  39. class ByteCodeSerializer : public asIBinaryStream
  40. {
  41. public:
  42. /// Construct.
  43. ByteCodeSerializer(Serializer& dest) :
  44. dest_(dest)
  45. {
  46. }
  47. /// Read from stream (no-op).
  48. virtual void Read(void* ptr, asUINT size)
  49. {
  50. // No-op, can not read from a Serializer
  51. }
  52. /// Write to stream.
  53. virtual void Write(const void* ptr, asUINT size)
  54. {
  55. dest_.Write(ptr, size);
  56. }
  57. private:
  58. /// Destination stream.
  59. Serializer& dest_;
  60. };
  61. /// Helper class for loading AngelScript bytecode.
  62. class ByteCodeDeserializer : public asIBinaryStream
  63. {
  64. public:
  65. /// Construct.
  66. ByteCodeDeserializer(Deserializer& source) :
  67. source_(source)
  68. {
  69. }
  70. /// Read from stream.
  71. virtual void Read(void* ptr, asUINT size)
  72. {
  73. source_.Read(ptr, size);
  74. }
  75. /// Write to stream (no-op).
  76. virtual void Write(const void* ptr, asUINT size)
  77. {
  78. }
  79. private:
  80. /// Source stream.
  81. Deserializer& source_;
  82. };
  83. ScriptFile::ScriptFile(Context* context) :
  84. Resource(context),
  85. script_(GetSubsystem<Script>()),
  86. scriptModule_(0),
  87. compiled_(false),
  88. subscribed_(false)
  89. {
  90. }
  91. ScriptFile::~ScriptFile()
  92. {
  93. ReleaseModule();
  94. }
  95. void ScriptFile::RegisterObject(Context* context)
  96. {
  97. context->RegisterFactory<ScriptFile>();
  98. }
  99. bool ScriptFile::Load(Deserializer& source)
  100. {
  101. PROFILE(LoadScript);
  102. ReleaseModule();
  103. // Create the module. Discard previous module if there was one
  104. asIScriptEngine* engine = script_->GetScriptEngine();
  105. scriptModule_ = engine->GetModule(GetName().CString(), asGM_ALWAYS_CREATE);
  106. if (!scriptModule_)
  107. {
  108. LOGERROR("Failed to create script module " + GetName());
  109. return false;
  110. }
  111. // Check if this file is precompiled bytecode
  112. if (source.ReadFileID() == "ASBC")
  113. {
  114. ByteCodeDeserializer deserializer = ByteCodeDeserializer(source);
  115. if (scriptModule_->LoadByteCode(&deserializer) >= 0)
  116. {
  117. LOGINFO("Loaded script module " + GetName() + " from bytecode");
  118. compiled_ = true;
  119. // Map script module to script resource with userdata
  120. scriptModule_->SetUserData(this);
  121. return true;
  122. }
  123. else
  124. return false;
  125. }
  126. else
  127. source.Seek(0);
  128. // Not bytecode: add the initial section and check for includes
  129. if (!AddScriptSection(engine, source))
  130. return false;
  131. // Compile
  132. int result = scriptModule_->Build();
  133. if (result < 0)
  134. {
  135. LOGERROR("Failed to compile script module " + GetName());
  136. return false;
  137. }
  138. LOGINFO("Compiled script module " + GetName());
  139. compiled_ = true;
  140. // Map script module to script resource with userdata
  141. scriptModule_->SetUserData(this);
  142. return true;
  143. }
  144. void ScriptFile::AddEventHandler(StringHash eventType, const String& handlerName)
  145. {
  146. if (!compiled_)
  147. return;
  148. String declaration = "void " + handlerName + "(StringHash, VariantMap&)";
  149. asIScriptFunction* function = GetFunction(declaration);
  150. if (!function)
  151. {
  152. declaration = "void " + handlerName + "()";
  153. function = GetFunction(declaration);
  154. if (!function)
  155. {
  156. LOGERROR("Event handler function " + handlerName + " not found in " + GetName());
  157. return;
  158. }
  159. }
  160. SubscribeToEvent(eventType, HANDLER_USERDATA(ScriptFile, HandleScriptEvent, (void*)function));
  161. }
  162. void ScriptFile::AddEventHandler(Object* sender, StringHash eventType, const String& handlerName)
  163. {
  164. if (!compiled_)
  165. return;
  166. if (!sender)
  167. {
  168. LOGERROR("Null event sender for event " + String(eventType) + ", handler " + handlerName);
  169. return;
  170. }
  171. String declaration = "void " + handlerName + "(StringHash, VariantMap&)";
  172. asIScriptFunction* function = GetFunction(declaration);
  173. if (!function)
  174. {
  175. declaration = "void " + handlerName + "()";
  176. function = GetFunction(declaration);
  177. if (!function)
  178. {
  179. LOGERROR("Event handler function " + handlerName + " not found in " + GetName());
  180. return;
  181. }
  182. }
  183. SubscribeToEvent(sender, eventType, HANDLER_USERDATA(ScriptFile, HandleScriptEvent, (void*)function));
  184. }
  185. bool ScriptFile::Execute(const String& declaration, const VariantVector& parameters, bool unprepare)
  186. {
  187. asIScriptFunction* function = GetFunction(declaration);
  188. if (!function)
  189. {
  190. LOGERROR("Function " + declaration + " not found in " + GetName());
  191. return false;
  192. }
  193. return Execute(function, parameters, unprepare);
  194. }
  195. bool ScriptFile::Execute(asIScriptFunction* function, const VariantVector& parameters, bool unprepare)
  196. {
  197. PROFILE(ExecuteFunction);
  198. if (!compiled_ || !function)
  199. return false;
  200. // It is possible that executing the function causes us to unload. Therefore do not rely on member variables
  201. // However, we are not prepared for the whole script system getting destroyed during execution (should never happen)
  202. Script* scriptSystem = script_;
  203. asIScriptContext* context = scriptSystem->GetScriptFileContext();
  204. if (context->Prepare(function) < 0)
  205. return false;
  206. SetParameters(context, function, parameters);
  207. scriptSystem->IncScriptNestingLevel();
  208. bool success = context->Execute() >= 0;
  209. if (unprepare)
  210. context->Unprepare();
  211. scriptSystem->DecScriptNestingLevel();
  212. return success;
  213. }
  214. bool ScriptFile::Execute(asIScriptObject* object, const String& declaration, const VariantVector& parameters, bool unprepare)
  215. {
  216. asIScriptFunction* method = GetMethod(object, declaration);
  217. if (!method)
  218. {
  219. LOGERROR("Method " + declaration + " not found in " + GetName());
  220. return false;
  221. }
  222. return Execute(object, method, parameters, unprepare);
  223. }
  224. bool ScriptFile::Execute(asIScriptObject* object, asIScriptFunction* method, const VariantVector& parameters, bool unprepare)
  225. {
  226. PROFILE(ExecuteMethod);
  227. if (!compiled_ || !object || !method)
  228. return false;
  229. // It is possible that executing the method causes us to unload. Therefore do not rely on member variables
  230. // However, we are not prepared for the whole script system getting destroyed during execution (should never happen)
  231. Script* scriptSystem = script_;
  232. asIScriptContext* context = scriptSystem->GetScriptFileContext();
  233. if (context->Prepare(method) < 0)
  234. return false;
  235. context->SetObject(object);
  236. SetParameters(context, method, parameters);
  237. scriptSystem->IncScriptNestingLevel();
  238. bool success = context->Execute() >= 0;
  239. if (unprepare)
  240. context->Unprepare();
  241. scriptSystem->DecScriptNestingLevel();
  242. return success;
  243. }
  244. void ScriptFile::DelayedExecute(float delay, bool repeat, const String& declaration, const VariantVector& parameters)
  245. {
  246. DelayedCall call;
  247. call.period_ = call.delay_ = Max(delay, 0.0f);
  248. call.repeat_ = repeat;
  249. call.declaration_ = declaration;
  250. call.parameters_ = parameters;
  251. delayedCalls_.Push(call);
  252. // Make sure we are registered to the application update event, because delayed calls are executed there
  253. if (!subscribed_)
  254. {
  255. SubscribeToEvent(E_UPDATE, HANDLER(ScriptFile, HandleUpdate));
  256. subscribed_ = true;
  257. }
  258. }
  259. void ScriptFile::ClearDelayedExecute(const String& declaration)
  260. {
  261. if (declaration.Empty())
  262. delayedCalls_.Clear();
  263. else
  264. {
  265. for (Vector<DelayedCall>::Iterator i = delayedCalls_.Begin(); i != delayedCalls_.End();)
  266. {
  267. if (declaration == i->declaration_)
  268. i = delayedCalls_.Erase(i);
  269. else
  270. ++i;
  271. }
  272. }
  273. }
  274. asIScriptObject* ScriptFile::CreateObject(const String& className)
  275. {
  276. PROFILE(CreateObject);
  277. if (!compiled_)
  278. return 0;
  279. asIScriptContext* context = script_->GetScriptFileContext();
  280. asIScriptEngine* engine = script_->GetScriptEngine();
  281. asIObjectType *type = engine->GetObjectTypeById(scriptModule_->GetTypeIdByDecl(className.CString()));
  282. if (!type)
  283. return 0;
  284. // Ensure that the type implements the "ScriptObject" interface, so it can be returned to script properly
  285. bool found = false;
  286. HashMap<asIObjectType*, bool>::ConstIterator i = validClasses_.Find(type);
  287. if (i != validClasses_.End())
  288. found = i->second_;
  289. else
  290. {
  291. unsigned numInterfaces = type->GetInterfaceCount();
  292. for (unsigned j = 0; j < numInterfaces; ++j)
  293. {
  294. asIObjectType* interfaceType = type->GetInterface(j);
  295. if (!strcmp(interfaceType->GetName(), "ScriptObject"))
  296. {
  297. found = true;
  298. break;
  299. }
  300. }
  301. validClasses_[type] = found;
  302. }
  303. if (!found)
  304. {
  305. LOGERROR("Script class " + className + " does not implement the ScriptObject interface");
  306. return 0;
  307. }
  308. // Get the factory function id from the object type
  309. String factoryName = className + "@ " + className + "()";
  310. asIScriptFunction* factory = type->GetFactoryByDecl(factoryName.CString());
  311. if (!factory || context->Prepare(factory) < 0 || context->Execute() < 0)
  312. return 0;
  313. asIScriptObject* obj = *(static_cast<asIScriptObject**>(context->GetAddressOfReturnValue()));
  314. if (obj)
  315. obj->AddRef();
  316. return obj;
  317. }
  318. bool ScriptFile::SaveByteCode(Serializer& dest)
  319. {
  320. if (compiled_)
  321. {
  322. dest.WriteFileID("ASBC");
  323. ByteCodeSerializer serializer = ByteCodeSerializer(dest);
  324. return scriptModule_->SaveByteCode(&serializer, true) >= 0;
  325. }
  326. else
  327. return false;
  328. }
  329. asIScriptFunction* ScriptFile::GetFunction(const String& declaration)
  330. {
  331. if (!compiled_)
  332. return 0;
  333. HashMap<String, asIScriptFunction*>::ConstIterator i = functions_.Find(declaration);
  334. if (i != functions_.End())
  335. return i->second_;
  336. asIScriptFunction* function = scriptModule_->GetFunctionByDecl(declaration.CString());
  337. functions_[declaration] = function;
  338. return function;
  339. }
  340. asIScriptFunction* ScriptFile::GetMethod(asIScriptObject* object, const String& declaration)
  341. {
  342. if (!compiled_ || !object)
  343. return 0;
  344. asIObjectType* type = object->GetObjectType();
  345. if (!type)
  346. return 0;
  347. HashMap<asIObjectType*, HashMap<String, asIScriptFunction*> >::ConstIterator i = methods_.Find(type);
  348. if (i != methods_.End())
  349. {
  350. HashMap<String, asIScriptFunction*>::ConstIterator j = i->second_.Find(declaration);
  351. if (j != i->second_.End())
  352. return j->second_;
  353. }
  354. asIScriptFunction* function = type->GetMethodByDecl(declaration.CString());
  355. methods_[type][declaration] = function;
  356. return function;
  357. }
  358. bool ScriptFile::AddScriptSection(asIScriptEngine* engine, Deserializer& source)
  359. {
  360. ResourceCache* cache = GetSubsystem<ResourceCache>();
  361. unsigned dataSize = source.GetSize();
  362. SharedArrayPtr<char> buffer(new char[dataSize]);
  363. source.Read((void*)buffer.Get(), dataSize);
  364. // Pre-parse for includes
  365. // Adapted from Angelscript's scriptbuilder add-on
  366. Vector<String> includeFiles;
  367. unsigned pos = 0;
  368. while(pos < dataSize)
  369. {
  370. int len;
  371. asETokenClass t = engine->ParseToken(&buffer[pos], dataSize - pos, &len);
  372. if (t == asTC_COMMENT || t == asTC_WHITESPACE)
  373. {
  374. pos += len;
  375. continue;
  376. }
  377. // Is this a preprocessor directive?
  378. if (buffer[pos] == '#')
  379. {
  380. int start = pos++;
  381. asETokenClass t = engine->ParseToken(&buffer[pos], dataSize - pos, &len);
  382. if (t == asTC_IDENTIFIER)
  383. {
  384. String token(&buffer[pos], len);
  385. if (token == "include")
  386. {
  387. pos += len;
  388. t = engine->ParseToken(&buffer[pos], dataSize - pos, &len);
  389. if (t == asTC_WHITESPACE)
  390. {
  391. pos += len;
  392. t = engine->ParseToken(&buffer[pos], dataSize - pos, &len);
  393. }
  394. if (t == asTC_VALUE && len > 2 && buffer[pos] == '"')
  395. {
  396. // Get the include file
  397. String includeFile(&buffer[pos+1], len - 2);
  398. pos += len;
  399. // If the file is not found as it is, add the path of current file but only if it is found there
  400. if (!cache->Exists(includeFile))
  401. {
  402. String prefixedIncludeFile = GetPath(GetName()) + includeFile;
  403. if (cache->Exists(prefixedIncludeFile))
  404. includeFile = prefixedIncludeFile;
  405. }
  406. String includeFileLower = includeFile.ToLower();
  407. // If not included yet, store it for later processing
  408. if (!includeFiles_.Contains(includeFileLower))
  409. {
  410. includeFiles_.Insert(includeFileLower);
  411. includeFiles.Push(includeFile);
  412. }
  413. // Overwrite the include directive with space characters to avoid compiler error
  414. memset(&buffer[start], ' ', pos - start);
  415. }
  416. }
  417. }
  418. }
  419. // Don't search includes within statement blocks or between tokens in statements
  420. else
  421. {
  422. int len;
  423. // Skip until ; or { whichever comes first
  424. while (pos < dataSize && buffer[pos] != ';' && buffer[pos] != '{')
  425. {
  426. engine->ParseToken(&buffer[pos], 0, &len);
  427. pos += len;
  428. }
  429. // Skip entire statement block
  430. if (pos < dataSize && buffer[pos] == '{')
  431. {
  432. ++pos;
  433. // Find the end of the statement block
  434. int level = 1;
  435. while (level > 0 && pos < dataSize)
  436. {
  437. asETokenClass t = engine->ParseToken(&buffer[pos], 0, &len);
  438. if (t == asTC_KEYWORD)
  439. {
  440. if (buffer[pos] == '{')
  441. ++level;
  442. else if(buffer[pos] == '}')
  443. --level;
  444. }
  445. pos += len;
  446. }
  447. }
  448. else
  449. ++pos;
  450. }
  451. }
  452. // Process includes first
  453. for (unsigned i = 0; i < includeFiles.Size(); ++i)
  454. {
  455. cache->StoreResourceDependency(this, includeFiles[i]);
  456. SharedPtr<File> file = cache->GetFile(includeFiles[i]);
  457. if (file)
  458. {
  459. if (!AddScriptSection(engine, *file))
  460. return false;
  461. }
  462. else
  463. {
  464. LOGERROR("Could not process all the include directives in " + GetName() + ": missing " + includeFiles[i]);
  465. return false;
  466. }
  467. }
  468. // Then add this section
  469. if (scriptModule_->AddScriptSection(source.GetName().CString(), (const char*)buffer.Get(), dataSize) < 0)
  470. {
  471. LOGERROR("Failed to add script section " + source.GetName());
  472. return false;
  473. }
  474. SetMemoryUse(GetMemoryUse() + dataSize);
  475. return true;
  476. }
  477. void ScriptFile::SetParameters(asIScriptContext* context, asIScriptFunction* function, const VariantVector& parameters)
  478. {
  479. unsigned paramCount = function->GetParamCount();
  480. for (unsigned i = 0; i < parameters.Size() && i < paramCount; ++i)
  481. {
  482. int paramType = function->GetParamTypeId(i);
  483. switch (paramType)
  484. {
  485. case asTYPEID_BOOL:
  486. context->SetArgByte(i, (unsigned char)parameters[i].GetBool());
  487. break;
  488. case asTYPEID_INT8:
  489. case asTYPEID_UINT8:
  490. context->SetArgByte(i, parameters[i].GetInt());
  491. break;
  492. case asTYPEID_INT16:
  493. case asTYPEID_UINT16:
  494. context->SetArgWord(i, parameters[i].GetInt());
  495. break;
  496. case asTYPEID_INT32:
  497. case asTYPEID_UINT32:
  498. context->SetArgDWord(i, parameters[i].GetInt());
  499. break;
  500. case asTYPEID_FLOAT:
  501. context->SetArgFloat(i, parameters[i].GetFloat());
  502. break;
  503. default:
  504. if (paramType & asTYPEID_APPOBJECT)
  505. {
  506. switch (parameters[i].GetType())
  507. {
  508. case VAR_VECTOR2:
  509. context->SetArgObject(i, (void *)&parameters[i].GetVector2());
  510. break;
  511. case VAR_VECTOR3:
  512. context->SetArgObject(i, (void *)&parameters[i].GetVector3());
  513. break;
  514. case VAR_VECTOR4:
  515. context->SetArgObject(i, (void *)&parameters[i].GetVector4());
  516. break;
  517. case VAR_QUATERNION:
  518. context->SetArgObject(i, (void *)&parameters[i].GetQuaternion());
  519. break;
  520. case VAR_STRING:
  521. context->SetArgObject(i, (void *)&parameters[i].GetString());
  522. break;
  523. case VAR_PTR:
  524. context->SetArgObject(i, (void *)parameters[i].GetPtr());
  525. break;
  526. default:
  527. break;
  528. }
  529. }
  530. break;
  531. }
  532. }
  533. }
  534. void ScriptFile::ReleaseModule()
  535. {
  536. if (scriptModule_)
  537. {
  538. script_->ClearObjectTypeCache();
  539. // Clear search caches and event handlers
  540. includeFiles_.Clear();
  541. validClasses_.Clear();
  542. functions_.Clear();
  543. methods_.Clear();
  544. delayedCalls_.Clear();
  545. UnsubscribeFromAllEventsExcept(PODVector<StringHash>(), true);
  546. // Remove the module
  547. scriptModule_->SetUserData(0);
  548. asIScriptEngine* engine = script_->GetScriptEngine();
  549. engine->DiscardModule(GetName().CString());
  550. scriptModule_ = 0;
  551. compiled_ = false;
  552. SetMemoryUse(0);
  553. ResourceCache* cache = GetSubsystem<ResourceCache>();
  554. if (cache)
  555. cache->ResetDependencies(this);
  556. }
  557. }
  558. void ScriptFile::HandleScriptEvent(StringHash eventType, VariantMap& eventData)
  559. {
  560. if (!compiled_)
  561. return;
  562. asIScriptFunction* function = static_cast<asIScriptFunction*>(GetEventHandler()->GetUserData());
  563. VariantVector parameters;
  564. if (function->GetParamCount() > 0)
  565. {
  566. parameters.Push(Variant((void*)&eventType));
  567. parameters.Push(Variant((void*)&eventData));
  568. }
  569. Execute(function, parameters);
  570. }
  571. void ScriptFile::HandleUpdate(StringHash eventType, VariantMap& eventData)
  572. {
  573. if (!compiled_)
  574. return;
  575. using namespace Update;
  576. float timeStep = eventData[P_TIMESTEP].GetFloat();
  577. // Execute delayed calls
  578. for (unsigned i = 0; i < delayedCalls_.Size();)
  579. {
  580. DelayedCall& call = delayedCalls_[i];
  581. bool remove = false;
  582. call.delay_ -= timeStep;
  583. if (call.delay_ <= 0.0f)
  584. {
  585. if (!call.repeat_)
  586. remove = true;
  587. else
  588. call.delay_ += call.period_;
  589. Execute(call.declaration_, call.parameters_);
  590. }
  591. if (remove)
  592. delayedCalls_.Erase(i);
  593. else
  594. ++i;
  595. }
  596. }
  597. ScriptFile* GetScriptContextFile()
  598. {
  599. asIScriptContext* context = asGetActiveContext();
  600. asIScriptFunction* function = context ? context->GetFunction() : 0;
  601. asIScriptModule* module = function ? function->GetEngine()->GetModule(function->GetModuleName()) : 0;
  602. if (module)
  603. return static_cast<ScriptFile*>(module->GetUserData());
  604. else
  605. return 0;
  606. }
  607. }