home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
pbllibrary.tcl
< prev
next >
Wrap
Text File
|
1997-07-25
|
14KB
|
514 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)pbllibrary.tcl /main/titanic/2
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)pbllibrary.tcl /main/titanic/2 25 Jul 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require "platform.tcl"
require "pb_msg.tcl"
# keep this in sync with orca.h & genpbl.hsxx #define statements
# Operation successful
global PBORCA_OK; set PBORCA_OK 0
# Invalid parameter list
global PBORCA_INVALIDPARMS; set PBORCA_INVALIDPARMS 1
# Duplicate operation
global PBORCA_DUPOPERATION; set PBORCA_DUPOPERATION 2
# Object not found
global PBORCA_OBJNOTFOUND; set PBORCA_OBJNOTFOUND 3
# Bad library name
global PBORCA_BADLIBRARY; set PBORCA_BADLIBRARY 4
# Library list not set
global PBORCA_LIBLISTNOTSET; set PBORCA_LIBLISTNOTSET 5
# Library not in lib list
global PBORCA_LIBNOTINLIST; set PBORCA_LIBNOTINLIST 6
# Library I/O error
global PBORCA_LIBIOERROR; set PBORCA_LIBIOERROR 7
# Object exists
global PBORCA_OBJEXISTS; set PBORCA_OBJEXISTS 8
# Invalid name
global PBORCA_INVALIDNAME; set PBORCA_INVALIDNAME 9
# Buffer size is too small
global PBORCA_BUFFERTOOSMALL; set PBORCA_BUFFERTOOSMALL 10
# Compile error
global PBORCA_COMPERROR; set PBORCA_COMPERROR 11
# Link error
global PBORCA_LINKERROR; set PBORCA_LINKERROR 12
# Current appl not set
global PBORCA_CURRAPPLNOTSET; set PBORCA_CURRAPPLNOTSET 13
# Object has no ancestors
global PBORCA_OBJHASNOANCS; set PBORCA_OBJHASNOANCS 14
# Object has no references
global PBORCA_OBJHASNOREFS; set PBORCA_OBJHASNOREFS 15
# Invalid # of PBD's
global PBORCA_PBDCOUNTERROR; set PBORCA_PBDCOUNTERROR 16
# PBD create error
global PBORCA_PBDCREATERROR; set PBORCA_PBDCREATERROR 17
global PBORCA_CHECKOUTERROR; set PBORCA_CHECKOUTERROR 18
global GENPBL_CANNOTOPENFILE; set GENPBL_CANNOTOPENFILE 100
global GENPBL_ENTRYCHECKEDOUT; set GENPBL_ENTRYCHECKEDOUT 101
global GENPBL_NOPBORCATYPE; set GENPBL_NOPBORCATYPE 102
global GENPBL_MULTIPLERUNERROR; set GENPBL_MULTIPLERUNERROR 103
global GENPBL_FILENOTEXIST; set GENPBL_FILENOTEXIST 104
global GENPBL_NOFILETOIMPORT; set GENPBL_NOFILETOIMPORT 105
# End user added include file section
# A shell around genpbl
Class PblLibrary : {GCObject} {
constructor
method destructor
method createLibrary
method existsLibrary
method removeLibrary
method createOldLibrary
method existsOldLibrary
method removeOldLibrary
method restoreLibrary
method export
method exportFiles
method import
method importFiles
method getLibName
method getInclFiles
method getSrcFiles
attribute libraryName
}
constructor PblLibrary {class this} {
set this [GCObject::constructor $class $this]
$this libraryName ""
# Start constructor user section
# End constructor user section
return $this
}
method PblLibrary::destructor {this} {
# Start destructor user section
# End destructor user section
}
proc PblLibrary::createLibraryByName {libName} {
# this function creates the file, so if remove an existing file!!
set errornr 0
global errorCode errorInfo
set libName [$this getLibName]
set libNameExt "$libName.pbl"
set libNameType "$libName.library"
m4_message $MPB_CREATINGLIB $libNameExt
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set genpbl [m4_path_name bin genpbl$EXE_EXT]
set fp [fstorage::open $libNameType w]
fstorage::close $fp
# first create entry in browser. This also results in
# afile. Now only create (by force: -f) the file by genpbl
# (else genpbl says file already exists)
# .main updateView
set ret [catch {exec $genpbl -Ccreate -L$dir\\$libNameExt -c\"Generated by ObjectTeam\" -f} msg]
if {$ret == 0} {
# file was created so,
} else {
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
if {$errorRet == $PBORCA_OBJEXISTS} {
# library already exists, but not shocking
} else {
incr errornr 1
m4_error $EPB_RETURNED $genpbl $errorRet
m4_message $MPB_MSG $msg
}
}
}
method PblLibrary::createLibrary {this} {
# this function creates the file, so if remove an existing file!!
set errornr 0
global errorCode errorInfo
set libName [$this getLibName]
set libNameExt "$libName.pbl"
set libNameType "$libName.library"
m4_message $MPB_CREATINGLIB $libNameExt
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set genpbl [m4_path_name bin genpbl$EXE_EXT]
set fp [fstorage::open $libNameType w]
fstorage::close $fp
# first create entry in browser. This also results in
# afile. Now only create (by force: -f) the file by genpbl
# (else genpbl says file already exists)
# .main updateView
set ret [catch {exec $genpbl -Ccreate -L$dir\\$libNameExt -c\"Generated by ObjectTeam\" -f} msg]
if {$ret == 0} {
# file was created so,
} else {
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
if {$errorRet == $PBORCA_OBJEXISTS} {
# library already exists, but not shocking
} else {
incr errornr 1
m4_error $EPB_RETURNED $genpbl $errorRet
m4_message $MPB_MSG $msg
}
}
}
method PblLibrary::existsLibrary {this} {
set errornr 0
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set libName [$this getLibName]
set libNameType "$libName.library"
set libNameExt "$libName.pbl"
if {[fstorage::exists $libNameType]} {
return 1
}
return 0
}
method PblLibrary::removeLibrary {this} {
set errornr 0
set libName [$this getLibName]
set libNameExt "$libName.pbl"
set libNameType "$libName.library"
if {[fstorage::exists $libNameType]} {
fstorage::remove $libNameType
}
}
method PblLibrary::createOldLibrary {this} {
global errorCode errorInfo
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set libName [$this getLibName]
set libNameExt "$libName.pbl"
set libNameType "$libName.library"
set libNameOldExt "$libName.old.pbl"
set libNameOldType "$libName.old.library"
m4_message $MPB_OLDLIBCREATED $libNameOldType
set fp [fstorage::open $libNameOldType w]
fstorage::close $fp
# first create entry in browser. This also results in
# afile. Now only create (by force: -f) the file by copy
set script "cmd /C copy $dir\\$libNameExt $dir\\$libNameOldExt"
#copy just the file
set ret [catch {exec cmd /C copy $dir\\$libNameExt \
$dir\\$libNameOldExt} msg]
if {$ret == 0} {
#ok
} else {
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
set cmd "cmd /C copy $dir\\$libNameExt $dir\\$libNameOldExt"
m4_error $EPB_RETURNED $cmd $errorRet
m4_message $MPB_MSG $msg
incr errornr $ret
}
}
method PblLibrary::existsOldLibrary {this} {
set errornr 0
set libName [$this getLibName]
set libNameExt "$libName.old.pbl"
set libNameType "$libName.old.library"
if {[fstorage::exists $libNameType]} {
return 1
}
return 0
}
method PblLibrary::removeOldLibrary {this} {
set errornr 0
set libName [$this getLibName]
set libNameExt "$libName.old.pbl"
set libNameType "$libName.old.library"
m4_message $MPB_OLDLIBDELETE
if {[fstorage::exists $libNameType]} {
fstorage::remove $libNameType
}
}
method PblLibrary::restoreLibrary {this} {
set errornr 0
if [$this existsOldLibrary] {
global errorCode errorInfo
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set libName [$this getLibName]
set libNameExt "$libName.pbl"
set libNameType "$libName.library"
set libNameOldExt "$libName.old.pbl"
set libNameOldType "$libName.old.library"
#copy just the file
set ret [catch {exec cmd /C copy $dir\\$libNameOldExt \
$dir\\$libNameExt} msg]
if {$ret == 0} {
#ok
m4_message $MPB_ORIGRESTORED
# now remove in browser.
if {[fstorage::exists $libNameOldType]} {
fstorage::remove $libNameOldType
}
} else {
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
set cmd "cmd /C copy $dir\\$libNameOldExt $dir\\$libNameExt"
#print error msg
m4_error $EPB_RETURNED $cmd $errorRet
m4_message $MPB_MSG $msg
set errornr $errorRet
}
}
}
method PblLibrary::export {this classList} {
set errornr 0
global errorCode errorInfo
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set libName [$this getLibName]
set libNameExt "$libName.pbl"
set genpbl [m4_path_name bin genpbl$EXE_EXT]
$classList foreach class {
if ![$class isGlobalType] {
continue
}
set kind [$class getPBClassKind]
if {$kind == ${PBClassKind::NotSupported}} {
continue
}
set entryName [$class getName]
set entryType [PBLibraryEntry::getFileTypeByKind $kind]
if {$entryType == ""} {
continue
}
set entryExt [PBLibraryEntry::getSrcFileTypeByFileType $entryType]
set fileName "$entryName\.$entryExt"
set ret [catch {exec $genpbl -Cexport -L$libNameExt \
-s$dir $fileName} msg]
if {$ret == 0} {
#ok
} elseif {$ret == 1} {
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
if {$errorRet == $PBORCA_OBJNOTFOUND} {
# if genpbl return PBORCA_OBJNOTFOUND then the entry
# was not present, so
# no error...
} else {
m4_error $EPB_RETURNED $genpbl $errorRet
m4_message $MPB_MSG $msg
incr errornr $ret
}
} else {
#return, break, continue, ??
incr errornr $ret
}
}
# because also an error is generate when the source files
# are not present, zero is returned.
return $errornr
}
method PblLibrary::exportFiles {this srcFile {inclFile ""} {dir ""}} {
if {$srcFile == ""} {
return 1
}
set libName [$this getLibName]
set libName "$libName.pbl"
set optCmd "-Cexport"
set optLib "-L$libName"
set optIncl [expr {($inclFile != "") ? "-i${inclFile}" : ""}]
set optSrc [expr {($srcFile != "") ? "-F${srcFile}" : ""}]
set optDir [expr {($dir != "") ? "-s${dir}" : ""}]
set genpbl [m4_path_name bin genpbl$EXE_EXT]
set ret [catch {exec $genpbl $optCmd $optLib $optIncl $optSrc $optDir} msg]
if {$ret == 0} {
#ok
} elseif {$ret == 1} {
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
if {$errorRet == $PBORCA_OBJNOTFOUND} {
# if genpbl return PBORCA_OBJNOTFOUND then the entry
# was not present, so
# no error...
} else {
m4_error $EPB_RETURNED $genpbl $errorRet
m4_message $MPB_MSG $msg
return 1
}
} else {
#return, break, continue, ??
return 1
}
return 0
}
method PblLibrary::import {this classList} {
set errornr 0
global errorCode errorInfo
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
set srcFile [$this getSrcFiles $classList]
set inclFile [$this getInclFiles]
set ret [$this importFiles $srcFile $inclFile $dir]
if {$ret == 0} {
return 0
}
return 1
}
method PblLibrary::importFiles {this srcFile {inclFile ""} {dir ""}} {
if {$srcFile == ""} {
return 1
}
set libName [$this getLibName]
set libName "$libName.pbl"
set optCmd "-Cimportlist"
set optLib "-L$libName"
set optIncl [expr {($inclFile != "") ? "-i${inclFile}" : ""}]
set optSrc [expr {($srcFile != "") ? "-F${srcFile}" : ""}]
set optDir [expr {($dir != "") ? "-s${dir}" : ""}]
set genpbl [m4_path_name bin genpbl$EXE_EXT]
set ret [catch {exec $genpbl $optCmd $optLib $optIncl $optSrc $optDir} msg]
if {$ret == 0} {
#ok
} elseif {$ret == 1} {
#error
set errorRet [expr {([lindex $errorCode 0] == "CHILDSTATUS") ? \
[lindex $errorCode 2] : "unknown" }]
m4_error $EPB_RETURNED $genpbl $errorRet
m4_message $MPB_MSG $msg
return 1
} else {
#return, break, continue, ??
return 1
}
return 0
}
method PblLibrary::getLibName {this} {
if {[$this libraryName] == ""} {
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set libName [[$sysV system] name]
set libName [string tolower $libName]
$this libraryName $libName
}
return [$this libraryName]
}
method PblLibrary::getInclFiles {this} {
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set dir [$sysV path]
# include file for classes in other libraries
set phaseV [$cc currentPhase]
set inclFile [args_file {}]
set fid [open $inclFile w]
set inclPattern [path_name concat [location [$phaseV path] *] \
* pbl]
# thanks our good old windows:
set x [regsub -all {\\} $inclPattern {/} inclPattern]
set incl [glob -nocomplain $inclPattern]
foreach elem $incl {
# thanks our good old windows:
set x [regsub -all {/} $elem {\\} elem]
puts $fid $elem
}
close $fid
if {[llength $incl] > 0} {
return $inclFile
} else {
return ""
}
}
method PblLibrary::getSrcFiles {this classList} {
# source file of classes to be imported
set srcFile [args_file {}]
set fid [open $srcFile w]
$classList foreach class {
if ![$class isGlobalType] {
continue
}
set kind [$class getPBClassKind]
if {$kind == ${PBClassKind::NotSupported}} {
continue
}
set entryName [$class getName]
set entryType [PBLibraryEntry::getFileTypeByKind $kind]
set entryExt [PBLibraryEntry::getSrcFileTypeByFileType $entryType]
set source "$entryName.$entryExt"
puts $fid $source
}
close $fid
return $srcFile
}
# Do not delete this line -- regeneration end marker