mirror of
				https://github.com/Ryujinx/GtkSharp.git
				synced 2025-11-04 13:04:53 +00:00 
			
		
		
		
	generator: Add validation check for return values that are arrays
When a C function returns an array, we need to be able to determine its length. This is done either through a parameter to that function, or because the array is null-terminated. If we don't know about either of those, we print out a warning and fail the validation for the return value. This means the corresponding method will not be generated. This fixes a crash when trying to generate a method for which this information is missing. This wasn't a problem until now because the parser doesn't handle array return values, so they were always handled through fix-ups. But now we can get a GAPI XML converted from GIR which contains the "array" attribute for a return value but no other information.
This commit is contained in:
		
							parent
							
								
									c3b3036441
								
							
						
					
					
						commit
						4f29defd5c
					
				| 
						 | 
				
			
			@ -182,6 +182,11 @@ namespace GtkSharp.Generation {
 | 
			
		|||
			} else if ((CSType == "GLib.List" || CSType == "GLib.SList") && String.IsNullOrEmpty (ElementType))
 | 
			
		||||
				log.Warn ("Returns {0} with unknown element type.  Add element_type attribute with gapi-fixup.", CType);
 | 
			
		||||
 | 
			
		||||
			if (is_array && !is_null_term && String.IsNullOrEmpty (array_length_param)) {
 | 
			
		||||
				log.Warn ("Returns an array with undeterminable length. Add null_term_array or array_length_param attribute with gapi-fixup.");
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue