예제 #1
0
파일: suifprinter.cpp 프로젝트: jrk/suif2
/*
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;
  }
예제 #2
0
파일: object.cpp 프로젝트: AdamSpitz/klein
void print(oop_t x) {
  char buf[1000];
  get_print_string(x, buf, sizeof(buf));
  printf_and_flush("%s\n", buf);
}