Esempio n. 1
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB_SCOPE_INIT, "Scope::init" )
   BOOLEAN Scope::init()
   {
      BOOLEAN ret = FALSE ;
      PD_TRACE_ENTRY ( SDB_SCOPE_INIT );

      SDB_ASSERT( globalEngine, "Script engine has not been initialized" );
      SDB_ASSERT( ! _context && ! _global, "Can't init a scope twice" );

      _context = JS_NewContext( globalEngine->_runtime, 1024 * 1024 ) ;
      VERIFY( _context );

      JS_SetOptions( _context, JSOPTION_VAROBJFIX );
      JS_SetVersion( _context, JSVERSION_LATEST );
      JS_SetErrorReporter( _context, sdbReportError );

      _global = JS_NewCompartmentAndGlobalObject( _context, &global_class, NULL );
      VERIFY( _global );

      VERIFY( JS_InitStandardClasses( _context, _global ) );

      VERIFY( InitDbClasses( _context, _global ) ) ;

      VERIFY ( SDB_OK == evalInitScripts ( this ) ) ;

      ret = TRUE ;

   done :
      PD_TRACE_EXIT ( SDB_SCOPE_INIT );
      return ret ;
   error :
      goto done ;
   }
Esempio n. 2
0
INT32 _sptContainer::_loadObj( _sptScope * pScope )
{
    INT32 rc = SDB_OK ;

    if ( _loadMask & SPT_OBJ_MASK_STANDARD )
    {
        if ( !InitDbClasses( ((sptSPScope *)pScope)->getContext(),
                             ((sptSPScope *)pScope)->getGlobalObj() ) )
        {
            PD_LOG( PDERROR, "Failed to init dbclass" ) ;
            rc = SDB_SYS ;
            goto error ;
        }
    }

    if ( _loadMask & SPT_OBJ_MASK_USR )
    {
        rc = pScope->loadUsrDefObj<_sptUsrSsh>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrSsh, rc = %d", rc ) ;
        rc = pScope->loadUsrDefObj<_sptUsrCmd>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrCmd, rc = %d", rc ) ;
        rc = pScope->loadUsrDefObj<_sptUsrFile>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrFile, rc = %d", rc ) ;
        rc = pScope->loadUsrDefObj<_sptUsrSystem>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrSystem, rc = %d", rc ) ;
        rc = pScope->loadUsrDefObj<_sptUsrOma>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrOma, rc = %d", rc ) ;
        rc = pScope->loadUsrDefObj<_sptUsrHash>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrHash, rc = %d", rc ) ;
        rc = pScope->loadUsrDefObj<_sptUsrSdbTool>() ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to load class _sptUsrSdbTool, rc = %d", rc ) ;
    }

    if ( _loadMask & SPT_OBJ_MASK_INNER_JS )
    {
        rc = evalInitScripts2( pScope ) ;
        PD_CHECK ( SDB_OK == rc, SDB_SYS, error, PDERROR,
                   "Failed to init spt scope, rc = %d", rc ) ;
    }

done:
    return rc ;
error:
    goto done ;
}