|
|
|
@ -531,17 +531,34 @@ namespace eval tomlish {
|
|
|
|
|
} else { |
|
|
|
|
#we have a table - but is it a tablearray? |
|
|
|
|
set ttype [dictn get $tablenames_info [list $norm_segments type]] |
|
|
|
|
#use a tabletype_unknown type for previous 'created' only tables? |
|
|
|
|
if {$ttype ne "header_tablearray"} { |
|
|
|
|
set msg "tablearray name $tablearrayname already appears to be already created as a table not a tablearray - invalid?" |
|
|
|
|
append msg \n [tomlish::dict::_show_tablenames $tablenames_info] |
|
|
|
|
#raise a specific type of error for tests to check |
|
|
|
|
return -code error -errorcode {TOMLISH STRUCTURE KEYCOLLISION} $msg |
|
|
|
|
#we use a header_unknown type for previous 'created' only tables |
|
|
|
|
|
|
|
|
|
if {$ttype eq "header_unknown"} { |
|
|
|
|
dictn set tablenames_info [list $norm_segments type] header_tablearray |
|
|
|
|
set ttype header_tablearray |
|
|
|
|
#assert - must not be 'defined' |
|
|
|
|
#we have seen it before as a supertable ie 'created' only |
|
|
|
|
#Not 'defined' but could still have subtables - treat it as a dict |
|
|
|
|
set ARRAY_ELEMENTS [dict get $datastructure {*}$norm_segments] |
|
|
|
|
} else { |
|
|
|
|
if {$ttype ne "header_tablearray"} { |
|
|
|
|
#header_table or itable |
|
|
|
|
switch -- $ttype { |
|
|
|
|
itable {set ttypename itable} |
|
|
|
|
header_table {set ttypename table} |
|
|
|
|
default {error "unrecognised type - expected header_table or itable"} |
|
|
|
|
} |
|
|
|
|
set msg "tablearray name $tablearrayname already appears to be already created as '$ttypename' not tablearray - invalid?" |
|
|
|
|
append msg \n [tomlish::dict::_show_tablenames $tablenames_info] |
|
|
|
|
#raise a specific type of error for tests to check |
|
|
|
|
return -code error -errorcode {TOMLISH STRUCTURE KEYCOLLISION} $msg |
|
|
|
|
} |
|
|
|
|
#EXISTING tablearray |
|
|
|
|
#add to array |
|
|
|
|
#error "add_to_array not implemented" |
|
|
|
|
#{type ARRAY value <list>} |
|
|
|
|
set ARRAY_ELEMENTS [dict get $datastructure {*}$norm_segments value] |
|
|
|
|
} |
|
|
|
|
#add to array |
|
|
|
|
#error "add_to_array not implemented" |
|
|
|
|
#{type ARRAY value <list>} |
|
|
|
|
set ARRAY_ELEMENTS [dict get $datastructure {*}$norm_segments value] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -748,7 +765,7 @@ namespace eval tomlish {
|
|
|
|
|
set norm_segments [::tomlish::to_dict::tablename_split $tablename true] ;#true to normalize |
|
|
|
|
|
|
|
|
|
set T_DEFINED [dictn getdef $tablenames_info [list $norm_segments defined] NULL] |
|
|
|
|
if {$T_DEFINED ne "NULL"} { |
|
|
|
|
if {$T_DEFINED ni [list NULL header_tablearray]} { |
|
|
|
|
#our tablename e.g [a.b.c.d] declares a space to 'define' subkeys - but there has already been a definition space for this path |
|
|
|
|
set msg "Table name $tablename has already been directly defined in the toml data. Invalid" |
|
|
|
|
append msg \n [tomlish::dict::_show_tablenames $tablenames_info] |
|
|
|
@ -779,7 +796,8 @@ namespace eval tomlish {
|
|
|
|
|
return -code error -errorcode {TOMLISH STRUCTURE KEYCOLLISION} $msg |
|
|
|
|
} |
|
|
|
|
#here we 'create' it, but it's not being 'defined' ie we're not setting keyvals for it here |
|
|
|
|
dictn set tablenames_info [list $supertable type] header_table |
|
|
|
|
#we also don't know whether it's a table or a tablearray |
|
|
|
|
dictn set tablenames_info [list $supertable type] header_unknown |
|
|
|
|
#ensure empty tables are still represented in the datastructure |
|
|
|
|
dict set datastructure {*}$supertable [list] |
|
|
|
|
} else { |
|
|
|
|