diff --git a/lib/ffi/openmpt/api.rb b/lib/ffi/openmpt/api.rb index 59075c0..577fee7 100644 --- a/lib/ffi/openmpt/api.rb +++ b/lib/ffi/openmpt/api.rb @@ -78,6 +78,9 @@ module API # Informational/error module calls attach_function :openmpt_module_get_duration_seconds, [:pointer], :double + attach_function :openmpt_module_get_metadata_keys, [:pointer], :pointer + attach_function :openmpt_module_get_metadata, + [:pointer, :string], :pointer attach_function :openmpt_module_error_get_last, [:pointer], :int attach_function :openmpt_module_error_set_last, [:pointer, :int], :void attach_function :openmpt_module_error_get_last_message, diff --git a/test/openmpt_api_test.rb b/test/openmpt_api_test.rb index 113f294..728f568 100644 --- a/test/openmpt_api_test.rb +++ b/test/openmpt_api_test.rb @@ -111,6 +111,23 @@ def test_module_get_duration end end + def test_module_metadata + module_test(MOD_LAST_SUN) do |mod| + keys = openmpt_module_get_metadata_keys(mod) + refute_equal keys.read_string, '' + assert keys.read_string.include?(';') + openmpt_free_string(keys) + + data = openmpt_module_get_metadata(mod, 'type') + assert_equal data.read_string, 'mod' + openmpt_free_string(data) + + data = openmpt_module_get_metadata(mod, 'xxxx') + assert_equal data.read_string, '' + openmpt_free_string(data) + end + end + def test_get_set_module_errors module_test(MOD_LAST_SUN) do |mod| errno = openmpt_module_error_get_last(mod)