2002-05-08 21:24:24 +00:00
|
|
|
/*
|
2002-10-22 14:53:18 +00:00
|
|
|
class.h
|
2002-05-08 21:24:24 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
QC class support code
|
2002-05-08 21:24:24 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Copyright (C) 2002 Bill Currie <bill@taniwha.org>
|
2002-05-08 21:24:24 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2002/05/08
|
2002-05-08 21:24:24 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __class_h
|
|
|
|
#define __class_h
|
|
|
|
|
2010-12-31 06:44:54 +00:00
|
|
|
typedef enum {
|
|
|
|
ct_class,
|
|
|
|
ct_category,
|
|
|
|
ct_protocol,
|
|
|
|
} ct_type_t;
|
|
|
|
|
2002-11-14 18:17:43 +00:00
|
|
|
typedef struct class_type_s {
|
2010-12-31 06:44:54 +00:00
|
|
|
ct_type_t type;
|
2002-11-14 18:17:43 +00:00
|
|
|
union {
|
|
|
|
struct category_s *category;
|
|
|
|
struct class_s *class;
|
2010-12-31 06:44:54 +00:00
|
|
|
struct protocol_s *protocol;
|
2002-11-14 18:17:43 +00:00
|
|
|
} c;
|
|
|
|
} class_type_t;
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
typedef struct class_s {
|
2002-05-10 00:00:23 +00:00
|
|
|
int defined;
|
2020-03-05 06:39:34 +00:00
|
|
|
int interface_declared;
|
2002-11-12 19:52:43 +00:00
|
|
|
const char *name;
|
2002-05-15 19:10:23 +00:00
|
|
|
struct class_s *super_class;
|
2002-11-12 19:52:43 +00:00
|
|
|
struct category_s *categories;
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symtab_s *ivars;
|
2002-05-15 19:10:23 +00:00
|
|
|
struct methodlist_s *methods;
|
|
|
|
struct protocollist_s *protocols;
|
2002-05-15 23:24:19 +00:00
|
|
|
struct def_s *def;
|
2002-05-16 20:20:23 +00:00
|
|
|
struct type_s *type;
|
2002-11-14 18:17:43 +00:00
|
|
|
class_type_t class_type;
|
2002-05-08 21:24:24 +00:00
|
|
|
} class_t;
|
|
|
|
|
2002-11-12 19:52:43 +00:00
|
|
|
typedef struct category_s {
|
|
|
|
struct category_s *next;
|
|
|
|
const char *name;
|
|
|
|
class_t *class;
|
2002-11-14 18:17:43 +00:00
|
|
|
int defined;
|
2002-11-12 19:52:43 +00:00
|
|
|
struct methodlist_s *methods;
|
|
|
|
struct protocollist_s *protocols;
|
2002-11-14 18:17:43 +00:00
|
|
|
struct def_s *def;
|
|
|
|
class_type_t class_type;
|
2002-11-12 19:52:43 +00:00
|
|
|
} category_t;
|
|
|
|
|
2004-11-11 00:34:00 +00:00
|
|
|
typedef struct protocol_s {
|
|
|
|
const char *name;
|
|
|
|
struct methodlist_s *methods;
|
|
|
|
struct protocollist_s *protocols;
|
2020-03-02 01:42:26 +00:00
|
|
|
struct def_s *def;
|
2010-12-31 06:44:54 +00:00
|
|
|
class_type_t class_type;
|
2004-11-11 00:34:00 +00:00
|
|
|
} protocol_t;
|
|
|
|
|
|
|
|
typedef struct protocollist_s {
|
|
|
|
int count;
|
|
|
|
protocol_t **list;
|
|
|
|
} protocollist_t;
|
|
|
|
|
2020-03-02 01:48:51 +00:00
|
|
|
typedef struct static_instance_s {
|
|
|
|
const char *class;
|
|
|
|
struct def_s *instance;
|
|
|
|
} static_instance_t;
|
|
|
|
|
2011-02-04 03:07:32 +00:00
|
|
|
extern struct type_s type_id;
|
2020-03-27 06:33:53 +00:00
|
|
|
extern struct type_s type_object;
|
|
|
|
extern struct type_s type_class;
|
2011-02-04 03:07:32 +00:00
|
|
|
extern struct type_s type_Class;
|
2020-03-27 06:33:53 +00:00
|
|
|
extern struct type_s type_protocol;
|
2022-01-19 15:42:29 +00:00
|
|
|
extern struct type_s type_selector;
|
2011-02-04 03:07:32 +00:00
|
|
|
extern struct type_s type_SEL;
|
|
|
|
extern struct type_s type_IMP;
|
|
|
|
extern struct type_s type_supermsg;
|
2020-03-27 06:33:53 +00:00
|
|
|
extern struct type_s type_exec_class;
|
|
|
|
extern struct type_s type_method;
|
|
|
|
extern struct type_s type_super;
|
|
|
|
extern struct type_s type_method_description;
|
|
|
|
extern struct type_s type_category;
|
2011-02-04 03:07:32 +00:00
|
|
|
extern struct type_s type_ivar;
|
|
|
|
extern struct type_s type_module;
|
|
|
|
|
2002-11-14 18:17:43 +00:00
|
|
|
extern class_type_t *current_class;
|
2002-05-17 19:35:26 +00:00
|
|
|
|
2012-11-08 07:46:48 +00:00
|
|
|
extern int obj_initialized;
|
|
|
|
|
2012-12-18 11:45:48 +00:00
|
|
|
struct dstring_s;
|
2002-05-16 20:20:23 +00:00
|
|
|
struct expr_s;
|
2002-05-15 23:24:19 +00:00
|
|
|
struct method_s;
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symbol_s;
|
2020-03-15 14:30:57 +00:00
|
|
|
struct selector_s;
|
2002-05-08 21:24:24 +00:00
|
|
|
|
2020-03-27 06:16:41 +00:00
|
|
|
int is_id (const struct type_s *type) __attribute__((pure));
|
|
|
|
int is_class (const struct type_s *type) __attribute__((pure));
|
2022-07-26 12:14:28 +00:00
|
|
|
int is_Class (const struct type_s *type) __attribute__((pure));
|
2020-03-27 06:16:41 +00:00
|
|
|
int is_classptr (const struct type_s *type) __attribute__((pure));
|
2022-07-26 12:14:28 +00:00
|
|
|
int is_SEL (const struct type_s *type) __attribute__((pure));
|
2020-04-01 12:17:13 +00:00
|
|
|
int is_object (const struct type_s *type) __attribute__((const));
|
|
|
|
int is_method (const struct type_s *type) __attribute__((const));
|
|
|
|
int is_method_description (const struct type_s *type) __attribute__((const));
|
2012-12-19 02:53:19 +00:00
|
|
|
int obj_types_assignable (const struct type_s *dst, const struct type_s *src);
|
2012-12-18 11:56:23 +00:00
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
class_t *extract_class (class_type_t *class_type) __attribute__((pure));
|
2010-12-31 06:44:54 +00:00
|
|
|
const char *get_class_name (class_type_t *class_type, int pretty);
|
2011-01-24 06:41:43 +00:00
|
|
|
struct symbol_s *class_symbol (class_type_t *class_type, int external);
|
2002-05-22 01:39:07 +00:00
|
|
|
void class_init (void);
|
2011-01-17 13:33:33 +00:00
|
|
|
class_t *get_class (struct symbol_s *sym, int create);
|
2002-05-10 00:00:23 +00:00
|
|
|
void class_add_methods (class_t *class, struct methodlist_s *methods);
|
2004-11-11 00:34:00 +00:00
|
|
|
void class_add_protocols (class_t *class, protocollist_t *protocols);
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symtab_s *class_new_ivars (class_t *class);
|
|
|
|
void class_add_ivars (class_t *class, struct symtab_s *ivars);
|
|
|
|
void class_check_ivars (class_t *class, struct symtab_s *ivars);
|
2002-11-14 18:17:43 +00:00
|
|
|
void class_begin (class_type_t *class_type);
|
|
|
|
void class_finish (class_type_t *class_type);
|
2018-10-09 03:35:01 +00:00
|
|
|
int class_access (class_type_t *current_class, class_t *class) __attribute__((pure));
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symbol_s *class_find_ivar (class_t *class, int vis, const char *name);
|
2011-02-06 23:32:52 +00:00
|
|
|
struct symtab_s *class_ivar_scope (class_type_t *class_type,
|
|
|
|
struct symtab_s *parent);
|
|
|
|
void class_finish_ivar_scope (class_type_t *class_type,
|
|
|
|
struct symtab_s *ivar_scope,
|
|
|
|
struct symtab_s *param_scope);
|
2002-11-14 18:17:43 +00:00
|
|
|
struct method_s *class_find_method (class_type_t *class_type,
|
|
|
|
struct method_s *method);
|
2020-03-15 14:30:57 +00:00
|
|
|
struct method_s *class_message_response (struct type_s *clstype, int class_msg,
|
2003-07-27 21:33:05 +00:00
|
|
|
struct expr_s *sel);
|
2011-02-06 05:33:52 +00:00
|
|
|
struct symbol_s *class_pointer_symbol (class_t *class_type);
|
2011-01-17 13:33:33 +00:00
|
|
|
category_t *get_category (struct symbol_s *class_name,
|
|
|
|
const char *category_name, int create);
|
2002-11-14 18:17:43 +00:00
|
|
|
void category_add_methods (category_t *category, struct methodlist_s *methods);
|
2004-11-11 00:34:00 +00:00
|
|
|
void category_add_protocols (category_t *category, protocollist_t *protocols);
|
2002-05-21 21:28:40 +00:00
|
|
|
void class_finish_module (void);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symtab_s *class_to_struct (class_t *class, struct symtab_s *symtab);
|
2010-12-12 11:27:56 +00:00
|
|
|
void emit_class_ref (const char *class_name);
|
|
|
|
void emit_category_ref (const char *class_name, const char *category_name);
|
2003-08-20 19:58:41 +00:00
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
protocol_t *get_protocol (const char *name, int create);
|
|
|
|
void protocol_add_methods (protocol_t *protocol, struct methodlist_s *methods);
|
2004-11-11 00:34:00 +00:00
|
|
|
void protocol_add_protocols (protocol_t *protocol, protocollist_t *protocols);
|
2002-05-10 00:00:23 +00:00
|
|
|
struct def_s *protocol_def (protocol_t *protocol);
|
2004-11-11 00:34:00 +00:00
|
|
|
protocollist_t *new_protocol_list (void);
|
|
|
|
protocollist_t *add_protocol (protocollist_t *protocollist, const char *name);
|
2018-10-09 03:35:01 +00:00
|
|
|
int procollist_find_protocol (protocollist_t *protocollist, protocol_t *proto) __attribute__((pure));
|
2020-03-15 14:30:57 +00:00
|
|
|
struct method_s *protocollist_find_method (protocollist_t *protocollist,
|
|
|
|
struct selector_s *selector,
|
|
|
|
int nstance)
|
|
|
|
__attribute__((pure));
|
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
int compare_protocols (protocollist_t *protos1, protocollist_t *protos2) __attribute__((pure));
|
2012-12-18 11:45:48 +00:00
|
|
|
void print_protocollist (struct dstring_s *dstr, protocollist_t *protocollist);
|
2002-07-13 06:09:03 +00:00
|
|
|
struct def_s *emit_protocol (protocol_t *protocol);
|
|
|
|
struct def_s *emit_protocol_list (protocollist_t *protocols, const char *name);
|
2002-05-15 23:24:19 +00:00
|
|
|
|
2002-06-28 16:00:01 +00:00
|
|
|
void clear_classes (void);
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
#endif//__class_h
|