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 kSPRuntimeSuiteVersion5                 5
00053 #ifdef WIN_ENV
00054         #define kSPRuntimeSuiteVersion6         6
00055         #define kSPRuntimeSuiteVersion          kSPRuntimeSuiteVersion6
00056 #elif MAC_ENV
00057         #define kSPRuntimeSuiteVersion          kSPRuntimeSuiteVersion5
00058 #endif
00059 
00060 /*******************************************************************************
00061  **
00062  **     Types
00063  **
00064  **/
00065 
00066 /*      INTERNAL DOCS
00067  *      PICA makes callbacks into the host through the host procs. The host
00068  *      procs are filled in by the host and passed to Sweet Pea at SPInit().
00069  *
00070  *      hostData - data that is given back to each host proc when Sweet Pea
00071  *              calls it. Sweet Pea does nothing with it itself.
00072  *
00073  *      extAllocate - implementation of the Block Suite's AllocateBlock() routine.
00074  *              It is identical to ANSI C malloc(). It returns a pointer to the
00075  *              beginning of the allocated block or NULL.
00076  *
00077  *      extFree - implementation of the Block Suite's FreeBlock() routine. It is
00078  *              identical to ANSI C free(). Note that you can pass it NULL.
00079  *
00080  *      extReallocate - implementation of the Block Suite's ReallocateBlock()
00081  *              routine. It is identical to ANSI C realloc(). It returns a pointer
00082  *              to the resized block or NULL. Note that you can pass it NULL or a
00083  *              newSize of 0.
00084  *  extSubAllocate, extSubFree, extSubReallocate- alternate memory allocation routines 
00085  *      intAllocate, intFree, intReallocate - routines used by Sweet Pea for
00086  *              its own memory needs. You may want to allocate blocks differently
00087  *              with plug-ins and Sweet Pea. Plug-ins are unbounded in their memory
00088  *              needs, while Sweet Pea's memory usage can be approximated.
00089  *
00090  *      startupNotify - called as each plug-in is started up. This is intended
00091  *              as a way to tell the user what's happening during start up.
00092  *              Note that plug-ins may start up at any time, not just during
00093  *              SPStartupPlugins().
00094  *
00095  *      shutdownNotify - called as each plug-in is shut down. Also intended as
00096  *              a way to let users know what's going on.
00097  *
00098  *      assertTrap - called when a fatal assert is triggered. Sweet Pea does
00099  *              not expect execution to continue after an assert.
00100  *
00101  *      throwTrap - called when an internal error is thrown. This can be used
00102  *              during debugging to catch errors as they happen. It should return
00103  *              to allow Sweet Pea to handle the error.
00104  *
00105  *
00106  *      To aid in getting Sweet Pea up and running quickly, you can set any of
00107  *      these to NULL and Sweet Pea will use a default implementation. However:
00108  *      you cannot mix your implementations of the memory routines with
00109  *      Sweet Pea's defaults.
00110  *
00111  *
00112  *      The string pool functions replace the default routines used internally
00113  *      and exported by the Strings suite.  Because they are exported, the behaviors
00114  *      listed below should be followed.
00115  *
00116  *      allocateStringPool - creates a new string pool instance. The host app and
00117  *              Sweet Pea have a string pool which can be used by a plug-in, or a plug-in
00118  *              can create its own.  See the notes in SPStrngs.h on how the pool is
00119  *              implemented.
00120  *              The function should return kSPNoError if the pool is allocated successfully
00121  *              or kSPOutOfMemoryError if allocation fails.
00122  *
00123  *      freeStringPool - disposes of the string pool and any associated memory.  The
00124  *              function should return kSPNoError
00125  *
00126  *      makeWString - the string pool keeps a list of added strings. When a new string is
00127  *              added with MakeWString(), the routine checks to see if it is already in the
00128  *              pool.  If so, the address of the string instance in the pool is returned.  If
00129  *              not, it will add it to the pool and return the address of the newly
00130  *              created string instance.  The behavior is:
00131  *
00132  *                      if ( string == NULL )
00133  *                                      *wString = NULL;
00134  *                                      returns kSPNoError;
00135  *                      else if ( string in string pool )
00136  *                                      *wString = found string;
00137  *                                      returns kSPNoError;
00138  *                      else add string
00139  *                              if successful
00140  *                                      *wString = new string;
00141  *                                      returns kSPNoError;
00142  *                              else
00143  *                                      *wString = nil
00144  *                                      returns kSPOutOfMemoryError
00145  *
00146  *      appStringPool - if the host application has already allocated a string pool to use,
00147  *              it's reference should be passed here.  If this value is NULL, Sweet Pea will
00148  *              allocate the pool when initialized and dispose of it at termination.
00149  *
00150  *      filterEvent - a function called for each event allowing the host to cancel it.
00151  *              The event type is indicative of what the filter is to do.  A  file validation
00152  *              is called before a directory entry is added to the file list (kAddFile).
00153  *              A plug-in validation before a file is checked for PiPL information (kAddPlugin);
00154  *              the host might examine the file name/type to determine whether it should be added.
00155  *              For these 'add' events the return value is TRUE if the item should be skipped
00156  *              or FALSE if should be should be added. The default filter proc, used (if NULL)
00157  *              is passed, will skip files/folders in ( ).
00158  *              The other event is kSuitesAvailable.  It is called when the last suite adding
00159  *              plug-in (as determined by available PiPL information) has been added.  This is
00160  *              a point at which the host can cancel the startup process; for instance, if the host
00161  *              requires a suite from a plug-in, this is the time to check for it.  If the
00162  *              host returns TRUE, the startup process continues.  If it returns FALSE, the
00163  *              plug-in startup is canceled and the host would likely terminate or startup in
00164  *              an alternate manner.
00165  *
00166  *      overrideAddPlugins - if supplied, SP will call the host to create the runtime
00167  *              plug-in list.  This occurs at SPStartupPlugins().  The function takes no parameters
00168  *              as it is up to the host to determine how to do this.  For instance, the host can do
00169  *              this from cached data or, as SP would, from the file list.  A returned error will
00170  *              stop the plug-in startup process.
00171  *
00172  *      overrideStartup - a function called for each SP2 plug-in before it is sent the
00173  *              startup message.  If the host returns FALSE, SP will startup the plug-in normal.
00174  *              If the host returns true, it is assumed that the host has handled the startup
00175  *              for the plug-in, so SP will not do anything for the plug-in.  This is intended
00176  *              to be used with a plug-in caching scheme.
00177  *              The host would be responsible, for instance, for defining the cacheable
00178  *              information in the PiPL, adding it when the callback is made, and later issuing
00179  *              a startup message when the plug-in is actually needed (e.g. when a menu item
00180  *              is selected.)  Two notes: don't forget to SetPluginStarted(), and make sure
00181  *              to use a string pooled char* to kSPInterfaceCaller and kSPInterfaceStartupSelector.
00182  *
00183  *      resolveLink - Windows only.  If the search for plug-ins is to recurse sub-folders,
00184  *              the host needs to supply this routine.  When a .lnk file is encountered, the
00185  *              resolveLink host callback function will be called and should return a resolved path.
00186  *              This is a host callback due to OLE issues such as initialization, which the SP
00187  *              library does not currently handle.  If it returns an error code, the result will
00188  *              be ignored.
00189  *
00190  *      getPluginAccess - Allows the host to set the plug-in access information.  This would
00191  *              be used if, for instance, the host kept its own plug-in list (ala, Photoshop), but
00192  *              still needed these to be compatible with SPPlugins (e.g. whose accesses are used by ADM)
00193  *
00194  *      memoryIsCritical - Mac only.  Allows the host to indicate that memory is in a critical state
00195  *              (really low, but can't be purged because you are, say, shutdown.)
00196  *              If so and the plug-in load target heap is the app heap, when a plug-in fails to load
00197  *              SP will then try to load the plug-in into the system heap
00198  */
00199 
00200 /* These are passed in startup and shutdown host notify procs and the filter file proc. */
00204 typedef enum {
00207         kAddFile,                               /*      Internal: for filter file, received before a file is added to a file list, notifyData is a pointer to the SPPlatformFileSpecification */
00210         kAddPlugin,                             /*      Internal: for filter file, received before a file is checked to see if it is a plugin, notifyData is the files SPFileRef */
00213         kSetMessage,
00215         kSuitesAvailable,               /*  Internal: used only by event filter to allow host to check for suites it requires, notifyDatais NULL */
00217         kError,                                 /*      Internal: notifyData is SPErrorDataPtr*/
00220         kStartingupPlugin,              /*  Internal: for filter file, received before a file is checked to see if it is a plugin, notifyData is the files SPFileRef */
00222         kNoEvent = 0xffffffff
00223  } NotifyEvent;
00224 
00226 typedef void *(*SPAllocateProc)( size_t size, void *hostData );
00228 typedef void (*SPFreeProc)( void *block, void *hostData );
00230 typedef void *(*SPReallocateProc)( void *block, size_t newSize, void *hostData );
00239 typedef void (*SPStartupNotifyProc)( NotifyEvent event, void *notifyData, void *hostData );
00247 typedef void (*SPShutdownNotifyProc)( NotifyEvent event, void *notifyData, void *hostData );
00249 typedef void (*SPAssertTrapProc)( const char *failMessage, void *hostData );
00251 typedef void (*SPThrowTrapProc)( SPErr error, void *hostData );
00253 typedef void (*SPDebugTrapProc)( const char *debugMessage, void *hostData );
00254 
00256 typedef SPAPI SPErr (*SPAllocateStringPoolProc)( SPStringPoolRef *pool );
00258 typedef SPAPI SPErr (*SPFreeStringPoolProc)( SPStringPoolRef stringPool );
00260 typedef SPAPI SPErr (*SPMakeWStringProc)( SPStringPoolRef stringPool, const char *string,
00261                         const char **wString );
00262 
00263 #if     !defined(IOS_ENV)
00264 
00265 typedef SPAPI SPErr (*SPGetHostAccessInfoProc)( SPPlatformAccessInfo *spHostAccessInfo );
00266 #endif  // !defined(IOS_ENV)
00267 
00269 typedef SPAPI SPBoolean (*SPFilterEventProc)( NotifyEvent event, const void *eventData );
00271 typedef SPAPI SPErr (*SPAddPluginsProc)( void );
00273 typedef SPAPI SPBoolean (*SPOverrideStartupProc)( SPPluginRef currentPlugin );
00274 
00275 #ifdef WIN_ENV
00276 
00277 typedef SPAPI SPErr (*SPResolveLinkProc)(const char *shortcutFile, char *resolvedPath);
00278 typedef SPAPI SPErr (*SPResolveLinkProcW)(const wchar_t*shortcutFile, wchar_t *resolvedPath);
00279 #endif
00280     
00281 typedef SPAPI SPErr (*SPWideCharToPlatform)(char* destination, size_t dstSizeBytes, const ai::uint16*  src, size_t srcWcharCount);
00282 typedef SPAPI SPErr (*SPPlatformToWideChar)(ai::uint16* destination, size_t dstCharCount, const char* src, size_t srcSizeBytes);
00283 
00285 typedef SPAPI SPErr (*GetNativePluginAccessProc)(SPPluginRef plugin, SPAccessRef *access);
00286 
00288 typedef SPAPI SPBoolean (*MemoryIsCriticalProc)( void );
00289 
00294 typedef struct SPHostProcs {
00295 
00296         void *hostData;
00297 
00298         SPAllocateProc extAllocate;
00299         SPFreeProc extFree;
00300         SPReallocateProc extReallocate;
00301 
00302         SPAllocateProc intAllocate;
00303         SPFreeProc intFree;
00304         SPReallocateProc intReallocate;
00306         SPStartupNotifyProc startupNotify;
00308         SPShutdownNotifyProc shutdownNotify;
00309 
00310         SPAssertTrapProc assertTrap;
00311         SPThrowTrapProc throwTrap;
00312         SPDebugTrapProc debugTrap;
00313 
00314         SPAllocateStringPoolProc allocateStringPool;
00315         SPFreeStringPoolProc freeStringPool;
00316         SPMakeWStringProc makeWString;
00317         SPStringPoolRef appStringPool;
00318 
00319         SPFilterEventProc filterEvent;
00320         SPAddPluginsProc overrideAddPlugins;
00321         SPOverrideStartupProc overridePluginStartup;
00322 
00323 #ifdef WIN_ENV
00324         SPResolveLinkProc resolveLink;
00325 #endif
00326 
00327         GetNativePluginAccessProc getPluginAccess;
00328 
00329 #ifdef MAC_ENV
00330         // enable second-chance plugin loading for success-critical situations
00331         MemoryIsCriticalProc memoryIsCritical;
00332 #endif
00333 
00334         SPAllocateProc extSubAllocate; //alternate allocation mechanism: Suballocation
00335         SPFreeProc extSubFree;
00336         SPReallocateProc extSubReallocate;
00337 
00338         //Do not insert in the middle as Photoshop Adapter's SPRuntime interface's order will become different
00339 #ifdef WIN_ENV
00340         SPResolveLinkProcW resolveLinkW;
00341 #endif
00342         SPWideCharToPlatform wideCharToPlatform;
00343         SPPlatformToWideChar platformToWideChar;
00344 
00345 } SPHostProcs;
00346 
00347 
00348 /*******************************************************************************
00349  **
00350  **     Suite
00351  **
00352  **/
00360 typedef struct SPRuntimeSuite {
00365         SPAPI SPErr (*GetRuntimeStringPool)( SPStringPoolRef *stringPool );
00370         SPAPI SPErr (*GetRuntimeSuiteList)( SPSuiteListRef *suiteList );
00375         SPAPI SPErr (*GetRuntimeFileList)( SPFileListRef *fileList );
00380         SPAPI SPErr (*GetRuntimePluginList)( SPPluginListRef *pluginList );
00385         SPAPI SPErr (*GetRuntimeAdapterList)( SPAdapterListRef *adapterList );
00396         SPAPI SPErr (*GetRuntimeHostProcs)( SPHostProcs **hostProcs );
00401         SPAPI SPErr (*GetRuntimePluginsFolder)( SPPlatformFileReference *pluginFolder );
00406         SPAPI SPErr (*GetRuntimeHostFileRef)( SPPlatformFileReference *hostFileSpec );
00407 } SPRuntimeSuite;
00408 
00409 
00411 SPAPI SPErr SPGetRuntimeStringPool( SPStringPoolRef *stringPool );
00413 SPAPI SPErr SPGetRuntimeSuiteList( SPSuiteListRef *suiteList );
00415 SPAPI SPErr SPGetRuntimeFileList( SPFileListRef *fileList );
00417 SPAPI SPErr SPGetRuntimePluginList( SPPluginListRef *pluginList );
00419 SPAPI SPErr SPGetRuntimeAdapterList( SPAdapterListRef *adapterList );
00421 SPAPI SPErr SPGetRuntimeHostProcs( SPHostProcs **hostProcs );
00423 SPAPI SPErr SPGetRuntimePluginsFolder( SPPlatformFileReference *pluginFolder );
00425 SPAPI SPErr SPSetRuntimePluginsFolder( SPPlatformFileReference *pluginFolder );
00427 SPAPI SPErr SPGetRuntimeHostFileRef( SPPlatformFileReference *hostFileSpec );
00428 #ifdef WIN_ENV
00429 
00430         SPAPI SPErr SPGetRuntimePluginsFolder_v5( SPPlatformFileSpecification *pluginFolder );
00432         SPAPI SPErr SPGetRuntimeHostFileRef_v5( SPPlatformFileSpecification *hostFileSpec );
00433 #endif
00434 
00435 typedef struct
00436 {
00437         SPAPI SPErr (*SPAcquireSuiteFunc)( SPSuiteListRef suiteList, const char *name, ai::int32 apiVersion, ai::int32 internalVersion, const void **suiteProcs );
00438         SPAPI SPErr (*SPReleaseSuiteFunc)( SPSuiteListRef suiteList, const char *name, ai::int32 apiVersion, ai::int32 internalVersion );
00439         SPErr (*spAllocateBlockFunc)( SPAllocateProc allocateProc, size_t size, const char *debug, void **block );
00440         SPErr (*spFreeBlockFunc)( SPFreeProc freeProc, void *block );
00441         SPErr (*spReallocateBlockFunc)( SPReallocateProc reallocateProc, void *block, size_t newSize, const char *debug, void **newblock );
00442         SPHostProcs *gProcs;
00443 } SPBasicFuncStruct;
00444 
00446 void SetUpBasicFuncs(SPBasicFuncStruct *inStruct);
00447 
00448 #ifdef __cplusplus
00449 }
00450 #endif
00451 
00452 #include "SPHeaderEnd.h"
00453 
00454 #endif


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