home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWSemEvt / PRSIGlue.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  15.1 KB  |  514 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PRSIGlue.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef PRSIGLUE_H
  11. #include "PRSIGlue.h"
  12. #endif
  13.  
  14. #ifndef PRSLGLTY_H
  15. #include "PRSIGlTy.h"
  16. #endif
  17.  
  18. #ifndef FWDEBUG_H
  19. #include "FWDebug.h"
  20. #endif
  21.  
  22. #ifndef FWSEMINT_H
  23. #include "FWSemInt.h"
  24. #endif
  25.  
  26. #ifndef FWAPLEVT_H
  27. #include "FWAplEvt.h"
  28. #endif
  29.  
  30. #ifdef FW_DEBUG
  31. #define FW_kSIInvalidException "Your mother temporarily wears army boots"
  32. #endif
  33.  
  34. // ----- OpenDoc Includes -----
  35.  
  36. #ifndef SOM_Module_OpenDoc_Errors_defined
  37. #include <ErrorDef.xh>
  38. #endif
  39.  
  40. //========================================================================================
  41. //    Runtime Informations
  42. //========================================================================================
  43.  
  44. #ifdef FW_BUILD_MAC    
  45. #pragma segment fwsemevt
  46. #endif
  47.  
  48. //========================================================================================
  49. // SOM -> C++ Glue Declarations
  50. //========================================================================================
  51.  
  52. FW_EXTERN_C_BEGIN    
  53.  
  54. static FW_PlatformError FW_PrivCallEventHandlerGlue(Environment* ev, FW_CSemanticInterface* semInt,
  55.                                         ODAppleEvent* theODAppleEvent, ODAppleEvent* reply);
  56.                             
  57. static FW_PlatformError FW_PrivCallCoercionHandlerGlue(Environment* ev, FW_CSemanticInterface* semInt,
  58.                                             ODDesc* theODDesc, ODDescType toType,
  59.                                             ODDesc* theResult);
  60.                                 
  61. static FW_PlatformError FW_PrivCallPredispatchProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  62.                                             ODAppleEvent* theODAppleEvent, ODAppleEvent* reply);
  63.  
  64. static FW_PlatformError FW_PrivCallObjectAccessorGlue(Environment* ev, FW_CSemanticInterface* semInt,
  65.                                         ODDescType desiredClass, ODOSLToken* container,
  66.                                         ODDescType containerClass, ODDescType form,
  67.                                         ODDesc* selectionData, ODOSLToken* value);
  68.                                 
  69. static FW_PlatformError FW_PrivCallCompareProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  70.                                         ODDescType oper, ODOSLToken* obj1,
  71.                                         ODOSLToken* obj2, ODBoolean* result);
  72.  
  73. static FW_PlatformError FW_PrivCallCountProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  74.                                     ODDescType desiredType, ODDescType containerClass,
  75.                                     ODOSLToken* container, ODSLong* result);
  76.                             
  77. static FW_PlatformError FW_PrivCallDisposeTokenProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  78.                                     ODOSLToken* unneededToken);
  79.  
  80. static FW_PlatformError FW_PrivCallGetErrDescProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  81.                                         ODDesc** errDesc);
  82.                                 
  83. static FW_PlatformError  FW_PrivCallGetMarkTokenProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  84.                                             ODOSLToken* dContainerToken, ODDescType containerClass,
  85.                                             ODOSLToken* result);
  86.                                     
  87. static FW_PlatformError FW_PrivCallMarkProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  88.                                     ODOSLToken* dToken, ODOSLToken* markToken,
  89.                                     ODSLong index);
  90.  
  91. static FW_PlatformError FW_PrivCallAdjustMarksProcGlue(Environment* ev, FW_CSemanticInterface* semInt,
  92.                                         ODSLong newStart, ODSLong newStop, ODOSLToken* markToken);
  93.  
  94. FW_EXTERN_C_END
  95.  
  96. //========================================================================================
  97. // Static Definitions
  98. //========================================================================================
  99.  
  100. //----------------------------------------------------------------------------------------
  101. // Routine Descriptors
  102. //----------------------------------------------------------------------------------------
  103.  
  104. static RoutineDescriptor priv_rdCallEventHandler = FW_RoutDesc_CallEventHandler(FW_PrivCallEventHandlerGlue);
  105. static RoutineDescriptor priv_rdCallCoercionHandler = FW_RoutDesc_CallCoercionHandler(FW_PrivCallCoercionHandlerGlue);
  106. static RoutineDescriptor priv_rdCallPredispatchProc = FW_RoutDesc_CallPredispatchProc(FW_PrivCallPredispatchProcGlue);
  107. static RoutineDescriptor priv_rdCallObjectAccessorProc = FW_RoutDesc_CallObjectAccessorProc(FW_PrivCallObjectAccessorGlue);
  108. static RoutineDescriptor priv_rdCallCompareProc = FW_RoutDesc_CallCompareProc(FW_PrivCallCompareProcGlue);
  109. static RoutineDescriptor priv_rdCallCountProc = FW_RoutDesc_CallCountProc(FW_PrivCallCountProcGlue);
  110. static RoutineDescriptor priv_rdCallDisposeTokenProc = FW_RoutDesc_CallDisposeTokenProc(FW_PrivCallDisposeTokenProcGlue);
  111. static RoutineDescriptor priv_rdCallGetErrDescProc = FW_RoutDesc_CallGetErrDescProc(FW_PrivCallGetErrDescProcGlue);
  112. static RoutineDescriptor priv_rdCallGetMarkTokenProc = FW_RoutDesc_CallGetMarkTokenProc(FW_PrivCallGetMarkTokenProcGlue);
  113. static RoutineDescriptor priv_rdCallMarkProc = FW_RoutDesc_CallMarkProc(FW_PrivCallMarkProcGlue);
  114. static RoutineDescriptor priv_rdCallAdjustMarksProc = FW_RoutDesc_CallAdjustMarksProc(FW_PrivCallAdjustMarksProcGlue);    
  115.  
  116. //----------------------------------------------------------------------------------------
  117. // Callback Pointer Block
  118. //----------------------------------------------------------------------------------------
  119.  
  120. static FW_SSemIntGlueProcs privSemanticInterfaceGlueProcs = {
  121.                 &priv_rdCallEventHandler, &priv_rdCallCoercionHandler, &priv_rdCallPredispatchProc, 
  122.                 &priv_rdCallObjectAccessorProc, &priv_rdCallCompareProc, &priv_rdCallCountProc, 
  123.                 &priv_rdCallDisposeTokenProc, &priv_rdCallGetErrDescProc, &priv_rdCallGetMarkTokenProc, 
  124.                 &priv_rdCallMarkProc, &priv_rdCallAdjustMarksProc };
  125.         
  126. //========================================================================================
  127. // Exported Functions
  128. //========================================================================================
  129.  
  130. //----------------------------------------------------------------------------------------
  131. // FW_PrivGetSemanticInterfaceGlue
  132. //----------------------------------------------------------------------------------------
  133.  
  134. FW_SSemIntGlueProcs* FW_PrivGetSemanticInterfaceGlue()
  135. {
  136.     return &privSemanticInterfaceGlueProcs;
  137. }
  138.  
  139. //========================================================================================
  140. // Private SOM -> C++ Glue
  141. //========================================================================================
  142.  
  143. //----------------------------------------------------------------------------------------
  144. // FW_PrivCallEventHandlerGlue
  145. //----------------------------------------------------------------------------------------
  146.  
  147. static FW_PlatformError FW_PrivCallEventHandlerGlue(Environment* ev, 
  148.                                 FW_CSemanticInterface* semInt,
  149.                                 ODAppleEvent* theODAppleEvent,
  150.                                 ODAppleEvent* reply)
  151. {
  152.     FW_PlatformError error = FW_xNoError;
  153.     
  154.     FW_TRY
  155.     {
  156.         FW_CAppleEvent localEvent(theODAppleEvent);
  157.         FW_CAppleEvent localReply(reply);
  158.         
  159.         semInt->CallEventHandler(ev, localEvent, localReply);
  160.     }
  161.     FW_CATCH_BEGIN
  162.     FW_CATCH_REFERENCE(FW_XException, exception)
  163.     {
  164.         error = exception.GetPlatformError();
  165.     }
  166. #ifdef FW_DEBUG
  167.     FW_CATCH_EVERYTHING()
  168.     {
  169.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  170.         error = kODErrUndefined;
  171.     }
  172. #endif
  173.     FW_CATCH_END
  174.     
  175.     return error;
  176. }
  177.  
  178. //----------------------------------------------------------------------------------------
  179. // FW_PrivCallCoercionHandlerGlue
  180. //----------------------------------------------------------------------------------------
  181.  
  182. static FW_PlatformError FW_PrivCallCoercionHandlerGlue(Environment* ev,
  183.                                     FW_CSemanticInterface* semInt,
  184.                                     ODDesc* theODDesc,
  185.                                     ODDescType toType,
  186.                                     ODDesc* theResult)
  187. {
  188.     FW_PlatformError error = FW_xNoError;
  189.     
  190.     FW_TRY
  191.     {
  192.         FW_CDesc localDesc(theODDesc);
  193.         FW_CDesc localResultDesc(theResult);
  194.         
  195.         semInt->CallCoercionHandler(ev, localDesc, toType, localResultDesc);
  196.     }
  197.     FW_CATCH_BEGIN
  198.     FW_CATCH_REFERENCE(FW_XException, exception)
  199.     {
  200.         error = exception.GetPlatformError();
  201.     }
  202. #ifdef FW_DEBUG
  203.     FW_CATCH_EVERYTHING()
  204.     {
  205.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  206.         error = kODErrUndefined;
  207.     }
  208. #endif
  209.     FW_CATCH_END
  210.     
  211.     return error;
  212. }
  213.  
  214. //----------------------------------------------------------------------------------------
  215. // FW_PrivCallPredispatchProcGlue
  216. //----------------------------------------------------------------------------------------
  217.  
  218. static FW_PlatformError FW_PrivCallPredispatchProcGlue(Environment* ev,
  219.                                     FW_CSemanticInterface* semInt,
  220.                                     ODAppleEvent* theODAppleEvent,
  221.                                     ODAppleEvent* reply)
  222. {
  223.     FW_PlatformError error = FW_xNoError;
  224.     
  225.     FW_TRY
  226.     {
  227.         FW_CAppleEvent localEvent(theODAppleEvent);
  228.         FW_CAppleEvent localReply(reply);
  229.         
  230.         semInt->CallPredispatchProc(ev, localEvent, localReply);
  231.     }
  232.     FW_CATCH_BEGIN
  233.     FW_CATCH_REFERENCE(FW_XException, exception)
  234.     {
  235.         error = exception.GetPlatformError();
  236.     }
  237. #ifdef FW_DEBUG
  238.     FW_CATCH_EVERYTHING()
  239.     {
  240.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  241.         error = kODErrUndefined;
  242.     }
  243. #endif
  244.     FW_CATCH_END
  245.     
  246.     return error;
  247. }
  248.  
  249. //----------------------------------------------------------------------------------------
  250. // FW_PrivCallObjectAccessorGlue
  251. //----------------------------------------------------------------------------------------
  252.  
  253. static FW_PlatformError FW_PrivCallObjectAccessorGlue(Environment* ev,
  254.                                 FW_CSemanticInterface* semInt,
  255.                                 ODDescType desiredClass,
  256.                                 ODOSLToken* container,
  257.                                 ODDescType containerClass,
  258.                                 ODDescType form,
  259.                                 ODDesc* selectionData,
  260.                                 ODOSLToken* value)
  261. {
  262.     FW_PlatformError error = FW_xNoError;
  263.     
  264.     FW_TRY
  265.     {
  266.         FW_CDesc localSelectionData(selectionData);
  267.         semInt->CallObjectAccessor(ev, desiredClass, container, containerClass, form, localSelectionData, value);
  268.     }
  269.     FW_CATCH_BEGIN
  270.     FW_CATCH_REFERENCE(FW_XException, exception)
  271.     {
  272.         error = exception.GetPlatformError();
  273.     }
  274. #ifdef FW_DEBUG
  275.     FW_CATCH_EVERYTHING()
  276.     {
  277.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  278.         error = kODErrUndefined;
  279.     }
  280. #endif
  281.     FW_CATCH_END
  282.     
  283.     return error;
  284. }
  285.                                 
  286. //----------------------------------------------------------------------------------------
  287. // FW_PrivCallCompareProcGlue
  288. //----------------------------------------------------------------------------------------
  289.  
  290. static FW_PlatformError FW_PrivCallCompareProcGlue(Environment* ev,
  291.                                 FW_CSemanticInterface* semInt,
  292.                                 ODDescType oper,
  293.                                 ODOSLToken* obj1,
  294.                                 ODOSLToken* obj2,
  295.                                 ODBoolean* result)
  296. {
  297.     FW_PlatformError error = FW_xNoError;
  298.     
  299.     FW_TRY
  300.     {
  301.         semInt->CallCompareProc(ev, oper, obj1, obj2, result);
  302.     }
  303.     FW_CATCH_BEGIN
  304.     FW_CATCH_REFERENCE(FW_XException, exception)
  305.     {
  306.         error = exception.GetPlatformError();
  307.     }
  308. #ifdef FW_DEBUG
  309.     FW_CATCH_EVERYTHING()
  310.     {
  311.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  312.         error = kODErrUndefined;
  313.     }
  314. #endif
  315.     FW_CATCH_END
  316.     
  317.     return error;
  318. }
  319.  
  320. //----------------------------------------------------------------------------------------
  321. // FW_PrivCallCountProcGlue
  322. //----------------------------------------------------------------------------------------
  323.  
  324. static FW_PlatformError FW_PrivCallCountProcGlue(Environment* ev,
  325.                             FW_CSemanticInterface* semInt,
  326.                             ODDescType desiredType,
  327.                             ODDescType containerClass,
  328.                             ODOSLToken* container,
  329.                             ODSLong* result)
  330. {
  331.     FW_PlatformError error = FW_xNoError;
  332.     
  333.     FW_TRY
  334.     {
  335.         semInt->CallCountProc(ev, desiredType, containerClass, container, result);
  336.     }
  337.     FW_CATCH_BEGIN
  338.     FW_CATCH_REFERENCE(FW_XException, exception)
  339.     {
  340.         error = exception.GetPlatformError();
  341.     }
  342. #ifdef FW_DEBUG
  343.     FW_CATCH_EVERYTHING()
  344.     {
  345.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  346.         error = kODErrUndefined;
  347.     }
  348. #endif
  349.     FW_CATCH_END
  350.     
  351.     return error;
  352. }
  353.                             
  354. //----------------------------------------------------------------------------------------
  355. // FW_PrivCallDisposeTokenProcGlue
  356. //----------------------------------------------------------------------------------------
  357.  
  358. static FW_PlatformError FW_PrivCallDisposeTokenProcGlue(Environment* ev,
  359.                                     FW_CSemanticInterface* semInt,
  360.                                     ODOSLToken* unneededToken)
  361. {
  362.     FW_PlatformError error = FW_xNoError;
  363.     
  364.     FW_TRY
  365.     {
  366.         semInt->CallDisposeTokenProc(ev, unneededToken);
  367.     }
  368.     FW_CATCH_BEGIN
  369.     FW_CATCH_REFERENCE(FW_XException, exception)
  370.     {
  371.         error = exception.GetPlatformError();
  372.     }
  373. #ifdef FW_DEBUG
  374.     FW_CATCH_EVERYTHING()
  375.     {
  376.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  377.         error = kODErrUndefined;
  378.     }
  379. #endif
  380.     FW_CATCH_END
  381.     
  382.     return error;
  383. }
  384.  
  385. //----------------------------------------------------------------------------------------
  386. // FW_PrivCallGetErrDescProcGlue
  387. //----------------------------------------------------------------------------------------
  388.  
  389. static FW_PlatformError FW_PrivCallGetErrDescProcGlue(Environment* ev,
  390.                                 FW_CSemanticInterface* semInt,
  391.                                 ODDesc** errDesc)
  392. {
  393.     FW_PlatformError error = FW_xNoError;
  394.     
  395.     FW_TRY
  396.     {
  397.         semInt->CallGetErrDescProc(ev, errDesc);
  398.     }
  399.     FW_CATCH_BEGIN
  400.     FW_CATCH_REFERENCE(FW_XException, exception)
  401.     {
  402.         error = exception.GetPlatformError();
  403.     }
  404. #ifdef FW_DEBUG
  405.     FW_CATCH_EVERYTHING()
  406.     {
  407.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  408.         error = kODErrUndefined;
  409.     }
  410. #endif
  411.     FW_CATCH_END
  412.     
  413.     return error;
  414. }
  415.                                 
  416. //----------------------------------------------------------------------------------------
  417. // FW_PrivCallGetMarkTokenProcGlue
  418. //----------------------------------------------------------------------------------------
  419.  
  420. static FW_PlatformError FW_PrivCallGetMarkTokenProcGlue(Environment* ev,
  421.                                     FW_CSemanticInterface* semInt,
  422.                                     ODOSLToken* dContainerToken,
  423.                                     ODDescType containerClass,
  424.                                     ODOSLToken* result)
  425. {
  426.     FW_PlatformError error = FW_xNoError;
  427.     
  428.     FW_TRY
  429.     {
  430.         semInt->CallGetMarkTokenProc(ev, dContainerToken, containerClass, result);
  431.     }
  432.     FW_CATCH_BEGIN
  433.     FW_CATCH_REFERENCE(FW_XException, exception)
  434.     {
  435.         error = exception.GetPlatformError();
  436.     }
  437. #ifdef FW_DEBUG
  438.     FW_CATCH_EVERYTHING()
  439.     {
  440.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  441.         error = kODErrUndefined;
  442.     }
  443. #endif
  444.     FW_CATCH_END
  445.     
  446.     return error;
  447. }
  448.                                     
  449. //----------------------------------------------------------------------------------------
  450. // FW_PrivCallMarkProcGlue
  451. //----------------------------------------------------------------------------------------
  452.  
  453. static FW_PlatformError FW_PrivCallMarkProcGlue(Environment* ev,
  454.                             FW_CSemanticInterface* semInt,
  455.                             ODOSLToken* dToken,
  456.                             ODOSLToken* markToken,
  457.                             ODSLong index)
  458. {
  459.     FW_PlatformError error = FW_xNoError;
  460.     
  461.     FW_TRY
  462.     {
  463.         semInt->CallMarkProc(ev, dToken, markToken, index);
  464.     }
  465.     FW_CATCH_BEGIN
  466.     FW_CATCH_REFERENCE(FW_XException, exception)
  467.     {
  468.         error = exception.GetPlatformError();
  469.     }
  470. #ifdef FW_DEBUG
  471.     FW_CATCH_EVERYTHING()
  472.     {
  473.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  474.         error = kODErrUndefined;
  475.     }
  476. #endif
  477.     FW_CATCH_END
  478.     
  479.     return error;
  480. }
  481.  
  482. //----------------------------------------------------------------------------------------
  483. // FW_PrivCallAdjustMarksProcGlue
  484. //----------------------------------------------------------------------------------------
  485.  
  486. static FW_PlatformError FW_PrivCallAdjustMarksProcGlue(Environment* ev,
  487.                                     FW_CSemanticInterface* semInt,
  488.                                     ODSLong newStart,
  489.                                     ODSLong newStop,
  490.                                     ODOSLToken* markToken)
  491. {
  492.     FW_PlatformError error = FW_xNoError;
  493.     
  494.     FW_TRY
  495.     {
  496.         semInt->CallAdjustMarksProc(ev, newStart, newStop, markToken);
  497.     }
  498.     FW_CATCH_BEGIN
  499.     FW_CATCH_REFERENCE(FW_XException, exception)
  500.     {
  501.         error = exception.GetPlatformError();
  502.     }
  503. #ifdef FW_DEBUG
  504.     FW_CATCH_EVERYTHING()
  505.     {
  506.         FW_DEBUG_MESSAGE(FW_kSIInvalidException);
  507.         error = kODErrUndefined;
  508.     }
  509. #endif
  510.     FW_CATCH_END
  511.     
  512.     return error;
  513. }
  514.