From 885a7dcd8f4f6edf03b15b9bbd1c38cb07001d29 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Thu, 7 Dec 2023 11:03:19 +0100 Subject: [PATCH] [ObjCExport] Implement `test - kdocWithBlockTags` FL-23390 --- .../tests/ObjCExportHeaderGeneratorTest.kt | 5 ++ .../kdocWithBlockTags/!kdocWithBlockTags.h | 78 +++++++++++++++++++ .../testData/headers/kdocWithBlockTags/Foo.kt | 52 +++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 native/objcexport-header-generator/testData/headers/kdocWithBlockTags/!kdocWithBlockTags.h create mode 100644 native/objcexport-header-generator/testData/headers/kdocWithBlockTags/Foo.kt diff --git a/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt b/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt index df2ce6ba2b7..ad061019e1e 100644 --- a/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt +++ b/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt @@ -110,6 +110,11 @@ class ObjCExportHeaderGeneratorTest(val generator: HeaderGenerator) { doTest(headersTestDataDir.resolve("functionWithErrorType")) } + @Test + fun `test - kdocWithBlockTags`() { + doTest(headersTestDataDir.resolve("kdocWithBlockTags")) + } + fun interface HeaderGenerator { fun generateHeaders(root: File): String } diff --git a/native/objcexport-header-generator/testData/headers/kdocWithBlockTags/!kdocWithBlockTags.h b/native/objcexport-header-generator/testData/headers/kdocWithBlockTags/!kdocWithBlockTags.h new file mode 100644 index 00000000000..52a1b14cd57 --- /dev/null +++ b/native/objcexport-header-generator/testData/headers/kdocWithBlockTags/!kdocWithBlockTags.h @@ -0,0 +1,78 @@ +#import +#import +#import +#import +#import +#import +#import + +@class SomeClassWithProperty; + +NS_ASSUME_NONNULL_BEGIN +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wincompatible-property-type" +#pragma clang diagnostic ignored "-Wnullability" + +#pragma push_macro("_Nullable_result") +#if !__has_feature(nullability_nullable_result) +#undef _Nullable_result +#define _Nullable_result _Nullable +#endif + + +/** + * `Summary class` [KDocExport]. + * + * @property xyzzy Doc for property xyzzy + * @property zzz See below. + */ +__attribute__((objc_subclassing_restricted)) +@interface KDocExport : Base +- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); ++ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); + +/** Non-primary ctor KDoc:*/ +- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer)); + +/** @property xyzzy KDoc for foo?*/ +@property (readonly) NSString *foo __attribute__((swift_name("foo"))); + +/** + * @param xyzzy is documented. + * + * This is multi-line KDoc. See a blank line above. + */ +@property (readonly) NSString *xyzzy __attribute__((swift_name("xyzzy"))); + +/** @property foo KDoc for yxxyz?*/ +@property int32_t yxxyz __attribute__((swift_name("yxxyz"))); +@end + +@interface SomeClassWithProperty : Base +- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); ++ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); + +/** + * Kdoc for a property + */ +@property (readonly) SomeClassWithProperty *heavyFormattedKDocFoo __attribute__((swift_name("heavyFormattedKDocFoo"))); +@end + +__attribute__((objc_subclassing_restricted)) +@interface FooKt : Base + +/** + * Useless function [whatever] + * + * This kdoc has some additional formatting. + * @param a keep intact and return + * @return value of [a] + * Check for additional comment (note) below + */ ++ (NSString *)whateverA:(NSString *)a __attribute__((swift_name("whatever(a:)"))); +@end + +#pragma pop_macro("_Nullable_result") +#pragma clang diagnostic pop +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/native/objcexport-header-generator/testData/headers/kdocWithBlockTags/Foo.kt b/native/objcexport-header-generator/testData/headers/kdocWithBlockTags/Foo.kt new file mode 100644 index 00000000000..abdd734359b --- /dev/null +++ b/native/objcexport-header-generator/testData/headers/kdocWithBlockTags/Foo.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kdocExport + +/** + * `Summary class` [KDocExport]. + * + * @property xyzzy Doc for property xyzzy + * @property zzz See below. + */ + +// Expected: this comment shall not affect KDoc (i.e. kdoc above is still OK) +class KDocExport() { + /** + * @param xyzzy is documented. + * + * This is multi-line KDoc. See a blank line above. + */ + val xyzzy: String = "String example" + + /** Non-primary ctor KDoc:*/ + constructor(name: String) : this() { + println(name) + } + + /** @property xyzzy KDoc for foo?*/ + val foo = "foo" + /** @property foo KDoc for yxxyz?*/ + var yxxyz = 0; +} + + +/** + * Useless function [whatever] + * + * This kdoc has some additional formatting. + * @param a keep intact and return + * @return value of [a] + * Check for additional comment (note) below + */ +fun whatever(a:String) = a + +public abstract class SomeClassWithProperty +{ + /** + * Kdoc for a property + */ + public abstract val heavyFormattedKDocFoo: SomeClassWithProperty +} \ No newline at end of file