blob: 439a2d091fe01235993dd0b1d1cb47c8539db8cc [file] [log] [blame]
Lev Walkinc6cac8e2016-03-14 02:57:07 -07001#ifndef ASN1_COMPILER_MISC_H
2#define ASN1_COMPILER_MISC_H
Lev Walkinf15320b2004-06-03 03:38:44 +00003
4/*
5 * Make the target language identifier out of one or more names.
6 * The function will concatenate the names and replace unsafe characters
7 * with safe ones.
8 */
Lev Walkin801fabc2005-01-28 12:18:50 +00009enum ami_flags_e {
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080010 AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */
11 AMI_CHECK_RESERVED = 2, /* Check against reserved keywords */
12 AMI_NODELIMITER = 4, /* Do not put delimiter, just concatenate */
13 AMI_USE_PREFIX = 8, /* Use Prefix when generating identifier */
Lev Walkin801fabc2005-01-28 12:18:50 +000014};
Lev Walkinb46156d2017-09-05 02:53:05 -070015const char *asn1c_make_identifier(enum ami_flags_e, asn1p_expr_t *expr, ...);
Lev Walkinf15320b2004-06-03 03:38:44 +000016
17/*
18 * Return the type name of the specified expression.
Lev Walkincf3f6eb2017-08-23 04:34:15 -070019 * The returned string is a pointer to a statically allocated buffer which is
20 * going to be clobbered by the subsequent invocation of this function.
Lev Walkinf15320b2004-06-03 03:38:44 +000021 */
22enum tnfmt {
Lev Walkin801fabc2005-01-28 12:18:50 +000023 TNF_UNMODIFIED = 0x10, /* Return unmodified type name */
24 TNF_INCLUDE = 0x20, /* Format for #include <> */
25 TNF_CTYPE = 0x30, /* Format as normal C-ish type (append "_t") */
Lev Walkinb5450702017-10-04 02:52:57 -070026 TNF_CONSTYPE = 0x40, /* Replace unsafe characters with _ */
27 TNF_SAFE = 0x50, /* Replace unsafe characters with _ */
28 TNF_RSAFE = 0x60, /* Recursion-safe C type format */
Lev Walkinf15320b2004-06-03 03:38:44 +000029};
Lev Walkincf3f6eb2017-08-23 04:34:15 -070030const char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
Lev Walkinf15320b2004-06-03 03:38:44 +000031
Lev Walkin082cadc2005-08-14 02:18:27 +000032/*
33 * Check whether the specified INTEGER or ENUMERATED type can be represented
34 * using the generic 'long' type.
35 * Return values:
36 * FL_NOTFIT: No, it cannot be represented using long.
Lev Walkin8bb57a22007-12-03 13:41:36 +000037 * FL_FITS_SIGNED: It can be represented using signed long.
38 * FL_FITS_UNSIGN: It can be represented using unsigned long.
Lev Walkin2a744a72013-03-27 01:56:23 -070039 * FL_PRESUMED: Probably can't, but -fwide-types is not in effect.
Lev Walkin082cadc2005-08-14 02:18:27 +000040 */
41enum asn1c_fitslong_e {
42 FL_NOTFIT,
Lev Walkin8bb57a22007-12-03 13:41:36 +000043 FL_FITS_SIGNED,
44 FL_FITS_UNSIGN,
Lev Walkin2a744a72013-03-27 01:56:23 -070045 FL_PRESUMED,
Lev Walkin082cadc2005-08-14 02:18:27 +000046};
47enum asn1c_fitslong_e asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr);
48
Lev Walkin43292722017-10-05 00:33:32 -070049enum asn1c_fitsfloat_e {
50 RL_NOTFIT,
51 RL_FITS_FLOAT32,
52 RL_FITS_DOUBLE64
53};
54enum asn1c_fitsfloat_e asn1c_REAL_fits(arg_t *arg, asn1p_expr_t *expr);
55
Lev Walkinc6cac8e2016-03-14 02:57:07 -070056#endif /* ASN1_COMPILER_MISC_H */