home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-12 | 2.0 KB | 100 lines | [TEXT/CWIE] |
- /***
- * GOSAScriptComponent.cp
- *
- * A component that does scripting
- *
- * Gordon Watts (gwatts@fnal.fnal.gov) © 1995 As Is!
- ***/
-
- #include "GOSAScriptComponent.h"
-
- #ifndef kComponentNotFound
- #define kComponentNotFound -1
- #endif
-
- GOSAScriptComponent *GOSAScriptComponent :: mDefaultScriptComponent = 0;
-
- /**
- * GetDefaultComponent
- *
- * Return the default component. This guy is only opened once...
- *
- **/
- GOSAScriptComponent * GOSAScriptComponent :: GetDefaultComponent (void)
- {
- if (!mDefaultScriptComponent)
- mDefaultScriptComponent = new GOSAScriptComponent;
-
- return mDefaultScriptComponent;
- }
-
- /**
- * GOSAScripComponent
- *
- * Open the component -- default
- *
- **/
- GOSAScriptComponent :: GOSAScriptComponent (void)
- {
- CommonInit ((OSType) 0, (OSType) 0);
- }
-
- GOSAScriptComponent :: GOSAScriptComponent (OSType subType, OSType manuf)
- {
- CommonInit (subType, manuf);
- }
-
- /**
- * ~GOSAScriptComponent
- *
- * Close off the component, if open.
- *
- **/
- GOSAScriptComponent :: ~GOSAScriptComponent (void)
- {
- if (mScriptComponent)
- CloseComponent(mScriptComponent);
- }
-
- /**
- * CommonInit
- *
- * Get the damm component.
- *
- **/
- void GOSAScriptComponent :: CommonInit (OSType subtype, OSType manuf)
- {
- mScriptComponent = 0;
-
- /**
- ** See if we can't find the component -- take the first one
- ** there.
- **/
-
- ComponentDescription descr;
- Component aComponent;
-
- descr.componentType = kOSAComponentType;
- descr.componentSubType = subtype;
- descr.componentManufacturer = manuf;
- descr.componentFlags = kOSASupportsCompiling +
- kOSASupportsGetSource +
- kOSASupportsConvenience +
- kOSASupportsEventHandling;
- descr.componentFlagsMask = descr.componentFlags;
-
- aComponent = FindNextComponent(nil, &descr);
-
- if (!aComponent)
- ThrowOSErr_(kComponentNotFound);
-
- /**
- ** Ok -- if we have the component, then we can open it.
- **/
-
- mScriptComponent = OpenComponent (aComponent);
-
- if (!mScriptComponent)
- ThrowOSErr_(kComponentNotFound);
- }
-