// @(#) 1.1 com/src/samples/scrsimp1/iodspex1.cpp, odsimplescript, od96nt, odnt9712d 2/20/97 17:46:48 [3/21/97 17:46:48]
//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odscriptableparts
//
//   CLASSES: none
//
//   ORIGINS: 82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//



// This file implements the ScriptExtension code for a scriptable part which
// inherits from 'SimplePart'.

#include <iodspcl1.h>

#ifndef SOM_Module_iodspex1_Source
#define SOM_Module_iodspex1_Source
#endif
#define ScriptableSimplePart1ScrExt_Class_Source

#include "iodspex1.xih"
#include "scrcomp.xh"          // to get return value codes


SOM_Scope ODScriptExtension_ODScrRegRet  SOMLINK _CLx_P(Register)(_CLx_ *somSelf,
                                                                  Environment *ev,
                                                                 ODScriptExtension* RegScope,
                                                                 string Prefix)
{
    ODScrRegRet RetVal = ODScrRegOK ;
    ODObject* basepart ;
    char*     className ;
    char*     nameAssigned ;

    /* _CLx_P(Data) *somThis = _CLx_P(GetData)(somSelf); */
    _CLx_P(MethodDebug)(_CLx_q , _CLx_Pq(Register) );

    basepart = somSelf->GetBase(ev) ;
    if (basepart == NULL) {return ODScrRegErr;}

    // The class for each scriptable object needs to be registered with the
    // ScriptComponent.

    className = basepart->somGetClassName() ;
    RetVal = RegScope->DoRegisterClass(ev, className) ;
    if (RetVal != ODScrRegOK)
    { return RetVal ; }

    // DoRegisterObject can take care of most normal naming issues.  We
    // call it here with the option option that will append a
    // numeric string to the name supplied here if needed to
    // make the name unique in the set of names assigned for this Part.

    RetVal = RegScope->DoRegisterObject(ev,
                     basepart,          // the object to be scriptable
                     className,         // the class name of that object
                     "SPart",           // the default name to be used
                     Prefix,            // prefix that applies in the scope
                                        //  where registration begins
                     &nameAssigned,     // receives name actually assigned
                     somSelf,           // the scope/extension of the object
                     kODTrue);          // digits to be appended to make the
                                        //  name unique if needed.

    if (RetVal == ODScrRegOK)           // if registration was successful, we
    { SOMFree(nameAssigned) ; }         //  need to release the storage
                                        //  that holds the actual name assigned.
                                        //  For this part we don't need to
                                        //  save that information.

    return RetVal ;

}


