1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/inter/inter-module/Chapter 4/The Version Construct.w

52 lines
1.8 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Inter::Version::] The Version Construct.
Defining the version construct.
@
@e VERSION_IST
=
void Inter::Version::define(void) {
inter_construct *IC = Inter::Defn::create_construct(
VERSION_IST,
L"version (%d+)",
I"version", I"versions");
IC->usage_permissions = OUTSIDE_OF_PACKAGES;
2019-07-09 08:45:46 +03:00
METHOD_ADD(IC, CONSTRUCT_READ_MTID, Inter::Version::read);
METHOD_ADD(IC, CONSTRUCT_VERIFY_MTID, Inter::Version::verify);
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, Inter::Version::write);
2019-02-05 02:44:07 +02:00
}
@
@d NUMBER_VERSION_IFLD 2
@d EXTENT_VERSION_IFR 3
=
2019-07-09 08:45:46 +03:00
void Inter::Version::read(inter_construct *IC, inter_reading_state *IRS, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
*E = Inter::Defn::vet_level(IRS, VERSION_IST, ilp->indent_level, eloc);
if (*E) return;
2019-02-05 02:44:07 +02:00
2019-07-09 08:45:46 +03:00
if (ilp->no_annotations > 0) { *E = Inter::Errors::plain(I"__annotations are not allowed", eloc); return; }
2019-02-05 02:44:07 +02:00
2019-07-09 08:45:46 +03:00
*E = Inter::Version::new(IRS, Str::atoi(ilp->mr.exp[0], 0), (inter_t) ilp->indent_level, eloc);
2019-02-05 02:44:07 +02:00
}
inter_error_message *Inter::Version::new(inter_reading_state *IRS, int V, inter_t level, inter_error_location *eloc) {
inter_frame P = Inter::Frame::fill_1(IRS, VERSION_IST, (inter_t) V, eloc, level);
inter_error_message *E = Inter::Defn::verify_construct(IRS->current_package, P); if (E) return E;
2019-02-05 02:44:07 +02:00
Inter::Frame::insert(P, IRS);
return NULL;
}
void Inter::Version::verify(inter_construct *IC, inter_frame P, inter_package *owner, inter_error_message **E) {
2019-07-09 08:45:46 +03:00
if (P.extent != EXTENT_VERSION_IFR) { *E = Inter::Frame::error(&P, I"extent wrong", NULL); return; }
if (P.data[NUMBER_VERSION_IFLD] < 1) { *E = Inter::Frame::error(&P, I"version out of range", NULL); return; }
2019-02-05 02:44:07 +02:00
}
2019-07-09 08:45:46 +03:00
void Inter::Version::write(inter_construct *IC, OUTPUT_STREAM, inter_frame P, inter_error_message **E) {
2019-02-05 02:44:07 +02:00
WRITE("version %d", P.data[NUMBER_VERSION_IFLD]);
}