Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Removed old cruft, simplified (a bit) the central data structure; we have a finit, known in advance set of of quents.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 39d74a1df4048191cb0f13349a47023f85c273cf6ff2aa747bbbef8420e84fad
User & Date: rolf 2019-10-19 01:46:42
Context
2019-10-19
12:01
Removed more no longer used defines. check-in: 0605e10005 user: rolf tags: schema
01:46
Removed old cruft, simplified (a bit) the central data structure; we have a finit, known in advance set of of quents. check-in: 39d74a1df4 user: rolf tags: schema
00:08
Ensure that the script error of a script evaluated by a schema command pops up to global level. check-in: a15e6f3d24 user: rolf tags: schema
Changes

Changes to generic/schema.c.

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
...
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
\---------------------------------------------------------------------------*/
#ifndef CONTENT_ARRAY_SIZE_INIT
#  define CONTENT_ARRAY_SIZE_INIT 20
#endif
#ifndef ANON_PATTERN_ARRAY_SIZE_INIT
#  define ANON_PATTERN_ARRAY_SIZE_INIT 256
#endif
#ifndef QUANTS_ARRAY_SIZE_INIT
#  define QUANTS_ARRAY_SIZE_INIT 8
#endif
#ifndef STACK_SIZE_INIT
#  define STACK_SIZE_INIT 16
#endif
#ifndef STACK_LIST_SIZE_INIT
#  define STACK_LIST_SIZE_INIT 64
#endif
#ifndef URI_BUFFER_LEN_INIT
................................................................................
    Tcl_InitHashTable (&sdata->namespace, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->textDef, TCL_STRING_KEYS);
    sdata->emptyNamespace = Tcl_CreateHashEntry (
        &sdata->namespace, "", &hnew);
    sdata->patternList = (SchemaCP **) MALLOC (
        sizeof (SchemaCP*) * ANON_PATTERN_ARRAY_SIZE_INIT);
    sdata->patternListSize = ANON_PATTERN_ARRAY_SIZE_INIT;
    sdata->quants = (SchemaQuant *) MALLOC (
        sizeof (SchemaQuant) * QUANTS_ARRAY_SIZE_INIT);
    sdata->quantsSize = QUANTS_ARRAY_SIZE_INIT;
    /* evalStub initialization */
    sdata->evalStub = (Tcl_Obj **) MALLOC (sizeof (Tcl_Obj*) * 4);
    sdata->evalStub[0] = Tcl_NewStringObj("::namespace", 11);
    Tcl_IncrRefCount (sdata->evalStub[0]);
    sdata->evalStub[1] = Tcl_NewStringObj("eval", 4);
    Tcl_IncrRefCount (sdata->evalStub[1]);
    sdata->evalStub[2] = Tcl_NewStringObj("::tdom::schema", 14);
................................................................................
    Tcl_DeleteHashTable (&sdata->pattern);
    Tcl_DeleteHashTable (&sdata->attrNames);
    Tcl_DeleteHashTable (&sdata->textDef);
    for (i = 0; i < sdata->numPatternList; i++) {
        freeSchemaCP (sdata->patternList[i]);
    }
    FREE (sdata->patternList);
    if (sdata->numQuants) {
        FREE (sdata->quants);
    }
    FREE (sdata->quants);
    while (sdata->stack) {
        down = sdata->stack->down;
        FREE (sdata->stack);
        sdata->stack = down;
    }
    while (sdata->stackPool) {







<
<
<







 







<
<
<







 







<
<
<







51
52
53
54
55
56
57



58
59
60
61
62
63
64
...
473
474
475
476
477
478
479



480
481
482
483
484
485
486
...
538
539
540
541
542
543
544



545
546
547
548
549
550
551
\---------------------------------------------------------------------------*/
#ifndef CONTENT_ARRAY_SIZE_INIT
#  define CONTENT_ARRAY_SIZE_INIT 20
#endif
#ifndef ANON_PATTERN_ARRAY_SIZE_INIT
#  define ANON_PATTERN_ARRAY_SIZE_INIT 256
#endif



#ifndef STACK_SIZE_INIT
#  define STACK_SIZE_INIT 16
#endif
#ifndef STACK_LIST_SIZE_INIT
#  define STACK_LIST_SIZE_INIT 64
#endif
#ifndef URI_BUFFER_LEN_INIT
................................................................................
    Tcl_InitHashTable (&sdata->namespace, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->textDef, TCL_STRING_KEYS);
    sdata->emptyNamespace = Tcl_CreateHashEntry (
        &sdata->namespace, "", &hnew);
    sdata->patternList = (SchemaCP **) MALLOC (
        sizeof (SchemaCP*) * ANON_PATTERN_ARRAY_SIZE_INIT);
    sdata->patternListSize = ANON_PATTERN_ARRAY_SIZE_INIT;



    /* evalStub initialization */
    sdata->evalStub = (Tcl_Obj **) MALLOC (sizeof (Tcl_Obj*) * 4);
    sdata->evalStub[0] = Tcl_NewStringObj("::namespace", 11);
    Tcl_IncrRefCount (sdata->evalStub[0]);
    sdata->evalStub[1] = Tcl_NewStringObj("eval", 4);
    Tcl_IncrRefCount (sdata->evalStub[1]);
    sdata->evalStub[2] = Tcl_NewStringObj("::tdom::schema", 14);
................................................................................
    Tcl_DeleteHashTable (&sdata->pattern);
    Tcl_DeleteHashTable (&sdata->attrNames);
    Tcl_DeleteHashTable (&sdata->textDef);
    for (i = 0; i < sdata->numPatternList; i++) {
        freeSchemaCP (sdata->patternList[i]);
    }
    FREE (sdata->patternList);



    FREE (sdata->quants);
    while (sdata->stack) {
        down = sdata->stack->down;
        FREE (sdata->stack);
        sdata->stack = down;
    }
    while (sdata->stackPool) {

Changes to generic/schema.h.

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    Tcl_HashTable attrNames;
    Tcl_HashTable textDef;
    SchemaCP **patternList; 
    unsigned int numPatternList;
    unsigned int patternListSize;
    unsigned int forwardPatternDefs;
    SchemaQuant *quants;
    unsigned int numQuants;
    unsigned int quantsSize;
    int       currentEvals;
    int       cleanupAfterEval;
    int       evalError;
    Tcl_Obj  *reportCmd;
    Tcl_Obj **evalStub;
    Tcl_Obj **textStub;
    char *currentNamespace;







<
<







148
149
150
151
152
153
154


155
156
157
158
159
160
161
    Tcl_HashTable attrNames;
    Tcl_HashTable textDef;
    SchemaCP **patternList; 
    unsigned int numPatternList;
    unsigned int patternListSize;
    unsigned int forwardPatternDefs;
    SchemaQuant *quants;


    int       currentEvals;
    int       cleanupAfterEval;
    int       evalError;
    Tcl_Obj  *reportCmd;
    Tcl_Obj **evalStub;
    Tcl_Obj **textStub;
    char *currentNamespace;

Changes to tests/schema.test.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
....
5728
5729
5730
5731
5732
5733
5734





5735
5736












#    schema-14.*: text
#    schema-15.*: Constraint cmd tcl
#    schema-16.*: interleave
#    schema-17.*: info
#    schema-18.*: reportcmd
#    schema-19.*: keyspace
#    schema-20.*: domunique

#
# Copyright (c) 2018-2019 Rolf Ade.

source [file join [file dir [info script]] loadtdom.tcl]

if {[dom featureinfo schema]} {

................................................................................
    } {
        lappend result [postValidation s $xml]
    }
    s delete
    set result
} {1 0}







}



















>







 







>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
....
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
#    schema-14.*: text
#    schema-15.*: Constraint cmd tcl
#    schema-16.*: interleave
#    schema-17.*: info
#    schema-18.*: reportcmd
#    schema-19.*: keyspace
#    schema-20.*: domunique
#    schema-21.*: internal: buffers
#
# Copyright (c) 2018-2019 Rolf Ade.

source [file join [file dir [info script]] loadtdom.tcl]

if {[dom featureinfo schema]} {

................................................................................
    } {
        lappend result [postValidation s $xml]
    }
    s delete
    set result
} {1 0}

test schema-21.1 {CONTENT_ARRAY_SIZE_INIT} {
    tdom::schema s
    s defelement doc {
        for {set i 1} {$i <= 30} {incr i} {
            element e ?
        }
    }
    set result [list]
    foreach xml [list <doc/> \
                     <doc>[string repeat <e/> 9]</doc> \
                     <doc>[string repeat <e/> 27]</doc>  \
                     <doc>[string repeat <e/> 37]</doc>] {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {1 1 1 0}

}