gtfunc.cpp
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 456 行 · 第 1/2 页
CPP
456 行
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include <string.h>
#include <string.hpp>
#include <drgetref.h>
#include <wpopmenu.hpp>
#include <wmenuitm.hpp>
#include "assure.h"
#include "browse.h"
#include "dbmgr.h"
#include "gtfunc.h"
#include "gtfnopt.h"
#include "keysym.h"
#include "mem.h"
#include "module.h"
#include "brwhelp.h"
const int PTRPOOLSIZE = 128;
const int NODEPOOLSIZE = 64;
#pragma warning 549 5 // sizeof contains compiler genned info.
MemoryPool TreeFuncPtr::_pool( sizeof( TreeFuncPtr ), "TreeFuncPtr",
PTRPOOLSIZE );
MemoryPool TreeFuncNode::_pool( sizeof( TreeFuncNode ), "TreeFuncNode",
NODEPOOLSIZE );
#pragma warning 549 3
/*---------------------------- TreeFuncPtr --------------------------*/
TreeFuncPtr::TreeFuncPtr( TreeFuncWindow * prt, TreeNode * from,
TreeNode * to, dr_ref_info ref )
: TreePtr( from, to )
, _reference( ref )
, _parent( prt )
, _numRefs( 1 )
//--------------------------------------------------------------
{
}
void * TreeFuncPtr::operator new( size_t )
//-----------------------------------------
{
return( _pool.alloc() );
}
void TreeFuncPtr::operator delete( void * mem )
//---------------------------------------------
{
_pool.free( mem );
}
TreePtr * TreeFuncPtr::makeClone( void )
//--------------------------------------
{
TreeFuncPtr * ptr = new TreeFuncPtr;
*ptr = *this;
return ptr;
}
PaintInfo * TreeFuncPtr::getPaintInfo( void )
//-------------------------------------------
{
OptionManager * mgr = WBRWinBase::optManager();
return new PaintInfo( mgr->getFunctionOpts().numCalls( _numRefs ) );
}
/*---------------------------- TreeFuncNode --------------------------*/
TreeFuncNode::TreeFuncNode( TreeWindow * prt, dr_sym_type stp,
dr_handle hdl, Module * mod, char * nm,
TreeCycleList * flatNode, TreeRefList * flatRef )
:TreeCycleNode(prt, flatNode, flatRef )
,_symType(stp)
,_handle(hdl)
,_module(mod)
,_name(nm)
,_decName(NULL)
//------------------------------------------------------------
{
dr_handle container;
char * name;
String accum;
container = DRGetContaining( hdl );
if( container ) {
accum = strrev( _name );
strrev( _name );
while( container ) {
Symbol contSym( hdl, NULL, mod, DRGetName( container ) );
name = WBRStrDup( contSym.name() );
accum += "::";
accum += strrev( name );
WBRFree( name );
container = DRGetContaining( container );
}
_decName = WBRStrDup( (const char *) accum );
strrev( _decName );
}
}
TreeFuncNode::~TreeFuncNode()
{
WBRFree( _name );
WBRFree( _decName );
}
void * TreeFuncNode::operator new( size_t )
//-----------------------------------------
{
return( _pool.alloc() );
}
void TreeFuncNode::operator delete( void * mem )
//---------------------------------------------
{
_pool.free( mem );
}
PaintInfo * TreeFuncNode::getPaintInfo( void )
//--------------------------------------------
{
OptionManager * mgr = WBRWinBase::optManager();
return new PaintInfo( mgr->getFunctionOpts().repeated( hasReference() ) );
}
int CompFuncNode( const TreeFuncNode ** lhs, const TreeFuncNode ** rhs )
//----------------------------------------------------------------------
{
return TreeNode::compareNodes( (const TreeNode*)(const TreeCycleNode*) *lhs,
(const TreeNode*)(const TreeCycleNode*) *rhs );
}
int CompFuncPtr( const TreeFuncPtr ** lhs, const TreeFuncPtr ** rhs )
//-------------------------------------------------------------------
{
return TreePtr::comparePtrs( (TreePtr*) *lhs, (TreePtr*) *rhs );
}
void TreeFuncNode::sortPrtKids()
//------------------------------
{
_parents.sort( (TComp) CompFuncPtr );
_children.sort( (TComp) CompFuncNode );
}
Symbol * TreeFuncNode::makeSymbol( void )
//---------------------------------------
{
char * name = WBRStrDup( _name );
return Symbol::defineSymbol( _symType, _handle, 0L, _module, name );
}
char * TreeFuncNode::name()
//-------------------------
{
return (_decName) ? _decName : _name;
}
void TreeFuncNode::loadModule( TreeFuncWindow * prt, Module * mod,
TreeNodeList& roots, KeySymbol * key )
//-------------------------------------------------------------------
{
FuncSearchData data;
data.mod = mod;
data.roots = &roots;
data.parentWin = prt;
data.key = key;
#if DEBUG
data.funcsFound = 0;
#endif
DRReferencedSymbols( DR_SYM_FUNCTION, &data, TreeFuncHook );
for( int i = roots.count(); i > 0; i -= 1 ) {
((TreeCycleNode *)roots[ i - 1 ])->breakCycles();
((TreeCycleNode *)roots[ i - 1 ])->assignLevels();
}
}
bool TreeFuncNode::TreeFuncHook( dr_handle owner, dr_ref_info * ref,
char* ownerName, void * info )
//------------------------------------------------------------------
// this function really needs to be split up
{
int parentIndex;
int parentRoot;
TreeFuncNode * parent = NULL;
int childIndex;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?