// File:       typeinfo.c++
// Version:    1.00
// Author:     (c) Miles Sabin, 1996
// Purpose:    fake RTTI for Acorn CFront

// Change log:
//  6/10/96    v. 1.00

#include "typeinfo.h"

#include <string.h>
#include "exception.h"


// Implementation of type_info

type_info::type_info(char const* name)
  : name_(name)
  {}

type_info::~type_info()
  {}

int type_info::operator==(type_info const& rhs) const
  { return strcmp(name_, rhs.name_); }

RTTI_SCAFFOLDING_DEFN_0(type_info)


// Implementation of bad_cast

bad_cast::bad_cast()
  {}

bad_cast::~bad_cast()
  {}

char const* bad_cast::what() const
  { return "bad_cast"; }

RTTI_SCAFFOLDING_DEFN_1(bad_cast, exception)


// Implementation of bad_typeid

bad_typeid::bad_typeid()
  {}

bad_typeid::~bad_typeid()
  {}

char const* bad_typeid::what() const
  { return "bad_typeid"; }

RTTI_SCAFFOLDING_DEFN_1(bad_typeid, exception)


// RTTI support fns

void* RTTI_check_bad_cast(void* p)
{
  if(p == 0)
    throw(bad_cast());

  return p;
}

void* RTTI_bad_typeid()
{
  throw(bad_typeid());
  return 0;
}

