Move enum definitions out of struct definition
This commit is contained in:
parent
c7fd015d83
commit
e763b1118b
Notes:
git
2022-07-22 23:10:46 +09:00
@ -98,6 +98,34 @@ PACKED_STRUCT_UNALIGNED(struct rb_io_buffer_t {
|
||||
/** @alias{rb_io_buffer_t} */
|
||||
typedef struct rb_io_buffer_t rb_io_buffer_t;
|
||||
|
||||
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */
|
||||
/*
|
||||
* enc enc2 read action write action
|
||||
* NULL NULL force_encoding(default_external) write the byte sequence of str
|
||||
* e1 NULL force_encoding(e1) convert str.encoding to e1
|
||||
* e1 e2 convert from e2 to e1 convert str.encoding to e2
|
||||
*/
|
||||
struct rb_io_enc_t {
|
||||
/** Internal encoding. */
|
||||
rb_encoding *enc;
|
||||
/** External encoding. */
|
||||
rb_encoding *enc2;
|
||||
/**
|
||||
* Flags.
|
||||
*
|
||||
* @see enum ::ruby_econv_flag_type
|
||||
*/
|
||||
int ecflags;
|
||||
/**
|
||||
* Flags as Ruby hash.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* This is set. But used from nowhere maybe?
|
||||
*/
|
||||
VALUE ecopts;
|
||||
};
|
||||
|
||||
/** Ruby's IO, metadata and buffers. */
|
||||
typedef struct rb_io_t {
|
||||
|
||||
@ -141,36 +169,7 @@ typedef struct rb_io_t {
|
||||
*/
|
||||
VALUE tied_io_for_writing;
|
||||
|
||||
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */
|
||||
/*
|
||||
* enc enc2 read action write action
|
||||
* NULL NULL force_encoding(default_external) write the byte sequence of str
|
||||
* e1 NULL force_encoding(e1) convert str.encoding to e1
|
||||
* e1 e2 convert from e2 to e1 convert str.encoding to e2
|
||||
*/
|
||||
struct rb_io_enc_t {
|
||||
/** Internal encoding. */
|
||||
rb_encoding *enc;
|
||||
|
||||
/** External encoding. */
|
||||
rb_encoding *enc2;
|
||||
|
||||
/**
|
||||
* Flags.
|
||||
*
|
||||
* @see enum ::ruby_econv_flag_type
|
||||
*/
|
||||
int ecflags;
|
||||
|
||||
/**
|
||||
* Flags as Ruby hash.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* This is set. But used from nowhere maybe?
|
||||
*/
|
||||
VALUE ecopts;
|
||||
} encs; /**< Decomposed encoding flags. */
|
||||
struct rb_io_enc_t encs; /**< Decomposed encoding flags. */
|
||||
|
||||
/** Encoding converter used when reading from this IO. */
|
||||
rb_econv_t *readconv;
|
||||
|
43
iseq.h
43
iseq.h
@ -241,28 +241,29 @@ struct iseq_insn_info_entry {
|
||||
rb_event_flag_t events;
|
||||
};
|
||||
|
||||
struct iseq_catch_table_entry {
|
||||
enum catch_type {
|
||||
CATCH_TYPE_RESCUE = INT2FIX(1),
|
||||
CATCH_TYPE_ENSURE = INT2FIX(2),
|
||||
CATCH_TYPE_RETRY = INT2FIX(3),
|
||||
CATCH_TYPE_BREAK = INT2FIX(4),
|
||||
CATCH_TYPE_REDO = INT2FIX(5),
|
||||
CATCH_TYPE_NEXT = INT2FIX(6)
|
||||
} type;
|
||||
/*
|
||||
* iseq type:
|
||||
* CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
|
||||
* use iseq as continuation.
|
||||
*
|
||||
* CATCH_TYPE_BREAK (iter):
|
||||
* use iseq as key.
|
||||
*
|
||||
* CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
|
||||
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
||||
* NULL.
|
||||
*/
|
||||
enum catch_type {
|
||||
CATCH_TYPE_RESCUE = INT2FIX(1),
|
||||
CATCH_TYPE_ENSURE = INT2FIX(2),
|
||||
CATCH_TYPE_RETRY = INT2FIX(3),
|
||||
CATCH_TYPE_BREAK = INT2FIX(4),
|
||||
CATCH_TYPE_REDO = INT2FIX(5),
|
||||
CATCH_TYPE_NEXT = INT2FIX(6)
|
||||
};
|
||||
|
||||
/*
|
||||
* iseq type:
|
||||
* CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
|
||||
* use iseq as continuation.
|
||||
*
|
||||
* CATCH_TYPE_BREAK (iter):
|
||||
* use iseq as key.
|
||||
*
|
||||
* CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
|
||||
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
||||
* NULL.
|
||||
*/
|
||||
struct iseq_catch_table_entry {
|
||||
enum catch_type type;
|
||||
rb_iseq_t *iseq;
|
||||
|
||||
unsigned int start;
|
||||
|
@ -40,6 +40,24 @@ struct rb_ractor_waiting_list {
|
||||
rb_ractor_t **ractors;
|
||||
};
|
||||
|
||||
enum ractor_wait_status {
|
||||
wait_none = 0x00,
|
||||
wait_receiving = 0x01,
|
||||
wait_taking = 0x02,
|
||||
wait_yielding = 0x04,
|
||||
wait_moving = 0x08,
|
||||
};
|
||||
|
||||
enum ractor_wakeup_status {
|
||||
wakeup_none,
|
||||
wakeup_by_send,
|
||||
wakeup_by_yield,
|
||||
wakeup_by_take,
|
||||
wakeup_by_close,
|
||||
wakeup_by_interrupt,
|
||||
wakeup_by_retry,
|
||||
};
|
||||
|
||||
struct rb_ractor_sync {
|
||||
// ractor lock
|
||||
rb_nativethread_lock_t lock;
|
||||
@ -56,29 +74,34 @@ struct rb_ractor_sync {
|
||||
bool outgoing_port_closed;
|
||||
|
||||
struct ractor_wait {
|
||||
enum ractor_wait_status {
|
||||
wait_none = 0x00,
|
||||
wait_receiving = 0x01,
|
||||
wait_taking = 0x02,
|
||||
wait_yielding = 0x04,
|
||||
wait_moving = 0x08,
|
||||
} status;
|
||||
|
||||
enum ractor_wakeup_status {
|
||||
wakeup_none,
|
||||
wakeup_by_send,
|
||||
wakeup_by_yield,
|
||||
wakeup_by_take,
|
||||
wakeup_by_close,
|
||||
wakeup_by_interrupt,
|
||||
wakeup_by_retry,
|
||||
} wakeup_status;
|
||||
|
||||
enum ractor_wait_status status;
|
||||
enum ractor_wakeup_status wakeup_status;
|
||||
struct rb_ractor_basket yielded_basket;
|
||||
struct rb_ractor_basket taken_basket;
|
||||
} wait;
|
||||
};
|
||||
|
||||
// created
|
||||
// | ready to run
|
||||
// ====================== inserted to vm->ractor
|
||||
// v
|
||||
// blocking <---+ all threads are blocking
|
||||
// | |
|
||||
// v |
|
||||
// running -----+
|
||||
// | all threads are terminated.
|
||||
// ====================== removed from vm->ractor
|
||||
// v
|
||||
// terminated
|
||||
//
|
||||
// status is protected by VM lock (global state)
|
||||
enum ractor_status {
|
||||
ractor_created,
|
||||
ractor_running,
|
||||
ractor_blocking,
|
||||
ractor_terminated,
|
||||
};
|
||||
|
||||
struct rb_ractor_struct {
|
||||
struct rb_ractor_pub pub;
|
||||
|
||||
@ -104,27 +127,7 @@ struct rb_ractor_struct {
|
||||
VALUE name;
|
||||
VALUE loc;
|
||||
|
||||
// created
|
||||
// | ready to run
|
||||
// ====================== inserted to vm->ractor
|
||||
// v
|
||||
// blocking <---+ all threads are blocking
|
||||
// | |
|
||||
// v |
|
||||
// running -----+
|
||||
// | all threads are terminated.
|
||||
// ====================== removed from vm->ractor
|
||||
// v
|
||||
// terminated
|
||||
//
|
||||
// status is protected by VM lock (global state)
|
||||
|
||||
enum ractor_status {
|
||||
ractor_created,
|
||||
ractor_running,
|
||||
ractor_blocking,
|
||||
ractor_terminated,
|
||||
} status_;
|
||||
enum ractor_status status_;
|
||||
|
||||
struct ccan_list_node vmlr_node;
|
||||
|
||||
|
25
vm_core.h
25
vm_core.h
@ -339,18 +339,21 @@ typedef uintptr_t iseq_bits_t;
|
||||
|
||||
#define ISEQ_IS_SIZE(body) (body->ic_size + body->ivc_size + body->ise_size + body->icvarc_size)
|
||||
|
||||
/* instruction sequence type */
|
||||
enum iseq_type {
|
||||
ISEQ_TYPE_TOP,
|
||||
ISEQ_TYPE_METHOD,
|
||||
ISEQ_TYPE_BLOCK,
|
||||
ISEQ_TYPE_CLASS,
|
||||
ISEQ_TYPE_RESCUE,
|
||||
ISEQ_TYPE_ENSURE,
|
||||
ISEQ_TYPE_EVAL,
|
||||
ISEQ_TYPE_MAIN,
|
||||
ISEQ_TYPE_PLAIN
|
||||
};
|
||||
|
||||
struct rb_iseq_constant_body {
|
||||
enum iseq_type {
|
||||
ISEQ_TYPE_TOP,
|
||||
ISEQ_TYPE_METHOD,
|
||||
ISEQ_TYPE_BLOCK,
|
||||
ISEQ_TYPE_CLASS,
|
||||
ISEQ_TYPE_RESCUE,
|
||||
ISEQ_TYPE_ENSURE,
|
||||
ISEQ_TYPE_EVAL,
|
||||
ISEQ_TYPE_MAIN,
|
||||
ISEQ_TYPE_PLAIN
|
||||
} type; /* instruction sequence type */
|
||||
enum iseq_type type;
|
||||
|
||||
unsigned int iseq_size;
|
||||
VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user