/********************************************************************
 * Ruby module for SWIG
 *
 * $Id: swigruby.h,v 1.5 2000/05/07 14:47:44 fukusima Exp $
 *
 * Copyright (C) 1999  Network Applied Communication Laboratory, Inc.
 *
 * Masaki Fukushima
 *
 ********************************************************************/

class RClass {
 private:
  String temp;
 public:
  String name;	// class name (renamed)
  String cname; // original C class/struct name
  String vname; // variable name
  String type;
  String prefix;
  String header;
  String init;

  String aliases;
  String includes;
  Hash freemethods;
  Hash predmethods;
  int destructor_defined;

  RClass(void) {
    destructor_defined = 0;
  }
  void set_name(char *cn, char *rn, char *valn) {
    cname = cn;
    name = valn;
    vname << "c" << name;
    prefix <<  (rn ? rn : cn) << "_";
  }
  char *strip(char *s) {
    if (strncmp(s, prefix, strlen(prefix)) != 0)
      return s;
    temp = s;
    temp.replace(prefix, "");
    return temp;
  }
};

class RUBY : public Language {
 private:
  char *module;
  char *modvar;
  char *feature;
  int extconf, toplevel;
  String other_extern;
  String other_init;
  char *import_file;

  int current;
  enum {
    NO_CPP,
    MEMBER_FUNC,
    CONSTRUCTOR,
    DESTRUCTOR,
    MEMBER_VAR,
    CLASS_CONST,
    STATIC_FUNC,
    STATIC_VAR
  };

  Hash classes;		// key=cname val=RClass
  RClass *klass;	// Currently processing class
  Hash special_methods;	// Python style special method name table

  char *make_wrapper_name(char *cname);
  char *validate_const_name(char *name);
  char *ruby_typemap_lookup(char *, DataType *, char *, char *, char *, WrapperFunction * = 0);
  char *to_VALUE(DataType *, char *, int = 0);
  char *from_VALUE(DataType *, char *);
 public:
  RUBY();

  // Virtual functions required by the SWIG parser
  void parse_args(int, char *argv[]);
  void parse();
  void create_function(char *, char *, DataType *, ParmList *);
  void link_variable(char *, char *, DataType *);
  void declare_const(char *, char *, DataType *, char *);
  void initialize(void);
  void headers(void);
  void close(void);
  void set_module(char *,char **);
  void create_command(char *, char *, int);

  // C++ language extensions.
  void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
  void cpp_constructor(char *name, char *iname, ParmList *l);
  void cpp_destructor(char *name, char *newname);
  void cpp_open_class(char *classname, char *rname, char *ctype, int strip);
  void cpp_close_class();
  void cpp_inherit(char **baseclass, int mode = INHERIT_ALL);
  void cpp_variable(char *name, char *iname, DataType *t);
  void cpp_static_func(char *name, char *iname, DataType *t, ParmList *l);
  void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
  void cpp_static_var(char *name, char *iname, DataType *t);

  // Declaration of a class, but not a full definition
  void cpp_class_decl(char *, char *, char *);

  // Pragma directive 
  void pragma(char *, char *, char *);

  // Import directive
  void import(char *filename);

};

/*
 * Local Variables:
 * c-basic-offset: 2
 * End:
 */
