89ce98bc70b03f76028f6f683ac35ad6706ce7e0
[com/asn1c.git] / libasn1compiler / asn1c_misc.h
1 #ifndef ASN1_COMPILER_MISC_H
2 #define ASN1_COMPILER_MISC_H
3
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  */
9 enum ami_flags_e {
10         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 */
14 };
15 const char *asn1c_make_identifier(enum ami_flags_e, asn1p_expr_t *expr, ...);
16
17 /*
18  * Return the type name of the specified expression.
19  * 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.
21  */
22 enum tnfmt {
23         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") */
26         TNF_CONSTYPE = 0x40, /* Replace unsafe characters with _ */
27         TNF_SAFE        = 0x50, /* Replace unsafe characters with _ */
28         TNF_RSAFE       = 0x60, /* Recursion-safe C type format */
29 };
30 const char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
31
32 /*
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.
37  *      FL_FITS_SIGNED: It can be represented using signed long.
38  *      FL_FITS_UNSIGN: It can be represented using unsigned long.
39  *      FL_PRESUMED:    Probably can't, but -fwide-types is not in effect.
40  */
41 enum asn1c_fitslong_e {
42         FL_NOTFIT,
43         FL_FITS_SIGNED,
44         FL_FITS_UNSIGN,
45         FL_PRESUMED,
46 };
47 enum asn1c_fitslong_e asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr);
48
49 enum asn1c_fitsfloat_e {
50     RL_NOTFIT,
51     RL_FITS_FLOAT32,
52     RL_FITS_DOUBLE64
53 };
54 enum asn1c_fitsfloat_e asn1c_REAL_fits(arg_t *arg, asn1p_expr_t *expr);
55 const char *asn1c_prefix(void);
56
57 #endif  /* ASN1_COMPILER_MISC_H */