Re: [swift-users] .apinotesc file placement?

2017-11-29 Thread Roderick Mann via swift-users


> On Nov 29, 2017, at 16:23 , Jonathan Prescott  wrote:
> 
> As a general question since I’m just getting into Swift frameworks, could the 
> framework architecture not be right?  When I build a 
> non-Swift(C/C++/Obj-C/Obj-C++/other language/etc) based framework using Xcode 
> to build the framework, the Info.plist goes into a Resources folder/directory 
> and the module map goes into a Modules folder/directory.  I seem to recall 
> reading somewhere that the .apinotes file for swift should go into the same 
> directory as the module map.
> 
> If the listing in the e-mail represents the framework file architecture, and 
> there doesn’t seem to be a Modules directory nor a Resources directory, could 
> this be why swift is failing on the “import” directive?  How important is the 
> directory architecture for Xcode frameworks to “work"?

Indeed, you're right. I added the Modules/ directory and followed up in a 
subsequent email. It finds and imports the module now, and it seems to know 
something about my renaming of the enum cases in the apinotes file, but still 
gets conflicting error messages (in one case, it tells me I have to use the new 
enum case name, and in another case it tells me that enum case name is not a 
member of the enum).

> 
> Just asking.
> 
> Jonathan
> 
>> On Nov 29, 2017, at 7:05 PM, Rick Mann via swift-users 
>>  wrote:
>> 
>> FWIW, I submitted an Xcode feature request via Radar:
>> 
>>  https://bugreport.apple.com/web/?problemID=35757360
>> 
>> I also have this Framework:
>> 
>> $ ls -Rl lgscolibri.framework 
>> total 18128
>> drwxr-xr-x  3 rmann  staff96B Nov 21 16:41 Headers/
>> -rwxr-xr-x  1 rmann  staff   888B Nov 21 16:41 Info.plist*
>> -rwxr-xr-x  1 rmann  staff   8.9M Nov 21 16:41 lgscolibri*
>> -rw-r--r--@ 1 rmann  staff   1.7K Nov 29 14:07 lgscolibri.apinotes
>> -rw-r--r--@ 1 rmann  staff69B Nov 29 15:21 module.modulemap
>> 
>> With the attached .apinotes and module map, and it doesn't seem to be picked 
>> up by Xcode:
>> 
>>  BLK360API.swift:10:8: error: no such module 'lgscolibri'
>>  import lgscolibri
>> ^
>> 
>> 
>> 
>> 
>> Note that this is Swift 3.2; does that matter? Is 4.0 better?
>> 
>> 
>>> On Nov 2, 2017, at 13:22 , Rick Mann  wrote:
>>> 
>>> 
 On Nov 1, 2017, at 14:27 , Jordan Rose  wrote:
 
 Yep, you can! In fact, you don't even need to compile it. You can just put 
 the apinotes file itself into the Headers/ directory and it will work, as 
 long as
 
 - the file has the same name as the framework, i.e. "MyKit.apinotes"
 - the framework has a proper module map
 
 (I have a task on me to write up documentation on this but haven't gotten 
 around to it. It's not something most people need to do, but adapting an 
 existing library is one of the more likely cases.)
>>> 
>>> I'd sure appreciate this. We get this binary iOS Framework from a vendor 
>>> and need to integrate it. They know nothing of Swift, and their header is 
>>> cross-platform, so they don't have any of the proper naming conventions or 
>>> macros included. I don't really know how to write a robust and complete 
>>> module map or apinotes file.
>>> 
>>> I'd love to be able to include both of those *outside* of the framework, so 
>>> that I don't have to modify their provided items in any way. But for now, I 
>>> can drop both files into the Framework they provide.
>>> 
>>> Thanks!
>>> 
 
 Jordan
 
 
> On Oct 30, 2017, at 18:31, Rick Mann via swift-users 
>  wrote:
> 
> I'm using a third-party C library shoehorned into a Framework. It does 
> not have proper ENUM macros nor an apinotes file. I'd like to add one. 
> I'm using Xcode 9. 
> 
> • Can I put the .apinotesc file in the Framework somewhere?
> • Can I make Xcode automatically compile it?
> 
> Thanks.
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
 
>>> 
>>> 
>>> -- 
>>> Rick Mann
>>> rm...@latencyzero.com
>>> 
>>> 
>> 
>> 
>> -- 
>> Rick Mann
>> rm...@latencyzero.com
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Rick Mann
>> rm...@latencyzero.com
>> 
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> 


-- 
Rick Mann
rm...@latencyzero.com


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] .apinotesc file placement?

2017-11-29 Thread Rick Mann via swift-users
Oops, slight correction. I finally found I wasn't including the 
module.modulemap correctly. It belongs in Modules/module.modulemap.

With that, Xcode sees the lgscolibri module. However enum renaming (the problem 
I was trying to solve initially) is still oddly broken. This pair of 
compilation errors illustrates the problem:

BLK360API.swift:664:9: Type 'lgs_status_t' has no member 'aborted'
BLK360Request.swift:657:9: 'lgs_status_aborted' has been renamed to 
'lgs_status_t.aborted'

> On Nov 29, 2017, at 16:05 , Rick Mann via swift-users  
> wrote:
> 
> FWIW, I submitted an Xcode feature request via Radar:
> 
>   https://bugreport.apple.com/web/?problemID=35757360
> 
> I also have this Framework:
> 
> $ ls -Rl lgscolibri.framework 
> total 18128
> drwxr-xr-x  3 rmann  staff96B Nov 21 16:41 Headers/
> -rwxr-xr-x  1 rmann  staff   888B Nov 21 16:41 Info.plist*
> -rwxr-xr-x  1 rmann  staff   8.9M Nov 21 16:41 lgscolibri*
> -rw-r--r--@ 1 rmann  staff   1.7K Nov 29 14:07 lgscolibri.apinotes
> -rw-r--r--@ 1 rmann  staff69B Nov 29 15:21 module.modulemap
> 
> With the attached .apinotes and module map, and it doesn't seem to be picked 
> up by Xcode:
> 
>   BLK360API.swift:10:8: error: no such module 'lgscolibri'
>   import lgscolibri
>  ^
> 
> 
> 
> 
> Note that this is Swift 3.2; does that matter? Is 4.0 better?
> 
> 
>> On Nov 2, 2017, at 13:22 , Rick Mann  wrote:
>> 
>> 
>>> On Nov 1, 2017, at 14:27 , Jordan Rose  wrote:
>>> 
>>> Yep, you can! In fact, you don't even need to compile it. You can just put 
>>> the apinotes file itself into the Headers/ directory and it will work, as 
>>> long as
>>> 
>>> - the file has the same name as the framework, i.e. "MyKit.apinotes"
>>> - the framework has a proper module map
>>> 
>>> (I have a task on me to write up documentation on this but haven't gotten 
>>> around to it. It's not something most people need to do, but adapting an 
>>> existing library is one of the more likely cases.)
>> 
>> I'd sure appreciate this. We get this binary iOS Framework from a vendor and 
>> need to integrate it. They know nothing of Swift, and their header is 
>> cross-platform, so they don't have any of the proper naming conventions or 
>> macros included. I don't really know how to write a robust and complete 
>> module map or apinotes file.
>> 
>> I'd love to be able to include both of those *outside* of the framework, so 
>> that I don't have to modify their provided items in any way. But for now, I 
>> can drop both files into the Framework they provide.
>> 
>> Thanks!
>> 
>>> 
>>> Jordan
>>> 
>>> 
 On Oct 30, 2017, at 18:31, Rick Mann via swift-users 
  wrote:
 
 I'm using a third-party C library shoehorned into a Framework. It does not 
 have proper ENUM macros nor an apinotes file. I'd like to add one. I'm 
 using Xcode 9. 
 
 • Can I put the .apinotesc file in the Framework somewhere?
 • Can I make Xcode automatically compile it?
 
 Thanks.
 
 -- 
 Rick Mann
 rm...@latencyzero.com
 
 
 ___
 swift-users mailing list
 swift-users@swift.org
 https://lists.swift.org/mailman/listinfo/swift-users
>>> 
>> 
>> 
>> -- 
>> Rick Mann
>> rm...@latencyzero.com
>> 
>> 
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 
> 
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users


-- 
Rick Mann
rm...@latencyzero.com


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] FloatingPoint/BinaryFloatingPoint protocol and concrete FloatingPoint types

2017-11-29 Thread Antonino Ficarra via swift-users
Suppose that I have a generic function that makes a complex floating calculation
with a generic floating point type.
Suppose that calculation require the max floating point machine precision so:
1) I need to convert the generic floating point type to Float80
2) make the complex calculation with Float80
3) convert back the Float80 result to the generic floating point type


func maxPrecisionCalculation( input:Float80 ) -> Float80 {
// 
}

Let's try with FloatingPoint:

func someComplexCalculation( input:T ) -> T {
let input80 = Float80( input )  // Error: Cannot invoke 
initializer for type 'Float80' with an argument list of type '(T)'
let input80 = input as Float80  // Error 'T' is not 
convertible to 'Float80'; did you mean to use 'as!' to force downcast?

let output80= maxPrecisionCalculation( input:input80 )

return output80 as T// Error: 'Float80' is not convertible to 'T'; 
did you mean to use 'as!' to force downcast?
return T(output80)  // Error: Non-nominal type 'T' does not support 
explicit initialization
}

How convert a generic FloatingPoint to a concrete floating point type and then 
convert it back?

And now let's try with BinaryFloatingPoint:

func someComplexCalculation ( input:T ) -> T {
let input80 = Float80( input )  // Error: Cannot invoke 
initializer for type 'Float80' with an argument list of type '(T)'
let input80 = input as Float80  // Error 'T' is not convertible 
to 'Float80'; did you mean to use 'as!' to force downcast?

let output80= maxPrecisionCalculation( input:Float80(0) )

return T(output80)  // Ok, now this work
return output80 as T// Error: 'Float80' is not convertible to 'T'; 
did you mean to use 'as!' to force downcast?
}

How convert a generic BinaryFloatingPoint to a concrete floating point type?
In the opposite direction the conversion work.


NOTE: Using Double instead of Float80 don't make any difference at all.

ADDENDUM: The Float80 type exists from the first Swift version. Now we have 
Swift 4
and math function over Float80 are still unsupported, making this type 
substantially useless.
I still can’t call sin(x) and log(x) with a Float80 value.
There is a plan to resolve the issue?

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Where to read about *.swiftmodule file format?

2017-11-29 Thread Volodymyr B via swift-users
Hi Slava,

Thank you for your respond. 

I want to read content of file and present relations between classes in visual 
diagram. 

Then I thought it also will be useful for other cases.


Best regards,
Volodymyr Boichentsov







> On 28 Nov 2017, at 21:07, Slava Pestov  wrote:
> 
> Hi Volodymyr,
> 
> The format is not documented anywhere and is subject to change. A good 
> starting point is include/swift/Serialization/ModuleFormat.h, but I would 
> first be curious to know what exactly you’re planning on doing with it.
> 
> It might be better to extend swift-ide-test and similar utilities to dump the 
> information you need in an easy to parse format, and exec() them from your 
> IDE, instead of attempting to parse swift modules directly.
> 
> Slava
> 
>> On Nov 28, 2017, at 7:00 AM, Volodymyr B via swift-users 
>> > wrote:
>> 
>> Hi
>> 
>> Where to read about *.swiftmodule file format?
>> 
>> And *.swiftdoc 
>> 
>> I want to understand container of it.
>> 
>> would be good to have parser for third party IDEs.
>> 
>> Best regards,
>> Volodymyr Boichentsov
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-users
> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users