summaryrefslogtreecommitdiff
path: root/internal/cmdlineopt.h
blob: adc76fc2e4034c5fa6dfe7827b5a9196321cf557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef INTERNAL_CMDLINEOPT_H                               /*-*-C-*-vi:se ft=c:*/
#define INTERNAL_CMDLINEOPT_H

#include "mjit.h"
#include "yjit.h"

typedef struct {
    unsigned int mask;
    unsigned int set;
} ruby_features_t;

typedef struct ruby_cmdline_options {
    const char *script;
    VALUE script_name;
    VALUE e_script;
    struct {
        struct {
            VALUE name;
            int index;
        } enc;
    } src, ext, intern;
    VALUE req_list;
    ruby_features_t features;
    ruby_features_t warn;
    unsigned int dump;
#if USE_MJIT
    struct mjit_options mjit;
#endif
#if YJIT_SUPPORTED_P
    struct rb_yjit_options yjit;
#endif

    int sflag, xflag;
    unsigned int warning: 1;
    unsigned int verbose: 1;
    unsigned int do_loop: 1;
    unsigned int do_print: 1;
    unsigned int do_line: 1;
    unsigned int do_split: 1;
    unsigned int do_search: 1;
    unsigned int setids: 2;
} ruby_cmdline_options_t;

struct ruby_opt_message {
    const char *str;
    unsigned short namelen, secondlen;
};

#define RUBY_OPT_MESSAGE(shortopt, longopt, desc) { \
    shortopt " " longopt " " desc, \
    (unsigned short)sizeof(shortopt), \
    (unsigned short)sizeof(longopt), \
}

#define opt_match(s, l, name) \
    ((((l) > rb_strlen_lit(name)) ? (s)[rb_strlen_lit(name)] == '=' : \
      (l) == rb_strlen_lit(name)) && \
     memcmp((s), name, rb_strlen_lit(name)) == 0 && \
     (((s) += rb_strlen_lit(name)), 1))

#endif