Skip to content

Commit

Permalink
Follow memory management rules in AddressBook (#435) and fix AddressB…
Browse files Browse the repository at this point in the history
…ook bugs (#444, #675).
  • Loading branch information
BlueRiverInteractive committed Feb 5, 2015
1 parent 6e97d23 commit 29e8dd1
Show file tree
Hide file tree
Showing 19 changed files with 520 additions and 367 deletions.
100 changes: 67 additions & 33 deletions cocoatouch/src/main/bro-gen/addressbook.yaml
Expand Up @@ -75,10 +75,11 @@ functions:
ABAddressBook(Create)WithOptions: ABAddressBook(Create)WithOptions:
class: ABAddressBook class: ABAddressBook
name: '#{g[0]}' name: '#{g[0]}'
throws: NSErrorException
return_marshaler: CFType.NoRetainMarshaler
parameters: parameters:
options: options:
type: 'NSDictionary<NSString, ?>' type: 'NSDictionary<NSString, ?>'
visibility: protected
ABAddressBook(RequestAccess)WithCompletion: ABAddressBook(RequestAccess)WithCompletion:
class: ABAddressBook class: ABAddressBook
name: '#{g[0]}' name: '#{g[0]}'
Expand All @@ -88,14 +89,16 @@ functions:
ABAddressBook(Save|AddRecord|RemoveRecord): ABAddressBook(Save|AddRecord|RemoveRecord):
class: ABAddressBook class: ABAddressBook
name: '#{g[0]}' name: '#{g[0]}'
visibility: protected throws: NSErrorException
ABAddressBookCopy(LocalizedLabel): ABAddressBookCopy(LocalizedLabel):
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_marshaler: CFString.AsStringNoRetainMarshaler
ABAddressBookCopy(DefaultSource): ABAddressBookCopy(DefaultSource):
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: ABSource return_type: ABSource
return_marshaler: ABRecord.NoRetainMarshaler
ABAddressBook(RegisterExternalChangeCallback|UnregisterExternalChangeCallback): ABAddressBook(RegisterExternalChangeCallback|UnregisterExternalChangeCallback):
class: ABAddressBook class: ABAddressBook
name: '#{g[0]}' name: '#{g[0]}'
Expand All @@ -114,34 +117,40 @@ functions:
ABAddressBookCopyArrayOf(AllSources): ABAddressBookCopyArrayOf(AllSources):
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABSource.AsListMarshaler.class) List<ABSource>' return_type: List<ABSource>
return_marshaler: ABSource.AsListMarshaler
ABAddressBookCopyArrayOf(AllPeople): ABAddressBookCopyArrayOf(AllPeople):
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' return_type: List<ABPerson>
return_marshaler: ABPerson.AsListMarshaler
ABAddressBookCopyArrayOf(AllPeopleInSource).*: ABAddressBookCopyArrayOf(AllPeopleInSource).*:
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' return_type: List<ABPerson>
return_marshaler: ABPerson.AsListMarshaler
parameters: parameters:
source: source:
type: ABSource type: ABSource
ABAddressBookCopy(People)WithName: ABAddressBookCopy(People)WithName:
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' return_type: List<ABPerson>
return_marshaler: ABPerson.AsListMarshaler
ABAddressBook(GetGroup)WithRecordID: ABAddressBook(GetGroup)WithRecordID:
class: ABAddressBook class: ABAddressBook
name: '#{g[0]}' name: '#{g[0]}'
return_type: ABGroup return_type: ABGroup
ABAddressBookCopyArrayOf(AllGroups): ABAddressBookCopyArrayOf(AllGroups):
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABGroup.AsListMarshaler.class) List<ABGroup>' return_type: List<ABGroup>
return_marshaler: ABGroup.AsListMarshaler
ABAddressBookCopyArrayOf(AllGroupsInSource).*: ABAddressBookCopyArrayOf(AllGroupsInSource).*:
class: ABAddressBook class: ABAddressBook
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABGroup.AsListMarshaler.class) List<ABGroup>' return_type: List<ABGroup>
return_marshaler: ABGroup.AsListMarshaler
parameters: parameters:
source: source:
type: ABSource type: ABSource
Expand All @@ -150,21 +159,31 @@ functions:
name: '#{g[0]}' name: '#{g[0]}'


# ABRecord # ABRecord
ABRecordCopyValue: ABRecordCopy(Value):
class: ABRecord class: ABRecord
name: getValue name: 'get#{g[0]}'
visibility: protected return_marshaler: CFType.NoRetainMarshaler
parameters:
property:
type: ABProperty
ABRecord(SetValue): ABRecord(SetValue):
class: ABRecord class: ABRecord
name: '#{g[0]}' name: '#{g[0]}'
visibility: protected throws: NSErrorException
parameters:
property:
type: ABProperty
ABRecord(RemoveValue): ABRecord(RemoveValue):
class: ABRecord class: ABRecord
name: '#{g[0]}' name: '#{g[0]}'
visibility: protected throws: NSErrorException
parameters:
property:
type: ABProperty
ABRecordCopy(CompositeName): ABRecordCopy(CompositeName):
class: ABRecord class: ABRecord
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_marshaler: CFString.AsStringNoRetainMarshaler
ABRecord(.*): ABRecord(.*):
class: ABRecord class: ABRecord
name: '#{g[0]}' name: '#{g[0]}'
Expand All @@ -174,27 +193,30 @@ functions:
class: ABGroup class: ABGroup
name: '#{g[0]}' name: '#{g[0]}'
return_type: ABGroup return_type: ABGroup
return_marshaler: ABRecord.NoRetainMarshaler
parameters: parameters:
source: source:
type: ABSource type: ABSource
ABGroupCopy(Source): ABGroupCopy(Source):
class: ABGroup class: ABGroup
name: '#{g[0]}' name: 'get#{g[0]}'
return_type: ABSource return_type: ABSource
return_marshaler: ABRecord.NoRetainMarshaler
parameters: parameters:
group: group:
type: ABGroup type: ABGroup
ABGroupCopyArrayOf(AllMembers).*: ABGroupCopyArrayOf(AllMembers).*:
class: ABGroup class: ABGroup
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' return_type: List<ABPerson>
return_marshaler: ABPerson.AsListMarshaler
parameters: parameters:
group: group:
type: ABGroup type: ABGroup
ABGroup(AddMember|RemoveMember): ABGroup(AddMember|RemoveMember):
class: ABGroup class: ABGroup
name: '#{g[0]}' name: '#{g[0]}'
visibility: protected # throws NSErrorException throws: NSErrorException
parameters: parameters:
group: group:
type: ABGroup type: ABGroup
Expand All @@ -210,14 +232,17 @@ functions:
ABMultiValueCopyValueAtIndex: ABMultiValueCopyValueAtIndex:
class: ABMultiValue class: ABMultiValue
name: getValue name: getValue
return_marshaler: CFType.NoRetainMarshaler
ABMultiValueCopyArrayOfAllValues: ABMultiValueCopyArrayOfAllValues:
class: ABMultiValue class: ABMultiValue
name: getAllValues name: getAllValues
return_type: '@org.robovm.rt.bro.annotation.Marshaler(CFArray.AsListMarshaler.class) List<CFType>' return_type: List<CFType>
return_marshaler: CFArray.AsListMarshaler
ABMultiValueCopyLabelAtIndex: ABMultiValueCopyLabelAtIndex:
class: ABMultiValue class: ABMultiValue
name: getLabel name: getLabel
return_type: CFString return_type: CFString
return_marshaler: CFType.NoRetainMarshaler
ABMultiValue(GetIndex)ForIdentifier: ABMultiValue(GetIndex)ForIdentifier:
class: ABMultiValue class: ABMultiValue
name: indexOf name: indexOf
Expand All @@ -230,6 +255,7 @@ functions:
ABMultiValue(Create)Mutable.*: ABMultiValue(Create)Mutable.*:
class: ABMutableMultiValue class: ABMutableMultiValue
name: '#{g[0]}' name: '#{g[0]}'
return_marshaler: CFType.NoRetainMarshaler
ABMultiValue(AddValueAndLabel): ABMultiValue(AddValueAndLabel):
class: ABMutableMultiValue class: ABMutableMultiValue
name: '#{g[0]}' name: '#{g[0]}'
Expand Down Expand Up @@ -265,39 +291,44 @@ functions:
name: '#{g[0]}' name: '#{g[0]}'


# ABPerson # ABPerson
ABPersonGetTypeOfProperty:
class: ABPersonProperty
name: getType
visibility: protected
ABPersonCopy(LocalizedPropertyName):
class: ABPersonProperty
name: 'get#{g[0]}'
visibility: protected

ABPerson(Create): ABPerson(Create):
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}'
return_type: ABPerson return_type: ABPerson
return_marshaler: ABRecord.NoRetainMarshaler
ABPerson(Create)InSource: ABPerson(Create)InSource:
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}'
return_type: ABPerson return_type: ABPerson
return_marshaler: ABRecord.NoRetainMarshaler
parameters: parameters:
source: source:
type: ABSource type: ABSource
ABPersonCopy(Source): ABPersonCopy(Source):
class: ABPerson class: ABPerson
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: ABSource return_type: ABSource
return_marshaler: ABRecord.NoRetainMarshaler
parameters: parameters:
person: person:
type: ABPerson type: ABPerson
ABPersonCopyArrayOf(AllLinkedPeople): ABPersonCopyArrayOf(AllLinkedPeople):
class: ABPerson class: ABPerson
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' return_type: List<ABPerson>
return_marshaler: ABPerson.AsListMarshaler
parameters: parameters:
person: person:
type: ABPerson type: ABPerson
ABPersonGetTypeOfProperty:
class: ABPersonProperty
name: getType
visibility: protected
ABPersonCopy(LocalizedPropertyName):
class: ABPersonProperty
name: 'get#{g[0]}'
visibility: protected
ABPersonGet(CompositeNameFormat): ABPersonGet(CompositeNameFormat):
class: ABPerson class: ABPerson
name: 'getConstant#{g[0]}' name: 'getConstant#{g[0]}'
Expand All @@ -310,13 +341,14 @@ functions:
ABPersonCopy(CompositeNameDelimiter)ForRecord: ABPersonCopy(CompositeNameDelimiter)ForRecord:
class: ABPerson class: ABPerson
name: 'get#{g[0]}' name: 'get#{g[0]}'
return_marshaler: CFString.AsStringNoRetainMarshaler
parameters: parameters:
record: record:
type: ABPerson type: ABPerson
ABPerson(SetImageData): ABPerson(SetImageData):
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}'
visibility: protected # throws NSErrorException throws: NSErrorException
parameters: parameters:
person: person:
type: ABPerson type: ABPerson
Expand All @@ -335,7 +367,7 @@ functions:
ABPerson(RemoveImageData): ABPerson(RemoveImageData):
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}'
visibility: protected # throws NSErrorException throws: NSErrorException
parameters: parameters:
person: person:
type: ABPerson type: ABPerson
Expand All @@ -345,19 +377,21 @@ functions:
parameters: parameters:
person1: person1:
type: ABPerson type: ABPerson
ABPerson(CreatePeopleInSource)WithVCardRepresentation: ABPerson(CreatePeople)InSource(WithVCardRepresentation):
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}#{g[1]}'
return_type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' return_type: List<ABPerson>
return_marshaler: ABPerson.AsListMarshaler
parameters: parameters:
source: source:
type: ABSource type: ABSource
ABPerson(CreateVCardRepresentation)WithPeople: ABPerson(CreateVCardRepresentationWithPeople):
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}'
parameters: parameters:
people: people:
type: '@org.robovm.rt.bro.annotation.Marshaler(ABPerson.AsListMarshaler.class) List<ABPerson>' type: List<ABPerson>
marshaler: ABPerson.AsListMarshaler
ABPerson(.*): ABPerson(.*):
class: ABPerson class: ABPerson
name: '#{g[0]}' name: '#{g[0]}'
Expand Down
Expand Up @@ -71,45 +71,6 @@ private static void cbExternalChange(ABAddressBook addressBook, NSDictionary<?,
callback.externalChange(addressBook, info); callback.externalChange(addressBook, info);
} }


/**
* @since Available in iOS 6.0 and later.
*/
public static ABAddressBook create(NSDictionary<NSString, ?> options) throws NSErrorException {
NSError.NSErrorPtr err = new NSError.NSErrorPtr();
ABAddressBook result = create(options, err);
if (err.get() != null) {
throw new NSErrorException(err.get());
}
return result;
}

public boolean save() throws NSErrorException {
NSError.NSErrorPtr err = new NSError.NSErrorPtr();
boolean result = save(err);
if (err.get() != null) {
throw new NSErrorException(err.get());
}
return result;
}

public boolean addRecord(ABRecord record) throws NSErrorException {
NSError.NSErrorPtr err = new NSError.NSErrorPtr();
boolean result = addRecord(record, err);
if (err.get() != null) {
throw new NSErrorException(err.get());
}
return result;
}

public boolean removeRecord(ABRecord record) throws NSErrorException {
NSError.NSErrorPtr err = new NSError.NSErrorPtr();
boolean result = removeRecord(record, err);
if (err.get() != null) {
throw new NSErrorException(err.get());
}
return result;
}

public void registerExternalChangeCallback(ExternalChangeCallback callback) { public void registerExternalChangeCallback(ExternalChangeCallback callback) {
long refconId = ABAddressBook.changeCallbackId.getAndIncrement(); long refconId = ABAddressBook.changeCallbackId.getAndIncrement();
registerExternalChangeCallback(new FunctionPtr(cbExternalChange), refconId); registerExternalChangeCallback(new FunctionPtr(cbExternalChange), refconId);
Expand Down Expand Up @@ -140,11 +101,20 @@ public static String getLocalizedLabel(ABPropertyLabel label) {
*/ */
@Bridge(symbol="ABAddressBookGetAuthorizationStatus", optional=true) @Bridge(symbol="ABAddressBookGetAuthorizationStatus", optional=true)
public static native ABAuthorizationStatus getAuthorizationStatus(); public static native ABAuthorizationStatus getAuthorizationStatus();
/**
* @since Available in iOS 6.0 and later.
*/
public static @org.robovm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) ABAddressBook create(NSDictionary<NSString, ?> options) throws NSErrorException {
NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
ABAddressBook result = create(options, ptr);
if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
return result;
}
/** /**
* @since Available in iOS 6.0 and later. * @since Available in iOS 6.0 and later.
*/ */
@Bridge(symbol="ABAddressBookCreateWithOptions", optional=true) @Bridge(symbol="ABAddressBookCreateWithOptions", optional=true)
protected static native ABAddressBook create(NSDictionary<NSString, ?> options, NSError.NSErrorPtr error); private static native @org.robovm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) ABAddressBook create(NSDictionary<NSString, ?> options, NSError.NSErrorPtr error);
/** /**
* @since Available in iOS 2.0 and later. * @since Available in iOS 2.0 and later.
* @deprecated Deprecated in iOS 6.0. * @deprecated Deprecated in iOS 6.0.
Expand All @@ -157,16 +127,34 @@ public static String getLocalizedLabel(ABPropertyLabel label) {
*/ */
@Bridge(symbol="ABAddressBookRequestAccessWithCompletion", optional=true) @Bridge(symbol="ABAddressBookRequestAccessWithCompletion", optional=true)
public native void requestAccess(@Block RequestAccessCompletionHandler completion); public native void requestAccess(@Block RequestAccessCompletionHandler completion);
public boolean save() throws NSErrorException {
NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
boolean result = save(ptr);
if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
return result;
}
@Bridge(symbol="ABAddressBookSave", optional=true) @Bridge(symbol="ABAddressBookSave", optional=true)
protected native boolean save(NSError.NSErrorPtr error); private native boolean save(NSError.NSErrorPtr error);
@Bridge(symbol="ABAddressBookHasUnsavedChanges", optional=true) @Bridge(symbol="ABAddressBookHasUnsavedChanges", optional=true)
public native boolean hasUnsavedChanges(); public native boolean hasUnsavedChanges();
public boolean addRecord(ABRecord record) throws NSErrorException {
NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
boolean result = addRecord(record, ptr);
if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
return result;
}
@Bridge(symbol="ABAddressBookAddRecord", optional=true) @Bridge(symbol="ABAddressBookAddRecord", optional=true)
protected native boolean addRecord(ABRecord record, NSError.NSErrorPtr error); private native boolean addRecord(ABRecord record, NSError.NSErrorPtr error);
public boolean removeRecord(ABRecord record) throws NSErrorException {
NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
boolean result = removeRecord(record, ptr);
if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
return result;
}
@Bridge(symbol="ABAddressBookRemoveRecord", optional=true) @Bridge(symbol="ABAddressBookRemoveRecord", optional=true)
protected native boolean removeRecord(ABRecord record, NSError.NSErrorPtr error); private native boolean removeRecord(ABRecord record, NSError.NSErrorPtr error);
@Bridge(symbol="ABAddressBookCopyLocalizedLabel", optional=true) @Bridge(symbol="ABAddressBookCopyLocalizedLabel", optional=true)
public static native String getLocalizedLabel(String label); public static native @org.robovm.rt.bro.annotation.Marshaler(CFString.AsStringNoRetainMarshaler.class) String getLocalizedLabel(String label);
@Bridge(symbol="ABAddressBookRegisterExternalChangeCallback", optional=true) @Bridge(symbol="ABAddressBookRegisterExternalChangeCallback", optional=true)
protected native void registerExternalChangeCallback(FunctionPtr callback, @Pointer long context); protected native void registerExternalChangeCallback(FunctionPtr callback, @Pointer long context);
@Bridge(symbol="ABAddressBookUnregisterExternalChangeCallback", optional=true) @Bridge(symbol="ABAddressBookUnregisterExternalChangeCallback", optional=true)
Expand All @@ -177,7 +165,7 @@ public static String getLocalizedLabel(ABPropertyLabel label) {
* @since Available in iOS 4.0 and later. * @since Available in iOS 4.0 and later.
*/ */
@Bridge(symbol="ABAddressBookCopyDefaultSource", optional=true) @Bridge(symbol="ABAddressBookCopyDefaultSource", optional=true)
public native ABSource getDefaultSource(); public native @org.robovm.rt.bro.annotation.Marshaler(ABRecord.NoRetainMarshaler.class) ABSource getDefaultSource();
/** /**
* @since Available in iOS 4.0 and later. * @since Available in iOS 4.0 and later.
*/ */
Expand Down

0 comments on commit 29e8dd1

Please sign in to comment.