home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # Copyright (c) 1995 by Westmount Technology B.V., Delft, The Netherlands.
- #
- # This software is furnished under a license and may be used only in
- # accordance with the terms of such license and with the inclusion of
- # the above copyright notice. This software or any other copies thereof
- # may not be provided or otherwise made available to any other person.
- # No title to and ownership of the software is hereby transferred.
- #
- # The information in this software is subject to change without notice
- # and should not be construed as a commitment by Westmount Technology B.V.
- #
- #---------------------------------------------------------------------------
- #
- # File : @(#)ixval.tcl 1.4
- # Original date : 26-01-1995
- # Description :
- #
- #---------------------------------------------------------------------------
- #
- # @(#)ixval.tcl 1.4\t18 Apr 1996 Copyright 1995 Westmount Technology B.V.
- #
- #---------------------------------------------------------------------------
-
-
- # Map NewEra types to the appropriate ixValue class
- # Note: the types in fgl2ixval are the types as used in etc-file "db_types"
- #
- global fgl2ixval
- set fgl2ixval(BYTE) ixByte
- set fgl2ixval(CHAR) ixString
- set fgl2ixval(DATE) ixDate
- set "fgl2ixval(DATETIME YEAR TO DAY)" ixDateTime
- set "fgl2ixval(DATETIME HOUR TO MINUTE)" ixDateTime
- set "fgl2ixval(DATETIME YEAR TO FRACTION)" ixDateTime
- set fgl2ixval(DEC) ixDecimal
- set fgl2ixval(DECIMAL) ixDecimal
- set "fgl2ixval(DOUBLE PRECISION)" ixFloat
- set fgl2ixval(FLOAT) ixFloat
- set fgl2ixval(INT) ixInteger
- set fgl2ixval(INTEGER) ixInteger
- set "fgl2ixval(INTERVAL YEAR TO MONTH)" ixIntervalYM
- set "fgl2ixval(INTERVAL HOUR TO MINUTE)" ixIntervalDF
- set fgl2ixval(MONEY) ixMoney
- set fgl2ixval(NUMERIC) ixDecimal
- set fgl2ixval(REAL) ixSmallFloat
- set fgl2ixval(SERIAL) ixInteger
- set fgl2ixval(SMALLFLOAT) ixSmallFloat
- set fgl2ixval(SMALLINT) ixSmallInt
- set fgl2ixval(BOOLEAN) ixSmallInt
- set fgl2ixval(TEXT) ixText
- set fgl2ixval(VARCHAR) ixString
-
- proc map_fgl2ixval {type} {
- global fgl2ixval
-
- regsub { *\(.*} $type "" type
- if [info exists fgl2ixval($type)] {
- return $fgl2ixval($type)
- }
- return ixValue
- }
-
- # Map NewEra types to the appropriate ixTypeInfo constant
- #
- global fgl2sqltype
- set fgl2sqltype(BYTE) 11
- set fgl2sqltype(CHAR) 0
- set fgl2sqltype(DATE) 7
- set "fgl2sqltype(DATETIME YEAR TO DAY)" 10
- set "fgl2sqltype(DATETIME HOUR TO MINUTE)" 10
- set "fgl2sqltype(DATETIME YEAR TO FRACTION)" 10
- set fgl2sqltype(DEC) 5
- set fgl2sqltype(DECIMAL) 5
- set "fgl2sqltype(DOUBLE PRECISION)" 3
- set fgl2sqltype(FLOAT) 3
- set fgl2sqltype(INT) 2
- set fgl2sqltype(INTEGER) 2
- set "fgl2sqltype(INTERVAL YEAR TO MONTH)" 14
- set "fgl2sqltype(INTERVAL HOUR TO MINUTE)" 14
- set fgl2sqltype(MONEY) 8
- set fgl2sqltype(NUMERIC) 5
- set fgl2sqltype(REAL) 4
- set fgl2sqltype(SERIAL) 6
- set fgl2sqltype(SMALLFLOAT) 4
- set fgl2sqltype(SMALLINT) 1
- set fgl2sqltype(BOOLEAN) 1
- set fgl2sqltype(TEXT) 12
- set fgl2sqltype(VARCHAR) 13
-
- proc map_fgl2sqltype {type} {
- global fgl2sqltype
-
- regsub { *\(.*} $type "" type
- if [info exists fgl2sqltype($type)] {
- return $fgl2sqltype($type)
- }
- return -1
- }
-
- # Get the maxdatachars value for the types
- #
- global fgl2maxdatachars
- set fgl2maxdatachars(BYTE) 32
- set fgl2maxdatachars(DATE) 10
- set "fgl2maxdatachars(DATETIME YEAR TO DAY)" 10
- set "fgl2maxdatachars(DATETIME HOUR TO MINUTE)" 5
- set "fgl2maxdatachars(DOUBLE PRECISION)" 22
- set fgl2maxdatachars(FLOAT) 22
- set fgl2maxdatachars(INT) 11
- set fgl2maxdatachars(INTEGER) 11
- set "fgl2maxdatachars(INTERVAL YEAR TO MONTH)" 8
- set "fgl2maxdatachars(INTERVAL HOUR TO MINUTE)" 6
- set fgl2maxdatachars(REAL) 13
- set fgl2maxdatachars(SERIAL) 11
- set fgl2maxdatachars(SMALLFLOAT) 13
- set fgl2maxdatachars(SMALLINT) 6
- set fgl2maxdatachars(BOOLEAN) 6
- set fgl2maxdatachars(TEXT) 128
-
- proc map_fgl2maxdatachars {type} {
- global fgl2maxdatachars
-
- regsub { *\(.*} $type "" mod_type
- if [info exists fgl2maxdatachars($mod_type)] {
- return $fgl2maxdatachars($mod_type)
- }
-
- if {[regexp {(VAR)?CHAR(\([0-9]+\))} $type dummy1 dummy2 size]} {
- if {$size == ""} {
- return 1
- } else {
- return [string trim $size " ()"]
- }
- }
-
- if {[regexp {DATETIME YEAR TO FRACTION(\([0-9]\))?} $type dummy size]} {
- set size [string trim $size " ()"]
- switch $size {
- 1 {return 21}
- 2 {return 22}
- 4 {return 24}
- 5 {return 25}
- default {return 23}
- }
- }
-
- if {[regexp {MONEY(\([0-9]+\))?} $type dummy precision]} {
- if {$precision != ""} {
- set precision [string trim $precision " ()"]
- } else {
- set precision 16
- }
- return [expr $precision + 2]
- }
-
- if {[regexp {(DEC|DECIMAL|NUMERIC)(\([0-9]+\))?} $type dummy1\
- dummy2 precision]} {
- if {$precision != ""} {
- set precision [string trim $precision " ()"]
- } else {
- set precision 16
- }
- return [expr $precision + 2]
- }
-
- return 0
- }
-
- # Get the enclength value for the types
- #
- global fgl2enclength
- set fgl2enclength(DATE) 4
- set "fgl2enclength(DOUBLE PRECISION)" 8
- set fgl2enclength(FLOAT) 8
- set fgl2enclength(INT) 4
- set fgl2enclength(INTEGER) 4
- set fgl2enclength(REAL) 4
- set fgl2enclength(SERIAL) 4
- set fgl2enclength(SMALLFLOAT) 4
- set fgl2enclength(SMALLINT) 2
- set fgl2enclength(BOOLEAN) 2
-
- proc map_fgl2enclength {type} {
- global fgl2enclength
-
- regsub { *\(.*} $type "" mod_type
- if [info exists fgl2enclength($mod_type)] {
- return $fgl2enclength($mod_type)
- }
-
- if {[regexp {(VAR)?CHAR(\([0-9]+\))?} $type dummy1 dummy2 size]} {
- if {$size == ""} {
- return 1
- } else {
- return [string trim $size " ()"]
- }
- }
-
- if {[regexp {DATETIME YEAR TO FRACTION(\([0-9]\))?} $type dummy size]} {
- set size [string trim $size " ()"]
- switch $size {
- 1 {set sq 11}
- 2 {set sq 12}
- 4 {set sq 14}
- 5 {set sq 15}
- default {set sq 13; set size 3}
- }
- return [expr ((14 + $size) *256) + $sq]
- }
-
- switch $type {
- "DATETIME YEAR TO DAY" {return 2052}
- "DATETIME HOUR TO MINUTE" {return 1128}
- "INTERVAL YEAR TO MONTH" {return 1538}
- "INTERVAL HOUR TO MINUTE" {return 1128}
- }
-
- if {[regexp {MONEY(\([0-9]+\))?} $type dummy precision]} {
- if {$precision != ""} {
- set precision [string trim $precision " ()"]
- } else {
- set precision 16
- }
- return [expr ($precision * 256) + 2]
- }
-
- if {[regexp {(DEC|DECIMAL|NUMERIC)(\([0-9]+\))?} $type dummy1\
- dummy2 precision]} {
- if {$precision != ""} {
- set precision [string trim $precision " ()"]
- } else {
- set precision 16
- }
- return [expr $precision * 256]
- }
-
- # BYTE ?
- # TEXT ?
-
- return 0
- }
-
- # Get corresponding include file name for derived ixValue class
- #
- global ixval2inc
- set ixval2inc(ixByte) ixbyte
- set ixval2inc(ixText) ixtext
- set ixval2inc(ixDate) ixdate
- set ixval2inc(ixDateTime) ixdate
- set ixval2inc(ixInterValDF) ixdate
- set ixval2inc(ixInterValYM) ixdate
- set ixval2inc(ixDecimal) ixnum
- set ixval2inc(ixFloat) ixnum
- set ixval2inc(ixInteger) ixnum
- set ixval2inc(ixMoney) ixnum
- set ixval2inc(ixSmallFloat) ixnum
- set ixval2inc(ixSmallInt) ixnum
- set ixval2inc(ixString) ixstring
-
- proc ixval2hdr {type} {
- global ixval2inc
- if [info exists ixval2inc($type)] {
- return $ixval2inc($type)
- }
- return ixvalue
- }
-
- # Get constructor call for derived ixValue class
- #
- global newixval
- set newixval(ixByte) ixByte(locInTempFile)
- set newixval(ixText) ixText(locInTempFile)
-
- proc newixvalue {type {val ""}} {
- global newixval
- if [info exists newixval($type)] {
- eval return $newixval($type)
- } else {
- eval return ${type}(\$val)
- }
- }
-
-
- # Get simple data type value of derived ixValue class
- #
- global gixvalvalue
- set gixvalvalue(ixString) "\${ixvalvar}.getValueStr()"
-
- proc getixvalvalue {type ixvalvar} {
- global gixvalvalue
- if [info exists gixvalvalue($type)] {
- eval return $gixvalvalue($type)
- } else {
- eval return ${ixvalvar}.value
- }
- }
-
-
- # Set simple data type value of derived ixValue class
- #
- global sixvalvalue
- set sixvalvalue(ixString) "CALL \${ixvalvar}.setValueStr(\$newval)"
- set sixvalvalue(ixByte) "-- Not implemented"
- set sixvalvalue(ixText) "-- Not implemented"
-
- proc setixvalvalue {type ixvalvar newval} {
- global sixvalvalue
- if [info exists sixvalvalue($type)] {
- eval return \"$sixvalvalue($type)\"
- } else {
- eval return \"LET ${ixvalvar}.value = $newval\"
- }
- }
-
-
- # Generate a "ixval type declaration" for the type
- #
- proc generate_ixval {type decl} {
- if {[$type get_obj_type] != "base_type"} {
- return [generate $type $decl]
- }
- set name [$type getType3GL]
- set ixvalname [map_fgl2ixval $name]
- set ixvalincname [ixval2hdr $ixvalname]
- if {$decl == "fwd"} {
- add_forward_name $ixvalname
- add_src_inc_name $ixvalincname
- } else {
- add_hdr_inc_name $ixvalincname
- }
- return $ixvalname
- }
-