#!/usr/bin/tclsh # Example 3. # Gives a brief impression of how clipboards can be used # in code generation (in this case, generating a C++ class). # The output of running this script is in 'out3.txt'. source "lib_clip.tcl" source "syn_clip.tcl" proc make_class {name base} { clip $name { cb_puts "class $name : public $base\n\{\n" plug CLASS_BODY { cb_puts "public:\n" plug PUBLIC cb_puts "private:\n" plug PRIVATE } cb_puts "\};\n" } } make_class A B add A PUBLIC { cb_puts " A() // Default constructor\n" cb_puts " \{\n" cb_puts " i= 5;\n" cb_puts " \}\n" } add A PRIVATE {cb_puts " int i; // Some member variable\n"} cb_output A