/Frameworks/AppKit/rhino.platform/CPPasteboard.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 142 lines · 142 code · 0 blank · 0 comment · 0 complexity · 8be340e50f37cbadc23de0bbfcaadd7c MD5 · raw file

  1. I;21;Foundation/CPObject.jI;20;Foundation/CPArray.jI;25;Foundation/CPDictionary.jI;40;Foundation/CPPropertyListSerialization.jc;4493;
  2. CPGeneralPboard="CPGeneralPboard";
  3. CPFontPboard="CPFontPboard";
  4. CPRulerPboard="CPRulerPboard";
  5. CPFindPboard="CPFindPboard";
  6. CPDragPboard="CPDragPboard";
  7. CPColorPboardType="CPColorPboardType";
  8. CPFilenamesPboardType="CPFilenamesPboardType";
  9. CPFontPboardType="CPFontPboardType";
  10. CPHTMLPboardType="CPHTMLPboardType";
  11. CPStringPboardType="CPStringPboardType";
  12. CPURLPboardType="CPURLPboardType";
  13. CPImagePboardType="CPImagePboardType";
  14. var _1=nil;
  15. var _2=objj_allocateClassPair(CPObject,"CPPasteboard"),_3=_2.isa;
  16. class_addIvars(_2,[new objj_ivar("_types"),new objj_ivar("_owners"),new objj_ivar("_provided"),new objj_ivar("_changeCount"),new objj_ivar("_stateUID")]);
  17. objj_registerClassPair(_2);
  18. objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  19. class_addMethods(_2,[new objj_method(sel_getUid("_initWithName:"),function(_4,_5,_6){
  20. with(_4){
  21. _4=objj_msgSendSuper({receiver:_4,super_class:objj_getClass("CPObject")},"init");
  22. if(_4){
  23. _name=_6;
  24. _types=[];
  25. _owners=objj_msgSend(CPDictionary,"dictionary");
  26. _provided=objj_msgSend(CPDictionary,"dictionary");
  27. _changeCount=0;
  28. }
  29. return _4;
  30. }
  31. }),new objj_method(sel_getUid("addTypes:owner:"),function(_7,_8,_9,_a){
  32. with(_7){
  33. var i=0,_c=_9.length;
  34. for(;i<_c;++i){
  35. var _d=_9[i];
  36. if(!objj_msgSend(_owners,"objectForKey:",_d)){
  37. objj_msgSend(_types,"addObject:",_d);
  38. objj_msgSend(_provided,"removeObjectForKey:",_d);
  39. }
  40. objj_msgSend(_owners,"setObject:forKey:",_a,_d);
  41. }
  42. return ++_changeCount;
  43. }
  44. }),new objj_method(sel_getUid("declareTypes:owner:"),function(_e,_f,_10,_11){
  45. with(_e){
  46. objj_msgSend(_types,"setArray:",_10);
  47. _owners=objj_msgSend(CPDictionary,"dictionary");
  48. _provided=objj_msgSend(CPDictionary,"dictionary");
  49. var _12=_types.length;
  50. while(_12--){
  51. objj_msgSend(_owners,"setObject:forKey:",_11,_types[_12]);
  52. }
  53. return ++_changeCount;
  54. }
  55. }),new objj_method(sel_getUid("setData:forType:"),function(_13,_14,_15,_16){
  56. with(_13){
  57. objj_msgSend(_provided,"setObject:forKey:",_15,_16);
  58. return YES;
  59. }
  60. }),new objj_method(sel_getUid("setPropertyList:forType:"),function(_17,_18,_19,_1a){
  61. with(_17){
  62. return objj_msgSend(_17,"setData:forType:",objj_msgSend(CPPropertyListSerialization,"dataFromPropertyList:format:errorDescription:",_19,CPPropertyListXMLFormat_v1_0,nil),_1a);
  63. }
  64. }),new objj_method(sel_getUid("setString:forType:"),function(_1b,_1c,_1d,_1e){
  65. with(_1b){
  66. return objj_msgSend(_1b,"setPropertyList:forType:",_1d,_1e);
  67. }
  68. }),new objj_method(sel_getUid("availableTypeFromArray:"),function(_1f,_20,_21){
  69. with(_1f){
  70. return objj_msgSend(_types,"firstObjectCommonWithArray:",_21);
  71. }
  72. }),new objj_method(sel_getUid("types"),function(_22,_23){
  73. with(_22){
  74. return _types;
  75. }
  76. }),new objj_method(sel_getUid("changeCount"),function(_24,_25){
  77. with(_24){
  78. return _changeCount;
  79. }
  80. }),new objj_method(sel_getUid("dataForType:"),function(_26,_27,_28){
  81. with(_26){
  82. var _29=objj_msgSend(_provided,"objectForKey:",_28);
  83. if(_29){
  84. return _29;
  85. }
  86. var _2a=objj_msgSend(_owners,"objectForKey:",_28);
  87. if(_2a){
  88. objj_msgSend(_2a,"pasteboard:provideDataForType:",_26,_28);
  89. ++_changeCount;
  90. return objj_msgSend(_provided,"objectForKey:",_28);
  91. }
  92. return nil;
  93. }
  94. }),new objj_method(sel_getUid("propertyListForType:"),function(_2b,_2c,_2d){
  95. with(_2b){
  96. var _2e=objj_msgSend(_2b,"dataForType:",_2d);
  97. if(_2e){
  98. return objj_msgSend(CPPropertyListSerialization,"propertyListFromData:format:errorDescription:",_2e,CPPropertyListXMLFormat_v1_0,nil);
  99. }
  100. return nil;
  101. }
  102. }),new objj_method(sel_getUid("stringForType:"),function(_2f,_30,_31){
  103. with(_2f){
  104. return objj_msgSend(_2f,"propertyListForType:",_31);
  105. }
  106. }),new objj_method(sel_getUid("_generateStateUID"),function(_32,_33){
  107. with(_32){
  108. var _34=32;
  109. _stateUID="";
  110. while(_34--){
  111. _stateUID+=FLOOR(RAND()*16).toString(16).toUpperCase();
  112. }
  113. return _stateUID;
  114. }
  115. }),new objj_method(sel_getUid("_stateUID"),function(_35,_36){
  116. with(_35){
  117. return _stateUID;
  118. }
  119. })]);
  120. class_addMethods(_3,[new objj_method(sel_getUid("initialize"),function(_37,_38){
  121. with(_37){
  122. if(_37!=objj_msgSend(CPPasteboard,"class")){
  123. return;
  124. }
  125. objj_msgSend(_37,"setVersion:",1);
  126. _1=objj_msgSend(CPDictionary,"dictionary");
  127. }
  128. }),new objj_method(sel_getUid("generalPasteboard"),function(_39,_3a){
  129. with(_39){
  130. return objj_msgSend(CPPasteboard,"pasteboardWithName:",CPGeneralPboard);
  131. }
  132. }),new objj_method(sel_getUid("pasteboardWithName:"),function(_3b,_3c,_3d){
  133. with(_3b){
  134. var _3e=objj_msgSend(_1,"objectForKey:",_3d);
  135. if(_3e){
  136. return _3e;
  137. }
  138. _3e=objj_msgSend(objj_msgSend(CPPasteboard,"alloc"),"_initWithName:",_3d);
  139. objj_msgSend(_1,"setObject:forKey:",_3e,_3d);
  140. return _3e;
  141. }
  142. })]);