2008-10-19 16:12:53 +04:00
|
|
|
%# -*- c -*-
|
|
|
|
/* DO NOT EDIT THIS FILE DIRECTLY */
|
|
|
|
/**********************************************************************
|
|
|
|
|
2008-12-09 10:14:13 +03:00
|
|
|
id.h -
|
2008-10-19 16:12:53 +04:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Sun Oct 19 21:12:51 2008
|
|
|
|
|
|
|
|
Copyright (C) 2007 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
<%
|
2012-12-21 11:38:07 +04:00
|
|
|
defs = File.join(File.dirname(File.dirname(erb.filename)), "defs/id.def")
|
2022-09-08 09:25:05 +03:00
|
|
|
ids = eval(File.read(defs), nil, defs)
|
2012-12-21 11:38:03 +04:00
|
|
|
types = ids.keys.grep(/^[A-Z]/)
|
2008-10-19 16:12:53 +04:00
|
|
|
%>
|
|
|
|
#ifndef RUBY_ID_H
|
|
|
|
#define RUBY_ID_H
|
|
|
|
|
2013-09-20 08:53:08 +04:00
|
|
|
enum ruby_id_types {
|
2014-03-26 08:57:47 +04:00
|
|
|
RUBY_ID_STATIC_SYM = 0x01,
|
2013-09-20 08:53:08 +04:00
|
|
|
RUBY_ID_LOCAL = 0x00,
|
2014-03-26 08:57:47 +04:00
|
|
|
RUBY_ID_INSTANCE = (0x01<<1),
|
|
|
|
RUBY_ID_GLOBAL = (0x03<<1),
|
|
|
|
RUBY_ID_ATTRSET = (0x04<<1),
|
|
|
|
RUBY_ID_CONST = (0x05<<1),
|
|
|
|
RUBY_ID_CLASS = (0x06<<1),
|
|
|
|
RUBY_ID_JUNK = (0x07<<1),
|
2013-09-20 08:53:08 +04:00
|
|
|
RUBY_ID_INTERNAL = RUBY_ID_JUNK,
|
2014-03-26 08:57:47 +04:00
|
|
|
RUBY_ID_SCOPE_SHIFT = 4,
|
|
|
|
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
|
2013-09-20 08:53:08 +04:00
|
|
|
};
|
|
|
|
|
2014-03-26 08:57:47 +04:00
|
|
|
#define ID_STATIC_SYM RUBY_ID_STATIC_SYM
|
2013-09-20 08:53:08 +04:00
|
|
|
#define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
|
|
|
|
#define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
|
|
|
|
#define ID_LOCAL RUBY_ID_LOCAL
|
|
|
|
#define ID_INSTANCE RUBY_ID_INSTANCE
|
|
|
|
#define ID_GLOBAL RUBY_ID_GLOBAL
|
|
|
|
#define ID_ATTRSET RUBY_ID_ATTRSET
|
|
|
|
#define ID_CONST RUBY_ID_CONST
|
|
|
|
#define ID_CLASS RUBY_ID_CLASS
|
|
|
|
#define ID_JUNK RUBY_ID_JUNK
|
|
|
|
#define ID_INTERNAL RUBY_ID_INTERNAL
|
2008-10-19 16:12:53 +04:00
|
|
|
|
|
|
|
#define symIFUNC ID2SYM(idIFUNC)
|
|
|
|
#define symCFUNC ID2SYM(idCFUNC)
|
|
|
|
|
2022-09-08 09:25:05 +03:00
|
|
|
% ids[:token_op].each do |_id, _op, token, index|
|
2015-11-05 07:04:00 +03:00
|
|
|
% next unless token
|
|
|
|
#define RUBY_TOKEN_<%=token%> <%=index%>
|
2012-08-31 09:31:20 +04:00
|
|
|
% end
|
|
|
|
#define RUBY_TOKEN(t) RUBY_TOKEN_##t
|
2008-12-24 23:05:12 +03:00
|
|
|
|
2017-02-11 05:14:06 +03:00
|
|
|
#define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM)
|
|
|
|
% types.each do |type|
|
|
|
|
#define TOKEN2<%=type%>ID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_<%=type%>)
|
|
|
|
% end
|
|
|
|
|
2008-10-19 16:12:53 +04:00
|
|
|
enum ruby_method_ids {
|
2015-11-05 07:04:00 +03:00
|
|
|
% ids[:token_op].uniq {|_, op| op}.each do |id, op, token|
|
|
|
|
id<%=id%> = <%=token ? "RUBY_TOKEN(#{token})" : "'#{op}'"%>,
|
|
|
|
% end
|
2022-09-08 09:25:05 +03:00
|
|
|
tPRESERVED_ID_BEGIN = <%=ids[:last_token]%>,
|
2012-12-21 11:38:03 +04:00
|
|
|
% ids[:preserved].each do |token|
|
2012-08-17 12:35:12 +04:00
|
|
|
id<%=token%>,
|
|
|
|
% end
|
|
|
|
tPRESERVED_ID_END,
|
2023-07-21 08:52:43 +03:00
|
|
|
|
2017-02-11 05:14:06 +03:00
|
|
|
% prev = 'tPRESERVED_ID_END'
|
|
|
|
% types.each do |type|
|
|
|
|
% tokens = ids[type]
|
2023-07-21 08:52:43 +03:00
|
|
|
/* <%= type %> tokens {{{ */
|
2017-02-11 05:14:06 +03:00
|
|
|
tTOKEN_<%=type%>_BEGIN = <%=prev%>-1,
|
|
|
|
% tokens.each do |token|
|
2012-03-14 05:35:06 +04:00
|
|
|
t<%=token%>,
|
2017-02-11 05:14:06 +03:00
|
|
|
% end
|
|
|
|
% prev = "tTOKEN_#{type}_END"
|
|
|
|
<%=prev%>,
|
2023-07-21 08:52:43 +03:00
|
|
|
/* <%= type %> tokens }}} */
|
|
|
|
|
2012-03-14 05:35:06 +04:00
|
|
|
% end
|
2017-02-11 05:14:06 +03:00
|
|
|
tNEXT_ID = <%=prev%>,
|
2023-07-21 08:52:43 +03:00
|
|
|
|
2012-12-21 11:38:03 +04:00
|
|
|
% types.each do |type|
|
2017-02-11 05:14:06 +03:00
|
|
|
% tokens = ids[type]
|
2023-07-21 08:52:43 +03:00
|
|
|
/* <%= type %> IDs {{{ */
|
2017-02-11 05:14:06 +03:00
|
|
|
#define DEFINE_<%=type%>ID_FROM_TOKEN(n) id##n = TOKEN2<%=type%>ID(t##n)
|
|
|
|
% tokens or next
|
|
|
|
% tokens.each do |token|
|
|
|
|
DEFINE_<%=type%>ID_FROM_TOKEN(<%=token%>),
|
2012-12-21 11:38:03 +04:00
|
|
|
% end
|
2023-07-21 08:52:43 +03:00
|
|
|
#undef DEFINE_<%=type%>ID_FROM_TOKEN
|
|
|
|
/* <%= type %> IDs }}} */
|
|
|
|
|
2012-03-14 05:35:06 +04:00
|
|
|
% end
|
2012-08-31 09:31:20 +04:00
|
|
|
tLAST_OP_ID = tPRESERVED_ID_END-1,
|
|
|
|
idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
|
2008-12-24 23:53:06 +03:00
|
|
|
};
|
2008-12-24 23:05:12 +03:00
|
|
|
|
2008-10-19 16:12:53 +04:00
|
|
|
#endif /* RUBY_ID_H */
|