📄 fauxcodec.cpp
字号:
result = CallComponentFunctionWithStorageProcInfo((Handle) storage, params, (ProcPtr)theProc, theProcInfo);
}
}
else if ( theProc == kCOMPONENT_NOERROR ) {
result = noErr;
}
}
#ifdef GET_DELEGATE_COMPONENT
else
return DelegateComponentCall(params, GET_DELEGATE_COMPONENT());
#endif
return result;
}
#elif C_DISPATCH_WITH_SWITCH
PASCAL_RTN ComponentResult COMPONENT_DISPATCH_ENTRY(ComponentParameters *params, COMPONENT_GLOBALS());
static ComponentFunctionUPP COMPONENTSELECTORLOOKUP(short selector_num);
PASCAL_RTN ComponentResult COMPONENT_DISPATCH_ENTRY( ComponentParameters *params, COMPONENT_GLOBALS() )
{
ComponentFunctionUPP theProc;
ComponentResult result = badComponentSelector;
theProc = COMPONENTSELECTORLOOKUP(params->what);
if (theProc) {
if ( (theProc != kCOMPONENT_ERROR) && (theProc != kCOMPONENT_NOERROR) ) {
result = CallComponentFunctionWithStorage((Handle) storage, params, theProc);
}
else if ( theProc == kCOMPONENT_NOERROR ) {
result = noErr;
}
}
#ifdef GET_DELEGATE_COMPONENT
else
result = DelegateComponentCall(params, GET_DELEGATE_COMPONENT());
#endif
return result;
}
#endif
#if C_DISPATCH_WITH_GLOBALS
typedef struct {
ComponentFunctionUPP theProc;
ProcInfoType theProcInfo;
} cdhDispatchInfoRecord;
typedef struct {
short rangeMax;
CDHCONST cdhDispatchInfoRecord *cdhDispatchInfoP;
} cdhRangeDispatchInfoRecord;
#define ComponentSelectorOffset(theOffset) enum {SelOffset = theOffset};
#define ComponentRangeCount(theCount) enum {RangeCount = theCount};
#define ComponentRangeShift(theShift) enum {RangeShift = theShift};
#define ComponentRangeMask(theMask) enum {RangeMask = cdh_GLUE2(0x,theMask)};
#define ComponentStorageType(theType)
#define ComponentDelegateByteOffset(theOffset)
#define StdComponentCall(procName) \
(ComponentFunctionUPP)ADD_BASENAME(procName), cdh_GLUE3(uppCallComponent,procName,ProcInfo),
#define ComponentCall(procName) \
(ComponentFunctionUPP)ADD_BASENAME(procName), cdh_GLUE3(COMPONENT_UPP_PREFIX(),procName,ProcInfo),
#define ComponentSubTypeCall(procName) \
(ComponentFunctionUPP)ADD_BASENAME(procName), cdh_GLUE3(COMPONENT_SUBTYPE_UPP_PREFIX(),procName,ProcInfo),
#define ComponentError(procName) kCOMPONENT_ERROR, 0,
#define StdComponentNoError(procName) kCOMPONENT_NOERROR, 0,
#define ComponentNoError(procName) kCOMPONENT_NOERROR, 0,
#define ComponentSubTypeNoError(procName) kCOMPONENT_NOERROR, 0,
#define ComponentDelegate(procName) kCOMPONENT_DELEGATE, 0,
#define ComponentRangeUnused(rangeNum) \
static CDHCONST cdhDispatchInfoRecord cdh_GLUE2(cdhDispatchInfo,rangeNum)[1] = { 0 }; \
enum {cdh_GLUE2(cdhDispatchMax,rangeNum) = 0};
#define ComponentRangeBegin(rangeNum) \
static CDHCONST cdhDispatchInfoRecord cdh_GLUE2(cdhDispatchInfo,rangeNum)[] = {
#define ComponentRangeEnd(rangeNum) \
}; \
enum {cdh_GLUE2(cdhDispatchMax,rangeNum) = sizeof(cdh_GLUE2(cdhDispatchInfo,rangeNum)) / sizeof(cdhDispatchInfoRecord)};
#define ComponentComment(theComment)
// define the static dispatch tables
#include COMPONENT_DISPATCH_FILE
#undef ComponentSelectorOffset
#undef ComponentRangeCount
#undef ComponentRangeShift
#undef ComponentRangeMask
#undef StdComponentCall
#undef ComponentCall
#undef ComponentSubTypeCall
#undef ComponentError
#undef StdComponentNoError
#undef ComponentNoError
#undef ComponentSubTypeNoError
#undef ComponentDelegate
#undef ComponentRangeUnused
#undef ComponentRangeBegin
#undef ComponentRangeEnd
#define ComponentSelectorOffset(theOffset)
#define ComponentRangeCount(theCount)
#define ComponentRangeShift(theShift)
#define ComponentRangeMask(theMask)
#define StdComponentCall(procName)
#define ComponentCall(procName)
#define ComponentSubTypeCall(procName)
#define ComponentError(procName)
#define StdComponentNoError(procName)
#define ComponentNoError(procName)
#define ComponentSubTypeNoError(procName)
#define ComponentDelegate(procName)
#define ComponentRangeUnused(rangeNum) \
{ 0, nil },
#define ComponentRangeBegin(rangeNum) \
{ cdh_GLUE2(cdhDispatchMax,rangeNum), cdh_GLUE2(cdhDispatchInfo,rangeNum) },
#define ComponentRangeEnd(rangeNum)
// define the static range tables (max per range and point to dispatch tables)
static CDHCONST cdhRangeDispatchInfoRecord cdhRangeDispatch[RangeCount+1] = {
#include COMPONENT_DISPATCH_FILE
};
ComponentFunctionUPP COMPONENTSELECTORLOOKUP(short selector_num, ProcInfoType *procInfo)
{
ProcInfoType pinfo = 0;
ComponentFunctionUPP result = kCOMPONENT_DELEGATE;
CDHCONST cdhDispatchInfoRecord *infoP = nil;
short theRange;
theRange = selector_num >> RangeShift;
if (theRange < 0) {
selector_num += SelOffset;
if (selector_num >= 0) {
infoP = &(cdhRangeDispatch[0].cdhDispatchInfoP)[selector_num];
}
} else {
if (theRange < RangeCount) {
selector_num &= RangeMask;
if (selector_num < cdhRangeDispatch[theRange+1].rangeMax)
infoP = &(cdhRangeDispatch[theRange+1].cdhDispatchInfoP)[selector_num];
}
}
if (infoP) {
*procInfo = infoP->theProcInfo;
result = infoP->theProc;
}
return result;
}
#elif C_DISPATCH_WITH_SWITCH
ComponentFunctionUPP COMPONENTSELECTORLOOKUP( short selector_num )
{
ComponentFunctionUPP aProc = (ComponentFunctionUPP) kCOMPONENT_DELEGATE;
#define ComponentSelectorOffset(theOffset)
#define case_ComponentCall(kPrefix,procName) case cdh_GLUE3(kPrefix,procName,Select): aProc = (ComponentFunctionUPP)ADD_BASENAME(procName); break;
#define StdComponentCall(procName) case_ComponentCall(kComponent,procName)
#define ComponentCall(procName) case_ComponentCall(COMPONENT_SELECT_PREFIX(),procName)
#define ComponentSubTypeCall(procName) case_ComponentCall(COMPONENT_SUBTYPE_SELECT_PREFIX(),procName)
#define case_ComponentNoError(kPrefix,procName) case cdh_GLUE3(kPrefix,procName,Select): aProc = (ComponentFunctionUPP)kCOMPONENT_NOERROR; break;
#define StdComponentNoError(procName) case_ComponentNoError(kComponent,procName)
#define ComponentNoError(procName) case_ComponentNoError(COMPONENT_SELECT_PREFIX(),procName)
#define ComponentSubTypeNoError(procName) case_ComponentNoError(COMPONENT_SUBTYPE_SELECT_PREFIX(),procName)
#define ComponentError(procName) //ComponentError for C_DISPATCH_WITH_SWITCH uses default case (delegate if we can)
#define ComponentDelegate(procName) //The default case for C_DISPATCH_WITH_SWITCH is to delegate if we can, error if we can't
#define ComponentRangeCount(theCount)
#define ComponentRangeShift(theShift)
#define ComponentRangeMask(theMask)
#define ComponentRangeBegin(rangeNum)
#define ComponentRangeEnd(rangeNum)
#define ComponentRangeUnused(rangeNum)
#define ComponentStorageType(theType)
#define ComponentDelegateByteOffset(theOffset)
#define ComponentComment(theComment)
switch (selector_num) {
#include COMPONENT_DISPATCH_FILE
}
return aProc;
}
#endif
#ifdef OVERRIDE_CANDO
ComponentResult OVERRIDE_CANDO( COMPONENT_GLOBALS(), short ftnNumber, ComponentResult result);
#endif
#ifndef TOUCH_UNUSED_ARG
// a macro to avoid "unused variable" warnings
#define TOUCH_UNUSED_ARG(arg) ((void)arg)
#endif
PASCAL_RTN ComponentResult ADD_BASENAME(CanDo)( COMPONENT_GLOBALS(), short ftnNumber );
PASCAL_RTN ComponentResult ADD_BASENAME(CanDo)( COMPONENT_GLOBALS(), short ftnNumber )
{
ComponentResult result;
#if C_DISPATCH_WITH_GLOBALS
ProcInfoType ignore;
result = (ComponentResult) COMPONENTSELECTORLOOKUP(ftnNumber, &ignore);
#else
result = (ComponentResult) COMPONENTSELECTORLOOKUP(ftnNumber);
#endif
/* check for a ComponentError */
if ( result == (ComponentResult) kCOMPONENT_ERROR )
result = false;
else if ( result == (ComponentResult) kCOMPONENT_DELEGATE )
result = false;
else
result = true;
#ifdef GET_DELEGATE_COMPONENT
/* if we're delegated, then keep looking */
if (!result)
{
if (GET_DELEGATE_COMPONENT())
result = CallComponentCanDo( GET_DELEGATE_COMPONENT(), ftnNumber );
}
#endif
#ifdef OVERRIDE_CANDO
result = OVERRIDE_CANDO( storage, ftnNumber, result);
#else
TOUCH_UNUSED_ARG(storage);
#endif
return result;
}
/* -- This Image Decompressor User the Base Image Decompressor Component --
The base image decompressor is an Apple-supplied component
that makes it easier for developers to create new decompressors.
The base image decompressor does most of the housekeeping and
interface functions required for a QuickTime decompressor component,
including scheduling for asynchronous decompression.
*/
// Component Open Request - Required
pascal ComponentResult FauxCodecImageCodecOpen(Codec_Globals glob, ComponentInstance self)
{
ComponentResult err;
// Allocate memory for our globals, set them up and inform the component manager that we've done so
glob = (Codec_Globals)NewPtrClear(sizeof(Codec_GlobalsRecord));
err = MemError();
if (err) goto bail;
SetComponentInstanceStorage(self, (Handle)glob);
glob->self = self;
glob->target = self;
glob->drawBandUPP = NULL;
// Open and target an instance of the base decompressor as we delegate
// most of our calls to the base decompressor instance
err = OpenADefaultComponent(decompressorComponentType, kBaseCodecType, &glob->delegateComponent);
if (err) goto bail;
ComponentSetTarget(glob->delegateComponent, self);
bail:
return err;
}
// Component Close Request - Required
pascal ComponentResult FauxCodecImageCodecClose(Codec_Globals glob, ComponentInstance self)
{
// Make sure to close the base component and dealocate our storage
if (glob) {
if (glob->delegateComponent) {
CloseComponent(glob->delegateComponent);
}
if (glob->drawBandUPP) {
#if defined(_CARBON) || defined(_MAC_UNIX)
DisposeImageCodecMPDrawBandUPP(glob->drawBandUPP);
#else
DisposeRoutineDescriptor(glob->drawBandUPP);
#endif
}
DisposePtr((Ptr)glob);
}
return noErr;
}
// Component Version Request - Required
pascal ComponentResult FauxCodecImageCodecVersion(Codec_Globals glob)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -