McCode icon indicating copy to clipboard operation
McCode copied to clipboard

Possible metadata runtime issue

Open g5t opened this issue 11 months ago • 0 comments

The metadata_table_defined method is not used in the McStas/McXtrace runtime; but it could be used in a component to check if a specified {component name | component instance name}:{metadata name} key exists in the global metadata_table. It splits the provided key at the : (if it exists) and returns the number of entries in the table with matching part(s) -- if the key has no :, the key is interpreted as the source and the returned number is the number of METADATA entries provided from the source component definition or component instance specification.

The actual implementation avoids accessing a NULL key https://github.com/McStasMcXtrace/McCode/blob/7859d04849c7dbc0336e37001be6ceb65cea889a/common/lib/share/metadata-r.c#L34-L37

Since the combination (source, NULL) returns the number of source-defined entries, some users might expect that (NULL, NULL) should return the total number of defined entries.

Others might instead expect the shortcut case to return 0, since no entries match.


Desired outcome

A decision for which behavior is intended should be made. Following this, the function return should be better documented to aid component definition authors who may like to access stored METADATA.

g5t avatar Mar 20 '24 15:03 g5t