2016-11-25 18:26:40 +01:00
|
|
|
## vim: filetype=makopython
|
|
|
|
|
|
|
|
|
|
@classmethod
|
2019-12-05 15:33:50 +01:00
|
|
|
def for_project(cls, project_file, project=None, scenario_vars=None,
|
|
|
|
|
target=None, runtime=None):
|
2018-04-04 15:40:29 +02:00
|
|
|
${py_doc('libadalang.create_project_unit_provider', 8)}
|
2016-11-25 18:26:40 +01:00
|
|
|
|
2022-10-17 12:51:45 +00:00
|
|
|
prj = GPRProject(project_file, scenario_vars, target, runtime,
|
|
|
|
|
print_errors=False)
|
2022-07-06 08:30:42 +00:00
|
|
|
return prj.create_unit_provider(project)
|
2018-04-04 15:46:21 +02:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def auto(cls, input_files, charset=None):
|
|
|
|
|
${py_doc('libadalang.create_auto_provider', 8)}
|
|
|
|
|
|
|
|
|
|
# Create a NULL-terminated array of strings
|
2019-11-28 11:31:37 +01:00
|
|
|
c_strings = [
|
2022-11-02 15:08:20 +00:00
|
|
|
ctypes.c_char_p(_coerce_bytes('input_files', f,
|
|
|
|
|
'a list of bytes strings'))
|
2019-11-28 11:31:37 +01:00
|
|
|
for f in input_files
|
|
|
|
|
]
|
2018-04-04 15:46:21 +02:00
|
|
|
c_array_type = ctypes.c_char_p * (len(input_files) + 1)
|
|
|
|
|
c_array = c_array_type()
|
|
|
|
|
for i, c_str in enumerate(c_strings):
|
|
|
|
|
c_array[i] = c_str
|
|
|
|
|
c_array[-1] = None
|
|
|
|
|
|
|
|
|
|
c_array_ptr = ctypes.pointer(c_array)
|
|
|
|
|
input_files_arg = ctypes.cast(c_array_ptr,
|
|
|
|
|
ctypes.POINTER(ctypes.c_char_p))
|
2022-11-02 15:10:31 +00:00
|
|
|
|
|
|
|
|
c_charset = _unwrap_charset(charset)
|
|
|
|
|
|
|
|
|
|
c_value = _create_auto_provider(input_files_arg, c_charset)
|
2026-01-07 08:50:02 +00:00
|
|
|
return _CUnitProvider(c_value)
|