home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-16 | 3.7 KB | 170 lines | [TEXT/KAHL] |
- /*
- File: MoMathComponent.c
-
- Contains: Extended math component routines.
-
- Written by: Gary Woodcock
-
- Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- */
-
- //-----------------------------------------------------------------------
- // Includes
-
- #include "MathComponent.h"
- #include "MathComponentPrivate.h"
- #include "MathComponentCommon.h"
- #include "MoMathComponent.h"
- #include "MoMathComponentPrivate.h"
- #include <Errors.h>
-
- //-----------------------------------------------------------------------
-
- #ifdef DEBUG_IT
-
- // Use this declaration when we're running linked (for debugging)
- pascal ComponentResult MoMathDispatcher (ComponentParameters *params,
- Handle storage)
-
- #else
-
- // Use this declaration when we're a standalone component
- pascal ComponentResult main (ComponentParameters *params,
- Handle storage)
-
- #endif DEBUG_IT
-
- {
- // This routine is the main dispatcher for the MoMath component
-
- ComponentResult result = noErr;
-
- // Did we get a Component Manager request code (< 0)?
- if (params->what < 0)
- {
- switch (params->what)
- {
- case kComponentOpenSelect: // Open request
- {
- result = CallComponentFunctionWithStorage (storage, params,
- (ComponentFunction) _MathOpen);
- break;
- }
- case kComponentCloseSelect: // Close request
- {
- result = CallComponentFunctionWithStorage (storage, params,
- (ComponentFunction) _MathClose);
- break;
- }
- case kComponentCanDoSelect: // Can Do request
- {
- result = CallComponentFunction (params,
- (ComponentFunction) _MoMathCanDo);
- break;
- }
- case kComponentVersionSelect: // Version request
- {
- result = CallComponentFunction (params,
- (ComponentFunction) _MathVersion);
- break;
- }
- case kComponentTargetSelect: // Target request
- {
- result = CallComponentFunctionWithStorage (storage, params,
- (ComponentFunction) _MathTarget);
- break;
- }
- case kComponentRegisterSelect: // Register request not supported
- default: // Unknown request
- {
- result = paramErr;
- break;
- }
- }
- }
- else // Was it one of our request codes?
- {
- switch (params->what)
- {
- // math component selectors
- case kDoDivideSelect: // Divide request
- {
- result = CallComponentFunction (params,
- (ComponentFunction) _MathDoDivide);
- break;
- }
-
- case kDoMultiplySelect: // Multiply request
- {
- result = CallComponentFunction (params,
- (ComponentFunction) _MathDoMultiply);
- break;
- }
-
- case kDoAddSelect: // Add request
- {
- result = CallComponentFunction (params,
- (ComponentFunction) _MoMathDoAdd);
- break;
- }
-
- default: // Unknown request
- {
- result = paramErr;
- break;
- }
- }
- }
- return (result);
- }
-
- //-----------------------------------------------------------------------
-
- pascal ComponentResult _MoMathCanDo (short selector)
- {
- switch (selector)
- {
- // Component Manager request codes
- case kComponentOpenSelect:
- case kComponentCloseSelect:
- case kComponentCanDoSelect:
- case kComponentVersionSelect:
- case kComponentTargetSelect:
-
- // Math component request codes
- case kDoDivideSelect:
- case kDoMultiplySelect:
-
- // MoMath component request codes
- case kDoAddSelect:
- {
- return (true);
- }
- case kComponentRegisterSelect: // Register request not supported
- default: // Not a request code we recognize
- {
- return (false);
- }
- }
- }
-
- //-----------------------------------------------------------------------
-
- pascal ComponentResult _MoMathDoAdd (short firstNum,
- short secondNum,
- short *additionResult)
- {
- ComponentResult result = noErr;
-
- *additionResult = firstNum + secondNum;
-
- return (result);
- }
-
- //-----------------------------------------------------------------------
-
-
-