⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 entry.cc

📁 Doc++,可以根据你的C/C++和java的源码文件中的注释行自动生成Html说明文件的工具
💻 CC
📖 第 1 页 / 共 3 页
字号:
bool equalArgs(McString const &a, McString const &b){    McDArray<McString *> a_list, b_list;    McString a_tmp = a, b_tmp = b;    int i;    bool equal = true;    if(countCommas(a) != countCommas(b))	return false;    if(a_tmp.rindex('(') == -1)	a_tmp.insert(0, "(");    if(a_tmp.rindex(')') == -1)	a_tmp += ')';    if(b_tmp.rindex('(') == -1)	b_tmp.insert(0, "(");    if(b_tmp.rindex(')') == -1)	b_tmp += ')';    separateArguments(a_tmp.c_str(), a_list);    separateArguments(b_tmp.c_str(), b_list);    if(a_list.size() != b_list.size())	return false;    for(i = 0; i < a_list.size(); i++)	{	if(*(a_list[i]) != *(b_list[i]) != 0)	    equal = false;	delete a_list[i];	delete b_list[i];	}    return equal;}bool equalSignature(Entry *a, Entry *b){    if(a->fullName != b->fullName)	return false; // names not the same    if(!equalTypes(a->type, b->type))	return false; // types not the same    if(!equalArgs(a->args, b->args))	return false; // args not the same    return true;}Entry *lookupEntryBySignature(Entry *group, Entry *model){    Entry *result, *index = group;    int i;    for(i = 0; i < group->sublist.size(); i++)	if((result = lookupEntryBySignature(group->sublist[i], model)))	    return result;    for(; index; index = index->next)	if(equalSignature(index, model) && index != model)	    return index;    return 0;}bool hasDocumentation(Entry const *entry){    return(entry->memo.length() > 0 ||	entry->doc.length() > 0 ||	entry->param.size() > 0 ||	entry->exception.size() > 0 ||	entry->retrn.size() > 0 ||	entry->see.size() > 0 ||	entry->field.size() > 0 ||	entry->precondition.size() > 0 ||	entry->postcondition.size() > 0 ||	entry->invariant.size() > 0 ||	entry->friends.size() > 0);}void mergeDocumentation(Entry *original, Entry *ccentry){    int i;    if(hasDocumentation(original) && hasDocumentation(ccentry))	fprintf(stderr, _("Warning: `%s %s%s' already have documentation, merging\n"),	    original->type.c_str(),	    original->fullName.c_str(),	    original->args.c_str());    original->memo += ccentry->memo;    original->doc += ccentry->doc;    for(i = 0; i < ccentry->param.size(); i++)	original->param.append(new McString(*(ccentry->param[i])));    for(i = 0; i < ccentry->exception.size(); i++)	original->exception.append(new McString(*(ccentry->exception[i])));    for(i = 0; i < ccentry->retrn.size(); i++)	original->retrn.append(new McString(*(ccentry->retrn[i])));    for(i = 0; i < ccentry->see.size(); i++)	original->see.append(new McString(*(ccentry->see[i])));    for(i = 0; i < ccentry->field.size(); i++)	original->field.append(new McString(*(ccentry->field[i])));    for(i = 0; i < ccentry->precondition.size(); i++)	original->precondition.append(new McString(*(ccentry->precondition[i])));    for(i = 0; i < ccentry->postcondition.size(); i++)	original->postcondition.append(new McString(*(ccentry->postcondition[i])));    for(i = 0; i < ccentry->invariant.size(); i++)	original->invariant.append(new McString(*(ccentry->invariant[i])));    for(i = 0; i < ccentry->friends.size(); i++)	original->friends.append(new McString(*(ccentry->friends[i])));    for(i = 0; i < ccentry->sublist.size(); i++)	original->addSubEntry(ccentry->sublist[i]);}bool mergeEntry(Entry *ccentry){    int scope;    bool noScope = false, parentFound = false;    scope = ccentry->fullName.rindex(':');    scope--;    if(scope < 1 || ccentry->fullName[scope] != ':')	noScope = true;    if(language == LANG_PHP)	{	scope = ccentry->fullName.rindex('.');	if(scope < 1 || ccentry->fullName[scope] != '.')	    noScope = true;	}    McString unqualified_name(ccentry->fullName, scope + 2,	ccentry->fullName.size() - scope - 3);    McString parent_name(ccentry->fullName, 0, scope);    Entry *father = getRefEntry(parent_name, ccentry->parent);    if(father)	parentFound = true;    if(!noScope && !parentFound)	{	if(verb)	    fprintf(stderr, _("Warning: no parent `%s' for `%s %s%s' found\n"),		parent_name.c_str(), ccentry->type.c_str(),		ccentry->fullName.c_str(), ccentry->args.c_str());	return false;	}    else	{	if(!parentFound)	    father = ccentry->parent;	Entry *original = lookupEntryBySignature(father, ccentry);	if(!parentFound && original == 0)	    return false;	if(original == 0 && father == ccentry->parent)	    return false;	Entry *tmp = ccentry->parent;	ccentry->parent->removeSub(ccentry);	ccentry->name = unqualified_name;	if(original == 0)	    {	    father->addSubEntry(ccentry);	    if(father != tmp)		return true;	    }	else	    {    	    mergeDocumentation(original, ccentry);    	    delete ccentry;	    return true;	    }	}    return false;}void mergeEntries(Entry *root){    int i;    for(i = 0; i < root->sublist.size(); i++)	{	if(root->sublist[i]->sub)	    mergeEntries(root->sublist[i]);	if(mergeEntry(root->sublist[i]))	    i--;	}}void getRefNames(McDArray<McString*> strings, const char *names){    McString str = names, *s;    int	i = 0, j;    while((j = str.index(",", i)) >= 0)	{	s = get1RefName(str, i, j);	if(s)	    strings.append(s);	i = j + 1;	}    s = get1RefName(str, i, str.length());    if(s)	strings.append(s);}/* We are looking for an entry named `name'. We start on the level of entry.   `name' can be a simple identifier or it can contain C++ scopes (`::')   This routine is called `A HELL OF A LOT' (tm), and needs keeping quick*/Entry *searchRefEntry(McString &name, Entry *entry){        Entry *rot = entry, *result;    static McHashTable<const char *, char *> *table;    int i, lp;    // General entries have a) no page, b) no references    // This saves a _huge_ amount of time!    if(entry == NULL || entry->general)	return 0;    if(language == LANG_JAVA && name.index('.') >= 0)	{	result = findJavaClass(name, root);	return result;	}    switch(language)	{	case LANG_CXX:	    table = cxxtable;	    break;	case LANG_JAVA:	    table = javatable;	    break;	case LANG_IDL:	    table = idltable;	    break;	case LANG_PHP:	    table = phptable;	    break;	default:	    table = 0;	}    if(table && table->lookup((char *)name))	// It's a keyword silly !	return 0;    // Don't bother caching keywords    if(cache_pos >= MAX_CACHE)	cache_pos = 0;    if(fastNotSmall)				// Actualy use the cache :-)	for(lp = 0; lp < MAX_CACHE; lp++)	    if(cache_entry[lp] && isIt(name, cache_entry[lp]))		return cache_entry[lp];		// Don't re-enter it (probably best)    	    else		if(cache_name[lp])		    if(strcmp(name.c_str(), cache_name[lp]) == 0)			return 0;    if(cache_name[cache_pos])	free(cache_name[cache_pos]);    cache_name[cache_pos] = 0;    while(rot->section == MANUAL_SEC && rot->parent)	rot = rot->parent;    Entry *tmp = rot->findSub(name);    if(tmp)	return(cache_entry[cache_pos++] = tmp);    // Otherwise search in parent classes    for(i = 0; i < rot->pubBaseclasses.size(); i++)	{	entry = searchRefEntry(name, rot->pubBaseclasses[i]);	if(cache_pos >= MAX_CACHE)	    cache_pos = 0;	if(entry)	    return(cache_entry[cache_pos++] = entry);	}    for(i = 0; i < rot->proBaseclasses.size(); i++)	{	entry = searchRefEntry(name, rot->proBaseclasses[i]);	if(cache_pos >= MAX_CACHE)	    cache_pos = 0;	if(entry)	    return(cache_entry[cache_pos++] = entry);	}    // Last chance, search on a higher doc++-level    if(rot->parent)	return searchRefEntry(name, rot->parent);    // Cache a name with no corresponding entry    assert(cache_pos < MAX_CACHE);    // Whilst entries are static, strings get realloced lots!    cache_name[cache_pos] = strdup(name.c_str());    cache_entry[cache_pos++] = 0;    return 0;}Entry *getRefEntry(const char *name, Entry *entry){    Entry *result;    McString tmp(name);    result = getRefEntry(tmp, entry);    return result;}Entry *getRefEntry(McString &name, Entry *entry){    extern McDArray<namespace_entry *> namespace_table;    int i;    McString tmp, fullName;    Entry *result = searchRefEntry(name, entry);    if(!result && language == LANG_CXX)	// try to search inside namespaces, if any	for(i = 0; i < namespace_table.size(); i++)	    {	    tmp = namespace_table[i]->name;	    fullName = namespace_table[i]->name;	    fullName += "::";	    fullName += name;	    if((result = searchRefEntry(fullName, searchRefEntry(tmp, root))))		{#ifdef DEBUG		if(verb)		    printf(_("`%s' found in namespace `%s'!\n"),			name.c_str(), (char *)namespace_table[i]->name);#endif		break;		}	    }    if(!result && language == LANG_CXX)	{        // Search for fully-qualified identifiers in top-level namespaces        namespace_roots.resetIter();        const char*	key;        Entry*		value;        while(!result && namespace_roots.next(key, value))	    {            fullName = value->fullName;            fullName += "::";            fullName += name;            result = searchRefEntry(fullName, value);	    }	}    return result;}Entry *findEntry(Entry *start, const char *fullName, unsigned short section){    Entry *result, *find;    for(find = start; find; find = find->next)	{	if(strcmp(find->fullName.c_str(), fullName) == 0)	    if(section == 0 || (find->section & section))		return find;	if(find->sub)	    if((result = findEntry(find->sub, fullName, section)))		return result;	}    return 0;}int getNumChildren(Entry *tp){    Entry *tmp = tp;    int num = 0;    for(tmp = tp->sub; tmp; tmp = tmp->next)	num++;    return num;}void checkPackages(Entry *tp){    Entry *tmp = tp, *child, *tmp2, *tmp3;    McString newName;    for(tmp = tp; tmp; tmp = tmp->next)	{	if(tmp->sub)	    checkPackages(tmp->sub);	if(MAKE_DOC(tmp))	    if((tmp->section == PACKAGE_SEC) && (getNumChildren(tmp) == 1))		{		child = tmp->sub;		if(child->section == PACKAGE_SEC)		    {		    newName.clear();		    newName += tmp->name;		    newName += "." + (tmp->sub)->name;		    tmp2 = tmp->sub;		    tmp2->parent = tmp->parent;		    for(tmp3 = tmp2->sub; tmp3; tmp3 = tmp3->next)			tmp3->parent = tmp;		    tmp->section = tmp2->section;		    tmp->general = tmp2->general;		    tmp->protection = tmp2->protection;		    tmp->ownPage = tmp2->ownPage;		    tmp->sub = tmp2->sub;		    tmp->type = tmp2->type;		    tmp->name = newName;		    tmp->args = tmp2->args;		    tmp->memo = tmp2->memo;		    tmp->doc = tmp2->doc;		    tmp->program = tmp2->program;		    tmp->author = tmp2->author;		    tmp->version = tmp2->version;		    tmp->see = tmp2->see;		    tmp->param = tmp2->param;		    tmp->exception = tmp2->exception;		    tmp->precondition = tmp2->precondition;
        	    tmp->postcondition = tmp2->postcondition;
        	    tmp->invariant = tmp2->invariant;
		    tmp->retrn = tmp2->retrn;		    tmp->sublist = tmp2->sublist;		    tmp->pubChilds = tmp2->pubChilds;		    tmp->proChilds = tmp2->proChilds;		    tmp->priChilds = tmp2->priChilds;		    tmp->baseclasses = tmp2->baseclasses;		    tmp->pubBaseclasses = tmp2->pubBaseclasses;		    tmp->proBaseclasses = tmp2->proBaseclasses;		    tmp->priBaseclasses = tmp2->priBaseclasses;		    tmp->otherPubBaseclasses = tmp2->otherPubBaseclasses;		    tmp->otherProBaseclasses = tmp2->otherProBaseclasses;		    tmp->otherPriBaseclasses = tmp2->otherPriBaseclasses;		    tmp->implements = tmp2->implements;		    tmp->extends = tmp2->extends;		    tmp->import = tmp2->import;		    tmp->override = tmp2->override;		    }	    	}	}}void reNumber(Entry *tp){    Entry *tmp = tp;    int	i = 1;    for(tmp = tp->sub; tmp; tmp = tmp->next)	{	if(MAKE_DOC(tmp))	    tmp->subnumber = i++;	reNumber(tmp);	}    for(tmp = tp->sub; tmp; tmp = tmp->next)	if(!MAKE_DOC(tmp))	    tmp->subnumber = i++;}bool relevantClassGraphs(Entry *tmp){    for(; tmp; tmp = tmp->next)	{	if((tmp->section & CLASS_SEC) &&	    tmp->proBaseclasses.size() == 0 &&	    tmp->pubBaseclasses.size() == 0)	    return true;	if(relevantClassGraphs(tmp->sub))	    return true;	}    return false;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -