/Frameworks/Debug/AppKit/rhino.platform/CPCib.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 115 lines · 114 code · 1 blank · 0 comment · 0 complexity · d0483a8c1d04b4a63bc7dae9527fc119 MD5 · raw file

  1. I;21;Foundation/CPObject.jI;28;Foundation/CPURLConnection.jI;25;Foundation/CPURLRequest.ji;20;_CPCibCustomObject.ji;22;_CPCibCustomResource.ji;18;_CPCibCustomView.ji;23;_CPCibKeyedUnarchiver.ji;18;_CPCibObjectData.ji;22;_CPCibWindowTemplate.jc;5776;
  2. CPCibOwner = "CPCibOwner",
  3. CPCibTopLevelObjects = "CPCibTopLevelObjects",
  4. CPCibReplacementClasses = "CPCibReplacementClasses";
  5. var CPCibObjectDataKey = "CPCibObjectDataKey";
  6. {var the_class = objj_allocateClassPair(CPObject, "CPCib"),
  7. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_data"), new objj_ivar("_bundle"), new objj_ivar("_awakenCustomResources"), new objj_ivar("_loadDelegate")]);
  8. objj_registerClassPair(the_class);
  9. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  10. class_addMethods(the_class, [new objj_method(sel_getUid("initWithContentsOfURL:"), function $CPCib__initWithContentsOfURL_(self, _cmd, aURL)
  11. { with(self)
  12. {
  13. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  14. if (self)
  15. {
  16. _data = objj_msgSend(CPURLConnection, "sendSynchronousRequest:returningResponse:error:", objj_msgSend(CPURLRequest, "requestWithURL:", aURL), nil, nil);
  17. _awakenCustomResources = YES;
  18. }
  19. return self;
  20. }
  21. }), new objj_method(sel_getUid("initWithContentsOfURL:loadDelegate:"), function $CPCib__initWithContentsOfURL_loadDelegate_(self, _cmd, aURL, aLoadDelegate)
  22. { with(self)
  23. {
  24. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  25. if (self)
  26. {
  27. objj_msgSend(CPURLConnection, "connectionWithRequest:delegate:", objj_msgSend(CPURLRequest, "requestWithURL:", aURL), self);
  28. _awakenCustomResources = YES;
  29. _loadDelegate = aLoadDelegate;
  30. }
  31. return self;
  32. }
  33. }), new objj_method(sel_getUid("initWithCibNamed:bundle:loadDelegate:"), function $CPCib__initWithCibNamed_bundle_loadDelegate_(self, _cmd, aName, aBundle, aLoadDelegate)
  34. { with(self)
  35. {
  36. if (!objj_msgSend(aName, "hasSuffix:", ".cib"))
  37. aName = objj_msgSend(aName, "stringByAppendingString:", ".cib");
  38. self = objj_msgSend(self, "initWithContentsOfURL:loadDelegate:", objj_msgSend(aBundle || objj_msgSend(CPBundle, "mainBundle"), "pathForResource:", aName), aLoadDelegate);
  39. if (self)
  40. _bundle = aBundle;
  41. return self;
  42. }
  43. }), new objj_method(sel_getUid("_setAwakenCustomResources:"), function $CPCib___setAwakenCustomResources_(self, _cmd, shouldAwakenCustomResources)
  44. { with(self)
  45. {
  46. _awakenCustomResources = shouldAwakenCustomResources;
  47. }
  48. }), new objj_method(sel_getUid("_awakenCustomResources"), function $CPCib___awakenCustomResources(self, _cmd)
  49. { with(self)
  50. {
  51. return _awakenCustomResources;
  52. }
  53. }), new objj_method(sel_getUid("instantiateCibWithExternalNameTable:"), function $CPCib__instantiateCibWithExternalNameTable_(self, _cmd, anExternalNameTable)
  54. { with(self)
  55. {
  56. var bundle = _bundle,
  57. owner = objj_msgSend(anExternalNameTable, "objectForKey:", CPCibOwner);
  58. if (!bundle && owner)
  59. bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(owner, "class"));
  60. var unarchiver = objj_msgSend(objj_msgSend(_CPCibKeyedUnarchiver, "alloc"), "initForReadingWithData:bundle:awakenCustomResources:", _data, bundle, _awakenCustomResources),
  61. replacementClasses = objj_msgSend(anExternalNameTable, "objectForKey:", CPCibReplacementClasses);
  62. if (replacementClasses)
  63. {
  64. var key = nil,
  65. keyEnumerator = objj_msgSend(replacementClasses, "keyEnumerator");
  66. while (key = objj_msgSend(keyEnumerator, "nextObject"))
  67. objj_msgSend(unarchiver, "setClass:forClassName:", objj_msgSend(replacementClasses, "objectForKey:", key), key);
  68. }
  69. var objectData = objj_msgSend(unarchiver, "decodeObjectForKey:", CPCibObjectDataKey);
  70. if (!objectData || !objj_msgSend(objectData, "isKindOfClass:", objj_msgSend(_CPCibObjectData, "class")))
  71. return NO;
  72. var topLevelObjects = objj_msgSend(anExternalNameTable, "objectForKey:", CPCibTopLevelObjects);
  73. objj_msgSend(objectData, "instantiateWithOwner:topLevelObjects:", owner, topLevelObjects)
  74. objj_msgSend(objectData, "establishConnectionsWithOwner:topLevelObjects:", owner, topLevelObjects);
  75. objj_msgSend(objectData, "awakeWithOwner:topLevelObjects:", owner, topLevelObjects);
  76. var menu;
  77. if ((menu = objj_msgSend(objectData, "mainMenu")) != nil)
  78. {
  79. objj_msgSend(CPApp, "setMainMenu:", menu);
  80. objj_msgSend(CPMenu, "setMenuBarVisible:", YES);
  81. }
  82. objj_msgSend(objectData, "displayVisibleWindows");
  83. return YES;
  84. }
  85. }), new objj_method(sel_getUid("instantiateCibWithOwner:topLevelObjects:"), function $CPCib__instantiateCibWithOwner_topLevelObjects_(self, _cmd, anOwner, topLevelObjects)
  86. { with(self)
  87. {
  88. return objj_msgSend(self, "instantiateCibWithExternalNameTable:", objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", anOwner, CPCibOwner, topLevelObjects, CPCibTopLevelObjects));
  89. }
  90. })]);
  91. }
  92. {
  93. var the_class = objj_getClass("CPCib")
  94. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPCib\""));
  95. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("connection:didReceiveData:"), function $CPCib__connection_didReceiveData_(self, _cmd, aConnection, data)
  96. { with(self)
  97. {
  98. _data = objj_msgSend(CPData, "dataWithString:", data);
  99. }
  100. }), new objj_method(sel_getUid("connection:didFailWithError:"), function $CPCib__connection_didFailWithError_(self, _cmd, aConnection, anError)
  101. { with(self)
  102. {
  103. alert("cib: connection failed.");
  104. _loadDelegate = nil;
  105. }
  106. }), new objj_method(sel_getUid("connectionDidFinishLoading:"), function $CPCib__connectionDidFinishLoading_(self, _cmd, aConnection)
  107. { with(self)
  108. {
  109. if (objj_msgSend(_loadDelegate, "respondsToSelector:", sel_getUid("cibDidFinishLoading:")))
  110. objj_msgSend(_loadDelegate, "cibDidFinishLoading:", self);
  111. _loadDelegate = nil;
  112. }
  113. })]);
  114. }