Beispiel #1
0
Rune *Rune::CreateRune( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	Rune *rune;


	fullname = "Rune";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &Rune::ClassInfo, cls ) )
		return NULL;

	rune = (Rune *)cls->newInstance();

	if ( !rune )
		return NULL;

	rune->init( modelName, sentient );

	return rune;
}
Beispiel #2
0
HoldableItem *HoldableItem::createHoldableItem( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	HoldableItem *holdableItem;


	fullname = "HoldableItem";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &HoldableItem::ClassInfo, cls ) )
		return NULL;

	holdableItem = (HoldableItem *)cls->newInstance();

	if ( !holdableItem )
		return NULL;

	holdableItem->init( modelName, sentient );

	return holdableItem;
}
Beispiel #3
0
Powerup *Powerup::CreatePowerup( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	Powerup *powerup;


	fullname = "Powerup";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &Powerup::ClassInfo, cls ) )
		return NULL;

	powerup = (Powerup *)cls->newInstance();

	if ( !powerup )
		return NULL;

	powerup->init( modelName, sentient );

	return powerup;
}
Beispiel #4
0
//--------------------------------------------------------------
//
// Name:			G_DropItemCmd
// Class:			None
//
// Description:		Drops an item that is clicked on from the inventory
//
// Parameters:		gentity_t -- the entity issuing the command.  This
//							 is the player who issued the command.
//
// Returns:			qboolean -- true if the command was executed.	
//
//--------------------------------------------------------------
qboolean G_DropItemCmd( const gentity_t *ent )
{
	if ( gi.argc() < 1 ) return false ;
	if ( !ent->entity->isSubclassOf( Player ) ) return false ;
	
	Player		*player			= (Player*)ent->entity ;
	str			 objectName		= gi.argv( 1 );
	str			 propertyName	= gi.argv( 2 );
	
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm ) return false ;
	
	str itemName	= gpm->getStringValue( objectName, propertyName );
	if ( itemName == "Empty" )
		return false;
	
	str tikiName	= gpm->getStringValue( itemName, "model" );
	str itemType	= gpm->getStringValue( itemName, "class" );
	str	playerItem("CurrentPlayer." + itemType);
	
	if ( !gpm->hasObject(playerItem) )
	{
		gi.WPrintf( "Warning: Unknown item type %s for item %s", itemType.c_str(), itemName.c_str() );
		return false ;
	}
	
	// Empty the slot
	gpm->setStringValue( objectName, propertyName, "Empty" );
	
	// Give the player the item to drop
	//Item *givenItem = player->giveItem(tikiName);
	
	Weapon *dropweap;
	ClassDef *cls;
	cls = getClass( tikiName.c_str() );
	if ( !cls )
	{
		SpawnArgs args;
		args.setArg( "model", tikiName.c_str() );
		cls = args.getClassDef();
		if ( !cls )
			return false;
	}
	dropweap = ( Weapon * )cls->newInstance();
	dropweap->setModel( tikiName.c_str() );
	dropweap->ProcessPendingEvents();
	dropweap->SetOwner(player);
	dropweap->hideModel();
	dropweap->setAttached(true);
	dropweap->Drop();
	
	return true ;
}
//--------------------------------------------------------------
//
// Name:			processGameplayData
// Class:			WeaponDualWield
//
// Description:		Process gameplay data
//
// Parameters:		Event *ev -- not used
//
// Returns:			None
//
//--------------------------------------------------------------
void WeaponDualWield::processGameplayData( Event * )
{
	ClassDef *cls;

	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm->hasObject(getArchetype()) )
		return;

	str leftmodel = gpm->getStringValue(getArchetype(), "leftmodel");
	str rightmodel = gpm->getStringValue(getArchetype(), "rightmodel");

	if ( !_leftweapon )
	{
		cls = getClass( leftmodel );
		if ( !cls )
		{
			SpawnArgs args;
			args.setArg( "model", leftmodel );
			cls = args.getClassDef();
			if ( !cls )
				return;
		}
		_leftweapon = ( Weapon * )cls->newInstance();
		_leftweapon->setModel( leftmodel );
		_leftweapon->ProcessPendingEvents();
		_leftweapon->hideModel();
	}

	if ( !_rightweapon )
	{
		cls = getClass( rightmodel );
		if ( !cls )
		{
			SpawnArgs args;
			args.setArg( "model", rightmodel );
			cls = args.getClassDef();
			if ( !cls )
				return;
		}
		_rightweapon = ( Weapon * )cls->newInstance();
		_rightweapon->setModel( rightmodel );
		_rightweapon->ProcessPendingEvents();
		_rightweapon->hideModel();
	}
	
	// Process gameplay data on myself.
	Weapon::processGameplayData( NULL );
}
Beispiel #6
0
static void lookupSymbol(Definition *d)
{
  if (d!=Doxygen::globalScope && // skip the global namespace symbol
      d->name().at(0)!='@'       // skip anonymous stuff
     )      
  {
    printf("Symbol info\n");
    printf("-----------\n");
    printf("Name: %s\n",d->name().data());
    printf("File: %s\n",d->getDefFileName().data());
    printf("Line: %d\n",d->getDefLine());
    // depending on the definition type we can case to the appropriate
    // derived to get additional information
    switch (d->definitionType())
    {
      case Definition::TypeClass:
        {
          ClassDef *cd = (ClassDef *)d;
          printf("Kind: %s\n",cd->compoundTypeString().data());
        }
        break;
      case Definition::TypeFile:
        {
          FileDef *fd = (FileDef *)d;
          printf("Kind: File: #includes %d other files\n",
              fd->includeFileList() ? fd->includeFileList()->count() : 0);
        }
        break;
      case Definition::TypeNamespace:
        {
          NamespaceDef *nd = (NamespaceDef *)d;
          printf("Kind: Namespace: contains %d classes and %d namespaces\n",
              nd->getClassSDict() ? nd->getClassSDict()->count() : 0,
              nd->getNamespaceSDict() ? nd->getNamespaceSDict()->count() : 0);
        }
        break;
      case Definition::TypeMember:
        {
          MemberDef *md = (MemberDef *)d;
          printf("Kind: %s\n",md->memberTypeName().data());
        }
        break;
      default:
        // ignore groups/pages/packages/dirs for now
        break;
    }
  }
}
Beispiel #7
0
AstNode *Ast::CreateDecorated(const location& loc, AstNode *decorators, AstNode *thing)
{
    FunctionDef *func = dynamic_cast<FunctionDef*>(thing);
    
    if (func) {
        func->AddDecorators(decorators);
        return func;
    }
    
    ClassDef *classDef = dynamic_cast<ClassDef*>(thing);
    if (classDef) {
        classDef->AddDecorators(decorators);
        return classDef;
    }
    
    assert(0);
    return 0;
}
Beispiel #8
0
QCString DiagramItem::label() const
{
  QCString result;
  if (!templSpec.isEmpty())
  {
    // we use classDef->name() here and not diplayName() in order
    // to get the name used in the inheritance relation.
    QCString n = classDef->name();
    if (/*n.right(2)=="-g" ||*/ n.right(2)=="-p")
    {
      n = n.left(n.length()-2);
    }
    result=insertTemplateSpecifierInScope(n,templSpec);
  }
  else
  {
    result=classDef->displayName();
  }
  if (Config_getBool("HIDE_SCOPE_NAMES")) result=stripScope(result);
  return result;
}
Beispiel #9
0
// members in a table
void MemberList::writeSimpleDocumentation(OutputList &ol,
        Definition *container)
{
    countDocMembers(FALSE);
    //printf("MemberList count=%d\n",numDocMembers());
    if (numDocMembers()==0) return;

    ClassDef *cd = 0;
    if (container && container->definitionType()==Definition::TypeClass)
    {
        cd = (ClassDef*)container;
    }
    ol.startMemberDocSimple(cd && cd->isJavaEnum());
    MemberListIterator mli(*this);
    MemberDef *md;
    for ( ; (md=mli.current()) ; ++mli)
    {
        md->writeMemberDocSimple(ol,container);
    }
    ol.endMemberDocSimple(cd && cd->isJavaEnum());
}
Beispiel #10
0
void FWeaponSlots::AddExtraWeapons()
{
	unsigned int i;

	// Set fractional positions for current weapons.
	for (i = 0; i < NUM_WEAPON_SLOTS; ++i)
	{
		Slots[i].SetInitialPositions();
	}

	// Append extra weapons to the slots.
	ClassDef::ClassIterator iter = ClassDef::GetClassIterator();
	ClassDef::ClassPair *pair;
	while (iter.NextPair(pair))
	{
		ClassDef *cls = pair->Value;

		if (//cls->ActorInfo != NULL &&
			//(cls->ActorInfo->GameFilter == GAME_Any || (cls->ActorInfo->GameFilter & gameinfo.gametype)) &&
			//cls->ActorInfo->Replacement == NULL &&	// Replaced weapons don't get slotted.
			cls->IsDescendantOf(NATIVE_CLASS(Weapon)) &&
			!LocateWeapon(cls, NULL, NULL)			// Don't duplicate it if it's already present.
			)
		{
			int slot = cls->Meta.GetMetaInt(AWMETA_SlotNumber, -1);
			if ((unsigned)slot < NUM_WEAPON_SLOTS)
			{
				fixed_t position = cls->Meta.GetMetaFixed(AWMETA_SlotPriority, INT_MAX);
				FWeaponSlot::WeaponInfo info = { cls, position };
				Slots[slot].Weapons.Push(info);
			}
		}
	}

	// Now resort every slot to put the new weapons in their proper places.
	for (i = 0; i < NUM_WEAPON_SLOTS; ++i)
	{
		Slots[i].Sort();
	}
}
Beispiel #11
0
static void writeInnerClasses(sqlite3*db,const ClassSDict *cl)
{
  if (!cl) return;

  ClassSDict::Iterator cli(*cl);
  ClassDef *cd;
  for (cli.toFirst();(cd=cli.current());++cli)
  {
    if (!cd->isHidden() && cd->name().find('@')==-1) // skip anonymous scopes
    {
      bindTextParameter(i_s_innerclass,":refid",cd->getOutputFileBase());
      bindIntParameter(i_s_innerclass,":prot",cd->protection());
      bindTextParameter(i_s_innerclass,":name",cd->name());
      step(db,i_s_innerclass);
    }
  }
}
Beispiel #12
0
/*! Add a member to the group with the highest priority */
void addMemberToGroups(Entry *root,MemberDef *md)
{
  //printf("addMemberToGroups:  Root %p = %s, md %p=%s groups=%d\n", 
  //    root, root->name.data(), md, md->name().data(), root->groups->count() );
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;

  // Search entry's group list for group with highest pri.
  Grouping::GroupPri_t pri = Grouping::GROUPING_LOWEST;
  GroupDef *fgd=0;
  for (;(g=gli.current());++gli)
  {
    GroupDef *gd=0;
    if (!g->groupname.isEmpty() &&
        (gd=Doxygen::groupSDict->find(g->groupname)) &&
        g->pri >= pri)
    {
      if (fgd && gd!=fgd && g->pri==pri) 
      {
        warn(root->fileName.data(), root->startLine,
            "warning: Member %s found in multiple %s groups! "
            "The member will be put in group %s, and not in group %s",
            md->name().data(), Grouping::getGroupPriName( pri ),
            gd->name().data(), fgd->name().data()
            );
      }

      fgd = gd;
      pri = g->pri;
    }
  }
  //printf("fgd=%p\n",fgd);

  // put member into group defined by this entry?
  if (fgd)
  {
    GroupDef *mgd = md->getGroupDef();
    //printf("mgd=%p\n",mgd);
    bool insertit = FALSE;
    if (mgd==0)
    {
      insertit = TRUE;
    }
    else if (mgd!=fgd)
    {
      bool moveit = FALSE;

      // move member from one group to another if 
      // - the new one has a higher priority
      // - the new entry has the same priority, but with docs where the old one had no docs
      if (md->getGroupPri()<pri)
      {
        moveit = TRUE;
      }
      else
      {
        if (md->getGroupPri()==pri)
        {
          if (!root->doc.isEmpty() && !md->getGroupHasDocs())
          {
            moveit = TRUE;
          }
          else if (!root->doc.isEmpty() && md->getGroupHasDocs())
          {
            warn(md->getGroupFileName(),md->getGroupStartLine(),
                "warning: Member documentation for %s found several times in %s groups!\n"
                "%s:%d: The member will remain in group %s, and won't be put into group %s",
                md->name().data(), Grouping::getGroupPriName( pri ),
                root->fileName.data(), root->startLine,
                mgd->name().data(),
                fgd->name().data()
                );
          }
        }
      }

      if (moveit)
      {
        //printf("removeMember\n");
        mgd->removeMember(md);
        insertit = TRUE;
      }
    }

    if (insertit)
    {
      //printf("insertMember found at %s line %d: %s: related %s\n",
      //    md->getDefFileName().data(),md->getDefLine(),
      //    md->name().data(),root->relates.data());
      bool success = fgd->insertMember(md);
      if (success)
      {
        //printf("insertMember successful\n");
        md->setGroupDef(fgd,pri,root->fileName,root->startLine,
            !root->doc.isEmpty());
        ClassDef *cd = md->getClassDefOfAnonymousType();
        if (cd) 
        {
          cd->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0);
        }
      }
    }
  }
}
Beispiel #13
0
void SearchIndex::setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile)
{
  if (ctx==0) return;
  assert(!isSourceFile || ctx->definitionType()==Definition::TypeFile);
  //printf("SearchIndex::setCurrentDoc(%s,%s,%s)\n",name,baseName,anchor);
  QCString url=isSourceFile ? ((FileDef*)ctx)->getSourceFileBase() : ctx->getOutputFileBase();
  url+=Config_getString("HTML_FILE_EXTENSION");
  if (anchor) url+=QCString("#")+anchor;  
  QCString name=ctx->qualifiedName();
  if (ctx->definitionType()==Definition::TypeMember)
  {
    MemberDef *md = (MemberDef *)ctx;
    name.prepend((md->getLanguage()==SrcLangExt_Fortran  ? 
                 theTranslator->trSubprogram(TRUE,TRUE) :
                 theTranslator->trMember(TRUE,TRUE))+" ");
  }
  else // compound type
  {
    SrcLangExt lang = ctx->getLanguage();
    QCString sep = getLanguageSpecificSeparator(lang);
    if (sep!="::")
    {
      name = substitute(name,"::",sep);
    }
    switch (ctx->definitionType())
    {
      case Definition::TypePage:
        {
          PageDef *pd = (PageDef *)ctx;
          if (!pd->title().isEmpty())
          {
            name = theTranslator->trPage(TRUE,TRUE)+" "+pd->title();
          }
          else
          {
            name = theTranslator->trPage(TRUE,TRUE)+" "+pd->name();
          }
        }
        break;
      case Definition::TypeClass:
        {
          ClassDef *cd = (ClassDef *)ctx;
          name.prepend(cd->compoundTypeString()+" ");
        }
        break;
      case Definition::TypeNamespace:
        {
          if (lang==SrcLangExt_Java || lang==SrcLangExt_CSharp)
          {
            name = theTranslator->trPackage(name);
          }
          else if (lang==SrcLangExt_Fortran)
          {
            name.prepend(theTranslator->trModule(TRUE,TRUE)+" ");
          }
          else
          {
            name.prepend(theTranslator->trNamespace(TRUE,TRUE)+" ");
          }
        }
        break;
      case Definition::TypeGroup:
        {
          GroupDef *gd = (GroupDef *)ctx;
          if (gd->groupTitle())
          {
            name = theTranslator->trGroup(TRUE,TRUE)+" "+gd->groupTitle();
          }
          else
          {
            name.prepend(theTranslator->trGroup(TRUE,TRUE)+" ");
          }
        }
        break;
      default:
        break;
    }
  }

  int *pIndex = m_url2IdMap.find(url);
  if (pIndex==0)
  {
    ++m_urlIndex;
    m_url2IdMap.insert(url,new int(m_urlIndex));
    m_urls.insert(m_urlIndex,new URL(name,url));
  }
  else
  {
    m_urls.insert(*pIndex,new URL(name,url));
  }
}
Beispiel #14
0
void NamespaceDef::writeTagFile(FTextStream &tagFile)
{
    tagFile << "  <compound kind=\"namespace\">" << endl;
    tagFile << "    <name>" << convertToXML(name()) << "</name>" << endl;
    tagFile << "    <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl;
    QCString idStr = id();
    if (!idStr.isEmpty())
    {
        tagFile << "    <clangid>" << convertToXML(idStr) << "</clangid>" << endl;
    }
    QListIterator<LayoutDocEntry> eli(
        LayoutDocManager::instance().docEntries(LayoutDocManager::Namespace));
    LayoutDocEntry *lde;
    for (eli.toFirst(); (lde=eli.current()); ++eli)
    {
        switch (lde->kind())
        {
        case LayoutDocEntry::NamespaceNestedNamespaces:
        {
            if (namespaceSDict)
            {
                SDict<NamespaceDef>::Iterator ni(*namespaceSDict);
                NamespaceDef *nd;
                for (ni.toFirst(); (nd=ni.current()); ++ni)
                {
                    if (nd->isLinkableInProject())
                    {
                        tagFile << "    <namespace>" << convertToXML(nd->name()) << "</namespace>" << endl;
                    }
                }
            }
        }
        break;
        case LayoutDocEntry::NamespaceClasses:
        {
            if (classSDict)
            {
                SDict<ClassDef>::Iterator ci(*classSDict);
                ClassDef *cd;
                for (ci.toFirst(); (cd=ci.current()); ++ci)
                {
                    if (cd->isLinkableInProject())
                    {
                        tagFile << "    <class kind=\"" << cd->compoundTypeString()
                                << "\">" << convertToXML(cd->name()) << "</class>" << endl;
                    }
                }
            }
        }
        case LayoutDocEntry::MemberDecl:
        {
            LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde;
            MemberList * ml = getMemberList(lmd->type);
            if (ml)
            {
                ml->writeTagFile(tagFile);
            }
        }
        break;
        case LayoutDocEntry::MemberGroups:
        {
            if (memberGroupSDict)
            {
                MemberGroupSDict::Iterator mgli(*memberGroupSDict);
                MemberGroup *mg;
                for (; (mg=mgli.current()); ++mgli)
                {
                    mg->writeTagFile(tagFile);
                }
            }
        }
        break;
        default:
            break;
        }
    }
    writeDocAnchorsToTagFile(tagFile);
    tagFile << "  </compound>" << endl;
}
Beispiel #15
0
//====================
//Player::SpawnActor
//====================
void Player::SpawnActor
	(
	Event *ev
	)

	{
	Entity   *ent;
   str      name;
   str      text;
   Vector	forward;
	Vector	up;
   Vector	delta;
	Vector	v;
	int		n;
	int		i;
	ClassDef	*cls;
   Event    *e;

   if ( ev->NumArgs() < 1 )
		{
		ScriptError( "Usage: actor [modelname] [keyname] [value]..." );
		return;
		}

   name = ev->GetString( 1 );
   if ( !name[ 0 ] )
		{
		ScriptError( "Must specify a model name" );
		return;
		}

   if ( !strstr( name.c_str(), ".tik" ) )
      {
      name += ".tik";
      }

   // create a new entity
	SpawnArgs args;

   args.setArg( "model", name.c_str() );

   cls = args.getClassDef();

   if ( cls == &Object::ClassInfo )
      {
      cls = &Actor::ClassInfo;
      }

   if ( !cls || !checkInheritance( &Actor::ClassInfo, cls ) )
      {
      ScriptError( "%s is not a valid Actor", name.c_str() );
      return;
      }
   
   ent = ( Entity * )cls->newInstance();
   e = new Event( EV_Model );
   e->AddString( name.c_str() );
   ent->PostEvent( e, EV_SPAWNARG );

   angles.AngleVectors( &forward, NULL, &up );
   v = origin + ( forward + up ) * 40;

   e = new Event( EV_SetOrigin );
   e->AddVector( v );
   ent->PostEvent( e, EV_SPAWNARG );

   delta = origin - v;
	v = delta.toAngles();

   e = new Event( EV_SetAngle );
   e->AddFloat( v[ 1 ] );
   ent->PostEvent( e, EV_SPAWNARG );

   if ( ev->NumArgs() > 2 )
		{
		n = ev->NumArgs();
		for( i = 2; i <= n; i += 2 )
			{
         e = new Event( ev->GetString( i ) );
         e->AddToken( ev->GetString( i + 1 ) );
         ent->PostEvent( e, EV_SPAWNARG );
			}
		}
   }
Beispiel #16
0
void GroupDef::writeTagFile(FTextStream &tagFile)
{
  tagFile << "  <compound kind=\"group\">" << endl;
  tagFile << "    <name>" << convertToXML(name()) << "</name>" << endl;
  tagFile << "    <title>" << convertToXML(title) << "</title>" << endl;
  tagFile << "    <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl;
  QListIterator<LayoutDocEntry> eli(
      LayoutDocManager::instance().docEntries(LayoutDocManager::Group));
  LayoutDocEntry *lde;
  for (eli.toFirst();(lde=eli.current());++eli)
  {
    switch (lde->kind())
    {
      case LayoutDocEntry::GroupClasses:
        {
          if (classSDict)
          {
            SDict<ClassDef>::Iterator ci(*classSDict);
            ClassDef *cd;
            for (ci.toFirst();(cd=ci.current());++ci)
            {
              if (cd->isLinkableInProject())
              {
                tagFile << "    <class kind=\"" << cd->compoundTypeString()
                        << "\">" << convertToXML(cd->name()) << "</class>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupNamespaces:
        {
          if (namespaceSDict)
          {
            SDict<NamespaceDef>::Iterator ni(*namespaceSDict);
            NamespaceDef *nd;
            for (ni.toFirst();(nd=ni.current());++ni)
            {
              if (nd->isLinkableInProject())
              {
                tagFile << "    <namespace>" << convertToXML(nd->name())
                        << "</namespace>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupFiles:
        {
          if (fileList)
          {
            QListIterator<FileDef> it(*fileList);
            FileDef *fd;
            for (;(fd=it.current());++it)
            {
              if (fd->isLinkableInProject())
              {
                tagFile << "    <file>" << convertToXML(fd->name()) << "</file>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupPageDocs:
        {
          if (pageDict)
          {
            PageSDict::Iterator pdi(*pageDict);
            PageDef *pd=0;
            for (pdi.toFirst();(pd=pdi.current());++pdi)
            {
              QCString pageName = pd->getOutputFileBase();
              if (pd->isLinkableInProject())
              {
                tagFile << "    <page>" << convertToXML(pageName) << "</page>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupDirs:
        {
          if (dirList)
          {
            QListIterator<DirDef> it(*dirList);
            DirDef *dd;
            for (;(dd=it.current());++it)
            {
              if (dd->isLinkableInProject())
              {
                tagFile << "    <dir>" << convertToXML(dd->displayName()) << "</dir>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupNestedGroups:
        {
          if (groupList)
          {
            QListIterator<GroupDef> it(*groupList);
            GroupDef *gd;
            for (;(gd=it.current());++it)
            {
              if (gd->isVisible())
              {
                tagFile << "    <subgroup>" << convertToXML(gd->name()) << "</subgroup>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::MemberDecl:
        {
          LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde;
          MemberList * ml = getMemberList(lmd->type);
          if (ml)
          {
            ml->writeTagFile(tagFile);
          }
        }
        break;
      case LayoutDocEntry::MemberGroups:
        {
          if (memberGroupSDict)
          {
            MemberGroupSDict::Iterator mgli(*memberGroupSDict);
            MemberGroup *mg;
            for (;(mg=mgli.current());++mgli)
            {
              mg->writeTagFile(tagFile);
            }
          }
        }
        break;
      default:
        break;
    }
  }
  writeDocAnchorsToTagFile(tagFile);
  tagFile << "  </compound>" << endl;
}
Beispiel #17
0
static void parseEnums(ClassDef &Def, bool isFlag, clang::Expr *Content, clang::Sema &Sema) {
    clang::Preprocessor &PP = Sema.getPreprocessor();
    clang::StringLiteral *Val = llvm::dyn_cast<clang::StringLiteral>(Content);
    if (!Val) {
        PP.getDiagnostics().Report(Content->getExprLoc(),
                                   PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error,
                                   "Invalid Q_ENUMS annotation"));
        return;
    }

    llvm::MemoryBuffer* Buf = maybe_unique(llvm::MemoryBuffer::getMemBufferCopy(Val->getString(), "Q_ENUMS"));
    clang::Lexer Lex(CreateFileIDForMemBuffer(PP, Buf, Content->getExprLoc()),
                     Buf, PP.getSourceManager(), PP.getLangOpts());

    clang::CXXScopeSpec SS;
    clang::Token Tok, Next;
    Lex.LexFromRawLexer(Tok);
    for (; !Tok.is(clang::tok::eof); Tok = Next) {
        Lex.LexFromRawLexer(Next);
        clang::IdentifierInfo* II = nullptr;
        if (Tok.is(clang::tok::raw_identifier))
            II = PP.LookUpIdentifierInfo(Tok);


        if (Tok.is(clang::tok::identifier)) {

            if (Next.is(clang::tok::coloncolon)) {
                if (Sema.ActOnCXXNestedNameSpecifier(Sema.getScopeForContext(Def.Record), *II,
                        GetFromLiteral(Tok, Val, PP), GetFromLiteral(Next, Val, PP), {}, false, SS))
                    SS.SetInvalid({GetFromLiteral(Tok, Val, PP), GetFromLiteral(Next, Val, PP)});

                Lex.LexFromRawLexer(Next);
                continue;
            }

            clang::LookupResult Found(Sema, II, GetFromLiteral(Tok, Val, PP), clang::Sema::LookupNestedNameSpecifierName);
            if (SS.isEmpty())
                Sema.LookupQualifiedName(Found, Def.Record);
            else {
                clang::DeclContext* DC = Sema.computeDeclContext(SS);
                Sema.LookupQualifiedName(Found, DC ? DC : Def.Record);
            }

            llvm::StringRef Alias;
            clang::EnumDecl* R = Found.getAsSingle<clang::EnumDecl>();

            if (!R) {
                if (clang::TypedefDecl *TD = Found.getAsSingle<clang::TypedefDecl>()) {
                    const clang::EnumType* ET = TD->getUnderlyingType()->getAs<clang::EnumType>();
                    const clang::TemplateSpecializationType* TDR = TD->getUnderlyingType()->getAs<clang::TemplateSpecializationType>();
                    if(TDR && TDR->getNumArgs() == 1 && TDR->getTemplateName().getAsTemplateDecl()->getName() == "QFlags")
                        ET = TDR->getArg(0).getAsType()->getAs<clang::EnumType>();
                    if (ET) {
                        R = ET->getDecl();
                        if (TD->getIdentifier())
                            Alias = TD->getName();
                    }
                }
            }

            if (Found.empty() || !R) {
                // TODO: typo correction

                // This should be an error, but the official moc do not understand that as an error.
                PP.getDiagnostics().Report(GetFromLiteral(Tok, Val, PP),
                                           PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Warning,
                                            "no enum names %0")) << Found.getLookupName();
                break;
            }
            if (R->getDeclContext() == Def.Record) {
                if (Alias.empty() && R->getIdentifier())
                    Alias = R->getName();
                Def.addEnum(R, Alias.empty() ? R->getNameAsString() : std::string(Alias), isFlag);
            } else if (R->getDeclContext()->isRecord() &&  llvm::isa<clang::CXXRecordDecl>(R->getDeclContext())) {
                // TODO: check it is a QObject
                Def.addExtra(llvm::cast<clang::CXXRecordDecl>(R->getDeclContext()));
            }
            SS.clear();
            continue;
        } else if (Tok.is(clang::tok::coloncolon)) {
            if (SS.isEmpty()) {
                SS.MakeGlobal(Sema.getASTContext(), GetFromLiteral(Tok, Val, PP));
                continue;
            }
        }

        PP.getDiagnostics().Report(GetFromLiteral(Tok, Val, PP),
                                       PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error,
                                       "Invalid token in Q_ENUMS"));
        break;
    }


}
Beispiel #18
0
//====================
//Player::SpawnEntity
//====================
void Player::SpawnEntity
	(
	Event *ev
	)

	{
	Entity		*ent;
   str         name;
	ClassDef		*cls;
   str         text;
   Vector		forward;
	Vector		up;
   Vector		delta;
	Vector		v;
	int			n;
	int			i;
   Event       *e;

   if ( ev->NumArgs() < 1 )
		{
		ScriptError( "Usage: spawn entityname [keyname] [value]..." );
		return;
		}

   name = ev->GetString( 1 );
   if ( !name.length() )
		{
		ScriptError( "Must specify an entity name" );
		return;
		}

   // create a new entity
   SpawnArgs args;

   args.setArg( "classname", name.c_str() );
   args.setArg( "model", name.c_str() );

   cls = args.getClassDef();
   if ( !cls )
      {
      cls = &Entity::ClassInfo;
      }

   if ( !checkInheritance( &Entity::ClassInfo, cls ) )
      {
      ScriptError( "%s is not a valid Entity", name.c_str() );
      return;
      }

   ent = ( Entity * )cls->newInstance();

   e = new Event( EV_Model );
   e->AddString( name.c_str() );
   ent->PostEvent( e, EV_PRIORITY_SPAWNARG );

   angles.AngleVectors( &forward, NULL, &up );
   v = origin + ( forward + up ) * 40;

   e = new Event( EV_SetOrigin );
   e->AddVector( v );
   ent->PostEvent( e, EV_SPAWNARG );

   delta = origin - v;
	v.x = 0;
   v.y = delta.toYaw();
   v.z = 0;

   e = new Event( EV_SetAngles );
   e->AddVector( v );
   ent->PostEvent( e, EV_SPAWNARG );

   if ( ev->NumArgs() > 2 )
		{
		n = ev->NumArgs();
		for( i = 2; i <= n; i += 2 )
			{
         e = new Event( ev->GetString( i ) );
         e->AddToken( ev->GetString( i + 1 ) );
		 ent->PostEvent( e, EV_SPAWNARG );
			}
		}

   e = new Event( EV_SetAnim );
   e->AddString( "idle" );
   ent->PostEvent( e, EV_SPAWNARG );
   }
Beispiel #19
0
QCString DiagramItem::fileName() const
{
  return classDef->getOutputFileBase();
}
Beispiel #20
0
ClassDef MocNg::parseClass(clang::CXXRecordDecl* RD, clang::Sema& Sema)
{
    clang::Preprocessor &PP = Sema.getPreprocessor();
    ClassDef Def;
    Def.Record = RD;

    for (auto it = RD->decls_begin(); it != RD->decls_end(); ++it) {
        if (clang::StaticAssertDecl *S = llvm::dyn_cast<clang::StaticAssertDecl>(*it) ) {
            if (auto *E = llvm::dyn_cast<clang::UnaryExprOrTypeTraitExpr>(S->getAssertExpr()))
                if (clang::ParenExpr *PE = llvm::dyn_cast<clang::ParenExpr>(E->getArgumentExpr()))
            {
                llvm::StringRef key = S->getMessage()->getString();
                if (key == "qt_property") {
                    clang::StringLiteral *Val = llvm::dyn_cast<clang::StringLiteral>(PE->getSubExpr());
                    if (Val) {
                        PropertyParser Parser(Val->getString(),
    //                                          Val->getStrTokenLoc(0),
                                            Val->getLocationOfByte(0, PP.getSourceManager(), PP.getLangOpts(), PP.getTargetInfo()),
                                            Sema, Def.Record);
                        Def.Properties.push_back(Parser.parseProperty());
                        Def.addExtra(Parser.Extra);
                    } else {
                        PP.getDiagnostics().Report(S->getLocation(),
                                                   PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error,
                                                   "Invalid Q_PROPERTY annotation"));
                    }
                } else if (key == "qt_private_property") {
                    clang::StringLiteral *Val1 = nullptr, *Val2 = nullptr;
                    std::tie(Val1, Val2) = ExtractLiterals(PE, PP, "Q_PRIVATE_PROPERTY",
                                                           "Invalid Q_PRIVATE_PROPERTY annotation");

                    if (Val1 && Val2) {
                        PropertyParser Parser(Val2->getString(),
                                              Val2->getLocationOfByte(0, PP.getSourceManager(), PP.getLangOpts(), PP.getTargetInfo()),
                                              Sema, Def.Record);
                        PropertyDef P = Parser.parseProperty(true);
                        P.inPrivateClass = Val1->getString();
                        Def.Properties.push_back(std::move(P));
                        Def.addExtra(Parser.Extra);
                    }
                } else if (key == "qt_private_slot") {
                    clang::StringLiteral *Val1 = nullptr, *Val2 = nullptr;
                    std::tie(Val1, Val2) = ExtractLiterals(PE, PP, "Q_PRIVATE_SLOT",
                                                           "Invalid Q_PRIVATE_SLOT annotation");
                    if (Val1 && Val2) {
                        PropertyParser Parser(Val2->getString(),
                                              Val2->getLocationOfByte(0, PP.getSourceManager(), PP.getLangOpts(), PP.getTargetInfo()),
                                              Sema, Def.Record);
                        PrivateSlotDef P = Parser.parsePrivateSlot();
                        P.InPrivateClass = Val1->getString();
                        if (!P.Name.empty()) {
                            Def.PrivateSlotCount += P.NumDefault + 1;
                            Def.PrivateSlots.push_back(std::move(P));
                        }
                    }
                } else if (key == "qt_enums")  {
                    parseEnums(Def, false, PE->getSubExpr(), Sema);
                } else if (key == "qt_flags")  {
                    parseEnums(Def, true, PE->getSubExpr(), Sema);
                } else if (key == "qt_qobject") {
                    Def.HasQObject = true;
                } else if (key == "qt_fake") {
                    Def.HasQGadget = false;
                } else if (key == "qt_qgadget") {
                    Def.HasQGadget = true;
                } else if (key == "qt_classinfo") {
                    clang::StringLiteral *Val1 = nullptr, *Val2 = nullptr;
                    std::tie(Val1, Val2) = ExtractLiterals(PE, PP, "Q_CLASSINFO",
                                                           "Expected string literal in Q_CLASSINFO");

                    if (Val1 && Val2) {
                        Def.ClassInfo.emplace_back(Val1->getString(), Val2->getString());
                    }
                } else if (key == "qt_interfaces") {
                    parseInterfaces(Def, PE->getSubExpr(), Sema);
                } else if (key == "qt_plugin_metadata") {
                    parsePluginMetaData(Def, PE->getSubExpr(), Sema);
                    HasPlugin = true;
                }
            }
        } else if (clang::CXXMethodDecl *M = llvm::dyn_cast<clang::CXXMethodDecl>(*it)) {
            for (auto attr_it = M->specific_attr_begin<clang::AnnotateAttr>();
                attr_it != M->specific_attr_end<clang::AnnotateAttr>();
                ++attr_it) {

                const clang::AnnotateAttr *A = *attr_it;
                if (A->getAnnotation() == "qt_signal") {
                        Def.Signals.push_back(M);
                } else if (A->getAnnotation() == "qt_slot") {
                        Def.Slots.push_back(M);
                } else if (A->getAnnotation() == "qt_invokable" || A->getAnnotation() == "qt_scriptable" ) {
                    if (auto *C = llvm::dyn_cast<clang::CXXConstructorDecl>(M)) {
                            Def.Constructors.push_back(C);
                    } else {
                            Def.Methods.push_back(M);
                    }
                } else if (A->getAnnotation().startswith("qt_revision:")) {
                    Def.RevisionMethodCount++;
                }
            }
        }
    }

    //Check notify Signals
    for (PropertyDef &P: Def.Properties) {
        if (!P.notify.Str.empty()) {
            int Idx = 0;
            for (clang::CXXMethodDecl *MD : Def.Signals) {
                if (MD->getName() == P.notify.Str) {
                    P.notify.notifyId = Idx;
                    P.notify.MD = MD;
                    break;
                }
                Idx += 1 + MD->getNumParams() - MD->getMinRequiredArguments();
            }
            if (P.notify.notifyId < 0 ) {
                PP.getDiagnostics().Report(P.notify.Loc,
                        PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error,
                        "NOTIFY signal '%0' of property '%1' does not exist in class %2"))
                    << P.notify.Str << P.name << Def.Record;
            } else {
                Def.NotifyCount++;
            }
        }

        if (P.revision > 0)
            Def.RevisionPropertyCount++;
    }
    return Def;
}
Beispiel #21
0
void generateSqlite3()
{
  // + classes
  // + namespaces
  // + files
  // + groups
  // + related pages
  // + examples
  // + main page

  QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY");
  QDir sqlite3Dir(outputDirectory);
  sqlite3 *db;
  sqlite3_initialize();
  int rc = sqlite3_open_v2(outputDirectory+"/doxygen_sqlite3.db", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
  if (rc != SQLITE_OK)
  {
    sqlite3_close(db);
    msg("database open failed: %s\n", "doxygen_sqlite3.db");
    return;
  }
  beginTransaction(db);
  pragmaTuning(db);

  if (-1==initializeSchema(db))
    return;

  if ( -1 == prepareStatements(db) )
  {
    err("sqlite generator: prepareStatements failed!");
    return;
  }

  // + classes
  ClassSDict::Iterator cli(*Doxygen::classSDict);
  ClassDef *cd;
  for (cli.toFirst();(cd=cli.current());++cli)
  {
    msg("Generating Sqlite3 output for class %s\n",cd->name().data());
    generateSqlite3ForClass(db,cd);
  }

  // + namespaces
  NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
  NamespaceDef *nd;
  for (nli.toFirst();(nd=nli.current());++nli)
  {
    msg("Generating Sqlite3 output for namespace %s\n",nd->name().data());
    generateSqlite3ForNamespace(db,nd);
  }

  // + files
  FileNameListIterator fnli(*Doxygen::inputNameList);
  FileName *fn;
  for (;(fn=fnli.current());++fnli)
  {
    FileNameIterator fni(*fn);
    FileDef *fd;
    for (;(fd=fni.current());++fni)
    {
      msg("Generating Sqlite3 output for file %s\n",fd->name().data());
      generateSqlite3ForFile(db,fd);
    }
  }

  // + groups
  GroupSDict::Iterator gli(*Doxygen::groupSDict);
  GroupDef *gd;
  for (;(gd=gli.current());++gli)
  {
    msg("Generating Sqlite3 output for group %s\n",gd->name().data());
    generateSqlite3ForGroup(db,gd);
  }

  // + page
  {
    PageSDict::Iterator pdi(*Doxygen::pageSDict);
    PageDef *pd=0;
    for (pdi.toFirst();(pd=pdi.current());++pdi)
    {
      msg("Generating Sqlite3 output for page %s\n",pd->name().data());
      generateSqlite3ForPage(db,pd,FALSE);
    }
  }

  // + dirs
  {
    DirDef *dir;
    DirSDict::Iterator sdi(*Doxygen::directories);
    for (sdi.toFirst();(dir=sdi.current());++sdi)
    {
      msg("Generating Sqlite3 output for dir %s\n",dir->name().data());
      generateSqlite3ForDir(db,dir);
    }
  }

  // + examples
  {
    PageSDict::Iterator pdi(*Doxygen::exampleSDict);
    PageDef *pd=0;
    for (pdi.toFirst();(pd=pdi.current());++pdi)
    {
      msg("Generating Sqlite3 output for example %s\n",pd->name().data());
      generateSqlite3ForPage(db,pd,TRUE);
    }
  }

  // + main page
  if (Doxygen::mainPage)
  {
    msg("Generating Sqlite3 output for the main page\n");
    generateSqlite3ForPage(db,Doxygen::mainPage,FALSE);
  }

  endTransaction(db);
}
Beispiel #22
0
void DocSets::addIndexItem(const char *, const char *, 
                           const char *, const char *,
                           const char *,const MemberDef *md)
{
  if (!md->isLinkable()) return; // internal symbol

  ClassDef *cd     = md->getClassDef();
  NamespaceDef *nd = md->getNamespaceDef();
  FileDef  *fd     = md->getFileDef();

  // determine language
  QCString lang;
  SrcLangExt langExt = SrcLangExt_Cpp;
  if (fd) langExt = getLanguageFromFileName(fd->name());
  switch (langExt)
  {
    case SrcLangExt_Cpp:
      {
        if (md->isObjCMethod())                        
          lang="occ";  // Objective C/C++
        else if (fd && fd->name().right(2).lower()==".c") 
          lang="c";    // Plain C
        else                                      
          lang="cpp";  // C++
      }
      break;
    case SrcLangExt_ObjC:   lang="occ"; break;        // Objective C++
    case SrcLangExt_IDL:    lang="idl"; break;        // IDL
    case SrcLangExt_CSharp: lang="csharp"; break;     // C#
    case SrcLangExt_PHP:    lang="php"; break;        // PHP4/5
    case SrcLangExt_D:      lang="d"; break;          // D
    case SrcLangExt_Java:   lang="java"; break;       // Java
    case SrcLangExt_JS:     lang="javascript"; break; // Javascript
    case SrcLangExt_Python: lang="python"; break;     // Python
    case SrcLangExt_F90:    lang="fortran"; break;    // Fortran
    case SrcLangExt_VHDL:   lang="vhdl"; break;       // VHDL
  }

  // determine scope
  QCString scope;
  QCString type;
  QCString decl;
  Definition *d = 0;
  if (fd && fd->isLinkable() && m_scopes.find(fd->getOutputFileBase())==0)
  {
    writeToken(m_tts,fd,"file",lang,0,0,0);
    m_scopes.append(fd->getOutputFileBase(),(void*)0x8);
  }
  if (cd) 
  {
    scope = cd->qualifiedName();
    if (cd->isTemplate()) 
      type="tmplt";
    else if (cd->compoundType()==ClassDef::Protocol) 
      type="intf";
    else if (cd->compoundType()==ClassDef::Interface) 
      type="cl";
    else if (cd->compoundType()==ClassDef::Category)
      type="cat";
    else 
      type = "cl";
    d = cd;
    IncludeInfo *ii = cd->includeInfo();
    if (ii)
    {
      decl=ii->includeName;
      if (decl.isEmpty())
      {
        decl=ii->local;
      }
    }
  }
  else if (nd) 
  {
    scope = nd->name();
    type = "ns";
    d = cd;
  }
  if (d && d->isLinkable() && m_scopes.find(d->getOutputFileBase())==0)
  {
    writeToken(m_tts,d,type,lang,0,0,decl);
    m_scopes.append(d->getOutputFileBase(),(void*)0x8);
  }

  switch (md->memberType())
  {
    case MemberDef::Define:
      type="macro"; break;
    case MemberDef::Function:
      if (cd && cd->compoundType()==ClassDef::Interface) 
        type="intfm";
      else if (cd && cd->compoundType()==ClassDef::Class) 
        type="clm"; 
      else 
        type="func"; 
      break;
    case MemberDef::Variable:
      type="data"; break;
    case MemberDef::Typedef:
      type="tdef"; break;
    case MemberDef::Enumeration:
      type="enum"; break;
    case MemberDef::EnumValue:
      type="econst"; break;
    //case MemberDef::Prototype:
    //  type="prototype"; break;
    case MemberDef::Signal:
      type="signal"; break;
    case MemberDef::Slot:
      type="slot"; break;
    case MemberDef::Friend:
      type="ffunc"; break;
    case MemberDef::DCOP:
      type="dcop"; break;
    case MemberDef::Property:
      type="property"; break;
    case MemberDef::Event:
      type="event"; break;
  }
  writeToken(m_tts,md,type,lang,scope,md->anchor());
}
Beispiel #23
0
void generateSqlite3()
{
  // + classes
  // + namespaces
  // + files
  // - groups
  // - related pages
  // - examples
  //QCString outputDirectory = Config_getString("SQLITE3_OUTPUT");
  QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY");
  QDir sqlite3Dir(outputDirectory);
  sqlite3 *db;
  sqlite3_initialize();
  int rc = sqlite3_open_v2(outputDirectory+"/doxygen_sqlite3.db", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
  if (rc != SQLITE_OK) 
  {
    sqlite3_close(db);
    msg("database open failed: %s\n", "doxygen_sqlite3.db");
    exit(-1);
  }
  beginTransaction(db);
  pragmaTuning(db);

  initializeSchema(db);
  if ( -1 == prepareStatements(db) )
  {
    err("sqlite generator: prepareStatements failed!");
    return;
  }

  // + classes
  ClassSDict::Iterator cli(*Doxygen::classSDict);
  ClassDef *cd;
  for (cli.toFirst();(cd=cli.current());++cli)
  {
    msg("Generating Sqlite3 output for class %s\n",cd->name().data());
    generateSqlite3ForClass(db,cd);
  }

  // + namespaces
  NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
  NamespaceDef *nd;
  for (nli.toFirst();(nd=nli.current());++nli)
  {
    msg("Generating Sqlite3 output for namespace %s\n",nd->name().data());
    generateSqlite3ForNamespace(db,nd);
  }

  // + files
  FileNameListIterator fnli(*Doxygen::inputNameList);
  FileName *fn;
  for (;(fn=fnli.current());++fnli)
  {
    FileNameIterator fni(*fn);
    FileDef *fd;
    for (;(fd=fni.current());++fni)
    {
      msg("Generating Sqlite3 output for file %s\n",fd->name().data());
      generateSqlite3ForFile(db,fd);
    }
  }
  endTransaction(db);
}
Beispiel #24
0
void DocSets::addIndexItem(Definition *context,MemberDef *md,
                           const char *,const char *)
{
  if (md==0 && context==0) return;

  FileDef *fd      = 0;
  ClassDef *cd     = 0;
  NamespaceDef *nd = 0;

  if (md)
  {
    fd = md->getFileDef();
    cd = md->getClassDef();
    nd = md->getNamespaceDef();
    if (!md->isLinkable()) return; // internal symbol
  }

  QCString scope;
  QCString type;
  QCString decl;

  // determine language
  QCString lang;
  SrcLangExt langExt = SrcLangExt_Cpp;
  if (md) 
  {
    langExt = md->getLanguage();
  }
  else if (context) 
  {
    langExt = context->getLanguage();
  }
  switch (langExt)
  {
    case SrcLangExt_Cpp:
    case SrcLangExt_ObjC:
      {
        if (md && (md->isObjCMethod() || md->isObjCProperty()))
          lang="occ";  // Objective C/C++
        else if (fd && fd->name().right(2).lower()==".c") 
          lang="c";    // Plain C
        else if (cd==0 && nd==0)
          lang="c";    // Plain C symbol outside any class or namespace
        else
          lang="cpp";  // C++
      }
      break;
    case SrcLangExt_IDL:     lang="idl"; break;        // IDL
    case SrcLangExt_CSharp:  lang="csharp"; break;     // C#
    case SrcLangExt_PHP:     lang="php"; break;        // PHP4/5
    case SrcLangExt_D:       lang="d"; break;          // D
    case SrcLangExt_Java:    lang="java"; break;       // Java
    case SrcLangExt_JS:      lang="javascript"; break; // Javascript
    case SrcLangExt_Python:  lang="python"; break;     // Python
    case SrcLangExt_Fortran: lang="fortran"; break;    // Fortran
    case SrcLangExt_VHDL:    lang="vhdl"; break;       // VHDL
    case SrcLangExt_XML:     lang="xml"; break;        // DBUS XML
    case SrcLangExt_Tcl:     lang="tcl"; break;        // Tcl
    case SrcLangExt_Markdown:lang="markdown"; break;   // Markdown
    case SrcLangExt_Unknown: lang="unknown"; break;    // should not happen!
  }

  if (md)
  {
    if (context==0)
    {
      if (md->getGroupDef())
        context = md->getGroupDef();
      else if (md->getFileDef())
        context = md->getFileDef();
    }
    if (context==0) return; // should not happen

    switch (md->memberType())
    {
      case MemberType_Define:
        type="macro"; break;
      case MemberType_Function:
        if (cd && (cd->compoundType()==ClassDef::Interface ||
              cd->compoundType()==ClassDef::Class))
        {
          if (md->isStatic())
            type="clm";         // class member
          else
            type="instm";       // instance member
        }
        else if (cd && cd->compoundType()==ClassDef::Protocol)
        {
          if (md->isStatic())
            type="intfcm";     // interface class member
          else
            type="intfm";      // interface member
        }
        else
          type="func";
        break;
      case MemberType_Variable:
        type="data"; break;
      case MemberType_Typedef:
        type="tdef"; break;
      case MemberType_Enumeration:
        type="enum"; break;
      case MemberType_EnumValue:
        type="econst"; break;
        //case MemberDef::Prototype:
        //  type="prototype"; break;
      case MemberType_Signal:
        type="signal"; break;
      case MemberType_Slot:
        type="slot"; break;
      case MemberType_Friend:
        type="ffunc"; break;
      case MemberType_DCOP:
        type="dcop"; break;
      case MemberType_Property:
        if (cd && cd->compoundType()==ClassDef::Protocol) 
          type="intfp";         // interface property
        else 
          type="instp";         // instance property
        break;
      case MemberType_Event:
        type="event"; break;
      case MemberType_Interface:
        type="ifc"; break;
      case MemberType_Service:
        type="svc"; break;
    }
    cd = md->getClassDef();
    nd = md->getNamespaceDef();
    if (cd) 
    {
      scope = cd->qualifiedName();
    }
    else if (nd)
    {
      scope = nd->name();
    }
    MemberDef *declMd = md->memberDeclaration();
    if (declMd==0) declMd = md;
    {
      fd = md->getFileDef();
      if (fd)
      {
        decl = fd->name();
      }
    }
    writeToken(m_tts,md,type,lang,scope,md->anchor(),decl);
  }
  else if (context && context->isLinkable())
  {
    if (fd==0 && context->definitionType()==Definition::TypeFile)
    {
      fd = (FileDef*)context;
    }
    if (cd==0 && context->definitionType()==Definition::TypeClass)
    {
      cd = (ClassDef*)context;
    }
    if (nd==0 && context->definitionType()==Definition::TypeNamespace)
    {
      nd = (NamespaceDef*)context;
    }
    if (fd)
    {
      type="file";
    }
    else if (cd) 
    {
      scope = cd->qualifiedName();
      if (cd->isTemplate())
      {
        type="tmplt";
      }
      else if (cd->compoundType()==ClassDef::Protocol) 
      {
        type="intf";
        if (scope.right(2)=="-p") scope=scope.left(scope.length()-2);
      }
      else if (cd->compoundType()==ClassDef::Interface)
      {
        type="cl";
      }
      else if (cd->compoundType()==ClassDef::Category)
      {
        type="cat";
      }
      else 
      {
        type = "cl";
      }
      IncludeInfo *ii = cd->includeInfo();
      if (ii)
      {
        decl=ii->includeName;
      }
    }
    else if (nd)
    {
      scope = nd->name();
      type = "ns";
    }
    if (m_scopes.find(context->getOutputFileBase())==0)
    {
      writeToken(m_tts,context,type,lang,scope,0,decl);
      m_scopes.append(context->getOutputFileBase(),(void*)0x8);
    }
  }
}
Beispiel #25
0
void CEditProjectMgr::LoadBinaries()
{
	CString dllFilename, str;
	DWORD i, j;
	int status, version, nClasses;
	ClassDef **pClasses, *pInClass, *pOutClass;
	HKEY hKey;
	DWORD valType, dataBufSize;
	BYTE dataBuf[261];


	UnloadBinaries();


	if(!m_bProjectDirectorySet)
		return;

	// Look in the project directory for the object DLL.
	dllFilename = dfm_BuildName(m_BaseProjectDir, "object.lto");
	status = cb_LoadModule((char*)(LPCTSTR)dllFilename, NULL, &m_hModule, &version);

	if(status != CB_NOERROR)
	{
		if(status == CB_CANTFINDMODULE)
		{
			
			// If we can't load it, let's check out the error.
			DWORD dwErrorCode = GetLastError();

			// Allocacte a string containing a human readable description of the error
			LPVOID lpMsgBuf;
			FormatMessage( 
				FORMAT_MESSAGE_ALLOCATE_BUFFER | 
				FORMAT_MESSAGE_FROM_SYSTEM | 
				FORMAT_MESSAGE_IGNORE_INSERTS,
				NULL,
				dwErrorCode,
				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
				(LPTSTR) &lpMsgBuf,
				0,
				NULL 
				);

            // Print out to the DEdit debug window.
			GetDebugDlg()->AddMessage(" Failed to load:\n %s\n"
									  " System Error Code: %d\n"
									  " Description: %s\n", dllFilename.GetBuffer(), dwErrorCode, (LPCTSTR)lpMsgBuf);

			// deallocate the string
			LocalFree( lpMsgBuf );

			str.Format(IDS_CANTFINDCLASSMODULE, dllFilename.GetBuffer());
		}
		else if(status == CB_NOTCLASSMODULE)
		{
			str.Format(IDS_INVALIDCLASSMODULE, dllFilename.GetBuffer());
		}
		else if(status == CB_VERSIONMISMATCH)
		{
			str.Format(IDS_INVALIDCLASSMODULEVERSION, dllFilename.GetBuffer(), SERVEROBJ_VERSION, version);
		}

		AppMessageBox(str, MB_OK);
		return;
	}
	
	// Get the ClassDefs.
	nClasses = cb_GetNumClassDefs(m_hModule);
	pClasses = cb_GetClassDefs(m_hModule);

	// Copy the class data over.
	m_ClassDefs = (ClassDef*)malloc(sizeof(ClassDef) * nClasses);
	m_nClassDefs = nClasses;

	// Prepare some temporary data for editstring lists
	const DDWORD cMaxStrings = 512;
	const DDWORD cMaxStringLen = 256;
	char* aszStrings[cMaxStrings];
	{for ( int iString = 0 ; iString < cMaxStrings ; iString++ )
	{
		aszStrings[iString] = new char[cMaxStringLen];
	}}

	int cProps = 0;

	// Read in all class definitions
	for(i=0; i < m_nClassDefs; i++)
	{
		pInClass = pClasses[i];
		pOutClass = &m_ClassDefs[i];
		
		memcpy(pOutClass, pInClass, sizeof(ClassDef));

		pOutClass->m_ClassName = _CopyStringPointer(pInClass->m_ClassName);

		// {BP 2/11/98}
		// Only allocate if there are some props to deal with...
		if( pInClass->m_nProps )
		{
			pOutClass->m_Props = (PropDef*)malloc(sizeof(PropDef) * pInClass->m_nProps);
			memcpy(pOutClass->m_Props, pInClass->m_Props, sizeof(PropDef) * pInClass->m_nProps);

			cProps += pInClass->m_nProps;

			for(j=0; j < pInClass->m_nProps; j++)
			{
				PropDef* pPropDef = &pOutClass->m_Props[j];
				pPropDef->m_PropName = _CopyStringPointer(pInClass->m_Props[j].m_PropName);
				pPropDef->m_DefaultValueString = _CopyStringPointer(pInClass->m_Props[j].m_DefaultValueString);
				
				// {BL 11/06/99}
				// See if this property supports EditStringLists

				ClassDef* pDef = pOutClass;
				while(pDef)
				{
					if(pDef->m_PluginFn && ((pPropDef->m_PropFlags & PF_STATICLIST) || (pPropDef->m_PropFlags & PF_DYNAMICLIST)) )
					{
						IObjectPlugin* pPlugin = pDef->m_PluginFn();
						if( pPlugin )
						{
							DDWORD cStrings = 0;
							if ( LT_OK == pPlugin->PreHook_EditStringList(m_BaseProjectDir, pPropDef->m_PropName,
																		  aszStrings, &cStrings, cMaxStrings, cMaxStringLen) )
							{
								DEditInternal* pDEditInternal = new DEditInternal;
								pPropDef->m_pDEditInternal = pDEditInternal;

								pDEditInternal->m_cStrings = cStrings;

								if( cStrings <= 0 )
 								{
 									pDEditInternal->m_aszStrings = NULL;
 								}
 								else
								{
									pDEditInternal->m_aszStrings = new char*[cStrings];
								
									for ( uint32 iString = 0 ; iString < cStrings ; iString++ )
									{
										pDEditInternal->m_aszStrings[iString] = _CopyStringPointer(aszStrings[iString]);
									}
								}

								delete pPlugin;
								break;
							}

							delete pPlugin;
						}
					}
					
					pDef = pDef->m_ParentClass;
				}
			}
		}
		else
			pOutClass->m_Props = NULL;
	}

	for ( int iString = 0 ; iString < cMaxStrings ; iString++ )
	{
		delete [] aszStrings[iString];
	}

	// Setup the parent info.
	for(i=0; i < m_nClassDefs; i++)
	{
		pInClass = pClasses[i];
		pOutClass = &m_ClassDefs[i];

		if(pInClass->m_ParentClass)
		{
			pOutClass->m_ParentClass = FindClassDef(pInClass->m_ParentClass->m_ClassName);
			ASSERT(pOutClass->m_ParentClass);
		}
		else
		{
			pOutClass->m_ParentClass = NULL;
		}
	}		

	LoadTemplateClasses();
}