Component.Version now returns the full version of libraries.

[INTERPRETER]
* NEW: Component.Version now returns the full version of libraries.
This commit is contained in:
gambas 2017-11-25 06:02:46 +01:00
parent 8bf14d2a7e
commit dfb179b549
5 changed files with 46 additions and 9 deletions

View File

@ -332,6 +332,7 @@ void ARCHIVE_delete(ARCHIVE *arch)
TABLE_delete(&arch->classes);
STRING_free(&arch->domain);
STRING_free(&arch->version);
FREE(&arch);
}
@ -713,3 +714,44 @@ void ARCHIVE_browse(ARCHIVE *arch, void (*found)(const char *path, int64_t size)
STRING_free(&path);
}
}
char *ARCHIVE_get_version(ARCHIVE *arch)
{
COMPONENT *current;
char *buffer;
int len;
int n;
char *line;
if (!arch->version_loaded)
{
current = COMPONENT_current;
COMPONENT_current = (COMPONENT *)arch->current_component;
ON_ERROR_1(error_ARCHIVE_load_exported_class, current)
{
STREAM_load(".startup", &buffer, &len);
n = 0;
line = strtok(buffer, "\n");
while (line)
{
n++;
if (n == 5)
{
arch->version = STRING_new_zero(line);
break;
}
line = strtok(NULL, "\n");
}
FREE(&buffer);
}
END_ERROR
COMPONENT_current = current;
arch->version_loaded = TRUE;
}
return arch->version;
}

View File

@ -41,6 +41,7 @@ typedef
LIST list;
ARCH *arch;
const char *name;
char *version;
char *domain;
TABLE *classes;
const char *path;
@ -48,6 +49,7 @@ typedef
struct _CLASS **exported;
unsigned translation_loaded : 1;
unsigned exported_classes_loaded : 1;
unsigned version_loaded : 1;
}
ARCHIVE;
@ -76,6 +78,7 @@ ARCHIVE *ARCHIVE_create(const char *name, const char *path);
void ARCHIVE_delete(ARCHIVE *arch);
void ARCHIVE_load(ARCHIVE *arch, bool load_exp);
void ARCHIVE_load_exported_class(ARCHIVE *arch, int pass);
char *ARCHIVE_get_version(ARCHIVE *arch);
bool ARCHIVE_get(ARCHIVE *arch, const char **ppath, ARCHIVE_FIND *find);

View File

@ -99,7 +99,7 @@ END_PROPERTY
BEGIN_PROPERTY(Component_Version)
if (OBJECT(COMPONENT)->user)
GB_ReturnConstZeroString(OBJECT(COMPONENT)->version);
GB_ReturnString(ARCHIVE_get_version(OBJECT(COMPONENT)->archive));
else
GB_ReturnConstZeroString(VERSION);

View File

@ -189,7 +189,6 @@ COMPONENT *COMPONENT_create(const char *name)
bool library = FALSE;
bool same_name_as_project = FALSE;
char *p = NULL;
char *version = NULL;
if (*name == '/' || *name == ':') // user library
{
@ -200,10 +199,7 @@ COMPONENT *COMPONENT_create(const char *name)
name++;
p = rindex(name, ':');
if (p)
{
version = p + 1;
*p = 0;
}
}
else
name = FILE_get_basename(name);
@ -219,8 +215,6 @@ COMPONENT *COMPONENT_create(const char *name)
comp->ref = 1;
comp->name = STRING_new_zero(name);
if (version)
comp->version = STRING_new_zero(version);
if (p)
*p = ':';
@ -303,7 +297,6 @@ void COMPONENT_delete(COMPONENT *comp)
ARCHIVE_delete(comp->archive);
STRING_free(&comp->name);
STRING_free(&comp->version);
FREE(&comp);
}

View File

@ -38,7 +38,6 @@ typedef
LIST list;
LIST load;
char *name;
char *version;
LIBRARY *library;
ARCHIVE *archive;
unsigned order : 8;