New properties for knowing if a component is a user library, and for getting its version.
[INTERPRETER] * NEW: Component.Library is a new property that returns if a component is actually a user library. * NEW: Component.Version is a new property that returns the version number of a loaded component. If the component is a user library, you get the version number of that library. Otherwise you get the current Gambas version.
This commit is contained in:
parent
36b16f18b3
commit
8bf14d2a7e
@ -96,6 +96,21 @@ BEGIN_PROPERTY(Component_Name)
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(Component_Version)
|
||||
|
||||
if (OBJECT(COMPONENT)->user)
|
||||
GB_ReturnConstZeroString(OBJECT(COMPONENT)->version);
|
||||
else
|
||||
GB_ReturnConstZeroString(VERSION);
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(Component_Library)
|
||||
|
||||
GB_ReturnBoolean(OBJECT(COMPONENT)->user);
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(Component_Path)
|
||||
|
||||
GB_ReturnString(COMPONENT_path);
|
||||
@ -885,6 +900,8 @@ GB_DESC NATIVE_Component[] =
|
||||
GB_STATIC_PROPERTY_READ("Path", "s", Component_Path),
|
||||
|
||||
GB_PROPERTY_READ("Name", "s", Component_Name),
|
||||
GB_PROPERTY_READ("Version", "s", Component_Version),
|
||||
GB_PROPERTY_READ("Library", "b", Component_Library),
|
||||
|
||||
GB_END_DECLARE
|
||||
};
|
||||
|
@ -189,6 +189,7 @@ 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
|
||||
{
|
||||
@ -199,7 +200,10 @@ COMPONENT *COMPONENT_create(const char *name)
|
||||
name++;
|
||||
p = rindex(name, ':');
|
||||
if (p)
|
||||
{
|
||||
version = p + 1;
|
||||
*p = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
name = FILE_get_basename(name);
|
||||
@ -215,6 +219,8 @@ 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 = ':';
|
||||
@ -297,6 +303,7 @@ void COMPONENT_delete(COMPONENT *comp)
|
||||
ARCHIVE_delete(comp->archive);
|
||||
|
||||
STRING_free(&comp->name);
|
||||
STRING_free(&comp->version);
|
||||
|
||||
FREE(&comp);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ typedef
|
||||
LIST list;
|
||||
LIST load;
|
||||
char *name;
|
||||
char *version;
|
||||
LIBRARY *library;
|
||||
ARCHIVE *archive;
|
||||
unsigned order : 8;
|
||||
|
Loading…
x
Reference in New Issue
Block a user