Adobe.com
Contents Suites Classes Class Index Member Index

SPRuntme.h

Go to the documentation of this file.
00001 /***********************************************************************/
00002 /*                                                                     */
00003 /* SPRuntme.h                                                          */
00004 /*                                                                     */
00005 /* ADOBE SYSTEMS INCORPORATED                                          */
00006 /* Copyright 1995-2007 Adobe Systems Incorporated.                     */
00007 /* All Rights Reserved.                                                */
00008 /*                                                                     */
00009 /* NOTICE:  Adobe permits you to use, modify, and distribute this file */
00010 /* in accordance with the terms of the Adobe license agreement         */
00011 /* accompanying it. If you have received this file from a source other */
00012 /* than Adobe, then your use, modification, or distribution of it      */
00013 /* requires the prior written permission of Adobe.                     */
00014 /*                                                                     */
00015 /* Patents Pending                                                     */
00016 /*                                                                     */
00017 /*                                                                     */
00018 /***********************************************************************/
00019 
00020 #ifndef __SPRuntime__
00021 #define __SPRuntime__
00022 
00023 
00024 /*******************************************************************************
00025  **
00026  **     Imports
00027  **
00028  **/
00029 
00030 #include "SPTypes.h"
00031 #include "SPAdapts.h"
00032 #include "SPFiles.h"
00033 #include "SPPlugs.h"
00034 #include "SPStrngs.h"
00035 #include "SPSuites.h"
00036 #include "SPStrngs.h"
00037 
00038 #include "SPHeaderBegin.h"
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 
00045 /*******************************************************************************
00046  **
00047  **     Constants
00048  **
00049  **/
00050 
00051 #define kSPRuntimeSuite                                 "SP Runtime Suite"
00052 #define kSPRuntimeSuiteVersion6             6
00053 #ifdef WIN_ENV
00054 #define kSPRuntimeSuiteVersion7             7
00055 #define kSPRuntimeSuiteVersion              kSPRuntimeSuiteVersion7
00056 #elif defined(MAC_ENV)
00057 #define kSPRuntimeSuiteVersion              kSPRuntimeSuiteVersion6
00058 #elif defined(LINUX_ENV)
00059 #define kSPRuntimeSuiteVersion                          kSPRuntimeSuiteVersion6
00060 #endif
00061 
00062 #define SPPerfLoggingEnabled 1
00063 /*******************************************************************************
00064  **
00065  **     Types
00066  **
00067  **/
00068 
00069 /*      INTERNAL DOCS
00070  *      PICA makes callbacks into the host through the host procs. The host
00071  *      procs are filled in by the host and passed to Sweet Pea at SPInit().
00072  *
00073  *      hostData - data that is given back to each host proc when Sweet Pea
00074  *              calls it. Sweet Pea does nothing with it itself.
00075  *
00076  *      extAllocate - implementation of the Block Suite's AllocateBlock() routine.
00077  *              It is identical to ANSI C malloc(). It returns a pointer to the
00078  *              beginning of the allocated block or NULL.
00079  *
00080  *      extFree - implementation of the Block Suite's FreeBlock() routine. It is
00081  *              identical to ANSI C free(). Note that you can pass it NULL.
00082  *
00083  *      extReallocate - implementation of the Block Suite's ReallocateBlock()
00084  *              routine. It is identical to ANSI C realloc(). It returns a pointer
00085  *              to the resized block or NULL. Note that you can pass it NULL or a
00086  *              newSize of 0.
00087  *  extSubAllocate, extSubFree, extSubReallocate- alternate memory allocation routines 
00088  *      intAllocate, intFree, intReallocate - routines used by Sweet Pea for
00089  *              its own memory needs. You may want to allocate blocks differently
00090  *              with plug-ins and Sweet Pea. Plug-ins are unbounded in their memory
00091  *              needs, while Sweet Pea's memory usage can be approximated.
00092  *
00093  *      startupNotify - called as each plug-in is started up. This is intended
00094  *              as a way to tell the user what's happening during start up.
00095  *              Note that plug-ins may start up at any time, not just during
00096  *              SPStartupPlugins().
00097  *
00098  *      shutdownNotify - called just before and after each plug-in is shut down.
00099  *              Also intended as a way to let users know what's going on.
00100  *
00101  *      assertTrap - called when a fatal assert is triggered. Sweet Pea does
00102  *              not expect execution to continue after an assert.
00103  *
00104  *      throwTrap - called when an internal error is thrown. This can be used
00105  *              during debugging to catch errors as they happen. It should return
00106  *              to allow Sweet Pea to handle the error.
00107  *
00108  *
00109  *      To aid in getting Sweet Pea up and running quickly, you can set any of
00110  *      these to NULL and Sweet Pea will use a default implementation. However:
00111  *      you cannot mix your implementations of the memory routines with
00112  *      Sweet Pea's defaults.
00113  *
00114  *
00115  *      The string pool functions replace the default routines used internally
00116  *      and exported by the Strings suite.  Because they are exported, the behaviors
00117  *      listed below should be followed.
00118  *
00119  *      allocateStringPool - creates a new string pool instance. The host app and
00120  *              Sweet Pea have a string pool which can be used by a plug-in, or a plug-in
00121  *              can create its own.  See the notes in SPStrngs.h on how the pool is
00122  *              implemented.
00123  *              The function should return kSPNoError if the pool is allocated successfully
00124  *              or kSPOutOfMemoryError if allocation fails.
00125  *
00126  *      freeStringPool - disposes of the string pool and any associated memory.  The
00127  *              function should return kSPNoError
00128  *
00129  *      makeWString - the string pool keeps a list of added strings. When a new string is
00130  *              added with MakeWString(), the routine checks to see if it is already in the
00131  *              pool.  If so, the address of the string instance in the pool is returned.  If
00132  *              not, it will add it to the pool and return the address of the newly
00133  *              created string instance.  The behavior is:
00134  *
00135  *                      if ( string == NULL )
00136  *                                      *wString = NULL;
00137  *                                      returns kSPNoError;
00138  *                      else if ( string in string pool )
00139  *                                      *wString = found string;
00140  *                                      returns kSPNoError;
00141  *                      else add string
00142  *                              if successful
00143  *                                      *wString = new string;
00144  *                                      returns kSPNoError;
00145  *                              else
00146  *                                      *wString = nil
00147  *                                      returns kSPOutOfMemoryError
00148  *
00149  *      appStringPool - if the host application has already allocated a string pool to use,
00150  *              it's reference should be passed here.  If this value is NULL, Sweet Pea will
00151  *              allocate the pool when initialized and dispose of it at termination.
00152  *
00153  *      filterEvent - a function called for each event allowing the host to cancel it.
00154  *              The event type is indicative of what the filter is to do.  A  file validation
00155  *              is called before a directory entry is added to the file list (kAddFile).
00156  *              A plug-in validation before a file is checked for PiPL information (kAddPlugin);
00157  *              the host might examine the file name/type to determine whether it should be added.
00158  *              For these 'add' events the return value is TRUE if the item should be skipped
00159  *              or FALSE if should be should be added. The default filter proc, used (if NULL)
00160  *              is passed, will skip files/folders in ( ).
00161  *              The other event is kSuitesAvailable.  It is called when the last suite adding
00162  *              plug-in (as determined by available PiPL information) has been added.  This is
00163  *              a point at which the host can cancel the startup process; for instance, if the host
00164  *              requires a suite from a plug-in, this is the time to check for it.  If the
00165  *              host returns TRUE, the startup process continues.  If it returns FALSE, the
00166  *              plug-in startup is canceled and the host would likely terminate or startup in
00167  *              an alternate manner.
00168  *
00169  *      overrideAddPlugins - if supplied, SP will call the host to create the runtime
00170  *              plug-in list.  This occurs at SPStartupPlugins().  The function takes no parameters
00171  *              as it is up to the host to determine how to do this.  For instance, the host can do
00172  *              this from cached data or, as SP would, from the file list.  A returned error will
00173  *              stop the plug-in startup process.
00174  *
00175  *      overrideStartup - a function called for each SP2 plug-in before it is sent the
00176  *              startup message.  If the host returns FALSE, SP will startup the plug-in normal.
00177  *              If the host returns true, it is assumed that the host has handled the startup
00178  *              for the plug-in, so SP will not do anything for the plug-in.  This is intended
00179  *              to be used with a plug-in caching scheme.
00180  *              The host would be responsible, for instance, for defining the cacheable
00181  *              information in the PiPL, adding it when the callback is made, and later issuing
00182  *              a startup message when the plug-in is actually needed (e.g. when a menu item
00183  *              is selected.)  Two notes: don't forget to SetPluginStarted(), and make sure
00184  *              to use a string pooled char* to kSPInterfaceCaller and kSPInterfaceStartupSelector.
00185  *
00186  *      resolveLink - Windows only.  If the search for plug-ins is to recurse sub-folders,
00187  *              the host needs to supply this routine.  When a .lnk file is encountered, the
00188  *              resolveLink host callback function will be called and should return a resolved path.
00189  *              This is a host callback due to OLE issues such as initialization, which the SP
00190  *              library does not currently handle.  If it returns an error code, the result will
00191  *              be ignored.
00192  *
00193  *      getPluginAccess - Allows the host to set the plug-in access information.  This would
00194  *              be used if, for instance, the host kept its own plug-in list (ala, Photoshop), but
00195  *              still needed these to be compatible with SPPlugins (e.g. whose accesses are used by ADM)
00196  *
00197  *      memoryIsCritical - Mac only.  Allows the host to indicate that memory is in a critical state
00198  *              (really low, but can't be purged because you are, say, shutdown.)
00199  *              If so and the plug-in load target heap is the app heap, when a plug-in fails to load
00200  *              SP will then try to load the plug-in into the system heap
00201  */
00202 
00203 /* These are passed in startup and shutdown host notify procs and the filter file proc. */
00207 typedef enum {
00210         kAddFile,                               /*      Internal: for filter file, received before a file is added to a file list, notifyData is a pointer to the SPPlatformFileSpecification */
00213         kAddPlugin,                             /*      Internal: for filter file, received before a file is checked to see if it is a plugin, notifyData is the files SPFileRef */
00216         kSetMessage,
00218         kSuitesAvailable,               /*  Internal: used only by event filter to allow host to check for suites it requires, notifyDatais NULL */
00220         kError,                                 /*      Internal: notifyData is SPErrorDataPtr*/
00223         kStartingupPlugin,              /*  Internal: for filter file, received before a file is checked to see if it is a plugin, notifyData is the files SPFileRef */
00226         kPreShutdownPlugin,
00229         kPostShutdownPlugin,
00231         kNoEvent = 0xffffffff
00232  } NotifyEvent;
00233 
00235 typedef void *(*SPAllocateProc)( size_t size, void *hostData );
00237 typedef void (*SPFreeProc)( void *block, void *hostData );
00239 typedef void *(*SPReallocateProc)( void *block, size_t newSize, void *hostData );
00248 typedef void (*SPStartupNotifyProc)( NotifyEvent event, void *notifyData, void *hostData );
00256 typedef void (*SPShutdownNotifyProc)( NotifyEvent event, void *notifyData, void *hostData );
00258 typedef void (*SPAssertTrapProc)( const char *failMessage, void *hostData );
00260 typedef void (*SPThrowTrapProc)( SPErr error, void *hostData );
00262 typedef void (*SPDebugTrapProc)( const char *debugMessage, void *hostData );
00263 
00264 typedef void (*SPWarningProc)(const char *warningMessage, void *hostData);
00265 
00267 typedef SPAPI SPErr (*SPAllocateStringPoolProc)( SPStringPoolRef *pool );
00269 typedef SPAPI SPErr (*SPFreeStringPoolProc)( SPStringPoolRef stringPool );
00271 typedef SPAPI SPErr (*SPMakeWStringProc)( SPStringPoolRef stringPool, const char *string,
00272                         const char **wString );
00273 
00274 #if     !defined(IOS_ENV)
00275 
00276 typedef SPAPI SPErr (*SPGetHostAccessInfoProc)( SPPlatformAccessInfo *spHostAccessInfo );
00277 #endif  // !defined(IOS_ENV)
00278 
00280 typedef SPAPI SPBoolean (*SPFilterEventProc)( NotifyEvent event, const void *eventData );
00282 typedef SPAPI SPErr (*SPAddPluginsProc)( void );
00284 typedef SPAPI SPBoolean (*SPOverrideStartupProc)( SPPluginRef currentPlugin );
00285 
00286 
00287 
00288 #ifdef WIN_ENV
00289 
00290 typedef SPAPI SPErr (*SPResolveLinkProc)(const char *shortcutFile, char *resolvedPath);
00291 typedef SPAPI SPErr (*SPResolveLinkProcW)(const wchar_t*shortcutFile, wchar_t *resolvedPath);
00292 #endif
00293     
00294 typedef SPAPI SPErr (*SPWideCharToPlatform)(char* destination, size_t dstSizeBytes, const ai::uint16*  src, size_t srcWcharCount);
00295 typedef SPAPI SPErr (*SPPlatformToWideChar)(ai::uint16* destination, size_t dstCharCount, const char* src, size_t srcSizeBytes);
00296 
00298 typedef SPAPI SPErr (*GetNativePluginAccessProc)(SPPluginRef plugin, SPAccessRef *access);
00299 
00301 typedef SPAPI SPBoolean (*MemoryIsCriticalProc)( void );
00302 
00303 #if SPPerfLoggingEnabled
00304 //Host should start timer at their end, can choose to send its data in hostLogData
00305 typedef SPAPI void (*SPPerfLogTimerStart)(void **hostLogData, SPBoolean pauseAtStart);
00306 typedef SPAPI void(*SPPerfLogTimerPause)(void *hostLogData);
00307 typedef SPAPI void(*SPPerfLogTimerPlay)(void *hostLogData);
00308 //Host should log time with given strings
00309 typedef SPAPI void (*SPPerfLogPut)(void *hostLogData, const char* logString1, const char* logString2);
00310 typedef SPAPI void(*SPPerfLogPutWithGivenTime)(ai::int64 givenTime, const char* logString1, const char* logString2);
00311 typedef SPAPI ai::int64(*SPGetElapsedMicroSeconds)(void *hostLogData);
00312 //Give opportunity to host to clear its data
00313 typedef SPAPI void(*SPPerfLogTimerDestroy)(void *hostLogData);
00314 #endif
00315 
00319 typedef struct SPHostProcs {
00320 
00321         void *hostData;
00322 
00323         SPAllocateProc extAllocate;
00324         SPFreeProc extFree;
00325         SPReallocateProc extReallocate;
00326 
00327         SPAllocateProc intAllocate;
00328         SPFreeProc intFree;
00329         SPReallocateProc intReallocate;
00331         SPStartupNotifyProc startupNotify;
00333         SPShutdownNotifyProc shutdownNotify;
00334 
00335         SPAssertTrapProc assertTrap;
00336         SPThrowTrapProc throwTrap;
00337         SPDebugTrapProc debugTrap;
00338         SPWarningProc   warningProc;
00339 
00340         SPAllocateStringPoolProc allocateStringPool;
00341         SPFreeStringPoolProc freeStringPool;
00342         SPMakeWStringProc makeWString;
00343         SPStringPoolRef appStringPool;
00344 
00345         SPFilterEventProc filterEvent;
00346         SPAddPluginsProc overrideAddPlugins;
00347         SPOverrideStartupProc overridePluginStartup;
00348 
00349 #ifdef WIN_ENV
00350         SPResolveLinkProc resolveLink;
00351 #endif
00352 
00353         GetNativePluginAccessProc getPluginAccess;
00354 
00355 #ifdef MAC_ENV
00356         // enable second-chance plugin loading for success-critical situations
00357         MemoryIsCriticalProc memoryIsCritical;
00358 #endif
00359 
00360         SPAllocateProc extSubAllocate; //alternate allocation mechanism: Suballocation
00361         SPFreeProc extSubFree;
00362         SPReallocateProc extSubReallocate;
00363 
00364         //Do not insert in the middle as Photoshop Adapter's SPRuntime interface's order will become different
00365 #ifdef WIN_ENV
00366         SPResolveLinkProcW resolveLinkW;
00367 #endif
00368         SPWideCharToPlatform wideCharToPlatform;
00369         SPPlatformToWideChar platformToWideChar;
00370 #if SPPerfLoggingEnabled
00371         SPPerfLogTimerStart startPerflog;
00372         SPPerfLogTimerPause pausePerfLogTimer;
00373         SPPerfLogTimerPlay playPerfLogTimer;
00374         SPPerfLogPut putPerfLog;
00375         SPPerfLogPutWithGivenTime putPerfLogWithGivenTime;
00376         SPGetElapsedMicroSeconds getElapsedMicroSeconds;
00377         SPPerfLogTimerDestroy clearHostLogData;
00378 #endif
00379 } SPHostProcs;
00380 
00381 
00382 /*******************************************************************************
00383  **
00384  **     Suite
00385  **
00386  **/
00394 typedef struct SPRuntimeSuite {
00399         SPAPI SPErr (*GetRuntimeStringPool)( SPStringPoolRef *stringPool );
00404         SPAPI SPErr (*GetRuntimeSuiteList)( SPSuiteListRef *suiteList );
00409         SPAPI SPErr (*GetRuntimeFileList)( SPFileListRef *fileList );
00414         SPAPI SPErr (*GetRuntimePluginList)( SPPluginListRef *pluginList );
00419         SPAPI SPErr (*GetRuntimeAdapterList)( SPAdapterListRef *adapterList );
00430         SPAPI SPErr (*GetRuntimeHostProcs)( SPHostProcs **hostProcs );
00435         SPAPI SPErr (*GetRuntimePluginsFolder)( SPPlatformFileReference *pluginFolder );
00440         SPAPI SPErr (*GetRuntimeHostFileRef)( SPPlatformFileReference *hostFileSpec );
00441 } SPRuntimeSuite;
00442 
00443 
00445 SPAPI SPErr SPGetRuntimeStringPool( SPStringPoolRef *stringPool );
00447 SPAPI SPErr SPGetRuntimeSuiteList( SPSuiteListRef *suiteList );
00449 SPAPI SPErr SPGetRuntimeFileList( SPFileListRef *fileList );
00451 SPAPI SPErr SPGetRuntimePluginList( SPPluginListRef *pluginList );
00453 SPAPI SPErr SPGetRuntimeAdapterList( SPAdapterListRef *adapterList );
00455 SPAPI SPErr SPGetRuntimeHostProcs( SPHostProcs **hostProcs );
00457 SPAPI SPErr SPGetRuntimePluginsFolder( SPPlatformFileReference *pluginFolder );
00459 SPAPI SPErr SPSetRuntimePluginsFolder( SPPlatformFileReference *pluginFolder );
00461 SPAPI SPErr SPGetRuntimeHostFileRef( SPPlatformFileReference *hostFileSpec );
00462 #ifdef WIN_ENV
00463 
00464         SPAPI SPErr SPGetRuntimePluginsFolder_v5( SPPlatformFileSpecification *pluginFolder );
00466         SPAPI SPErr SPGetRuntimeHostFileRef_v5( SPPlatformFileSpecification *hostFileSpec );
00467 #endif
00468 
00469 typedef struct
00470 {
00471         SPAPI SPErr (*SPAcquireSuiteFunc)( SPSuiteListRef suiteList, const char *name, ai::int32 apiVersion, ai::int32 internalVersion, const void **suiteProcs );
00472         SPAPI SPErr (*SPReleaseSuiteFunc)( SPSuiteListRef suiteList, const char *name, ai::int32 apiVersion, ai::int32 internalVersion );
00473         SPErr (*spAllocateBlockFunc)( SPAllocateProc allocateProc, size_t size, const char *debug, void **block );
00474         SPErr (*spFreeBlockFunc)( SPFreeProc freeProc, void *block );
00475         SPErr (*spReallocateBlockFunc)( SPReallocateProc reallocateProc, void *block, size_t newSize, const char *debug, void **newblock );
00476         SPHostProcs *gProcs;
00477 } SPBasicFuncStruct;
00478 
00480 void SetUpBasicFuncs(SPBasicFuncStruct *inStruct);
00481 
00482 #ifdef __cplusplus
00483 }
00484 #endif
00485 
00486 #include "SPHeaderEnd.h"
00487 
00488 #endif


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2014 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks