Skip to content

Commit

Permalink
* cocoatouch: bindings for AdServices.framework (MobiVM#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkimitsa authored Apr 12, 2023
1 parent 36ce197 commit 5cb662a
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 0 deletions.
41 changes: 41 additions & 0 deletions compiler/cocoatouch/src/main/bro-gen/adservices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package: org.robovm.apple.adservices
include: [foundation.yaml]
library: AdServices
framework: AdServices
clang_args: ['-x', 'objective-c']
headers:
- /System/Library/Frameworks/AdServices.framework/Headers/AdServices.h
typedefs:

enums:
AAAttributionErrorCode: { nserror: true } #since 14.3

classes:
AAAttribution: #since 14.3
methods:
'+attributionTokenWithError:':
name: attributionToken
throws: NSErrorException
protocols:

functions:
# Make sure we don't miss any functions if new ones are introduced in a later version
(.*):
class: !!!FIXME
name: 'Function__#{g[0]}'

values:
AAAttributionErrorDomain:
class: AAAttributionErrorCode
name: getClassDomain

# Make sure we don't miss any values if new ones are introduced in a later version
(.*):
class: !!!FIXME
name: 'Value__#{g[0]}'

constants:
# Make sure we don't miss any constants if new ones are introduced in a later version
(.*):
class: !!!FIXME
name: 'Constant__#{g[0]}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2013-2015 RoboVM AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.robovm.apple.adservices;

/*<imports>*/
import java.io.*;
import java.nio.*;
import java.util.*;
import org.robovm.objc.*;
import org.robovm.objc.annotation.*;
import org.robovm.objc.block.*;
import org.robovm.rt.*;
import org.robovm.rt.annotation.*;
import org.robovm.rt.bro.*;
import org.robovm.rt.bro.annotation.*;
import org.robovm.rt.bro.ptr.*;
import org.robovm.apple.foundation.*;
/*</imports>*/

/*<javadoc>*/
/**
* @since Available in iOS 14.3 and later.
*/
/*</javadoc>*/
/*<annotations>*/@Library("AdServices") @NativeClass/*</annotations>*/
/*<visibility>*/public/*</visibility>*/ class /*<name>*/AAAttribution/*</name>*/
extends /*<extends>*/NSObject/*</extends>*/
/*<implements>*//*</implements>*/ {

/*<ptr>*/public static class AAAttributionPtr extends Ptr<AAAttribution, AAAttributionPtr> {}/*</ptr>*/
/*<bind>*/static { ObjCRuntime.bind(AAAttribution.class); }/*</bind>*/
/*<constants>*//*</constants>*/
/*<constructors>*/
public AAAttribution() {}
protected AAAttribution(Handle h, long handle) { super(h, handle); }
protected AAAttribution(SkipInit skipInit) { super(skipInit); }
/*</constructors>*/
/*<properties>*/

/*</properties>*/
/*<members>*//*</members>*/
/*<methods>*/
public static String attributionToken() throws NSErrorException {
NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
String result = attributionToken(ptr);
if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
return result;
}
@Method(selector = "attributionTokenWithError:")
private static native String attributionToken(NSError.NSErrorPtr error);
/*</methods>*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2013-2015 RoboVM AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.robovm.apple.adservices;

/*<imports>*/
import java.io.*;
import java.nio.*;
import java.util.*;
import org.robovm.objc.*;
import org.robovm.objc.annotation.*;
import org.robovm.objc.block.*;
import org.robovm.rt.*;
import org.robovm.rt.annotation.*;
import org.robovm.rt.bro.*;
import org.robovm.rt.bro.annotation.*;
import org.robovm.rt.bro.ptr.*;
import org.robovm.apple.foundation.*;
/*</imports>*/

/*<javadoc>*/
/**
* @since Available in iOS 14.3 and later.
*/
/*</javadoc>*/
/*<annotations>*/@Marshaler(ValuedEnum.AsMachineSizedSIntMarshaler.class) @Library("AdServices")/*</annotations>*/
public enum /*<name>*/AAAttributionErrorCode/*</name>*/ implements NSErrorCode {
/*<values>*/
NetworkError(1L),
InternalError(2L),
PlatformNotSupported(3L);
/*</values>*/

/*<bind>*/static { Bro.bind(AAAttributionErrorCode.class); }/*</bind>*/
/*<constants>*//*</constants>*/
/*<members>*//*</members>*/
/*<methods>*/
/**
* @since Available in iOS 14.3 and later.
*/
@GlobalValue(symbol="AAAttributionErrorDomain", optional=true)
public static native String getClassDomain();
/*</methods>*/

private final long n;

private /*<name>*/AAAttributionErrorCode/*</name>*/(long n) { this.n = n; }
public long value() { return n; }
public static /*<name>*/AAAttributionErrorCode/*</name>*/ valueOf(long n) {
for (/*<name>*/AAAttributionErrorCode/*</name>*/ v : values()) {
if (v.n == n) {
return v;
}
}
throw new IllegalArgumentException("No constant with value " + n + " found in "
+ /*<name>*/AAAttributionErrorCode/*</name>*/.class.getName());
}

// bind wrap to include it in compilation as long as nserror enum is used
static { Bro.bind(NSErrorWrap.class); }
@StronglyLinked
public static class NSErrorWrap extends NSError {
protected NSErrorWrap(SkipInit skipInit) {super(skipInit);}

@Override public NSErrorCode getErrorCode() {
try {
return /*<name>*/AAAttributionErrorCode/*</name>*/.valueOf(getCode());
} catch (IllegalArgumentException e) {
return null;
}
}

public static String getClassDomain() {
/** must be inserted in value section */
return /*<name>*/AAAttributionErrorCode/*</name>*/.getClassDomain();
}
}
}

0 comments on commit 5cb662a

Please sign in to comment.