mirror of
https://github.com/ganelson/inform.git
synced 2024-06-26 04:00:43 +03:00
Tidied up copies code
This commit is contained in:
parent
4dc12ac3ef
commit
f125104bfe
|
@ -55,17 +55,7 @@ int main(int argc, char **argv) {
|
|||
inbuild_copy *C;
|
||||
LOOP_OVER_LINKED_LIST(C, inbuild_copy, targets) {
|
||||
switch (inbuild_task) {
|
||||
case INSPECT_TTASK:
|
||||
WRITE_TO(STDOUT, "%S: ", Model::genre_name(C->edition->work->genre));
|
||||
Model::write_copy(STDOUT, C);
|
||||
if (C->location_if_path) {
|
||||
WRITE_TO(STDOUT, " at path %p", C->location_if_path);
|
||||
}
|
||||
if (C->location_if_file) {
|
||||
WRITE_TO(STDOUT, " in directory %p", Filenames::get_path_to(C->location_if_file));
|
||||
}
|
||||
WRITE_TO(STDOUT, "\n");
|
||||
break;
|
||||
case INSPECT_TTASK: Copies::inspect(STDOUT, C); break;
|
||||
case GRAPH_TTASK: Graphs::describe(STDOUT, C->vertex, TRUE); break;
|
||||
case BUILD_TTASK: Graphs::build(C->vertex, BM); break;
|
||||
case REBUILD_TTASK: Graphs::rebuild(C->vertex, BM); break;
|
||||
|
@ -184,7 +174,7 @@ void Main::load_many(pathname *P) {
|
|||
}
|
||||
|
||||
void Main::load_one(text_stream *arg, int throwing_error) {
|
||||
inbuild_copy *C = Model::claim(arg);
|
||||
inbuild_copy *C = Copies::claim(arg);
|
||||
if (C == NULL) {
|
||||
if (throwing_error) Errors::with_text("unable to identify '%S'", arg);
|
||||
return;
|
||||
|
|
|
@ -124,7 +124,7 @@ void Inbuild::go_operational(void) {
|
|||
inbuild_phase = GOING_OPERATIONAL_INBUILD_PHASE;
|
||||
inbuild_copy *C;
|
||||
LOOP_OVER(C, inbuild_copy)
|
||||
Model::cppy_go_operational(C);
|
||||
Copies::go_operational(C);
|
||||
inbuild_phase = OPERATIONAL_INBUILD_PHASE;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ Setting up the use of this module.
|
|||
@e inform_project_MT
|
||||
@e inform_language_MT
|
||||
@e inform_pipeline_MT
|
||||
@e source_text_error_MT
|
||||
@e copy_error_MT
|
||||
|
||||
=
|
||||
ALLOCATE_INDIVIDUALLY(inform_kit)
|
||||
|
@ -54,7 +54,7 @@ ALLOCATE_INDIVIDUALLY(inform_template)
|
|||
ALLOCATE_INDIVIDUALLY(inform_project)
|
||||
ALLOCATE_INDIVIDUALLY(inform_language)
|
||||
ALLOCATE_INDIVIDUALLY(inform_pipeline)
|
||||
ALLOCATE_INDIVIDUALLY(source_text_error)
|
||||
ALLOCATE_INDIVIDUALLY(copy_error)
|
||||
|
||||
ALLOCATE_IN_ARRAYS(inbuild_work_database_entry, 100)
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ int description_round = 1;
|
|||
void Graphs::describe(OUTPUT_STREAM, build_vertex *V, int recurse) {
|
||||
Graphs::describe_r(OUT, 0, V, recurse, NULL, NOT_A_GB, description_round++);
|
||||
}
|
||||
void Graphs::describe_r(OUTPUT_STREAM, int depth, build_vertex *V, int recurse, pathname *stem, int which, int description_round) {
|
||||
void Graphs::describe_r(OUTPUT_STREAM, int depth, build_vertex *V,
|
||||
int recurse, pathname *stem, int which, int description_round) {
|
||||
for (int i=0; i<depth; i++) WRITE(" ");
|
||||
if (which == BUILD_GB) WRITE("--build-> ");
|
||||
if (which == USE_GB) WRITE("--use---> ");
|
||||
|
@ -98,7 +99,7 @@ void Graphs::describe_r(OUTPUT_STREAM, int depth, build_vertex *V, int recurse,
|
|||
if (V->last_described == description_round) { WRITE("q.v.\n"); return; }
|
||||
TEMPORARY_TEXT(T);
|
||||
switch (V->type) {
|
||||
case COPY_VERTEX: Model::write_copy(T, V->buildable_if_copy); break;
|
||||
case COPY_VERTEX: Copies::write_copy(T, V->buildable_if_copy); break;
|
||||
case REQUIREMENT_VERTEX: Requirements::write(T, V->findable); break;
|
||||
case FILE_VERTEX: WRITE("%f", V->buildable_if_internal_file); break;
|
||||
}
|
||||
|
@ -120,7 +121,8 @@ void Graphs::describe_r(OUTPUT_STREAM, int depth, build_vertex *V, int recurse,
|
|||
}
|
||||
if (recurse) {
|
||||
if (V->buildable_if_copy) stem = V->buildable_if_copy->location_if_path;
|
||||
if (V->buildable_if_internal_file) stem = Filenames::get_path_to(V->buildable_if_internal_file);
|
||||
if (V->buildable_if_internal_file)
|
||||
stem = Filenames::get_path_to(V->buildable_if_internal_file);
|
||||
build_vertex *W;
|
||||
LOOP_OVER_LINKED_LIST(W, build_vertex, V->build_edges)
|
||||
Graphs::describe_r(OUT, depth+1, W, TRUE, stem, BUILD_GB, description_round);
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
[Model::] Conceptual Model.
|
||||
|
||||
The main concepts of inbuild.
|
||||
|
||||
@h Genres.
|
||||
For example, "kit" and "extension" will both be both genres. There will be
|
||||
few of these.
|
||||
|
||||
@e GENRE_WRITE_WORK_MTID
|
||||
@e GENRE_CLAIM_AS_COPY_MTID
|
||||
@e GENRE_SEARCH_NEST_FOR_MTID
|
||||
@e GENRE_COPY_TO_NEST_MTID
|
||||
@e GENRE_GO_OPERATIONAL_MTID
|
||||
@e GENRE_READ_SOURCE_TEXT_FOR_MTID
|
||||
|
||||
=
|
||||
typedef struct inbuild_genre {
|
||||
text_stream *genre_name;
|
||||
METHOD_CALLS
|
||||
MEMORY_MANAGEMENT
|
||||
} inbuild_genre;
|
||||
|
||||
VMETHOD_TYPE(GENRE_WRITE_WORK_MTID, inbuild_genre *gen, text_stream *OUT, inbuild_work *work)
|
||||
VMETHOD_TYPE(GENRE_CLAIM_AS_COPY_MTID, inbuild_genre *gen, inbuild_copy **C, text_stream *arg, text_stream *ext, int directory_status)
|
||||
VMETHOD_TYPE(GENRE_SEARCH_NEST_FOR_MTID, inbuild_genre *gen, inbuild_nest *N, inbuild_requirement *req, linked_list *search_results)
|
||||
VMETHOD_TYPE(GENRE_COPY_TO_NEST_MTID, inbuild_genre *gen, inbuild_copy *C, inbuild_nest *N, int syncing, build_methodology *meth)
|
||||
VMETHOD_TYPE(GENRE_GO_OPERATIONAL_MTID, inbuild_genre *gen, inbuild_copy *C)
|
||||
VMETHOD_TYPE(GENRE_READ_SOURCE_TEXT_FOR_MTID, inbuild_genre *gen, inbuild_copy *C)
|
||||
|
||||
@ =
|
||||
inbuild_genre *Model::genre(text_stream *name) {
|
||||
inbuild_genre *gen;
|
||||
LOOP_OVER(gen, inbuild_genre)
|
||||
if (Str::eq(gen->genre_name, name))
|
||||
return gen;
|
||||
gen = CREATE(inbuild_genre);
|
||||
gen->genre_name = Str::duplicate(name);
|
||||
ENABLE_METHOD_CALLS(gen);
|
||||
return gen;
|
||||
}
|
||||
|
||||
text_stream *Model::genre_name(inbuild_genre *G) {
|
||||
if (G == NULL) return I"(none)";
|
||||
return G->genre_name;
|
||||
}
|
||||
|
||||
@h Editions.
|
||||
An "edition" of a work is a particular version numbered form of it. For
|
||||
example, release 7 of Bronze by Emily Short would be an edition of Bronze.
|
||||
|
||||
=
|
||||
typedef struct inbuild_edition {
|
||||
struct inbuild_work *work;
|
||||
struct inbuild_version_number version;
|
||||
MEMORY_MANAGEMENT
|
||||
} inbuild_edition;
|
||||
|
||||
inbuild_edition *Model::edition(inbuild_work *work, inbuild_version_number version) {
|
||||
inbuild_edition *edition = CREATE(inbuild_edition);
|
||||
edition->work = work;
|
||||
edition->version = version;
|
||||
return edition;
|
||||
}
|
||||
|
||||
@h Copies.
|
||||
A "copy" of a work exists in the file system when we've actually got hold of
|
||||
some edition of it. For some genres, copies will be files; for others,
|
||||
directories holding a set of files.
|
||||
|
||||
=
|
||||
typedef struct inbuild_copy {
|
||||
struct inbuild_edition *edition;
|
||||
struct pathname *location_if_path;
|
||||
struct filename *location_if_file;
|
||||
general_pointer content; /* the type of which depends on the work's genre */
|
||||
struct build_vertex *vertex;
|
||||
int source_text_read;
|
||||
struct wording source_text;
|
||||
struct linked_list *errors_reading_source_text;
|
||||
struct inbuild_requirement *found_by;
|
||||
MEMORY_MANAGEMENT
|
||||
} inbuild_copy;
|
||||
|
||||
inbuild_copy *Model::copy_in_file(inbuild_edition *edition, filename *F, general_pointer C) {
|
||||
inbuild_copy *copy = CREATE(inbuild_copy);
|
||||
copy->edition = edition;
|
||||
copy->location_if_path = NULL;
|
||||
copy->location_if_file = F;
|
||||
copy->content = C;
|
||||
copy->vertex = NULL;
|
||||
copy->source_text_read = FALSE;
|
||||
copy->source_text = EMPTY_WORDING;
|
||||
copy->errors_reading_source_text = NEW_LINKED_LIST(source_text_error);
|
||||
copy->found_by = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
inbuild_copy *Model::copy_in_directory(inbuild_edition *edition, pathname *P, general_pointer C) {
|
||||
inbuild_copy *copy = CREATE(inbuild_copy);
|
||||
copy->edition = edition;
|
||||
copy->location_if_path = P;
|
||||
copy->location_if_file = NULL;
|
||||
copy->content = C;
|
||||
copy->vertex = NULL;
|
||||
copy->source_text_read = FALSE;
|
||||
copy->source_text = EMPTY_WORDING;
|
||||
copy->errors_reading_source_text = NEW_LINKED_LIST(source_text_error);
|
||||
copy->found_by = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
void Model::write_copy(OUTPUT_STREAM, inbuild_copy *C) {
|
||||
Works::write(OUT, C->edition->work);
|
||||
inbuild_version_number N = C->edition->version;
|
||||
if (VersionNumbers::is_null(N) == FALSE) {
|
||||
WRITE(" v"); VersionNumbers::to_text(OUT, N);
|
||||
}
|
||||
}
|
||||
|
||||
inbuild_copy *Model::claim(text_stream *arg) {
|
||||
TEMPORARY_TEXT(ext);
|
||||
int pos = Str::len(arg) - 1, dotpos = -1;
|
||||
while (pos >= 0) {
|
||||
wchar_t c = Str::get_at(arg, pos);
|
||||
if (c == FOLDER_SEPARATOR) break;
|
||||
if (c == '.') dotpos = pos;
|
||||
pos--;
|
||||
}
|
||||
if (dotpos >= 0)
|
||||
Str::substr(ext, Str::at(arg, dotpos+1), Str::end(arg));
|
||||
int directory_status = NOT_APPLICABLE;
|
||||
if (Str::get_last_char(arg) == FOLDER_SEPARATOR) {
|
||||
Str::delete_last_character(arg);
|
||||
directory_status = TRUE;
|
||||
}
|
||||
inbuild_copy *C = NULL;
|
||||
inbuild_genre *G;
|
||||
LOOP_OVER(G, inbuild_genre)
|
||||
if (C == NULL)
|
||||
VMETHOD_CALL(G, GENRE_CLAIM_AS_COPY_MTID, &C, arg, ext, directory_status);
|
||||
DISCARD_TEXT(ext);
|
||||
return C;
|
||||
}
|
||||
|
||||
void Model::cppy_go_operational(inbuild_copy *C) {
|
||||
VMETHOD_CALL(C->edition->work->genre, GENRE_GO_OPERATIONAL_MTID, C);
|
||||
}
|
||||
|
||||
wording Model::read_source_text_for(inbuild_copy *C) {
|
||||
if (C->source_text_read == FALSE) {
|
||||
C->source_text_read = TRUE;
|
||||
feed_t id = Feeds::begin();
|
||||
VMETHOD_CALL(C->edition->work->genre, GENRE_READ_SOURCE_TEXT_FOR_MTID, C);
|
||||
wording W = Feeds::end(id);
|
||||
if (Wordings::nonempty(W)) C->source_text = W;
|
||||
}
|
||||
return C->source_text;
|
||||
}
|
178
inbuild/inbuild-module/Chapter 2/Copies.w
Normal file
178
inbuild/inbuild-module/Chapter 2/Copies.w
Normal file
|
@ -0,0 +1,178 @@
|
|||
[Copies::] Copies.
|
||||
|
||||
A copy is an instance in the file system of a specific edition of a work.
|
||||
|
||||
@h Editions.
|
||||
An "edition" of a work is a particular version numbered form of it. For
|
||||
example, release 7 of Bronze by Emily Short would be an edition of Bronze.
|
||||
|
||||
=
|
||||
typedef struct inbuild_edition {
|
||||
struct inbuild_work *work;
|
||||
struct inbuild_version_number version;
|
||||
MEMORY_MANAGEMENT
|
||||
} inbuild_edition;
|
||||
|
||||
inbuild_edition *Copies::edition(inbuild_work *work, inbuild_version_number version) {
|
||||
inbuild_edition *edition = CREATE(inbuild_edition);
|
||||
edition->work = work;
|
||||
edition->version = version;
|
||||
return edition;
|
||||
}
|
||||
|
||||
void Copies::write_edition(OUTPUT_STREAM, inbuild_edition *E) {
|
||||
Works::write(OUT, E->work);
|
||||
inbuild_version_number V = E->version;
|
||||
if (VersionNumbers::is_null(V) == FALSE) {
|
||||
WRITE(" v%v", &V);
|
||||
}
|
||||
}
|
||||
|
||||
@h Copies.
|
||||
A "copy" of a work exists in the file system when we've actually got hold of
|
||||
some edition of it. For some genres, copies will be files; for others,
|
||||
directories holding a set of files.
|
||||
|
||||
=
|
||||
typedef struct inbuild_copy {
|
||||
struct inbuild_edition *edition;
|
||||
struct pathname *location_if_path;
|
||||
struct filename *location_if_file;
|
||||
general_pointer content; /* the type of which depends on the work's genre */
|
||||
struct build_vertex *vertex;
|
||||
int source_text_read;
|
||||
struct wording source_text;
|
||||
struct linked_list *errors_reading_source_text;
|
||||
struct inbuild_requirement *found_by;
|
||||
MEMORY_MANAGEMENT
|
||||
} inbuild_copy;
|
||||
|
||||
inbuild_copy *Copies::new_p(inbuild_edition *edition, general_pointer ref) {
|
||||
inbuild_copy *copy = CREATE(inbuild_copy);
|
||||
copy->edition = edition;
|
||||
copy->location_if_path = NULL;
|
||||
copy->location_if_file = NULL;
|
||||
copy->content = ref;
|
||||
copy->vertex = NULL;
|
||||
copy->source_text_read = FALSE;
|
||||
copy->source_text = EMPTY_WORDING;
|
||||
copy->errors_reading_source_text = NEW_LINKED_LIST(copy_error);
|
||||
copy->found_by = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
inbuild_copy *Copies::new_in_file(inbuild_edition *edition, filename *F, general_pointer ref) {
|
||||
inbuild_copy *copy = Copies::new_p(edition, ref);
|
||||
copy->location_if_file = F;
|
||||
return copy;
|
||||
}
|
||||
|
||||
inbuild_copy *Copies::new_in_path(inbuild_edition *edition, pathname *P, general_pointer ref) {
|
||||
inbuild_copy *copy = Copies::new_p(edition, ref);
|
||||
copy->location_if_path = P;
|
||||
return copy;
|
||||
}
|
||||
|
||||
void Copies::write_copy(OUTPUT_STREAM, inbuild_copy *C) {
|
||||
Copies::write_edition(OUT, C->edition);
|
||||
}
|
||||
|
||||
void Copies::go_operational(inbuild_copy *C) {
|
||||
VMETHOD_CALL(C->edition->work->genre, GENRE_GO_OPERATIONAL_MTID, C);
|
||||
}
|
||||
|
||||
wording Copies::read_source_text_for(inbuild_copy *C) {
|
||||
if (C->source_text_read == FALSE) {
|
||||
C->source_text_read = TRUE;
|
||||
feed_t id = Feeds::begin();
|
||||
VMETHOD_CALL(C->edition->work->genre, GENRE_READ_SOURCE_TEXT_FOR_MTID, C);
|
||||
wording W = Feeds::end(id);
|
||||
if (Wordings::nonempty(W)) C->source_text = W;
|
||||
}
|
||||
return C->source_text;
|
||||
}
|
||||
|
||||
inbuild_copy *Copies::claim(text_stream *arg) {
|
||||
TEMPORARY_TEXT(ext);
|
||||
int pos = Str::len(arg) - 1, dotpos = -1;
|
||||
while (pos >= 0) {
|
||||
wchar_t c = Str::get_at(arg, pos);
|
||||
if (c == FOLDER_SEPARATOR) break;
|
||||
if (c == '.') dotpos = pos;
|
||||
pos--;
|
||||
}
|
||||
if (dotpos >= 0)
|
||||
Str::substr(ext, Str::at(arg, dotpos+1), Str::end(arg));
|
||||
int directory_status = NOT_APPLICABLE;
|
||||
if (Str::get_last_char(arg) == FOLDER_SEPARATOR) {
|
||||
Str::delete_last_character(arg);
|
||||
directory_status = TRUE;
|
||||
}
|
||||
inbuild_copy *C = NULL;
|
||||
inbuild_genre *G;
|
||||
LOOP_OVER(G, inbuild_genre)
|
||||
if (C == NULL)
|
||||
VMETHOD_CALL(G, GENRE_CLAIM_AS_COPY_MTID, &C, arg, ext, directory_status);
|
||||
DISCARD_TEXT(ext);
|
||||
return C;
|
||||
}
|
||||
|
||||
void Copies::inspect(OUTPUT_STREAM, inbuild_copy *C) {
|
||||
WRITE("%S: ", Genres::name(C->edition->work->genre));
|
||||
Copies::write_copy(STDOUT, C);
|
||||
if (C->location_if_path) {
|
||||
WRITE(" at path %p", C->location_if_path);
|
||||
}
|
||||
if (C->location_if_file) {
|
||||
WRITE(" in directory %p", Filenames::get_path_to(C->location_if_file));
|
||||
}
|
||||
int N = LinkedLists::len(C->errors_reading_source_text);
|
||||
if (N > 0) {
|
||||
WRITE(" - %d error", N);
|
||||
if (N > 1) WRITE("s");
|
||||
}
|
||||
WRITE("\n");
|
||||
}
|
||||
|
||||
@h Errors.
|
||||
Copies can sometimes exist in a damaged form: for example, they are purportedly
|
||||
extension files but have a mangled identification line. Each copy structure
|
||||
therefore has a list attached of errors which occurred in reading it.
|
||||
|
||||
@e OPEN_FAILED_CE from 1
|
||||
@e EXT_MISWORDED_CE
|
||||
@e LEXER_CE
|
||||
|
||||
=
|
||||
typedef struct copy_error {
|
||||
int error_category;
|
||||
int error_subcategory;
|
||||
struct inbuild_copy *copy;
|
||||
struct filename *file;
|
||||
struct text_file_position pos;
|
||||
struct text_stream *notes;
|
||||
MEMORY_MANAGEMENT
|
||||
} copy_error;
|
||||
|
||||
copy_error *Copies::new_error(int cat, text_stream *NB) {
|
||||
copy_error *CE = CREATE(copy_error);
|
||||
CE->error_category = cat;
|
||||
CE->error_subcategory = -1;
|
||||
CE->file = NULL;
|
||||
CE->notes = Str::duplicate(NB);
|
||||
CE->pos = TextFiles::nowhere();
|
||||
CE->copy = NULL;
|
||||
return CE;
|
||||
}
|
||||
|
||||
copy_error *Copies::new_error_on_file(int cat, filename *F) {
|
||||
copy_error *CE = Copies::new_error(cat, NULL);
|
||||
CE->file = F;
|
||||
return CE;
|
||||
}
|
||||
|
||||
void Copies::attach(inbuild_copy *C, copy_error *CE) {
|
||||
if (C == NULL) internal_error("no copy to attach to");
|
||||
CE->copy = C;
|
||||
ADD_TO_LINKED_LIST(CE, copy_error, C->errors_reading_source_text);
|
||||
}
|
56
inbuild/inbuild-module/Chapter 2/Genres.w
Normal file
56
inbuild/inbuild-module/Chapter 2/Genres.w
Normal file
|
@ -0,0 +1,56 @@
|
|||
[Genres::] Genres.
|
||||
|
||||
The different sorts of work managed by inbuild.
|
||||
|
||||
@h Genres.
|
||||
For example, "kit" and "extension" will both be both genres. There will be
|
||||
few of these.
|
||||
|
||||
=
|
||||
typedef struct inbuild_genre {
|
||||
text_stream *genre_name;
|
||||
METHOD_CALLS
|
||||
MEMORY_MANAGEMENT
|
||||
} inbuild_genre;
|
||||
|
||||
inbuild_genre *Genres::new(text_stream *name) {
|
||||
inbuild_genre *gen;
|
||||
LOOP_OVER(gen, inbuild_genre)
|
||||
if (Str::eq(gen->genre_name, name))
|
||||
return gen;
|
||||
gen = CREATE(inbuild_genre);
|
||||
gen->genre_name = Str::duplicate(name);
|
||||
ENABLE_METHOD_CALLS(gen);
|
||||
return gen;
|
||||
}
|
||||
|
||||
text_stream *Genres::name(inbuild_genre *G) {
|
||||
if (G == NULL) return I"(none)";
|
||||
return G->genre_name;
|
||||
}
|
||||
|
||||
@
|
||||
|
||||
@e GENRE_WRITE_WORK_MTID
|
||||
@e GENRE_CLAIM_AS_COPY_MTID
|
||||
@e GENRE_SEARCH_NEST_FOR_MTID
|
||||
@e GENRE_COPY_TO_NEST_MTID
|
||||
@e GENRE_GO_OPERATIONAL_MTID
|
||||
@e GENRE_READ_SOURCE_TEXT_FOR_MTID
|
||||
|
||||
=
|
||||
VMETHOD_TYPE(GENRE_WRITE_WORK_MTID,
|
||||
inbuild_genre *gen, text_stream *OUT, inbuild_work *work)
|
||||
VMETHOD_TYPE(GENRE_CLAIM_AS_COPY_MTID,
|
||||
inbuild_genre *gen, inbuild_copy **C, text_stream *arg, text_stream *ext,
|
||||
int directory_status)
|
||||
VMETHOD_TYPE(GENRE_SEARCH_NEST_FOR_MTID,
|
||||
inbuild_genre *gen, inbuild_nest *N, inbuild_requirement *req,
|
||||
linked_list *search_results)
|
||||
VMETHOD_TYPE(GENRE_COPY_TO_NEST_MTID,
|
||||
inbuild_genre *gen, inbuild_copy *C, inbuild_nest *N, int syncing,
|
||||
build_methodology *meth)
|
||||
VMETHOD_TYPE(GENRE_GO_OPERATIONAL_MTID,
|
||||
inbuild_genre *gen, inbuild_copy *C)
|
||||
VMETHOD_TYPE(GENRE_READ_SOURCE_TEXT_FOR_MTID,
|
||||
inbuild_genre *gen, inbuild_copy *C)
|
|
@ -15,7 +15,7 @@ length to one character less than the following constants:
|
|||
|
||||
@ =
|
||||
void ExtensionManager::start(void) {
|
||||
extension_genre = Model::genre(I"extension");
|
||||
extension_genre = Genres::new(I"extension");
|
||||
METHOD_ADD(extension_genre, GENRE_WRITE_WORK_MTID, ExtensionManager::write_work);
|
||||
METHOD_ADD(extension_genre, GENRE_CLAIM_AS_COPY_MTID, ExtensionManager::claim_as_copy);
|
||||
METHOD_ADD(extension_genre, GENRE_SEARCH_NEST_FOR_MTID, ExtensionManager::search_nest_for);
|
||||
|
@ -56,7 +56,7 @@ inbuild_copy *ExtensionManager::new_copy(inbuild_edition *edition, filename *F)
|
|||
C = Dictionaries::read_value(ext_copy_cache, key);
|
||||
if (C == NULL) {
|
||||
inform_extension *E = Extensions::new_ie();
|
||||
C = Model::copy_in_file(edition, F, STORE_POINTER_inform_extension(E));
|
||||
C = Copies::new_in_file(edition, F, STORE_POINTER_inform_extension(E));
|
||||
E->as_copy = C;
|
||||
if (Works::is_standard_rules(C->edition->work)) Extensions::make_standard(E);
|
||||
Dictionaries::create(ext_copy_cache, key);
|
||||
|
@ -100,12 +100,9 @@ inbuild_copy *ExtensionManager::claim_file_as_copy(filename *F,
|
|||
inbuild_version_number V =
|
||||
ExtensionManager::scan_file(F, title, author, rubric_text, requirement_text, error_text);
|
||||
inbuild_copy *C = ExtensionManager::new_copy(
|
||||
Model::edition(Works::new(extension_genre, title, author), V), F);
|
||||
if (Str::len(error_text) > 0) {
|
||||
source_text_error *ste = SourceText::ste_text(EXT_MISWORDED_STE, error_text);
|
||||
ste->copy = C;
|
||||
ADD_TO_LINKED_LIST(ste, source_text_error, C->errors_reading_source_text);
|
||||
}
|
||||
Copies::edition(Works::new(extension_genre, title, author), V), F);
|
||||
if (Str::len(error_text) > 0)
|
||||
Copies::attach(C, Copies::new_error(EXT_MISWORDED_CE, error_text));
|
||||
if ((allow_malformed) || (Str::len(error_text) == 0)) {
|
||||
Works::add_to_database(C->edition->work, CLAIMED_WDBC);
|
||||
ExtensionManager::build_vertex(C);
|
||||
|
|
|
@ -7,7 +7,7 @@ A kit is a combination of Inter code with an Inform 7 extension.
|
|||
=
|
||||
inbuild_genre *kit_genre = NULL;
|
||||
void KitManager::start(void) {
|
||||
kit_genre = Model::genre(I"kit");
|
||||
kit_genre = Genres::new(I"kit");
|
||||
METHOD_ADD(kit_genre, GENRE_WRITE_WORK_MTID, KitManager::write_work);
|
||||
METHOD_ADD(kit_genre, GENRE_CLAIM_AS_COPY_MTID, KitManager::claim_as_copy);
|
||||
METHOD_ADD(kit_genre, GENRE_SEARCH_NEST_FOR_MTID, KitManager::search_nest_for);
|
||||
|
@ -49,8 +49,8 @@ inbuild_copy *KitManager::new_copy(text_stream *name, pathname *P) {
|
|||
if (C == NULL) {
|
||||
inform_kit *K = Kits::new_ik(name, P);
|
||||
inbuild_work *work = Works::new_raw(kit_genre, Str::duplicate(name), NULL);
|
||||
inbuild_edition *edition = Model::edition(work, K->version);
|
||||
C = Model::copy_in_directory(edition, P, STORE_POINTER_inform_kit(K));
|
||||
inbuild_edition *edition = Copies::edition(work, K->version);
|
||||
C = Copies::new_in_path(edition, P, STORE_POINTER_inform_kit(K));
|
||||
K->as_copy = C;
|
||||
Dictionaries::create(kit_copy_cache, key);
|
||||
Dictionaries::write_value(kit_copy_cache, key, C);
|
||||
|
|
|
@ -9,7 +9,7 @@ inbuild_genre *language_genre = NULL;
|
|||
|
||||
@ =
|
||||
void LanguageManager::start(void) {
|
||||
language_genre = Model::genre(I"language");
|
||||
language_genre = Genres::new(I"language");
|
||||
METHOD_ADD(language_genre, GENRE_WRITE_WORK_MTID, LanguageManager::write_work);
|
||||
METHOD_ADD(language_genre, GENRE_CLAIM_AS_COPY_MTID, LanguageManager::claim_as_copy);
|
||||
METHOD_ADD(language_genre, GENRE_SEARCH_NEST_FOR_MTID, LanguageManager::search_nest_for);
|
||||
|
@ -50,8 +50,8 @@ inbuild_copy *LanguageManager::new_copy(text_stream *name, pathname *P) {
|
|||
if (C == NULL) {
|
||||
inform_language *K = Languages::new_il(name, P);
|
||||
inbuild_work *work = Works::new(language_genre, Str::duplicate(name), NULL);
|
||||
inbuild_edition *edition = Model::edition(work, K->version);
|
||||
C = Model::copy_in_directory(edition, P, STORE_POINTER_inform_language(K));
|
||||
inbuild_edition *edition = Copies::edition(work, K->version);
|
||||
C = Copies::new_in_path(edition, P, STORE_POINTER_inform_language(K));
|
||||
K->as_copy = C;
|
||||
Dictionaries::create(language_copy_cache, key);
|
||||
Dictionaries::write_value(language_copy_cache, key, C);
|
||||
|
|
|
@ -9,7 +9,7 @@ inbuild_genre *pipeline_genre = NULL;
|
|||
|
||||
@ =
|
||||
void PipelineManager::start(void) {
|
||||
pipeline_genre = Model::genre(I"pipeline");
|
||||
pipeline_genre = Genres::new(I"pipeline");
|
||||
METHOD_ADD(pipeline_genre, GENRE_WRITE_WORK_MTID, PipelineManager::write_work);
|
||||
METHOD_ADD(pipeline_genre, GENRE_CLAIM_AS_COPY_MTID, PipelineManager::claim_as_copy);
|
||||
METHOD_ADD(pipeline_genre, GENRE_SEARCH_NEST_FOR_MTID, PipelineManager::search_nest_for);
|
||||
|
@ -41,7 +41,7 @@ inform_pipeline *PipelineManager::from_copy(inbuild_copy *C) {
|
|||
|
||||
inbuild_copy *PipelineManager::new_copy(inbuild_edition *edition, filename *F) {
|
||||
inform_pipeline *E = Pipelines::new_ip(edition->work->title, F);
|
||||
inbuild_copy *C = Model::copy_in_file(edition, F, STORE_POINTER_inform_pipeline(E));
|
||||
inbuild_copy *C = Copies::new_in_file(edition, F, STORE_POINTER_inform_pipeline(E));
|
||||
E->as_copy = C;
|
||||
return C;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ inbuild_copy *PipelineManager::claim_file_as_copy(filename *F, text_stream *erro
|
|||
TEMPORARY_TEXT(unext);
|
||||
Filenames::write_unextended_leafname(unext, F);
|
||||
inbuild_copy *C = PipelineManager::new_copy(
|
||||
Model::edition(Works::new_raw(pipeline_genre, unext, NULL), V), F);
|
||||
Copies::edition(Works::new_raw(pipeline_genre, unext, NULL), V), F);
|
||||
DISCARD_TEXT(unext);
|
||||
Works::add_to_database(C->edition->work, CLAIMED_WDBC);
|
||||
PipelineManager::build_vertex(C);
|
||||
|
|
|
@ -7,7 +7,7 @@ A project bundle is a folder holding an Inform 7 work. The app creates these.
|
|||
=
|
||||
inbuild_genre *project_bundle_genre = NULL;
|
||||
void ProjectBundleManager::start(void) {
|
||||
project_bundle_genre = Model::genre(I"projectbundle");
|
||||
project_bundle_genre = Genres::new(I"projectbundle");
|
||||
METHOD_ADD(project_bundle_genre, GENRE_WRITE_WORK_MTID, ProjectBundleManager::write_work);
|
||||
METHOD_ADD(project_bundle_genre, GENRE_CLAIM_AS_COPY_MTID, ProjectBundleManager::claim_as_copy);
|
||||
METHOD_ADD(project_bundle_genre, GENRE_SEARCH_NEST_FOR_MTID, ProjectBundleManager::search_nest_for);
|
||||
|
@ -34,8 +34,8 @@ inform_project *ProjectBundleManager::from_copy(inbuild_copy *C) {
|
|||
inbuild_copy *ProjectBundleManager::new_copy(text_stream *name, pathname *P) {
|
||||
inform_project *K = Projects::new_ip(name, NULL, P);
|
||||
inbuild_work *work = Works::new(project_bundle_genre, Str::duplicate(name), NULL);
|
||||
inbuild_edition *edition = Model::edition(work, K->version);
|
||||
K->as_copy = Model::copy_in_directory(edition, P, STORE_POINTER_inform_project(K));
|
||||
inbuild_edition *edition = Copies::edition(work, K->version);
|
||||
K->as_copy = Copies::new_in_path(edition, P, STORE_POINTER_inform_project(K));
|
||||
return K->as_copy;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ A project file is a plain text file of Inform 7 source text.
|
|||
=
|
||||
inbuild_genre *project_file_genre = NULL;
|
||||
void ProjectFileManager::start(void) {
|
||||
project_file_genre = Model::genre(I"projectfile");
|
||||
project_file_genre = Genres::new(I"projectfile");
|
||||
METHOD_ADD(project_file_genre, GENRE_WRITE_WORK_MTID, ProjectFileManager::write_work);
|
||||
METHOD_ADD(project_file_genre, GENRE_CLAIM_AS_COPY_MTID, ProjectFileManager::claim_as_copy);
|
||||
METHOD_ADD(project_file_genre, GENRE_SEARCH_NEST_FOR_MTID, ProjectFileManager::search_nest_for);
|
||||
|
@ -34,8 +34,8 @@ inform_project *ProjectFileManager::from_copy(inbuild_copy *C) {
|
|||
inbuild_copy *ProjectFileManager::new_copy(text_stream *name, filename *F) {
|
||||
inform_project *K = Projects::new_ip(name, F, NULL);
|
||||
inbuild_work *work = Works::new(project_file_genre, Str::duplicate(name), NULL);
|
||||
inbuild_edition *edition = Model::edition(work, K->version);
|
||||
K->as_copy = Model::copy_in_file(edition, F, STORE_POINTER_inform_project(K));
|
||||
inbuild_edition *edition = Copies::edition(work, K->version);
|
||||
K->as_copy = Copies::new_in_file(edition, F, STORE_POINTER_inform_project(K));
|
||||
return K->as_copy;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ A template is the outline for a website presenting an Inform work.
|
|||
=
|
||||
inbuild_genre *template_genre = NULL;
|
||||
void TemplateManager::start(void) {
|
||||
template_genre = Model::genre(I"template");
|
||||
template_genre = Genres::new(I"template");
|
||||
METHOD_ADD(template_genre, GENRE_WRITE_WORK_MTID, TemplateManager::write_work);
|
||||
METHOD_ADD(template_genre, GENRE_CLAIM_AS_COPY_MTID, TemplateManager::claim_as_copy);
|
||||
METHOD_ADD(template_genre, GENRE_SEARCH_NEST_FOR_MTID, TemplateManager::search_nest_for);
|
||||
|
@ -40,8 +40,8 @@ inform_template *TemplateManager::from_copy(inbuild_copy *C) {
|
|||
inbuild_copy *TemplateManager::new_copy(text_stream *name, pathname *P) {
|
||||
inform_template *K = Templates::new_it(name, P);
|
||||
inbuild_work *work = Works::new(template_genre, Str::duplicate(name), NULL);
|
||||
inbuild_edition *edition = Model::edition(work, K->version);
|
||||
K->as_copy = Model::copy_in_directory(edition, P, STORE_POINTER_inform_template(K));
|
||||
inbuild_edition *edition = Copies::edition(work, K->version);
|
||||
K->as_copy = Copies::new_in_path(edition, P, STORE_POINTER_inform_template(K));
|
||||
return K->as_copy;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ void Extensions::read_source_text_for(inform_extension *E) {
|
|||
#endif
|
||||
TEMPORARY_TEXT(synopsis);
|
||||
@<Concoct a synopsis for the extension to be read@>;
|
||||
E->read_into_file = SourceText::read_file(F, synopsis, doc_only, E->as_copy->errors_reading_source_text, FALSE);
|
||||
E->read_into_file = SourceText::read_file(E->as_copy, F, synopsis, doc_only, FALSE);
|
||||
DISCARD_TEXT(synopsis);
|
||||
if (E->read_into_file) {
|
||||
E->read_into_file->your_ref = STORE_POINTER_inbuild_copy(E->as_copy);
|
||||
|
|
|
@ -274,8 +274,8 @@ void Projects::read_source_text_for(inform_project *project) {
|
|||
build_vertex *N;
|
||||
LOOP_OVER_LINKED_LIST(N, build_vertex, L) {
|
||||
filename *F = N->buildable_if_internal_file;
|
||||
N->read_as = SourceText::read_file(F, N->annotation,
|
||||
FALSE, project->as_copy->errors_reading_source_text, TRUE);
|
||||
N->read_as = SourceText::read_file(project->as_copy, F, N->annotation,
|
||||
FALSE, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,47 +3,14 @@
|
|||
Code for reading Inform 7 source text, which Inbuild uses for both extensions
|
||||
and projects.
|
||||
|
||||
@ Either way, we use the following code. The |SourceText::read_file| function returns
|
||||
one of the following values to indicate the source of the source: the value
|
||||
only really tells us something we didn't know in the case of extensions,
|
||||
but in that event the Extensions.w routines do indeed want to know this.
|
||||
|
||||
@e SEARCH_FAILED_STE from 1
|
||||
@e OPEN_FAILED_STE
|
||||
@e EXT_MISWORDED_STE
|
||||
@ This short function is a bridge to the lexer, and is used for reading
|
||||
text files of source into either projects or extensions. Note that it
|
||||
doesn't attach the fed text to the copy: the copy may need to contain text
|
||||
from multiple files and indeed from elsewhere.
|
||||
|
||||
=
|
||||
typedef struct source_text_error {
|
||||
int ste_code;
|
||||
struct inbuild_copy *copy;
|
||||
struct filename *file;
|
||||
struct text_file_position pos;
|
||||
struct text_stream *notes;
|
||||
MEMORY_MANAGEMENT
|
||||
} source_text_error;
|
||||
|
||||
source_text_error *SourceText::ste(int code, filename *F) {
|
||||
source_text_error *ste = CREATE(source_text_error);
|
||||
ste->ste_code = code;
|
||||
ste->file = F;
|
||||
ste->notes = NULL;
|
||||
ste->pos = TextFiles::nowhere();
|
||||
ste->copy = NULL;
|
||||
return ste;
|
||||
}
|
||||
|
||||
source_text_error *SourceText::ste_text(int code, text_stream *NB) {
|
||||
source_text_error *ste = CREATE(source_text_error);
|
||||
ste->ste_code = code;
|
||||
ste->file = NULL;
|
||||
ste->notes = Str::duplicate(NB);
|
||||
ste->pos = TextFiles::nowhere();
|
||||
ste->copy = NULL;
|
||||
return ste;
|
||||
}
|
||||
|
||||
source_file *SourceText::read_file(filename *F, text_stream *synopsis,
|
||||
int documentation_only, linked_list *errors, int primary) {
|
||||
source_file *SourceText::read_file(inbuild_copy *C, filename *F, text_stream *synopsis,
|
||||
int documentation_only, int primary) {
|
||||
general_pointer ref = STORE_POINTER_inbuild_copy(NULL);
|
||||
FILE *handle = Filenames::fopen(F, "r");
|
||||
if (handle == NULL) return NULL;
|
||||
|
@ -52,8 +19,7 @@ source_file *SourceText::read_file(filename *F, text_stream *synopsis,
|
|||
source_file *sf = TextFromFiles::feed_open_file_into_lexer(F, handle,
|
||||
leaf, documentation_only, ref);
|
||||
if (sf == NULL) {
|
||||
source_text_error *ste = SourceText::ste(OPEN_FAILED_STE, F);
|
||||
ADD_TO_LINKED_LIST(ste, source_text_error, errors);
|
||||
Copies::attach(C, Copies::new_error_on_file(OPEN_FAILED_CE, F));
|
||||
} else {
|
||||
fclose(handle);
|
||||
if (documentation_only == FALSE) @<Tell console output about the file@>;
|
||||
|
@ -66,8 +32,8 @@ source_file *SourceText::read_file(filename *F, text_stream *synopsis,
|
|||
|I've also read Standard Rules by Graham Nelson, which is 27204 words long.|
|
||||
|
||||
are printed to |stdout| (not |stderr|), in something of an affectionate nod
|
||||
to \TeX's traditional console output, though occasionally I think silence is
|
||||
golden and that the messages could go. It's a moot point for almost all users,
|
||||
to TeX's traditional console output, though occasionally I think silence is
|
||||
golden and that these messages could go. It's a moot point for almost all users,
|
||||
though, because the console output is concealed from them by the Inform
|
||||
application.
|
||||
|
||||
|
|
|
@ -9,9 +9,10 @@ Chapter 1: Setting Up
|
|||
Inbuild Control
|
||||
|
||||
Chapter 2: Conceptual Framework
|
||||
Conceptual Model
|
||||
Genres
|
||||
Works
|
||||
Version Numbers
|
||||
Copies
|
||||
Requirements
|
||||
Build Graphs
|
||||
Build Steps
|
||||
|
|
|
@ -36,7 +36,7 @@ void Problems::quote_copy(int t, inbuild_copy *p) {
|
|||
Problems::problem_quote(t, (void *) p, Problems::expand_copy);
|
||||
}
|
||||
void Problems::expand_copy(OUTPUT_STREAM, void *p) {
|
||||
Model::write_copy(OUT, (inbuild_copy *) p);
|
||||
Copies::write_copy(OUT, (inbuild_copy *) p);
|
||||
}
|
||||
void Problems::quote_work(int t, inbuild_work *p) {
|
||||
Problems::problem_quote(t, (void *) p, Problems::expand_work);
|
||||
|
|
|
@ -14,17 +14,17 @@ inclusion sentences -- see Kits.
|
|||
=
|
||||
void SourceFiles::read_primary_source_text(void) {
|
||||
inbuild_copy *C = Inbuild::project()->as_copy;
|
||||
Model::read_source_text_for(C);
|
||||
Copies::read_source_text_for(C);
|
||||
SourceFiles::issue_problems_arising(C);
|
||||
}
|
||||
|
||||
void SourceFiles::issue_problems_arising(inbuild_copy *C) {
|
||||
if (C == NULL) return;
|
||||
source_text_error *ste;
|
||||
LOOP_OVER_LINKED_LIST(ste, source_text_error, C->errors_reading_source_text) {
|
||||
switch (ste->ste_code) {
|
||||
case OPEN_FAILED_STE:
|
||||
Problems::quote_stream(1, Filenames::get_leafname(ste->file));
|
||||
copy_error *CE;
|
||||
LOOP_OVER_LINKED_LIST(CE, copy_error, C->errors_reading_source_text) {
|
||||
switch (CE->error_category) {
|
||||
case OPEN_FAILED_CE:
|
||||
Problems::quote_stream(1, Filenames::get_leafname(CE->file));
|
||||
Problems::Issue::handmade_problem(_p_(Untestable));
|
||||
Problems::issue_problem_segment(
|
||||
"I can't open the file '%1' of source text. %P"
|
||||
|
@ -33,9 +33,9 @@ void SourceFiles::issue_problems_arising(inbuild_copy *C) {
|
|||
"typo in it?");
|
||||
Problems::issue_problem_end();
|
||||
break;
|
||||
case EXT_MISWORDED_STE:
|
||||
Problems::quote_work(1, ste->copy->found_by->work);
|
||||
Problems::quote_stream(2, ste->notes);
|
||||
case EXT_MISWORDED_CE:
|
||||
Problems::quote_work(1, CE->copy->found_by->work);
|
||||
Problems::quote_stream(2, CE->notes);
|
||||
Problems::Issue::handmade_problem(_p_(PM_ExtMiswordedBeginsHere));
|
||||
Problems::issue_problem_segment(
|
||||
"The extension %1, which your source text makes use of, seems to be "
|
||||
|
|
|
@ -239,7 +239,7 @@ trap-door into Read Source Text, to seek and open the file.
|
|||
if (E == NULL) @<Issue a cannot-find problem@>
|
||||
else {
|
||||
inbuild_copy *C = E->as_copy;
|
||||
Model::read_source_text_for(C);
|
||||
Copies::read_source_text_for(C);
|
||||
SourceFiles::issue_problems_arising(C);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue