// A simple template with multiple template parameters
template <class A, class B, class C, class D, class E>
-void flubber (void) // flubber
-{
+void flubber (void) { // flubber
A a;
B b;
C c;
int overload (base& b) const { return 5; } // base::overload(base&) const
// Operators
- int operator+ (base const& o) const // base::operator+
- { return foo_ + o.foo_; }
+ int operator+ (base const& o) const { // base::operator+
+ return foo_ + o.foo_; }
- base operator++ (void) // base::operator++
- { ++foo_; return *this; }
+ base operator++ (void) { // base::operator++
+ ++foo_; return *this; }
- base operator+=(base const& o) // base::operator+=
- { foo_ += o.foo_; return *this; }
+ base operator+=(base const& o) { // base::operator+=
+ foo_ += o.foo_; return *this; }
- int operator- (base const& o) const // base::operator-
- { return foo_ - o.foo_; }
+ int operator- (base const& o) const { // base::operator-
+ return foo_ - o.foo_; }
- base operator-- (void) // base::operator--
- { --foo_; return *this; }
+ base operator-- (void) { // base::operator--
+ --foo_; return *this; }
- base operator-= (base const& o) // base::operator-=
- { foo_ -= o.foo_; return *this; }
+ base operator-= (base const& o) { // base::operator-=
+ foo_ -= o.foo_; return *this; }
- int operator* (base const& o) const // base::operator*
- { return foo_ * o.foo_; }
+ int operator* (base const& o) const { // base::operator*
+ return foo_ * o.foo_; }
- base operator*= (base const& o) // base::operator*=
- { foo_ *= o.foo_; return *this; }
+ base operator*= (base const& o) { // base::operator*=
+ foo_ *= o.foo_; return *this; }
- int operator/ (base const& o) const // base::operator/
- { return foo_ / o.foo_; }
+ int operator/ (base const& o) const { // base::operator/
+ return foo_ / o.foo_; }
- base operator/= (base const& o) // base::operator/=
- { foo_ /= o.foo_; return *this; }
+ base operator/= (base const& o) { // base::operator/=
+ foo_ /= o.foo_; return *this; }
- int operator% (base const& o) const // base::operator%
- { return foo_ % o.foo_; }
+ int operator% (base const& o) const { // base::operator%
+ return foo_ % o.foo_; }
- base operator%= (base const& o) // base::operator%=
- { foo_ %= o.foo_; return *this; }
+ base operator%= (base const& o) { // base::operator%=
+ foo_ %= o.foo_; return *this; }
- bool operator< (base const& o) const // base::operator<
- { return foo_ < o.foo_; }
+ bool operator< (base const& o) const { // base::operator<
+ return foo_ < o.foo_; }
- bool operator<= (base const& o) const // base::operator<=
- { return foo_ <= o.foo_; }
+ bool operator<= (base const& o) const { // base::operator<=
+ return foo_ <= o.foo_; }
- bool operator> (base const& o) const // base::operator>
- { return foo_ > o.foo_; }
+ bool operator> (base const& o) const { // base::operator>
+ return foo_ > o.foo_; }
- bool operator>= (base const& o) const // base::operator>=
- { return foo_ >= o.foo_; }
+ bool operator>= (base const& o) const { // base::operator>=
+ return foo_ >= o.foo_; }
- bool operator!= (base const& o) const // base::operator!=
- { return foo_ != o.foo_; }
+ bool operator!= (base const& o) const { // base::operator!=
+ return foo_ != o.foo_; }
- bool operator== (base const& o) const // base::operator==
- { return foo_ == o.foo_; }
+ bool operator== (base const& o) const { // base::operator==
+ return foo_ == o.foo_; }
- bool operator! (void) const // base::operator!
- { return !foo_; }
+ bool operator! (void) const { // base::operator!
+ return !foo_; }
- bool operator&& (base const& o) const // base::operator&&
- { return foo_ && o.foo_; }
+ bool operator&& (base const& o) const { // base::operator&&
+ return foo_ && o.foo_; }
- bool operator|| (base const& o) const // base::operator||
- { return foo_ || o.foo_; }
+ bool operator|| (base const& o) const { // base::operator||
+ return foo_ || o.foo_; }
- int operator<< (int value) const // base::operator<<
- { return foo_ << value; }
+ int operator<< (int value) const { // base::operator<<
+ return foo_ << value; }
- base operator<<= (int value) // base::operator<<=
- { foo_ <<= value; return *this; }
+ base operator<<= (int value) { // base::operator<<=
+ foo_ <<= value; return *this; }
- int operator>> (int value) const // base::operator>>
- { return foo_ >> value; }
+ int operator>> (int value) const { // base::operator>>
+ return foo_ >> value; }
- base operator>>= (int value) // base::operator>>=
- { foo_ >>= value; return *this; }
+ base operator>>= (int value) { // base::operator>>=
+ foo_ >>= value; return *this; }
- int operator~ (void) const // base::operator~
- { return ~foo_; }
+ int operator~ (void) const { // base::operator~
+ return ~foo_; }
- int operator& (base const& o) const // base::operator&
- { return foo_ & o.foo_; }
+ int operator& (base const& o) const { // base::operator&
+ return foo_ & o.foo_; }
- base operator&= (base const& o) // base::operator&=
- { foo_ &= o.foo_; return *this; }
+ base operator&= (base const& o) { // base::operator&=
+ foo_ &= o.foo_; return *this; }
- int operator| (base const& o) const // base::operator|
- { return foo_ | o.foo_; }
+ int operator| (base const& o) const { // base::operator|
+ return foo_ | o.foo_; }
- base operator|= (base const& o) // base::operator|=
- { foo_ |= o.foo_; return *this; }
+ base operator|= (base const& o) { // base::operator|=
+ foo_ |= o.foo_; return *this; }
- int operator^ (base const& o) const // base::operator^
- { return foo_ ^ o.foo_; }
+ int operator^ (base const& o) const { // base::operator^
+ return foo_ ^ o.foo_; }
- base operator^= (base const& o) // base::operator^=
- { foo_ ^= o.foo_; return *this; }
+ base operator^= (base const& o) { // base::operator^=
+ foo_ ^= o.foo_; return *this; }
- base operator= (base const& o) // base::operator=
- { foo_ = o.foo_; return *this; }
+ base operator= (base const& o) { // base::operator=
+ foo_ = o.foo_; return *this; }
- void operator() (void) const // base::operator()
- { return; }
+ void operator() (void) const { // base::operator()
+ return; }
- int operator[] (int idx) const // base::operator[]
- { return idx; }
+ int operator[] (int idx) const { // base::operator[]
+ return idx; }
- void* operator new (size_t size) throw () // base::operator new
- { return malloc (size); }
+ void* operator new (size_t size) throw () { // base::operator new
+ return malloc (size); }
- void operator delete (void* ptr) // base::operator delete
- { free (ptr); }
+ void operator delete (void* ptr) { // base::operator delete
+ free (ptr); }
- void* operator new[] (size_t size) throw () // base::operator new[]
- { return malloc (size); }
+ void* operator new[] (size_t size) throw () { // base::operator new[]
+ return malloc (size); }
- void operator delete[] (void* ptr) // base::operator delete[]
- { free (ptr); }
+ void operator delete[] (void* ptr) { // base::operator delete[]
+ free (ptr); }
- base const* operator-> (void) const // base::opeartor->
- { return this; }
+ base const* operator-> (void) const { // base::opeartor->
+ return this; }
- int operator->* (base const& b) const // base::operator->*
- { return foo_ * b.foo_; }
+ int operator->* (base const& b) const { // base::operator->*
+ return foo_ * b.foo_; }
operator char* () const { return const_cast<char*> ("hello"); } // base::operator char*
operator int () const { return 21; } // base::operator int
{
public:
derived(void) : foo_ (4) { } // derived::derived
- void a_function (void) const // derived::a_function
- {
+ void a_function (void) const { // derived::a_function
this->base1::a_function ();
this->base2::a_function ();
}
# Usage:
# add NAME TYPE PRINT LST
# add NAME TYPE PRINT -
-proc add {func type print lst} {
+proc add_type_regexp {func type print lst} {
global all_functions CONVAR ADDR
set all_functions($func,type) $type
regsub {\(void\)} $print {()} print
set all_functions($func,print) \
- "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>"
+ "$CONVAR = {$type} $ADDR <[string_to_regexp $print].*>"
if {$lst == "-"} {
set lst "$func"
}
set all_functions($func,list) ".*// [string_to_regexp $lst]"
}
+proc add {func type print lst} {
+ add_type_regexp $func [string_to_regexp $type] $print $lst
+}
+
proc get {func cmd} {
global all_functions
return $all_functions($func,$cmd)
# On targets using the ARM EABI, the constructor is expected to return
# "this".
-proc ctor { type arglist } {
+proc ctor_ret { type } {
if { [istarget arm*-*eabi*] } {
- set ret "$type *"
+ return "$type *"
} else {
- set ret "void "
+ return "void "
}
+}
+
+proc ctor_prefix { type } {
+ set ret [ctor_ret $type]
+ return "${ret}($type * const"
+}
+
+proc ctor { type arglist } {
if { $arglist != "" } {
set arglist ", $arglist"
}
- return "${ret}($type * const$arglist)"
+ return "[ctor_prefix $type]$arglist)"
}
add {derived::derived} \
[ctor derived ""] \
- \
-
-add {base1::base1(void)} \
- [ctor base1 "const void ** const"] \
+add_type_regexp {base1::base1(void)} \
+ "[string_to_regexp [ctor_prefix base1]], (const )?void \\*\\*( const)?\\)" \
- \
-
add {base1::base1(int)} \
[ctor base1 "int"] \
- \
-
-add {base2::base2} \
- [ctor base2 "const void ** const"] \
+add_type_regexp {base2::base2} \
+ "[string_to_regexp [ctor_prefix base2]], (const )?void \\*\\*( const)?\\)" \
- \
-
add {base::base(void)} \