Add ColumnLimit: 80 and run clang-format #5

Merged
Letterus merged 1 commits from js/objgtkgen:column-limit into main 1 year ago
  1. 1
      src/.clang-format
  2. 26
      src/BaseClasses/OGTK.h
  3. 4
      src/BaseClasses/OGTKBase.h
  4. 21
      src/BaseClasses/OGTKBaseBuilder.h
  5. 27
      src/BaseClasses/OGTKBaseBuilder.m
  6. 6
      src/BaseClasses/OGTKCallbackData.h
  7. 3
      src/BaseClasses/OGTKCallbackData.m
  8. 9
      src/BaseClasses/OGTKSignalConnector.h
  9. 22
      src/BaseClasses/OGTKSignalConnector.m
  10. 3
      src/Exceptions/OGTKReceivedNilExpectedStringException.m
  11. 13
      src/GIR/GIRApi.m
  12. 17
      src/GIR/GIRBase.h
  13. 23
      src/GIR/GIRBase.m
  14. 37
      src/GIR/GIRClass.m
  15. 5
      src/GIR/GIRConstant.m
  16. 14
      src/GIR/GIRConstructor.m
  17. 5
      src/GIR/GIRDoc.m
  18. 23
      src/GIR/GIREnumeration.m
  19. 3
      src/GIR/GIRField.m
  20. 20
      src/GIR/GIRFunction.m
  21. 3
      src/GIR/GIRImplements.m
  22. 31
      src/GIR/GIRInterface.m
  23. 3
      src/GIR/GIRMember.m
  24. 57
      src/GIR/GIRMethod.h
  25. 17
      src/GIR/GIRMethod.m
  26. 32
      src/GIR/GIRNamespace.m
  27. 43
      src/GIR/GIRParameter.h
  28. 5
      src/GIR/GIRParameter.m
  29. 156
      src/GIR/GIRProperty.m
  30. 3
      src/GIR/GIRReturnValue.m
  31. 3
      src/GIR/GIRType.m
  32. 5
      src/GIR/GIRVarargs.m
  33. 9
      src/Generator/OFDictionary+JsonContentsOfFile.m
  34. 2
      src/Generator/OGTKClass.h
  35. 2
      src/Generator/OGTKClass.m
  36. 11
      src/Generator/OGTKClassWriter.h
  37. 133
      src/Generator/OGTKClassWriter.m
  38. 2
      src/Generator/OGTKMethod.h
  39. 39
      src/Generator/OGTKMethod.m
  40. 2
      src/Generator/OGTKParameter.h
  41. 2
      src/Generator/OGTKParameter.m
  42. 25
      src/Generator/OGTKUtil.h
  43. 66
      src/Generator/OGTKUtil.m
  44. 20
      src/Gir2Objc.h
  45. 31
      src/Gir2Objc.m
  46. 21
      src/ObjGTKGen.m
  47. 50
      src/Output/HelloWorld.m
  48. 3
      src/XMLReader/XMLReader.h
  49. 32
      src/XMLReader/XMLReader.m

@ -1,2 +1,3 @@
---
BasedOnStyle: WebKit
ColumnLimit: 80

@ -46,23 +46,23 @@
+ (OFString*)objGtkVersion;
/**
* Call this function before using any other GTK+ functions in your GUI
* applications. It will initialize everything needed to operate the toolkit and
* Call this function before using any other GTK+ functions in your GUI
* applications. It will initialize everything needed to operate the toolkit and
* parses some standard command line options.
*
* Although you are expected to pass the argc, argv parameters from main() to
* this function, it is possible to pass NULL if argv is not available or
* Although you are expected to pass the argc, argv parameters from main() to
* this function, it is possible to pass NULL if argv is not available or
* commandline handling is not required.
*
* argc and argv are adjusted accordingly so your own code will never see those
* argc and argv are adjusted accordingly so your own code will never see those
* standard arguments.
*
*
* @param argc
* Address of the argc parameter of your main() function (or 0 if argv is
* Address of the argc parameter of your main() function (or 0 if argv is
* NULL). This will be changed if any arguments were handled. [inout]
*
* @param argv
* Address of the argv parameter of main(), or NULL. Any options understood by
* Address of the argv parameter of main(), or NULL. Any options understood by
* GTK+ are stripped before return. [array length=argc][inout][allow-none]
*/
+ (void)initWithArgc:(int*)argc andArgv:(char***)argv;
@ -71,11 +71,11 @@
* Same as initWithArgc:andArgv: but does the type conversion automatically.
*
* @param argc
* Address of the argc parameter of your main() function (or 0 if argv is
* Address of the argc parameter of your main() function (or 0 if argv is
* NULL). This will be changed if any arguments were handled. [inout]
*
* @param argv
* Address of the argv parameter of main(), or NULL. Any options understood by
* Address of the argv parameter of main(), or NULL. Any options understood by
* GTK+ are stripped before return. [array length=argc][inout][allow-none]
*
* @returns modified argc value
@ -85,8 +85,8 @@
+ (int)autoInitWithArgc:(int)argc andArgv:(char*[])argv;
/**
* Runs the main loop until mainQuit is called.
* You can nest calls to main. In that case mainQuit will make the innermost
* Runs the main loop until mainQuit is called.
* You can nest calls to main. In that case mainQuit will make the innermost
* invocation of the main loop return.
*
* @see mainQuit
@ -94,7 +94,7 @@
+ (void)main;
/**
* Makes the innermost invocation of the main loop return when it regains
* Makes the innermost invocation of the main loop return when it regains
* control.
*/
+ (void)mainQuit;

@ -39,8 +39,8 @@
*/
@interface OGTKBase : OFObject {
/**
* The internal GtkObject pointer
*/
* The internal GtkObject pointer
*/
GObject* _gObject;
}

@ -43,17 +43,17 @@
+ (void)setDebug:(bool)debugEnabled;
/**
* Similar to the other connect signals functions, this takes a dictionary key'd
* on CallbackData objects (configured with class/selectors) and their
* Similar to the other connect signals functions, this takes a dictionary key'd
* on CallbackData objects (configured with class/selectors) and their
* associated signals as values and connects them accordingly.
*
* Example usage:
* OFDictionary *dict = [[OFDictionary alloc] initWithObjectsAndKeys:
* OFDictionary *dict = [[OFDictionary alloc] initWithObjectsAndKeys:
* [CallbackData withObject:[OGTK class] andSEL:@selector(endMainLoop)],
* @"mainQuit",
* @"mainQuit",
* [CallbackData withObject:button andSEL:@selector(clicked)],
* @"on_button1_activate",
* [CallbackData withObject:button andSEL:@selector(clicked)],
* @"on_button1_activate",
* [CallbackData withObject:button andSEL:@selector(clicked)],
* @"on_button2_clicked", nil];
*
* [builder connectSignalsToObjects:dict];
@ -64,10 +64,12 @@
* @param objectSignalDictionary
* A dictionary mapping CallbackData objects to OFString signal names
*/
+ (void)connectSignalsToObjectsWithBuilder:(OGTKBuilder*)builder andSignalDictionary:(OFDictionary*)objectSignalDictionary;
+ (void)connectSignalsToObjectsWithBuilder:(OGTKBuilder*)builder
andSignalDictionary:
(OFDictionary*)objectSignalDictionary;
/**
* Attempts to get the object witht he name returning it as a OGTKWidget. If the
* Attempts to get the object witht he name returning it as a OGTKWidget. If the
* object is not found or not compatible with OGTKWidget this will return nil.
*
*
@ -79,6 +81,7 @@
*
* @returns the OGTKWidget or nil
*/
+ (OGTKWidget*)getWidgetFromBuilder:(OGTKBuilder*)builder withName:(OFString*)name;
+ (OGTKWidget*)getWidgetFromBuilder:(OGTKBuilder*)builder
withName:(OFString*)name;
@end

@ -29,16 +29,20 @@
static bool OGTKBuilderDebugMode = false;
static void gtkbuilder_connect_signals_handler(GtkBuilder* builder, GObject* object, const gchar* signal_name, const gchar* handler_name, GObject* connect_object, GConnectFlags flags, gpointer user_data)
static void gtkbuilder_connect_signals_handler(GtkBuilder* builder,
GObject* object, const gchar* signal_name, const gchar* handler_name,
GObject* connect_object, GConnectFlags flags, gpointer user_data)
{
if (OGTKBuilderDebugMode) {
OFLog(@"Signal_name = %@", [OFString stringWithUTF8String:signal_name]);
OFLog(@"Handlers_name = %@", [OFString stringWithUTF8String:handler_name]);
OFLog(@"Handlers_name = %@",
[OFString stringWithUTF8String:handler_name]);
}
OFDictionary* objectSignalDictionary = (OFDictionary*)user_data;
id callbackData = [objectSignalDictionary objectForKey:[OFString stringWithUTF8String:handler_name]];
id callbackData = [objectSignalDictionary
objectForKey:[OFString stringWithUTF8String:handler_name]];
id obj = [callbackData object];
SEL sel = [callbackData sel];
@ -55,7 +59,12 @@ static void gtkbuilder_connect_signals_handler(GtkBuilder* builder, GObject* obj
}
// Connect to Objective-C method
[OGTKSignalConnector connectGpointer:object withSignal:[OFString stringWithUTF8String:signal_name] toTarget:obj withSelector:sel andData:NULL];
[OGTKSignalConnector
connectGpointer:object
withSignal:[OFString stringWithUTF8String:signal_name]
toTarget:obj
withSelector:sel
andData:NULL];
}
}
@ -66,12 +75,16 @@ static void gtkbuilder_connect_signals_handler(GtkBuilder* builder, GObject* obj
OGTKBuilderDebugMode = debugEnabled;
}
+ (void)connectSignalsToObjectsWithBuilder:(OGTKBuilder*)builder andSignalDictionary:(OFDictionary*)objectSignalDictionary;
+ (void)connectSignalsToObjectsWithBuilder:(OGTKBuilder*)builder
andSignalDictionary:
(OFDictionary*)objectSignalDictionary;
{
gtk_builder_connect_signals_full([builder BUILDER], &gtkbuilder_connect_signals_handler, objectSignalDictionary);
gtk_builder_connect_signals_full([builder BUILDER],
&gtkbuilder_connect_signals_handler, objectSignalDictionary);
}
+ (OGTKWidget*)getWidgetFromBuilder:(OGTKBuilder*)builder withName:(OFString*)name
+ (OGTKWidget*)getWidgetFromBuilder:(OGTKBuilder*)builder
withName:(OFString*)name
{
GObject* obj = gtk_builder_get_object([builder BUILDER], [name UTF8String]);

@ -36,7 +36,8 @@
}
/**
* Creates and returns a new instance of OGTKCallbackData holding the object and the selector.
* Creates and returns a new instance of OGTKCallbackData holding the object and
* the selector.
*
* Note this returned instance is autoreleased.
*
@ -51,7 +52,8 @@
+ (id)withObject:(id)obj andSEL:(SEL)sel;
/**
* Creates and returns a new instance of OGTKCallbackData holding the object and the selector.
* Creates and returns a new instance of OGTKCallbackData holding the object and
* the selector.
*
* @param obj
* The object to hold

@ -42,7 +42,8 @@
+ (id)withObject:(id)obj andSEL:(SEL)sel
{
return [[[OGTKCallbackData alloc] initWithObject:obj andSEL:sel] autorelease];
return [[[OGTKCallbackData alloc] initWithObject:obj
andSEL:sel] autorelease];
}
- (void)dealloc

@ -38,7 +38,8 @@ void gsignal_forwarder(gpointer gtk, OGTKSignalData* data);
}
/**
* Connects a GCallback function to a signal for a particular object. The GCallback function redirects the call to the Objective-C target and selector.
* Connects a GCallback function to a signal for a particular object. The
* GCallback function redirects the call to the Objective-C target and selector.
*
* @param object
* The instance to connect to
@ -57,6 +58,10 @@ void gsignal_forwarder(gpointer gtk, OGTKSignalData* data);
*
* @returns a new OGTKCallbackData
*/
+ (void)connectGpointer:(gpointer)object withSignal:(OFString*)name toTarget:(id)target withSelector:(SEL)selector andData:(gpointer)data;
+ (void)connectGpointer:(gpointer)object
withSignal:(OFString*)name
toTarget:(id)target
withSelector:(SEL)selector
andData:(gpointer)data;
@end

@ -37,15 +37,25 @@ void gsignal_forwarder(gpointer gtk, OGTKSignalData* data)
@implementation OGTKSignalConnector
+ (void)connectGpointer:(gpointer)object withSignal:(OFString*)name toTarget:(id)target withSelector:(SEL)selector andData:(gpointer)data
+ (void)connectGpointer:(gpointer)object
withSignal:(OFString*)name
toTarget:(id)target
withSelector:(SEL)selector
andData:(gpointer)data
{
/*
* Don't release this or else we could seg fault! (Note that to avoid memory leaks in the case of a short-lived GUI, the application should
* maintain references to the OGTKSignalData elsewhere and release it there when it is no longer needed.)
*/
OGTKSignalData* signalData = [[OGTKSignalData alloc] initWithTarget:(id)target selector:selector data:data];
* Don't release this or else we could seg fault! (Note that to avoid memory
* leaks in the case of a short-lived GUI, the application should maintain
* references to the OGTKSignalData elsewhere and release it there when it
* is no longer needed.)
*/
OGTKSignalData* signalData =
[[OGTKSignalData alloc] initWithTarget:(id)target
selector:selector
data:data];
g_signal_connect(object, [name UTF8String], G_CALLBACK(gsignal_forwarder), signalData);
g_signal_connect(
object, [name UTF8String], G_CALLBACK(gsignal_forwarder), signalData);
}
@end

@ -13,7 +13,8 @@
- (OFString*)description
{
return @"Wrong format: Received nil value as parameter but expected instance of OFString.";
return @"Wrong format: Received nil value as parameter but expected "
@"instance of OFString.";
}
@end

@ -57,19 +57,18 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"include"]
|| [key isEqual:@"xmlns:glib"]
|| [key isEqual:@"xmlns:c"]
|| [key isEqual:@"xmlns"]
|| [key isEqual:@"package"]) {
if ([key isEqual:@"text"] || [key isEqual:@"include"] ||
[key isEqual:@"xmlns:glib"] || [key isEqual:@"xmlns:c"] ||
[key isEqual:@"xmlns"] || [key isEqual:@"package"]) {
// Do nothing
} else if ([key isEqual:@"version"]) {
self.version = value;
} else if ([key isEqual:@"c:include"]) {
self.cInclude = value;
} else if ([key isEqual:@"namespace"]) {
[self processArrayOrDictionary:value withClass:[GIRNamespace class] andArray:namespaces];
[self processArrayOrDictionary:value
withClass:[GIRNamespace class]
andArray:namespaces];
} else {
[self logUnknownElement:key];
}

@ -30,12 +30,7 @@
/**
* The possible log levels
*/
typedef enum LogLevel {
Debug = 0,
Info = 1,
Warning = 2,
Error = 3
} LogLevel;
typedef enum LogLevel { Debug = 0, Info = 1, Warning = 2, Error = 3 } LogLevel;
@protocol GIRParseDictionary
- (void)parseDictionary:(OFDictionary*)dict;
@ -61,13 +56,17 @@ typedef enum LogLevel {
+ (void)log:(OFString*)message andLevel:(LogLevel)level;
/**
* When an unknown item is discovered this will log it iff it hasn't previously been logged
* When an unknown item is discovered this will log it iff it hasn't previously
* been logged
*/
- (void)logUnknownElement:(OFString*)element;
/**
* Extracts information from the array or dictionary (values) into the provided array using the provided class type
* Extracts information from the array or dictionary (values) into the provided
* array using the provided class type
*/
- (void)processArrayOrDictionary:(id)values withClass:(Class)clazz andArray:(OFMutableArray*)array;
- (void)processArrayOrDictionary:(id)values
withClass:(Class)clazz
andArray:(OFMutableArray*)array;
@end

@ -68,15 +68,17 @@ LogLevel _logLevel = Info;
- (void)parseDictionary:(OFDictionary*)dict
{
OF_UNRECOGNIZED_SELECTOR
OF_UNRECOGNIZED_SELECTOR
}
- (instancetype)initWithDictionary:(OFDictionary*)dict
{
OF_INVALID_INIT_METHOD
OF_INVALID_INIT_METHOD
}
- (void)processArrayOrDictionary:(id)values withClass:(Class)clazz andArray:(OFMutableArray*)array;
- (void)processArrayOrDictionary:(id)values
withClass:(Class)clazz
andArray:(OFMutableArray*)array;
{
// If the values are a dictionary call it directly
if ([values isKindOfClass:[OFDictionary class]]) {
@ -88,7 +90,9 @@ LogLevel _logLevel = Info;
}
} else if ([values isKindOfClass:[OFArray class]]) {
for (id object in values) {
[self processArrayOrDictionary:object withClass:clazz andArray:array];
[self processArrayOrDictionary:object
withClass:clazz
andArray:array];
}
} else
@throw [OFInvalidArgumentException exception];
@ -100,12 +104,17 @@ LogLevel _logLevel = Info;
self.unknownElements = [[OFMutableDictionary alloc] init];
}
OFString* hopefullyUniqueKey = [OFString stringWithFormat:@"%@--%@", self.elementTypeName, element];
OFString* hopefullyUniqueKey =
[OFString stringWithFormat:@"%@--%@", self.elementTypeName, element];
if ([self.unknownElements objectForKey:hopefullyUniqueKey] != nil) {
[self.unknownElements setObject:hopefullyUniqueKey forKey:hopefullyUniqueKey];
[self.unknownElements setObject:hopefullyUniqueKey
forKey:hopefullyUniqueKey];
} else {
[GIRBase log:[OFString stringWithFormat:@"[%@]: Found unknown element: [%@]", self.elementTypeName, element] andLevel:Warning];
[GIRBase log:[OFString
stringWithFormat:@"[%@]: Found unknown element: [%@]",
self.elementTypeName, element]
andLevel:Warning];
}
}

@ -75,12 +75,9 @@
id value = [dict objectForKey:key];
// TODO: Do we need signal?
if ([key isEqual:@"text"]
|| [key isEqual:@"glib:type-name"]
|| [key isEqual:@"glib:type-struct"]
|| [key isEqual:@"glib:get-type"]
|| [key isEqual:@"glib:signal"]
|| [key isEqual:@"source-position"]
if ([key isEqual:@"text"] || [key isEqual:@"glib:type-name"] ||
[key isEqual:@"glib:type-struct"] || [key isEqual:@"glib:get-type"]
|| [key isEqual:@"glib:signal"] || [key isEqual:@"source-position"]
|| [key isEqual:@"signal"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
@ -98,19 +95,33 @@
} else if ([key isEqual:@"doc"]) {
self.doc = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"constructor"]) {
[self processArrayOrDictionary:value withClass:[GIRConstructor class] andArray:constructors];
[self processArrayOrDictionary:value
withClass:[GIRConstructor class]
andArray:constructors];
} else if ([key isEqual:@"field"]) {
[self processArrayOrDictionary:value withClass:[GIRField class] andArray:fields];
[self processArrayOrDictionary:value
withClass:[GIRField class]
andArray:fields];
} else if ([key isEqual:@"method"]) {
[self processArrayOrDictionary:value withClass:[GIRMethod class] andArray:methods];
[self processArrayOrDictionary:value
withClass:[GIRMethod class]
andArray:methods];
} else if ([key isEqual:@"virtual-method"]) {
[self processArrayOrDictionary:value withClass:[GIRVirtualMethod class] andArray:virtualMethods];
[self processArrayOrDictionary:value
withClass:[GIRVirtualMethod class]
andArray:virtualMethods];
} else if ([key isEqual:@"property"]) {
[self processArrayOrDictionary:value withClass:[GIRProperty class] andArray:properties];
[self processArrayOrDictionary:value
withClass:[GIRProperty class]
andArray:properties];
} else if ([key isEqual:@"implements"]) {
[self processArrayOrDictionary:value withClass:[GIRImplements class] andArray:implements];
[self processArrayOrDictionary:value
withClass:[GIRImplements class]
andArray:implements];
} else if ([key isEqual:@"function"]) {
[self processArrayOrDictionary:value withClass:[GIRFunction class] andArray:functions];
[self processArrayOrDictionary:value
withClass:[GIRFunction class]
andArray:functions];
} else {
[self logUnknownElement:key];
}

@ -62,9 +62,8 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"type"]
|| [key isEqual:@"source-position"]) {
if ([key isEqual:@"text"] || [key isEqual:@"type"] ||
[key isEqual:@"source-position"]) {
// Do nothing
} else if ([key isEqual:@"c:type"]) {
self.cType = value;

@ -68,8 +68,7 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"source-position"]) {
if ([key isEqual:@"text"] || [key isEqual:@"source-position"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;
@ -94,13 +93,18 @@
} else if ([key isEqual:@"doc-deprecated"]) {
self.doc = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"return-value"]) {
self.returnValue = [[GIRReturnValue alloc] initWithDictionary:value];
self.returnValue =
[[GIRReturnValue alloc] initWithDictionary:value];
} else if ([key isEqual:@"parameters"]) {
for (OFString* paramKey in value) {
if ([paramKey isEqual:@"parameter"]) {
[self processArrayOrDictionary:[value objectForKey:paramKey] withClass:[GIRParameter class] andArray:parameters];
[self processArrayOrDictionary:[value objectForKey:paramKey]
withClass:[GIRParameter class]
andArray:parameters];
} else if ([paramKey isEqual:@"instance-parameter"]) {
[self processArrayOrDictionary:[value objectForKey:paramKey] withClass:[GIRParameter class] andArray:instanceParameters];
[self processArrayOrDictionary:[value objectForKey:paramKey]
withClass:[GIRParameter class]
andArray:instanceParameters];
}
}
} else {

@ -56,9 +56,8 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"filename"] ||
[key isEqual:@"line"]) {
// do nothing - suppress warning
if ([key isEqual:@"filename"] || [key isEqual:@"line"]) {
// do nothing - suppress warning
} else if ([key isEqual:@"text"]) {
self.docText = value;
} else if ([key isEqual:@"xml:space"]) {

@ -43,9 +43,9 @@
{
self = [super init];
self.elementTypeName = @"GIREnumeration";
self.members = [[OFMutableArray alloc] init];
self.functions = [[OFMutableArray alloc] init];
self.elementTypeName = @"GIREnumeration";
self.members = [[OFMutableArray alloc] init];
self.functions = [[OFMutableArray alloc] init];
return self;
}
@ -54,7 +54,7 @@
{
self = [self init];
[self parseDictionary:dict];
[self parseDictionary:dict];
return self;
}
@ -64,10 +64,9 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"glib:type-name"]
|| [key isEqual:@"glib:get-type"]
|| [key isEqual:@"glib:error-domain"]) {
if ([key isEqual:@"text"] || [key isEqual:@"glib:type-name"] ||
[key isEqual:@"glib:get-type"] ||
[key isEqual:@"glib:error-domain"]) {
// Do nothing
} else if ([key isEqual:@"c:type"]) {
self.cType = value;
@ -84,9 +83,13 @@
} else if ([key isEqual:@"doc-deprecated"]) {
self.docDeprecated = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"member"]) {
[self processArrayOrDictionary:value withClass:[GIRMember class] andArray:members];
[self processArrayOrDictionary:value
withClass:[GIRMember class]
andArray:members];
} else if ([key isEqual:@"function"]) {
[self processArrayOrDictionary:value withClass:[GIRFunction class] andArray:functions];
[self processArrayOrDictionary:value
withClass:[GIRFunction class]
andArray:functions];
} else {
[self logUnknownElement:key];
}

@ -59,8 +59,7 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"doc"]) {
if ([key isEqual:@"text"] || [key isEqual:@"doc"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;

@ -47,9 +47,9 @@
{
self = [super init];
elementTypeName = @"GIRFunction";
parameters = [OFMutableArray array];
instanceParameters = [OFMutableArray array];
elementTypeName = @"GIRFunction";
parameters = [OFMutableArray array];
instanceParameters = [OFMutableArray array];
return self;
}
@ -68,8 +68,7 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"] ||
[key isEqual:@"source-position"]) {
if ([key isEqual:@"text"] || [key isEqual:@"source-position"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;
@ -92,13 +91,18 @@
} else if ([key isEqual:@"doc"]) {
self.doc = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"return-value"]) {
self.returnValue = [[GIRReturnValue alloc] initWithDictionary:value];
self.returnValue =
[[GIRReturnValue alloc] initWithDictionary:value];
} else if ([key isEqual:@"parameters"]) {
for (OFString* paramKey in value) {
if ([paramKey isEqual:@"parameter"]) {
[self processArrayOrDictionary:[value objectForKey:paramKey] withClass:[GIRParameter class] andArray:parameters];
[self processArrayOrDictionary:[value objectForKey:paramKey]
withClass:[GIRParameter class]
andArray:parameters];
} else if ([paramKey isEqual:@"instance-parameter"]) {
[self processArrayOrDictionary:[value objectForKey:paramKey] withClass:[GIRParameter class] andArray:instanceParameters];
[self processArrayOrDictionary:[value objectForKey:paramKey]
withClass:[GIRParameter class]
andArray:instanceParameters];
}
}
} else {

@ -54,8 +54,7 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"type"]) {
if ([key isEqual:@"text"] || [key isEqual:@"type"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;

@ -66,14 +66,10 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"glib:type-name"]
|| [key isEqual:@"glib:type-struct"]
|| [key isEqual:@"glib:signal"]
|| [key isEqual:@"glib:get-type"]
|| [key isEqual:@"source-position"]
|| [key isEqual:@"version"]
|| [key isEqual:@"signal"]) {
if ([key isEqual:@"text"] || [key isEqual:@"glib:type-name"] ||
[key isEqual:@"glib:type-struct"] || [key isEqual:@"glib:signal"] ||
[key isEqual:@"glib:get-type"] || [key isEqual:@"source-position"]
|| [key isEqual:@"version"] || [key isEqual:@"signal"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;
@ -84,15 +80,24 @@
} else if ([key isEqual:@"doc"]) {
self.doc = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"fields"]) {
[self processArrayOrDictionary:value withClass:[GIRField class] andArray:fields];
[self processArrayOrDictionary:value
withClass:[GIRField class]
andArray:fields];
} else if ([key isEqual:@"method"]) {
[self processArrayOrDictionary:value withClass:[GIRMethod class] andArray:methods];
[self processArrayOrDictionary:value
withClass:[GIRMethod class]
andArray:methods];
} else if ([key isEqual:@"virtual-method"]) {
[self processArrayOrDictionary:value withClass:[GIRVirtualMethod class] andArray:virtualMethods];
[self processArrayOrDictionary:value
withClass:[GIRVirtualMethod class]
andArray:virtualMethods];
} else if ([key isEqual:@"property"]) {
[self processArrayOrDictionary:value withClass:[GIRProperty class] andArray:properties];
[self processArrayOrDictionary:value
withClass:[GIRProperty class]
andArray:properties];
} else if ([key isEqual:@"prerequisite"]) {
self.prerequisite = [[GIRPrerequisite alloc] initWithDictionary:value];
self.prerequisite =
[[GIRPrerequisite alloc] initWithDictionary:value];
} else {
[self logUnknownElement:key];
}

@ -57,8 +57,7 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"glib:nick"]) {
if ([key isEqual:@"text"] || [key isEqual:@"glib:nick"]) {
// Do nothing
} else if ([key isEqual:@"c:identifier"]) {
self.cIdentifier = value;

@ -28,45 +28,44 @@
#import <ObjFW/ObjFW.h>
#import "GIRBase.h"
#import "GIRDoc.h"
#import "GIRParameter.h"
#import "GIRReturnValue.h"
#import "GIRDoc.h"
@interface GIRMethod : GIRBase
{
OFString *name;
OFString *cIdentifier;
OFString *version;
OFString *invoker;
GIRReturnValue *returnValue;
GIRDoc *doc;
GIRDoc *docDeprecated;
bool deprecated;
OFString *deprecatedVersion;
bool throws;
bool introspectable;
bool shadowedBy;
bool shadows;
OFMutableArray *parameters;
OFMutableArray *instanceParameters;
@interface GIRMethod : GIRBase {
OFString* name;
OFString* cIdentifier;
OFString* version;
OFString* invoker;
GIRReturnValue* returnValue;
GIRDoc* doc;
GIRDoc* docDeprecated;
bool deprecated;
OFString* deprecatedVersion;
bool throws;
bool introspectable;
bool shadowedBy;
bool shadows;
OFMutableArray* parameters;
OFMutableArray* instanceParameters;
}
@property (nonatomic, copy) OFString *name;
@property (nonatomic, copy) OFString *cIdentifier;
@property (nonatomic, copy) OFString *version;
@property (nonatomic, retain) GIRReturnValue *returnValue;
@property (nonatomic, retain) GIRDoc *doc;
@property (nonatomic, retain) GIRDoc *docDeprecated;
@property (nonatomic, copy) OFString *deprecatedVersion;
@property (nonatomic, copy) OFString *invoker;
@property (nonatomic, copy) OFString* name;
@property (nonatomic, copy) OFString* cIdentifier;
@property (nonatomic, copy) OFString* version;
@property (nonatomic, retain) GIRReturnValue* returnValue;
@property (nonatomic, retain) GIRDoc* doc;
@property (nonatomic, retain) GIRDoc* docDeprecated;
@property (nonatomic, copy) OFString* deprecatedVersion;
@property (nonatomic, copy) OFString* invoker;
@property (nonatomic) bool deprecated;
@property (nonatomic) bool throws;
@property (nonatomic) bool introspectable;
@property (nonatomic) bool shadowedBy;
@property (nonatomic) bool shadows;
@property (nonatomic, retain) OFMutableArray *parameters;
@property (nonatomic, retain) OFMutableArray *instanceParameters;
@property (nonatomic, retain) OFMutableArray* parameters;
@property (nonatomic, retain) OFMutableArray* instanceParameters;
-(bool)tryParseWithKey:(OFString *)key andValue:(id)value;
- (bool)tryParseWithKey:(OFString*)key andValue:(id)value;
@end

@ -49,9 +49,9 @@
{
self = [super init];
elementTypeName = @"GIRMethod";
parameters = [OFMutableArray array];
instanceParameters = [OFMutableArray array];
elementTypeName = @"GIRMethod";
parameters = [OFMutableArray array];
instanceParameters = [OFMutableArray array];
return self;
}
@ -78,8 +78,7 @@
- (bool)tryParseWithKey:(OFString*)key andValue:(id)value
{
if ([key isEqual:@"text"]
|| [key isEqual:@"source-position"]) {
if ([key isEqual:@"text"] || [key isEqual:@"source-position"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;
@ -110,9 +109,13 @@
} else if ([key isEqual:@"parameters"]) {
for (OFString* paramKey in value) {
if ([paramKey isEqual:@"parameter"]) {
[self processArrayOrDictionary:[value objectForKey:paramKey] withClass:[GIRParameter class] andArray:parameters];
[self processArrayOrDictionary:[value objectForKey:paramKey]
withClass:[GIRParameter class]
andArray:parameters];
} else if ([paramKey isEqual:@"instance-parameter"]) {
[self processArrayOrDictionary:[value objectForKey:paramKey] withClass:[GIRParameter class] andArray:instanceParameters];
[self processArrayOrDictionary:[value objectForKey:paramKey]
withClass:[GIRParameter class]
andArray:instanceParameters];
}
}
} else {

@ -66,14 +66,10 @@
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]
|| [key isEqual:@"shared-library"]
|| [key isEqual:@"version"]
|| [key isEqual:@"record"]
|| [key isEqual:@"callback"]
|| [key isEqual:@"bitfield"]
|| [key isEqual:@"alias"]
|| [key isEqual:@"function-macro"]) {
if ([key isEqual:@"text"] || [key isEqual:@"shared-library"] ||
[key isEqual:@"version"] || [key isEqual:@"record"] ||
[key isEqual:@"callback"] || [key isEqual:@"bitfield"] ||
[key isEqual:@"alias"] || [key isEqual:@"function-macro"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;
@ -82,15 +78,25 @@
} else if ([key isEqual:@"c:identifier-prefixes"]) {
self.cIdentifierPrefixes = value;
} else if ([key isEqual:@"class"]) {
[self processArrayOrDictionary:value withClass:[GIRClass class] andArray:classes];
[self processArrayOrDictionary:value
withClass:[GIRClass class]
andArray:classes];
} else if ([key isEqual:@"function"]) {
[self processArrayOrDictionary:value withClass:[GIRFunction class] andArray:functions];
[self processArrayOrDictionary:value
withClass:[GIRFunction class]
andArray:functions];
} else if ([key isEqual:@"enumeration"]) {
[self processArrayOrDictionary:value withClass:[GIREnumeration class] andArray:enumerations];
[self processArrayOrDictionary:value
withClass:[GIREnumeration class]
andArray:enumerations];
} else if ([key isEqual:@"constant"]) {
[self processArrayOrDictionary:value withClass:[GIRConstant class] andArray:constants];
[self processArrayOrDictionary:value
withClass:[GIRConstant class]
andArray:constants];
} else if ([key isEqual:@"interface"]) {
[self processArrayOrDictionary:value withClass:[GIRInterface class] andArray:interfaces];
[self processArrayOrDictionary:value
withClass:[GIRInterface class]
andArray:interfaces];
} else {
[self logUnknownElement:key];
}

@ -33,33 +33,32 @@
#import "GIRType.h"
#import "GIRVarargs.h"
@interface GIRParameter : GIRBase
{
OFString *name;
OFString *transferOwnership;
OFString *direction;
OFString *scope;
bool allowNone;
bool callerAllocates;
long closure;
long destroy;
GIRDoc *doc;
GIRType *type;
GIRArray *array;
GIRVarargs *varargs;
@interface GIRParameter : GIRBase {
OFString* name;
OFString* transferOwnership;
OFString* direction;
OFString* scope;
bool allowNone;
bool callerAllocates;
long closure;
long destroy;
GIRDoc* doc;
GIRType* type;
GIRArray* array;
GIRVarargs* varargs;
}
@property (nonatomic, retain) OFString *name;
@property (nonatomic, retain) OFString *transferOwnership;
@property (nonatomic, retain) OFString *direction;
@property (nonatomic, retain) OFString *scope;
@property (nonatomic, retain) OFString* name;
@property (nonatomic, retain) OFString* transferOwnership;
@property (nonatomic, retain) OFString* direction;
@property (nonatomic, retain) OFString* scope;
@property (nonatomic) bool allowNone;
@property (nonatomic) bool callerAllocates;
@property (nonatomic) long closure;
@property (nonatomic) long destroy;
@property (nonatomic, retain) GIRDoc *doc;
@property (nonatomic, retain) GIRType *type;
@property (nonatomic, retain) GIRArray *array;
@property (nonatomic, retain) GIRVarargs *varargs;
@property (nonatomic, retain) GIRDoc* doc;
@property (nonatomic, retain) GIRType* type;
@property (nonatomic, retain) GIRArray* array;
@property (nonatomic, retain) GIRVarargs* varargs;
@end

@ -66,9 +66,8 @@
id value = [dict objectForKey:key];
// TODO: Check if we need nullable or optional
if ([key isEqual:@"text"]
|| [key isEqual:@"nullable"]
|| [key isEqual:@"optional"]) {
if ([key isEqual:@"text"] || [key isEqual:@"nullable"] ||
[key isEqual:@"optional"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;

@ -47,110 +47,78 @@
@synthesize writable;
@synthesize array;
-(id)init
- (id)init
{
self = [super init];
self.elementTypeName = @"GIRProperty";
return self;
self = [super init];
self.elementTypeName = @"GIRProperty";
return self;
}
-(id)initWithDictionary:(OFDictionary *) dict
- (id)initWithDictionary:(OFDictionary*)dict
{
self = [self init];
[self parseDictionary:dict];
return self;
self = [self init];
[self parseDictionary:dict];
return self;
}
-(void)parseDictionary:(OFDictionary *) dict
- (void)parseDictionary:(OFDictionary*)dict
{
for (OFString *key in dict)
{
id value = [dict objectForKey:key];
if([key isEqual:@"text"])
{
// Do nothing
}
else if([key isEqual:@"name"])
{
self.name = value;
}
else if([key isEqual:@"transfer-ownership"])
{
self.transferOwnership = value;
}
else if([key isEqual:@"version"])
{
self.version = value;
}
else if([key isEqual:@"deprecated-version"])
{
self.deprecatedVersion = value;
}
else if([key isEqual:@"doc"])
{
self.doc = [[GIRDoc alloc] initWithDictionary:value];
}
else if([key isEqual:@"doc-deprecated"])
{
self.docDeprecated = [[GIRDoc alloc] initWithDictionary:value];
}
else if([key isEqual:@"type"])
{
self.type = [[GIRType alloc] initWithDictionary:value];
}
else if([key isEqual:@"allow-none"])
{
self.allowNone = [value isEqual:@"1"];
}
else if([key isEqual:@"construct-only"])
{
self.constructOnly = [value isEqual:@"1"];
}
else if([key isEqual:@"readable"])
{
self.readable = [value isEqual:@"1"];
}
else if([key isEqual:@"deprecated"])
{
self.deprecated = [value isEqual:@"1"];
}
else if([key isEqual:@"construct"])
{
self.construct = value;
}
else if([key isEqual:@"writable"])
{
self.writable = value;
}
else if([key isEqual:@"array"])
{
self.array = [[GIRArray alloc] initWithDictionary:value];
}
else
{
[self logUnknownElement:key];
}
}
for (OFString* key in dict) {
id value = [dict objectForKey:key];
if ([key isEqual:@"text"]) {
// Do nothing
} else if ([key isEqual:@"name"]) {
self.name = value;
} else if ([key isEqual:@"transfer-ownership"]) {
self.transferOwnership = value;
} else if ([key isEqual:@"version"]) {
self.version = value;
} else if ([key isEqual:@"deprecated-version"]) {
self.deprecatedVersion = value;
} else if ([key isEqual:@"doc"]) {
self.doc = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"doc-deprecated"]) {
self.docDeprecated = [[GIRDoc alloc] initWithDictionary:value];
} else if ([key isEqual:@"type"]) {
self.type = [[GIRType alloc] initWithDictionary:value];
} else if ([key isEqual:@"allow-none"]) {
self.allowNone = [value isEqual:@"1"];
} else if ([key isEqual:@"construct-only"]) {
self.constructOnly = [value isEqual:@"1"];
} else if ([key isEqual:@"readable"]) {
self.readable = [value isEqual:@"1"];
} else if ([key isEqual:@"deprecated"]) {
self.deprecated = [value isEqual:@"1"];
} else if ([key isEqual:@"construct"]) {
self.construct = value;
} else if ([key isEqual:@"writable"]) {
self.writable = value;
} else if ([key isEqual:@"array"]) {
self.array = [[GIRArray alloc] initWithDictionary:value];
} else {
[self logUnknownElement:key];
}
}
}
-(void)dealloc
- (void)dealloc
{
[name release];
[transferOwnership release];
[version release];
[deprecatedVersion release];
[doc release];
[docDeprecated release];
[type release];
[construct release];
[writable release];
[array release];
[super dealloc];
[name release];
[transferOwnership release];
[version release];
[deprecatedVersion release];
[doc release];
[docDeprecated release];
[type release];
[construct release];
[writable release];
[array release];
[super dealloc];
}
@end

@ -58,8 +58,7 @@
id value = [dict objectForKey:key];
// TODO: Do we nee nullable?
if (