コード例 #1
0
ファイル: framekit.C プロジェクト: ralfbrown/framepac
bool import_FrameKit_frames(istream &input,ostream &output)
{
   FrObject *obj ;
   FrFrame *fr ;
   FrSymbol *symbolMAKEFRAME = FrSymbolTable::add(stringMAKEFRAME) ;
   FrSymbol *symbolMAKEFROLD = FrSymbolTable::add(stringMAKEFR_OLD) ;

   if (output)
      output << "Importing frames" << endl ;
   bool oldvirt = read_virtual_frames(true) ;
   if (!VFrame_Info)
      read_virtual_frames(oldvirt) ;
   while (!input.eof())
      {
      input >> obj ;
      if (obj)
	 {
	 if (obj->consp() &&
	     (((FrCons*)obj)->first() == symbolMAKEFRAME ||
	      ((FrCons*)obj)->first() == symbolMAKEFROLD))
	    {
	    fr = FrameKit_to_FramepaC((FrList*)obj) ;
	    if (!fr)
	       {
	       read_virtual_frames(oldvirt) ;
	       return false ;	// error reading stream
	       }
	    if (output)
	       output << stringREAD << fr->frameName() << endl ;
	    }
	 else if (output)
	    {
	    output << stringREAD << obj->objTypeName() << ' ' ;
	    if (obj->framep())
	       output << ((FrFrame*)obj)->frameName() ;
	    else if (obj->consp())
	       output << "(" << obj->car() << " ... )" ;
	    else
	       output << obj ;
	    output << endl ;
	    }
	 obj->freeObject() ;
	 }
      }
   read_virtual_frames(oldvirt) ;
   return true ;
}
コード例 #2
0
ファイル: test.C プロジェクト: tripleee/la-strings
void display_object_info(ostream &out, const FrObject *obj)
{
   FramepaC_bgproc() ;		// handle any asynchronous operations
   FramepaC_bgproc() ;
   size_t objlen = FrObject_string_length(obj) ;
   out << "\n\nYou entered " ;
   if (objlen > 68)
      out << endl ;
   out << obj << endl ;
   if (obj)
      out << "That object is of type " << obj->objTypeName()
          << "; it takes " << objlen << " bytes to print" << endl ;
   else
      return ;
   if (obj->framep())
      {
      FrList *framekit = FramepaC_to_FrameKit((FrFrame *)obj) ;
      
      out << "As a FrameKit frame, it would be:\n" << framekit << endl ;
      free_object(framekit) ;
      }
   else if (obj->arrayp())
      {
      if (obj->length() > 0)
	 out << "This "
	     << ((obj->objType() == OT_FrSparseArray) ? "sparse " : "")
	     << "array's last element is "
	     << (*(FrArray*)obj)[obj->length()-1] << endl ;
      }
   else if (obj->queuep())
      {
      out << "This queue contains " << ((FrQueue*)obj)->queueLength()
	  << " items" << endl ;
      }
   else if (obj->hashp())
      {
      FrList *matches = ((FrHashTable*)obj)->prefixMatches("A") ;
      out << "This hash table contains " << matches->listlength()
	  << " items matching the prefix 'A'" << endl ;
      free_object(matches) ;
      }
   else if (obj->stringp())
      out << "This string uses " << ((FrString*)obj)->charWidth()
	  << "-byte characters." << endl ;
   else if (obj->consp())
      {
      out << "Its length is " << obj->length() << " cons cells.\n"
	  << "Its head is " << obj->car() << " and its tail is "
	  << obj->cdr() << endl << endl ;
      FrObject *obj_car = obj->car() ;
      if (obj_car && obj_car->symbolp() &&
	  (obj_car == findSymbol("MAKE-FRAME") ||
	   obj_car == findSymbol("MAKE-FRAME-OLD")))
	 {
	 FrFrame *frame = FrameKit_to_FramepaC((FrList *)obj) ;
	 out << "It is a FrameKit frame; as a FramepaC frame, it would be:\n"
	     << frame << endl ;
	 free_object(frame) ;
	 }
      }
   else if (obj->vectorp())
      {
      out << "This vector contains " << obj->length() << " bits, of which "
	  << ((FrBitVector*)obj)->countBits() << " are set." << endl ;
      }
   FramepaC_bgproc() ;		// handle any asynchronous operations
}