Files
swift-mirror/stdlib/private/StdlibUnittest/GetOSVersion.mm
John McCall 50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00

37 lines
1.3 KiB
Plaintext

//===--- GetOSVersion.mm --------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include <Foundation/Foundation.h>
#include "swift/Runtime/Config.h"
SWIFT_CC(swift)
extern "C" const char *
swift_stdlib_getSystemVersionPlistProperty(const char *PropertyName) {
// This function is implemented in Objective-C because Swift does not support
// failing initializers.
if (!PropertyName)
return nullptr;
NSDictionary *SystemVersion =
[NSDictionary dictionaryWithContentsOfFile:
@"/System/Library/CoreServices/SystemVersion.plist"];
if (!SystemVersion)
return nullptr;
NSString *PropertyNameString = [NSString stringWithUTF8String:PropertyName];
const char *Result = strdup([SystemVersion[PropertyNameString] UTF8String]);
[PropertyNameString release];
[SystemVersion release];
return Result;
}