[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    weird code :-(
From:       tech () bishop ! dhs ! org
Date:       2002-09-10 6:07:23
[Download RAW message or body]

Maybe it's just too late (and I'm going to bed after sending this) but I
just can't figure out what in the heck this code is supposed to do.
Normally I'd ask the original author, but they dropped support for it
(TheKompany's KDEStudio*) :-(

As far as I can tell by how it's used, this routine is *supposed* to
get a list of all libraries used by this project (to help in creating
the Makefile.am).

void Workspace::getAllLibrary( QStrList& list )
{
  if ( getType() == SHARED_LIB ||  getType() == STATIC_LIB ) list.append( name );

  QStrList sub;
  wConfig->setGroup( configPath );
  wConfig->readListEntry( "Group", sub );
  for ( uint k = 0; k < sub.count(); k++ )
  {
    Workspace* ws = new Workspace( this, sub.at( sub.count() - 1 - k) );
    ws->getAllLibrary( list );
    delete ws;
  }
}

How it's actually used:
1st layer
mainWorkspace->getAllProjectLibrary( prjLib );
2nd (in a .h)
void getAllProjectLibrary( QStrList& list ){ getAllLibrary( list ); }
3rd is above

Explanation of function calls and objects:

wConfig is a KSimpleConfig object.  "Group" seems to contain just the
name of the "Project" (i.e., Project "Foo" with several shared libs and
executables contained within it). getType() returns what kind of project 
it is you're making, and in the case that I'm testing, is EXECUTABLE.

My immediate question is: why create an object, call the same function,
and then delete the object?  AFAICT, that for loop is the only thing
that *does* anything, and even at that, nothing important! Does anyone
see someplace that an actual assignment might be taking place, that I'm
missing?  Recursion is fine, but there has to be results.

My second is: why have the "middle" class? Why wouldn't they just go
straight from the first layer to the third?

Please note that I know you guys aren't mind-reading gods.  I'm more
interested in why someone would use a middle layer in the general case,
than knowing exactly what was running though their heads in this case.
But the recursion thing, *that* I expect you to know immediately *grin*

Gah, I'm way too tired to be typing.  Have a great night...

D.A.Bishop

*If somebody is seriously overmotivated, and they have a copy of the
kdestudio source, I'm wandering around in
studio/src/workspace/workspace.[cpp|h]

[Attachment #3 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic