mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Mangler hack for various subsystems feedback
Swift SVN r17069
This commit is contained in:
60
lib/FunctionNameDemangle/MangleHack.cpp
Normal file
60
lib/FunctionNameDemangle/MangleHack.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
//===-- MangleHack.cpp - Swift Mangle Hack for various clients ------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2015 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Implementations of mangler hacks for Interface Builder
|
||||
//
|
||||
// We don't have the time to disentangle the real mangler from the compiler
|
||||
// right now.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/FunctionNameDemangle/MangleHack.h"
|
||||
#include "cassert"
|
||||
#include "cstring"
|
||||
#include "cstdio"
|
||||
|
||||
const char *
|
||||
_swift_mangleSimpleClass(const char *module, const char *class_) {
|
||||
size_t moduleLength = strlen(module);
|
||||
size_t classLength = strlen(class_);
|
||||
char *value = nullptr;
|
||||
if (strcmp(module, "swift") == 0) {
|
||||
int result = asprintf(&value, "_TtCSs%zu%s", classLength, class_);
|
||||
assert(result > 0);
|
||||
} else {
|
||||
int result = asprintf(&value, "_TtC%zu%s%zu%s", moduleLength, module,
|
||||
classLength, class_);
|
||||
assert(result > 0);
|
||||
}
|
||||
assert(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const char *
|
||||
_swift_mangleSimpleProtocol(const char *module, const char *protocol) {
|
||||
if (strcmp(module, "swift") == 0) {
|
||||
module = "Ss";
|
||||
}
|
||||
size_t moduleLength = strlen(module);
|
||||
size_t protocolLength = strlen(protocol);
|
||||
char *value = nullptr;
|
||||
if (strcmp(module, "swift") == 0) {
|
||||
int result = asprintf(&value, "_TtPSs%zu%s_", protocolLength, protocol);
|
||||
assert(result > 0);
|
||||
} else {
|
||||
int result = asprintf(&value, "_TtP%zu%s%zu%s_", moduleLength, module,
|
||||
protocolLength, protocol);
|
||||
assert(result > 0);
|
||||
}
|
||||
assert(value);
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user