OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [libcdl/] [property.cxx] - Blame information for rev 831

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//{{{  Banner                           
2
 
3
//============================================================================
4
//
5
//     property.cxx
6
//
7
//     Implementation of the CdlProperty class and derived classes.
8
//
9
//============================================================================
10
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
11
// -------------------------------------------                              
12
// This file is part of the eCos host tools.                                
13
// Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.            
14
//
15
// This program is free software; you can redistribute it and/or modify     
16
// it under the terms of the GNU General Public License as published by     
17
// the Free Software Foundation; either version 2 or (at your option) any   
18
// later version.                                                           
19
//
20
// This program is distributed in the hope that it will be useful, but      
21
// WITHOUT ANY WARRANTY; without even the implied warranty of               
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
23
// General Public License for more details.                                 
24
//
25
// You should have received a copy of the GNU General Public License        
26
// along with this program; if not, write to the                            
27
// Free Software Foundation, Inc., 51 Franklin Street,                      
28
// Fifth Floor, Boston, MA  02110-1301, USA.                                
29
// -------------------------------------------                              
30
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
31
//============================================================================
32
//#####DESCRIPTIONBEGIN####
33
//
34
// Author(s):   bartv
35
// Contact(s):  bartv
36
// Date:        1999/01/29
37
// Version:     0.02
38
// Description: The CdlProperty class is used to hold the bulk of the
39
//              actual data in a CDL script. The CdlOption and other
40
//              higher-level classes are essentially just named containers
41
//              of properties.
42
//
43
//####DESCRIPTIONEND####
44
//============================================================================
45
 
46
//}}}
47
//{{{  #include's                       
48
 
49
// ----------------------------------------------------------------------------
50
#include "cdlconfig.h"
51
 
52
// Get the infrastructure types, assertions, tracing and similar
53
// facilities.
54
#include <cyg/infra/cyg_ass.h>
55
#include <cyg/infra/cyg_trac.h>
56
 
57
// <cdl.hxx> defines everything implemented in this module.
58
// It implicitly supplies <string>, <vector> and <map> because
59
// the class definitions rely on these headers.
60
#include <cdlcore.hxx>
61
 
62
//}}}
63
 
64
//{{{  Statics                          
65
 
66
// ----------------------------------------------------------------------------
67
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlPropertyBody);
68
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_MinimalBody);
69
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_StringBody);
70
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_TclCodeBody);
71
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_ReferenceBody);
72
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_StringVectorBody);
73
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_ExpressionBody);
74
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_ListExpressionBody);
75
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_GoalExpressionBody);
76
 
77
//}}}
78
//{{{  CdlProperty base class           
79
 
80
// ----------------------------------------------------------------------------
81
 
82
CdlPropertyBody::CdlPropertyBody(CdlNode node, std::string name_arg, int argc, const char* argv_arg[],
83
                                 std::vector<std::pair<std::string,std::string> >& options_arg)
84
{
85
    CYG_REPORT_FUNCNAME("CdlProperty:: constructor");
86
    CYG_REPORT_FUNCARG3XV(this, node, argc);
87
    CYG_PRECONDITIONC(argc > 0);
88
    CYG_PRECONDITION_CLASSC(node);
89
 
90
    name = name_arg;
91
    argv.push_back(CdlParse::get_tcl_cmd_name(argv_arg[0]));
92
    for (int i = 1; i < argc; i++) {
93
        argv.push_back(argv_arg[i]);
94
    }
95
    options = options_arg;
96
    node->properties.push_back(this);
97
    cdlpropertybody_cookie = CdlPropertyBody_Magic;
98
    CYGDBG_MEMLEAK_CONSTRUCTOR();
99
 
100
    CYG_POSTCONDITION_THISC();
101
    CYG_REPORT_RETURN();
102
}
103
 
104
CdlPropertyBody::~CdlPropertyBody()
105
{
106
    CYG_REPORT_FUNCNAME("CdlProperty:: destructor");
107
    CYG_REPORT_FUNCARG1("this %p", this);
108
    CYG_PRECONDITION_THISC();
109
 
110
    cdlpropertybody_cookie      = CdlPropertyBody_Invalid;
111
    name                        = "";
112
    argv.clear();
113
    CYGDBG_MEMLEAK_DESTRUCTOR();
114
 
115
    CYG_REPORT_RETURN();
116
}
117
 
118
std::string
119
CdlPropertyBody::get_property_name(void) const
120
{
121
    CYG_REPORT_FUNCNAME("CdlProperty::get_property_id");
122
    CYG_REPORT_FUNCARG1("this %p", this);
123
    CYG_PRECONDITION_THISC();
124
 
125
    CYG_REPORT_RETURN();
126
    return name;
127
}
128
 
129
int
130
CdlPropertyBody::get_argc(void) const
131
{
132
    CYG_REPORT_FUNCNAMETYPE("CdlProperty::get_argc", "argc %d");
133
    CYG_REPORT_FUNCARG1("this %p", this);
134
    CYG_PRECONDITION_THISC();
135
 
136
    int result = argv.size();
137
    CYG_REPORT_RETVAL(result);
138
    return result;
139
}
140
 
141
const std::vector<std::string>&
142
CdlPropertyBody::get_argv(void) const
143
{
144
    CYG_REPORT_FUNCNAME("CdlProperty::get_argv");
145
    CYG_REPORT_FUNCARG1("this %p", this);
146
    CYG_PRECONDITION_THISC();
147
    CYG_REPORT_RETURN();
148
    return argv;
149
}
150
 
151
const std::vector<std::pair<std::string,std::string> >&
152
CdlPropertyBody::get_options() const
153
{
154
    CYG_REPORT_FUNCNAME("CdlProperty::get_options");
155
    CYG_REPORT_FUNCARG1XV(this);
156
    CYG_PRECONDITION_THISC();
157
    CYG_REPORT_RETURN();
158
    return options;
159
}
160
 
161
bool
162
CdlPropertyBody::has_option(std::string name) const
163
{
164
    CYG_REPORT_FUNCNAMETYPE("CdlProperty::has_option", "result %d");
165
    CYG_REPORT_FUNCARG1XV(this);
166
    CYG_PRECONDITION_THISC();
167
 
168
    bool result = false;
169
    std::vector<std::pair<std::string,std::string> >::const_iterator opt_i;
170
    for (opt_i = options.begin(); opt_i != options.end(); opt_i++) {
171
        if (name == opt_i->first) {
172
            result = true;
173
            break;
174
        }
175
    }
176
 
177
    CYG_REPORT_RETVAL(result);
178
    return result;
179
}
180
 
181
std::string
182
CdlPropertyBody::get_option(std::string name) const
183
{
184
    CYG_REPORT_FUNCNAME("CdlProperty::get_option");
185
    CYG_REPORT_FUNCARG1XV(this);
186
    CYG_PRECONDITION_THISC();
187
 
188
    std::string result = "";
189
    std::vector<std::pair<std::string,std::string> >::const_iterator opt_i;
190
    for (opt_i = options.begin(); opt_i != options.end(); opt_i++) {
191
        if (name == opt_i->first) {
192
            result = opt_i->second;
193
            break;
194
        }
195
    }
196
 
197
    CYG_REPORT_RETURN();
198
    return result;
199
}
200
 
201
// ----------------------------------------------------------------------------
202
// Handling updates. This is a virtual function. The default
203
// implementation does nothing because not all properties contain
204
// references to other CDL entities.
205
 
206
void
207
CdlPropertyBody::update(CdlTransaction transact, CdlNode source, CdlNode dest, CdlUpdate change)
208
{
209
    CYG_REPORT_FUNCNAME("CdlProperty::update");
210
    CYG_REPORT_FUNCARG5XV(this, transact, source, dest, change);
211
    CYG_PRECONDITION_THISC();
212
 
213
    CYG_UNUSED_PARAM(CdlTransaction, transact);
214
    CYG_UNUSED_PARAM(CdlNode, source);
215
    CYG_UNUSED_PARAM(CdlNode, dest);
216
    CYG_UNUSED_PARAM(CdlUpdate, change);
217
 
218
    CYG_REPORT_RETURN();
219
}
220
 
221
// ----------------------------------------------------------------------------
222
bool
223
CdlPropertyBody::check_this(cyg_assert_class_zeal zeal) const
224
{
225
    if (CdlPropertyBody_Magic != cdlpropertybody_cookie) {
226
        return false;
227
    }
228
    CYGDBG_MEMLEAK_CHECKTHIS();
229
    CYG_UNUSED_PARAM(cyg_assert_class_zeal, zeal);
230
    return true;
231
}
232
 
233
//}}}
234
//{{{  CdlProperty_Minimal class        
235
 
236
// ----------------------------------------------------------------------------
237
 
238
CdlProperty_Minimal
239
CdlProperty_MinimalBody::make(CdlNode node_arg, std::string name_arg, int argc_arg, const char* argv_arg[],
240
                              std::vector<std::pair<std::string,std::string> >& options_arg)
241
{
242
    return new CdlProperty_MinimalBody(node_arg, name_arg, argc_arg, argv_arg, options_arg);
243
}
244
 
245
CdlProperty_MinimalBody::CdlProperty_MinimalBody(CdlNode node_arg, std::string name_arg, int argc_arg, const char* argv_arg[],
246
                                                 std::vector<std::pair<std::string,std::string> >& options_arg)
247
    : inherited(node_arg, name_arg, argc_arg, argv_arg, options_arg)
248
{
249
    CYG_REPORT_FUNCNAME("CdlProperty_Minimal:: constructor");
250
    CYG_REPORT_FUNCARG1("this %p", this);
251
 
252
    cdlproperty_minimalbody_cookie = CdlProperty_MinimalBody_Magic;
253
    CYGDBG_MEMLEAK_CONSTRUCTOR();
254
 
255
    CYG_POSTCONDITION_THISC();
256
    CYG_REPORT_RETURN();
257
}
258
 
259
CdlProperty_MinimalBody::~CdlProperty_MinimalBody()
260
{
261
    CYG_REPORT_FUNCNAME("CdlProperty_Minimal:: destructor");
262
    CYG_REPORT_FUNCARG1("this %p", this);
263
    CYG_PRECONDITION_THISC();
264
 
265
    cdlproperty_minimalbody_cookie = CdlProperty_MinimalBody_Invalid;
266
    CYGDBG_MEMLEAK_DESTRUCTOR();
267
 
268
    CYG_REPORT_RETURN();
269
}
270
 
271
bool
272
CdlProperty_MinimalBody::check_this(cyg_assert_class_zeal zeal) const
273
{
274
    if (CdlProperty_MinimalBody_Magic != cdlproperty_minimalbody_cookie) {
275
        return false;
276
    }
277
    CYGDBG_MEMLEAK_CHECKTHIS();
278
    return inherited::check_this(zeal);
279
}
280
 
281
//}}}
282
//{{{  CdlProperty_String class         
283
 
284
// ----------------------------------------------------------------------------
285
 
286
CdlProperty_String
287
CdlProperty_StringBody::make(CdlNode node_arg, std::string name_arg, std::string value_arg, int argc_arg, const char* argv_arg[],
288
                             std::vector<std::pair<std::string,std::string> >& options_arg)
289
{
290
    return new CdlProperty_StringBody(node_arg, name_arg, value_arg, argc_arg, argv_arg, options_arg);
291
}
292
 
293
CdlProperty_StringBody::CdlProperty_StringBody(CdlNode node_arg, std::string name_arg, std::string value_arg,
294
                                               int argc_arg, const char* argv_arg[],
295
                                               std::vector<std::pair<std::string,std::string> >& options_arg)
296
    : inherited(node_arg, name_arg, argc_arg, argv_arg, options_arg)
297
{
298
    CYG_REPORT_FUNCNAME("CdlProperty_String:: constructor");
299
    CYG_REPORT_FUNCARG1("this %p", this);
300
 
301
    data = value_arg;
302
    cdlproperty_stringbody_cookie = CdlProperty_StringBody_Magic;
303
    CYGDBG_MEMLEAK_CONSTRUCTOR();
304
 
305
    CYG_POSTCONDITION_THISC();
306
    CYG_REPORT_RETURN();
307
}
308
 
309
CdlProperty_StringBody::~CdlProperty_StringBody()
310
{
311
    CYG_REPORT_FUNCNAME("CdlProperty_String:: destructor");
312
    CYG_REPORT_FUNCARG1("this %p", this);
313
    CYG_PRECONDITION_THISC();
314
 
315
    cdlproperty_stringbody_cookie = CdlProperty_StringBody_Invalid;
316
    data = "";
317
    CYGDBG_MEMLEAK_DESTRUCTOR();
318
 
319
    CYG_REPORT_RETURN();
320
}
321
 
322
std::string
323
CdlProperty_StringBody::get_string(void) const
324
{
325
    CYG_REPORT_FUNCNAME("CdlProperty_String::get_string");
326
    CYG_REPORT_FUNCARG1("this %p", this);
327
    CYG_PRECONDITION_THISC();
328
 
329
    CYG_REPORT_RETURN();
330
    return data;
331
}
332
 
333
bool
334
CdlProperty_StringBody::check_this(cyg_assert_class_zeal zeal) const
335
{
336
    if (CdlProperty_StringBody_Magic != cdlproperty_stringbody_cookie) {
337
        return false;
338
    }
339
    CYGDBG_MEMLEAK_CHECKTHIS();
340
    return inherited::check_this(zeal);
341
}
342
 
343
//}}}`
344
//{{{  CdlProperty_TclCode class        
345
 
346
// ----------------------------------------------------------------------------
347
 
348
CdlProperty_TclCode
349
CdlProperty_TclCodeBody::make(CdlNode node_arg, std::string name_arg, cdl_tcl_code code_arg,
350
                              int argc_arg, const char* argv_arg[],
351
                              std::vector<std::pair<std::string,std::string> >& options_arg)
352
{
353
    return new CdlProperty_TclCodeBody(node_arg, name_arg, 0, code_arg, argc_arg, argv_arg, options_arg);
354
}
355
 
356
CdlProperty_TclCode
357
CdlProperty_TclCodeBody::make(CdlNode node_arg, std::string name_arg, cdl_int number_arg, cdl_tcl_code code_arg,
358
                              int argc_arg, const char* argv_arg[],
359
                              std::vector<std::pair<std::string,std::string> >& options_arg)
360
{
361
    return new CdlProperty_TclCodeBody(node_arg, name_arg, number_arg, code_arg, argc_arg, argv_arg, options_arg);
362
}
363
 
364
 
365
CdlProperty_TclCodeBody::CdlProperty_TclCodeBody(CdlNode node_arg, std::string name_arg,
366
                                                 cdl_int number_arg, cdl_tcl_code code_arg,
367
                                                 int argc_arg, const char* argv_arg[],
368
                                                 std::vector<std::pair<std::string,std::string> >& options_arg)
369
    : inherited(node_arg, name_arg, argc_arg, argv_arg, options_arg)
370
{
371
    CYG_REPORT_FUNCNAME("CdlProperty_TclCode:: constructor");
372
    CYG_REPORT_FUNCARG2("this %p, number_arg %d", this, number_arg);
373
 
374
    code   = code_arg;
375
    number = number_arg;
376
    cdlproperty_tclcodebody_cookie = CdlProperty_TclCodeBody_Magic;
377
    CYGDBG_MEMLEAK_CONSTRUCTOR();
378
 
379
    CYG_POSTCONDITION_THISC();
380
    CYG_REPORT_RETURN();
381
}
382
 
383
CdlProperty_TclCodeBody::~CdlProperty_TclCodeBody()
384
{
385
    CYG_REPORT_FUNCNAME("CdlProperty_TclCode:: destructor");
386
    CYG_REPORT_FUNCARG1("this %p", this);
387
    CYG_PRECONDITION_THISC();
388
 
389
    cdlproperty_tclcodebody_cookie = CdlProperty_TclCodeBody_Invalid;
390
    code = cdl_tcl_code("");
391
    CYGDBG_MEMLEAK_DESTRUCTOR();
392
 
393
    CYG_REPORT_RETURN();
394
}
395
 
396
const cdl_tcl_code&
397
CdlProperty_TclCodeBody::get_code(void) const
398
{
399
    CYG_REPORT_FUNCNAME("CdlProperty_TclCode::get_code");
400
    CYG_REPORT_FUNCARG1("this %p", this);
401
    CYG_PRECONDITION_THISC();
402
 
403
    CYG_REPORT_RETURN();
404
    return code;
405
}
406
 
407
cdl_int
408
CdlProperty_TclCodeBody::get_number(void) const
409
{
410
    CYG_REPORT_FUNCNAMETYPE("CdlProperty_TclCode::get_number", "result %d");
411
    CYG_REPORT_FUNCARG1("this %p", this);
412
    CYG_PRECONDITION_THISC();
413
 
414
    cdl_int result = number;
415
    CYG_REPORT_RETVAL(result);
416
    return result;
417
}
418
 
419
bool
420
CdlProperty_TclCodeBody::check_this(cyg_assert_class_zeal zeal) const
421
{
422
    if (CdlProperty_TclCodeBody_Magic != cdlproperty_tclcodebody_cookie) {
423
        return false;
424
    }
425
    CYGDBG_MEMLEAK_CHECKTHIS();
426
    return inherited::check_this(zeal);
427
}
428
 
429
//}}}
430
//{{{  CdlProperty_StringVector class   
431
 
432
// ----------------------------------------------------------------------------
433
 
434
CdlProperty_StringVector
435
CdlProperty_StringVectorBody::make(CdlNode node_arg, std::string name_arg, const std::vector<std::string>& data_arg,
436
                                   int argc_arg, const char* argv_arg[],
437
                                   std::vector<std::pair<std::string,std::string> >& options_arg)
438
{
439
    return new CdlProperty_StringVectorBody(node_arg, name_arg, data_arg, argc_arg, argv_arg, options_arg);
440
}
441
 
442
CdlProperty_StringVectorBody::CdlProperty_StringVectorBody(CdlNode node_arg, std::string name_arg,
443
                                                           const std::vector<std::string>& data_arg,
444
                                                           int argc_arg, const char* argv_arg[],
445
                                                           std::vector<std::pair<std::string,std::string> >& options_arg)
446
    : inherited(node_arg, name_arg, argc_arg, argv_arg, options_arg)
447
{
448
    CYG_REPORT_FUNCNAME("CdlProperty_StringVector:: constructor");
449
    CYG_REPORT_FUNCARG1("this %p", this);
450
 
451
    data = data_arg;
452
    cdlproperty_stringvectorbody_cookie = CdlProperty_StringVectorBody_Magic;
453
    CYGDBG_MEMLEAK_CONSTRUCTOR();
454
 
455
    CYG_POSTCONDITION_THISC();
456
    CYG_REPORT_RETURN();
457
}
458
 
459
CdlProperty_StringVectorBody::~CdlProperty_StringVectorBody()
460
{
461
    CYG_REPORT_FUNCNAME("CdlProperty_StringVector:: destructor");
462
    CYG_REPORT_FUNCARG1("this %p", this);
463
    CYG_PRECONDITION_THISC();
464
 
465
    cdlproperty_stringvectorbody_cookie = CdlProperty_StringVectorBody_Invalid;
466
    data.clear();
467
    CYGDBG_MEMLEAK_DESTRUCTOR();
468
 
469
    CYG_REPORT_RETURN();
470
}
471
 
472
std::string
473
CdlProperty_StringVectorBody::get_first_string(void) const
474
{
475
    CYG_REPORT_FUNCNAME("CdlProperty_StringVector::get_first_string");
476
    CYG_REPORT_FUNCARG1("this %p", this);
477
    CYG_PRECONDITION_THISC();
478
 
479
    std::string result;
480
    if (0 == data.size()) {
481
        result = "";
482
    } else {
483
        result = data[0];
484
    }
485
    CYG_REPORT_RETURN();
486
    return result;
487
}
488
 
489
unsigned int
490
CdlProperty_StringVectorBody::get_number_of_strings() const
491
{
492
    CYG_REPORT_FUNCNAMETYPE("CdlProperty_StringVector::get_number_of_strings", "result %d");
493
    CYG_REPORT_FUNCARG1XV(this);
494
    CYG_PRECONDITION_THISC();
495
 
496
    unsigned int result = data.size();
497
    CYG_REPORT_RETVAL(result);
498
    return result;
499
}
500
 
501
std::string
502
CdlProperty_StringVectorBody::get_string(unsigned int index) const
503
{
504
    CYG_REPORT_FUNCNAME("CdlProperty_StringVector::get_string");
505
    CYG_REPORT_FUNCARG2XV(this, index);
506
    CYG_PRECONDITION_THISC();
507
    CYG_PRECONDITIONC(index < data.size());
508
 
509
    std::string result = data[index];
510
    CYG_REPORT_RETURN();
511
    return result;
512
}
513
 
514
const std::vector<std::string>&
515
CdlProperty_StringVectorBody::get_strings(void) const
516
{
517
    CYG_REPORT_FUNCNAME("CdlProperty_StringVector::get_strings");
518
    CYG_REPORT_FUNCARG1("this %p", this);
519
    CYG_PRECONDITION_THISC();
520
 
521
    CYG_REPORT_RETURN();
522
    return data;
523
}
524
 
525
bool
526
CdlProperty_StringVectorBody::check_this(cyg_assert_class_zeal zeal) const
527
{
528
    if (CdlProperty_StringVectorBody_Magic != cdlproperty_stringvectorbody_cookie) {
529
        return false;
530
    }
531
    CYGDBG_MEMLEAK_CHECKTHIS();
532
    return inherited::check_this(zeal);
533
}
534
 
535
//}}}`
536
//{{{  CdlProperty_Reference class      
537
 
538
// ----------------------------------------------------------------------------
539
// This is pretty simple since most of the functionality is provided by the
540
// reference class.
541
 
542
CdlProperty_Reference
543
CdlProperty_ReferenceBody::make(CdlNode node_arg, std::string name_arg, std::string ref_arg, CdlUpdateHandler update_handler,
544
                                int argc_arg, const char* argv_arg[],
545
                                std::vector<std::pair<std::string,std::string> >& options_arg)
546
{
547
    return new CdlProperty_ReferenceBody(node_arg, name_arg, ref_arg, update_handler, argc_arg, argv_arg, options_arg);
548
}
549
 
550
CdlProperty_ReferenceBody::CdlProperty_ReferenceBody(CdlNode node_arg, std::string name_arg, std::string ref_arg,
551
                                                     CdlUpdateHandler update_handler_arg,
552
                                                     int argc_arg, const char* argv_arg[],
553
                                                     std::vector<std::pair<std::string,std::string> >& options_arg)
554
    : CdlPropertyBody(node_arg, name_arg, argc_arg, argv_arg, options_arg),
555
      CdlReference(ref_arg),
556
      update_handler(update_handler_arg)
557
{
558
    CYG_REPORT_FUNCNAME("CdlProperty_Reference:: constructor");
559
    CYG_REPORT_FUNCARG1("this %p", this);
560
 
561
    cdlproperty_referencebody_cookie = CdlProperty_ReferenceBody_Magic;
562
    CYGDBG_MEMLEAK_CONSTRUCTOR();
563
 
564
    CYG_POSTCONDITION_THISC();
565
    CYG_REPORT_RETURN();
566
}
567
 
568
CdlProperty_ReferenceBody::~CdlProperty_ReferenceBody()
569
{
570
    CYG_REPORT_FUNCNAME("CdlProperty_Reference:: destructor");
571
    CYG_REPORT_FUNCARG1("this %p", this);
572
    CYG_PRECONDITION_THISC();
573
 
574
    cdlproperty_referencebody_cookie = CdlProperty_ReferenceBody_Invalid;
575
    CYGDBG_MEMLEAK_DESTRUCTOR();
576
 
577
    CYG_REPORT_RETURN();
578
}
579
 
580
// ----------------------------------------------------------------------------
581
// Reference handling. It is useful at this level to cope with the
582
// four cases of Loaded, Unloaded, Created, and Destroyed. In addition
583
// the property-specific update handler needs to be invoked.
584
 
585
void
586
CdlProperty_ReferenceBody::update(CdlTransaction transact, CdlNode source, CdlNode dest, CdlUpdate change)
587
{
588
    CYG_REPORT_FUNCNAME("CdlProperty_Reference::update");
589
    CYG_REPORT_FUNCARG5XV(this, transact, source, dest, change);
590
    CYG_PRECONDITION_THISC();
591
 
592
    switch(change) {
593
 
594
      case CdlUpdate_Loaded :
595
      {
596
        // The source has just been loaded, try to resolve the reference.
597
        // Note that e.g. the parent property allow for a reference to ""
598
        // The necessary validation will have happened during parsing.
599
        CYG_ASSERTC(0 == dest);
600
        CdlToplevel toplevel = source->get_toplevel();
601
        std::string dest_name = get_destination_name();
602
        if ("" != dest_name) {
603
            dest = toplevel->lookup(dest_name);
604
            if (0 == dest) {
605
                CdlConflict_UnresolvedBody::make(transact, source, this, get_destination_name());
606
            } else {
607
                bind(source, this, dest);
608
            }
609
        }
610
        break;
611
      }
612
 
613
      case CdlUpdate_Unloading:
614
      {
615
        // The source is being unloaded. If the reference is currently bound,
616
        // unbind it. There is no point in creating a new conflict object.
617
        CYG_ASSERTC(0 == dest);
618
        dest = get_destination();
619
        if (0 != dest) {
620
            unbind(source, this);
621
        }
622
        break;
623
      }
624
 
625
      case CdlUpdate_Created:
626
      {
627
        // There is an existing conflict object, but the destination has
628
        // just been created. The old conflict object should be eliminated,
629
        // and the reference can now be bound.
630
        CYG_ASSERT_CLASSC(dest);
631
 
632
        bind(source, this, dest);
633
 
634
        CdlConflict conflict = transact->get_structural_conflict(source, this, &CdlConflict_UnresolvedBody::test);
635
        CYG_ASSERTC(0 != conflict);
636
        transact->clear_conflict(conflict);
637
        break;
638
      }
639
      case CdlUpdate_Destroyed :
640
      {
641
        // The destination is about to be destroyed. Eliminate the existing
642
        // binding and create a new conflict object.
643
        CYG_ASSERT_CLASSC(dest);
644
        unbind(source, this);
645
        CdlConflict_UnresolvedBody::make(transact, source, this, get_destination_name());
646
        break;
647
      }
648
 
649
      // Init, ValueChange and ActiveChange are of no interest.
650
      default:
651
        break;
652
    }
653
 
654
    (*update_handler)(transact, source, this, dest, change);
655
 
656
    CYG_REPORT_RETURN();
657
}
658
 
659
// ----------------------------------------------------------------------------
660
bool
661
CdlProperty_ReferenceBody::check_this(cyg_assert_class_zeal zeal) const
662
{
663
    if (CdlProperty_ReferenceBody_Magic != cdlproperty_referencebody_cookie) {
664
        return false;
665
    }
666
    CYGDBG_MEMLEAK_CHECKTHIS();
667
    return inherited_property::check_this(zeal) && inherited_reference::check_this(zeal);
668
}
669
 
670
//}}}
671
//{{{  CdlProperty_Expression class     
672
 
673
// ----------------------------------------------------------------------------
674
// This is pretty simple since most of the functionality is provided by the
675
// base expression class.
676
 
677
CdlProperty_Expression
678
CdlProperty_ExpressionBody::make(CdlNode node_arg, std::string name_arg, CdlExpression expr_arg,
679
                                 CdlUpdateHandler update_handler_arg,
680
                                 int argc_arg, const char* argv_arg[],
681
                                 std::vector<std::pair<std::string,std::string> >& options_arg)
682
{
683
    return new CdlProperty_ExpressionBody(node_arg, name_arg, expr_arg, update_handler_arg, argc_arg, argv_arg, options_arg);
684
}
685
 
686
CdlProperty_ExpressionBody::CdlProperty_ExpressionBody(CdlNode node_arg, std::string name_arg, CdlExpression expr_arg,
687
                                                       CdlUpdateHandler update_handler_arg,
688
                                                       int argc_arg, const char* argv_arg[],
689
                                                       std::vector<std::pair<std::string,std::string> >& options_arg)
690
    : CdlPropertyBody(node_arg, name_arg, argc_arg, argv_arg, options_arg),
691
      CdlExpressionBody(*expr_arg),
692
      update_handler(update_handler_arg)
693
{
694
    CYG_REPORT_FUNCNAME("CdlProperty_Expression:: constructor");
695
    CYG_REPORT_FUNCARG1("this %p", this);
696
 
697
    cdlproperty_expressionbody_cookie = CdlProperty_ExpressionBody_Magic;
698
    CYGDBG_MEMLEAK_CONSTRUCTOR();
699
 
700
    CYG_POSTCONDITION_THISC();
701
    CYG_REPORT_RETURN();
702
}
703
 
704
CdlProperty_ExpressionBody::~CdlProperty_ExpressionBody()
705
{
706
    CYG_REPORT_FUNCNAME("CdlProperty_Expression:: destructor");
707
    CYG_REPORT_FUNCARG1("this %p", this);
708
    CYG_PRECONDITION_THISC();
709
 
710
    cdlproperty_expressionbody_cookie = CdlProperty_ExpressionBody_Invalid;
711
    CYGDBG_MEMLEAK_DESTRUCTOR();
712
 
713
    CYG_REPORT_RETURN();
714
}
715
 
716
void
717
CdlProperty_ExpressionBody::update(CdlTransaction transact, CdlNode source, CdlNode dest, CdlUpdate change)
718
{
719
    CYG_REPORT_FUNCNAME("CdlProperty_Expression::update");
720
    CYG_REPORT_FUNCARG5XV(this, transact, source, dest, change);
721
    CYG_PRECONDITION_THISC();
722
 
723
    // The CdlExpression update() member will take care of binding
724
    // and unbinding, as needed.
725
    if ((change & (CdlUpdate_Loaded | CdlUpdate_Unloading | CdlUpdate_Created | CdlUpdate_Destroyed)) != 0) {
726
        (void) CdlExpressionBody::update(transact, source, this, dest, change);
727
    }
728
 
729
    // Now invoke the per-property update handler to re-evaluate the
730
    // expression etc., as needed
731
    (*update_handler)(transact, source, this, dest, change);
732
 
733
    CYG_REPORT_RETURN();
734
}
735
 
736
bool
737
CdlProperty_ExpressionBody::check_this(cyg_assert_class_zeal zeal) const
738
{
739
    if (CdlProperty_ExpressionBody_Magic != cdlproperty_expressionbody_cookie) {
740
        return false;
741
    }
742
    CYGDBG_MEMLEAK_CHECKTHIS();
743
    return inherited_property::check_this(zeal) && inherited_expression::check_this(zeal);
744
}
745
 
746
//}}}
747
//{{{  CdlProperty_ListExpression class 
748
 
749
// ----------------------------------------------------------------------------
750
// This is pretty simple since most of the functionality is provided by the
751
// base expression class.
752
 
753
CdlProperty_ListExpression
754
CdlProperty_ListExpressionBody::make(CdlNode node_arg, std::string name_arg, CdlListExpression expr_arg,
755
                                     CdlUpdateHandler update_handler_arg,
756
                                     int argc_arg, const char* argv_arg[],
757
                                     std::vector<std::pair<std::string,std::string> >& options_arg)
758
{
759
    return new CdlProperty_ListExpressionBody(node_arg, name_arg, expr_arg, update_handler_arg,
760
                                              argc_arg, argv_arg, options_arg);
761
}
762
 
763
CdlProperty_ListExpressionBody::CdlProperty_ListExpressionBody(CdlNode node_arg, std::string name_arg,
764
                                                               CdlListExpression expr_arg,
765
                                                               CdlUpdateHandler update_handler_arg,
766
                                                               int argc_arg, const char* argv_arg[],
767
                                                               std::vector<std::pair<std::string,std::string> >& options_arg)
768
    : CdlPropertyBody(node_arg, name_arg, argc_arg, argv_arg, options_arg),
769
      CdlListExpressionBody(*expr_arg),
770
      update_handler(update_handler_arg)
771
{
772
    CYG_REPORT_FUNCNAME("CdlProperty_ListExpression:: constructor");
773
    CYG_REPORT_FUNCARG1("this %p", this);
774
 
775
    cdlproperty_listexpressionbody_cookie = CdlProperty_ListExpressionBody_Magic;
776
    CYGDBG_MEMLEAK_CONSTRUCTOR();
777
 
778
    CYG_POSTCONDITION_THISC();
779
    CYG_REPORT_RETURN();
780
}
781
 
782
CdlProperty_ListExpressionBody::~CdlProperty_ListExpressionBody()
783
{
784
    CYG_REPORT_FUNCNAME("CdlProperty_ListExpression:: destructor");
785
    CYG_REPORT_FUNCARG1("this %p", this);
786
    CYG_PRECONDITION_THISC();
787
 
788
    cdlproperty_listexpressionbody_cookie = CdlProperty_ListExpressionBody_Invalid;
789
    CYGDBG_MEMLEAK_DESTRUCTOR();
790
 
791
    CYG_REPORT_RETURN();
792
}
793
 
794
void
795
CdlProperty_ListExpressionBody::update(CdlTransaction transact, CdlNode source, CdlNode dest, CdlUpdate change)
796
{
797
    CYG_REPORT_FUNCNAME("CdlProperty_ListExpression::update");
798
    CYG_REPORT_FUNCARG4XV(this, source, dest, change);
799
    CYG_PRECONDITION_THISC();
800
 
801
    if ((change & (CdlUpdate_Loaded | CdlUpdate_Unloading | CdlUpdate_Created | CdlUpdate_Destroyed)) != 0) {
802
        bool handled = CdlListExpressionBody::update(transact, source, this, dest, change);
803
        CYG_UNUSED_PARAM(bool, handled);
804
        CYG_ASSERTC(handled);
805
    }
806
 
807
    // Now invoke the per-property update handler to re-evaluate
808
    // the lexpr as appropriate.
809
    (*update_handler)(transact, source, this, dest, change);
810
 
811
    CYG_REPORT_RETURN();
812
}
813
 
814
bool
815
CdlProperty_ListExpressionBody::check_this(cyg_assert_class_zeal zeal) const
816
{
817
    if (CdlProperty_ListExpressionBody_Magic != cdlproperty_listexpressionbody_cookie) {
818
        return false;
819
    }
820
    CYGDBG_MEMLEAK_CHECKTHIS();
821
    return inherited_property::check_this(zeal) && inherited_expression::check_this(zeal);
822
}
823
 
824
//}}}
825
//{{{  CdlProperty_GoalExpression class 
826
 
827
// ----------------------------------------------------------------------------
828
// This is pretty simple since most of the functionality is provided by the
829
// base expression class.
830
 
831
CdlProperty_GoalExpression
832
CdlProperty_GoalExpressionBody::make(CdlNode node_arg, std::string name_arg, CdlGoalExpression expr_arg,
833
                                     CdlUpdateHandler update_handler_arg,
834
                                     int argc_arg, const char* argv_arg[],
835
                                     std::vector<std::pair<std::string,std::string> >& options_arg)
836
{
837
    return new CdlProperty_GoalExpressionBody(node_arg, name_arg, expr_arg, update_handler_arg,
838
                                              argc_arg, argv_arg, options_arg);
839
}
840
 
841
CdlProperty_GoalExpressionBody::CdlProperty_GoalExpressionBody(CdlNode node_arg, std::string name_arg,
842
                                                               CdlGoalExpression expr_arg,
843
                                                               CdlUpdateHandler update_handler_arg,
844
                                                               int argc_arg, const char* argv_arg[],
845
                                                               std::vector<std::pair<std::string,std::string> >& options_arg)
846
    : CdlPropertyBody(node_arg, name_arg, argc_arg, argv_arg, options_arg),
847
      CdlGoalExpressionBody(*expr_arg),
848
      update_handler(update_handler_arg)
849
{
850
    CYG_REPORT_FUNCNAME("CdlProperty_GoalExpression:: constructor");
851
    CYG_REPORT_FUNCARG1("this %p", this);
852
 
853
    cdlproperty_goalexpressionbody_cookie = CdlProperty_GoalExpressionBody_Magic;
854
    CYGDBG_MEMLEAK_CONSTRUCTOR();
855
 
856
    CYG_POSTCONDITION_THISC();
857
    CYG_REPORT_RETURN();
858
}
859
 
860
CdlProperty_GoalExpressionBody::~CdlProperty_GoalExpressionBody()
861
{
862
    CYG_REPORT_FUNCNAME("CdlProperty_GoalExpression:: destructor");
863
    CYG_REPORT_FUNCARG1("this %p", this);
864
    CYG_PRECONDITION_THISC();
865
 
866
    cdlproperty_goalexpressionbody_cookie = CdlProperty_GoalExpressionBody_Invalid;
867
    CYGDBG_MEMLEAK_DESTRUCTOR();
868
 
869
    CYG_REPORT_RETURN();
870
}
871
 
872
void
873
CdlProperty_GoalExpressionBody::update(CdlTransaction transact, CdlNode source, CdlNode dest, CdlUpdate change)
874
{
875
    CYG_REPORT_FUNCNAME("CdlProperty_GoalExpression::update");
876
    CYG_REPORT_FUNCARG4XV(this, source, dest, change);
877
    CYG_PRECONDITION_THISC();
878
 
879
    // The CdlExpression update() member will take care of binding and
880
    // unbinding, as needed.
881
    if ((change & (CdlUpdate_Loaded | CdlUpdate_Unloading | CdlUpdate_Created | CdlUpdate_Destroyed)) != 0) {
882
        CdlExpression expr = get_expression();
883
        bool handled = expr->update(transact, source, this, dest, change);
884
        CYG_UNUSED_PARAM(bool, handled);
885
        CYG_ASSERTC(handled);
886
    }
887
 
888
    // Now invoke the per-property update handler to re-evaluate
889
    // the gexpr as appropriate
890
    (*update_handler)(transact, source, this, dest, change);
891
 
892
    CYG_REPORT_RETURN();
893
}
894
 
895
bool
896
CdlProperty_GoalExpressionBody::check_this(cyg_assert_class_zeal zeal) const
897
{
898
    if (CdlProperty_GoalExpressionBody_Magic != cdlproperty_goalexpressionbody_cookie) {
899
        return false;
900
    }
901
    CYGDBG_MEMLEAK_CHECKTHIS();
902
    return inherited_property::check_this(zeal) && inherited_expression::check_this(zeal);
903
}
904
 
905
//}}}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.