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

Overview
Comment:wip
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | wip
Files: files | file ages | folders
SHA3-256:b6f3e3b2b4c643de4a6baeab3cb696f96ee91d800a351e867a01cc122c8d1f79
User & Date: rolf 2019-08-25 00:22:40
Context
2019-08-25
00:22
wip Leaf check-in: b6f3e3b2b4 user: rolf tags: wip
2019-08-24
13:27
wip check-in: eed7c07609 user: rolf tags: wip
Changes

Changes to generic/schema.c.

445
446
447
448
449
450
451



452
453
454
455
456
457
458
....
2740
2741
2742
2743
2744
2745
2746
2747

2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
....
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
....
2864
2865
2866
2867
2868
2869
2870

2871




2872































2873
2874
2875
2876
2877
2878
2879
....
3020
3021
3022
3023
3024
3025
3026


3027
3028
3029
3030
3031
3032
3033
                FREE (pattern->attrs[i]);
            }
            FREE (pattern->attrs);
        }
        freedomKeyConstraints (pattern->domKeys);
        break;
    }



    FREE (pattern);
}

static SchemaData*
initSchemaData (
    Tcl_Obj *cmdNameObj)
{
................................................................................
    )
{
    int methodIndex;
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaCP *cp;
    SchemaValidationStack *se;
    Tcl_Obj *resultObj, *elmObj;

    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "defelements", "stack", "toplevel",
        "expected", NULL
    };
    enum schemaInstanceInfoMethod {
        m_validationstate, m_vstate, m_defelements, m_stack, m_toplevel,
        m_expected
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        break;
        
    case m_defelements:
        if (objc != 2) {
            Tcl_WrongNumArgs (interp, 1, objv, "defelements");
            return TCL_ERROR;
        }
        resultObj = Tcl_GetObjResult (interp);
        for (h = Tcl_FirstHashEntry (&sdata->element, &search);
             h != NULL;
             h = Tcl_NextHashEntry (&search)) {
            cp = (SchemaCP *) Tcl_GetHashValue (h);
            if (!cp) continue;
            if (cp->flags & FORWARD_PATTERN_DEF
                || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
            elmObj = serializeElementName (interp, cp);
            if (Tcl_ListObjAppendElement (interp, resultObj, elmObj) != TCL_OK)
                return TCL_ERROR;
        }
        break;

    case m_stack:
        if (Tcl_GetIndexFromObj (interp, objv[2],
                                 schemaInstanceInfoStackMethods,
................................................................................
                    Tcl_AppendElement (interp, sdata->startNamespace);
                }
            } else {
                /* do the same as defelements: factor that out */
            }
        } else {
        }

    }




    































    return TCL_OK;
}

int
schemaInstanceCmd (
    ClientData clientData,
    Tcl_Interp *interp,
................................................................................
            if (forwardDef) {
                if (pattern->flags & FORWARD_PATTERN_DEF) {
                    sdata->forwardPatternDefs--;
                    pattern->flags &= ~FORWARD_PATTERN_DEF;
                }
                pattern->flags &= ~PLACEHOLDER_PATTERN_DEF;
            }


        } else {
            cleanupLastPattern (sdata, savedNumPatternList);
        }
        sdata->defineToplevel = savedDefineToplevel;
        sdata->currentNamespace = savedNamespacePtr;
        if (!savedDefineToplevel) {
            SETASI(savedsdata);







>
>
>







 







|
>



|



|







 







|








|







 







>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
....
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
....
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
....
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
....
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
                FREE (pattern->attrs[i]);
            }
            FREE (pattern->attrs);
        }
        freedomKeyConstraints (pattern->domKeys);
        break;
    }
    if (pattern->defScript) {
        Tcl_DecrRefCount (pattern->defScript);
    }
    FREE (pattern);
}

static SchemaData*
initSchemaData (
    Tcl_Obj *cmdNameObj)
{
................................................................................
    )
{
    int methodIndex;
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaCP *cp;
    SchemaValidationStack *se;
    Tcl_Obj *rObj, *elmObj;
    void *ns;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "defelements", "stack", "toplevel",
        "expected", "definition", NULL
    };
    enum schemaInstanceInfoMethod {
        m_validationstate, m_vstate, m_defelements, m_stack, m_toplevel,
        m_expected, m_definition
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        break;
        
    case m_defelements:
        if (objc != 2) {
            Tcl_WrongNumArgs (interp, 1, objv, "defelements");
            return TCL_ERROR;
        }
        rObj = Tcl_GetObjResult (interp);
        for (h = Tcl_FirstHashEntry (&sdata->element, &search);
             h != NULL;
             h = Tcl_NextHashEntry (&search)) {
            cp = (SchemaCP *) Tcl_GetHashValue (h);
            if (!cp) continue;
            if (cp->flags & FORWARD_PATTERN_DEF
                || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
            elmObj = serializeElementName (interp, cp);
            if (Tcl_ListObjAppendElement (interp, rObj, elmObj) != TCL_OK)
                return TCL_ERROR;
        }
        break;

    case m_stack:
        if (Tcl_GetIndexFromObj (interp, objv[2],
                                 schemaInstanceInfoStackMethods,
................................................................................
                    Tcl_AppendElement (interp, sdata->startNamespace);
                }
            } else {
                /* do the same as defelements: factor that out */
            }
        } else {
        }
        break;
        
    case m_definition:
        if (objc < 3 && objc > 4) {
            Tcl_WrongNumArgs (interp, 1, objv, "name ?namespace?");
            return TCL_ERROR;
        }
        h = Tcl_FindHashEntry (&sdata->element, Tcl_GetString (objv[2]));
        if (!h) {
            SetResult ("Unknown element");
            return TCL_ERROR;
        }
        cp = Tcl_GetHashValue (h);
        ns = NULL;
        if (objc == 4) {
            ns = getNamespacePtr (sdata, Tcl_GetString (objv[3]));
        }
        while (cp && cp->namespace != ns) {
            cp = cp->next;
        }
        if (!cp) {
            SetResult ("Unknown element");
            return TCL_ERROR;
        }
        if (cp->flags & LOCAL_DEFINED_ELEMENT) {
            Tcl_AppendElement (interp, "element");
        } else {
            Tcl_AppendElement (interp, "defelement");
        }
        Tcl_AppendElement (interp, cp->name);
        if (cp->namespace) {
            Tcl_AppendElement (interp, cp->namespace);
        }
        if (cp->defScript) {
            Tcl_AppendElement (interp, Tcl_GetString (cp->defScript));
        }
        break;
    }
    return TCL_OK;
}

int
schemaInstanceCmd (
    ClientData clientData,
    Tcl_Interp *interp,
................................................................................
            if (forwardDef) {
                if (pattern->flags & FORWARD_PATTERN_DEF) {
                    sdata->forwardPatternDefs--;
                    pattern->flags &= ~FORWARD_PATTERN_DEF;
                }
                pattern->flags &= ~PLACEHOLDER_PATTERN_DEF;
            }
            pattern->defScript = objv[patternIndex];
            Tcl_IncrRefCount (pattern->defScript);
        } else {
            cleanupLastPattern (sdata, savedNumPatternList);
        }
        sdata->defineToplevel = savedDefineToplevel;
        sdata->currentNamespace = savedNamespacePtr;
        if (!savedDefineToplevel) {
            SETASI(savedsdata);

Changes to generic/schema.h.

104
105
106
107
108
109
110

111
112
113
114
115
116
117
    SchemaQuant      *quants;
    unsigned int      nc;
    SchemaAttr      **attrs;
    unsigned int      numAttr;
    unsigned int      numReqAttr;
    domKeyConstraint *domKeys;
    SchemaKeySpace   *keySpace;

} SchemaCP;

typedef struct SchemaValidationStack
{
    SchemaCP *pattern;
    struct SchemaValidationStack *next;
    struct SchemaValidationStack *down;







>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    SchemaQuant      *quants;
    unsigned int      nc;
    SchemaAttr      **attrs;
    unsigned int      numAttr;
    unsigned int      numReqAttr;
    domKeyConstraint *domKeys;
    SchemaKeySpace   *keySpace;
    Tcl_Obj          *defScript;
} SchemaCP;

typedef struct SchemaValidationStack
{
    SchemaCP *pattern;
    struct SchemaValidationStack *next;
    struct SchemaValidationStack *down;

Changes to tests/schema.test.

4737
4738
4739
4740
4741
4742
4743






















4744
4745
4746
4747
4748
4749
4750
            element a2
        }
    }
    set result [lsort [s info defelements]]
    s delete
    set result
} {a b}























proc schema-18 {args} {
    lappend ::result {*}$args
}
test schema-18.1 {reportcmd} {
    tdom::schema s
    s define {







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







4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
            element a2
        }
    }
    set result [lsort [s info defelements]]
    s delete
    set result
} {a b}

test schema-17.4 {info} {
    tdom::schema s
    s define {
        defelement b {
            element b1 1 text
            element a
            element b2
        }
        defelement a {
            element a1
            element a2
        }
    }
    set result [s info definition b]
    s delete
    set result
} {defelement b {
            element b1 1 text
            element a
            element b2
        }}

proc schema-18 {args} {
    lappend ::result {*}$args
}
test schema-18.1 {reportcmd} {
    tdom::schema s
    s define {