gtclass.cpp
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 484 行 · 第 1/2 页
CPP
484 行
/****************************************************************************
*
* 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 <wmenu.hpp>
#include <wmenuitm.hpp>
#include "assure.h"
#include "dbmgr.h"
#include "gtclass.h"
#include "gtclsopt.h"
#include "keysym.h"
#include "module.h"
#include "optmgr.h"
#include "symbol.h"
#include "util.h"
#include "brwhelp.h"
const int PTRPOOLSIZE = 128;
const int NODEPOOLSIZE = 64;
#pragma warning 549 5 // sizeof contains compiler genned info.
MemoryPool TreeClassPtr::_pool( sizeof( TreeClassPtr ), "TreeClassPtr",
PTRPOOLSIZE );
MemoryPool TreeClassNode::_pool( sizeof( TreeClassNode ), "TreeClassNode",
NODEPOOLSIZE );
#pragma warning 549 3
TreeClassPtr::TreeClassPtr( TreeClassWindow * prt, TreeClassNode * from,
TreeClassNode * to, dr_access acc,
dr_virtuality virt )
: DerivationPtr( to, acc, virt )
, TreePtr( from, to )
, _parent( prt )
//----------------------------------------------------------------------
{
}
void * TreeClassPtr::operator new( size_t )
//-----------------------------------------
{
return( _pool.alloc() );
}
void TreeClassPtr::operator delete( void * mem )
//---------------------------------------------
{
_pool.free( mem );
}
void TreeClassPtr::adjustTo( ClassLattice * cls )
//-----------------------------------------------
{
setTo( (TreeNode *)(TreeClassNode *) cls );
DerivationPtr::adjustTo( cls );
}
TreePtr * TreeClassPtr::makeClone()
//----------------------------------
{
TreeClassPtr * ptr = new TreeClassPtr;
*ptr = *this;
return ptr;
}
PaintInfo * TreeClassPtr::getPaintInfo( void )
//--------------------------------------------
{
OptionManager * mgr = WBRWinBase::optManager();
return new PaintInfo( mgr->getClassOpts().value( _access, _virtuality ) );
}
TreeClassNode::TreeClassNode( TreeWindow * prt, Symbol * sym )
: TreeNode( prt )
, ClassLattice( sym, TRUE )
//------------------------------------------------------------
{
};
TreeClassNode::TreeClassNode( TreeWindow * prt, dr_handle hdl, Module * mod,
char * nm, ClassList * l, dr_access acc,
dr_virtuality v, int lvl )
: ClassLattice( hdl, mod, nm, l, acc, v, TRUE, lvl )
, TreeNode( prt )
//--------------------------------------------------------------------------
{
}
void * TreeClassNode::operator new( size_t )
//------------------------------------------
{
return( _pool.alloc() );
}
void TreeClassNode::operator delete( void * mem )
//-----------------------------------------------
{
_pool.free( mem );
}
int TreeClassNode::getLevel( void ) const
//---------------------------------------
{
return ClassLattice::_level;
}
PaintInfo * TreeClassNode::getPaintInfo( void )
//---------------------------------------------
{
Color clr = ColorBlack;
WLineStyle stl = LS_PEN_SOLID;
unsigned thk = 1;
return new PaintInfo( clr, thk, stl );
}
virtual bool TreeClassNode::isRelated( TreeNode * node )
//------------------------------------------------------
{
bool ret = (findClass( *_flatClasses,
(ClassLattice *)(TreeClassNode *) node ) >= 0);
return ret;
}
ClassLattice * TreeClassNode::newLattice( dr_handle hdl, Module *mod,
char *nm, ClassList *l,
dr_access acc, dr_virtuality v,
int lvl )
//-------------------------------------------------------------------------
{
return (ClassLattice *) new TreeClassNode( _parent, hdl, mod, nm, l, acc,
v, lvl );
}
virtual DerivationPtr * TreeClassNode::newPtr( ClassLattice * cls,
dr_access acc, dr_virtuality virt )
//-----------------------------------------------------------------
{
return new TreeClassPtr( (TreeClassWindow *)_parent, this,
(TreeClassNode *) cls, acc, virt );
}
bool TreeClassNode::doParents( WVList& world, TreeClassList & roots,
TreeClassList& joinTo )
//-------------------------------------------------------------------
{
bool joinable = FALSE;
loadBases();
for( int i = _bases.count(); i > 0; i -= 1 ) {
TreeClassNode * baseNode = (TreeClassNode*)_bases[ i - 1 ]->_class;
bool thisNodeJoinable = FALSE;
int j;
// remove a base from the world -- should be done for all bases
for( j = world.count(); j > 0; j -= 1 ) {
if( ((Symbol *)world[ j - 1 ])->getHandle() ==
baseNode->getHandle() ) {
delete world.removeAt( j - 1 );
break;
}
}
// look to see if we are related to another root
for( j = roots.count(); j > 0; j -= 1 ) {
TreeClassNode * rootNode = roots[ j - 1 ];
if( rootNode != this &&
rootNode->isRelated( (TreeClassNode *) baseNode ) &&
!rootNode->isRelated( this ) ) {
joinable = TRUE;
thisNodeJoinable = TRUE;
joinTo.add( rootNode );
break;
}
}
if( !baseNode->_basesLoaded && !thisNodeJoinable ) {
joinable = joinable | baseNode->doParents( world, roots, joinTo );
}
}
return joinable;
}
TreePtr* TreeClassNode::getPtr( TreeList_T list, int index )
//----------------------------------------------------------
{
switch( list ) {
case ParentList:
return (TreePtr*)(TreeClassPtr*)_bases[ index ];
case ChildList:
case TreeNode::FlatList:
default:
REQUIRE( 0, "TreeClassNode::getPtr - bad list." );
return NULL;
}
}
TreeNode* TreeClassNode::getNode( TreeList_T list, int index )
//------------------------------------------------------------
{
switch( list ) {
case ParentList:
return (TreeNode*)(TreeClassNode*)((TreeClassPtr *)_bases[ index ])->getTo();
case ChildList:
return (TreeNode*)(TreeClassNode*)((TreeClassPtr *)_deriveds[ index ])->getTo();
case TreeNode::FlatList:
return (TreeNode*)(TreeClassNode*)(*_flatClasses)[ index ];
default:
REQUIRE( 0, "TreeClassNode::getPtr - bad list." );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?