mirror of
https://github.com/ganelson/inform.git
synced 2024-06-26 04:00:43 +03:00
Began migrating extension version numbers to inbuild
This commit is contained in:
parent
70280f6be0
commit
5b5e6ccf47
|
@ -61,6 +61,7 @@ void InbuildModule::start(void) {
|
|||
;
|
||||
|
||||
@<Register this module's stream writers@> =
|
||||
Writers::register_writer('v', &VersionNumbers::writer);
|
||||
Writers::register_writer('X', &Works::writer);
|
||||
|
||||
@
|
||||
|
|
|
@ -28,6 +28,19 @@ inbuild_version_number VersionNumbers::null(void) {
|
|||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
inbuild_version_number VersionNumbers::from_major(int major) {
|
||||
inbuild_version_number V = VersionNumbers::null();
|
||||
V.version_numbers[0] = major;
|
||||
return V;
|
||||
}
|
||||
|
||||
inbuild_version_number VersionNumbers::from_pair(int major, int minor) {
|
||||
inbuild_version_number V = VersionNumbers::null();
|
||||
V.version_numbers[0] = major;
|
||||
V.version_numbers[1] = minor;
|
||||
return V;
|
||||
}
|
||||
|
||||
int VersionNumbers::is_null(inbuild_version_number V) {
|
||||
for (int i=0, allow=TRUE; i<VERSION_NUMBER_DEPTH; i++) {
|
||||
if (V.version_numbers[i] < -1)
|
||||
|
@ -52,6 +65,11 @@ void VersionNumbers::to_text(OUTPUT_STREAM, inbuild_version_number V) {
|
|||
}
|
||||
}
|
||||
|
||||
void VersionNumbers::writer(OUTPUT_STREAM, char *format_string, void *vE) {
|
||||
inbuild_version_number *V = (inbuild_version_number *) vE;
|
||||
VersionNumbers::to_text(OUT, *V);
|
||||
}
|
||||
|
||||
inbuild_version_number VersionNumbers::from_text(text_stream *T) {
|
||||
inbuild_version_number V;
|
||||
int component = 0, val = -1;
|
||||
|
|
|
@ -209,12 +209,13 @@ indeed, the typical number will be 0 or 1.
|
|||
|
||||
Works are entered into the database with one of the following contexts:
|
||||
|
||||
@d NO_WDB_CONTEXTS 5
|
||||
@d NO_WDB_CONTEXTS 6
|
||||
@d LOADED_WDBC 0
|
||||
@d INSTALLED_WDBC 1
|
||||
@d DICTIONARY_REFERRED_WDBC 2
|
||||
@d HYPOTHETICAL_WDBC 3
|
||||
@d USEWITH_WDBC 4
|
||||
@d CLAIMED_WDBC 5
|
||||
|
||||
=
|
||||
typedef struct inbuild_work_database_entry {
|
||||
|
|
|
@ -19,6 +19,8 @@ inbuild_copy *Extensions::claim(text_stream *arg, text_stream *ext, int director
|
|||
if (directory_status == TRUE) return NULL;
|
||||
if (Str::eq_insensitive(ext, I"i7x")) {
|
||||
// eventually load into a copy here
|
||||
|
||||
// Works::add_to_database(...->work, CLAIMED_WDBC);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -21,6 +21,7 @@ inbuild_copy *Kits::claim(text_stream *arg, text_stream *ext, int directory_stat
|
|||
(Str::get_at(arg, kitpos+2) == 't')) {
|
||||
pathname *P = Pathnames::from_text(arg);
|
||||
inform_kit *K = Kits::load_at(Pathnames::directory_name(P), P);
|
||||
Works::add_to_database(K->as_copy->edition->work, CLAIMED_WDBC);
|
||||
return K->as_copy;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
sound name <= value, word value, enumerated value, sayable value
|
||||
topic <= value, word value
|
||||
natural language <= value, word value, enumerated value, sayable value
|
||||
grammatical tense <= value, word value, enumerated value, sayable value
|
||||
narrative viewpoint <= value, word value, enumerated value, sayable value
|
||||
grammatical case <= value, word value, enumerated value, sayable value
|
||||
grammatical gender <= value, word value, enumerated value, sayable value
|
||||
room <= value, word value, sayable value, object
|
||||
thing <= value, word value, sayable value, object
|
||||
direction <= value, word value, sayable value, object
|
||||
|
@ -65,10 +69,6 @@
|
|||
vehicle <= value, word value, sayable value, object, thing, container
|
||||
player's holdall <= value, word value, sayable value, object, thing, container
|
||||
command parser error <= value, word value, enumerated value, sayable value
|
||||
grammatical tense <= value, word value, enumerated value, sayable value
|
||||
narrative viewpoint <= value, word value, enumerated value, sayable value
|
||||
grammatical case <= value, word value, enumerated value, sayable value
|
||||
grammatical gender <= value, word value, enumerated value, sayable value
|
||||
|
||||
2. 2
|
||||
The (always) compatibility relation on (base) kinds, where it differs from <=:
|
||||
|
@ -123,6 +123,10 @@
|
|||
sound name ->
|
||||
topic ->
|
||||
natural language ->
|
||||
grammatical tense ->
|
||||
narrative viewpoint ->
|
||||
grammatical case ->
|
||||
grammatical gender ->
|
||||
room -> object ->
|
||||
thing -> object ->
|
||||
direction -> object ->
|
||||
|
@ -139,10 +143,6 @@
|
|||
vehicle -> container -> thing -> object ->
|
||||
player's holdall -> container -> thing -> object ->
|
||||
command parser error ->
|
||||
grammatical tense ->
|
||||
narrative viewpoint ->
|
||||
grammatical case ->
|
||||
grammatical gender ->
|
||||
|
||||
4. 4
|
||||
Looking for partially ordered set violations.
|
||||
|
|
|
@ -264,7 +264,7 @@ source_file *Extensions::Files::get_corresponding_source_file(extension_file *ef
|
|||
|
||||
=
|
||||
inbuild_work *Extensions::Files::get_work(extension_file *ef) {
|
||||
return ef->ef_work;
|
||||
return (ef)?(ef->ef_work):NULL;
|
||||
}
|
||||
|
||||
@ A few problem messages need the version number loaded, so:
|
||||
|
@ -342,10 +342,10 @@ check that they have been met.
|
|||
void Extensions::Files::check_versions(void) {
|
||||
extension_file *ef;
|
||||
LOOP_OVER(ef, extension_file) {
|
||||
int have = Extensions::Inclusion::parse_version(ef->version_loaded),
|
||||
inbuild_version_number have = Extensions::Inclusion::parse_version(ef->version_loaded),
|
||||
need = Extensions::Inclusion::parse_version(ef->min_version_needed);
|
||||
if (need > have) {
|
||||
LOG("Need %d, have %d\n", need, have);
|
||||
if (VersionNumbers::gt(need, have)) {
|
||||
LOG("Need %v, have %v\n", &need, &have);
|
||||
current_sentence = ef->inclusion_sentence;
|
||||
Problems::quote_source(1, current_sentence);
|
||||
Problems::quote_extension(2, ef);
|
||||
|
|
|
@ -163,8 +163,9 @@ then we need to note that the version requirement on PS has been raised to 3.
|
|||
can't know at load time what we will ultimately require.)
|
||||
|
||||
@<This is an extension already loaded, so note any version number hike and return@> =
|
||||
if (Extensions::Inclusion::parse_version(ef->min_version_needed) <
|
||||
Extensions::Inclusion::parse_version(version_word)) {
|
||||
if (VersionNumbers::lt(
|
||||
Extensions::Inclusion::parse_version(ef->min_version_needed),
|
||||
Extensions::Inclusion::parse_version(version_word))) {
|
||||
ef->min_version_needed = version_word;
|
||||
ef->inclusion_sentence = current_sentence;
|
||||
}
|
||||
|
@ -261,10 +262,10 @@ it seems cleaner to constrain the number of digits than the value.
|
|||
@d MAX_VERSION_NUMBER_LENGTH 10 /* for |999/991231| */
|
||||
|
||||
=
|
||||
int Extensions::Inclusion::parse_version(int vwn) {
|
||||
int i, rv, slashes = 0, digits = 0, slash_at = 0;
|
||||
inbuild_version_number Extensions::Inclusion::parse_version(int vwn) {
|
||||
int i, slashes = 0, digits = 0, slash_at = 0;
|
||||
wchar_t *p, *q;
|
||||
if (vwn == -1) return 0; /* an unspecified version equates to |0/000000| */
|
||||
if (vwn == -1) return VersionNumbers::from_pair(0, 0); /* an unspecified version equates to |0/000000| */
|
||||
p = Lexer::word_text(vwn); q = p;
|
||||
for (i=0; p[i] != 0; i++)
|
||||
if (p[i] == '/') {
|
||||
|
@ -277,15 +278,15 @@ int Extensions::Inclusion::parse_version(int vwn) {
|
|||
if ((p[0] == '0') || (digits == 0)) goto Malformed;
|
||||
|
||||
if ((slashes == 0) && (digits <= 3)) /* so that |p| points to 1 to 3 digits, not starting with |0| */
|
||||
return Wide::atoi(p)*1000000;
|
||||
return VersionNumbers::from_pair(Wide::atoi(p), 0);
|
||||
p[slash_at] = 0; /* temporarily replace the slash with a null, making |p| and |q| distinct C strings */
|
||||
if (Wide::len(p) > 3) goto Malformed; /* now |p| points to 1 to 3 digits, not starting with |0| */
|
||||
if (Wide::len(q) != 6) goto Malformed;
|
||||
while (*q == '0') q++; /* now |q| points to 0 to 6 digits, not starting with |0| */
|
||||
if (q[0] == 0) q--; /* if it was 0 digits, backspace to make it a single digit |0| */
|
||||
rv = (Wide::atoi(p)*1000000) + Wide::atoi(q);
|
||||
inbuild_version_number V = VersionNumbers::from_pair(Wide::atoi(p), Wide::atoi(q));
|
||||
p[slash_at] = '/'; /* put the slash back over the null byte temporarily dividing the string */
|
||||
return rv;
|
||||
return V;
|
||||
|
||||
Malformed: @<Issue a problem message for a malformed version number@>;
|
||||
}
|
||||
|
@ -303,7 +304,7 @@ number text.
|
|||
"(The DDDDDD part is optional, so '3' is a legal version number too. "
|
||||
"N must be between 1 and 999: in particular, there is no version 0.)");
|
||||
Vocabulary::change_text_of_word(vwn, L"1");
|
||||
return 1000000; /* which equates to |1/000000| */
|
||||
return VersionNumbers::from_pair(1, 0); /* which equates to |1/000000| */
|
||||
|
||||
@h Checking the begins here and ends here sentences.
|
||||
When a newly loaded extension is being sentence-broken, problem messages
|
||||
|
|
|
@ -90,6 +90,7 @@ INBUILDX = inbuild/Tangled/inbuild
|
|||
{dep} INFORM7 on INTER
|
||||
{dep} INFORM7 on BUILDING
|
||||
{dep} INFORM7 on CODEGEN
|
||||
{dep} INFORM7 on INBUILD
|
||||
|
||||
{tool} INPOLICY inpolicy inpolicy
|
||||
{dep} INPOLICY on FOUNDATION
|
||||
|
|
Loading…
Reference in a new issue