mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
52 lines
1020 B
Swift
52 lines
1020 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %{python} %utils/split_file.py -o %t %s
|
|
|
|
// RUN: %target-swift-frontend -I %t %t/Main.swift -enable-experimental-feature Embedded -cxx-interoperability-mode=default -c -o %t/a.o -Rmodule-loading
|
|
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
// BEGIN header.h
|
|
|
|
class C;
|
|
|
|
void retainC(C * _Nonnull obj);
|
|
void releaseC(C * _Nonnull obj);
|
|
|
|
class C {
|
|
public:
|
|
C(const C &) = delete;
|
|
C() {};
|
|
|
|
virtual void foo();
|
|
|
|
static C * _Nonnull create () __attribute__((swift_attr("returns_retained")));
|
|
}
|
|
__attribute__((swift_attr("import_reference")))
|
|
__attribute__((swift_attr("retain:retainC")))
|
|
__attribute__((swift_attr("release:releaseC")));
|
|
|
|
// BEGIN module.modulemap
|
|
|
|
module MyModule {
|
|
header "header.h"
|
|
}
|
|
|
|
// BEGIN Main.swift
|
|
|
|
import MyModule
|
|
|
|
public func test()
|
|
{
|
|
let c = C.create()
|
|
c.foo()
|
|
}
|
|
|
|
public func cast<S,D>(_ s:S, to type:D.Type) -> D {
|
|
return unsafeBitCast(s, to: type.self)
|
|
}
|
|
|
|
public func testcast(_ provider: AnyObject) -> C {
|
|
return cast (provider, to: C.self)
|
|
}
|
|
|