当前位置: 首页>>代码示例>>C++>>正文


C++ CoreObject::setUserData方法代码示例

本文整理汇总了C++中CoreObject::setUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreObject::setUserData方法的具体用法?C++ CoreObject::setUserData怎么用?C++ CoreObject::setUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CoreObject的用法示例。


在下文中一共展示了CoreObject::setUserData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Handle_aquery

void Handle_aquery( VMachine *vm )
{
   Item* i_sql = vm->param(0);
   Item* i_params = vm->param(1);
   if ( i_sql == 0 || ! i_sql->isString()
      || i_params == 0 || ! i_params->isArray() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                        .extra( "S,A" ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIHandle *dbt = static_cast<DBIHandle *>( self->getUserData() );

   DBIRecordset* res = 0;
   res = dbt->query( *i_sql->asString(), &i_params->asArray()->items() );

   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );
      vm->retval( rset );
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:28,代码来源:dbi_ext.cpp

示例2: Statement_aexec

void Statement_aexec( VMachine *vm )
{
   Item* i_params = vm->param(0);
   if( i_params == 0 || ! i_params->isArray() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                               .extra( "A" ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIStatement *dbt = static_cast<DBIStatement *>( self->getUserData() );

   DBIRecordset* res;
   res = dbt->execute( &i_params->asArray()->items() );

   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );

      vm->retval( rset );
   }
   else
   {
      vm->retnil();
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:31,代码来源:dbi_ext.cpp

示例3: DBIError_init

void DBIError_init( VMachine *vm )
{
   CoreObject *einst = vm->self().asObject();
   if( einst->getUserData() == 0 )
      einst->setUserData( new DBIError );

   ::Falcon::core::Error_init( vm );
}
开发者ID:Klaim,项目名称:falcon,代码行数:8,代码来源:dbi_ext.cpp

示例4: internal_stmt_open

static void internal_stmt_open( VMachine* vm, DBIStatement* trans )
{
   Item *trclass = vm->findWKI( "%Statement" );
   fassert( trclass != 0 && trclass->isClass() );

   CoreObject *oth = trclass->asClass()->createInstance();
   oth->setUserData( trans );
   vm->retval( oth );
}
开发者ID:Klaim,项目名称:falcon,代码行数:9,代码来源:dbi_ext.cpp

示例5: Dictionary_last

FALCON_FUNC Dictionary_last( VMachine *vm )
{
   Item *itclass = vm->findWKI( "Iterator" );
   fassert( itclass != 0 );

   CoreObject *iterator = itclass->asClass()->createInstance();
   // we need to set the FalconData flag
   iterator->setUserData( new Iterator( &vm->self().asDict()->items(), true  ) );
   vm->retval( iterator );
}
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:10,代码来源:dict_ext.cpp

示例6: sdl_GetCursor

/*#
   @method GetCursor SDL
   @brief Gets currently active cursor.
   @return an instance of @a SDLCursor class or nil.

   This method returns the currently active cursor. It can be used to
   store this away and set it later.
*/
FALCON_FUNC sdl_GetCursor( ::Falcon::VMachine *vm )
{
   ::SDL_Cursor *cursor = ::SDL_GetCursor();
   if ( cursor == 0 )
      vm->retnil();
   else {
      Item *cls = vm->findWKI( "SDLCursor" );
      fassert( cls != 0 );
      CoreObject *obj = cls->asClass()->createInstance();
      obj->setUserData( new SDLCursorCarrier( cursor, false ) );
      vm->retval( obj );
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:21,代码来源:sdl_cursor_ext.cpp

示例7: Handle_query

void Handle_query( VMachine *vm )
{
   Item* i_sql = vm->param(0);

   if ( i_sql == 0 || ! i_sql->isString() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                        .extra( "S, ..." ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIHandle *dbt = static_cast<DBIHandle *>( self->getUserData() );
   

   DBIRecordset* res = 0;
   int32 pCount = vm->paramCount();
   if( pCount > 1 )
   {
      ItemArray params( pCount - 1 );      
      for( int32 i = 1; i < vm->paramCount(); i++)
      {
         params.append( *vm->param(i) );
      }
      
      // Query may throw.
      res = dbt->query( *i_sql->asString(), &params );
   }
   else 
   {
      res = dbt->query( *i_sql->asString() );
   }

   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );

      vm->retval( rset );
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:44,代码来源:dbi_ext.cpp

示例8: Recordset_next

void Recordset_next( VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   DBIRecordset *dbr = static_cast<DBIRecordset *>( self->getUserData() );

   DBIRecordset *res = dbr->getNext();
   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );

      vm->retval( rset );
   }
   // else return nothing
}
开发者ID:Klaim,项目名称:falcon,代码行数:19,代码来源:dbi_ext.cpp

示例9: Statement_execute

void Statement_execute( VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   DBIStatement *dbt = static_cast<DBIStatement *>( self->getUserData() );
   
   DBIRecordset* res;

   if( vm->paramCount() != 0 )
   {
      ItemArray params( vm->paramCount() );
      for( int32 i = 0; i < vm->paramCount(); i++)
      {
         params.append( *vm->param(i) );
      }
      res = dbt->execute( &params );
   }
   else {
      res = dbt->execute();
   }

   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );

      vm->retval( rset );
   }
   else
   {
      vm->retnil();
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:36,代码来源:dbi_ext.cpp

示例10: ConfParser_init

FALCON_FUNC  ConfParser_init( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   Item *i_fname = vm->param(0);
   Item *i_encoding = vm->param(1);

   if ( (i_fname != 0 && ! i_fname->isString()) || ( i_encoding != 0 && ! i_encoding->isString() ) )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "S, [S]" ) );
      return;
   }

   String fname;
   String encoding;

   if ( i_fname != 0 )
      fname = *i_fname->asString();

   if ( i_encoding != 0 )
      encoding = *i_encoding->asString();

   ConfigFile *cfile = new ConfigFile( fname, encoding );
   self->setUserData( cfile );
}
开发者ID:Klaim,项目名称:falcon,代码行数:24,代码来源:confparser_ext.cpp

示例11: sdl_CreateCursor

/*#
   @method CreateCursor SDL
   @brief Gets currently active cursor.
   @param mbData MemBuf containing visual bit data.
   @param mbMask Membuf containing visibility mask data.
   @param width Width of the cursor.
   @param height Height of the cursor.
   @param Xspot X position of the cursor hotspot.
   @param Yspot Y position of the cursor hotspot.
   @raise SDLError if the cursor couldn't be created.

   See SDL_CreateCursor documentation. Method @a SDL.MakeCursor is
   probably simpler to use.
*/
FALCON_FUNC sdl_CreateCursor( ::Falcon::VMachine *vm )
{
   Item *i_data, *i_mask;
   Item *i_width, *i_height, *i_xspot, *i_yspot;

   if( vm->paramCount() < 6 ||
      ! (i_data = vm->param(0) )->isMemBuf() ||
      ! (i_mask = vm->param(1) )->isMemBuf() ||
      ! (i_width = vm->param(2) )->isOrdinal() ||
      ! (i_height = vm->param(3) )->isOrdinal() ||
      ! (i_xspot = vm->param(4) )->isOrdinal() ||
      ! (i_yspot = vm->param(5) )->isOrdinal()
      )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
         extra( "M,M,N,N,N,N" ) ) ;
      return;
   }

   MemBuf *data = i_data->asMemBuf();
   MemBuf *mask = i_mask->asMemBuf();
   // we are not interested in their word size.
   if( data->size() || data->size() != mask->size() )
   {
      throw new ParamError( ErrorParam( e_param_type, __LINE__ ).
         extra( "Membuf must be of same size" ) ) ;
      return;
   }

   int width = (int) i_width->forceInteger();
   int height = (int) i_height->forceInteger();
   int xspot = (int) i_xspot->forceInteger();
   int yspot = (int) i_yspot->forceInteger();

   if( width < 8 || height < 1 || width % 8 != 0 )
   {
      throw new ParamError( ErrorParam( e_param_type, __LINE__ ).
         extra( "Invalid sizes" ) ) ;
      return;
   }

   if( data->size() != (uint32)( width/8 * height ) )
   {
      throw new ParamError( ErrorParam( e_param_type, __LINE__ ).
         extra( "Membuf doesn't match width and height" ) ) ;
      return;
   }

   if( xspot < 0  || xspot >= width || yspot < 0 || yspot >= height )
   {
      throw new ParamError( ErrorParam( e_param_type, __LINE__ ).
         extra( "Hotspot outside cursor" ) ) ;
      return;
   }

   // ok, all fine
   ::SDL_Cursor *cursor = SDL_CreateCursor( (Uint8 *) data->data(), (Uint8 *) mask->data(),
      width, height, xspot, yspot );

   if ( cursor == 0 )
   {
      throw new SDLError( ErrorParam( FALCON_SDL_ERROR_BASE + 11, __LINE__ )
         .desc( "SDL Create Cursor" )
         .extra( SDL_GetError() ) ) ;
      return;
   }

   Item *cls = vm->findWKI( "SDLCursor" );
   fassert( cls != 0 );
   CoreObject *obj = cls->asClass()->createInstance();
   obj->setUserData( new SDLCursorCarrier( cursor, true ) );
   vm->retval( obj );
}
开发者ID:Klaim,项目名称:falcon,代码行数:87,代码来源:sdl_cursor_ext.cpp

示例12: sdl_MakeCursor


//.........这里部分代码省略.........
   int yspot = i_yspot->forceInteger();

   CoreArray *array = i_array->asArray();
   int height = (int) array->length();
   if ( height < 1 )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
         extra( "Array empty" ) ) ;
      return;
   }

   int width = -1;

   for ( int i = 0; i < height; i ++ )
   {
      Item &elem = array->at(i);
      if( ! elem.isString() )
      {
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
            extra( "Array contains non-strings" ) ) ;
         return;
      }

      String &row = *elem.asString();
      if( row.length() == 0 || row.length() % 8 != 0 )
      {
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
            extra( "Strings not modulo 8" ) ) ;
         if ( data != 0 )
         {
            memFree( data );
            memFree( mask );
         }
         return;
      }

      if( width == -1 )
      {
         // calculate first width
         width = row.length();
         data = (Uint8 *) memAlloc( width / 8 * height );
         mask = (Uint8 *) memAlloc( width / 8 * height );
         memset( data, 0, width / 8 * height );
         memset( mask, 0, width / 8 * height );
      }
      else if ( width != (int) row.length() )
      {
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
            extra( "Strings of different sizes" ) ) ;
         return;
      }

      // perform the parsing
      Uint8 *pdata = data + i * width/8;
      Uint8 *pmask = mask + i * width/8;

      for ( int j = 0; j < width; j ++ )
      {
         uint32 chr = row.getCharAt( j );

         switch( chr )
         {
            case ' ': // nothing to do 0/0
               break;

            case 'X': // inverse 1/0
               pdata[ j/8 ] |= 1 << (7 - (j % 8));
               break;

            case '@':  // white 0/1
               pmask[ j/8 ] |= 1 << (7 -(j % 8));
               break;

            case '.': // black 1/1
               pdata[ j/8 ] |= 1 << (7 -(j % 8));
               pmask[ j/8 ] |= 1 << (7 -(j % 8));
               break;

            default:
               // error
               memFree( data );
               memFree( mask );
               throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
                  extra( "Unrecognized char in string" ) );
               return;
         }
      }
   }

   ::SDL_Cursor *cursor = ::SDL_CreateCursor( data, mask, width, height, xspot, yspot );
   Item *cls = vm->findWKI( "SDLCursor" );
   fassert( cls != 0 );
   CoreObject *obj = cls->asClass()->createInstance();
   obj->setUserData( new SDLCursorCarrier( cursor, true ) );

   memFree( data );
   memFree( mask );

   vm->retval( obj );
}
开发者ID:Klaim,项目名称:falcon,代码行数:101,代码来源:sdl_cursor_ext.cpp


注:本文中的CoreObject::setUserData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。