]> www.ginac.de Git - ginac.git/blob - ginac/container.pl
documentation update
[ginac.git] / ginac / container.pl
1 if (($#ARGV!=0) and ($#ARGV!=1)) {
2         die 'usage: container.pl type [maxargs] (type=lst or exprseq)';
3 }
4
5 if ($ARGV[0] eq 'lst') {
6         $type='lst';
7 } elsif ($ARGV[0] eq 'exprseq') {
8         $type='exprseq';
9 } else {
10         die 'only lst and exprseq supported';
11 }
12
13 if ($#ARGV==1) {
14         $maxargs=$ARGV[1];
15 } else {
16         $maxargs=15; # must be greater or equal than the value used in function.pl
17 }
18
19 if ($type eq 'exprseq') {
20
21         # settings for exprseq
22         $CONTAINER="exprseq";
23         $STLHEADER="vector";
24         $reserve=1;
25         $prepend=0;
26         $let_op=0;
27         $open_bracket='(';
28         $close_bracket=')';
29         
30 } elsif ($type eq 'lst') {
31  
32         # settings for lst
33         $CONTAINER="lst";
34         $STLHEADER="list";
35         $reserve=0;
36         $prepend=1;
37         $let_op=1;
38         $open_bracket='[';
39         $close_bracket=']';
40
41 } else {
42         die "invalid type $type";
43 }
44
45 $CONTAINER_UC=uc(${CONTAINER});
46 $STLT="ex".$STLHEADER;
47
48 if ($reserve) {
49         $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) (s).reserve(size)";
50 } else {
51         $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) // no reserve needed for ${STLHEADER}";
52 }
53
54 if ($prepend) {
55         $PREPEND_INTERFACE=<<END_OF_PREPEND_INTERFACE;
56         virtual ${CONTAINER} & prepend(const ex & b);
57 END_OF_PREPEND_INTERFACE
58
59         $PREPEND_IMPLEMENTATION=<<END_OF_PREPEND_IMPLEMENTATION;
60 ${CONTAINER} & ${CONTAINER}::prepend(const ex & b)
61 {
62         ensure_if_modifiable();
63         seq.push_front(b);
64         return *this;
65 }
66 END_OF_PREPEND_IMPLEMENTATION
67 } else {
68         $PREPEND_INTERFACE="    // no prepend possible for ${CONTAINER}";
69         $PREPEND_IMPLEMENTATION="";
70 }
71
72 if ($let_op) {
73         $LET_OP_IMPLEMENTATION=<<END_OF_LET_OP_IMPLEMENTATION
74 ex & ${CONTAINER}::let_op(int i)
75 {
76         GINAC_ASSERT(i>=0);
77         GINAC_ASSERT(i<nops());
78
79         ${STLT}::iterator it=seq.begin();
80         for (int j=0; j<i; j++) {
81                 ++it;
82         }
83         return *it;
84 }
85 END_OF_LET_OP_IMPLEMENTATION
86 } else {
87         $LET_OP_IMPLEMENTATION="// ${CONTAINER}::let_op() will be implemented by user elsewhere";
88 }
89
90 sub generate_seq {
91         my ($seq_template,$n,$separator)=@_;
92         my ($res,$N);
93         
94         $res='';
95         for ($N=1; $N<=$n; $N++) {
96                 $res .= eval('"' . $seq_template . '"');
97                 if ($N!=$n) {
98                         $res .= $separator;
99                 }
100         }
101         return $res;
102 }
103
104 sub generate_from_to {
105         my ($template,$seq_template1,$seq_separator1,$seq_template2,
106             $seq_separator2,$from,$to)=@_;
107         my ($res,$N,$SEQ);
108
109         $res='';
110         for ($N=$from; $N<=$to; $N++) {
111                 $SEQ1=generate_seq($seq_template1,$N,$seq_separator1);
112                 $SEQ2=generate_seq($seq_template2,$N,$seq_separator2);
113                 $res .= eval('"' . $template . '"');
114                 $SEQ1=''; # to avoid main::SEQ1 used only once warning
115                 $SEQ2=''; # same as above
116         }
117         return $res;
118 }
119
120 sub generate {
121         my ($template,$seq_template1,$seq_separator1,$seq_template2,
122             $seq_separator2)=@_;
123         return generate_from_to($template,$seq_template1,$seq_separator1,
124                                                         $seq_template2,$seq_separator2,1,$maxargs);
125 }
126
127 $constructors_interface=generate(
128 '       explicit ${CONTAINER}(${SEQ1});'."\n",
129 'const ex & param${N}',', ','','');
130
131 $constructors_implementation=generate(
132         <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ','    seq.push_back(param${N});',"\n");
133 ${CONTAINER}::${CONTAINER}(${SEQ1}) : basic(TINFO_${CONTAINER})
134 {
135         debugmsg(\"${CONTAINER} ctor from ${N}*ex\",LOGLEVEL_CONSTRUCT);
136         RESERVE(seq,${N});
137 ${SEQ2}
138 }
139 END_OF_CONSTRUCTORS_IMPLEMENTATION
140
141 $interface=<<END_OF_INTERFACE;
142 /** \@file ${CONTAINER}.h
143  *
144  *  Definition of GiNaC's ${CONTAINER}. */
145
146 /*
147  *  This file was generated automatically by container.pl.
148  *  Please do not modify it directly, edit the perl script instead!
149  *  container.pl options: \$CONTAINER=${CONTAINER}
150  *                        \$STLHEADER=${STLHEADER}
151  *                        \$reserve=${reserve}
152  *                        \$prepend=${prepend}
153  *                        \$let_op=${let_op}
154  *                        \$open_bracket=${open_bracket}
155  *                        \$close_bracket=${close_bracket}
156  *                        \$maxargs=${maxargs}
157  *
158  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
159  *
160  *  This program is free software; you can redistribute it and/or modify
161  *  it under the terms of the GNU General Public License as published by
162  *  the Free Software Foundation; either version 2 of the License, or
163  *  (at your option) any later version.
164  *
165  *  This program is distributed in the hope that it will be useful,
166  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
167  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
168  *  GNU General Public License for more details.
169  *
170  *  You should have received a copy of the GNU General Public License
171  *  along with this program; if not, write to the Free Software
172  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
173  */
174
175 #ifndef __GINAC_${CONTAINER_UC}_H__
176 #define __GINAC_${CONTAINER_UC}_H__
177
178 #include <${STLHEADER}>
179
180 // CINT needs <algorithm> to work properly with <vector> and <list> 
181 #include <algorithm>
182
183 #include "basic.h"
184 #include "ex.h"
185
186 namespace GiNaC {
187
188
189 // Cint currently does not like ${STLHEADER}<..,default_alloc> but malloc_alloc is
190 // unstandardized and not supported by newer GCCs.  This ugly hack will go
191 // away soon!
192 #if (defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 97)) || (defined(G__GNUC) && (G__GNUC == 2) && (G__GNUC_MINOR < 97))
193 typedef std::${STLHEADER}<GiNaC::ex,malloc_alloc> ${STLT};
194 #else
195 typedef std::${STLHEADER}<ex> ${STLT};
196 #endif
197
198 class ${CONTAINER} : public basic
199 {
200         GINAC_DECLARE_REGISTERED_CLASS(${CONTAINER}, basic)
201
202 public:
203         ${CONTAINER}(${STLT} const & s, bool discardable=0);
204         ${CONTAINER}(${STLT} * vp); // vp will be deleted
205 ${constructors_interface}
206
207 public:
208         void print(const print_context & c, unsigned level = 0) const;
209         bool info(unsigned inf) const;
210         unsigned nops() const;
211         ex & let_op(int i);
212         ex expand(unsigned options=0) const;
213         bool has(const ex & other) const;
214         ex eval(int level=0) const;
215         ex evalf(int level=0) const;
216         ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
217         ex derivative(const symbol & s) const;
218         ex subs(const lst & ls, const lst & lr) const;
219 protected:
220         bool is_equal_same_type(const basic & other) const;
221         unsigned return_type(void) const;
222
223         // new virtual functions which can be overridden by derived classes
224 public:
225         virtual ${CONTAINER} & append(const ex & b);
226 ${PREPEND_INTERFACE}
227 protected:
228         virtual void printseq(const print_context & c, char openbracket, char delim,
229                               char closebracket, unsigned this_precedence,
230                               unsigned upper_precedence = 0) const;
231         virtual ex this${CONTAINER}(${STLT} const & v) const;
232         virtual ex this${CONTAINER}(${STLT} * vp) const;
233
234 protected:
235         bool is_canonical() const;
236         ${STLT} evalchildren(int level) const;
237         ${STLT} evalfchildren(int level) const;
238         ${STLT} normalchildren(int level) const;
239         ${STLT} diffchildren(const symbol & s) const;
240         ${STLT} * subschildren(const lst & ls, const lst & lr) const;
241
242 protected:
243         ${STLT} seq;
244         static unsigned precedence;
245 };
246
247 // utility functions
248 inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e)
249 {
250         return static_cast<const ${CONTAINER} &>(*e.bp);
251 }
252
253 inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e)
254 {
255         return static_cast<${CONTAINER} &>(*e.bp);
256 }
257
258 } // namespace GiNaC
259
260 #endif // ndef __GINAC_${CONTAINER_UC}_H__
261
262 END_OF_INTERFACE
263
264 $implementation=<<END_OF_IMPLEMENTATION;
265 /** \@file ${CONTAINER}.cpp
266  *
267  *  Implementation of GiNaC's ${CONTAINER}. */
268
269 /*
270  *  This file was generated automatically by container.pl.
271  *  Please do not modify it directly, edit the perl script instead!
272  *  container.pl options: \$CONTAINER=${CONTAINER}
273  *                        \$STLHEADER=${STLHEADER}
274  *                        \$reserve=${reserve}
275  *                        \$prepend=${prepend}
276  *                        \$let_op=${let_op}
277  *                        \$open_bracket=${open_bracket}
278  *                        \$close_bracket=${close_bracket}
279  *                        \$maxargs=${maxargs}
280  *
281  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
282  *
283  *  This program is free software; you can redistribute it and/or modify
284  *  it under the terms of the GNU General Public License as published by
285  *  the Free Software Foundation; either version 2 of the License, or
286  *  (at your option) any later version.
287  *
288  *  This program is distributed in the hope that it will be useful,
289  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
290  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
291  *  GNU General Public License for more details.
292  *
293  *  You should have received a copy of the GNU General Public License
294  *  along with this program; if not, write to the Free Software
295  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
296  */
297
298 #include <iostream>
299 #include <stdexcept>
300
301 #include "${CONTAINER}.h"
302 #include "ex.h"
303 #include "print.h"
304 #include "archive.h"
305 #include "debugmsg.h"
306
307 namespace GiNaC {
308
309 GINAC_IMPLEMENT_REGISTERED_CLASS(${CONTAINER}, basic)
310
311 ${RESERVE_IMPLEMENTATION}
312
313 //////////
314 // default ctor, dtor, copy ctor assignment operator and helpers
315 //////////
316
317 // public
318
319 ${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER})
320 {
321         debugmsg("${CONTAINER} default ctor",LOGLEVEL_CONSTRUCT);
322 }
323
324 // protected
325
326 void ${CONTAINER}::copy(${CONTAINER} const & other)
327 {
328         inherited::copy(other);
329         seq=other.seq;
330 }
331
332 void ${CONTAINER}::destroy(bool call_parent)
333 {
334         seq.clear();
335         if (call_parent) inherited::destroy(call_parent);
336 }
337
338 //////////
339 // other ctors
340 //////////
341
342 // public
343
344 ${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) :  basic(TINFO_${CONTAINER})
345 {
346         debugmsg("${CONTAINER} ctor from ${STLT}", LOGLEVEL_CONSTRUCT);
347         if (discardable) {
348                 seq.swap(const_cast<${STLT} &>(s));
349         } else {
350                 seq=s;
351         }
352 }
353
354 ${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER})
355 {
356         debugmsg("${CONTAINER} ctor from ${STLT} *",LOGLEVEL_CONSTRUCT);
357         GINAC_ASSERT(vp!=0);
358         seq.swap(*vp);
359         delete vp;
360 }
361
362 ${constructors_implementation}
363
364 //////////
365 // archiving
366 //////////
367
368 /** Construct object from archive_node. */
369 ${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
370 {
371         debugmsg("${CONTAINER} ctor from archive_node", LOGLEVEL_CONSTRUCT);
372         for (unsigned int i=0; true; i++) {
373                 ex e;
374                 if (n.find_ex("seq", e, sym_lst, i))
375                         seq.push_back(e);
376                 else
377                         break;
378         }
379 }
380
381 /** Unarchive the object. */
382 ex ${CONTAINER}::unarchive(const archive_node &n, const lst &sym_lst)
383 {
384         return (new ${CONTAINER}(n, sym_lst))->setflag(status_flags::dynallocated);
385 }
386
387 /** Archive the object. */
388 void ${CONTAINER}::archive(archive_node &n) const
389 {
390         inherited::archive(n);
391         ${STLT}::const_iterator i = seq.begin(), iend = seq.end();
392         while (i != iend) {
393                 n.add_ex("seq", *i);
394                 i++;
395         }
396 }
397
398 //////////
399 // functions overriding virtual functions from bases classes
400 //////////
401
402 // public
403
404 void ${CONTAINER}::print(const print_context & c, unsigned level) const
405 {
406         debugmsg("${CONTAINER} print", LOGLEVEL_PRINT);
407
408         if (is_of_type(c, print_tree)) {
409
410                 c.s << std::string(level, ' ') << class_name()
411                     << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
412                     << ", nops=" << nops()
413                     << std::endl;
414                 unsigned delta_indent = static_cast<const print_tree &>(c).delta_indent;
415                 for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit)
416                         cit->print(c, level + delta_indent);
417                 c.s << std::string(level + delta_indent,' ') << "=====" << std::endl;
418
419         } else {
420                 // always print brackets around seq, ignore upper_precedence
421                 printseq(c, '${open_bracket}', ',', '${close_bracket}', precedence, precedence+1);
422         }
423 }
424
425 // ${CONTAINER}::info() will be implemented by user elsewhere";
426
427 unsigned ${CONTAINER}::nops() const
428 {
429         return seq.size();
430 }
431
432 ${LET_OP_IMPLEMENTATION}
433
434 ex ${CONTAINER}::expand(unsigned options) const
435 {
436         ${STLT} s;
437         RESERVE(s,seq.size());
438         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
439                 s.push_back((*it).expand(options));
440         }
441
442         return this${CONTAINER}(s);
443 }
444
445 // a ${CONTAINER} 'has' an expression if it is this expression itself or a child 'has' it
446
447 bool ${CONTAINER}::has(const ex & other) const
448 {
449         GINAC_ASSERT(other.bp!=0);
450         if (is_equal(*other.bp)) return true;
451         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
452                 if ((*it).has(other)) return true;
453         }
454         return false;
455 }
456
457 ex ${CONTAINER}::eval(int level) const
458 {
459         if (level==1) {
460                 return this->hold();
461         }
462         return this${CONTAINER}(evalchildren(level));
463 }
464
465 ex ${CONTAINER}::evalf(int level) const
466 {
467         return this${CONTAINER}(evalfchildren(level));
468 }
469
470 /** Implementation of ex::normal() for ${CONTAINER}s. It normalizes the arguments
471  *  and replaces the ${CONTAINER} by a temporary symbol.
472  *  \@see ex::normal */
473 ex ${CONTAINER}::normal(lst &sym_lst, lst &repl_lst, int level) const
474 {
475         ex n=this${CONTAINER}(normalchildren(level));
476         return n.bp->basic::normal(sym_lst,repl_lst,level);
477 }
478
479 ex ${CONTAINER}::derivative(const symbol & s) const
480 {
481         return this${CONTAINER}(diffchildren(s));
482 }
483
484 ex ${CONTAINER}::subs(const lst & ls, const lst & lr) const
485 {
486         ${STLT} * vp=subschildren(ls,lr);
487         if (vp==0)
488                 return inherited::subs(ls, lr);
489
490         return this${CONTAINER}(vp);
491 }
492
493 // protected
494
495 int ${CONTAINER}::compare_same_type(const basic & other) const
496 {
497         GINAC_ASSERT(is_of_type(other,${CONTAINER}));
498         ${CONTAINER} const & o=static_cast<${CONTAINER} const &>
499                                                                         (const_cast<basic &>(other));
500         int cmpval;
501         ${STLT}::const_iterator it1=seq.begin();
502         ${STLT}::const_iterator it2=o.seq.begin();
503
504         for (; (it1!=seq.end())&&(it2!=o.seq.end()); ++it1, ++it2) {
505                 cmpval=(*it1).compare(*it2);
506                 if (cmpval!=0) return cmpval;
507         }
508
509         if (it1==seq.end()) {
510                 return (it2==o.seq.end() ? 0 : -1);
511         }
512
513         return 1;
514 }
515
516 bool ${CONTAINER}::is_equal_same_type(const basic & other) const
517 {
518         GINAC_ASSERT(is_of_type(other,${CONTAINER}));
519         ${CONTAINER} const & o=static_cast<${CONTAINER} const &>
520                                                                         (const_cast<basic &>(other));
521         if (seq.size()!=o.seq.size()) return false;
522
523         ${STLT}::const_iterator it1=seq.begin();
524         ${STLT}::const_iterator it2=o.seq.begin();
525
526         for (; it1!=seq.end(); ++it1, ++it2) {
527                 if (!(*it1).is_equal(*it2)) return false;
528         }
529
530         return true;
531 }
532
533 unsigned ${CONTAINER}::return_type(void) const
534 {
535         return return_types::noncommutative_composite;
536 }
537
538 //////////
539 // new virtual functions which can be overridden by derived classes
540 //////////
541
542 // public
543
544 ${CONTAINER} & ${CONTAINER}::append(const ex & b)
545 {
546         ensure_if_modifiable();
547         seq.push_back(b);
548         return *this;
549 }
550
551 ${PREPEND_IMPLEMENTATION}
552
553 // protected
554
555 void ${CONTAINER}::printseq(const print_context & c, char openbracket, char delim,
556                             char closebracket, unsigned this_precedence,
557                             unsigned upper_precedence) const
558 {
559         if (this_precedence <= upper_precedence)
560                 c.s << openbracket;
561
562         if (seq.size() != 0) {
563                 ${STLT}::const_iterator it = seq.begin(), itend = seq.end();
564                 --itend;
565                 while (it != itend) {
566                         it->print(c, this_precedence);
567                         c.s << delim;
568                         it++;
569                 }
570                 it->print(c, this_precedence);
571         }
572
573         if (this_precedence <= upper_precedence)
574                 c.s << closebracket;
575 }
576
577 ex ${CONTAINER}::this${CONTAINER}(${STLT} const & v) const
578 {
579         return ${CONTAINER}(v);
580 }
581
582 ex ${CONTAINER}::this${CONTAINER}(${STLT} * vp) const
583 {
584         return ${CONTAINER}(vp);
585 }
586
587 //////////
588 // non-virtual functions in this class
589 //////////
590
591 // public
592
593 // none
594
595 // protected
596
597 bool ${CONTAINER}::is_canonical() const
598 {
599         if (seq.size()<=1) { return 1; }
600
601         ${STLT}::const_iterator it=seq.begin();
602         ${STLT}::const_iterator it_last=it;
603         for (++it; it!=seq.end(); it_last=it, ++it) {
604                 if ((*it_last).compare(*it)>0) {
605                         if ((*it_last).compare(*it)>0) {
606                                 std::cout << *it_last << ">" << *it << "\\n";
607                                 return 0;
608                         }
609                 }
610         }
611         return 1;
612 }
613
614
615 ${STLT} ${CONTAINER}::evalchildren(int level) const
616 {
617         ${STLT} s;
618         RESERVE(s,seq.size());
619
620         if (level==1) {
621                 return seq;
622         }
623         if (level == -max_recursion_level) {
624                 throw(std::runtime_error("max recursion level reached"));
625         }
626         --level;
627         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
628                 s.push_back((*it).eval(level));
629         }
630         return s;
631 }
632
633 ${STLT} ${CONTAINER}::evalfchildren(int level) const
634 {
635         ${STLT} s;
636         RESERVE(s,seq.size());
637
638         if (level==1) {
639                 return seq;
640         }
641         if (level == -max_recursion_level) {
642                 throw(std::runtime_error("max recursion level reached"));
643         }
644         --level;
645         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
646                 s.push_back((*it).evalf(level));
647         }
648         return s;
649 }
650
651 ${STLT} ${CONTAINER}::normalchildren(int level) const
652 {
653         ${STLT} s;
654         RESERVE(s,seq.size());
655
656         if (level==1) {
657                 return seq;
658         }
659         if (level == -max_recursion_level) {
660                 throw(std::runtime_error("max recursion level reached"));
661         }
662         --level;
663         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
664                 s.push_back((*it).normal(level));
665         }
666         return s;
667 }
668
669 ${STLT} ${CONTAINER}::diffchildren(const symbol & y) const
670 {
671         ${STLT} s;
672         RESERVE(s,seq.size());
673         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
674                 s.push_back((*it).diff(y));
675         }
676         return s;
677 }
678
679 /* obsolete subschildren
680 ${STLT} ${CONTAINER}::subschildren(const lst & ls, const lst & lr) const
681 {
682         ${STLT} s;
683         RESERVE(s,seq.size());
684         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
685                 s.push_back((*it).subs(ls,lr));
686         }
687         return s;
688 }
689 */
690
691 ${STLT} * ${CONTAINER}::subschildren(const lst & ls, const lst & lr) const
692 {
693         // returns a NULL pointer if nothing had to be substituted
694         // returns a pointer to a newly created epvector otherwise
695         // (which has to be deleted somewhere else)
696
697         ${STLT}::const_iterator last=seq.end();
698         ${STLT}::const_iterator cit=seq.begin();
699         while (cit!=last) {
700                 const ex & subsed_ex=(*cit).subs(ls,lr);
701                 if (!are_ex_trivially_equal(*cit,subsed_ex)) {
702
703                         // something changed, copy seq, subs and return it
704                         ${STLT} *s=new ${STLT};
705                         RESERVE(*s,seq.size());
706
707                         // copy parts of seq which are known not to have changed
708                         ${STLT}::const_iterator cit2=seq.begin();
709                         while (cit2!=cit) {
710                                 s->push_back(*cit2);
711                                 ++cit2;
712                         }
713                         // copy first changed element
714                         s->push_back(subsed_ex);
715                         ++cit2;
716                         // copy rest
717                         while (cit2!=last) {
718                                 s->push_back((*cit2).subs(ls,lr));
719                                 ++cit2;
720                         }
721                         return s;
722                 }
723                 ++cit;
724         }
725         
726         return 0; // nothing has changed
727 }
728
729 //////////
730 // static member variables
731 //////////
732
733 // protected
734
735 unsigned ${CONTAINER}::precedence = 10;
736
737 } // namespace GiNaC
738
739 END_OF_IMPLEMENTATION
740
741 print "Creating interface file ${CONTAINER}.h...";
742 open OUT,">${CONTAINER}.h" or die "cannot open ${CONTAINER}.h";
743 print OUT $interface;
744 close OUT;
745 print "ok.\n";
746
747 print "Creating implementation file ${CONTAINER}.cpp...";
748 open OUT,">${CONTAINER}.cpp" or die "cannot open ${CONTAINER}.cpp";
749 print OUT $implementation;
750 close OUT;
751 print "ok.\n";
752
753 print "done.\n";