@@ -68,6 +68,20 @@ struct PluginConfigTVOS {
6868
6969 inline static const char * PLIST_SECTION = "plist ";
7070
71+ enum PlistItemType {
72+ UNKNOWN ,
73+ STRING ,
74+ INTEGER ,
75+ BOOLEAN ,
76+ RAW ,
77+ STRING_INPUT ,
78+ };
79+
80+ struct PlistItem {
81+ PlistItemType type ;
82+ String value ;
83+ };
84+
7185 // Set to true when the config file is properly loaded.
7286 bool valid_config = false;
7387 bool supports_targets = false;
@@ -91,8 +105,10 @@ struct PluginConfigTVOS {
91105 Vector < String > linker_flags ;
92106
93107 // Optional plist section
94- // Supports only string types for now
95- HashMap < String , String > plist ;
108+ // String value is default value.
109+ // Currently supports `string`, `boolean`, `integer`, `raw`, `string_input` types
110+ // <name>:<type> = <value>
111+ HashMap < String , PlistItem > plist ;
96112};
97113
98114static inline String resolve_local_dependency_path (String plugin_config_dir , String dependency_path ) {
@@ -233,6 +249,8 @@ static inline PluginConfigTVOS load_plugin_config(Ref<ConfigFile> config_file, c
233249 return plugin_config ;
234250 }
235251
252+ config_file -> clear ();
253+
236254 Error err = config_file -> load (path );
237255
238256 if (err != OK ) {
@@ -270,13 +288,68 @@ static inline PluginConfigTVOS load_plugin_config(Ref<ConfigFile> config_file, c
270288 config_file -> get_section_keys (PluginConfigTVOS ::PLIST_SECTION , & keys );
271289
272290 for (int i = 0 ; i < keys .size (); i ++ ) {
273- String value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
291+ Vector < String > key_components = keys [i ].split (":" );
292+
293+ String key_value = "" ;
294+ PluginConfigTVOS ::PlistItemType key_type = PluginConfigTVOS ::PlistItemType ::UNKNOWN ;
295+
296+ if (key_components .size () == 1 ) {
297+ key_value = key_components [0 ];
298+ key_type = PluginConfigTVOS ::PlistItemType ::STRING ;
299+ } else if (key_components .size () == 2 ) {
300+ key_value = key_components [0 ];
301+
302+ if (key_components [1 ].to_lower () == "string" ) {
303+ key_type = PluginConfigTVOS ::PlistItemType ::STRING ;
304+ } else if (key_components [1 ].to_lower () == "integer" ) {
305+ key_type = PluginConfigTVOS ::PlistItemType ::INTEGER ;
306+ } else if (key_components [1 ].to_lower () == "boolean" ) {
307+ key_type = PluginConfigTVOS ::PlistItemType ::BOOLEAN ;
308+ } else if (key_components [1 ].to_lower () == "raw" ) {
309+ key_type = PluginConfigTVOS ::PlistItemType ::RAW ;
310+ } else if (key_components [1 ].to_lower () == "string_input" ) {
311+ key_type = PluginConfigTVOS ::PlistItemType ::STRING_INPUT ;
312+ }
313+ }
274314
275- if (value .is_empty ()) {
315+ if (key_value .is_empty () || key_type == PluginConfigTVOS :: PlistItemType :: UNKNOWN ) {
276316 continue ;
277317 }
278318
279- plugin_config .plist [keys [i ]] = value ;
319+ String value ;
320+
321+ switch (key_type ) {
322+ case PluginConfigTVOS ::PlistItemType ::STRING : {
323+ String raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
324+ value = "<string>" + raw_value + "</string>" ;
325+ } break ;
326+ case PluginConfigTVOS ::PlistItemType ::INTEGER : {
327+ int raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], 0 );
328+ Dictionary value_dictionary ;
329+ String value_format = "<integer>$value</integer>" ;
330+ value_dictionary ["value" ] = raw_value ;
331+ value = value_format .format (value_dictionary , "$_" );
332+ } break ;
333+ case PluginConfigTVOS ::PlistItemType ::BOOLEAN :
334+ if (config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], false)) {
335+ value = "<true/>" ;
336+ } else {
337+ value = "<false/>" ;
338+ }
339+ break ;
340+ case PluginConfigTVOS ::PlistItemType ::RAW : {
341+ String raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
342+ value = raw_value ;
343+ } break ;
344+ case PluginConfigTVOS ::PlistItemType ::STRING_INPUT : {
345+ String raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
346+ value = raw_value ;
347+ } break ;
348+ default :
349+ continue ;
350+ }
351+
352+ plugin_config .plist [key_value ] = PluginConfigTVOS ::PlistItem { key_type , value };
280353 }
281354 }
282355
0 commit comments