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


C++ ObjectWrapper::get_meta_class方法代码示例

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


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

示例1: if

/*
bool
SuifPrinterModule::print2(ostream& output, const ObjectWrapper &obj,
			  const LString &name, int _indent, int deref)
{
  return(print2(output, obj.get_address(), obj.get_meta_class(),
		name, _indent, deref));
}
*/
bool
//SuifPrinterModule::print2(ostream& output, const Address what, const MetaClass* type,
//       //const LString &name = emptyLString, int _indent = 2, int deref = 0)
//       const LString &name, int _indent, int deref)
SuifPrinterModule::print2(ostream& output, const ObjectWrapper &obj,
			  const LString &name, int _indent, int deref)
{
  if (!start_of_object(output,obj,deref)) {
      return false;
      }
  //  MetaClassId id = type->get_meta_class_id();
  String str = get_print_string(obj.get_meta_class()->get_instance_name());

  // This is NOT always a suifobject.  It is only
  // a suifobject if the metaclass is a child of the SuifObject metaclass.
  SuifObject *o = NULL;
  if (is_kind_of_suif_object_meta_class(obj.get_meta_class())) {
    o = (SuifObject *) obj.get_address(); 
    }

  // length is at least 1 (for the \0 at the end)
  //output << "p2:deref = " << deref << endl;
  if (use_print_string() && str != emptyString) {
     bool b = parse_and_print(output, obj, name, str, _indent, deref);
     end_of_object(output,obj);
     return b;
     }

  // No print string registered.
  const MetaClass *type = obj.get_meta_class();
  bool b = false;
  if (type->is_elementary()) {
     b =  print_elementary(output, obj, name, _indent, deref);
     }
  else if (type->isKindOf(AggregateMetaClass::get_class_name())) {
     b = print_aggregate(output, 
			      AggregateWrapper(obj),
			      name, _indent, deref);
     }  
  else if (type->isKindOf(PointerMetaClass::get_class_name())) {
     b = print_pointer(output, 
			    PointerWrapper(obj),
			    name, _indent, deref);
     }  
  else if (type->isKindOf(ListMetaClass::get_class_name())) {
     b = print_list(output, obj, name, _indent, deref);
     }  
  else if (type->isKindOf(STLMetaClass::get_class_name())) {
     b = print_stl(output, obj, name, _indent, deref);
     }  
  else {
     b = print_catchall(output, obj, name, _indent, deref);
     }
  end_of_object(output,obj);
  return b;
  }
开发者ID:jrk,项目名称:suif2,代码行数:65,代码来源:suifprinter.cpp

示例2: initialize

void PointerMetaClass::initialize( const ObjectWrapper &obj,
				   InputStream* inputStream ) const {
  Address address = obj.get_address(); 
  kernel_assert(obj.get_meta_class() == this);

   // debugit("initializing pointer ",address);
  if ( _pre_init ) {
    _pre_init( obj, true, inputStream );
  }
  Address objectAddress =  *(Address*)address;


  // test for whether it's already there
  if ( _is_static ||
       (  _pointer_owns_object && inputStream->exists_in_input_stream( objectAddress ) &&
          (!inputStream->was_already_visited( objectAddress ) ) ) ) {
    if ( !_is_static ) {
      inputStream->set_already_visited( objectAddress );
    }
    const MetaClass *mc = 
      get_base_type()->get_meta_class( (Byte*)objectAddress );
    mc->initialize( ObjectWrapper(*(Address*)address, mc), inputStream );
  }
  if ( _post_init ) {
    _post_init( obj, true, inputStream );
  }
}
开发者ID:jrk,项目名称:suif2,代码行数:27,代码来源:pointer_meta_class.cpp

示例3:

PointerWrapper::PointerWrapper(const ObjectWrapper &obj) :
  _meta_class(NULL), _address(0)
{
  kernel_assert_message(is_pointer(obj), 
			("Attempt to pointer object with non-pointer"));
  _meta_class = to<PointerMetaClass>(obj.get_meta_class());
  _address = obj.get_address();
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:8,代码来源:pointer_wrapper.cpp

示例4: destruct

void STLMetaClass::destruct( const ObjectWrapper &obj,
			     bool called_from_destructor ) const {
  kernel_assert(obj.get_meta_class() == this);
  // an stl object is never destroyed from the destructor
  kernel_assert( !called_from_destructor );

  _stl_descriptor->get_destructor_function()( obj );
}
开发者ID:jrk,项目名称:suif2,代码行数:8,代码来源:stl_meta_class.cpp

示例5: print_dispatch

void CPrintStyleModule::print_dispatch(Module *module,
				       ostream &str,
				       const ObjectWrapper &obj)
{
  CPrintStyleModule *pm = (CPrintStyleModule*)module;
  String result;
  if (is_kind_of_suif_object_meta_class(obj.get_meta_class())) {
    result = pm->print_to_string((const SuifObject*)obj.get_address());
  }
  str << result.c_str();
}
开发者ID:jrk,项目名称:suif2,代码行数:11,代码来源:cprint_style.cpp

示例6: destruct

void PointerMetaClass::destruct( const ObjectWrapper &obj,
				 bool called_from_destructor ) const {
  Address address = obj.get_address();
  kernel_assert(obj.get_meta_class() == this);

  // is never called from a destructor
  kernel_assert( !called_from_destructor );

  if ( _pointer_owns_object ) {
    Address object_address = *(Address*)address;
    if ( object_address ) {
      const MetaClass *mc = _base_type -> get_meta_class( object_address );
      mc-> destruct( ObjectWrapper(object_address, mc), false );
      delete (char*)object_address;
      *(Address*)address = 0; // just to be nice
    }
  }
}
开发者ID:jrk,项目名称:suif2,代码行数:18,代码来源:pointer_meta_class.cpp

示例7: obj

//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_catchall(ostream& output, 
				  const ObjectWrapper &obj,
				  const LString &name, 
				  int _indent,int deref = 0)
{
  const Address what = obj.get_address();
  const MetaClass* type = obj.get_meta_class(); 
   int field_deref = deref?deref-1:0;
   output << type->get_instance_name()
              << '(' << type->get_meta_class_id() << ") ";
   if (name)
         output << ' ' << name << ' ';
   output << " (un-implemented) ";
   Iterator* it = type->get_iterator(what);
   if (it) {
     if (it->current()) {
       //output << "{\n";
       output << endl;
       //while (it->is_valid()) {
       for (; it->is_valid(); it->next())
	 {
	   ObjectWrapper obj(it->current(), it->current_meta_class());
	   //		const MetaClass* currentMetaClass = it->current_meta_class();
	   //                 const Address curAddr = it->current();
	   if(!obj.is_null()) {
	     //                 if (curAddr) {
	     indent(output, _indent+istep);
	     print2(output, obj, it->current_name(), 
		    _indent+istep, field_deref);
	   }
	   //		it->next();
	   //}
	 }// while (it->is_valid());
       indent(output, _indent);
       //output << "}\n";
     }
         else
            output <<" {0x0}\n";
   }
   if (it) delete it;
   return true;
}
开发者ID:jrk,项目名称:suif2,代码行数:45,代码来源:suifprinter.cpp

示例8: initialize

void UnionMetaClass::initialize( const ObjectWrapper &obj,
				 InputStream* inputStream ) const {
  Address address = obj.get_address();
  kernel_assert(obj.get_meta_class() == this);
 
  // debugit("initializing union ",address);
  AggregateWrapper agg_obj(address, this);
  AggregateMetaClass::initialize( obj, inputStream );
  int index = get_tag_num( address );
  if (index < 0)
    zero_field(address);
  else {
    FieldDescription* field_description = (*_union_fields)[ index ];
    ObjectWrapper field = field_description->build_object(agg_obj);

    //Address instance_address = (Address)( ( (Byte*)address ) + field_description->offset );
    field.initialize(inputStream);
    //    field_description->get_meta_class()->initialize( field.get_address() ,inputStream );
    }
}
开发者ID:jrk,项目名称:suif2,代码行数:20,代码来源:union_meta_class.cpp

示例9: write

void UnionMetaClass::write( const ObjectWrapper &obj,
			    OutputStream* outputStream ) const {
  Address instance = obj.get_address();
  kernel_assert(obj.get_meta_class() == this);

  AggregateWrapper agg_obj(instance, this);
  AggregateMetaClass::write( obj, outputStream );

  int index = get_tag_num( instance );
  // if the tag number is not stored in a field that was already
  // written out => write out the tag number
  if ( _tag_offset == -1 ) {
    outputStream->write_unsigned_int( index );
  }

  if ( index >= 0 ) {
    FieldDescription* field_description = (*_union_fields)[ index ];
    ObjectWrapper field = field_description->build_object(agg_obj);
    outputStream->write( field, false );
  }
}
开发者ID:jrk,项目名称:suif2,代码行数:21,代码来源:union_meta_class.cpp

示例10: read

void PointerMetaClass::read( const ObjectWrapper &obj,
			     InputStream* inputStream ) const {
    Address instance = obj.get_address();
    kernel_assert(obj.get_meta_class() == this);
    PointerWrapper ptr_obj(instance, this);

    if (_needs_cloning) {
	inputStream->read_defining_pointer( ptr_obj );
        }
    else if ( _pointer_owns_object ) {
    	if ( _is_static ) {
	    inputStream->read_static_pointer( ptr_obj );
    	    } 
	else {
      	    inputStream->read_owning_pointer( ptr_obj );
    	    }
  	} 
    else {
    	inputStream->read_reference( ptr_obj );
  	}
    }
开发者ID:jrk,项目名称:suif2,代码行数:21,代码来源:pointer_meta_class.cpp

示例11: read

void UnionMetaClass::read( const ObjectWrapper &obj,
			   InputStream* inputStream ) const {
  Address instance = obj.get_address();
  kernel_assert(obj.get_meta_class() == this);

  AggregateWrapper agg_obj(instance, this);
  AggregateMetaClass::read( obj, inputStream );
  int index;
  if ( _tag_offset != -1 ) {
    index = *(int *) ((Byte*)instance + _tag_offset);
  } else {
    index = inputStream->read_unsigned_int();
  }
  if ( index >= 0 ) {
    FieldDescription* field_description = (*_union_fields)[ index ];
    ObjectWrapper field = field_description->build_object(agg_obj);

    inputStream->read( field, false );
  } else { // works for now as only Union is a Union of pointers
    zero_field(instance);
  }
}
开发者ID:jrk,项目名称:suif2,代码行数:22,代码来源:union_meta_class.cpp

示例12: get_member

Address Object::get_member( const LString& name,
                            Address& return_address,
                            const MetaClass*&  return_meta_class ) const {
  kernel_assert_message( _meta_class, ("Empty MetaClass") );

  FieldDescription* field_description = 
    _meta_class->get_field_description( (void*)address,  name );
  if ( field_description ) {
    //    return_address = ((const Object *)this) + field_description->offset;
    AggregateWrapper agg_obj((Address)this, _meta_class);
    ObjectWrapper obj = field_description->build_object(agg_obj);
    obj = obj.update_meta_class();
    return_address = obj.get_address();
    return_meta_class = obj.get_meta_class();
    //return_address = ((Byte*)this) + field_description->offset;
    //    return_meta_class = field_description->
    //                           metaClass->get_meta_class( return_address );
  } else {
    return_address = 0;
    return_meta_class = 0;
  }
  return return_address;
}
开发者ID:jrk,项目名称:suif2,代码行数:23,代码来源:object.cpp

示例13:

//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_elementary(ostream& output, 
				    const ObjectWrapper &obj,
				    const LString &name, 
				    int _indent,int deref = 0)
{
  const Address what = obj.get_address();
  const MetaClass* type = obj.get_meta_class();
  //output << "elem:deref = " << deref << endl;
  if (!deref) {
    output << type->get_instance_name()
	   << '(' << type->get_meta_class_id() << ')';
    if (name)
      output << ' ' << name << ' ';
  }
  if (what) {
    if (type->isKindOf("String"))
      output <<'[' << *(String*)what <<"] ";
    else
      output <<'[' << *(int*)what <<"] ";
  }
  return true;
}
开发者ID:jrk,项目名称:suif2,代码行数:25,代码来源:suifprinter.cpp

示例14: is_pointer

bool PointerWrapper::is_pointer(const ObjectWrapper &obj) {
  const MetaClass *mc = obj.get_meta_class();
  return(is_kind_of<PointerMetaClass>(mc));
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:4,代码来源:pointer_wrapper.cpp

示例15: print

void
SuifPrinterModule::print(ostream& output, const ObjectWrapper &obj)
{
  print(output, obj.get_address(), obj.get_meta_class(), 0);
}
开发者ID:jrk,项目名称:suif2,代码行数:5,代码来源:suifprinter.cpp


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