Files
libadalang/extensions/python_api/analysis_context_class
Pierre-Marie de Rodat 6839152cb8 Libadalang.Config_Pragmas: rework the API not to force parsing
Data types in this API store analysis units directly.

This means that in order to create the config pragmas mapping for a
given project, all sources of that project + for the config pragmas
files need to be parsed. For cases like opening a project in order to
analyze only a couple of source files, this is very inefficient, both
for processing time and for memory consumption.

This commit reworks the data types to avoid this: store filenames
instead of analysis units.
2025-11-27 15:55:28 +00:00

31 lines
1.0 KiB
Plaintext

## vim: filetype=makopython
def set_config_pragmas_mapping(
self,
global_pragmas: Opt[AnyStr] = None,
local_pragmas: Opt[Dict[AnyStr, AnyStr]] = None,
):
${py_doc("libadalang.set_config_pragmas_mapping", 8)}
global_c = _unwrap_filename(global_pragmas)
local_mapping = []
if local_pragmas is not None:
for key, value in local_pragmas.items():
local_mapping += [
_unwrap_filename(key), _unwrap_filename(value)
]
local_mapping.append(None)
local_c_type = ctypes.c_char_p * len(local_mapping)
local_c = local_c_type()
for i, u in enumerate(local_mapping):
local_c[i] = u
_set_config_pragmas_mapping(self._c_value, global_c, local_c)
def set_target_information(self, target_info: TargetInformation) -> None:
${py_doc("libadalang.target_info_set", 8)}
assert isinstance(target_info, TargetInformation)
TargetInformation._c_set(self._c_value, target_info._c_value)