tDOM

Check-in [ba4f23dbc4]
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:Save work.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | virtualConstraints
Files: files | file ages | folders
SHA3-256: ba4f23dbc448a2a7c03933372a6de6cfc0e99e815fb4cb34c9d8e2c969176bf9
User & Date: rolf 2019-03-07 01:48:56
Context
2019-03-07
13:42
(This and the previous commit on this branch:) Changed the calling convention of the virtual contraints: Append the schema command name to the args given and evaluate that. Whatever data the virtual contraint need has to be requested inside the called script (most probably by the new [<schemacmd> info ...] method, which has to be enhanced over time to provide the information that may needed in practice by this. Added code to ensure a Tcl error in evaluated virtual event does pop up in the result of the schema command call. Closed-Leaf check-in: 71d80fea6e user: rolf tags: virtualConstraints
01:48
Save work. check-in: ba4f23dbc4 user: rolf tags: virtualConstraints
00:05
Merged from schema. check-in: f189f4695e user: rolf tags: virtualConstraints
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

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
747
748
749
750
...
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
....
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
....
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
....
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
....
3174
3175
3176
3177
3178
3179
3180


3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
    }
    return 1;
}

static int
evalVirtual (
    Tcl_Interp *interp,

    SchemaCP *cp,
    char *name,
    char *namespace
    )
{
    Tcl_Obj *nsObj, *nameObj;
    int rc;

    nsObj = Tcl_NewStringObj(namespace, -1);
    Tcl_IncrRefCount (nsObj);
    nameObj = Tcl_NewStringObj(name, -1);
    Tcl_IncrRefCount (nameObj);
    cp->content[cp->nc-2] = (SchemaCP *) nsObj;
    cp->content[cp->nc-1] = (SchemaCP *) nameObj;
    rc = Tcl_EvalObjv (interp, cp->nc, (Tcl_Obj **) cp->content,
                       TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL);
    Tcl_DecrRefCount (nameObj);
    Tcl_DecrRefCount (nsObj);
    if (rc != TCL_OK) {
        return 0;
    }
    return 1;
}

static int
................................................................................
                            return 1;
                        }
                        popStack (sdata);
                        if (rc == -1) mayskip = 1;
                        break;

                    case SCHEMA_CTYPE_VIRTUAL:
                        if (evalVirtual (interp, icp, namespace, name)) break;
                        else return 0;
                        
                    }
                    if (!mayskip && mayMiss (candidate->quants[i]))
                        mayskip = 1;
                }
                break;

            case SCHEMA_CTYPE_VIRTUAL:
                if (evalVirtual (interp, candidate, namespace, name)) {
                    mayskip = 1;
                    break;
                }
                else return 0;

            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
................................................................................
                        break;
                        
                    case SCHEMA_CTYPE_VIRTUAL:
                        tse = se;
                        while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                            tse = tse->down;
                        }
                        if (evalVirtual (interp, ic, tse->pattern->namespace,
                                         tse->pattern->name)) break;
                        else return 0;
                    }
                    if (mayMiss) break;
                }
                if (mayMiss) break;
                return 0;

            case SCHEMA_CTYPE_VIRTUAL:
                tse = se;
                while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                    tse = tse->down;
                }
                if (evalVirtual (interp, cp->content[ac],
                                 tse->pattern->namespace,
                                 tse->pattern->name)) break;
                else return 0;
                
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                pushToStack (sdata, cp->content[ac]);
                rc = checkElementEnd (interp, sdata);
                popStack (sdata);
................................................................................
                            break;

                        case SCHEMA_CTYPE_VIRTUAL:
                            tse = se;
                            while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                                tse = tse->down;
                            }
                            if (!evalVirtual (interp, ic,
                                              tse->pattern->namespace,
                                              tse->pattern->name)) return 0;
                            break;
                            
                        case SCHEMA_CTYPE_CHOICE:
                            Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE");

                        }
                    }
................................................................................
                    break;

                case SCHEMA_CTYPE_VIRTUAL:
                    tse = se;
                    while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                        tse = tse->down;
                    }
                    if (!evalVirtual (interp, ic, tse->pattern->namespace,
                                      tse->pattern->name)) return 0;
                    break;
                    
                case SCHEMA_CTYPE_NAME:
                case SCHEMA_CTYPE_ANY:
                    if (mustMatch (cp->quants[ac], hm)) {
                        SetResult ("Unexpected text content");
                        return 0;
................................................................................
                   "allowed in sequential context (defelement, "
                   "element or defpattern)");
        return TCL_ERROR;
    }

    pattern = initSchemaCP (SCHEMA_CTYPE_VIRTUAL, NULL, NULL);
    REMEMBER_PATTERN (pattern)


        pattern->content = MALLOC (sizeof (Tcl_Obj*) * (objc +1));
    for (i = 1; i < objc; i++) {
        pattern->content[i-1] = (SchemaCP *) objv[i];
        Tcl_IncrRefCount (objv[i]);
    }
    pattern->nc = objc + 1;
    addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0);
    return TCL_OK;
}

static int
integerImpl (
    Tcl_Interp *interp,






>
|
<
<


<


<
<
<
<
<
|

|
<
<







 







|









|







 







|
<












|
<
<







 







|
<
<







 







|
<







 







>
>
|




|







719
720
721
722
723
724
725
726
727


728
729

730
731





732
733
734


735
736
737
738
739
740
741
...
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
....
1367
1368
1369
1370
1371
1372
1373
1374

1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387


1388
1389
1390
1391
1392
1393
1394
....
1543
1544
1545
1546
1547
1548
1549
1550


1551
1552
1553
1554
1555
1556
1557
....
1576
1577
1578
1579
1580
1581
1582
1583

1584
1585
1586
1587
1588
1589
1590
....
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
    }
    return 1;
}

static int
evalVirtual (
    Tcl_Interp *interp,
    SchemaData *sdata,
    SchemaCP *cp


    )
{

    int rc;






    cp->content[cp->nc-1] = (SchemaCP *) sdata->self;
    rc = Tcl_EvalObjv (interp, cp->nc, (Tcl_Obj **) cp->content,
                       TCL_EVAL_GLOBAL);


    if (rc != TCL_OK) {
        return 0;
    }
    return 1;
}

static int
................................................................................
                            return 1;
                        }
                        popStack (sdata);
                        if (rc == -1) mayskip = 1;
                        break;

                    case SCHEMA_CTYPE_VIRTUAL:
                        if (evalVirtual (interp, sdata, icp)) break;
                        else return 0;
                        
                    }
                    if (!mayskip && mayMiss (candidate->quants[i]))
                        mayskip = 1;
                }
                break;

            case SCHEMA_CTYPE_VIRTUAL:
                if (evalVirtual (interp, sdata, candidate)) {
                    mayskip = 1;
                    break;
                }
                else return 0;

            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
................................................................................
                        break;
                        
                    case SCHEMA_CTYPE_VIRTUAL:
                        tse = se;
                        while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                            tse = tse->down;
                        }
                        if (evalVirtual (interp, sdata, ic)) break;

                        else return 0;
                    }
                    if (mayMiss) break;
                }
                if (mayMiss) break;
                return 0;

            case SCHEMA_CTYPE_VIRTUAL:
                tse = se;
                while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                    tse = tse->down;
                }
                if (evalVirtual (interp, sdata, cp->content[ac])) break;


                else return 0;
                
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                pushToStack (sdata, cp->content[ac]);
                rc = checkElementEnd (interp, sdata);
                popStack (sdata);
................................................................................
                            break;

                        case SCHEMA_CTYPE_VIRTUAL:
                            tse = se;
                            while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                                tse = tse->down;
                            }
                            if (!evalVirtual (interp, sdata, ic)) return 0;


                            break;
                            
                        case SCHEMA_CTYPE_CHOICE:
                            Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE");

                        }
                    }
................................................................................
                    break;

                case SCHEMA_CTYPE_VIRTUAL:
                    tse = se;
                    while (tse->pattern->type != SCHEMA_CTYPE_NAME) {
                        tse = tse->down;
                    }
                    if (!evalVirtual (interp, sdata, ic)) return 0;

                    break;
                    
                case SCHEMA_CTYPE_NAME:
                case SCHEMA_CTYPE_ANY:
                    if (mustMatch (cp->quants[ac], hm)) {
                        SetResult ("Unexpected text content");
                        return 0;
................................................................................
                   "allowed in sequential context (defelement, "
                   "element or defpattern)");
        return TCL_ERROR;
    }

    pattern = initSchemaCP (SCHEMA_CTYPE_VIRTUAL, NULL, NULL);
    REMEMBER_PATTERN (pattern)
    /* We alloc for one arugment more: the always appended schema
     * cmd, */
    pattern->content = MALLOC (sizeof (Tcl_Obj*) * (objc));
    for (i = 1; i < objc; i++) {
        pattern->content[i-1] = (SchemaCP *) objv[i];
        Tcl_IncrRefCount (objv[i]);
    }
    pattern->nc = objc;
    addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0);
    return TCL_OK;
}

static int
integerImpl (
    Tcl_Interp *interp,