tDOM

Check-in [811794c107]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Work in progress on reportcmd/recovering and schemacmd info.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 811794c107c8a6450332525b1df934b2a46b6b781cb1efa0bebb28d04259c6cc
User & Date: rolf 2019-03-02 15:21:47
Context
2019-03-04
12:37
Hardened schema cmds againts deleting the command in one of its call out to Tcl by postponing the clientData cleanup until the outmost Tcl_Eval*() call has finished. check-in: 2774ed6a5a user: rolf tags: schema
2019-03-02
15:21
Work in progress on reportcmd/recovering and schemacmd info. check-in: 811794c107 user: rolf tags: schema
02:28
Removed #define and code for a tcl version (8.0) that isn't support for a long time. check-in: 0efaef90de user: rolf tags: schema
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

381
382
383
384
385
386
387
388

389
390
391

392
393
394



395
396
397
398
399
400
401
...
431
432
433
434
435
436
437

438
439
440
441
442
443
444
...
691
692
693
694
695
696
697

698
699
700
701
702
703
704
...
708
709
710
711
712
713
714


















715
716
717
718
719
720
721
....
1882
1883
1884
1885
1886
1887
1888

1889
1890
1891
1892
1893
1894
1895
....
1941
1942
1943
1944
1945
1946
1947











1948
1949
1950
1951
1952
1953
1954
....
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
        }
        break;
    }
    FREE (pattern);
}

static SchemaData*
initSchemaData ()

{
    SchemaData *sdata;
    int hnew;


    sdata = TMALLOC (SchemaData);
    memset (sdata, 0, sizeof(SchemaData));



    Tcl_InitHashTable (&sdata->element, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->pattern, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->attrNames, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->namespace, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->textDef, TCL_STRING_KEYS);
    sdata->emptyNamespace = Tcl_CreateHashEntry (
        &sdata->namespace, "", &hnew);
................................................................................
    ClientData clientData
    )
{
    SchemaData *sdata = (SchemaData *) clientData;
    unsigned int i;
    SchemaValidationStack *down;


    if (sdata->start) FREE (sdata->start);
    if (sdata->startNamespace) FREE (sdata->startNamespace);
    Tcl_DeleteHashTable (&sdata->namespace);
    Tcl_DeleteHashTable (&sdata->element);
    Tcl_DeleteHashTable (&sdata->pattern);
    Tcl_DeleteHashTable (&sdata->attrNames);
    Tcl_DeleteHashTable (&sdata->textDef);
................................................................................
    char *namespace
    )
{
    SchemaCP *cp, *candidate, *icp;
    int hm, ac, i, mayskip, rc;
    int isName = 0;
    SchemaValidationStack *se;


    if (!sdata->stack) return 0;
    se = sdata->stack;
    getContext (cp, ac, hm);

    switch (cp->type) {
    case SCHEMA_CTYPE_NAME:
................................................................................
        while (ac < cp->nc) {
            candidate = cp->content[ac];
            mayskip = 0;
            switch (candidate->type) {
            case SCHEMA_CTYPE_TEXT:
                if (candidate->nc) {
                    if (!checkText (interp, candidate, "")) {


















                        return 0;
                    }
                }
                break;

            case SCHEMA_CTYPE_ANY:
                updateStack (se, cp, ac);
................................................................................
    Tcl_Obj *const objv[]
    )
{
    int methodIndex;
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaCP *cp;

    Tcl_Obj *resultObj, *elmObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "defelements", "stack", NULL
    };
    enum schemaInstanceInfoMethod {
        m_defelements, m_stack
................................................................................
            != TCL_OK) {
            return TCL_ERROR;
        }
        switch ((enum schemaInstanceInfoStackMethod) methodIndex) {
        case m_top:
            break;
        case m_inside:











            break;
        }
        
    }
    
    return TCL_OK;
}
................................................................................
        }
        ind = 2;
    }

    Tcl_ResetResult (interp);
    switch ((enum schemaMethod) methodIndex) {
    case m_create:
        sdata = initSchemaData ();
        Tcl_CreateObjCommand (interp, Tcl_GetString(objv[ind]),
                              schemaInstanceCmd,
                              (ClientData) sdata,
                              schemaInstanceDelete);
        Tcl_SetObjResult (interp, objv[ind]);
        break;







|
>


|
>



>
>
>







 







>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>







 







|







381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
...
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
...
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
....
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
....
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
....
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
        }
        break;
    }
    FREE (pattern);
}

static SchemaData*
initSchemaData (
    Tcl_Obj *cmdNameObj)
{
    SchemaData *sdata;
    int hnew, len;
    char *name;

    sdata = TMALLOC (SchemaData);
    memset (sdata, 0, sizeof(SchemaData));
    name = Tcl_GetStringFromObj (cmdNameObj, &len);
    sdata->self = Tcl_NewStringObj (name, len);
    Tcl_IncrRefCount (sdata->self);
    Tcl_InitHashTable (&sdata->element, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->pattern, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->attrNames, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->namespace, TCL_STRING_KEYS);
    Tcl_InitHashTable (&sdata->textDef, TCL_STRING_KEYS);
    sdata->emptyNamespace = Tcl_CreateHashEntry (
        &sdata->namespace, "", &hnew);
................................................................................
    ClientData clientData
    )
{
    SchemaData *sdata = (SchemaData *) clientData;
    unsigned int i;
    SchemaValidationStack *down;

    Tcl_DecrRefCount (sdata->self);
    if (sdata->start) FREE (sdata->start);
    if (sdata->startNamespace) FREE (sdata->startNamespace);
    Tcl_DeleteHashTable (&sdata->namespace);
    Tcl_DeleteHashTable (&sdata->element);
    Tcl_DeleteHashTable (&sdata->pattern);
    Tcl_DeleteHashTable (&sdata->attrNames);
    Tcl_DeleteHashTable (&sdata->textDef);
................................................................................
    char *namespace
    )
{
    SchemaCP *cp, *candidate, *icp;
    int hm, ac, i, mayskip, rc;
    int isName = 0;
    SchemaValidationStack *se;
    Tcl_Obj *cmdPtr;

    if (!sdata->stack) return 0;
    se = sdata->stack;
    getContext (cp, ac, hm);

    switch (cp->type) {
    case SCHEMA_CTYPE_NAME:
................................................................................
        while (ac < cp->nc) {
            candidate = cp->content[ac];
            mayskip = 0;
            switch (candidate->type) {
            case SCHEMA_CTYPE_TEXT:
                if (candidate->nc) {
                    if (!checkText (interp, candidate, "")) {
                        if (sdata->reportCmd) {
                            cmdPtr = Tcl_DuplicateObj (sdata->reportCmd);
                            Tcl_ListObjAppendElement (interp, cmdPtr,
                                                      sdata->self);
                            Tcl_ListObjAppendElement (
                                interp, cmdPtr,
                                Tcl_NewStringObj ("MISSING_MANDATORY_TEXT", 22)
                                );
                            rc = Tcl_EvalObjEx (interp, cmdPtr,
                                                TCL_EVAL_GLOBAL
                                                | TCL_EVAL_DIRECT);
                            Tcl_DecrRefCount (cmdPtr);
                            if (rc != TCL_OK) {
                                return 0;
                            }
                            break;
                        }
                        
                        return 0;
                    }
                }
                break;

            case SCHEMA_CTYPE_ANY:
                updateStack (se, cp, ac);
................................................................................
    Tcl_Obj *const objv[]
    )
{
    int methodIndex;
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaCP *cp;
    SchemaValidationStack *se;
    Tcl_Obj *resultObj, *elmObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "defelements", "stack", NULL
    };
    enum schemaInstanceInfoMethod {
        m_defelements, m_stack
................................................................................
            != TCL_OK) {
            return TCL_ERROR;
        }
        switch ((enum schemaInstanceInfoStackMethod) methodIndex) {
        case m_top:
            break;
        case m_inside:
            if (!sdata->stack) {
                Tcl_ResetResult (interp);
                return TCL_OK;
            }
            se = sdata->stack;
            while (se->pattern->type != SCHEMA_CTYPE_NAME) {
                se = se->down;
            }
            serializeElementName (elmObj, se->pattern);
            Tcl_SetObjResult (interp, elmObj);
            return TCL_OK;
            break;
        }
        
    }
    
    return TCL_OK;
}
................................................................................
        }
        ind = 2;
    }

    Tcl_ResetResult (interp);
    switch ((enum schemaMethod) methodIndex) {
    case m_create:
        sdata = initSchemaData (objv[ind]);
        Tcl_CreateObjCommand (interp, Tcl_GetString(objv[ind]),
                              schemaInstanceCmd,
                              (ClientData) sdata,
                              schemaInstanceDelete);
        Tcl_SetObjResult (interp, objv[ind]);
        break;

Changes to generic/schema.h.

101
102
103
104
105
106
107

108
109
110
111
112
113
114
    VALIDATION_STARTED,
    VALIDATION_ERROR,
    VALIDATION_FINISHED
} ValidationState;

typedef struct 
{

    char *start;
    char *startNamespace;
    Tcl_HashTable element;
    Tcl_HashTable namespace;
    Tcl_HashEntry *emptyNamespace;
    Tcl_HashTable pattern;
    Tcl_HashTable attrNames;






>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    VALIDATION_STARTED,
    VALIDATION_ERROR,
    VALIDATION_FINISHED
} ValidationState;

typedef struct 
{
    Tcl_Obj *self;
    char *start;
    char *startNamespace;
    Tcl_HashTable element;
    Tcl_HashTable namespace;
    Tcl_HashEntry *emptyNamespace;
    Tcl_HashTable pattern;
    Tcl_HashTable attrNames;