From c512b4f039f0c5cb503b9aa130c617969dd741ce Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 5 Jun 2018 09:42:33 -0700 Subject: revert -framework CoreFoundation Make error CFStream only --- src/core/lib/iomgr/endpoint_cfstream.cc | 2 +- src/core/lib/iomgr/error_apple.cc | 52 ------------------------------- src/core/lib/iomgr/error_apple.h | 31 ------------------ src/core/lib/iomgr/error_cfstream.cc | 52 +++++++++++++++++++++++++++++++ src/core/lib/iomgr/error_cfstream.h | 31 ++++++++++++++++++ src/core/lib/iomgr/tcp_client_cfstream.cc | 2 +- 6 files changed, 85 insertions(+), 85 deletions(-) delete mode 100644 src/core/lib/iomgr/error_apple.cc delete mode 100644 src/core/lib/iomgr/error_apple.h create mode 100644 src/core/lib/iomgr/error_cfstream.cc create mode 100644 src/core/lib/iomgr/error_cfstream.h (limited to 'src/core/lib/iomgr') diff --git a/src/core/lib/iomgr/endpoint_cfstream.cc b/src/core/lib/iomgr/endpoint_cfstream.cc index 6525a02fbb..c3bc0cc8fd 100644 --- a/src/core/lib/iomgr/endpoint_cfstream.cc +++ b/src/core/lib/iomgr/endpoint_cfstream.cc @@ -33,7 +33,7 @@ #include "src/core/lib/iomgr/cfstream_handle.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/error_apple.h" +#include "src/core/lib/iomgr/error_cfstream.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" diff --git a/src/core/lib/iomgr/error_apple.cc b/src/core/lib/iomgr/error_apple.cc deleted file mode 100644 index bc375bae88..0000000000 --- a/src/core/lib/iomgr/error_apple.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#ifdef GPR_APPLE -#include - -#include -#include - -#include "src/core/lib/iomgr/error.h" - -#define MAX_ERROR_DESCRIPTION 256 - -grpc_error* grpc_error_create_from_cferror(const char* file, int line, - void* arg, const char* custom_desc) { - CFErrorRef error = static_cast(arg); - char buf_domain[MAX_ERROR_DESCRIPTION]; - char buf_desc[MAX_ERROR_DESCRIPTION]; - char* error_msg; - CFErrorDomain domain = CFErrorGetDomain((error)); - CFIndex code = CFErrorGetCode((error)); - CFStringRef desc = CFErrorCopyDescription((error)); - CFStringGetCString(domain, buf_domain, MAX_ERROR_DESCRIPTION, - kCFStringEncodingUTF8); - CFStringGetCString(desc, buf_desc, MAX_ERROR_DESCRIPTION, - kCFStringEncodingUTF8); - gpr_asprintf(&error_msg, "%s (error domain:%s, code:%ld, description:%s)", - custom_desc, buf_domain, code, buf_desc); - CFRelease(desc); - grpc_error* return_error = grpc_error_create( - file, line, grpc_slice_from_copied_string(error_msg), NULL, 0); - gpr_free(error_msg); - return return_error; -} -#endif /* GPR_APPLE */ diff --git a/src/core/lib/iomgr/error_apple.h b/src/core/lib/iomgr/error_apple.h deleted file mode 100644 index 276ec77d35..0000000000 --- a/src/core/lib/iomgr/error_apple.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_IOMGR_ERROR_APPLE_H -#define GRPC_CORE_LIB_IOMGR_ERROR_APPLE_H - -#ifdef GRPC_CFSTREAM -// Create an error from Apple Core Foundation CFError object -#define GRPC_ERROR_CREATE_FROM_CFERROR(error, desc) \ - grpc_error_create_from_cferror(__FILE__, __LINE__, \ - static_cast((error)), (desc)) -grpc_error* grpc_error_create_from_cferror(const char* file, int line, - void* arg, const char* desc); -#endif /* GRPC_CFSTREAM */ - -#endif /* GRPC_CORE_LIB_IOMGR_ERROR_APPLE_H */ diff --git a/src/core/lib/iomgr/error_cfstream.cc b/src/core/lib/iomgr/error_cfstream.cc new file mode 100644 index 0000000000..d7af8c377f --- /dev/null +++ b/src/core/lib/iomgr/error_cfstream.cc @@ -0,0 +1,52 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#ifdef GRPC_CFSTREAM +#include + +#include +#include + +#include "src/core/lib/iomgr/error.h" + +#define MAX_ERROR_DESCRIPTION 256 + +grpc_error* grpc_error_create_from_cferror(const char* file, int line, + void* arg, const char* custom_desc) { + CFErrorRef error = static_cast(arg); + char buf_domain[MAX_ERROR_DESCRIPTION]; + char buf_desc[MAX_ERROR_DESCRIPTION]; + char* error_msg; + CFErrorDomain domain = CFErrorGetDomain((error)); + CFIndex code = CFErrorGetCode((error)); + CFStringRef desc = CFErrorCopyDescription((error)); + CFStringGetCString(domain, buf_domain, MAX_ERROR_DESCRIPTION, + kCFStringEncodingUTF8); + CFStringGetCString(desc, buf_desc, MAX_ERROR_DESCRIPTION, + kCFStringEncodingUTF8); + gpr_asprintf(&error_msg, "%s (error domain:%s, code:%ld, description:%s)", + custom_desc, buf_domain, code, buf_desc); + CFRelease(desc); + grpc_error* return_error = grpc_error_create( + file, line, grpc_slice_from_copied_string(error_msg), NULL, 0); + gpr_free(error_msg); + return return_error; +} +#endif /* GRPC_CFSTREAM */ diff --git a/src/core/lib/iomgr/error_cfstream.h b/src/core/lib/iomgr/error_cfstream.h new file mode 100644 index 0000000000..06ab751329 --- /dev/null +++ b/src/core/lib/iomgr/error_cfstream.h @@ -0,0 +1,31 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_ERROR_CFSTREAM_H +#define GRPC_CORE_LIB_IOMGR_ERROR_CFSTREAM_H + +#ifdef GRPC_CFSTREAM +// Create an error from Apple Core Foundation CFError object +#define GRPC_ERROR_CREATE_FROM_CFERROR(error, desc) \ + grpc_error_create_from_cferror(__FILE__, __LINE__, \ + static_cast((error)), (desc)) +grpc_error* grpc_error_create_from_cferror(const char* file, int line, + void* arg, const char* desc); +#endif /* GRPC_CFSTREAM */ + +#endif /* GRPC_CORE_LIB_IOMGR_ERROR_CFSTREAM_H */ diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc index b1a40f7a30..ffed3bbef6 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -39,7 +39,7 @@ #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint_cfstream.h" #include "src/core/lib/iomgr/error.h" -#include "src/core/lib/iomgr/error_apple.h" +#include "src/core/lib/iomgr/error_cfstream.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/tcp_client.h" #include "src/core/lib/iomgr/timer.h" -- cgit v1.2.3