tDOM

Check-in [2d5a4f85c8]
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:Further work on calling schema commands in schema definition / text constraint scripts.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 2d5a4f85c8c73c9365926085f682c67b19d144f65ad369e6d302d324d1e4ea04
User & Date: rolf 2019-03-06 22:47:34
Context
2019-03-07
13:44
Merged feature virtual constraints into the main schema dev branch. check-in: c24d55afe8 user: rolf tags: schema
00:05
Merged from schema. check-in: f189f4695e user: rolf tags: virtualConstraints
2019-03-06
22:47
Further work on calling schema commands in schema definition / text constraint scripts. check-in: 2d5a4f85c8 user: rolf tags: schema
13:34
More hardening and clarification of using a schema cmd inside one of the script arguments evaluated by itself. check-in: 4cefb1db19 user: rolf tags: schema
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
....
2067
2068
2069
2070
2071
2072
2073
2074



2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087

2088
2089
2090
2091
2092
2093
2094
....
2206
2207
2208
2209
2210
2211
2212

2213
2214
2215
2216
2217
2218
2219
....
2237
2238
2239
2240
2241
2242
2243

2244
2245
2246
2247
2248
2249
2250
#define CHECK_TOPLEVEL                                                  \
    if (sdata->defineToplevel) {                                        \
        SetResult("Command not allowed at top level "                   \
                  "in schema define evaluation");                       \
        return TCL_ERROR;                                               \
    }

#define CHECK_TOPLEVEL_CMD                                              \
    if (!sdata->defineToplevel && sdata->currentEvals > 1) {            \
        SetResult ("Command not allowed in nested schema define script"); \
        return TCL_ERROR;                                               \
    }                                                                   \
    if (clientData != NULL) {                                           \
        savedsdata = GETASI;                                            \
        if (savedsdata == sdata) {                                      \
            SetResult ("This recursive call is not allowed"); \
            return TCL_ERROR;                                           \
        }                                                               \
    }
................................................................................
        return TCL_ERROR;
    }

    if (sdata == NULL) {
        /* Inline defined defelement, defpattern, deftext or start */
        sdata = GETASI;
        CHECK_SI;
        CHECK_TOPLEVEL_CMD



        i = 1;
    }

    if (Tcl_GetIndexFromObj (interp, objv[1-i], schemaInstanceMethods,
                             "method", 0, &methodIndex)
        != TCL_OK) {
        return TCL_ERROR;
    }

    Tcl_ResetResult (interp);
    switch ((enum schemaInstanceMethod) methodIndex) {
    case m_defelement:
    case m_defpattern:

        if (objc != 4-i && objc != 5-i) {
            Tcl_WrongNumArgs (interp, 1-i, objv, "<name>"
                 " ?<namespace>? pattern");
            return TCL_ERROR;
        }
        if ((enum schemaInstanceMethod) methodIndex == m_defelement) {
            hashTable = &sdata->element;
................................................................................
            cleanupLastPattern (sdata, savedNumPatternList);
        }
        sdata->defineToplevel = 0;
        SETASI(savedsdata);
        break;

    case m_deftext:

        if (objc !=  4-i) {
            Tcl_WrongNumArgs (interp, 2-i, objv, "<name>"
                              " <constraints script>");
            return TCL_ERROR;
        }
        h = Tcl_CreateHashEntry (&sdata->textDef, Tcl_GetString (objv[2-i]),
                                 &hnew);
................................................................................
            Tcl_SetHashValue (h, pattern);
        } else {
            Tcl_DeleteHashEntry (h);
        }
        break;
        
    case m_start:

        if (objc < 3-i || objc > 4-i) {
            Tcl_WrongNumArgs (interp, 2-i, objv, "<documentElement>"
                              " ?<namespace>?");
            return TCL_ERROR;
        }
        if (sdata->start) {
            FREE (sdata->start);






<
<
<
|
<







 







|
>
>
>













>







 







>







 







>







164
165
166
167
168
169
170



171

172
173
174
175
176
177
178
....
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
....
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
....
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
#define CHECK_TOPLEVEL                                                  \
    if (sdata->defineToplevel) {                                        \
        SetResult("Command not allowed at top level "                   \
                  "in schema define evaluation");                       \
        return TCL_ERROR;                                               \
    }




#define CHECK_RECURSIVE_CALL                                            \

    if (clientData != NULL) {                                           \
        savedsdata = GETASI;                                            \
        if (savedsdata == sdata) {                                      \
            SetResult ("This recursive call is not allowed"); \
            return TCL_ERROR;                                           \
        }                                                               \
    }
................................................................................
        return TCL_ERROR;
    }

    if (sdata == NULL) {
        /* Inline defined defelement, defpattern, deftext or start */
        sdata = GETASI;
        CHECK_SI;
        if (!sdata->defineToplevel && sdata->currentEvals > 1) {
            SetResult ("Method not allowed in nested schema define script");
            return TCL_ERROR;
        }
        i = 1;
    }

    if (Tcl_GetIndexFromObj (interp, objv[1-i], schemaInstanceMethods,
                             "method", 0, &methodIndex)
        != TCL_OK) {
        return TCL_ERROR;
    }

    Tcl_ResetResult (interp);
    switch ((enum schemaInstanceMethod) methodIndex) {
    case m_defelement:
    case m_defpattern:
        CHECK_RECURSIVE_CALL
        if (objc != 4-i && objc != 5-i) {
            Tcl_WrongNumArgs (interp, 1-i, objv, "<name>"
                 " ?<namespace>? pattern");
            return TCL_ERROR;
        }
        if ((enum schemaInstanceMethod) methodIndex == m_defelement) {
            hashTable = &sdata->element;
................................................................................
            cleanupLastPattern (sdata, savedNumPatternList);
        }
        sdata->defineToplevel = 0;
        SETASI(savedsdata);
        break;

    case m_deftext:
        CHECK_RECURSIVE_CALL
        if (objc !=  4-i) {
            Tcl_WrongNumArgs (interp, 2-i, objv, "<name>"
                              " <constraints script>");
            return TCL_ERROR;
        }
        h = Tcl_CreateHashEntry (&sdata->textDef, Tcl_GetString (objv[2-i]),
                                 &hnew);
................................................................................
            Tcl_SetHashValue (h, pattern);
        } else {
            Tcl_DeleteHashEntry (h);
        }
        break;
        
    case m_start:
        CHECK_RECURSIVE_CALL
        if (objc < 3-i || objc > 4-i) {
            Tcl_WrongNumArgs (interp, 2-i, objv, "<documentElement>"
                              " ?<namespace>?");
            return TCL_ERROR;
        }
        if (sdata->start) {
            FREE (sdata->start);