From 8d20f0f1540c4c116f52e333edc57a4f549927e8 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 22 Dec 2015 07:27:34 -0800 Subject: [PATCH] Automatically generate FFI bridges using libclang. --- .gitignore | 3 + Analysis.cpp | 43 + Analyze.cpp | 195 + Bridge.cpp | 4 - Bridge.def | 1832 -------- Bridge.def.in | 89 + Bridge.sh | 7 +- Code.hpp | 1 + Exception.hpp | 4 +- Execute.cpp | 172 +- Execute.hpp | 8 - JavaScript.hpp | 1 + Library.cpp | 6 + Makefile.am | 29 +- Makefile.in | 149 +- ObjectiveC/Library.mm | 9 +- apple-configure.sh | 6 +- apple.mk | 15 +- config.h.in | 3 + configure | 2342 ++++++++-- configure.ac | 15 + extra/clang-c/BuildSystem.h | 156 + extra/clang-c/CXCompilationDatabase.h | 176 + extra/clang-c/CXErrorCode.h | 64 + extra/clang-c/CXString.h | 71 + extra/clang-c/Documentation.h | 554 +++ extra/clang-c/Index.h | 5835 +++++++++++++++++++++++++ extra/clang-c/Platform.h | 45 + libcycript.py | 23 + libcycript.sh | 33 + m4/ax_prog_cxx_for_build.m4 | 110 + 31 files changed, 9676 insertions(+), 2324 deletions(-) create mode 100644 Analysis.cpp create mode 100644 Analyze.cpp delete mode 100644 Bridge.def create mode 100644 Bridge.def.in create mode 100644 extra/clang-c/BuildSystem.h create mode 100644 extra/clang-c/CXCompilationDatabase.h create mode 100644 extra/clang-c/CXErrorCode.h create mode 100644 extra/clang-c/CXString.h create mode 100644 extra/clang-c/Documentation.h create mode 100644 extra/clang-c/Index.h create mode 100644 extra/clang-c/Platform.h create mode 100755 libcycript.py create mode 100755 libcycript.sh create mode 100644 m4/ax_prog_cxx_for_build.m4 diff --git a/.gitignore b/.gitignore index cabf90a..ab7adb8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ libtool .deps .dirstamp .libs +Analyze autom4te.cache codesign.mk config.h @@ -22,6 +23,7 @@ Parser.output Scanner.lpp Scanner.cpp Scanner.output +Bridge.def Bridge.gperf stack.hh sysroot.ios @@ -38,6 +40,7 @@ ncurses.* readline-6.2 readline-6.2.tar.gz readline.* +libcycript.db libffi.* libuv.* build.* diff --git a/Analysis.cpp b/Analysis.cpp new file mode 100644 index 0000000..a5b1822 --- /dev/null +++ b/Analysis.cpp @@ -0,0 +1,43 @@ +/* Cycript - Optimizing JavaScript Compiler/Runtime + * Copyright (C) 2009-2015 Jay Freeman (saurik) +*/ + +/* GNU Affero General Public License, Version 3 {{{ */ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +**/ +/* }}} */ + +#include + +#include + +#include + +#ifdef __OBJC__ +#include +#endif + +#ifdef __APPLE__ +#include +#include +#include +#include + +#if TARGET_OS_IPHONE +#include +#else +#include +#endif +#endif diff --git a/Analyze.cpp b/Analyze.cpp new file mode 100644 index 0000000..791d8f4 --- /dev/null +++ b/Analyze.cpp @@ -0,0 +1,195 @@ +#include +#include +#include +#include +#include + +#include + +struct CYCXString { + CXString value_; + + CYCXString(CXString value) : + value_(value) + { + } + + ~CYCXString() { + clang_disposeString(value_); + } + + operator const char *() const { + return clang_getCString(value_); + } +}; + +struct CYFieldBaton { + std::ostringstream types; + std::ostringstream names; +}; + +static CXChildVisitResult CYFieldVisit(CXCursor cursor, CXCursor parent, CXClientData arg) { + CYFieldBaton &baton(*static_cast(arg)); + + if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) { + CXType type(clang_getCursorType(cursor)); + baton.types << "(typedef " << CYCXString(clang_getTypeSpelling(type)) << "),"; + baton.names << "'" << CYCXString(clang_getCursorSpelling(cursor)) << "',"; + } + + return CXChildVisit_Continue; +} + +typedef std::map CYKeyMap; + +struct CYChildBaton { + CXTranslationUnit unit; + CYKeyMap &keys; + + CYChildBaton(CXTranslationUnit unit, CYKeyMap &keys) : + unit(unit), + keys(keys) + { + } +}; + +struct CYTokens { + CXTranslationUnit unit; + CXToken *tokens; + unsigned count; + + CYTokens(CXTranslationUnit unit, CXCursor cursor) : + unit(unit) + { + CXSourceRange range(clang_getCursorExtent(cursor)); + clang_tokenize(unit, range, &tokens, &count); + } + + ~CYTokens() { + clang_disposeTokens(unit, tokens, count); + } + + operator CXToken *() const { + return tokens; + } +}; + +static CXChildVisitResult CYChildVisit(CXCursor cursor, CXCursor parent, CXClientData arg) { + CYChildBaton &baton(*static_cast(arg)); + CXTranslationUnit &unit(baton.unit); + + CYCXString spelling(clang_getCursorSpelling(cursor)); + std::string name(spelling); + std::ostringstream value; + + /*CXSourceLocation location(clang_getCursorLocation(cursor)); + + CXFile file; + unsigned line; + unsigned column; + unsigned offset; + clang_getSpellingLocation(location, &file, &line, &column, &offset); + + if (file != NULL) { + CYCXString path(clang_getFileName(file)); + std::cout << spelling << " " << path << ":" << line << std::endl; + }*/ + + switch (clang_getCursorKind(cursor)) { + case CXCursor_EnumConstantDecl: { + value << clang_getEnumConstantDeclValue(cursor); + } break; + + case CXCursor_MacroDefinition: { + CYTokens tokens(unit, cursor); + if (tokens.count <= 2) + goto skip; + + CXCursor cursors[tokens.count]; + clang_annotateTokens(unit, tokens, tokens.count, cursors); + + for (unsigned i(1); i != tokens.count - 1; ++i) { + CYCXString token(clang_getTokenSpelling(unit, tokens[i])); + if (i != 1) + value << " "; + else if (strcmp(token, "(") == 0) + goto skip; + value << token; + } + } break; + + case CXCursor_StructDecl: { + if (!clang_isCursorDefinition(cursor)) + goto skip; + if (spelling[0] == '\0') + goto skip; + + CYFieldBaton baton; + + baton.types << "["; + baton.names << "["; + clang_visitChildren(cursor, &CYFieldVisit, &baton); + baton.types << "]"; + baton.names << "]"; + + name += "$cy"; + value << "new Type(" << baton.types.str() << "," << baton.names.str() << ")"; + } break; + + case CXCursor_TypedefDecl: { + CXType type(clang_getTypedefDeclUnderlyingType(cursor)); + value << "(typedef " << CYCXString(clang_getTypeSpelling(type)) << ")"; + } break; + + case CXCursor_FunctionDecl: + case CXCursor_VarDecl: { + CXType type(clang_getCursorType(cursor)); + value << "*(typedef " << CYCXString(clang_getTypeSpelling(type)) << ").pointerTo()(dlsym(RTLD_DEFAULT,'" << spelling << "'))"; + } break; + + default: { + return CXChildVisit_Recurse; + } break; + } + + baton.keys[name] = value.str(); + + skip: + return CXChildVisit_Continue; +} + +int main(int argc, const char *argv[]) { + CXIndex index(clang_createIndex(0, 0)); + + const char *file(argv[1]); + + unsigned offset(3); +#if CY_OBJECTIVEC + argv[--offset] = "-ObjC++"; +#endif + + CXTranslationUnit unit(clang_parseTranslationUnit(index, file, argv + offset, argc - offset, NULL, 0, CXTranslationUnit_DetailedPreprocessingRecord | CXTranslationUnit_SkipFunctionBodies)); + + for (unsigned i(0), e(clang_getNumDiagnostics(unit)); i != e; ++i) { + CXDiagnostic diagnostic(clang_getDiagnostic(unit, i)); + CYCXString spelling(clang_getDiagnosticSpelling(diagnostic)); + std::cerr << spelling << std::endl; + } + + CYKeyMap keys; + CYChildBaton baton(unit, keys); + clang_visitChildren(clang_getTranslationUnitCursor(unit), &CYChildVisit, &baton); + + for (CYKeyMap::const_iterator key(keys.begin()); key != keys.end(); ++key) { + std::string value(key->second); + for (size_t i(0), e(value.size()); i != e; ++i) + if (value[i] <= 0 || value[i] >= 0x7f || value[i] == '\n') + goto skip; + std::cout << key->first << "|\"" << value << "\"" << std::endl; + skip:; } + + clang_disposeTranslationUnit(unit); + clang_disposeIndex(index); + + return 0; +} diff --git a/Bridge.cpp b/Bridge.cpp index f3d1b6c..6035deb 100644 --- a/Bridge.cpp +++ b/Bridge.cpp @@ -22,7 +22,3 @@ #include #include "Bridge.hpp" - -extern "C" struct CYBridgeEntry *CYBridgeHash(const char *data, size_t size) { - return CYBridgeHash_(data, size); -} diff --git a/Bridge.def b/Bridge.def deleted file mode 100644 index 35b1d58..0000000 --- a/Bridge.def +++ /dev/null @@ -1,1832 +0,0 @@ -C YES true -C NO false -C NULL null - -T id @ -T Class # -T SEL : - -T short s -T int i -T long l -T longlong q - -T byte C -T ushort S -T uint I -T ulong L -T ulonglong Q - -T char c -T boolean B -T float f -T double d - -T Boolean B -T BOOL B -T bool B - -T int8_t {char} -T uint8_t {byte} -T int16_t {short} -T uint16_t {ushort} -T int32_t {int} -T uint32_t {uint} -T int64_t {longlong} -T uint64_t {ulonglong} - -T SInt8 {int8_t} -T UInt8 {uint8_t} -T SInt16 {int16_t} -T UInt16 {uint16_t} -T SInt32 {int32_t} -T UInt32 {uint32_t} -T SInt64 {int64_t} -T UInt64 {uint64_t} - -S CGPoint "x"{CGFloat}"y"{CGFloat} -S CGRect "origin"{CGPoint}"size"{CGSize} -S CGSize "width"{CGFloat}"height"{CGFloat} - -l c - -S nlist_64 "_un"(?="n_strx"I)"n_type"C"n_sect"C"n_desc"S"n_value"Q - -F malloc ^vL -F free v^v - -l objc - -F class_addIvar B#*LC* -F class_addMethod B#:^?* -F class_addProtocol B#@ -F class_conformsToProtocol B#@ -F class_copyIvarList ^^{objc_ivar=}#^I -F class_copyMethodList ^^{objc_method=}#^I -F class_copyPropertyList ^^{objc_property=}#^I -F class_copyProtocolList ^@#^I -F class_createInstance @#L -F class_getClassMethod ^{objc_method=}#: -F class_getClassVariable ^{objc_ivar=}#* -F class_getInstanceMethod ^{objc_method=}#: -F class_getInstanceSize L# -F class_getInstanceVariable ^{objc_ivar=}#* -F class_getIvarLayout *# -F class_getMethodImplementation ^?#: -F class_getMethodImplementation_stret ^?#: -F class_getName *# -F class_getProperty ^{objc_property=}#* -F class_getSuperclass ## -F class_getVersion i# -F class_getWeakIvarLayout *# -F class_isMetaClass B# -F class_replaceMethod ^?#:^?* -F class_respondsToSelector B#: -F class_setIvarLayout v#* -F class_setSuperclass ### -F class_setVersion v#i -F class_setWeakIvarLayout v#* - -F ivar_getName *^{objc_ivar=} -F ivar_getOffset i^{objc_ivar=} -F ivar_getTypeEncoding *^{objc_ivar=} - -F method_copyArgumentType ^c^{objc_method=}I -F method_copyReturnType ^c^{objc_method=} -F method_exchangeImplementations v^{objc_method=}^{objc_method=} -F method_getArgumentType v^{objc_method=}I^cL -F method_getImplementation ^?^{objc_method=} -F method_getName :^{objc_method=} -F method_getNumberOfArguments I^{objc_method=} -F method_getReturnType v^{objc_method=}^cL -F method_getTypeEncoding *^{objc_method=} -F method_setImplementation ^?^{objc_method=}^? - -# this should return # or ^v ? -F objc_allocateClassPair ##*L -F objc_copyProtocolList ^@^I -F objc_duplicateClass ##*L -F objc_getClass #* -F objc_getClassList i^#i -F objc_getFutureClass #* -F objc_getMetaClass @* -F objc_getProtocol @* -F objc_getRequiredClass @* -F objc_lookUpClass @* -F objc_registerClassPair v# -F objc_setFutureClass v#* - -F object_copy @@L -F object_dispose @@ -F object_getClass #@ -F object_getClassName *@ -F object_getIndexedIvars ^v@ -F object_getInstanceVariable ^{objc_ivar=}@*^^v -F object_getIvar @@^{objc_ivar=} -F object_setClass #@# -F object_setInstanceVariable ^{objc_ivar=}@*^v -F object_setIvar v@^{objc_ivar=}@ - -F property_getAttributes *^{objc_property=} -F property_getName *^{objc_property=} - -F protocol_conformsToProtocol B@@ -F protocol_copyMethodDescriptionList ^{objc_method_description=:*}@BB^I -F protocol_copyPropertyList ^^{objc_property=}@^I -F protocol_copyProtocolList ^@@^I -F protocol_getMethodDescription {objc_method_description=:*}@:BB -F protocol_getName *@ -F protocol_getProperty ^{objc_property=}@*BB -F protocol_isEqual B@@ - -F sel_getName *: -F sel_getUid :* -F sel_isEqual B:: -F sel_registerName :* - -f UIKit - -C UIBarStyleDefault 0 -C UIBarStyleBlack 1 -C UIBarStyleBlackOpaque 2 -C UIBarStyleBlackTranslucent 3 -T UIBarStyle i - -C UIDataDetectorTypePhoneNumber (1<<0) -C UIDataDetectorTypeLink (1<<1) -C UIDataDetectorTypeNone 0 -C UIDataDetectorTypeAll -1 -T UIDataDetectorTypes {NSUInteger} - -S UIEdgeInsets "top"{CGFloat}"left"{CGFloat}"bottom"{CGFloat}"right"{CGFloat} - -# UINavigationBar - -# UINavigationController - -V UINavigationControllerHideShowBarDuration f - -# UINavigationControllerDelegate - -# UIScrollView - -C UIScrollViewIndicatorStyleDefault 0 -C UIScrollViewIndicatorStyleBlack 1 -C UIScrollViewIndicatorStyleWhite 2 - -V UIScrollViewDecelerationRateNormal f -V UIScrollViewDecelerationRateFast f - -# UIScrollViewDelegate - -# UITabBar - -# UITabBarDelegate - -# UITableView - -C UITableViewStylePlain 0 -C UITableViewStyleGrouped 1 - -C UITableViewScrollPositionNone 0 -C UITableViewScrollPositionTop 1 -C UITableViewScrollPositionMiddle 2 -C UITableViewScrollPositionBottom 3 - -C UITableViewRowAnimationFade 0 -C UITableViewRowAnimationRight 1 -C UITableViewRowAnimationLeft 2 -C UITableViewRowAnimationTop 3 -C UITableViewRowAnimationBottom 4 -C UITableViewRowAnimationNone 5 - -V UITableViewIndexSearch @ - -# UITableViewCell - -C UITableViewCellStyleDefault 0 -C UITableViewCellStyleValue1 1 -C UITableViewCellStyleValue2 2 -C UITableViewCellStyleSubtitle 3 - -C UITableViewCellStateDefaultMask 0 -C UITableViewCellStateEditingMask (1<<0) -C UITableViewCellStateShowingDeleteConfirmationMask (1<<1) - -C UITableViewCellSelectionStyleNone 0 -C UITableViewCellSelectionStyleBlue 1 -C UITableViewCellSelectionStyleGray 2 - -C UITableViewCellEditingStyleNone 0 -C UITableViewCellEditingStyleDelete 1 -C UITableViewCellEditingStyleInsert 2 - -C UITableViewCellAccessoryNone 0 -C UITableViewCellAccessoryDisclosureIndicator 1 -C UITableViewCellAccessoryDetailDisclosureButton 2 -C UITableViewCellAccessoryCheckmark 3 - -C UITableViewCellSeparatorStyleNone 0 -C UITableViewCellSeparatorStyleSingleLine 1 - -# UITableViewController - -# UITableViewDataSource - -# UIToolbar - -# UIView - -C UIViewAnimationCurveEaseInOut 0 -C UIViewAnimationCurveEaseIn 1 -C UIViewAnimationCurveEaseOut 2 -C UIViewAnimationCurveLinear 3 - -C UIViewContentModeScaleToFill 0 -C UIViewContentModeScaleAspectFit 1 -C UIViewContentModeScaleAspectFill 2 -C UIViewContentModeRedraw 3 -C UIViewContentModeCenter 4 -C UIViewContentModeTop 5 -C UIViewContentModeBottom 6 -C UIViewContentModeLeft 7 -C UIViewContentModeRight 8 -C UIViewContentModeTopLeft 9 -C UIViewContentModeTopRight 10 -C UIViewContentModeBottomLeft 11 -C UIViewContentModeBottomRight 12 - -C UIViewAutoresizingNone 0 -C UIViewAutoresizingFlexibleLeftMargin (1<<0) -C UIViewAutoresizingFlexibleWidth (1<<1) -C UIViewAutoresizingFlexibleRightMargin (1<<2) -C UIViewAutoresizingFlexibleTopMargin (1<<3) -C UIViewAutoresizingFlexibleHeight (1<<4) -C UIViewAutoresizingFlexibleBottomMargin (1<<5) - -C UIViewAnimationTransitionNone 0 -C UIViewAnimationTransitionFlipFromLeft 1 -C UIViewAnimationTransitionFlipFromRight 2 -C UIViewAnimationTransitionCurlUp 3 -C UIViewAnimationTransitionCurlDown 4 - -# UIViewController - -C UIModalTransitionStyleCoverVertical 0 -C UIModalTransitionStyleFlipHorizontal 1 -C UIModalTransitionStyleCrossDissolve 2 - -# UIWebView - -C UIWebViewNavigationTypeLinkClicked 0 -C UIWebViewNavigationTypeFormSubmitted 1 -C UIWebViewNavigationTypeBackForward 2 -C UIWebViewNavigationTypeReload 3 -C UIWebViewNavigationTypeFormResubmitted 4 -C UIWebViewNavigationTypeOther 5 - -# UIWebViewDelegate - -# UIWindow - -V UIWindowLevelNormal f -V UIWindowLevelAlert f -V UIWindowLevelStatusBar f - -V UIKeyboardCenterBeginUserInfoKey @ -V UIKeyboardCenterEndUserInfoKey @ -V UIKeyboardBoundsUserInfoKey @ -V UIKeyboardAnimationCurveUserInfoKey @ -V UIKeyboardAnimationDurationUserInfoKey @ - -# Functions - -F UIApplicationMain ii^^c@@ - -F UIImageJPEGRepresentation @@f -F UIImagePNGRepresentation @@ -F UIImageWriteToSavedPhotosAlbum v@@:^v - -F UISaveVideoAtPathToSavedPhotosAlbum v@@:^v -F UIVideoAtPathIsCompatibleWithSavedPhotosAlbum B@ - -F UIGraphicsGetCurrentContext @ -F UIGraphicsPushContext v@ -F UIGraphicsPopContext v -F UIGraphicsBeginImageContext v{CGSize} -F UIGraphicsGetImageFromCurrentImageContext @ -F UIGraphicsEndImageContext v -F UIRectClip v{CGRect} -F UIRectFill v{CGRect} -F UIRectFillUsingBlendMode v{CGRect}{CGBlendMode} -F UIRectFrame v{CGRect} -F UIRectFrameUsingBlendMode v{CGRect}{CGBlendMode} - -F CGPointFromString {CGPoint}@ -F CGRectFromString {CGRect}@ -F CGSizeFromString {CGSize}@ -F CGAffineTransformFromString {CGAffineTransform}@ -F UIEdgeInsetsFromString {UIEdgeInsets=ffff}@ -F NSStringFromCGPoint @{CGPoint} -F NSStringFromCGRect @{CGRect} -F NSStringFromCGSize @{CGSize} -F NSStringFromCGAffineTransform @{CGAffineTransform} -F NSStringFromUIEdgeInsets @{UIEdgeInsets=ffff} - -F UIEdgeInsetsMake {UIEdgeInsets=ffff}ffff -F UIEdgeInsetsEqualToEdgeInsets B{UIEdgeInsets=ffff}{UIEdgeInsets=ffff} -F UIEdgeInsetsInsetRect {CGRect}{CGRect}{UIEdgeInsets=ffff} - -# XXX: UIInterfaceOrientationIsPortrait -# XXX: UIInterfaceOrientationIsLandscape - -# XXX: UIDeviceOrientationIsValidInterfaceOrientation -# XXX: UIDeviceOrientationIsPortrait -# XXX: UIDeviceOrientationIsLandscape - -F UIAccessibilityPostNotification vI@ - -# Miscellaneous - -F UIGetScreenImage @ - -V UIAbbreviatedMonthDayFormat @ -V UIAbbreviatedWeekdayDateFormat @ -V UIAbbreviatedWeekdayFormat @ -V UIAbbreviatedWeekdayMonthDayFormat @ -V UIAbbreviatedWeekdayMonthDayMinutelessFormat @ -V UIAbbreviatedWeekdayMonthDayTimeFormat @ -V UIDatePickerDayFormat @ -V UIDatePickerMonthFormat @ -V UIDatePickerYearFormat @ -V UIHourFormat @ -V UIMinutelessTimeFormat @ -V UIMonthYearFormat @ -V UINoAMPMTimeFormat @ -V UIShortMonthDayFormat @ -V UIWeekdayAbbreviatedDateFormat @ -V UIWeekdayAbbreviatedNoYearDateFormat @ -V UIWeekdayFormat @ -V UIWeekdayNoYearDateFormat @ - -F UIDateFormatStringForFormatType @@ - -F UIApplicationUseLegacyEvents vB - -F UIKeyboardDisableAutomaticAppearance v -F UIKeyboardEnableAutomaticAppearance v -F UIKeyboardInputModeUsesKBStar B@ - -F _UIImageWithName @@ - -F UIFormattedPhoneNumberFromString @@ -F UIUnformattedPhoneNumberFromString @@ - -V UIApp @ - -V kUIButtonBarButtonAction @ -V kUIButtonBarButtonInfo @ -V kUIButtonBarButtonInfoOffset @ -V kUIButtonBarButtonSelectedInfo @ -V kUIButtonBarButtonSizeToFit @ -V kUIButtonBarButtonStyle @ -V kUIButtonBarButtonTag @ -V kUIButtonBarButtonTarget @ -V kUIButtonBarButtonTitle @ -V kUIButtonBarButtonTitleVerticalHeight @ -V kUIButtonBarButtonTitleWidth @ -V kUIButtonBarButtonType @ - -V UIKeyboardRequiresInternationalKey @ - -V UIKeyboardCandidateCorrectionDidChangeNotification @ -V UIKeyboardCurrentInputModeDidChangeNotification @ -V UIKeyboardDefaultsDidChangeNotification @ -V UIKeyboardDidHideNotification @ -V UIKeyboardDidShowNotification @ -V UIKeyboardEmptyDelegateNotification @ -V UIKeyboardWillHideNotification @ -V UIKeyboardWillShowNotification @ - -V UIWebViewDidReceiveMessageNotification @ -V UIWebViewDidClearMessagesNotification @ -V UIWebViewGrowsAndShrinksToFitHeight f -V UIWebViewGrowsAndShrinksToFitWidth f -V UIWebViewScalesToFitScale f - -f Security - -T OSStatus {ulong} - -F SecCertificateAddToKeychain {OSStatus}@@ -F SecCertificateCopyCommonName {OSStatus}@^@ -F SecCertificateCopyData @@ -F SecCertificateCopyEmailAddresses {OSStatus}@^@ -F SecCertificateCopyLongDescription @@@^@ -F SecCertificateCopyNormalizedIssuerContent @@^@ -F SecCertificateCopyNormalizedSubjectContent @@^@ -F SecCertificateCopyPreferred @@@ -F SecCertificateCopyPublicKey {OSStatus}@^@ -F SecCertificateCopySerialNumber @@^@ -F SecCertificateCopyShortDescription @@@^@ -F SecCertificateCopySubjectSummary @@ -F SecCertificateCopyValues @@@^@ -F SecCertificateCreateWithData @@@ -F SecCertificateGetItem @@^@ -F SecCertificateGetTypeID {CFTypeID} -F SecCertificateSetPreference {OSStatus}@@{uint32_t}@ -F SecCertificateSetPreferred {OSStatus}@@@ -F SecCopyErrorMessageString @{OSStatus}^v -F SecIdentityCopyCertificate {OSStatus}@^@ -F SecIdentityCopyPreferred @@@@ -F SecIdentityCopyPrivateKey {OSStatus}@^@ -F SecIdentityCopySystemIdentity {OSStatus}@^@^@ -F SecIdentityCreateWithCertificate {OSStatus}@@^@ -F SecIdentityGetTypeID {CFTypeID} -F SecIdentitySetPreferred {OSStatus}@@@ -F SecIdentitySetSystemIdentity {OSStatus}@@ -F SecKeyCreateFromData @@@^@ -F SecKeyDeriveFromPassword @@@^@ -F SecKeyGeneratePair {OSStatus}@^@^@ -F SecKeyGeneratePairAsync v@{dispatch_queue_t}@? -F SecKeyGenerateSymmetric @@^@ -F SecKeyGetBlockSize {size_t}@ -F SecKeyGetTypeID {CFTypeID} -F SecKeyUnwrapSymmetric @^@@@^@ -F SecKeyWrapSymmetric @@@@^@ -F SecPKCS12Import {OSStatus}@@^@ -F SecPolicyCopyProperties @@ -F SecPolicyCreateBasicX509 @ -F SecPolicyCreateSSL @B@ -F SecPolicyGetTypeID {CFTypeID} -F SecTrustCopyAnchorCertificates {OSStatus}^@ -F SecTrustCopyCustomAnchorCertificates {OSStatus}@^@ -F SecTrustCopyExceptions @@ -F SecTrustCopyPolicies {OSStatus}@^@ -F SecTrustCopyProperties @@ -F SecTrustCopyPublicKey @@ -F SecTrustCreateWithCertificates {OSStatus}@@^@ -F SecTrustEvaluate {OSStatus}@^@ -F SecTrustEvaluateAsync @{dispatch_queue_t}@? -F SecTrustGetCertificateAtIndex @@{CFIndex} -F SecTrustGetCertificateCount {CFIndex}@ -F SecTrustGetTrustResult {OSStatus}@^@ -F SecTrustGetTypeID {CFTypeID} -F SecTrustGetVerifyTime {CFAbsoluteTime}@ -F SecTrustSetAnchorCertificates {OSStatus}@@ -F SecTrustSetAnchorCertificatesOnly {OSStatus}@B -F SecTrustSetExceptions B@@ -F SecTrustSetKeychains {OSStatus}@@ -F SecTrustSetOptions {OSStatus}@{SecTrustOptionFlags} -F SecTrustSetPolicies {OSStatus}@@ -F SecTrustSettingsCopyCertificates {OSStatus}{SecTrustSettingsDomain}^@ -F SecTrustSettingsCopyModificationDate {OSStatus}@{SecTrustSettingsDomain}^@ -F SecTrustSettingsCopyTrustSettings {OSStatus}@{SecTrustSettingsDomain}^@ -F SecTrustSettingsCreateExternalRepresentation {OSStatus}{SecTrustSettingsDomain}^@ -F SecTrustSettingsImportExternalRepresentation {OSStatus}{SecTrustSettingsDomain}@ -F SecTrustSettingsRemoveTrustSettings {OSStatus}@{SecTrustSettingsDomain} -F SecTrustSettingsSetTrustSettings {OSStatus}@{SecTrustSettingsDomain}@ -F SecTrustSetVerifyDate {OSStatus}@@ - -C CSSM_CERT_STATUS_EXPIRED 0x00000001 -C CSSM_CERT_STATUS_NOT_VALID_YET 0x00000002 -C CSSM_CERT_STATUS_IS_IN_INPUT_CERTS 0x00000004 -C CSSM_CERT_STATUS_IS_IN_ANCHORS 0x00000008 -C CSSM_CERT_STATUS_IS_ROOT 0x00000010 -C CSSM_CERT_STATUS_IS_FROM_NET 0x00000020 - -C kSecPaddingNone 0 -C kSecPaddingPKCS1 1 -C kSecPaddingPKCS1MD2 0x8000 -C kSecPaddingPKCS1MD5 0x8001 -C kSecPaddingPKCS1SHA1 0x8002 - -C kSecTrustResultInvalid 0 -C kSecTrustResultProceed 1 -C kSecTrustResultConfirm 2 -C kSecTrustResultDeny 3 -C kSecTrustResultUnspecified 4 -C kSecTrustResultRecoverableTrustFailure 5 -C kSecTrustResultFatalTrustFailure 6 -C kSecTrustResultOtherError 7 - -C CSSM_TP_ACTION_ALLOW_EXPIRED 0x00000001 -C CSSM_TP_ACTION_LEAF_IS_CA 0x00000002 -C CSSM_TP_ACTION_FETCH_CERT_FROM_NET 0x00000004 -C CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT 0x00000008 - -V kSecImportItemLabel @ -V kSecImportItemKeyID @ -V kSecImportItemTrust @ -V kSecImportItemCertChain @ -V kSecImportItemIdentity @ - -V kSecIdentityDomainDefault @ -V kSecIdentityDomainKerberosKDC @ - -C kSecCredentialTypeDefault 0 -C kSecCredentialTypeWithUI 1 -C kSecCredentialTypeNoUI 2 - -T SecTrustSettingsDomain {uint32_t} -C kSecTrustSettingsDomainUser 0 -C kSecTrustSettingsDomainAdmin 1 -C kSecTrustSettingsDomainSystem 2 - -C kSecTrustSettingsKeyUseSignature 0x00000001 -C kSecTrustSettingsKeyUseEnDecryptData 0x00000002 -C kSecTrustSettingsKeyUseEnDecryptKey 0x00000004 -C kSecTrustSettingsKeyUseSignCert 0x00000008 -C kSecTrustSettingsKeyUseSignRevocation 0x00000010 -C kSecTrustSettingsKeyUseKeyExchange 0x00000020 -C kSecTrustSettingsKeyUseAny 0xffffffff - -C kSecTrustSettingsPolicy @"kSecTrustSettingsPolicy" -C kSecTrustSettingsApplication @"kSecTrustSettingsApplication" -C kSecTrustSettingsPolicyString @"kSecTrustSettingsPolicyString" -C kSecTrustSettingsKeyUsage @"kSecTrustSettingsKeyUsage" -C kSecTrustSettingsAllowedError @"kSecTrustSettingsAllowedError" -C kSecTrustSettingsResult @"kSecTrustSettingsResult" - -C kSecTrustSettingsResultInvalid 0 -C kSecTrustSettingsResultTrustRoot 1 -C kSecTrustSettingsResultTrustAsRoot 2 -C kSecTrustSettingsResultDeny 3 -C kSecTrustSettingsResultUnspecified 4 - -# XXX: this is a pointer... -C kSecTrustSettingsDefaultRootCertSetting -1 - -V kSecPropertyKeyType @ -V kSecPropertyKeyLabel @ -V kSecPropertyKeyLocalizedLabel @ -V kSecPropertyKeyValue @ - -V kSecPropertyTypeWarning @ -V kSecPropertyTypeSuccess @ -V kSecPropertyTypeSection @ -V kSecPropertyTypeData @ -V kSecPropertyTypeString @ -V kSecPropertyTypeURL @ -V kSecPropertyTypeDate @ -V kSecPropertyTypeTitle @ -V kSecPropertyTypeError @ - -V kSecCertificateUsageSigning @ -V kSecCertificateUsageSigningAndEncrypting @ -V kSecCertificateUsageDeriveAndSign @ - -V kSecPolicyOid @ -V kSecPolicyName @ -V kSecPolicyClient @ -V kSecPolicyKU_DigitalSignature @ -V kSecPolicyKU_NonRepudiation @ -V kSecPolicyKU_KeyEncipherment @ -V kSecPolicyKU_DataEncipherment @ -V kSecPolicyKU_KeyAgreement @ -V kSecPolicyKU_KeyCertSign @ -V kSecPolicyKU_CRLSign @ -V kSecPolicyKU_EncipherOnly @ -V kSecPolicyKU_DecipherOnly @ - -C kSecTrustOptionAllowExpired 0x00000001 -C kSecTrustOptionLeafIsCA 0x00000002 -C kSecTrustOptionFetchIssuerFromNet 0x00000004 -C kSecTrustOptionAllowExpiredRoot 0x00000008 -C kSecTrustOptionRequireRevPerCert 0x00000010 -C kSecTrustOptionImplicitAnchors 0x00000040 - -C kSecDefaultKeySize 0 -C kSec3DES192 192 -C kSecAES128 128 -C kSecAES192 192 -C kSecAES256 256 -C kSecp192r1 192 -C kSecp256r1 256 -C kSecp384r1 384 -C kSecp521r1 521 -C kSecRSAMin 1024 -C kSecRSAMax 4096 - -V kSecPolicyAppleX509Basic @ -V kSecPolicyAppleSSL @ -V kSecPolicyAppleSMIME @ -V kSecPolicyAppleEAP @ -V kSecPolicyAppleIPsec @ -V kSecPolicyAppleiCha @ -V kSecPolicyApplePKINITClient @ -V kSecPolicyApplePKINITServer @ -V kSecPolicyAppleCodeSigning @ -V kSecPolicyMacAppStoreReceipt @ -V kSecPolicyAppleIDValidation @ -V kSecPolicyAppleTimeStamping @ - -C errSecSuccess 0 -C errSecUnimplemented -4 -C errSecParam -50 -C errSecAllocate -108 -C errSecNotAvailable –25291 -C errSecReadOnly –25292 -C errSecAuthFailed –25293 -C errSecNoSuchKeychain –25294 -C errSecInvalidKeychain –25295 -C errSecDuplicateKeychain –25296 -C errSecDuplicateItem –25299 -C errSecItemNotFound –25300 -C errSecBufferTooSmall –25301 -C errSecDataTooLarge –25302 -C errSecNoSuchAttr –25303 -C errSecInvalidItemRef –25304 -C errSecInvalidSearchRef –25305 -C errSecNoSuchClass –25306 -C errSecNoDefaultKeychain –25307 -C errSecInteractionNotAllowed –25308 -C errSecReadOnlyAttr –25309 -C errSecWrongSecVersion –25310 -C errSecKeySizeNotAllowed –25311 -C errSecNoStorageModule –25312 -C errSecNoCertificateModule –25313 -C errSecNoPolicyModule –25314 -C errSecInteractionRequired –25315 -C errSecDataNotAvailable –25316 -C errSecDataNotModifiable –25317 -C errSecCreateChainFailed –25318 -C errSecInvalidPrefsDomain –25319 -C errSecACLNotSimple –25240 -C errSecPolicyNotFound –25241 -C errSecInvalidTrustSetting –25242 -C errSecNoAccessForItem –25243 -C errSecInvalidOwnerEdit –25244 -C errSecTrustNotAvailable –25245 -C errSecDecode -26275 - -f AddressBook - -# Private - -F CPPhoneNumberCopyNetworkCountryCode @ -F ABCGetSharedAddressBook @ -F ABCFindPersonMatchingPhoneNumberWithCountry @@@@^i^i -F ABCRecordCopyCompositeName @@ -F ABCFindPersonMatchingPhoneNumber @@@^i^i -F ABCCopyLocalizedPropertyOrLabel @i - -# Public - -F ABAddressBookAddRecord B@@^@ -F ABAddressBookCopyArrayOfAllGroups @@ -F ABAddressBookCopyArrayOfAllPeople @@ -F ABAddressBookCopyLocalizedLabel @@ -F ABAddressBookCreate @ -F ABAddressBookGetGroupCount l@ -F ABAddressBookGetPersonCount l@ -F ABAddressBookHasUnsavedChanges B@ -F ABAddressBookRegisterExternalChangeCallback v@^?^v -F ABAddressBookRemoveRecord B@@^@ -F ABAddressBookRevert v@ -F ABAddressBookSave B@^@ -F ABAddressBookUnregisterExternalChangeCallback v@^?^v - -V ABAddressBookErrorDomain @ -C kABOperationNotPermittedByStoreError 0 - -F ABMultiValueCopyArrayOfAllValues @@ -F ABMultiValueCopyLabelAtIndex @@l -F ABMultiValueCopyValueAtIndex @@l -F ABMultiValueGetCount l@ -F ABMultiValueGetFirstIndexOfValue l@@ -F ABMultiValueGetIdentifierAtIndex i@l -F ABMultiValueGetIndexForIdentifier l@i -F ABMultiValueGetPropertyType S@ - -C kABMultiValueInvalidIdentifier -1 - -F ABMultiValueAddValueAndLabel @@@^i -F ABMultiValueCreateMutable @S -F ABMultiValueCreateMutableCopy @@ -F ABMultiValueInsertValueAndLabelAtIndex B@@@l^i -F ABMultiValueRemoveValueAndLabelAtIndex B@l -F ABMultiValueReplaceLabelAtIndex B@@l -F ABMultiValueReplaceValueAtIndex B@@l - -F ABRecordCopyCompositeName @@ -F ABRecordCopyValue @@i -F ABRecordGetRecordID i@ -F ABRecordGetRecordType I@ -F ABRecordRemoveValue B@i^@ -F ABRecordSetValue B@i@^@ - -C kABPersonType 0 -C kABGroupType 1 - -# this was (1<<8) -C kABMultiValueMask 0x100 - -C kABInvalidPropertyType 0x0 -C kABStringPropertyType 0x1 -C kABIntegerPropertyType 0x2 -C kABRealPropertyType 0x3 -C kABDateTimePropertyType 0x4 -C kABDictionaryPropertyType 0x5 -C kABMultiStringPropertyType 0x101 -C kABMultiIntegerPropertyType 0x102 -C kABMultiRealPropertyType 0x103 -C kABMultiDateTimePropertyType 0x104 -C kABMultiDictionaryPropertyType 0x105 - -C kABRecordInvalidID -1 -C kABPropertyInvalidID -1 - -F ABAddressBookGetGroupWithRecordID @@i -F ABGroupAddMember B@@^@ -F ABGroupCopyArrayOfAllMembers @@ -F ABGroupCopyArrayOfAllMembersWithSortOrdering @@I -F ABGroupCreate @ -F ABGroupRemoveMember B@@^@ - -V kABGroupNameProperty i - -F ABAddressBookCopyPeopleWithName @@@ -F ABAddressBookGetPersonWithRecordID @@i -F ABPersonComparePeopleByName i@@I -F ABPersonCopyImageData @@ -F ABPersonCopyLocalizedPropertyName @i -F ABPersonCreate @ -F ABPersonGetCompositeNameFormat I -F ABPersonGetSortOrdering I -F ABPersonGetTypeOfProperty SI -F ABPersonHasImageData B@ -F ABPersonRemoveImageData B@^@ -F ABPersonSetImageData B@@^@ - -C kABPersonSortByFirstName 0 -C kABPersonSortByLastName 1 - -C kABPersonCompositeNameFormatFirstNameFirst 0 -C kABPersonCompositeNameFormatLastNameFirst 1 - -V kABPersonFirstNameProperty i -V kABPersonLastNameProperty i -V kABPersonMiddleNameProperty i -V kABPersonPrefixProperty i -V kABPersonSuffixProperty i -V kABPersonNicknameProperty i -V kABPersonFirstNamePhoneticProperty i -V kABPersonLastNamePhoneticProperty i -V kABPersonMiddleNamePhoneticProperty i -V kABPersonOrganizationProperty i -V kABPersonJobTitleProperty i -V kABPersonDepartmentProperty i -V kABPersonEmailProperty i -V kABPersonBirthdayProperty i -V kABPersonNoteProperty i -V kABPersonCreationDateProperty i -V kABPersonModificationDateProperty i - -V kABPersonAddressProperty i -V kABPersonAddressStreetKey @ -V kABPersonAddressCityKey @ -V kABPersonAddressStateKey @ -V kABPersonAddressZIPKey @ -V kABPersonAddressCountryKey @ -V kABPersonAddressCountryCodeKey @ - -V kABPersonDateProperty i -V kABPersonAnniversaryLabel @ - -V kABPersonKindProperty i -V kABPersonKindPerson @ -V kABPersonKindOrganization @ - -V kABPersonPhoneProperty i -V kABPersonPhoneMobileLabel @ -V kABPersonPhoneIPhoneLabel @ -V kABPersonPhoneMainLabel @ -V kABPersonPhoneHomeFAXLabel @ -V kABPersonPhoneWorkFAXLabel @ -V kABPersonPhonePagerLabel @ - -V kABPersonInstantMessageProperty i -V kABPersonInstantMessageServiceKey @ -V kABPersonInstantMessageServiceYahoo @ -V kABPersonInstantMessageServiceJabber @ -V kABPersonInstantMessageServiceMSN @ -V kABPersonInstantMessageServiceICQ @ -V kABPersonInstantMessageServiceAIM @ -V kABPersonInstantMessageUsernameKey @ - -V kABPersonURLProperty i -V kABPersonHomePageLabel @ - -V kABPersonRelatedNamesProperty i -V kABPersonMotherLabel @ -V kABPersonFatherLabel @ -V kABPersonParentLabel @ -V kABPersonSisterLabel @ -V kABPersonBrotherLabel @ -V kABPersonChildLabel @ -V kABPersonFriendLabel @ -V kABPersonSpouseLabel @ -V kABPersonPartnerLabel @ -V kABPersonManagerLabel @ -V kABPersonAssistantLabel @ - -V kABWorkLabel @ -V kABHomeLabel @ -V kABOtherLabel @ - -f Calendar - -F CalDatabaseCopyEventOccurrencesInDateRange {CFArrayRef}^{CalDatabase}^{CalFilter}{CFGregorianDate}{CFGregorianDate}{CFTimeZoneRef} -F CalFilterCreateWithDatabase ^{CalFilter}^{CalDatabase} - -F CalEventOccurrenceGetEvent @@ -F CalEventCopySummary @@ -F CalEventIsAllDay B@ -F CalEventOccurrenceGetDate I@ - -f CoreAnimation - -S CATransform3D "m11"{CGFloat}"m12"{CGFloat}"m13"{CGFloat}"m14"{CGFloat}"m21"{CGFloat}"m22"{CGFloat}"m23"{CGFloat}"m24"{CGFloat}"m31"{CGFloat}"m32"{CGFloat}"m33"{CGFloat}"m34"{CGFloat}"m41"{CGFloat}"m42"{CGFloat}"m43"{CGFloat}"m44"{CGFloat} - -F CACurrentMediaTime {CFTimeInterval} - -F CATransform3DIsIdentity B{CATransform3D} -F CATransform3DEqualToTransform B{CATransform3D}{CATransform3D} -F CATransform3DMakeTranslation {CATransform3D}{CGFloat}{CGFloat}{CGFloat} -F CATransform3DMakeScale {CATransform3D}{CGFloat}{CGFloat}{CGFloat} -F CATransform3DMakeRotation {CATransform3D}{CGFloat}{CGFloat}{CGFloat}{CGFloat} -F CATransform3DTranslate {CATransform3D}{CATransform3D}{CGFloat}{CGFloat}{CGFloat} -F CATransform3DScale {CATransform3D}{CATransform3D}{CGFloat}{CGFloat}{CGFloat} -F CATransform3DRotate {CATransform3D}{CATransform3D}{CGFloat}{CGFloat}{CGFloat}{CGFloat} -F CATransform3DConcat {CATransform3D}{CATransform3D}{CATransform3D} -F CATransform3DInvert {CATransform3D}{CATransform3D} -F CATransform3DMakeAffineTransform {CATransform3D}{CGAffineTransform} -F CATransform3DIsAffine B{CATransform3D} -F CATransform3DGetAffineTransform {CGAffineTransform}{CATransform3D} - -f CoreData - -C NSUndefinedAttributeType 0 -C NSInteger16AttributeType 100 -C NSInteger32AttributeType 200 -C NSInteger64AttributeType 300 -C NSDecimalAttributeType 400 -C NSDoubleAttributeType 500 -C NSFloatAttributeType 600 -C NSStringAttributeType 700 -C NSBooleanAttributeType 800 -C NSDateAttributeType 900 -C NSBinaryDataAttributeType 1000 -C NSTransformableAttributeType 1800 -C NSObjectIDAttributeType 2000 - -C NSUndefinedEntityMappingType 0x00 -C NSCustomEntityMappingType 0x01 -C NSAddEntityMappingType 0x02 -C NSRemoveEntityMappingType 0x03 -C NSCopyEntityMappingType 0x04 -C NSTransformEntityMappingType 0x05 - -V NSMigrationManagerKey @ -V NSMigrationSourceObjectKey @ -V NSMigrationDestinationObjectKey @ -V NSMigrationEntityMappingKey @ -V NSMigrationPropertyMappingKey @ -V NSMigrationEntityPolicyKey @ - -C NSManagedObjectResultType 0x00 -C NSManagedObjectIDResultType 0x01 -C NSDictionaryResultType 0x02 - -C NSFetchRequestExpressionType 50 - -C NSSnapshotEventUndoInsertion 1<<1 -C NSSnapshotEventUndoDeletion 1<<2 -C NSSnapshotEventUndoUpdate 1<<3 -C NSSnapshotEventRollback 1<<4 -C NSSnapshotEventRefresh 1<<5 -C NSSnapshotEventMergePolicy 1<<6 - -V NSInsertedObjectsKey @ -V NSUpdatedObjectsKey @ -V NSDeletedObjectsKey @ -V NSRefreshedObjectsKey @ -V NSInvalidatedObjectsKey @ -V NSInvalidatedAllObjectsKey @ - -V NSErrorMergePolicy @ -V NSMergeByPropertyStoreTrumpMergePolicy @ -V NSMergeByPropertyObjectTrumpMergePolicy @ -V NSOverwriteMergePolicy @ -V NSRollbackMergePolicy @ - -V NSSQLiteStoreType @ -V NSBinaryStoreType @ -V NSInMemoryStoreType @ - -V NSStoreTypeKey @ -V NSStoreUUIDKey @ - -V NSAddedPersistentStoresKey @ -V NSRemovedPersistentStoresKey @ -V NSUUIDChangedPersistentStoresKey @ - -V NSReadOnlyPersistentStoreOption @ -V NSPersistentStoreTimeoutOption @ -V NSSQLitePragmasOption @ -V NSSQLiteAnalyzeOption @ -V NSSQLiteManualVacuumOption @ - -V NSIgnorePersistentStoreVersioningOption @ -V NSMigratePersistentStoresAutomaticallyOption @ -V NSInferMappingModelAutomaticallyOption @ - -V NSStoreModelVersionHashesKey @ -V NSStoreModelVersionIdentifiersKey @ -V NSPersistentStoreOSCompatibility @ - -C NSNoActionDeleteRule 0 -C NSNullifyDeleteRule 1 -C NSCascadeDeleteRule 2 -C NSDenyDeleteRule 3 - -C NSFetchedResultsChangeInsert 1 -C NSFetchedResultsChangeDelete 2 -C NSFetchedResultsChangeMove 3 -C NSFetchedResultsChangeUpdate 4 - -V NSDetailedErrorsKey @ -V NSValidationObjectErrorKey @ -V NSValidationKeyErrorKey @ -V NSValidationPredicateErrorKey @ -V NSValidationValueErrorKey @ -V NSAffectedStoresErrorKey @ -V NSAffectedObjectsErrorKey @ - -V NSSQLiteErrorDomain @ - -C NSManagedObjectValidationError 1550 -C NSValidationMultipleErrorsError 1560 -C NSValidationMissingMandatoryPropertyError 1570 -C NSValidationRelationshipLacksMinimumCountError 1580 -C NSValidationRelationshipExceedsMaximumCountError 1590 -C NSValidationRelationshipDeniedDeleteError 1600 -C NSValidationNumberTooLargeError 1610 -C NSValidationNumberTooSmallError 1620 -C NSValidationDateTooLateError 1630 -C NSValidationDateTooSoonError 1640 -C NSValidationInvalidDateError 1650 -C NSValidationStringTooLongError 1660 -C NSValidationStringTooShortError 1670 -C NSValidationStringPatternMatchingError 1680 - -C NSManagedObjectContextLockingError 132000 -C NSPersistentStoreCoordinatorLockingError 132010 -C NSManagedObjectReferentialIntegrityError 133000 -C NSManagedObjectExternalRelationshipError 133010 -C NSManagedObjectMergeError 133020 - -C NSPersistentStoreInvalidTypeError 134000 -C NSPersistentStoreTypeMismatchError 134010 -C NSPersistentStoreIncompatibleSchemaError 134020 -C NSPersistentStoreSaveError 134030 -C NSPersistentStoreIncompleteSaveError 134040 -C NSPersistentStoreOperationError 134070 -C NSPersistentStoreOpenError 134080 -C NSPersistentStoreTimeoutError 134090 -C NSPersistentStoreIncompatibleVersionHashError 134100 - -C NSMigrationError 134110 -C NSMigrationCancelledError 134120 -C NSMigrationMissingSourceModelError 134130 -C NSMigrationMissingMappingModelError 134140 -C NSMigrationManagerSourceStoreError 134150 -C NSMigrationManagerDestinationStoreError 134160 -C NSEntityMigrationPolicyError 134170 -C NSInferredMappingModelError 134190 -C NSExternalRecordImportError 134200 - -C NSCoreDataError 134060 -C NSSQLiteError 134180 - -V NSCoreDataVersionNumber d - -C NSCoreDataVersionNumber10_4 46.0 -C NSCoreDataVersionNumber10_4_3 77.0 -C NSCoreDataVersionNumber10_5 185.0 -C NSCoreDataVersionNumber10_5_3 186.0 - -f CoreFoundation - -# Base Utilities - -F CFRangeMake {CFRange}{CFIndex}{CFIndex} - -# Time Utilities - -F CFAbsoluteTimeAddGregorianUnits {CFAbsoluteTime}{CFAbsoluteTime}{CFTimeZoneRef}{CFGregorianUnits} -F CFAbsoluteTimeGetCurrent {CFAbsoluteTime} -F CFAbsoluteTimeGetDayOfWeek {SInt32}{CFAbsoluteTime}{CFTimeZoneRef} -F CFAbsoluteTimeGetDayOfYear {SInt32}{CFAbsoluteTime}{CFTimeZoneRef} -F CFAbsoluteTimeGetDifferenceAsGregorianUnits {CFGregorianUnits}{CFAbsoluteTime}{CFAbsoluteTime}{CFTimeZoneRef}{CFOptionFlags} -F CFAbsoluteTimeGetGregorianDate {CFGregorianDate}{CFAbsoluteTime}{CFTimeZoneRef} -F CFAbsoluteTimeGetWeekOfYear {SInt32}{CFAbsoluteTime}{CFTimeZoneRef} -F CFGregorianDateGetAbsoluteTime {CFAbsoluteTime}{CFGregorianDate}{CFTimeZoneRef} -F CFGregorianDateIsValid {Boolean}{CFGregorianDate}{CFOptionFlags} - -T CFAbsoluteTime {CFTimeInterval} -S CFGregorianDate "year"{SInt32}"month"{SInt8}"day"{SInt8}"hour"{SInt8}"minute"{SInt8}"second"{double} -S CFGregorianUnits "years"{SInt32}"months"{SInt32}"days"{SInt32}"hours"{SInt32}"minutes"{SInt32}"second"{double} -T CFTimeInterval {double} - -C kCFGregorianUnitsYears 1<<0 -C kCFGregorianUnitsMonths 1<<1 -C kCFGregorianUnitsDays 1<<2 -C kCFGregorianUnitsHours 1<<3 -C kCFGregorianUnitsMinutes 1<<4 -C kCFGregorianUnitsSeconds 1<<5 -C kCFGregorianAllUnits 0x00FFFFFF - -V kCFAbsoluteTimeIntervalSince1970 {CFTimeInterval} -V kCFAbsoluteTimeIntervalSince1904 {CFTimeInterval} - -# CFComparatorFunction - -T CFIndex l -T CFOptionFlags {UInt32} -S CFRange "location"{CFIndex}"length"{CFIndex} - -E CFComparisonResult -C kCFCompareLessThan -1 -C kCFCompareEqualTo 0 -C kCFCompareGreaterThan 1 -# CFComparisonResult CFComparisonResult - -C kCFNotFound -1 - -V kCFCoreFoundationVersionNumber d - -C kCFCoreFoundationVersionNumber10_0 196.40 -C kCFCoreFoundationVersionNumber10_0_3 196.50 -C kCFCoreFoundationVersionNumber10_1 226.00 -C kCFCoreFoundationVersionNumber10_1_1 226.00 -C kCFCoreFoundationVersionNumber10_1_2 227.20 -C kCFCoreFoundationVersionNumber10_1_3 227.20 -C kCFCoreFoundationVersionNumber10_1_4 227.30 -C kCFCoreFoundationVersionNumber10_2 263.00 -C kCFCoreFoundationVersionNumber10_2_1 263.10 -C kCFCoreFoundationVersionNumber10_2_2 263.10 -C kCFCoreFoundationVersionNumber10_2_3 263.30 -C kCFCoreFoundationVersionNumber10_2_4 263.30 -C kCFCoreFoundationVersionNumber10_2_5 263.50 -C kCFCoreFoundationVersionNumber10_2_6 263.50 -C kCFCoreFoundationVersionNumber10_2_7 263.50 -C kCFCoreFoundationVersionNumber10_2_8 263.50 -C kCFCoreFoundationVersionNumber10_3 299.00 -C kCFCoreFoundationVersionNumber10_3_1 299.00 -C kCFCoreFoundationVersionNumber10_3_2 299.00 -C kCFCoreFoundationVersionNumber10_3_3 299.30 -C kCFCoreFoundationVersionNumber10_3_4 299.31 -C kCFCoreFoundationVersionNumber10_3_5 299.31 -C kCFCoreFoundationVersionNumber10_3_6 299.32 -C kCFCoreFoundationVersionNumber10_3_7 299.33 -C kCFCoreFoundationVersionNumber10_3_8 299.33 -C kCFCoreFoundationVersionNumber10_3_9 299.35 -C kCFCoreFoundationVersionNumber10_4 368.00 -C kCFCoreFoundationVersionNumber10_4_1 368.10 -C kCFCoreFoundationVersionNumber10_4_2 368.11 -C kCFCoreFoundationVersionNumber10_4_3 368.18 -C kCFCoreFoundationVersionNumber10_4_4_Intel 368.26 -C kCFCoreFoundationVersionNumber10_4_4_PowerPC 368.25 -C kCFCoreFoundationVersionNumber10_4_5_Intel 368.26 -C kCFCoreFoundationVersionNumber10_4_5_PowerPC 368.25 -C kCFCoreFoundationVersionNumber10_4_6_Intel 368.26 -C kCFCoreFoundationVersionNumber10_4_6_PowerPC 368.25 -C kCFCoreFoundationVersionNumber10_4_7 368.27 -C kCFCoreFoundationVersionNumber10_4_8 368.27 -C kCFCoreFoundationVersionNumber10_4_9 368.28 -C kCFCoreFoundationVersionNumber10_4_10 368.28 -C kCFCoreFoundationVersionNumber10_4_11 368.31 -C kCFCoreFoundationVersionNumber10_5 476.00 -C kCFCoreFoundationVersionNumber10_5_1 476.00 -C kCFCoreFoundationVersionNumber10_5_2 476.10 -C kCFCoreFoundationVersionNumber10_5_3 476.13 -C kCFCoreFoundationVersionNumber10_5_4 476.14 -C kCFCoreFoundationVersionNumber10_5_5 476.15 -C kCFCoreFoundationVersionNumber10_5_6 476.17 - -# CFAllocator - -F CFAllocatorCreate {CFAllocatorRef}{CFAllocatorRef}{CFAllocatorContext} - -F CFAllocatorAllocate ^v{CFAllocatorRef}{CFIndex}{CFOptionFlags} -F CFAllocatorDeallocate v{CFAllocatorRef}^v -F CFAllocatorGetPreferredSizeForSize {CFIndex}{CFAllocatorRef}{CFIndex}{CFOptionFlags} -F CFAllocatorReallocate ^v{CFAllocatorRef}^v{CFIndex}{CFOptionFlags} - -F CFAllocatorGetDefault {CFAllocatorRef} -f CFAllocatorSetDefault v{CFAllocatorRef} - -F CFAllocatorGetContext v{CFAllocatorRef}^{CFAllocatorContext} - -F CFAllocatorGetTypeID {CFTypeID} - -# CFAllocatorAllocateCallBack -# CFAllocatorCopyDescriptionCallBack -# CFAllocatorDeallocateCallBack -# CFAllocatorPreferredSizeCallBack -# CFAllocatorReallocateCallBack -# CFAllocatorReleaseCallBack -# CFAllocatorRetainCallBack - -S CFAllocatorContext "version"{CFIndex}"info"^v"retain"{CFAllocatorRetainCallBack}"release"{CFAllocatorReleaseCallBack}"copyDescription"{CFAllocatorCopyDescriptionCallBack}"allocate"{CFAllocatorAllocateCallBack}"reallocate"{CFAllocatorReallocateCallBack}"deallocate"{CFAllocatorDeallocateCallBack}"preferredSize"{CFAllocatorPreferredSizeCallBack} -# CFAllocatorContext CFAllocatorContext - -T CFAllocatorRef @ -# CFAllocatorRef ^r{__CFAllocator} - -V kCFAllocatorDefault {CFAllocatorRef} -V kCFAllocatorSystemDefault {CFAllocatorRef} -V kCFAllocatorMalloc {CFAllocatorRef} -V kCFAllocatorMallocZone {CFAllocatorRef} -V kCFAllocatorNull {CFAllocatorRef} -V kCFAllocatorUseContext {CFAllocatorRef} - -# CFByteOrderUtils - -E __CFByteOrder -C CFByteOrderUnknown 0 -C CFByteOrderLittleEndian 1 -C CFByteOrderBigEndian 2 -T CFByteOrder __CFByteOrder - -# CFArray - -T CFArrayRef @ - -# CFData - -F CFDataCreate {CFDataRef}{CFAllocatorRef}^r{UInt8}{CFIndex} -F CFDataCreateCopy {CFDataRef}{CFAllocatorRef}{CFDataRef} -F CFDataCreateWithBytesNoCopy {CFDataRef}{CFAllocatorRef}^r{UInt8}{CFIndex}{CFAllocatorRef} - -F CFDataGetBytePtr ^r{UInt8}{CFDataRef} -F CFDataGetBytes v{CFDataRef}{CFRange}^{UInt8} -F CFDataGetLength {CFIndex}{CFDataRef} - -F CFDataGetTypeID {CFTypeID} - -T CFDataRef @ -# CFDataRef ^r{__CFData} - -# CFDate - -F CFDateCompare {CFComparisonResult}{CFDateRef}{CFDateRef}^v -F CFDateCreate {CFDateRef}{CFAllocatorRef}{CFAbsoluteTime} -F CFDateGetAbsoluteTime {CFAbsoluteTime}{CFDateRef} -F CFDateGetTimeIntervalSinceDate {CFTimeInterval}{CFDateRef}{CFDateRef} -F CFDateGetTypeID {CFTypeID} - -T CFDateRef @ -# CFDateRef ^r{__CFDate} - -# CFDateFormatter - -F CFDateFormatterCreate {CFDateFormatterRef}{CFAllocatorRef}{CFLocaleRef}{CFDateFormatterStyle}{CFDateFormatterStyle} - -F CFDateFormatterSetFormat v{CFDateFormatterRef}{CFStringRef} -F CFDateFormatterSetProperty v{CFDateFormatterRef}{CFStringRef}{CFTypeRef} - -F CFDateFormatterCreateDateFromString {CFDateRef}{CFAllocatorRef}{CFDateFormatterRef}{CFStringRef}^{CFRange} -F CFDateFormatterGetAbsoluteTimeFromString {Boolean}{CFDateFormatterRef}{CFStringRef}^{CFRange}^{CFAbsoluteTime} - -F CFDateFormatterCreateStringWithAbsoluteTime {CFStringRef}{CFAllocatorRef}{CFDateFormatterRef}{CFAbsoluteTime} -F CFDateFormatterCreateStringWithDate {CFStringRef}{CFAllocatorRef}{CFDateFormatterRef}{CFDateRef} -F CFDateFormatterCreateDateFormatFromTemplate {CFStringRef}{CFAllocatorRef}{CFStringRef}{CFOptionFlags}{CFLocaleRef} - -F CFDateFormatterCopyProperty {CFTypeRef}{CFDateFormatterRef}{CFStringRef} -F CFDateFormatterGetDateStyle {CFDateFormatterStyle}{CFDateFormatterRef} -F CFDateFormatterGetFormat {CFStringRef}{CFDateFormatterRef} -F CFDateFormatterGetLocale {CFLocaleRef}{CFDateFormatterRef} -F CFDateFormatterGetTimeStyle {CFDateFormatterStyle}{CFDateFormatterRef} - -F CFDateFormatterGetTypeID {CFTypeID} - -T CFDateFormatterRef @ -# CFDateFormatterRef ^r{__CFDateFormatter} - -T CFDateFormatterStyle {CFIndex} - -C kCFDateFormatterNoStyle 0 -C kCFDateFormatterShortStyle 1 -C kCFDateFormatterMediumStyle 2 -C kCFDateFormatterLongStyle 3 -C kCFDateFormatterFullStyle 4 - -V kCFDateFormatterIsLenient @ -V kCFDateFormatterTimeZone @ -V kCFDateFormatterCalendarName @ -V kCFDateFormatterDefaultFormat @ - -V kCFDateFormatterTwoDigitStartDate @ -V kCFDateFormatterDefaultDate @ -V kCFDateFormatterCalendar @ -V kCFDateFormatterEraSymbols @ -V kCFDateFormatterMonthSymbols @ -V kCFDateFormatterShortMonthSymbols @ -V kCFDateFormatterWeekdaySymbols @ -V kCFDateFormatterShortWeekdaySymbols @ -V kCFDateFormatterAMSymbol @ -V kCFDateFormatterPMSymbol @ - -V kCFDateFormatterLongEraSymbols @ -V kCFDateFormatterVeryShortMonthSymbols @ -V kCFDateFormatterStandaloneMonthSymbols @ -V kCFDateFormatterShortStandaloneMonthSymbols @ -V kCFDateFormatterVeryShortStandaloneMonthSymbols @ -V kCFDateFormatterVeryShortWeekdaySymbols @ -V kCFDateFormatterStandaloneWeekdaySymbols @ -V kCFDateFormatterShortStandaloneWeekdaySymbols @ -V kCFDateFormatterVeryShortStandaloneWeekdaySymbols @ -V kCFDateFormatterQuarterSymbols @ -V kCFDateFormatterShortQuarterSymbols @ -V kCFDateFormatterStandaloneQuarterSymbols @ -V kCFDateFormatterShortStandaloneQuarterSymbols @ -V kCFDateFormatterGregorianStartDate @ - -V CFGregorianCalendar @ - -# CFLocale - -F CFLocaleCopyCurrent {CFLocaleRef} -F CFLocaleCreate {CFLocaleRef}{CFAllocatorRef}{CFStringRef} -F CFLocaleCreateCopy {CFLocaleRef}{CFAllocatorRef}{CFLocaleRef} -F CFLocaleGetSystem {CFLocaleRef} - -F CFLocaleCopyAvailableLocaleIdentifiers {CFArrayRef} - -F CFLocaleCopyISOCountryCodes {CFArrayRef} -F CFLocaleCopyISOLanguageCodes {CFArrayRef} -F CFLocaleCopyISOCurrencyCodes {CFArrayRef} -F CFLocaleCopyCommonISOCurrencyCodes {CFArrayRef} - -F CFLocaleCopyPreferredLanguages {CFArrayRef} - -F CFLocaleCopyDisplayNameForPropertyValue {CFStringRef}{CFLocaleRef}{CFStringRef}{CFStringRef} -F CFLocaleGetValue {CFTypeRef}{CFLocaleRef}{CFStringRef} -F CFLocaleGetIdentifier {CFStringRef}{CFLocaleRef} - -F CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes {CFStringRef}{CFAllocatorRef}{LangCode}{RegionCode} -F CFLocaleCreateCanonicalLanguageIdentifierFromString {CFStringRef}{CFAllocatorRef}{CFStringRef} -F CFLocaleCreateCanonicalLocaleIdentifierFromString {CFStringRef}{CFAllocatorRef}{CFStringRef} -F CFLocaleCreateComponentsFromLocaleIdentifier {CFDictionaryRef}{CFAllocatorRef}{CFStringRef} -F CFLocaleCreateLocaleIdentifierFromComponents {CFStringRef}{CFAllocatorRef}{CFDictionaryRef} - -F CFLocaleGetTypeID {CFTypeID} - -F CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode {CFStringRef}{CFAllocatorRef}{uint32_t} -F CFLocaleGetLanguageCharacterDirection {CFLocaleLanguageDirection}{CFStringRef} -F CFLocaleGetLanguageLineDirection {CFLocaleLanguageDirection}{CFStringRef} -F CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier {uint32_t}{CFStringRef} - -T CFLocaleRef @ -# CFLocaleRef ^r{__CFLocale} - -C kCFLocaleLanguageDirectionUnknown 0 -C kCFLocaleLanguageDirectionLeftToRight 1 -C kCFLocaleLanguageDirectionRightToLeft 2 -C kCFLocaleLanguageDirectionTopToBottom 3 -C kCFLocaleLanguageDirectionBottomToTop 4 - -T CFLocaleLanguageDirection {CFIndex} - -V kCFLocaleMeasurementSystem @ -V kCFLocaleDecimalSeparator @ -V kCFLocaleGroupingSeparator @ -V kCFLocaleCurrencySymbol @ -V kCFLocaleCurrencyCode @ - -V kCFLocaleIdentifier @ -V kCFLocaleLanguageCode @ -V kCFLocaleCountryCode @ -V kCFLocaleScriptCode @ -V kCFLocaleVariantCode @ -V kCFLocaleExemplarCharacterSet @ -V kCFLocaleCalendarIdentifier @ -V kCFLocaleCalendar @ -V kCFLocaleCollationIdentifier @ -V kCFLocaleUsesMetricSystem @ - -V kCFGregorianCalendar @ -V kCFBuddhistCalendar @ -V kCFChineseCalendar @ -V kCFHebrewCalendar @ -V kCFIslamicCalendar @ -V kCFIslamicCivilCalendar @ -V kCFJapaneseCalendar @ -V kCFRepublicOfChinaCalendar @ -V kCFPersianCalendar @ -V kCFIndianCalendar @ -V kCFISO8601Calendar @ - -V kCFLocaleCurrentLocaleDidChangeNotificatio @ - -# CFRunLoop - -F CFRunLoopGetCurrent {CFRunLoopRef} -F CFRunLoopGetMain {CFRunLoopRef} - -F CFRunLoopRun v -F CFRunLoopRunInMode {SInt32}{CFStringRef}{CFTimeInterval}{Boolean} -F CFRunLoopWakeUp v{CFRunLoopRef} -F CFRunLoopStop v{CFRunLoopRef} -F CFRunLoopIsWaiting {Boolean}{CFRunLoopRef} - -F CFRunLoopAddSource v{CFRunLoopRef}{CFRunLoopSourceRef}{CFStringRef} -F CFRunLoopContainsSource {Boolean}{CFRunLoopRef}{CFRunLoopSourceRef}{CFStringRef} -F CFRunLoopRemoveSource v{CFRunLoopRef}{CFRunLoopSourceRef}{CFStringRef} - -F CFRunLoopAddObserver v{CFRunLoopRef}{CFRunLoopObserverRef}{CFStringRef} -F CFRunLoopContainsObserver {Boolean}{CFRunLoopRef}{CFRunLoopObserverRef}{CFStringRef} -F CFRunLoopRemoveObserver v{CFRunLoopRef}{CFRunLoopObserverRef}{CFStringRef} - -F CFRunLoopAddCommonMode v{CFRunLoopRef}{CFStringRef} -F CFRunLoopCopyAllModes {CFArrayRef}{CFRunLoopRef} -F CFRunLoopCopyCurrentMode {CFStringRef}{CFRunLoopRef} - -F CFRunLoopAddTimer v{CFRunLoopRef}{CFRunLoopTimerRef}{CFStringRef} -F CFRunLoopGetNextTimerFireDate {CFAbsoluteTime}{CFRunLoopRef}{CFStringRef} -F CFRunLoopRemoveTimer v{CFRunLoopRef}{CFRunLoopTimerRef}{CFStringRef} -F CFRunLoopContainsTimer {Boolean}{CFRunLoopRef}{CFRunLoopTimerRef}{CFStringRef} - -# F CFRunLoopPerformBlock - -F CFRunLoopGetTypeID {CFTypeID} - -T CFRunLoopRef @ - -C kCFRunLoopRunFinished 1 -C kCFRunLoopRunStopped 2 -C kCFRunLoopRunTimedOut 3 -C kCFRunLoopRunHandledSource 4 - -V kCFRunLoopCommonModes {CFStringRef} -V kCFRunLoopDefaultMode {CFStringRef} - -# CFRunLoopTimer - -T CFRunLoopTimerRef @ - -# CFString - -T CFStringRef @ - -# CFTimeZone - -F CFTimeZoneCreateWithName {CFTimeZoneRef}{CFAllocatorRef}{CFStringRef}{Boolean} -F CFTimeZoneCreateWithTimeIntervalFromGMT {CFTimeZoneRef}{CFAllocatorRef}{CFTimeInterval} -F CFTimeZoneCreate {CFTimeZoneRef}{CFAllocatorRef}{CFStringRef}{CFDataRef} - -F CFTimeZoneCopyAbbreviationDictionary {CFDictionaryRef} -F CFTimeZoneCopyAbbreviation {CFStringRef}{CFTimeZoneRef}{CFAbsoluteTime} -F CFTimeZoneCopyDefault {CFTimeZoneRef} -F CFTimeZoneCopySystem {CFTimeZoneRef} -F CFTimeZoneSetDefault v{CFTimeZoneRef} -F CFTimeZoneCopyKnownNames {CFArrayRef} -F CFTimeZoneResetSystem v -F CFTimeZoneSetAbbreviationDictionary v{CFDictionaryRef} - -F CFTimeZoneGetName {CFStringRef}{CFTimeZoneRef} -F CFTimeZoneCopyLocalizedName {CFStringRef}{CFTimeZoneRef}{CFTimeZoneNameStyle}{CFLocaleRef} -F CFTimeZoneGetSecondsFromGMT {CFTimeInterval}{CFTimeZoneRef}{CFAbsoluteTime} -F CFTimeZoneGetData {CFDataRef}{CFTimeZoneRef} - -F CFTimeZoneIsDaylightSavingTime {Boolean}{CFTimeZoneRef}{CFAbsoluteTime} -F CFTimeZoneGetDaylightSavingTimeOffset {CFTimeInterval}{CFTimeZoneRef}{CFAbsoluteTime} -F CFTimeZoneGetNextDaylightSavingTimeTransition {CFAbsoluteTime}{CFTimeZoneRef}{CFAbsoluteTime} - -F CFTimeZoneGetTypeID {CFTypeID} - -T CFTimeZoneNameStyle {CFIndex} -T CFTimeZoneRef @ -# CFTimeZoneRef ^r{__CFTimeZoneRef} - -V kCFTimeZoneSystemTimeZoneDidChangeNotification {CFStringRef} - -C kCFTimeZoneNameStyleStandard 0 -C kCFTimeZoneNameStyleShortStandard 1 -C kCFTimeZoneNameStyleDaylightSaving 2 -C kCFTimeZoneNameStyleShortDaylightSaving 3 - -# CFType - -F CFGetAllocator {CFAllocatorRef}{CFTypeRef} -F CFGetRetainCount {CFIndex}{CFTypeRef} -F CFMakeCollectable {CFTypeRef}{CFTypeRef} -F CFRelease v{CFTypeRef} -F CFRetain {CFTypeRef}{CFTypeRef} - -F CFEqual - -F CFHash {CFHashCode}{CFTypeRef} - -F CFGetTypeID {CFTypeID}{CFTypeRef} -F CFShow v{CFTypeRef} - -T CFHashCode L -T CFTypeID L - -T CFTypeRef @ -# CFTypeRef ^rv - -# Private - -F CFShowStr v@ - -f CoreGraphics - -T CGFloat F - -# CGAffineTransform - -F CGAffineTransformMake {CGAffineTransform}{CGFloat}{CGFloat}{CGFloat}{CGFloat}{CGFloat}{CGFloat} -F CGAffineTransformMakeRotation {CGAffineTransform}{CGFloat} -F CGAffineTransformMakeScale {CGAffineTransform}{CGFloat}{CGFloat} -F CGAffineTransformMakeTranslation {CGAffineTransform}{CGFloat}{CGFloat} - -F CGAffineTransformTranslate {CGAffineTransform}{CGAffineTransform}{CGFloat}{CGFloat} -F CGAffineTransformScale {CGAffineTransform}{CGAffineTransform}{CGFloat}{CGFloat} -F CGAffineTransformRotate {CGAffineTransform}{CGAffineTransform}{CGFloat} -F CGAffineTransformInvert {CGAffineTransform}{CGAffineTransform} -F CGAffineTransformConcat {CGAffineTransform}{CGAffineTransform}{CGAffineTransform} - -F CGPointApplyAffineTransform {CGPoint}{CGPoint}{CGAffineTransform} -F CGSizeApplyAffineTransform {CGSize}{CGSize}{CGAffineTransform} -F CGRectApplyAffineTransform {CGRect}{CGRect}{CGAffineTransform} - -F CGAffineTransformIsIdentity B{CGAffineTransform} -F CGAffineTransformEqualToTransform B{CGAffineTransform}{CGAffineTransform} - -S CGAffineTransform "a"{CGFloat}"b"{CGFloat}"c"{CGFloat}"d"{CGFloat}"tx"{CGFloat}"ty"{CGFloat} - -V CGAffineTransformIdentity {CGAffineTransform} - -# CGContext - -T CGContextRef ^{CGContext} - -E CGBlendMode -C kCGBlendModeNormal 0 -C kCGBlendModeMultiply 1 -C kCGBlendModeScreen 2 -C kCGBlendModeOverlay 3 -C kCGBlendModeDarken 4 -C kCGBlendModeLighten 5 -C kCGBlendModeColorDodge 6 -C kCGBlendModeColorBurn 7 -C kCGBlendModeSoftLight 8 -C kCGBlendModeHardLight 9 -C kCGBlendModeDifference 10 -C kCGBlendModeExclusion 11 -C kCGBlendModeHue 12 -C kCGBlendModeSaturation 13 -C kCGBlendModeColor 14 -C kCGBlendModeLuminosity 15 -C kCGBlendModeClear 16 -C kCGBlendModeCopy 17 -C kCGBlendModeSourceIn 18 -C kCGBlendModeSourceOut 19 -C kCGBlendModeSourceAtop 20 -C kCGBlendModeDestinationOver 21 -C kCGBlendModeDestinationIn 22 -C kCGBlendModeDestinationOut 23 -C kCGBlendModeDestinationAtop 24 -C kCGBlendModeXOR 25 -C kCGBlendModePlusDarker 26 -C kCGBlendModePlusLighter 27 - -E CGInterpolationQuality -C kCGInterpolationDefault 0 -C kCGInterpolationNone 1 -C kCGInterpolationLow 2 -C kCGInterpolationHigh 3 - -E CGLineCap -C kCGLineCapButt 0 -C kCGLineCapRound 1 -C kCGLineCapSquare 2 - -E CGLineJoin -C kCGLineJoinMiter 0 -C kCGLineJoinRound 1 -C kCGLineJoinBevel 2 - -E CGTextDrawingMode -C kCGTextFill 0 -C kCGTextStroke 1 -C kCGTextFillStroke 2 -C kCGTextInvisible 3 -C kCGTextFillClip 4 -C kCGTextStrokeClip 5 -C kCGTextFillStrokeClip 6 -C kCGTextClip 7 - -E CGTextEncoding -C kCGEncodingFontSpecific 0 -C kCGEncodingMacRoman 1 - -f CoreLocation - -T CLLocationDegrees d - -S CLLocationCoordinate2D "latitude"{CLLocationDegrees}"longitude"{CLLocationDegrees} - -T CLLocationAccuracy d - -V kCLLocationAccuracyBest d -V kCLLocationAccuracyNearestTenMeters d -V kCLLocationAccuracyHundredMeters d -V kCLLocationAccuracyKilometer d -V kCLLocationAccuracyThreeKilometers d - -T CLLocationSpeed d -T CLLocationDirection d - -V kCLDistanceFilterNone d -V kCLHeadingFilterNone d - -C kCLErrorLocationUnknown 0 -C kCLErrorDenied 1 -C kCLErrorNetwork 2 -C kCLErrorHeadingFailure 3 - -V kCLErrorDomain @ - -f CoreTelephony - -# most of this is garbage - -T CTCallRef @ - -# CTCallAddressBlocked -# CTCallAnswer -# CTCallAnswerEndingActive -# CTCallAnswerEndingAllOthers -# CTCallAnswerEndingHeld -# CTCallAnswerWithSourceIdentifier -F CTCallCopyAddress {CFStringRef}{CFAllocatorRef}{CTCallRef} -# CTCallCopyAllCallsSince -# CTCallCopyAllIncomingCallsSince -F CTCallCopyAllMissedCallsAfterRowID {CFArrayRef}{CFAllocatorRef}l -F CTCallCopyAllMissedCallsSince {CFArrayRef}{CFAllocatorRef}{CFDateRef} -# CTCallCopyAllOutgoingCallsSince -# CTCallCopyName -# CTCallCopyUUID -# CTCallDeleteAllCallsBeforeDate -# CTCallDial -# CTCallDialEmergency -# CTCallDialEmergencyWithSourceIdentifier -# CTCallDialVoicemail -# CTCallDialVoicemailWithSourceIdentifier -# CTCallDialWithID -# CTCallDialWithIDAndSourceIdentifier -# CTCallDialWithSourceIdentifier -# CTCallDisconnect -# CTCallGetCauseCode -# CTCallGetDuration -# CTCallGetEmergencyStatus -F CTCallGetGetRowIDOfLastInsert i -F CTCallGetID l{CTCallRef} -# CTCallGetMultiPartyCallCountMax -F CTCallGetStartTime B{CTCallRef}^d -# CTCallGetStatus -F CTCallGetTypeID {CFTypeID} -# CTCallHistoryInvalidateCaches -# CTCallHold -# CTCallIsAlerting -# CTCallIsConferenced -# CTCallIsOutgoing -# CTCallIsToVoicemail -# CTCallIsWaiting -# CTCallJoinConference -# CTCallLeaveConference -# CTCallListDisconnect -# CTCallListDisconnectAll -# CTCallResume -# CTCallTimersGetAll -# CTCallTimersGetIncoming -# CTCallTimersGetLast -# CTCallTimersGetLastResetTime -# CTCallTimersGetLifetime -# CTCallTimersGetOutgoing -# CTCallTimersReset - -f Foundation - -T NSAppleEventManagerSuspensionID ^r{__NSAppleEventManagerSuspension} - -E _NSByteOrder -C NS_UnknownByteOrder CFByteOrderUnknown -C NS_LittleEndian CFByteOrderLittleEndian -C NS_BigEndian CFByteOrderBigEndian - -# NSComparator - -C NSOrderedAscending -1 -C NSOrderedSame 0 -C NSOrderedDescending 1 -T NSComparisonResult {NSInteger} - -# NSDecimal - -T NSEnumerationOptions {NSUInteger} -# NSHashEnumerator -T NSHashTable {_NSHashTable} -# NSHashTableCallBacks - -T NSHashTableOptions {NSUInteger} -T NSInteger l - -# NSMapEnumerator - -T NSMapTable {_NSMapTable} -# NSMapTableKeyCallBacks - -T NSMapTableOptions {NSUInteger} -# NSMapTableValueCallBacks - -S _NSPoint "x"{CGFloat}"y"{CGFloat} -T NSPoint {_NSPoint} -T NSPointArray ^{NSPoint} -T NSPointPointer ^{NSPoint} - -S _NSRange "location"{NSUInteger}"length"{NSUInteger} -T NSRange {_NSRange} -T NSRangePointer ^{NSRange} - -S _NSRect "origin"{NSPoint}"size"{NSSize} -T NSRectArray ^{NSRect} - -C NSMinXEdge 0 -C NSMinYEdge 1 -C NSMaxXEdge 2 -C NSMaxYEdge 3 - -T NSRectPointer ^{NSRect} - -C NSApplicationDirectory 1 -C NSDemoApplicationDirectory 2 -C NSDeveloperApplicationDirectory 3 -C NSAdminApplicationDirectory 4 -C NSLibraryDirectory 5 -C NSDeveloperDirectory 6 -C NSUserDirectory 7 -C NSDocumentationDirectory 8 -C NSDocumentDirectory 9 -C NSCoreServiceDirectory 10 -C NSAutosavedInformationDirectory 11 -C NSDesktopDirectory 12 -C NSCachesDirectory 13 -C NSApplicationSupportDirectory 14 -C NSDownloadsDirectory 15 -C NSInputMethodsDirectory 16 -C NSMoviesDirectory 17 -C NSMusicDirectory 18 -C NSPicturesDirectory 19 -C NSPrinterDescriptionDirectory 20 -C NSSharedPublicDirectory 21 -C NSPreferencePanesDirectory 22 -C NSItemReplacementDirectory 99 -C NSAllApplicationsDirectory 100 -C NSAllLibrariesDirectory 101 -T NSSearchPathDirectory {NSUInteger} - -C NSUserDomainMask 1 -C NSLocalDomainMask 2 -C NSNetworkDomainMask 4 -C NSSystemDomainMask 8 -C NSAllDomainsMask 0x0ffff -T NSSearchPathDomainMask {NSUInteger} - -S _NSSize "width"{CGFloat}"height"{CGFloat} -T NSSize {_NSSize} - -T NSSizePointer ^{NSSize} -T NSSocketNativeHandle i -T NSStringEncoding {NSUInteger} -S NSSwappedDouble "v"Q -S NSSwappedFloat "v"L -T NSTimeInterval d -# NSUncaughtExceptionHandler -T NSUInteger L -T NSZone {_NSZone} - -f MapKit - -C MKMapTypeStandard 0 -C MKMapTypeSatellite 1 -C MKMapTypeHybrid 2 - -V MKErrorDomain @ - -C MKErrorUnknown 1 -C MKErrorServerFailure 2 -C MKErrorLoadingThrottled 3 -C MKErrorPlacemarkNotFound 4 - -C MKPinAnnotationColorRed 0 -C MKPinAnnotationColorGreen 1 -C MKPinAnnotationColorPurple 2 - -# MKCoordinateRegionMake -F MKCoordinateRegionMakeWithDistance {MKCoordinateRegion}{CLLocationCoordinate2D}{CLLocationDistance}{CLLocationDistance} -# MKCoordinateSpanMake - -f MobileWiFi - -#F WiFiManagerClientAddNetwork -#F WiFiManagerClientCopyDevices -#F WiFiManagerClientCopyNetworks -#F WiFiManagerClientCopyProperty -#F WiFiManagerClientCreate -#F WiFiManagerClientDisable -#F WiFiManagerClientDisableNetwork -#F WiFiManagerClientDispatchNotificationResponse -#F WiFiManagerClientEnable -#F WiFiManagerClientEnableNetwork -#F WiFiManagerClientGetAssociationMode -#F WiFiManagerClientGetDevice -#F WiFiManagerClientGetType -#F WiFiManagerClientGetTypeID -#F WiFiManagerClientIsNetworkEnabled -#F WiFiManagerClientRegisterNotificationCallback -#F WiFiManagerClientRemoveNetwork -#F WiFiManagerClientScheduleWithRunLoop -#F WiFiManagerClientSetAssociationMode -#F WiFiManagerClientSetPower -#F WiFiManagerClientSetProperty -#F WiFiManagerClientSetType -#F WiFiManagerClientUnscheduleFromRunLoop -#F WiFiManagerClientUpdateNetwork - -F WiFiNetworkComparePriority B@@ -#F WiFiNetworkCopyFilteredRecord -F WiFiNetworkCopyPassword @@ -#F WiFiNetworkCopyPreparedEAPProfile -#F WiFiNetworkCopyRecord -#F WiFiNetworkCreate -#F WiFiNetworkCreateCopy -F WiFiNetworkGetAssociationDate @@ -#F WiFiNetworkGetAuthFlags -#F WiFiNetworkGetDirectedState -#F WiFiNetworkGetFloatProperty -#F WiFiNetworkGetIntProperty -#F WiFiNetworkGetProperty -#F WiFiNetworkGetRateBounds -F WiFiNetworkGetSSID @@ -F WiFiNetworkGetSSIDData @@ -F WiFiNetworkGetTypeID {CFTypeID} -F WiFiNetworkIsEAP B@ -F WiFiNetworkIsEnabled B@ -F WiFiNetworkIsHidden B@ -F WiFiNetworkIsHiddenSSID B@ -F WiFiNetworkIsWEP B@ -F WiFiNetworkIsWPA B@ -#F WiFiNetworkMerge -#F WiFiNetworkMergeForAssociation -#F WiFiNetworkMergeProperties -F WiFiNetworkRemovePassword v@ -F WiFiNetworkRequiresIdentity B@ -F WiFiNetworkRequiresOneTimePassword B@ -F WiFiNetworkRequiresPassword B@ -F WiFiNetworkRequiresUsername B@ -F WiFiNetworkSetAssociationDate v@@ -#F WiFiNetworkSetDirectedState -#F WiFiNetworkSetFloatProperty -#F WiFiNetworkSetIntProperty -F WiFiNetworkSetPassword v@@ -#F WiFiNetworkSetProperty - -C RTLD_LAZY 0x1 -C RTLD_NOW 0x2 -C RTLD_LOCAL 0x4 -C RTLD_GLOBAL 0x8 - -C RTLD_NOLOAD 0x10 -C RTLD_NODELETE 0x80 -C RTLD_FIRST 0x100 - -C RTLD_NEXT -1 -C RTLD_DEFAULT -2 -C RTLD_SELF -3 - -S dl_info "dli_fname"*"dli_fbase"^v"dli_sname"*"dli_saddr"^v -T Dl_info {dl_info} - -F dladdr i^rv^{dl_info} -F dlclose i^v -F dlerror * -F dlopen ^v*i -F dlsym ^v^v* -F dlopen_preflight B* diff --git a/Bridge.def.in b/Bridge.def.in new file mode 100644 index 0000000..7bec54a --- /dev/null +++ b/Bridge.def.in @@ -0,0 +1,89 @@ +IMP|"(typedef void (*)())" + +malloc|"*(typedef void*(*)(unsigned long int))(dlsym(RTLD_DEFAULT,'malloc'))" +free|"*(typedef void(*)(void*))(dlsym(RTLD_DEFAULT,'free'))" + +class_addIvar|"*(typedef bool(*)(Class,const char*,unsigned long int,unsigned char,const char*))(dlsym(RTLD_DEFAULT,'class_addIvar'))" +class_addMethod|"*(typedef bool(*)(Class,SEL,IMP,const char*))(dlsym(RTLD_DEFAULT,'class_addMethod'))" +class_addProtocol|"*(typedef bool(*)(Class,id))(dlsym(RTLD_DEFAULT,'class_addProtocol'))" +class_conformsToProtocol|"*(typedef bool(*)(Class,id))(dlsym(RTLD_DEFAULT,'class_conformsToProtocol'))" +class_copyIvarList|"*(typedef struct objc_ivar**(*)(Class,unsigned int*))(dlsym(RTLD_DEFAULT,'class_copyIvarList'))" +class_copyMethodList|"*(typedef struct objc_method**(*)(Class,unsigned int*))(dlsym(RTLD_DEFAULT,'class_copyMethodList'))" +class_copyPropertyList|"*(typedef struct objc_property**(*)(Class,unsigned int*))(dlsym(RTLD_DEFAULT,'class_copyPropertyList'))" +class_copyProtocolList|"*(typedef id*(*)(Class,unsigned int*))(dlsym(RTLD_DEFAULT,'class_copyProtocolList'))" +class_createInstance|"*(typedef id(*)(Class,unsigned long int))(dlsym(RTLD_DEFAULT,'class_createInstance'))" +class_getClassMethod|"*(typedef struct objc_method*(*)(Class,SEL))(dlsym(RTLD_DEFAULT,'class_getClassMethod'))" +class_getClassVariable|"*(typedef struct objc_ivar*(*)(Class,const char*))(dlsym(RTLD_DEFAULT,'class_getClassVariable'))" +class_getInstanceMethod|"*(typedef struct objc_method*(*)(Class,SEL))(dlsym(RTLD_DEFAULT,'class_getInstanceMethod'))" +class_getInstanceSize|"*(typedef unsigned long int(*)(Class))(dlsym(RTLD_DEFAULT,'class_getInstanceSize'))" +class_getInstanceVariable|"*(typedef struct objc_ivar*(*)(Class,const char*))(dlsym(RTLD_DEFAULT,'class_getInstanceVariable'))" +class_getIvarLayout|"*(typedef const char*(*)(Class))(dlsym(RTLD_DEFAULT,'class_getIvarLayout'))" +class_getMethodImplementation|"*(typedef IMP(*)(Class,SEL))(dlsym(RTLD_DEFAULT,'class_getMethodImplementation'))" +class_getMethodImplementation_stret|"*(typedef IMP(*)(Class,SEL))(dlsym(RTLD_DEFAULT,'class_getMethodImplementation_stret'))" +class_getName|"*(typedef const char*(*)(Class))(dlsym(RTLD_DEFAULT,'class_getName'))" +class_getProperty|"*(typedef struct objc_property*(*)(Class,const char*))(dlsym(RTLD_DEFAULT,'class_getProperty'))" +class_getSuperclass|"*(typedef Class(*)(Class))(dlsym(RTLD_DEFAULT,'class_getSuperclass'))" +class_getVersion|"*(typedef int(*)(Class))(dlsym(RTLD_DEFAULT,'class_getVersion'))" +class_getWeakIvarLayout|"*(typedef const char*(*)(Class))(dlsym(RTLD_DEFAULT,'class_getWeakIvarLayout'))" +class_isMetaClass|"*(typedef bool(*)(Class))(dlsym(RTLD_DEFAULT,'class_isMetaClass'))" +class_replaceMethod|"*(typedef IMP(*)(Class,SEL,IMP,const char*))(dlsym(RTLD_DEFAULT,'class_replaceMethod'))" +class_respondsToSelector|"*(typedef bool(*)(Class,SEL))(dlsym(RTLD_DEFAULT,'class_respondsToSelector'))" +class_setIvarLayout|"*(typedef void(*)(Class,const char*))(dlsym(RTLD_DEFAULT,'class_setIvarLayout'))" +class_setSuperclass|"*(typedef Class(*)(Class,Class))(dlsym(RTLD_DEFAULT,'class_setSuperclass'))" +class_setVersion|"*(typedef void(*)(Class,int))(dlsym(RTLD_DEFAULT,'class_setVersion'))" +class_setWeakIvarLayout|"*(typedef void(*)(Class,const char*))(dlsym(RTLD_DEFAULT,'class_setWeakIvarLayout'))" + +ivar_getName|"*(typedef const char*(*)(struct objc_ivar*))(dlsym(RTLD_DEFAULT,'ivar_getName'))" +ivar_getOffset|"*(typedef int(*)(struct objc_ivar*))(dlsym(RTLD_DEFAULT,'ivar_getOffset'))" +ivar_getTypeEncoding|"*(typedef const char*(*)(struct objc_ivar*))(dlsym(RTLD_DEFAULT,'ivar_getTypeEncoding'))" + +method_copyArgumentType|"*(typedef char*(*)(struct objc_method*,unsigned int))(dlsym(RTLD_DEFAULT,'method_copyArgumentType'))" +method_copyReturnType|"*(typedef char*(*)(struct objc_method*))(dlsym(RTLD_DEFAULT,'method_copyReturnType'))" +method_exchangeImplementations|"*(typedef void(*)(struct objc_method*,struct objc_method*))(dlsym(RTLD_DEFAULT,'method_exchangeImplementations'))" +method_getArgumentType|"*(typedef void(*)(struct objc_method*,unsigned int,char*,unsigned long int))(dlsym(RTLD_DEFAULT,'method_getArgumentType'))" +method_getImplementation|"*(typedef IMP(*)(struct objc_method*))(dlsym(RTLD_DEFAULT,'method_getImplementation'))" +method_getName|"*(typedef SEL(*)(struct objc_method*))(dlsym(RTLD_DEFAULT,'method_getName'))" +method_getNumberOfArguments|"*(typedef unsigned int(*)(struct objc_method*))(dlsym(RTLD_DEFAULT,'method_getNumberOfArguments'))" +method_getReturnType|"*(typedef void(*)(struct objc_method*,char*,unsigned long int))(dlsym(RTLD_DEFAULT,'method_getReturnType'))" +method_getTypeEncoding|"*(typedef const char*(*)(struct objc_method*))(dlsym(RTLD_DEFAULT,'method_getTypeEncoding'))" +method_setImplementation|"*(typedef IMP(*)(struct objc_method*,IMP))(dlsym(RTLD_DEFAULT,'method_setImplementation'))" + +objc_allocateClassPair|"*(typedef Class(*)(Class,const char*,unsigned long int))(dlsym(RTLD_DEFAULT,'objc_allocateClassPair'))" +objc_copyProtocolList|"*(typedef id*(*)(unsigned int*))(dlsym(RTLD_DEFAULT,'objc_copyProtocolList'))" +objc_duplicateClass|"*(typedef Class(*)(Class,const char*,unsigned long int))(dlsym(RTLD_DEFAULT,'objc_duplicateClass'))" +objc_getClass|"*(typedef Class(*)(const char*))(dlsym(RTLD_DEFAULT,'objc_getClass'))" +objc_getClassList|"*(typedef int(*)(Class*,int))(dlsym(RTLD_DEFAULT,'objc_getClassList'))" +objc_getFutureClass|"*(typedef Class(*)(const char*))(dlsym(RTLD_DEFAULT,'objc_getFutureClass'))" +objc_getMetaClass|"*(typedef id(*)(const char*))(dlsym(RTLD_DEFAULT,'objc_getMetaClass'))" +objc_getProtocol|"*(typedef id(*)(const char*))(dlsym(RTLD_DEFAULT,'objc_getProtocol'))" +objc_getRequiredClass|"*(typedef id(*)(const char*))(dlsym(RTLD_DEFAULT,'objc_getRequiredClass'))" +objc_lookUpClass|"*(typedef id(*)(const char*))(dlsym(RTLD_DEFAULT,'objc_lookUpClass'))" +objc_registerClassPair|"*(typedef void(*)(Class))(dlsym(RTLD_DEFAULT,'objc_registerClassPair'))" +objc_setFutureClass|"*(typedef void(*)(Class,const char*))(dlsym(RTLD_DEFAULT,'objc_setFutureClass'))" + +object_copy|"*(typedef id(*)(id,unsigned long int))(dlsym(RTLD_DEFAULT,'object_copy'))" +object_dispose|"*(typedef id(*)(id))(dlsym(RTLD_DEFAULT,'object_dispose'))" +object_getClass|"*(typedef Class(*)(id))(dlsym(RTLD_DEFAULT,'object_getClass'))" +object_getClassName|"*(typedef const char*(*)(id))(dlsym(RTLD_DEFAULT,'object_getClassName'))" +object_getIndexedIvars|"*(typedef void*(*)(id))(dlsym(RTLD_DEFAULT,'object_getIndexedIvars'))" +object_getInstanceVariable|"*(typedef struct objc_ivar*(*)(id,const char*,void**))(dlsym(RTLD_DEFAULT,'object_getInstanceVariable'))" +object_getIvar|"*(typedef id(*)(id,struct objc_ivar*))(dlsym(RTLD_DEFAULT,'object_getIvar'))" +object_setClass|"*(typedef Class(*)(id,Class))(dlsym(RTLD_DEFAULT,'object_setClass'))" +object_setInstanceVariable|"*(typedef struct objc_ivar*(*)(id,const char*,void*))(dlsym(RTLD_DEFAULT,'object_setInstanceVariable'))" +object_setIvar|"*(typedef void(*)(id,struct objc_ivar*,id))(dlsym(RTLD_DEFAULT,'object_setIvar'))" + +property_getAttributes|"*(typedef const char*(*)(struct objc_property*))(dlsym(RTLD_DEFAULT,'property_getAttributes'))" +property_getName|"*(typedef const char*(*)(struct objc_property*))(dlsym(RTLD_DEFAULT,'property_getName'))" +protocol_conformsToProtocol|"*(typedef bool(*)(id,id))(dlsym(RTLD_DEFAULT,'protocol_conformsToProtocol'))" +protocol_copyMethodDescriptionList|"*(typedef struct objc_method_description*(*)(id,bool,bool,unsigned int*))(dlsym(RTLD_DEFAULT,'protocol_copyMethodDescriptionList'))" +protocol_copyPropertyList|"*(typedef struct objc_property**(*)(id,unsigned int*))(dlsym(RTLD_DEFAULT,'protocol_copyPropertyList'))" +protocol_copyProtocolList|"*(typedef id*(*)(id,unsigned int*))(dlsym(RTLD_DEFAULT,'protocol_copyProtocolList'))" +protocol_getMethodDescription|"*(typedef struct objc_method_description(*)(id,SEL,bool,bool))(dlsym(RTLD_DEFAULT,'protocol_getMethodDescription'))" +protocol_getName|"*(typedef const char*(*)(id))(dlsym(RTLD_DEFAULT,'protocol_getName'))" +protocol_getProperty|"*(typedef struct objc_property*(*)(id,const char*,bool,bool))(dlsym(RTLD_DEFAULT,'protocol_getProperty'))" +protocol_isEqual|"*(typedef bool(*)(id,id))(dlsym(RTLD_DEFAULT,'protocol_isEqual'))" + +sel_getName|"*(typedef const char*(*)(SEL))(dlsym(RTLD_DEFAULT,'sel_getName'))" +sel_getUid|"*(typedef SEL(*)(const char*))(dlsym(RTLD_DEFAULT,'sel_getUid'))" +sel_isEqual|"*(typedef bool(*)(SEL,SEL))(dlsym(RTLD_DEFAULT,'sel_isEqual'))" +sel_registerName|"*(typedef SEL(*)(const char*))(dlsym(RTLD_DEFAULT,'sel_registerName'))" diff --git a/Bridge.sh b/Bridge.sh index 83ce23a..0bf14ab 100755 --- a/Bridge.sh +++ b/Bridge.sh @@ -38,21 +38,20 @@ cat << EOF %define slot-name name_ %struct-type -%omit-struct-type %pic +%delimiters="|" + struct CYBridgeEntry { int name_; const char *value_; - void *cache_; }; %% EOF -grep '^[CFV]' "$1" | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$/\1\2, "\3", NULL/'; -grep '^[EST]' "$1" | sed -e 's/^S/3/;s/^T/4/;s/^E/5/' | sed -e 's/^5\(.*\)$/4\1 i/;s/"/\\"/g' | sed -e 's/^\([^ ]*\) \([^ ]*\) \(.*\)$/\1\2, "\3", NULL/'; +grep -v '^$' cat <= 100 && _value < 200, #expr, " %u:%s", _value sqlite3_errmsg(database_)); \ -}) + _assert_("sqlcall", _value == 0 || _value >= 100 && _value < 200, #expr, " %u:%s", _value, sqlite3_errmsg(database_)); \ +_value; }) struct CYJSException { JSContextRef context_; diff --git a/Execute.cpp b/Execute.cpp index 0402829..6bf9b50 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -36,6 +36,8 @@ #include #include +#include + #include "sig/parse.hpp" #include "sig/ffi_type.hpp" @@ -48,6 +50,12 @@ #include "Pooling.hpp" #include "String.hpp" +char *sqlite3_column_pooled(CYPool &pool, sqlite3_stmt *stmt, int n) { + if (const unsigned char *value = sqlite3_column_text(stmt, n)) + return pool.strdup(reinterpret_cast(value)); + else return NULL; +} + static std::vector &GetHooks() { static std::vector hooks; return hooks; @@ -166,6 +174,8 @@ JSStringRef toPointer_s; JSStringRef toString_s; JSStringRef weak_s; +static sqlite3 *database_; + static JSStringRef Result_; void CYFinalize(JSObjectRef object) { @@ -190,28 +200,7 @@ void Structor_(CYPool &pool, sig::Type *&type) { if (type->primitive != sig::struct_P || type->name == NULL) return; - size_t length(strlen(type->name)); - char keyed[length + 2]; - memcpy(keyed + 1, type->name, length + 1); - - static const char *modes = "34"; - for (size_t i(0); i != 2; ++i) { - char mode(modes[i]); - keyed[0] = mode; - - if (CYBridgeEntry *entry = CYBridgeHash(keyed, length + 1)) - switch (mode) { - case '3': - sig::Parse(pool, &type->data.signature, entry->value_, &Structor_); - break; - - case '4': { - sig::Signature signature; - sig::Parse(pool, &signature, entry->value_, &Structor_); - type = signature.elements[0].type; - } break; - } - } + //_assert(false); } JSClassRef Type_privateData::Class_; @@ -248,6 +237,13 @@ struct Pointer : length_(length) { } + + Pointer(void *value, JSContextRef context, JSObjectRef owner, size_t length, const char *encoding) : + CYOwned(value, context, owner), + type_(new(*pool_) Type_privateData(encoding)), + length_(length) + { + } }; struct Struct_privateData : @@ -576,6 +572,11 @@ JSObjectRef CYMakePointer(JSContextRef context, void *pointer, size_t length, si return JSObjectMake(context, Pointer_, internal); } +JSObjectRef CYMakePointer(JSContextRef context, void *pointer, size_t length, const char *encoding, JSObjectRef owner) { + Pointer *internal(new Pointer(pointer, context, owner, length, encoding)); + return JSObjectMake(context, Pointer_, internal); +} + JSObjectRef CYMakeCString(JSContextRef context, char *pointer, JSObjectRef owner) { CString *internal(new CString(pointer, context, owner)); return JSObjectMake(context, CString_, internal); @@ -585,19 +586,12 @@ static JSObjectRef CYMakeFunctor(JSContextRef context, void (*function)(), const return JSObjectMake(context, Functor_, new cy::Functor(signature, function)); } -static JSObjectRef CYMakeFunctor(JSContextRef context, const char *symbol, const char *encoding, void **cache) { - cy::Functor *internal; - if (*cache != NULL) - internal = reinterpret_cast(*cache); - else { - void (*function)()(reinterpret_cast(CYCastSymbol(symbol))); - if (function == NULL) - return NULL; - - internal = new cy::Functor(encoding, function); - *cache = internal; - } +static JSObjectRef CYMakeFunctor(JSContextRef context, const char *symbol, const char *encoding) { + void (*function)()(reinterpret_cast(CYCastSymbol(symbol))); + if (function == NULL) + return NULL; + cy::Functor *internal(new cy::Functor(encoding, function)); ++internal->count_; return JSObjectMake(context, Functor_, internal); } @@ -1124,6 +1118,31 @@ JSObjectRef CYMakeType(JSContextRef context, sig::Signature *signature) { return CYMakeType(context, &type); } +extern "C" const char *CYBridgeHash(CYPool &pool, CYUTF8String name) { + sqlite3_stmt *statement; + + _sqlcall(sqlite3_prepare(database_, + "select " + "\"cache\".\"value\" " + "from \"cache\" " + "where" + " \"cache\".\"system\" & " CY_SYSTEM " == " CY_SYSTEM " and" + " \"cache\".\"name\" = ?" + " limit 1" + , -1, &statement, NULL)); + + _sqlcall(sqlite3_bind_text(statement, 1, name.data, name.size, SQLITE_STATIC)); + + const char *value; + if (_sqlcall(sqlite3_step(statement)) == SQLITE_DONE) + value = NULL; + else + value = sqlite3_column_pooled(pool, statement, 0); + + _sqlcall(sqlite3_finalize(statement)); + return value; +} + static bool All_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) { JSObjectRef global(CYGetGlobalObject(context)); JSObjectRef cycript(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Cycript")))); @@ -1135,18 +1154,8 @@ static bool All_hasProperty(JSContextRef context, JSObjectRef object, JSStringRe return true; CYPool pool; - CYUTF8String name(CYPoolUTF8String(pool, context, property)); - - size_t length(name.size); - char keyed[length + 2]; - memcpy(keyed + 1, name.data, length + 1); - - static const char *modes = "0124"; - for (size_t i(0); i != 4; ++i) { - keyed[0] = modes[i]; - if (CYBridgeHash(keyed, length + 1) != NULL) - return true; - } + if (CYBridgeHash(pool, CYPoolUTF8String(pool, context, property)) != NULL) + return true; return false; } @@ -1163,39 +1172,10 @@ static JSValueRef All_getProperty(JSContextRef context, JSObjectRef object, JSSt return value; CYPool pool; - CYUTF8String name(CYPoolUTF8String(pool, context, property)); - - size_t length(name.size); - char keyed[length + 2]; - memcpy(keyed + 1, name.data, length + 1); - - static const char *modes = "0124"; - for (size_t i(0); i != 4; ++i) { - char mode(modes[i]); - keyed[0] = mode; - - if (CYBridgeEntry *entry = CYBridgeHash(keyed, length + 1)) - switch (mode) { - case '0': - return JSEvaluateScript(CYGetJSContext(context), CYJSString(entry->value_), NULL, NULL, 0, NULL); - - case '1': - return CYMakeFunctor(context, name.data, entry->value_, &entry->cache_); - - case '2': - if (void *symbol = CYCastSymbol(name.data)) { - // XXX: this is horrendously inefficient - sig::Signature signature; - sig::Parse(pool, &signature, entry->value_, &Structor_); - ffi_cif cif; - sig::sig_ffi_cif(pool, &sig::ObjectiveC, &signature, &cif); - return CYFromFFI(context, signature.elements[0].type, cif.rtype, symbol); - } else return NULL; - - // XXX: implement case 3 - case '4': - return CYMakeType(context, entry->value_); - } + if (const char *code = CYBridgeHash(pool, CYPoolUTF8String(pool, context, property))) { + JSValueRef result(_jsccall(JSEvaluateScript, context, CYJSString(CYPoolCode(pool, code)), NULL, NULL, 0)); + CYSetProperty(context, object, property, result, kJSPropertyAttributeDontEnum); + return result; } return NULL; @@ -1849,6 +1829,8 @@ _visible void CYCancel() { cancel_ = true; } +static const char *CYPoolLibraryPath(CYPool &pool); + static bool initialized_ = false; void CYInitializeDynamic() { @@ -1856,6 +1838,10 @@ void CYInitializeDynamic() { initialized_ = true; else return; + CYPool pool; + const char *db(pool.strcat(CYPoolLibraryPath(pool), "/libcycript.db", NULL)); + _sqlcall(sqlite3_open_v2(db, &database_, SQLITE_OPEN_READONLY, NULL)); + JSObjectMakeArray$ = reinterpret_cast(dlsym(RTLD_DEFAULT, "JSObjectMakeArray")); JSSynchronousGarbageCollectForDebugging$ = reinterpret_cast(dlsym(RTLD_DEFAULT, "JSSynchronousGarbageCollectForDebugging")); @@ -2018,10 +2004,14 @@ static void *CYPoolFile(CYPool &pool, const char *path, size_t *psize) { *psize = size; void *base; - _syscall(base = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0)); + if (size == 0) + base = pool.strndup("", 0); + else { + _syscall(base = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0)); - CYFile *file(new (pool) CYFile(base, size)); - pool.atexit(&CYFileExit, file); + CYFile *file(new (pool) CYFile(base, size)); + pool.atexit(&CYFileExit, file); + } _syscall(close(fd)); return base; @@ -2109,8 +2099,7 @@ static bool CYRunScript(JSGlobalContextRef context, const char *path) { if (code.data == NULL) return false; - CYStream stream(code.data, code.data + code.size); - code = CYPoolCode(pool, stream); + code = CYPoolCode(pool, code); _jsccall(JSEvaluateScript, context, CYJSString(code), NULL, NULL, 0); return true; } @@ -2234,8 +2223,19 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) { } #endif - if (CYBridgeEntry *entry = CYBridgeHash("1dlerror", 8)) - entry->cache_ = new cy::Functor(entry->value_, reinterpret_cast(&dlerror)); + CYSetProperty(context, global, CYJSString("dlerror"), CYMakeFunctor(context, "dlerror", "*"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("RTLD_DEFAULT"), CYCastJSValue(context, reinterpret_cast(RTLD_DEFAULT)), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("dlsym"), CYMakeFunctor(context, "dlsym", "^v^v*"), kJSPropertyAttributeDontEnum); + + CYSetProperty(context, global, CYJSString("NULL"), CYJSNull(context), kJSPropertyAttributeDontEnum); + + CYSetProperty(context, global, CYJSString("bool"), CYMakeType(context, "B"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("char"), CYMakeType(context, "c"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("short"), CYMakeType(context, "s"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("int"), CYMakeType(context, "i"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("long"), CYMakeType(context, "l"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("float"), CYMakeType(context, "f"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("double"), CYMakeType(context, "d"), kJSPropertyAttributeDontEnum); CYRunScript(context, "libcycript.cy"); diff --git a/Execute.hpp b/Execute.hpp index 372f89d..eaad7e5 100644 --- a/Execute.hpp +++ b/Execute.hpp @@ -22,12 +22,4 @@ #ifndef CYCRIPT_EXECUTE_HPP #define CYCRIPT_EXECUTE_HPP -struct CYBridgeEntry { - int name_; - const char *value_; - void *cache_; -}; - -extern "C" struct CYBridgeEntry *CYBridgeHash(const char *data, size_t size); - #endif/*CYCRIPT_EXECUTE_HPP*/ diff --git a/JavaScript.hpp b/JavaScript.hpp index ebc2bac..33b3db8 100644 --- a/JavaScript.hpp +++ b/JavaScript.hpp @@ -143,6 +143,7 @@ struct CYRegisterHook { JSObjectRef CYMakePointer(JSContextRef context, void *pointer, size_t length, sig::Type *type, ffi_type *ffi, JSObjectRef owner); +JSObjectRef CYMakeType(JSContextRef context, const char *encoding); JSObjectRef CYMakeType(JSContextRef context, sig::Type *type); JSObjectRef CYMakeType(JSContextRef context, sig::Signature *signature); diff --git a/Library.cpp b/Library.cpp index ac9d8b0..05cdde1 100644 --- a/Library.cpp +++ b/Library.cpp @@ -32,6 +32,7 @@ #include +#include "Code.hpp" #include "ConvertUTF.h" #include "Driver.hpp" #include "Error.hpp" @@ -245,6 +246,11 @@ CYUTF8String CYPoolCode(CYPool &pool, std::streambuf &stream) { return $pool.strdup(str.str().c_str()); } +CYUTF8String CYPoolCode(CYPool &pool, CYUTF8String code) { + CYStream stream(code.data, code.data + code.size); + return CYPoolCode(pool, stream); +} + CYPool &CYGetGlobalPool() { static CYPool pool; return pool; diff --git a/Makefile.am b/Makefile.am index eb0c884..87a4aa0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,7 @@ SUBDIRS = ACLOCAL_AMFLAGS = -I m4 -AM_CPPFLAGS = -DYYDEBUG=1 +AM_CPPFLAGS = -DYYDEBUG=1 -DCY_SYSTEM="\"$(CY_SYSTEM)\"" AM_CPPFLAGS += -include config.h -include $(srcdir)/unconfig.h AM_CFLAGS = -fvisibility=hidden @@ -41,7 +41,7 @@ lib_LTLIBRARIES = lib_LTLIBRARIES += libcycript.la libcycript_la_LDFLAGS = $(CY_LDFLAGS) -libcycript_la_LIBADD = $(LTLIBUV) $(LTLIBFFI) $(LTLIBGCC) -ldl +libcycript_la_LIBADD = $(LTLIBUV) $(LTLIBFFI) $(LTLIBSQLITE3) $(LTLIBGCC) -ldl libcycript_la_SOURCES = ConvertUTF.c Decode.cpp Driver.cpp Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp Syntax.cpp libcycript_la_SOURCES += Parser.cpp Scanner.cpp @@ -57,17 +57,36 @@ endif if CY_EXECUTE libcycript_la_SOURCES += sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp -libcycript_la_SOURCES += Bridge.cpp Execute.cpp JavaScriptCore.cpp +libcycript_la_SOURCES += Execute.cpp JavaScriptCore.cpp libcycript_la_LIBADD += $(LTJAVASCRIPTCORE) AM_CPPFLAGS += -DCY_EXECUTE filters += C -Bridge.lo: Bridge.hpp +datdir = $(libdir) +dat_DATA = libcycript.db + +CLEANFILES += libcycript.db +libcycript.db: Bridge.def libcycript.sh + $(srcdir)/libcycript.sh $(CY_SYSTEM) $@ $< + +if CY_PRELINK +CLEANFILES += Analyze +Analyze: Analyze.cpp + $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -DCY_OBJECTIVEC=$(CY_OBJECTIVEC) -I$(srcdir)/extra -o $@ $< $(CY_LIBCLANG) + +CLEANFILES += Bridge.def +Bridge.def: Analysis.cpp Analyze + ./Analyze $< $(OBJCXX) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) >$@ +else +CLEANFILES += Bridge.def +Bridge.def: Bridge.def.in + cat $< >$@ +endif CLEANFILES += Bridge.gperf Bridge.gperf: Bridge.def Bridge.sh - $(srcdir)/Bridge.sh $< >$@ + $(srcdir)/Bridge.sh <$< >$@ CLEANFILES += Bridge.hpp Bridge.hpp: Bridge.gperf diff --git a/Makefile.in b/Makefile.in index 9f07a05..b844399 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,6 +34,7 @@ # }}} + VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -111,24 +112,27 @@ host_triplet = @host@ @CY_CONSOLE_TRUE@bin_PROGRAMS = cycript$(EXEEXT) @CY_CONSOLE_TRUE@am__append_1 = Complete.cpp @CY_EXECUTE_TRUE@am__append_2 = sig/ffi_type.cpp sig/parse.cpp \ -@CY_EXECUTE_TRUE@ sig/copy.cpp Bridge.cpp Execute.cpp \ -@CY_EXECUTE_TRUE@ JavaScriptCore.cpp +@CY_EXECUTE_TRUE@ sig/copy.cpp Execute.cpp JavaScriptCore.cpp @CY_EXECUTE_TRUE@am__append_3 = $(LTJAVASCRIPTCORE) @CY_EXECUTE_TRUE@am__append_4 = -DCY_EXECUTE @CY_EXECUTE_TRUE@am__append_5 = C -@CY_EXECUTE_TRUE@am__append_6 = Bridge.gperf Bridge.hpp -@CY_JAVA_TRUE@am__append_7 = Java -@CY_JAVA_TRUE@am__append_8 = Java/Execute.cpp -@CY_JAVA_TRUE@am__append_9 = $(LTJAVA) -@CY_OBJECTIVEC_TRUE@am__append_10 = ObjectiveC -@CY_OBJECTIVEC_TRUE@am__append_11 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm -@CY_OBJECTIVEC_TRUE@am__append_12 = $(LTOBJECTIVEC) -@CY_ATTACH_TRUE@am__append_13 = Handler.cpp -@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_14 = Inject.cpp -@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_15 = -DCY_ATTACH +@CY_EXECUTE_TRUE@am__append_6 = libcycript.db +@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@am__append_7 = Analyze Bridge.def +@CY_EXECUTE_TRUE@@CY_PRELINK_FALSE@am__append_8 = Bridge.def +@CY_EXECUTE_TRUE@am__append_9 = Bridge.gperf Bridge.hpp +@CY_JAVA_TRUE@am__append_10 = Java +@CY_JAVA_TRUE@am__append_11 = Java/Execute.cpp +@CY_JAVA_TRUE@am__append_12 = $(LTJAVA) +@CY_OBJECTIVEC_TRUE@am__append_13 = ObjectiveC +@CY_OBJECTIVEC_TRUE@am__append_14 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm +@CY_OBJECTIVEC_TRUE@am__append_15 = $(LTOBJECTIVEC) +@CY_ATTACH_TRUE@am__append_16 = Handler.cpp +@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_17 = Inject.cpp +@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_18 = -DCY_ATTACH subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_prog_cxx_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/framework.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ @@ -170,7 +174,8 @@ am__uninstall_files_from_dir = { \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ + "$(DESTDIR)$(datdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = @CY_EXECUTE_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) @@ -178,20 +183,18 @@ am__DEPENDENCIES_1 = @CY_OBJECTIVEC_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) libcycript_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3) \ - $(am__DEPENDENCIES_4) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) am__libcycript_la_SOURCES_DIST = ConvertUTF.c Decode.cpp Driver.cpp \ Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp \ Syntax.cpp Parser.cpp Scanner.cpp Complete.cpp \ - sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp Bridge.cpp \ - Execute.cpp JavaScriptCore.cpp Java/Execute.cpp \ - ObjectiveC/Output.cpp ObjectiveC/Replace.cpp \ - ObjectiveC/Library.mm Handler.cpp + sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp Execute.cpp \ + JavaScriptCore.cpp Java/Execute.cpp ObjectiveC/Output.cpp \ + ObjectiveC/Replace.cpp ObjectiveC/Library.mm Handler.cpp @CY_CONSOLE_TRUE@am__objects_1 = Complete.lo am__dirstamp = $(am__leading_dot)dirstamp @CY_EXECUTE_TRUE@am__objects_2 = sig/ffi_type.lo sig/parse.lo \ -@CY_EXECUTE_TRUE@ sig/copy.lo Bridge.lo Execute.lo \ -@CY_EXECUTE_TRUE@ JavaScriptCore.lo +@CY_EXECUTE_TRUE@ sig/copy.lo Execute.lo JavaScriptCore.lo @CY_JAVA_TRUE@am__objects_3 = Java/Execute.lo @CY_OBJECTIVEC_TRUE@am__objects_4 = ObjectiveC/Output.lo \ @CY_OBJECTIVEC_TRUE@ ObjectiveC/Replace.lo \ @@ -305,6 +308,7 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +DATA = $(dat_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ @@ -389,19 +393,31 @@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ +BUILD_EXEEXT = @BUILD_EXEEXT@ +BUILD_OBJEXT = @BUILD_OBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ CFLAGS = @CFLAGS@ +CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ CXX = @CXX@ CXXCPP = @CXXCPP@ +CXXCPPFLAGS_FOR_BUILD = @CXXCPPFLAGS_FOR_BUILD@ +CXXCPP_FOR_BUILD = @CXXCPP_FOR_BUILD@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ +CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@ +CXX_FOR_BUILD = @CXX_FOR_BUILD@ CYGPATH_W = @CYGPATH_W@ CY_EXECUTE = @CY_EXECUTE@ CY_JAVA = @CY_JAVA@ +CY_LIBCLANG = @CY_LIBCLANG@ CY_OBJECTIVEC = @CY_OBJECTIVEC@ +CY_SYSTEM = @CY_SYSTEM@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -427,6 +443,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ LFLAGS = @LFLAGS@ LIBFFI_CFLAGS = @LIBFFI_CFLAGS@ LIBFFI_LIBS = @LIBFFI_LIBS@ @@ -442,6 +459,7 @@ LTLIBFFI = @LTLIBFFI@ LTLIBGCC = @LTLIBGCC@ LTLIBOBJS = @LTLIBOBJS@ LTLIBREADLINE = @LTLIBREADLINE@ +LTLIBSQLITE3 = @LTLIBSQLITE3@ LTLIBTERMCAP = @LTLIBTERMCAP@ LTLIBUV = @LTLIBUV@ LTOBJECTIVEC = @LTOBJECTIVEC@ @@ -489,7 +507,9 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@ ac_ct_CXX = @ac_ct_CXX@ +ac_ct_CXX_FOR_BUILD = @ac_ct_CXX_FOR_BUILD@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ ac_ct_OBJCXX = @ac_ct_OBJCXX@ am__include = @am__include@ @@ -539,13 +559,15 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = subdir-objects -CLEANFILES = $(am__append_6) Parser.ypp Scanner.lpp Scanner.cpp \ +CLEANFILES = $(am__append_6) $(am__append_7) $(am__append_8) \ + $(am__append_9) Parser.ypp Scanner.lpp Scanner.cpp \ Scanner.output lex.backup Parser.cpp Parser.hpp stack.hh \ Parser.output SUBDIRS = ACLOCAL_AMFLAGS = -I m4 -AM_CPPFLAGS = -DYYDEBUG=1 -include config.h -include \ - $(srcdir)/unconfig.h $(am__append_4) $(am__append_15) +AM_CPPFLAGS = -DYYDEBUG=1 -DCY_SYSTEM="\"$(CY_SYSTEM)\"" -include \ + config.h -include $(srcdir)/unconfig.h $(am__append_4) \ + $(am__append_18) AM_CFLAGS = -fvisibility=hidden AM_CXXFLAGS = -fvisibility=hidden AM_OBJCXXFLAGS = -fvisibility=hidden -fobjc-exceptions @@ -553,16 +575,19 @@ AM_LDFLAGS = -fvisibility=hidden CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic lib_LTLIBRARIES = libcycript.la libcycript_la_LDFLAGS = $(CY_LDFLAGS) -libcycript_la_LIBADD = $(LTLIBUV) $(LTLIBFFI) $(LTLIBGCC) -ldl \ - $(am__append_3) $(am__append_9) $(am__append_12) +libcycript_la_LIBADD = $(LTLIBUV) $(LTLIBFFI) $(LTLIBSQLITE3) \ + $(LTLIBGCC) -ldl $(am__append_3) $(am__append_12) \ + $(am__append_15) libcycript_la_SOURCES = ConvertUTF.c Decode.cpp Driver.cpp \ Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp \ Syntax.cpp Parser.cpp Scanner.cpp $(am__append_1) \ - $(am__append_2) $(am__append_8) $(am__append_11) \ - $(am__append_13) -filters = $(am__append_5) $(am__append_7) $(am__append_10) -@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp $(am__append_14) + $(am__append_2) $(am__append_11) $(am__append_14) \ + $(am__append_16) +filters = $(am__append_5) $(am__append_10) $(am__append_13) +@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp $(am__append_17) @CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) $(PTHREAD_CFLAGS) -ldl +@CY_EXECUTE_TRUE@datdir = $(libdir) +@CY_EXECUTE_TRUE@dat_DATA = libcycript.db all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -748,7 +773,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bridge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Complete.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Console.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConvertUTF.Plo@am__quote@ @@ -857,6 +881,27 @@ clean-libtool: distclean-libtool: -rm -f libtool config.lt +install-datDATA: $(dat_DATA) + @$(NORMAL_INSTALL) + @list='$(dat_DATA)'; test -n "$(datdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(datdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(datdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(datdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(datdir)" || exit $$?; \ + done + +uninstall-datDATA: + @$(NORMAL_UNINSTALL) + @list='$(dat_DATA)'; test -n "$(datdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(datdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. @@ -1154,12 +1199,12 @@ distcleancheck: distclean exit 1; } >&2 check-am: all-am check: check-recursive -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) config.h +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) config.h install-binPROGRAMS: install-libLTLIBRARIES installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(datdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive @@ -1223,7 +1268,7 @@ info: info-recursive info-am: -install-data-am: +install-data-am: install-datDATA install-dvi: install-dvi-recursive @@ -1271,7 +1316,8 @@ ps: ps-recursive ps-am: -uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES +uninstall-am: uninstall-binPROGRAMS uninstall-datDATA \ + uninstall-libLTLIBRARIES .MAKE: $(am__recursive_targets) all install-am install-strip @@ -1283,25 +1329,32 @@ uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES distcheck distclean distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-binPROGRAMS install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-libLTLIBRARIES install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs installdirs-am \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-binPROGRAMS uninstall-libLTLIBRARIES + info-am install install-am install-binPROGRAMS install-datDATA \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-datDATA uninstall-libLTLIBRARIES .PRECIOUS: Makefile .DELETE_ON_ERROR: - -@CY_EXECUTE_TRUE@Bridge.lo: Bridge.hpp +@CY_EXECUTE_TRUE@libcycript.db: Bridge.def libcycript.sh +@CY_EXECUTE_TRUE@ $(srcdir)/libcycript.sh $(CY_SYSTEM) $@ $< +@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@Analyze: Analyze.cpp +@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@ $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -DCY_OBJECTIVEC=$(CY_OBJECTIVEC) -I$(srcdir)/extra -o $@ $< $(CY_LIBCLANG) +@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@Bridge.def: Analysis.cpp Analyze +@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@ ./Analyze $< $(OBJCXX) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) >$@ +@CY_EXECUTE_TRUE@@CY_PRELINK_FALSE@Bridge.def: Bridge.def.in +@CY_EXECUTE_TRUE@@CY_PRELINK_FALSE@ cat $< >$@ @CY_EXECUTE_TRUE@Bridge.gperf: Bridge.def Bridge.sh -@CY_EXECUTE_TRUE@ $(srcdir)/Bridge.sh $< >$@ +@CY_EXECUTE_TRUE@ $(srcdir)/Bridge.sh <$< >$@ @CY_EXECUTE_TRUE@Bridge.hpp: Bridge.gperf @CY_EXECUTE_TRUE@ $(GPERF) $< >$@ Parser.ypp: Parser.ypp.in diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index ec80665..b5a2d64 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -2977,6 +2977,12 @@ void CYObjectiveC_SetupContext(JSContextRef context) { CYPoolTry { CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Message, prototype_s)), Function_prototype); CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Selector, prototype_s)), Function_prototype); + + CYSetProperty(context, global, CYJSString("YES"), JSValueMakeBoolean(context, true), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("NO"), JSValueMakeBoolean(context, false), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("id"), CYMakeType(context, "@"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("Class"), CYMakeType(context, "#"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, global, CYJSString("SEL"), CYMakeType(context, ":"), kJSPropertyAttributeDontEnum); } CYPoolCatch() } static void *CYObjectiveC_CastSymbol(const char *name) { @@ -3009,8 +3015,7 @@ _extern void CydgetMemoryParse(const uint16_t **data, size_t *size) { try { CYPool pool; CYUTF8String utf8(CYPoolUTF8String(pool, CYUTF16String(*data, *size))); - CYStream stream(utf8.data, utf8.data + utf8.size); - utf8 = CYPoolCode(pool, stream); + utf8 = CYPoolCode(pool, utf8); CYUTF16String utf16(CYPoolUTF16String(pool, CYUTF8String(utf8.data, utf8.size))); size_t bytes(utf16.size * sizeof(uint16_t)); diff --git a/apple-configure.sh b/apple-configure.sh index 68625e5..50b4461 100755 --- a/apple-configure.sh +++ b/apple-configure.sh @@ -41,6 +41,9 @@ function path() { xcs=$(xcode-select --print-path) mac=$(path macosx) +xct="${xcs}/Toolchains/XcodeDefault.xctoolchain/usr/lib" + +system=0 function configure() { local dir=$1 @@ -74,9 +77,10 @@ function configure() { ldf+=" -L../libuv.${arch}/.libs" ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" \ + --with-libclang="-rpath ${xct} ${xct}/libclang.dylib" \ CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \ CFLAGS="${ccf[*]}" CXXFLAGS="${ccf[*]}" OBJCXXFLAGS="${ccf[*]} ${obc}" \ - CPPFLAGS="${cpf}" LDFLAGS="${ldf}" + CPPFLAGS="${cpf}" LDFLAGS="${ldf}" CY_SYSTEM="$((1<package/DEBIAN/control @@ -71,6 +72,8 @@ $(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/libcycript.dylib ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib cp -a libcycript.cy package/usr/lib/libcycript.cy + cp -a Cycript.lib/libcycript.db package/usr/lib/libcycript.db + sqlite3 package/usr/lib/libcycript.db "delete from cache where system & $$(($$(cat build.ios-arm{v6,64}/Makefile | sed -e '/^CY_SYSTEM = \([0-9]*\)$$/{s//\1/;p;};d;' | tr $$'\n' '|') 0)) == 0; vacuum full;" ./dpkg-deb.sh -Zlzma -b package $@ deb: $(deb) @@ -78,6 +81,8 @@ deb: $(deb) clean := +db := + library := libffi libuv # make stubbornly refuses to believe that these @'s are bugs @@ -96,6 +101,9 @@ build.$(1)-$(2)/.libs/libcycript.a: build-$(1)-$(2) clean-$(1)-$(2): $$(MAKE) -C build.$(1)-$(2) clean clean += clean-$(1)-$(2) +db += build.$(1)-$(2)/libcycript.db +build.$(1)-$(2)/libcycript.db: build-$(1)-$(2) + @ ifneq ($(1),sim) $(foreach lib,$(library), $(call build_lar,$(lib),$(2)) @@ -196,6 +204,11 @@ Cycript.lib/libcycript.cy: @mkdir -p $(dir $@) ln -sf ../libcycript.cy $@ +Cycript.lib/libcycript.db: $(db) + @mkdir -p $(dir $@) + ./libcycript.sh 0 $@ + ./libcycript.py $@ $^ + Cycript.lib/cycript0.9: @mkdir -p $(dir $@) ln -s ../modules $@ diff --git a/config.h.in b/config.h.in index 71f2f5c..46d3410 100644 --- a/config.h.in +++ b/config.h.in @@ -46,6 +46,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_READLINE_READLINE_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SQLITE3_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/configure b/configure index ca12353..0dfc278 100755 --- a/configure +++ b/configure @@ -643,6 +643,9 @@ LTFLAGS LTLIBGCC LTLIBTERMCAP LTLIBREADLINE +CY_PRELINK_FALSE +CY_PRELINK_TRUE +CY_LIBCLANG CY_OBJECTIVEC_FALSE CY_OBJECTIVEC_TRUE CY_JAVA_FALSE @@ -655,7 +658,9 @@ CY_JAVA LTLIBFFI LIBFFI_LIBS LIBFFI_CFLAGS +LTLIBSQLITE3 LTLIBUV +CY_SYSTEM CY_EXECUTE_FALSE CY_EXECUTE_TRUE CY_ATTACH_FALSE @@ -681,8 +686,6 @@ PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG HAVE_CXX11 -CXXCPP -CPP LT_SYS_LIBRARY_PATH OTOOL64 OTOOL @@ -702,6 +705,23 @@ FGREP EGREP GREP SED +LIBTOOL +ac_ct_AR +AR +CXXCPPFLAGS_FOR_BUILD +CXXFLAGS_FOR_BUILD +CXXCPP_FOR_BUILD +ac_ct_CXX_FOR_BUILD +CXX_FOR_BUILD +CXXCPP +LDFLAGS_FOR_BUILD +CPPFLAGS_FOR_BUILD +CFLAGS_FOR_BUILD +BUILD_OBJEXT +BUILD_EXEEXT +CPP_FOR_BUILD +ac_ct_CC_FOR_BUILD +CC_FOR_BUILD host_os host_vendor host_cpu @@ -710,9 +730,7 @@ build_os build_vendor build_cpu build -LIBTOOL -ac_ct_AR -AR +CPP am__fastdepOBJCXX_FALSE am__fastdepOBJCXX_TRUE OBJCXXDEPMODE @@ -827,6 +845,7 @@ enable_libtool_lock enable_javascript enable_console enable_attach +with_libclang ' ac_precious_vars='build_alias host_alias @@ -841,9 +860,9 @@ CXXFLAGS CCC OBJCXX OBJCXXFLAGS -LT_SYS_LIBRARY_PATH CPP CXXCPP +LT_SYS_LIBRARY_PATH PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR @@ -1507,6 +1526,7 @@ Optional Packages: --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). + --with-libclang build bridge definitions using this libclang Some influential environment variables: CC C compiler command @@ -1520,10 +1540,10 @@ Some influential environment variables: CXXFLAGS C++ compiler flags OBJCXX Objective C++ compiler command OBJCXXFLAGS Objective C++ compiler flags - LT_SYS_LIBRARY_PATH - User-defined run-time library search path. CPP C preprocessor CXXCPP C++ preprocessor + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path @@ -1737,6 +1757,80 @@ fi } # ac_fn_objcxx_try_compile +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_cpp + # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -1814,43 +1908,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes @@ -1960,43 +2017,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_func -# ac_fn_cxx_try_cpp LINENO -# ------------------------ -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_cpp - # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -4972,49 +4992,1802 @@ fi - -if test -n "$ac_tool_prefix"; then - for ac_prog in ar lib "link -lib" - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + # Broken: fails on valid input. +continue fi +rm -f conftest.err conftest.i conftest.$ac_ext + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext - test -n "$AR" && break - done +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + + +save_cross_compiling=$cross_compiling +save_ac_tool_prefix=$ac_tool_prefix +cross_compiling=no +ac_tool_prefix= + +ac_ext=c +ac_build_cpp='$CPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC_FOR_BUILD -c $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC_FOR_BUILD -o conftest$ac_build_exeext $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC_FOR_BUILD"; then + ac_cv_prog_CC_FOR_BUILD="$CC_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC_FOR_BUILD="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC_FOR_BUILD=$ac_cv_prog_CC_FOR_BUILD +if test -n "$CC_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC_FOR_BUILD" >&5 +$as_echo "$CC_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC_FOR_BUILD"; then + ac_ct_CC_FOR_BUILD=$CC_FOR_BUILD + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC_FOR_BUILD"; then + ac_cv_prog_ac_ct_CC_FOR_BUILD="$ac_ct_CC_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC_FOR_BUILD="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC_FOR_BUILD=$ac_cv_prog_ac_ct_CC_FOR_BUILD +if test -n "$ac_ct_CC_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC_FOR_BUILD" >&5 +$as_echo "$ac_ct_CC_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC_FOR_BUILD" = x; then + CC_FOR_BUILD="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with build triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with build triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC_FOR_BUILD=$ac_ct_CC_FOR_BUILD + fi +else + CC_FOR_BUILD="$ac_cv_prog_CC_FOR_BUILD" +fi + +if test -z "$CC_FOR_BUILD"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC_FOR_BUILD"; then + ac_cv_prog_CC_FOR_BUILD="$CC_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC_FOR_BUILD="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC_FOR_BUILD=$ac_cv_prog_CC_FOR_BUILD +if test -n "$CC_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC_FOR_BUILD" >&5 +$as_echo "$CC_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC_FOR_BUILD"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC_FOR_BUILD"; then + ac_cv_prog_CC_FOR_BUILD="$CC_FOR_BUILD" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC_FOR_BUILD="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC_FOR_BUILD + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC_FOR_BUILD to just the basename; use the full file name. + shift + ac_cv_prog_CC_FOR_BUILD="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC_FOR_BUILD=$ac_cv_prog_CC_FOR_BUILD +if test -n "$CC_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC_FOR_BUILD" >&5 +$as_echo "$CC_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC_FOR_BUILD"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC_FOR_BUILD"; then + ac_cv_prog_CC_FOR_BUILD="$CC_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC_FOR_BUILD="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC_FOR_BUILD=$ac_cv_prog_CC_FOR_BUILD +if test -n "$CC_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC_FOR_BUILD" >&5 +$as_echo "$CC_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC_FOR_BUILD" && break + done +fi +if test -z "$CC_FOR_BUILD"; then + ac_ct_CC_FOR_BUILD=$CC_FOR_BUILD + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC_FOR_BUILD"; then + ac_cv_prog_ac_ct_CC_FOR_BUILD="$ac_ct_CC_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC_FOR_BUILD="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC_FOR_BUILD=$ac_cv_prog_ac_ct_CC_FOR_BUILD +if test -n "$ac_ct_CC_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC_FOR_BUILD" >&5 +$as_echo "$ac_ct_CC_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC_FOR_BUILD" && break +done + + if test "x$ac_ct_CC_FOR_BUILD" = x; then + CC_FOR_BUILD="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with build triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with build triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC_FOR_BUILD=$ac_ct_CC_FOR_BUILD + fi +fi + +fi + + +test -z "$CC_FOR_BUILD" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_build_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_build_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS_FOR_BUILD+set} +ac_save_CFLAGS=$CFLAGS_FOR_BUILD +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC_FOR_BUILD accepts -g" >&5 +$as_echo_n "checking whether $CC_FOR_BUILD accepts -g... " >&6; } +if ${ac_cv_build_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_build_prog_cc_g=no + CFLAGS_FOR_BUILD="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_build_prog_cc_g=yes +else + CFLAGS_FOR_BUILD="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS_FOR_BUILD="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_build_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_build_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_build_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_build_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build_prog_cc_g" >&5 +$as_echo "$ac_cv_build_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS_FOR_BUILD=$ac_save_CFLAGS +elif test $ac_cv_build_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS_FOR_BUILD="-g -O2" + else + CFLAGS_FOR_BUILD="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS_FOR_BUILD="-O2" + else + CFLAGS_FOR_BUILD= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC_FOR_BUILD option to accept ISO C89" >&5 +$as_echo_n "checking for $CC_FOR_BUILD option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC_FOR_BUILD +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC_FOR_BUILD="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_build_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC_FOR_BUILD=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC_FOR_BUILD="$CC_FOR_BUILD $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_build_cpp='$CPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC_FOR_BUILD -c $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC_FOR_BUILD -o conftest$ac_build_exeext $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_build_cpp='$CPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC_FOR_BUILD -c $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC_FOR_BUILD -o conftest$ac_build_exeext $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC_FOR_BUILD understands -c and -o together" >&5 +$as_echo_n "checking whether $CC_FOR_BUILD understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC_FOR_BUILD -c conftest.$ac_ext -o conftest2.$ac_build_objext" >&5 + ($CC_FOR_BUILD -c conftest.$ac_ext -o conftest2.$ac_build_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_build_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC_FOR_BUILD="$am_aux_dir/compile $CC_FOR_BUILD" +fi +ac_ext=c +ac_build_cpp='$CPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC_FOR_BUILD -c $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC_FOR_BUILD -o conftest$ac_build_exeext $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +depcc="$CC_FOR_BUILD" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=c +ac_build_cpp='$CPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC_FOR_BUILD -c $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC_FOR_BUILD -o conftest$ac_build_exeext $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP_FOR_BUILD" && test -d "$CPP_FOR_BUILD"; then + CPP_FOR_BUILD= +fi +if test -z "$CPP_FOR_BUILD"; then + if ${ac_cv_build_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP_FOR_BUILD in "$CC_FOR_BUILD -E" "$CC_FOR_BUILD -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_build_prog_CPP=$CPP_FOR_BUILD + +fi + CPP_FOR_BUILD=$ac_cv_build_prog_CPP +else + ac_cv_build_prog_CPP=$CPP_FOR_BUILD +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP_FOR_BUILD" >&5 +$as_echo "$CPP_FOR_BUILD" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP_FOR_BUILD\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_build_cpp='$CPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC_FOR_BUILD -c $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC_FOR_BUILD -o conftest$ac_build_exeext $CFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_tool_prefix=$save_ac_tool_prefix +cross_compiling=$save_cross_compiling + + +BUILD_EXEEXT=$ac_build_exeext +BUILD_OBJEXT=$ac_build_objext + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if ${ac_cv_prog_CXXCPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +save_cross_compiling=$cross_compiling +save_ac_tool_prefix=$ac_tool_prefix +cross_compiling=no +ac_tool_prefix= + +ac_ext=cpp +ac_cpp='$CXXCPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CXX_FOR_BUILD -c $CXXFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CXX_FOR_BUILD -o conftest$ac_exeext $CXXFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX_FOR_BUILD"; then + if test -n "$CCC"; then + CXX_FOR_BUILD=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX_FOR_BUILD"; then + ac_cv_prog_CXX_FOR_BUILD="$CXX_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX_FOR_BUILD="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX_FOR_BUILD=$ac_cv_prog_CXX_FOR_BUILD +if test -n "$CXX_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX_FOR_BUILD" >&5 +$as_echo "$CXX_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX_FOR_BUILD" && break + done +fi +if test -z "$CXX_FOR_BUILD"; then + ac_ct_CXX_FOR_BUILD=$CXX_FOR_BUILD + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX_FOR_BUILD"; then + ac_cv_prog_ac_ct_CXX_FOR_BUILD="$ac_ct_CXX_FOR_BUILD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX_FOR_BUILD="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX_FOR_BUILD=$ac_cv_prog_ac_ct_CXX_FOR_BUILD +if test -n "$ac_ct_CXX_FOR_BUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX_FOR_BUILD" >&5 +$as_echo "$ac_ct_CXX_FOR_BUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX_FOR_BUILD" && break +done + + if test "x$ac_ct_CXX_FOR_BUILD" = x; then + CXX_FOR_BUILD="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with build triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with build triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX_FOR_BUILD=$ac_ct_CXX_FOR_BUILD + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_build_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS_FOR_BUILD+set} +ac_save_CXXFLAGS=$CXXFLAGS_FOR_BUILD +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX_FOR_BUILD accepts -g" >&5 +$as_echo_n "checking whether $CXX_FOR_BUILD accepts -g... " >&6; } +if ${ac_cv_build_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_build_prog_cxx_g=no + CXXFLAGS_FOR_BUILD="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_build_prog_cxx_g=yes +else + CXXFLAGS_FOR_BUILD="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS_FOR_BUILD="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_build_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build_prog_cxx_g" >&5 +$as_echo "$ac_cv_build_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS_FOR_BUILD=$ac_save_CXXFLAGS +elif test $ac_cv_build_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS_FOR_BUILD="-g -O2" + else + CXXFLAGS_FOR_BUILD="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS_FOR_BUILD="-O2" + else + CXXFLAGS_FOR_BUILD= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC -c $CFLAGS $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS_FOR_BUILD $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX_FOR_BUILD" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +ac_ext=cpp +ac_cpp='$CXXCPP_FOR_BUILD $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CXX_FOR_BUILD -c $CXXFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CXX_FOR_BUILD -o conftest$ac_exeext $CXXFLAGS_FOR_BUILD $CPPFLAGS_FOR_BUILD $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP_FOR_BUILD"; then + if ${ac_cv_build_prog_CXXCPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP_FOR_BUILD in "$CXX_FOR_BUILD -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_build_prog_CXXCPP=$CXXCPP_FOR_BUILD + +fi + CXXCPP_FOR_BUILD=$ac_cv_build_prog_CXXCPP +else + ac_cv_build_prog_CXXCPP=$CXXCPP_FOR_BUILD +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP_FOR_BUILD" >&5 +$as_echo "$CXXCPP_FOR_BUILD" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C++ preprocessor \"$CXXCPP_FOR_BUILD\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS_FOR_BUILD' +ac_build_compile='$CC -c $CFLAGS $CPPFLAGS_FOR_BUILD conftest.$ac_ext >&5' +ac_build_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS_FOR_BUILD $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_tool_prefix=$save_ac_tool_prefix +cross_compiling=$save_cross_compiling + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar lib "link -lib" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AR" && break + done fi if test -z "$AR"; then ac_ct_AR=$AR @@ -5165,83 +6938,12 @@ macro_revision='2.4.6' - - - - -ltmain=$ac_aux_dir/ltmain.sh - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - + + + + +ltmain=$ac_aux_dir/ltmain.sh + # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' @@ -8634,143 +10336,6 @@ func_munge_path_list () esac } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } @@ -20898,6 +22463,9 @@ else fi +if test "x$CY_SYSTEM" = x; then CY_SYSTEM=1; fi + + case $CY_EXECUTE in #( 1) : @@ -20979,6 +22547,83 @@ done + + cy_save=$LIBS + LIBS= + for ac_header in sqlite3.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default" +if test "x$ac_cv_header_sqlite3_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SQLITE3_H 1 +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sqlite3_open_v2" >&5 +$as_echo_n "checking for library containing sqlite3_open_v2... " >&6; } +if ${ac_cv_search_sqlite3_open_v2+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_open_v2 (); +int +main () +{ +return sqlite3_open_v2 (); + ; + return 0; +} +_ACEOF +for ac_lib in '' sqlite3; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_search_sqlite3_open_v2=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_sqlite3_open_v2+:} false; then : + break +fi +done +if ${ac_cv_search_sqlite3_open_v2+:} false; then : + +else + ac_cv_search_sqlite3_open_v2=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sqlite3_open_v2" >&5 +$as_echo "$ac_cv_search_sqlite3_open_v2" >&6; } +ac_res=$ac_cv_search_sqlite3_open_v2 +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + +fi + +done + + LTLIBSQLITE3=$LIBS + LIBS=$cy_save + + + for ac_header in ffi.h ffi/ffi.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -21759,6 +23404,29 @@ fi +# Check whether --with-libclang was given. +if test "${with_libclang+set}" = set; then : + withval=$with_libclang; +else + with_libclang=no +fi + + +if test "x$with_libclang" != "xno"; then : + + CY_LIBCLANG="$with_libclang" + +fi + if test "x$with_libclang" != "xno"; then + CY_PRELINK_TRUE= + CY_PRELINK_FALSE='#' +else + CY_PRELINK_TRUE='#' + CY_PRELINK_FALSE= +fi + + + cy_save=$LIBS LIBS= @@ -22117,6 +23785,14 @@ if test -z "${am__fastdepOBJCXX_TRUE}" && test -z "${am__fastdepOBJCXX_FALSE}"; as_fn_error $? "conditional \"am__fastdepOBJCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${CY_CONSOLE_TRUE}" && test -z "${CY_CONSOLE_FALSE}"; then as_fn_error $? "conditional \"CY_CONSOLE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -22137,6 +23813,10 @@ if test -z "${CY_OBJECTIVEC_TRUE}" && test -z "${CY_OBJECTIVEC_FALSE}"; then as_fn_error $? "conditional \"CY_OBJECTIVEC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${CY_PRELINK_TRUE}" && test -z "${CY_PRELINK_FALSE}"; then + as_fn_error $? "conditional \"CY_PRELINK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/configure.ac b/configure.ac index 88e3230..a1c34d3 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,8 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_OBJCXX +AX_PROG_CXX_FOR_BUILD + AM_PROG_AR AC_PROG_INSTALL @@ -195,11 +197,18 @@ AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [ AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1]) +if test "x$CY_SYSTEM" = x; then CY_SYSTEM=1; fi +AC_SUBST([CY_SYSTEM]) + AS_CASE([$CY_EXECUTE], [1], [ CY_LT_LIB([LTLIBUV], [AC_CHECK_HEADERS([uv.h], [ AC_SEARCH_LIBS([uv_loop_init], [uv]) ])]) + CY_LT_LIB([LTLIBSQLITE3], [AC_CHECK_HEADERS([sqlite3.h], [ + AC_SEARCH_LIBS([sqlite3_open_v2], [sqlite3]) + ])]) + AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [break]) CY_LT_LIB([LTLIBFFI], AS_IF([test "x$ac_cv_header_ffi_h" = xno && test "x$ac_cv_header_ffi_ffi_h" = xno], [ @@ -256,6 +265,12 @@ AS_CASE([$CY_EXECUTE], [1], [ AM_CONDITIONAL([CY_JAVA], [test "x$CY_JAVA" = x1]) AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1]) +AC_ARG_WITH([libclang], AS_HELP_STRING([--with-libclang], [build bridge definitions using this libclang]), [], [with_libclang=no]) + +AS_IF([test "x$with_libclang" != "xno"], [ + AC_SUBST([CY_LIBCLANG], ["$with_libclang"])]) +AM_CONDITIONAL([CY_PRELINK], [test "x$with_libclang" != "xno"]) + CY_LT_LIB([LTLIBREADLINE], [AX_LIB_READLINE]) AS_CASE([$ax_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])]) diff --git a/extra/clang-c/BuildSystem.h b/extra/clang-c/BuildSystem.h new file mode 100644 index 0000000..8d323a4 --- /dev/null +++ b/extra/clang-c/BuildSystem.h @@ -0,0 +1,156 @@ +/*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides various utilities for use by build systems. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_BUILDSYSTEM_H +#define LLVM_CLANG_C_BUILDSYSTEM_H + +#include "clang-c/Platform.h" +#include "clang-c/CXErrorCode.h" +#include "clang-c/CXString.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup BUILD_SYSTEM Build system utilities + * @{ + */ + +/** + * \brief Return the timestamp for use with Clang's + * \c -fbuild-session-timestamp= option. + */ +CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void); + +/** + * \brief Object encapsulating information about overlaying virtual + * file/directories over the real file system. + */ +typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay; + +/** + * \brief Create a \c CXVirtualFileOverlay object. + * Must be disposed with \c clang_VirtualFileOverlay_dispose(). + * + * \param options is reserved, always pass 0. + */ +CINDEX_LINKAGE CXVirtualFileOverlay +clang_VirtualFileOverlay_create(unsigned options); + +/** + * \brief Map an absolute virtual file path to an absolute real one. + * The virtual path must be canonicalized (not contain "."/".."). + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay, + const char *virtualPath, + const char *realPath); + +/** + * \brief Set the case sensitivity for the \c CXVirtualFileOverlay object. + * The \c CXVirtualFileOverlay object is case-sensitive by default, this + * option can be used to override the default. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay, + int caseSensitive); + +/** + * \brief Write out the \c CXVirtualFileOverlay object to a char buffer. + * + * \param options is reserved, always pass 0. + * \param out_buffer_ptr pointer to receive the buffer pointer, which should be + * disposed using \c clang_free(). + * \param out_buffer_size pointer to receive the buffer size. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options, + char **out_buffer_ptr, + unsigned *out_buffer_size); + +/** + * \brief free memory allocated by libclang, such as the buffer returned by + * \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer(). + * + * \param buffer memory pointer to free. + */ +CINDEX_LINKAGE void clang_free(void *buffer); + +/** + * \brief Dispose a \c CXVirtualFileOverlay object. + */ +CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay); + +/** + * \brief Object encapsulating information about a module.map file. + */ +typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor; + +/** + * \brief Create a \c CXModuleMapDescriptor object. + * Must be disposed with \c clang_ModuleMapDescriptor_dispose(). + * + * \param options is reserved, always pass 0. + */ +CINDEX_LINKAGE CXModuleMapDescriptor +clang_ModuleMapDescriptor_create(unsigned options); + +/** + * \brief Sets the framework module name that the module.map describes. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor, + const char *name); + +/** + * \brief Sets the umbrealla header name that the module.map describes. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor, + const char *name); + +/** + * \brief Write out the \c CXModuleMapDescriptor object to a char buffer. + * + * \param options is reserved, always pass 0. + * \param out_buffer_ptr pointer to receive the buffer pointer, which should be + * disposed using \c clang_free(). + * \param out_buffer_size pointer to receive the buffer size. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options, + char **out_buffer_ptr, + unsigned *out_buffer_size); + +/** + * \brief Dispose a \c CXModuleMapDescriptor object. + */ +CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* CLANG_C_BUILD_SYSTEM_H */ + diff --git a/extra/clang-c/CXCompilationDatabase.h b/extra/clang-c/CXCompilationDatabase.h new file mode 100644 index 0000000..9359abf --- /dev/null +++ b/extra/clang-c/CXCompilationDatabase.h @@ -0,0 +1,176 @@ +/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a public inferface to use CompilationDatabase without *| +|* the full Clang C++ API. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H +#define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H + +#include "clang-c/Platform.h" +#include "clang-c/CXString.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** \defgroup COMPILATIONDB CompilationDatabase functions + * \ingroup CINDEX + * + * @{ + */ + +/** + * A compilation database holds all information used to compile files in a + * project. For each file in the database, it can be queried for the working + * directory or the command line used for the compiler invocation. + * + * Must be freed by \c clang_CompilationDatabase_dispose + */ +typedef void * CXCompilationDatabase; + +/** + * \brief Contains the results of a search in the compilation database + * + * When searching for the compile command for a file, the compilation db can + * return several commands, as the file may have been compiled with + * different options in different places of the project. This choice of compile + * commands is wrapped in this opaque data structure. It must be freed by + * \c clang_CompileCommands_dispose. + */ +typedef void * CXCompileCommands; + +/** + * \brief Represents the command line invocation to compile a specific file. + */ +typedef void * CXCompileCommand; + +/** + * \brief Error codes for Compilation Database + */ +typedef enum { + /* + * \brief No error occurred + */ + CXCompilationDatabase_NoError = 0, + + /* + * \brief Database can not be loaded + */ + CXCompilationDatabase_CanNotLoadDatabase = 1 + +} CXCompilationDatabase_Error; + +/** + * \brief Creates a compilation database from the database found in directory + * buildDir. For example, CMake can output a compile_commands.json which can + * be used to build the database. + * + * It must be freed by \c clang_CompilationDatabase_dispose. + */ +CINDEX_LINKAGE CXCompilationDatabase +clang_CompilationDatabase_fromDirectory(const char *BuildDir, + CXCompilationDatabase_Error *ErrorCode); + +/** + * \brief Free the given compilation database + */ +CINDEX_LINKAGE void +clang_CompilationDatabase_dispose(CXCompilationDatabase); + +/** + * \brief Find the compile commands used for a file. The compile commands + * must be freed by \c clang_CompileCommands_dispose. + */ +CINDEX_LINKAGE CXCompileCommands +clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase, + const char *CompleteFileName); + +/** + * \brief Get all the compile commands in the given compilation database. + */ +CINDEX_LINKAGE CXCompileCommands +clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase); + +/** + * \brief Free the given CompileCommands + */ +CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands); + +/** + * \brief Get the number of CompileCommand we have for a file + */ +CINDEX_LINKAGE unsigned +clang_CompileCommands_getSize(CXCompileCommands); + +/** + * \brief Get the I'th CompileCommand for a file + * + * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands) + */ +CINDEX_LINKAGE CXCompileCommand +clang_CompileCommands_getCommand(CXCompileCommands, unsigned I); + +/** + * \brief Get the working directory where the CompileCommand was executed from + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getDirectory(CXCompileCommand); + +/** + * \brief Get the filename associated with the CompileCommand. + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getFilename(CXCompileCommand); + +/** + * \brief Get the number of arguments in the compiler invocation. + * + */ +CINDEX_LINKAGE unsigned +clang_CompileCommand_getNumArgs(CXCompileCommand); + +/** + * \brief Get the I'th argument value in the compiler invocations + * + * Invariant : + * - argument 0 is the compiler executable + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getArg(CXCompileCommand, unsigned I); + +/** + * \brief Get the number of source mappings for the compiler invocation. + */ +CINDEX_LINKAGE unsigned +clang_CompileCommand_getNumMappedSources(CXCompileCommand); + +/** + * \brief Get the I'th mapped source path for the compiler invocation. + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I); + +/** + * \brief Get the I'th mapped source content for the compiler invocation. + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/extra/clang-c/CXErrorCode.h b/extra/clang-c/CXErrorCode.h new file mode 100644 index 0000000..aff73b7 --- /dev/null +++ b/extra/clang-c/CXErrorCode.h @@ -0,0 +1,64 @@ +/*===-- clang-c/CXErrorCode.h - C Index Error Codes --------------*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the CXErrorCode enumerators. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXERRORCODE_H +#define LLVM_CLANG_C_CXERRORCODE_H + +#include "clang-c/Platform.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Error codes returned by libclang routines. + * + * Zero (\c CXError_Success) is the only error code indicating success. Other + * error codes, including not yet assigned non-zero values, indicate errors. + */ +enum CXErrorCode { + /** + * \brief No error. + */ + CXError_Success = 0, + + /** + * \brief A generic error code, no further details are available. + * + * Errors of this kind can get their own specific error codes in future + * libclang versions. + */ + CXError_Failure = 1, + + /** + * \brief libclang crashed while performing the requested operation. + */ + CXError_Crashed = 2, + + /** + * \brief The function detected that the arguments violate the function + * contract. + */ + CXError_InvalidArguments = 3, + + /** + * \brief An AST deserialization error has occurred. + */ + CXError_ASTReadError = 4 +}; + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/extra/clang-c/CXString.h b/extra/clang-c/CXString.h new file mode 100644 index 0000000..68ab7bc --- /dev/null +++ b/extra/clang-c/CXString.h @@ -0,0 +1,71 @@ +/*===-- clang-c/CXString.h - C Index strings --------------------*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the interface to C Index strings. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXSTRING_H +#define LLVM_CLANG_C_CXSTRING_H + +#include "clang-c/Platform.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup CINDEX_STRING String manipulation routines + * \ingroup CINDEX + * + * @{ + */ + +/** + * \brief A character string. + * + * The \c CXString type is used to return strings from the interface when + * the ownership of that string might differ from one call to the next. + * Use \c clang_getCString() to retrieve the string data and, once finished + * with the string data, call \c clang_disposeString() to free the string. + */ +typedef struct { + const void *data; + unsigned private_flags; +} CXString; + +typedef struct { + CXString *Strings; + unsigned Count; +} CXStringSet; + +/** + * \brief Retrieve the character data associated with the given string. + */ +CINDEX_LINKAGE const char *clang_getCString(CXString string); + +/** + * \brief Free the given string. + */ +CINDEX_LINKAGE void clang_disposeString(CXString string); + +/** + * \brief Free the given string set. + */ +CINDEX_LINKAGE void clang_disposeStringSet(CXStringSet *set); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/extra/clang-c/Documentation.h b/extra/clang-c/Documentation.h new file mode 100644 index 0000000..89373b1 --- /dev/null +++ b/extra/clang-c/Documentation.h @@ -0,0 +1,554 @@ +/*==-- clang-c/Documentation.h - Utilities for comment processing -*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a supplementary interface for inspecting *| +|* documentation comments. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_DOCUMENTATION_H +#define LLVM_CLANG_C_DOCUMENTATION_H + +#include "clang-c/Index.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup CINDEX_COMMENT Comment introspection + * + * The routines in this group provide access to information in documentation + * comments. These facilities are distinct from the core and may be subject to + * their own schedule of stability and deprecation. + * + * @{ + */ + +/** + * \brief A parsed comment. + */ +typedef struct { + const void *ASTNode; + CXTranslationUnit TranslationUnit; +} CXComment; + +/** + * \brief Given a cursor that represents a documentable entity (e.g., + * declaration), return the associated parsed comment as a + * \c CXComment_FullComment AST node. + */ +CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C); + +/** + * \brief Describes the type of the comment AST node (\c CXComment). A comment + * node can be considered block content (e. g., paragraph), inline content + * (plain text) or neither (the root AST node). + */ +enum CXCommentKind { + /** + * \brief Null comment. No AST node is constructed at the requested location + * because there is no text or a syntax error. + */ + CXComment_Null = 0, + + /** + * \brief Plain text. Inline content. + */ + CXComment_Text = 1, + + /** + * \brief A command with word-like arguments that is considered inline content. + * + * For example: \\c command. + */ + CXComment_InlineCommand = 2, + + /** + * \brief HTML start tag with attributes (name-value pairs). Considered + * inline content. + * + * For example: + * \verbatim + *

+ * \endverbatim + */ + CXComment_HTMLStartTag = 3, + + /** + * \brief HTML end tag. Considered inline content. + * + * For example: + * \verbatim + * + * \endverbatim + */ + CXComment_HTMLEndTag = 4, + + /** + * \brief A paragraph, contains inline comment. The paragraph itself is + * block content. + */ + CXComment_Paragraph = 5, + + /** + * \brief A command that has zero or more word-like arguments (number of + * word-like arguments depends on command name) and a paragraph as an + * argument. Block command is block content. + * + * Paragraph argument is also a child of the block command. + * + * For example: \\brief has 0 word-like arguments and a paragraph argument. + * + * AST nodes of special kinds that parser knows about (e. g., \\param + * command) have their own node kinds. + */ + CXComment_BlockCommand = 6, + + /** + * \brief A \\param or \\arg command that describes the function parameter + * (name, passing direction, description). + * + * For example: \\param [in] ParamName description. + */ + CXComment_ParamCommand = 7, + + /** + * \brief A \\tparam command that describes a template parameter (name and + * description). + * + * For example: \\tparam T description. + */ + CXComment_TParamCommand = 8, + + /** + * \brief A verbatim block command (e. g., preformatted code). Verbatim + * block has an opening and a closing command and contains multiple lines of + * text (\c CXComment_VerbatimBlockLine child nodes). + * + * For example: + * \\verbatim + * aaa + * \\endverbatim + */ + CXComment_VerbatimBlockCommand = 9, + + /** + * \brief A line of text that is contained within a + * CXComment_VerbatimBlockCommand node. + */ + CXComment_VerbatimBlockLine = 10, + + /** + * \brief A verbatim line command. Verbatim line has an opening command, + * a single line of text (up to the newline after the opening command) and + * has no closing command. + */ + CXComment_VerbatimLine = 11, + + /** + * \brief A full comment attached to a declaration, contains block content. + */ + CXComment_FullComment = 12 +}; + +/** + * \brief The most appropriate rendering mode for an inline command, chosen on + * command semantics in Doxygen. + */ +enum CXCommentInlineCommandRenderKind { + /** + * \brief Command argument should be rendered in a normal font. + */ + CXCommentInlineCommandRenderKind_Normal, + + /** + * \brief Command argument should be rendered in a bold font. + */ + CXCommentInlineCommandRenderKind_Bold, + + /** + * \brief Command argument should be rendered in a monospaced font. + */ + CXCommentInlineCommandRenderKind_Monospaced, + + /** + * \brief Command argument should be rendered emphasized (typically italic + * font). + */ + CXCommentInlineCommandRenderKind_Emphasized +}; + +/** + * \brief Describes parameter passing direction for \\param or \\arg command. + */ +enum CXCommentParamPassDirection { + /** + * \brief The parameter is an input parameter. + */ + CXCommentParamPassDirection_In, + + /** + * \brief The parameter is an output parameter. + */ + CXCommentParamPassDirection_Out, + + /** + * \brief The parameter is an input and output parameter. + */ + CXCommentParamPassDirection_InOut +}; + +/** + * \param Comment AST node of any kind. + * + * \returns the type of the AST node. + */ +CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment); + +/** + * \param Comment AST node of any kind. + * + * \returns number of children of the AST node. + */ +CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment); + +/** + * \param Comment AST node of any kind. + * + * \param ChildIdx child index (zero-based). + * + * \returns the specified child of the AST node. + */ +CINDEX_LINKAGE +CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx); + +/** + * \brief A \c CXComment_Paragraph node is considered whitespace if it contains + * only \c CXComment_Text nodes that are empty or whitespace. + * + * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are + * never considered whitespace. + * + * \returns non-zero if \c Comment is whitespace. + */ +CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment); + +/** + * \returns non-zero if \c Comment is inline content and has a newline + * immediately following it in the comment text. Newlines between paragraphs + * do not count. + */ +CINDEX_LINKAGE +unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment); + +/** + * \param Comment a \c CXComment_Text AST node. + * + * \returns text contained in the AST node. + */ +CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \returns name of the inline command. + */ +CINDEX_LINKAGE +CXString clang_InlineCommandComment_getCommandName(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \returns the most appropriate rendering mode, chosen on command + * semantics in Doxygen. + */ +CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind +clang_InlineCommandComment_getRenderKind(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \returns number of command arguments. + */ +CINDEX_LINKAGE +unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \param ArgIdx argument index (zero-based). + * + * \returns text of the specified argument. + */ +CINDEX_LINKAGE +CXString clang_InlineCommandComment_getArgText(CXComment Comment, + unsigned ArgIdx); + +/** + * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST + * node. + * + * \returns HTML tag name. + */ +CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \returns non-zero if tag is self-closing (for example, <br />). + */ +CINDEX_LINKAGE +unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \returns number of attributes (name-value pairs) attached to the start tag. + */ +CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \param AttrIdx attribute index (zero-based). + * + * \returns name of the specified attribute. + */ +CINDEX_LINKAGE +CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \param AttrIdx attribute index (zero-based). + * + * \returns value of the specified attribute. + */ +CINDEX_LINKAGE +CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx); + +/** + * \param Comment a \c CXComment_BlockCommand AST node. + * + * \returns name of the block command. + */ +CINDEX_LINKAGE +CXString clang_BlockCommandComment_getCommandName(CXComment Comment); + +/** + * \param Comment a \c CXComment_BlockCommand AST node. + * + * \returns number of word-like arguments. + */ +CINDEX_LINKAGE +unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment); + +/** + * \param Comment a \c CXComment_BlockCommand AST node. + * + * \param ArgIdx argument index (zero-based). + * + * \returns text of the specified word-like argument. + */ +CINDEX_LINKAGE +CXString clang_BlockCommandComment_getArgText(CXComment Comment, + unsigned ArgIdx); + +/** + * \param Comment a \c CXComment_BlockCommand or + * \c CXComment_VerbatimBlockCommand AST node. + * + * \returns paragraph argument of the block command. + */ +CINDEX_LINKAGE +CXComment clang_BlockCommandComment_getParagraph(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns parameter name. + */ +CINDEX_LINKAGE +CXString clang_ParamCommandComment_getParamName(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns non-zero if the parameter that this AST node represents was found + * in the function prototype and \c clang_ParamCommandComment_getParamIndex + * function will return a meaningful value. + */ +CINDEX_LINKAGE +unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns zero-based parameter index in function prototype. + */ +CINDEX_LINKAGE +unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns non-zero if parameter passing direction was specified explicitly in + * the comment. + */ +CINDEX_LINKAGE +unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns parameter passing direction. + */ +CINDEX_LINKAGE +enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection( + CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns template parameter name. + */ +CINDEX_LINKAGE +CXString clang_TParamCommandComment_getParamName(CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns non-zero if the parameter that this AST node represents was found + * in the template parameter list and + * \c clang_TParamCommandComment_getDepth and + * \c clang_TParamCommandComment_getIndex functions will return a meaningful + * value. + */ +CINDEX_LINKAGE +unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns zero-based nesting depth of this parameter in the template parameter list. + * + * For example, + * \verbatim + * template class TT> + * void test(TT aaa); + * \endverbatim + * for C and TT nesting depth is 0, + * for T nesting depth is 1. + */ +CINDEX_LINKAGE +unsigned clang_TParamCommandComment_getDepth(CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns zero-based parameter index in the template parameter list at a + * given nesting depth. + * + * For example, + * \verbatim + * template class TT> + * void test(TT aaa); + * \endverbatim + * for C and TT nesting depth is 0, so we can ask for index at depth 0: + * at depth 0 C's index is 0, TT's index is 1. + * + * For T nesting depth is 1, so we can ask for index at depth 0 and 1: + * at depth 0 T's index is 1 (same as TT's), + * at depth 1 T's index is 0. + */ +CINDEX_LINKAGE +unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth); + +/** + * \param Comment a \c CXComment_VerbatimBlockLine AST node. + * + * \returns text contained in the AST node. + */ +CINDEX_LINKAGE +CXString clang_VerbatimBlockLineComment_getText(CXComment Comment); + +/** + * \param Comment a \c CXComment_VerbatimLine AST node. + * + * \returns text contained in the AST node. + */ +CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment); + +/** + * \brief Convert an HTML tag AST node to string. + * + * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST + * node. + * + * \returns string containing an HTML tag. + */ +CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment); + +/** + * \brief Convert a given full parsed comment to an HTML fragment. + * + * Specific details of HTML layout are subject to change. Don't try to parse + * this HTML back into an AST, use other APIs instead. + * + * Currently the following CSS classes are used: + * \li "para-brief" for \\brief paragraph and equivalent commands; + * \li "para-returns" for \\returns paragraph and equivalent commands; + * \li "word-returns" for the "Returns" word in \\returns paragraph. + * + * Function argument documentation is rendered as a \ list with arguments + * sorted in function prototype order. CSS classes used: + * \li "param-name-index-NUMBER" for parameter name (\); + * \li "param-descr-index-NUMBER" for parameter description (\); + * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if + * parameter index is invalid. + * + * Template parameter documentation is rendered as a \ list with + * parameters sorted in template parameter list order. CSS classes used: + * \li "tparam-name-index-NUMBER" for parameter name (\); + * \li "tparam-descr-index-NUMBER" for parameter description (\); + * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for + * names inside template template parameters; + * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if + * parameter position is invalid. + * + * \param Comment a \c CXComment_FullComment AST node. + * + * \returns string containing an HTML fragment. + */ +CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment); + +/** + * \brief Convert a given full parsed comment to an XML document. + * + * A Relax NG schema for the XML can be found in comment-xml-schema.rng file + * inside clang source tree. + * + * \param Comment a \c CXComment_FullComment AST node. + * + * \returns string containing an XML document. + */ +CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* CLANG_C_DOCUMENTATION_H */ + diff --git a/extra/clang-c/Index.h b/extra/clang-c/Index.h new file mode 100644 index 0000000..09e2160 --- /dev/null +++ b/extra/clang-c/Index.h @@ -0,0 +1,5835 @@ +/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a public inferface to a Clang library for extracting *| +|* high-level symbol information from source files without exposing the full *| +|* Clang C++ API. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_INDEX_H +#define LLVM_CLANG_C_INDEX_H + +#include + +#include "clang-c/Platform.h" +#include "clang-c/CXErrorCode.h" +#include "clang-c/CXString.h" +#include "clang-c/BuildSystem.h" + +/** + * \brief The version constants for the libclang API. + * CINDEX_VERSION_MINOR should increase when there are API additions. + * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. + * + * The policy about the libclang API was always to keep it source and ABI + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. + */ +#define CINDEX_VERSION_MAJOR 0 +#define CINDEX_VERSION_MINOR 32 + +#define CINDEX_VERSION_ENCODE(major, minor) ( \ + ((major) * 10000) \ + + ((minor) * 1)) + +#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \ + CINDEX_VERSION_MAJOR, \ + CINDEX_VERSION_MINOR ) + +#define CINDEX_VERSION_STRINGIZE_(major, minor) \ + #major"."#minor +#define CINDEX_VERSION_STRINGIZE(major, minor) \ + CINDEX_VERSION_STRINGIZE_(major, minor) + +#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \ + CINDEX_VERSION_MAJOR, \ + CINDEX_VERSION_MINOR) + +#ifdef __cplusplus +extern "C" { +#endif + +/** \defgroup CINDEX libclang: C Interface to Clang + * + * The C Interface to Clang provides a relatively small API that exposes + * facilities for parsing source code into an abstract syntax tree (AST), + * loading already-parsed ASTs, traversing the AST, associating + * physical source locations with elements within the AST, and other + * facilities that support Clang-based development tools. + * + * This C interface to Clang will never provide all of the information + * representation stored in Clang's C++ AST, nor should it: the intent is to + * maintain an API that is relatively stable from one release to the next, + * providing only the basic functionality needed to support development tools. + * + * To avoid namespace pollution, data types are prefixed with "CX" and + * functions are prefixed with "clang_". + * + * @{ + */ + +/** + * \brief An "index" that consists of a set of translation units that would + * typically be linked together into an executable or library. + */ +typedef void *CXIndex; + +/** + * \brief A single translation unit, which resides in an index. + */ +typedef struct CXTranslationUnitImpl *CXTranslationUnit; + +/** + * \brief Opaque pointer representing client data that will be passed through + * to various callbacks and visitors. + */ +typedef void *CXClientData; + +/** + * \brief Provides the contents of a file that has not yet been saved to disk. + * + * Each CXUnsavedFile instance provides the name of a file on the + * system along with the current contents of that file that have not + * yet been saved to disk. + */ +struct CXUnsavedFile { + /** + * \brief The file whose contents have not yet been saved. + * + * This file must already exist in the file system. + */ + const char *Filename; + + /** + * \brief A buffer containing the unsaved contents of this file. + */ + const char *Contents; + + /** + * \brief The length of the unsaved contents of this buffer. + */ + unsigned long Length; +}; + +/** + * \brief Describes the availability of a particular entity, which indicates + * whether the use of this entity will result in a warning or error due to + * it being deprecated or unavailable. + */ +enum CXAvailabilityKind { + /** + * \brief The entity is available. + */ + CXAvailability_Available, + /** + * \brief The entity is available, but has been deprecated (and its use is + * not recommended). + */ + CXAvailability_Deprecated, + /** + * \brief The entity is not available; any use of it will be an error. + */ + CXAvailability_NotAvailable, + /** + * \brief The entity is available, but not accessible; any use of it will be + * an error. + */ + CXAvailability_NotAccessible +}; + +/** + * \brief Describes a version number of the form major.minor.subminor. + */ +typedef struct CXVersion { + /** + * \brief The major version number, e.g., the '10' in '10.7.3'. A negative + * value indicates that there is no version number at all. + */ + int Major; + /** + * \brief The minor version number, e.g., the '7' in '10.7.3'. This value + * will be negative if no minor version number was provided, e.g., for + * version '10'. + */ + int Minor; + /** + * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value + * will be negative if no minor or subminor version number was provided, + * e.g., in version '10' or '10.7'. + */ + int Subminor; +} CXVersion; + +/** + * \brief Provides a shared context for creating translation units. + * + * It provides two options: + * + * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" + * declarations (when loading any new translation units). A "local" declaration + * is one that belongs in the translation unit itself and not in a precompiled + * header that was used by the translation unit. If zero, all declarations + * will be enumerated. + * + * Here is an example: + * + * \code + * // excludeDeclsFromPCH = 1, displayDiagnostics=1 + * Idx = clang_createIndex(1, 1); + * + * // IndexTest.pch was produced with the following command: + * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" + * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); + * + * // This will load all the symbols from 'IndexTest.pch' + * clang_visitChildren(clang_getTranslationUnitCursor(TU), + * TranslationUnitVisitor, 0); + * clang_disposeTranslationUnit(TU); + * + * // This will load all the symbols from 'IndexTest.c', excluding symbols + * // from 'IndexTest.pch'. + * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; + * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, + * 0, 0); + * clang_visitChildren(clang_getTranslationUnitCursor(TU), + * TranslationUnitVisitor, 0); + * clang_disposeTranslationUnit(TU); + * \endcode + * + * This process of creating the 'pch', loading it separately, and using it (via + * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks + * (which gives the indexer the same performance benefit as the compiler). + */ +CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, + int displayDiagnostics); + +/** + * \brief Destroy the given index. + * + * The index must not be destroyed until all of the translation units created + * within that index have been destroyed. + */ +CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); + +typedef enum { + /** + * \brief Used to indicate that no special CXIndex options are needed. + */ + CXGlobalOpt_None = 0x0, + + /** + * \brief Used to indicate that threads that libclang creates for indexing + * purposes should use background priority. + * + * Affects #clang_indexSourceFile, #clang_indexTranslationUnit, + * #clang_parseTranslationUnit, #clang_saveTranslationUnit. + */ + CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, + + /** + * \brief Used to indicate that threads that libclang creates for editing + * purposes should use background priority. + * + * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, + * #clang_annotateTokens + */ + CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, + + /** + * \brief Used to indicate that all threads that libclang creates should use + * background priority. + */ + CXGlobalOpt_ThreadBackgroundPriorityForAll = + CXGlobalOpt_ThreadBackgroundPriorityForIndexing | + CXGlobalOpt_ThreadBackgroundPriorityForEditing + +} CXGlobalOptFlags; + +/** + * \brief Sets general options associated with a CXIndex. + * + * For example: + * \code + * CXIndex idx = ...; + * clang_CXIndex_setGlobalOptions(idx, + * clang_CXIndex_getGlobalOptions(idx) | + * CXGlobalOpt_ThreadBackgroundPriorityForIndexing); + * \endcode + * + * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags. + */ +CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); + +/** + * \brief Gets the general options associated with a CXIndex. + * + * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that + * are associated with the given CXIndex object. + */ +CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex); + +/** + * \defgroup CINDEX_FILES File manipulation routines + * + * @{ + */ + +/** + * \brief A particular source file that is part of a translation unit. + */ +typedef void *CXFile; + +/** + * \brief Retrieve the complete file and path name of the given file. + */ +CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); + +/** + * \brief Retrieve the last modification time of the given file. + */ +CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); + +/** + * \brief Uniquely identifies a CXFile, that refers to the same underlying file, + * across an indexing session. + */ +typedef struct { + unsigned long long data[3]; +} CXFileUniqueID; + +/** + * \brief Retrieve the unique ID for the given \c file. + * + * \param file the file to get the ID for. + * \param outID stores the returned CXFileUniqueID. + * \returns If there was a failure getting the unique ID, returns non-zero, + * otherwise returns 0. +*/ +CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID); + +/** + * \brief Determine whether the given header is guarded against + * multiple inclusions, either with the conventional + * \#ifndef/\#define/\#endif macro guards or with \#pragma once. + */ +CINDEX_LINKAGE unsigned +clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); + +/** + * \brief Retrieve a file handle within the given translation unit. + * + * \param tu the translation unit + * + * \param file_name the name of the file. + * + * \returns the file handle for the named file in the translation unit \p tu, + * or a NULL file handle if the file was not a part of this translation unit. + */ +CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, + const char *file_name); + +/** + * \brief Returns non-zero if the \c file1 and \c file2 point to the same file, + * or they are both NULL. + */ +CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); + +/** + * @} + */ + +/** + * \defgroup CINDEX_LOCATIONS Physical source locations + * + * Clang represents physical source locations in its abstract syntax tree in + * great detail, with file, line, and column information for the majority of + * the tokens parsed in the source code. These data types and functions are + * used to represent source location information, either for a particular + * point in the program or for a range of points in the program, and extract + * specific location information from those data types. + * + * @{ + */ + +/** + * \brief Identifies a specific source location within a translation + * unit. + * + * Use clang_getExpansionLocation() or clang_getSpellingLocation() + * to map a source location to a particular file, line, and column. + */ +typedef struct { + const void *ptr_data[2]; + unsigned int_data; +} CXSourceLocation; + +/** + * \brief Identifies a half-open character range in the source code. + * + * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the + * starting and end locations from a source range, respectively. + */ +typedef struct { + const void *ptr_data[2]; + unsigned begin_int_data; + unsigned end_int_data; +} CXSourceRange; + +/** + * \brief Retrieve a NULL (invalid) source location. + */ +CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void); + +/** + * \brief Determine whether two source locations, which must refer into + * the same translation unit, refer to exactly the same point in the source + * code. + * + * \returns non-zero if the source locations refer to the same location, zero + * if they refer to different locations. + */ +CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, + CXSourceLocation loc2); + +/** + * \brief Retrieves the source location associated with a given file/line/column + * in a particular translation unit. + */ +CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, + CXFile file, + unsigned line, + unsigned column); +/** + * \brief Retrieves the source location associated with a given character offset + * in a particular translation unit. + */ +CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, + CXFile file, + unsigned offset); + +/** + * \brief Returns non-zero if the given source location is in a system header. + */ +CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location); + +/** + * \brief Returns non-zero if the given source location is in the main file of + * the corresponding translation unit. + */ +CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location); + +/** + * \brief Retrieve a NULL (invalid) source range. + */ +CINDEX_LINKAGE CXSourceRange clang_getNullRange(void); + +/** + * \brief Retrieve a source range given the beginning and ending source + * locations. + */ +CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, + CXSourceLocation end); + +/** + * \brief Determine whether two ranges are equivalent. + * + * \returns non-zero if the ranges are the same, zero if they differ. + */ +CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, + CXSourceRange range2); + +/** + * \brief Returns non-zero if \p range is null. + */ +CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); + +/** + * \brief Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro expansion, retrieves the + * location of the macro expansion. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, + CXFile *file, + unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * \brief Retrieve the file, line, column, and offset represented by + * the given source location, as specified in a # line directive. + * + * Example: given the following source code in a file somefile.c + * + * \code + * #123 "dummy.c" 1 + * + * static int func(void) + * { + * return 0; + * } + * \endcode + * + * the location information returned by this function would be + * + * File: dummy.c Line: 124 Column: 12 + * + * whereas clang_getExpansionLocation would have returned + * + * File: somefile.c Line: 3 Column: 12 + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param filename [out] if non-NULL, will be set to the filename of the + * source location. Note that filenames returned will be for "virtual" files, + * which don't necessarily exist on the machine running clang - e.g. when + * parsing preprocessed output obtained from a different environment. If + * a non-NULL value is passed in, remember to dispose of the returned value + * using \c clang_disposeString() once you've finished with it. For an invalid + * source location, an empty string is returned. + * + * \param line [out] if non-NULL, will be set to the line number of the + * source location. For an invalid source location, zero is returned. + * + * \param column [out] if non-NULL, will be set to the column number of the + * source location. For an invalid source location, zero is returned. + */ +CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, + CXString *filename, + unsigned *line, + unsigned *column); + +/** + * \brief Legacy API to retrieve the file, line, column, and offset represented + * by the given source location. + * + * This interface has been replaced by the newer interface + * #clang_getExpansionLocation(). See that interface's documentation for + * details. + */ +CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, + CXFile *file, + unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * \brief Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro instantiation, return where the + * location was originally spelled in the source file. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, + CXFile *file, + unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * \brief Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro expansion, return where the macro was + * expanded or where the macro argument was written, if the location points at + * a macro argument. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location, + CXFile *file, + unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * \brief Retrieve a source location representing the first character within a + * source range. + */ +CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); + +/** + * \brief Retrieve a source location representing the last character within a + * source range. + */ +CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); + +/** + * \brief Identifies an array of ranges. + */ +typedef struct { + /** \brief The number of ranges in the \c ranges array. */ + unsigned count; + /** + * \brief An array of \c CXSourceRanges. + */ + CXSourceRange *ranges; +} CXSourceRangeList; + +/** + * \brief Retrieve all ranges that were skipped by the preprocessor. + * + * The preprocessor will skip lines when they are surrounded by an + * if/ifdef/ifndef directive whose condition does not evaluate to true. + */ +CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, + CXFile file); + +/** + * \brief Destroy the given \c CXSourceRangeList. + */ +CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges); + +/** + * @} + */ + +/** + * \defgroup CINDEX_DIAG Diagnostic reporting + * + * @{ + */ + +/** + * \brief Describes the severity of a particular diagnostic. + */ +enum CXDiagnosticSeverity { + /** + * \brief A diagnostic that has been suppressed, e.g., by a command-line + * option. + */ + CXDiagnostic_Ignored = 0, + + /** + * \brief This diagnostic is a note that should be attached to the + * previous (non-note) diagnostic. + */ + CXDiagnostic_Note = 1, + + /** + * \brief This diagnostic indicates suspicious code that may not be + * wrong. + */ + CXDiagnostic_Warning = 2, + + /** + * \brief This diagnostic indicates that the code is ill-formed. + */ + CXDiagnostic_Error = 3, + + /** + * \brief This diagnostic indicates that the code is ill-formed such + * that future parser recovery is unlikely to produce useful + * results. + */ + CXDiagnostic_Fatal = 4 +}; + +/** + * \brief A single diagnostic, containing the diagnostic's severity, + * location, text, source ranges, and fix-it hints. + */ +typedef void *CXDiagnostic; + +/** + * \brief A group of CXDiagnostics. + */ +typedef void *CXDiagnosticSet; + +/** + * \brief Determine the number of diagnostics in a CXDiagnosticSet. + */ +CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); + +/** + * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet. + * + * \param Diags the CXDiagnosticSet to query. + * \param Index the zero-based diagnostic number to retrieve. + * + * \returns the requested diagnostic. This diagnostic must be freed + * via a call to \c clang_disposeDiagnostic(). + */ +CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, + unsigned Index); + +/** + * \brief Describes the kind of error that occurred (if any) in a call to + * \c clang_loadDiagnostics. + */ +enum CXLoadDiag_Error { + /** + * \brief Indicates that no error occurred. + */ + CXLoadDiag_None = 0, + + /** + * \brief Indicates that an unknown error occurred while attempting to + * deserialize diagnostics. + */ + CXLoadDiag_Unknown = 1, + + /** + * \brief Indicates that the file containing the serialized diagnostics + * could not be opened. + */ + CXLoadDiag_CannotLoad = 2, + + /** + * \brief Indicates that the serialized diagnostics file is invalid or + * corrupt. + */ + CXLoadDiag_InvalidFile = 3 +}; + +/** + * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode + * file. + * + * \param file The name of the file to deserialize. + * \param error A pointer to a enum value recording if there was a problem + * deserializing the diagnostics. + * \param errorString A pointer to a CXString for recording the error string + * if the file was not successfully loaded. + * + * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These + * diagnostics should be released using clang_disposeDiagnosticSet(). + */ +CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file, + enum CXLoadDiag_Error *error, + CXString *errorString); + +/** + * \brief Release a CXDiagnosticSet and all of its contained diagnostics. + */ +CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); + +/** + * \brief Retrieve the child diagnostics of a CXDiagnostic. + * + * This CXDiagnosticSet does not need to be released by + * clang_disposeDiagnosticSet. + */ +CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D); + +/** + * \brief Determine the number of diagnostics produced for the given + * translation unit. + */ +CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); + +/** + * \brief Retrieve a diagnostic associated with the given translation unit. + * + * \param Unit the translation unit to query. + * \param Index the zero-based diagnostic number to retrieve. + * + * \returns the requested diagnostic. This diagnostic must be freed + * via a call to \c clang_disposeDiagnostic(). + */ +CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, + unsigned Index); + +/** + * \brief Retrieve the complete set of diagnostics associated with a + * translation unit. + * + * \param Unit the translation unit to query. + */ +CINDEX_LINKAGE CXDiagnosticSet + clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); + +/** + * \brief Destroy a diagnostic. + */ +CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); + +/** + * \brief Options to control the display of diagnostics. + * + * The values in this enum are meant to be combined to customize the + * behavior of \c clang_formatDiagnostic(). + */ +enum CXDiagnosticDisplayOptions { + /** + * \brief Display the source-location information where the + * diagnostic was located. + * + * When set, diagnostics will be prefixed by the file, line, and + * (optionally) column to which the diagnostic refers. For example, + * + * \code + * test.c:28: warning: extra tokens at end of #endif directive + * \endcode + * + * This option corresponds to the clang flag \c -fshow-source-location. + */ + CXDiagnostic_DisplaySourceLocation = 0x01, + + /** + * \brief If displaying the source-location information of the + * diagnostic, also include the column number. + * + * This option corresponds to the clang flag \c -fshow-column. + */ + CXDiagnostic_DisplayColumn = 0x02, + + /** + * \brief If displaying the source-location information of the + * diagnostic, also include information about source ranges in a + * machine-parsable format. + * + * This option corresponds to the clang flag + * \c -fdiagnostics-print-source-range-info. + */ + CXDiagnostic_DisplaySourceRanges = 0x04, + + /** + * \brief Display the option name associated with this diagnostic, if any. + * + * The option name displayed (e.g., -Wconversion) will be placed in brackets + * after the diagnostic text. This option corresponds to the clang flag + * \c -fdiagnostics-show-option. + */ + CXDiagnostic_DisplayOption = 0x08, + + /** + * \brief Display the category number associated with this diagnostic, if any. + * + * The category number is displayed within brackets after the diagnostic text. + * This option corresponds to the clang flag + * \c -fdiagnostics-show-category=id. + */ + CXDiagnostic_DisplayCategoryId = 0x10, + + /** + * \brief Display the category name associated with this diagnostic, if any. + * + * The category name is displayed within brackets after the diagnostic text. + * This option corresponds to the clang flag + * \c -fdiagnostics-show-category=name. + */ + CXDiagnostic_DisplayCategoryName = 0x20 +}; + +/** + * \brief Format the given diagnostic in a manner that is suitable for display. + * + * This routine will format the given diagnostic to a string, rendering + * the diagnostic according to the various options given. The + * \c clang_defaultDiagnosticDisplayOptions() function returns the set of + * options that most closely mimics the behavior of the clang compiler. + * + * \param Diagnostic The diagnostic to print. + * + * \param Options A set of options that control the diagnostic display, + * created by combining \c CXDiagnosticDisplayOptions values. + * + * \returns A new string containing for formatted diagnostic. + */ +CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, + unsigned Options); + +/** + * \brief Retrieve the set of display options most similar to the + * default behavior of the clang compiler. + * + * \returns A set of display options suitable for use with \c + * clang_formatDiagnostic(). + */ +CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); + +/** + * \brief Determine the severity of the given diagnostic. + */ +CINDEX_LINKAGE enum CXDiagnosticSeverity +clang_getDiagnosticSeverity(CXDiagnostic); + +/** + * \brief Retrieve the source location of the given diagnostic. + * + * This location is where Clang would print the caret ('^') when + * displaying the diagnostic on the command line. + */ +CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); + +/** + * \brief Retrieve the text of the given diagnostic. + */ +CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); + +/** + * \brief Retrieve the name of the command-line option that enabled this + * diagnostic. + * + * \param Diag The diagnostic to be queried. + * + * \param Disable If non-NULL, will be set to the option that disables this + * diagnostic (if any). + * + * \returns A string that contains the command-line option used to enable this + * warning, such as "-Wconversion" or "-pedantic". + */ +CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, + CXString *Disable); + +/** + * \brief Retrieve the category number for this diagnostic. + * + * Diagnostics can be categorized into groups along with other, related + * diagnostics (e.g., diagnostics under the same warning flag). This routine + * retrieves the category number for the given diagnostic. + * + * \returns The number of the category that contains this diagnostic, or zero + * if this diagnostic is uncategorized. + */ +CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); + +/** + * \brief Retrieve the name of a particular diagnostic category. This + * is now deprecated. Use clang_getDiagnosticCategoryText() + * instead. + * + * \param Category A diagnostic category number, as returned by + * \c clang_getDiagnosticCategory(). + * + * \returns The name of the given diagnostic category. + */ +CINDEX_DEPRECATED CINDEX_LINKAGE +CXString clang_getDiagnosticCategoryName(unsigned Category); + +/** + * \brief Retrieve the diagnostic category text for a given diagnostic. + * + * \returns The text of the given diagnostic category. + */ +CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); + +/** + * \brief Determine the number of source ranges associated with the given + * diagnostic. + */ +CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); + +/** + * \brief Retrieve a source range associated with the diagnostic. + * + * A diagnostic's source ranges highlight important elements in the source + * code. On the command line, Clang displays source ranges by + * underlining them with '~' characters. + * + * \param Diagnostic the diagnostic whose range is being extracted. + * + * \param Range the zero-based index specifying which range to + * + * \returns the requested source range. + */ +CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, + unsigned Range); + +/** + * \brief Determine the number of fix-it hints associated with the + * given diagnostic. + */ +CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); + +/** + * \brief Retrieve the replacement information for a given fix-it. + * + * Fix-its are described in terms of a source range whose contents + * should be replaced by a string. This approach generalizes over + * three kinds of operations: removal of source code (the range covers + * the code to be removed and the replacement string is empty), + * replacement of source code (the range covers the code to be + * replaced and the replacement string provides the new code), and + * insertion (both the start and end of the range point at the + * insertion location, and the replacement string provides the text to + * insert). + * + * \param Diagnostic The diagnostic whose fix-its are being queried. + * + * \param FixIt The zero-based index of the fix-it. + * + * \param ReplacementRange The source range whose contents will be + * replaced with the returned replacement string. Note that source + * ranges are half-open ranges [a, b), so the source code should be + * replaced from a and up to (but not including) b. + * + * \returns A string containing text that should be replace the source + * code indicated by the \c ReplacementRange. + */ +CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, + unsigned FixIt, + CXSourceRange *ReplacementRange); + +/** + * @} + */ + +/** + * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation + * + * The routines in this group provide the ability to create and destroy + * translation units from files, either by parsing the contents of the files or + * by reading in a serialized representation of a translation unit. + * + * @{ + */ + +/** + * \brief Get the original translation unit source file name. + */ +CINDEX_LINKAGE CXString +clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); + +/** + * \brief Return the CXTranslationUnit for a given source file and the provided + * command line arguments one would pass to the compiler. + * + * Note: The 'source_filename' argument is optional. If the caller provides a + * NULL pointer, the name of the source file is expected to reside in the + * specified command line arguments. + * + * Note: When encountered in 'clang_command_line_args', the following options + * are ignored: + * + * '-c' + * '-emit-ast' + * '-fsyntax-only' + * '-o \' (both '-o' and '\' are ignored) + * + * \param CIdx The index object with which the translation unit will be + * associated. + * + * \param source_filename The name of the source file to load, or NULL if the + * source file is included in \p clang_command_line_args. + * + * \param num_clang_command_line_args The number of command-line arguments in + * \p clang_command_line_args. + * + * \param clang_command_line_args The command-line arguments that would be + * passed to the \c clang executable if it were being invoked out-of-process. + * These command-line options will be parsed and will affect how the translation + * unit is parsed. Note that the following options are ignored: '-c', + * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. + * + * \param num_unsaved_files the number of unsaved file entries in \p + * unsaved_files. + * + * \param unsaved_files the files that have not yet been saved to disk + * but may be required for code completion, including the contents of + * those files. The contents and name of these files (as specified by + * CXUnsavedFile) are copied when necessary, so the client only needs to + * guarantee their validity until the call to this function returns. + */ +CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( + CXIndex CIdx, + const char *source_filename, + int num_clang_command_line_args, + const char * const *clang_command_line_args, + unsigned num_unsaved_files, + struct CXUnsavedFile *unsaved_files); + +/** + * \brief Same as \c clang_createTranslationUnit2, but returns + * the \c CXTranslationUnit instead of an error code. In case of an error this + * routine returns a \c NULL \c CXTranslationUnit, without further detailed + * error codes. + */ +CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit( + CXIndex CIdx, + const char *ast_filename); + +/** + * \brief Create a translation unit from an AST file (\c -emit-ast). + * + * \param[out] out_TU A non-NULL pointer to store the created + * \c CXTranslationUnit. + * + * \returns Zero on success, otherwise returns an error code. + */ +CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2( + CXIndex CIdx, + const char *ast_filename, + CXTranslationUnit *out_TU); + +/** + * \brief Flags that control the creation of translation units. + * + * The enumerators in this enumeration type are meant to be bitwise + * ORed together to specify which options should be used when + * constructing the translation unit. + */ +enum CXTranslationUnit_Flags { + /** + * \brief Used to indicate that no special translation-unit options are + * needed. + */ + CXTranslationUnit_None = 0x0, + + /** + * \brief Used to indicate that the parser should construct a "detailed" + * preprocessing record, including all macro definitions and instantiations. + * + * Constructing a detailed preprocessing record requires more memory + * and time to parse, since the information contained in the record + * is usually not retained. However, it can be useful for + * applications that require more detailed information about the + * behavior of the preprocessor. + */ + CXTranslationUnit_DetailedPreprocessingRecord = 0x01, + + /** + * \brief Used to indicate that the translation unit is incomplete. + * + * When a translation unit is considered "incomplete", semantic + * analysis that is typically performed at the end of the + * translation unit will be suppressed. For example, this suppresses + * the completion of tentative declarations in C and of + * instantiation of implicitly-instantiation function templates in + * C++. This option is typically used when parsing a header with the + * intent of producing a precompiled header. + */ + CXTranslationUnit_Incomplete = 0x02, + + /** + * \brief Used to indicate that the translation unit should be built with an + * implicit precompiled header for the preamble. + * + * An implicit precompiled header is used as an optimization when a + * particular translation unit is likely to be reparsed many times + * when the sources aren't changing that often. In this case, an + * implicit precompiled header will be built containing all of the + * initial includes at the top of the main file (what we refer to as + * the "preamble" of the file). In subsequent parses, if the + * preamble or the files in it have not changed, \c + * clang_reparseTranslationUnit() will re-use the implicit + * precompiled header to improve parsing performance. + */ + CXTranslationUnit_PrecompiledPreamble = 0x04, + + /** + * \brief Used to indicate that the translation unit should cache some + * code-completion results with each reparse of the source file. + * + * Caching of code-completion results is a performance optimization that + * introduces some overhead to reparsing but improves the performance of + * code-completion operations. + */ + CXTranslationUnit_CacheCompletionResults = 0x08, + + /** + * \brief Used to indicate that the translation unit will be serialized with + * \c clang_saveTranslationUnit. + * + * This option is typically used when parsing a header with the intent of + * producing a precompiled header. + */ + CXTranslationUnit_ForSerialization = 0x10, + + /** + * \brief DEPRECATED: Enabled chained precompiled preambles in C++. + * + * Note: this is a *temporary* option that is available only while + * we are testing C++ precompiled preamble support. It is deprecated. + */ + CXTranslationUnit_CXXChainedPCH = 0x20, + + /** + * \brief Used to indicate that function/method bodies should be skipped while + * parsing. + * + * This option can be used to search for declarations/definitions while + * ignoring the usages. + */ + CXTranslationUnit_SkipFunctionBodies = 0x40, + + /** + * \brief Used to indicate that brief documentation comments should be + * included into the set of code completions returned from this translation + * unit. + */ + CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, + + /** + * \brief Used to indicate that the precompiled preamble should be created on + * the first parse. Otherwise it will be created on the first reparse. This + * trades runtime on the first parse (serializing the preamble takes time) for + * reduced runtime on the second parse (can now reuse the preamble). + */ + CXTranslationUnit_CreatePreambleOnFirstParse = 0x100 +}; + +/** + * \brief Returns the set of flags that is suitable for parsing a translation + * unit that is being edited. + * + * The set of flags returned provide options for \c clang_parseTranslationUnit() + * to indicate that the translation unit is likely to be reparsed many times, + * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly + * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag + * set contains an unspecified set of optimizations (e.g., the precompiled + * preamble) geared toward improving the performance of these routines. The + * set of optimizations enabled may change from one version to the next. + */ +CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); + +/** + * \brief Same as \c clang_parseTranslationUnit2, but returns + * the \c CXTranslationUnit instead of an error code. In case of an error this + * routine returns a \c NULL \c CXTranslationUnit, without further detailed + * error codes. + */ +CINDEX_LINKAGE CXTranslationUnit +clang_parseTranslationUnit(CXIndex CIdx, + const char *source_filename, + const char *const *command_line_args, + int num_command_line_args, + struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, + unsigned options); + +/** + * \brief Parse the given source file and the translation unit corresponding + * to that file. + * + * This routine is the main entry point for the Clang C API, providing the + * ability to parse a source file into a translation unit that can then be + * queried by other functions in the API. This routine accepts a set of + * command-line arguments so that the compilation can be configured in the same + * way that the compiler is configured on the command line. + * + * \param CIdx The index object with which the translation unit will be + * associated. + * + * \param source_filename The name of the source file to load, or NULL if the + * source file is included in \c command_line_args. + * + * \param command_line_args The command-line arguments that would be + * passed to the \c clang executable if it were being invoked out-of-process. + * These command-line options will be parsed and will affect how the translation + * unit is parsed. Note that the following options are ignored: '-c', + * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. + * + * \param num_command_line_args The number of command-line arguments in + * \c command_line_args. + * + * \param unsaved_files the files that have not yet been saved to disk + * but may be required for parsing, including the contents of + * those files. The contents and name of these files (as specified by + * CXUnsavedFile) are copied when necessary, so the client only needs to + * guarantee their validity until the call to this function returns. + * + * \param num_unsaved_files the number of unsaved file entries in \p + * unsaved_files. + * + * \param options A bitmask of options that affects how the translation unit + * is managed but not its compilation. This should be a bitwise OR of the + * CXTranslationUnit_XXX flags. + * + * \param[out] out_TU A non-NULL pointer to store the created + * \c CXTranslationUnit, describing the parsed code and containing any + * diagnostics produced by the compiler. + * + * \returns Zero on success, otherwise returns an error code. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_parseTranslationUnit2(CXIndex CIdx, + const char *source_filename, + const char *const *command_line_args, + int num_command_line_args, + struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, + unsigned options, + CXTranslationUnit *out_TU); + +/** + * \brief Same as clang_parseTranslationUnit2 but requires a full command line + * for \c command_line_args including argv[0]. This is useful if the standard + * library paths are relative to the binary. + */ +CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv( + CXIndex CIdx, const char *source_filename, + const char *const *command_line_args, int num_command_line_args, + struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, + unsigned options, CXTranslationUnit *out_TU); + +/** + * \brief Flags that control how translation units are saved. + * + * The enumerators in this enumeration type are meant to be bitwise + * ORed together to specify which options should be used when + * saving the translation unit. + */ +enum CXSaveTranslationUnit_Flags { + /** + * \brief Used to indicate that no special saving options are needed. + */ + CXSaveTranslationUnit_None = 0x0 +}; + +/** + * \brief Returns the set of flags that is suitable for saving a translation + * unit. + * + * The set of flags returned provide options for + * \c clang_saveTranslationUnit() by default. The returned flag + * set contains an unspecified set of options that save translation units with + * the most commonly-requested data. + */ +CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); + +/** + * \brief Describes the kind of error that occurred (if any) in a call to + * \c clang_saveTranslationUnit(). + */ +enum CXSaveError { + /** + * \brief Indicates that no error occurred while saving a translation unit. + */ + CXSaveError_None = 0, + + /** + * \brief Indicates that an unknown error occurred while attempting to save + * the file. + * + * This error typically indicates that file I/O failed when attempting to + * write the file. + */ + CXSaveError_Unknown = 1, + + /** + * \brief Indicates that errors during translation prevented this attempt + * to save the translation unit. + * + * Errors that prevent the translation unit from being saved can be + * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). + */ + CXSaveError_TranslationErrors = 2, + + /** + * \brief Indicates that the translation unit to be saved was somehow + * invalid (e.g., NULL). + */ + CXSaveError_InvalidTU = 3 +}; + +/** + * \brief Saves a translation unit into a serialized representation of + * that translation unit on disk. + * + * Any translation unit that was parsed without error can be saved + * into a file. The translation unit can then be deserialized into a + * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, + * if it is an incomplete translation unit that corresponds to a + * header, used as a precompiled header when parsing other translation + * units. + * + * \param TU The translation unit to save. + * + * \param FileName The file to which the translation unit will be saved. + * + * \param options A bitmask of options that affects how the translation unit + * is saved. This should be a bitwise OR of the + * CXSaveTranslationUnit_XXX flags. + * + * \returns A value that will match one of the enumerators of the CXSaveError + * enumeration. Zero (CXSaveError_None) indicates that the translation unit was + * saved successfully, while a non-zero value indicates that a problem occurred. + */ +CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, + const char *FileName, + unsigned options); + +/** + * \brief Destroy the specified CXTranslationUnit object. + */ +CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); + +/** + * \brief Flags that control the reparsing of translation units. + * + * The enumerators in this enumeration type are meant to be bitwise + * ORed together to specify which options should be used when + * reparsing the translation unit. + */ +enum CXReparse_Flags { + /** + * \brief Used to indicate that no special reparsing options are needed. + */ + CXReparse_None = 0x0 +}; + +/** + * \brief Returns the set of flags that is suitable for reparsing a translation + * unit. + * + * The set of flags returned provide options for + * \c clang_reparseTranslationUnit() by default. The returned flag + * set contains an unspecified set of optimizations geared toward common uses + * of reparsing. The set of optimizations enabled may change from one version + * to the next. + */ +CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); + +/** + * \brief Reparse the source files that produced this translation unit. + * + * This routine can be used to re-parse the source files that originally + * created the given translation unit, for example because those source files + * have changed (either on disk or as passed via \p unsaved_files). The + * source code will be reparsed with the same command-line options as it + * was originally parsed. + * + * Reparsing a translation unit invalidates all cursors and source locations + * that refer into that translation unit. This makes reparsing a translation + * unit semantically equivalent to destroying the translation unit and then + * creating a new translation unit with the same command-line arguments. + * However, it may be more efficient to reparse a translation + * unit using this routine. + * + * \param TU The translation unit whose contents will be re-parsed. The + * translation unit must originally have been built with + * \c clang_createTranslationUnitFromSourceFile(). + * + * \param num_unsaved_files The number of unsaved file entries in \p + * unsaved_files. + * + * \param unsaved_files The files that have not yet been saved to disk + * but may be required for parsing, including the contents of + * those files. The contents and name of these files (as specified by + * CXUnsavedFile) are copied when necessary, so the client only needs to + * guarantee their validity until the call to this function returns. + * + * \param options A bitset of options composed of the flags in CXReparse_Flags. + * The function \c clang_defaultReparseOptions() produces a default set of + * options recommended for most uses, based on the translation unit. + * + * \returns 0 if the sources could be reparsed. A non-zero error code will be + * returned if reparsing was impossible, such that the translation unit is + * invalid. In such cases, the only valid call for \c TU is + * \c clang_disposeTranslationUnit(TU). The error codes returned by this + * routine are described by the \c CXErrorCode enum. + */ +CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU, + unsigned num_unsaved_files, + struct CXUnsavedFile *unsaved_files, + unsigned options); + +/** + * \brief Categorizes how memory is being used by a translation unit. + */ +enum CXTUResourceUsageKind { + CXTUResourceUsage_AST = 1, + CXTUResourceUsage_Identifiers = 2, + CXTUResourceUsage_Selectors = 3, + CXTUResourceUsage_GlobalCompletionResults = 4, + CXTUResourceUsage_SourceManagerContentCache = 5, + CXTUResourceUsage_AST_SideTables = 6, + CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, + CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, + CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, + CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, + CXTUResourceUsage_Preprocessor = 11, + CXTUResourceUsage_PreprocessingRecord = 12, + CXTUResourceUsage_SourceManager_DataStructures = 13, + CXTUResourceUsage_Preprocessor_HeaderSearch = 14, + CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, + CXTUResourceUsage_MEMORY_IN_BYTES_END = + CXTUResourceUsage_Preprocessor_HeaderSearch, + + CXTUResourceUsage_First = CXTUResourceUsage_AST, + CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch +}; + +/** + * \brief Returns the human-readable null-terminated C string that represents + * the name of the memory category. This string should never be freed. + */ +CINDEX_LINKAGE +const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); + +typedef struct CXTUResourceUsageEntry { + /* \brief The memory usage category. */ + enum CXTUResourceUsageKind kind; + /* \brief Amount of resources used. + The units will depend on the resource kind. */ + unsigned long amount; +} CXTUResourceUsageEntry; + +/** + * \brief The memory usage of a CXTranslationUnit, broken into categories. + */ +typedef struct CXTUResourceUsage { + /* \brief Private data member, used for queries. */ + void *data; + + /* \brief The number of entries in the 'entries' array. */ + unsigned numEntries; + + /* \brief An array of key-value pairs, representing the breakdown of memory + usage. */ + CXTUResourceUsageEntry *entries; + +} CXTUResourceUsage; + +/** + * \brief Return the memory usage of a translation unit. This object + * should be released with clang_disposeCXTUResourceUsage(). + */ +CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU); + +CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); + +/** + * @} + */ + +/** + * \brief Describes the kind of entity that a cursor refers to. + */ +enum CXCursorKind { + /* Declarations */ + /** + * \brief A declaration whose specific kind is not exposed via this + * interface. + * + * Unexposed declarations have the same operations as any other kind + * of declaration; one can extract their location information, + * spelling, find their definitions, etc. However, the specific kind + * of the declaration is not reported. + */ + CXCursor_UnexposedDecl = 1, + /** \brief A C or C++ struct. */ + CXCursor_StructDecl = 2, + /** \brief A C or C++ union. */ + CXCursor_UnionDecl = 3, + /** \brief A C++ class. */ + CXCursor_ClassDecl = 4, + /** \brief An enumeration. */ + CXCursor_EnumDecl = 5, + /** + * \brief A field (in C) or non-static data member (in C++) in a + * struct, union, or C++ class. + */ + CXCursor_FieldDecl = 6, + /** \brief An enumerator constant. */ + CXCursor_EnumConstantDecl = 7, + /** \brief A function. */ + CXCursor_FunctionDecl = 8, + /** \brief A variable. */ + CXCursor_VarDecl = 9, + /** \brief A function or method parameter. */ + CXCursor_ParmDecl = 10, + /** \brief An Objective-C \@interface. */ + CXCursor_ObjCInterfaceDecl = 11, + /** \brief An Objective-C \@interface for a category. */ + CXCursor_ObjCCategoryDecl = 12, + /** \brief An Objective-C \@protocol declaration. */ + CXCursor_ObjCProtocolDecl = 13, + /** \brief An Objective-C \@property declaration. */ + CXCursor_ObjCPropertyDecl = 14, + /** \brief An Objective-C instance variable. */ + CXCursor_ObjCIvarDecl = 15, + /** \brief An Objective-C instance method. */ + CXCursor_ObjCInstanceMethodDecl = 16, + /** \brief An Objective-C class method. */ + CXCursor_ObjCClassMethodDecl = 17, + /** \brief An Objective-C \@implementation. */ + CXCursor_ObjCImplementationDecl = 18, + /** \brief An Objective-C \@implementation for a category. */ + CXCursor_ObjCCategoryImplDecl = 19, + /** \brief A typedef. */ + CXCursor_TypedefDecl = 20, + /** \brief A C++ class method. */ + CXCursor_CXXMethod = 21, + /** \brief A C++ namespace. */ + CXCursor_Namespace = 22, + /** \brief A linkage specification, e.g. 'extern "C"'. */ + CXCursor_LinkageSpec = 23, + /** \brief A C++ constructor. */ + CXCursor_Constructor = 24, + /** \brief A C++ destructor. */ + CXCursor_Destructor = 25, + /** \brief A C++ conversion function. */ + CXCursor_ConversionFunction = 26, + /** \brief A C++ template type parameter. */ + CXCursor_TemplateTypeParameter = 27, + /** \brief A C++ non-type template parameter. */ + CXCursor_NonTypeTemplateParameter = 28, + /** \brief A C++ template template parameter. */ + CXCursor_TemplateTemplateParameter = 29, + /** \brief A C++ function template. */ + CXCursor_FunctionTemplate = 30, + /** \brief A C++ class template. */ + CXCursor_ClassTemplate = 31, + /** \brief A C++ class template partial specialization. */ + CXCursor_ClassTemplatePartialSpecialization = 32, + /** \brief A C++ namespace alias declaration. */ + CXCursor_NamespaceAlias = 33, + /** \brief A C++ using directive. */ + CXCursor_UsingDirective = 34, + /** \brief A C++ using declaration. */ + CXCursor_UsingDeclaration = 35, + /** \brief A C++ alias declaration */ + CXCursor_TypeAliasDecl = 36, + /** \brief An Objective-C \@synthesize definition. */ + CXCursor_ObjCSynthesizeDecl = 37, + /** \brief An Objective-C \@dynamic definition. */ + CXCursor_ObjCDynamicDecl = 38, + /** \brief An access specifier. */ + CXCursor_CXXAccessSpecifier = 39, + + CXCursor_FirstDecl = CXCursor_UnexposedDecl, + CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, + + /* References */ + CXCursor_FirstRef = 40, /* Decl references */ + CXCursor_ObjCSuperClassRef = 40, + CXCursor_ObjCProtocolRef = 41, + CXCursor_ObjCClassRef = 42, + /** + * \brief A reference to a type declaration. + * + * A type reference occurs anywhere where a type is named but not + * declared. For example, given: + * + * \code + * typedef unsigned size_type; + * size_type size; + * \endcode + * + * The typedef is a declaration of size_type (CXCursor_TypedefDecl), + * while the type of the variable "size" is referenced. The cursor + * referenced by the type of size is the typedef for size_type. + */ + CXCursor_TypeRef = 43, + CXCursor_CXXBaseSpecifier = 44, + /** + * \brief A reference to a class template, function template, template + * template parameter, or class template partial specialization. + */ + CXCursor_TemplateRef = 45, + /** + * \brief A reference to a namespace or namespace alias. + */ + CXCursor_NamespaceRef = 46, + /** + * \brief A reference to a member of a struct, union, or class that occurs in + * some non-expression context, e.g., a designated initializer. + */ + CXCursor_MemberRef = 47, + /** + * \brief A reference to a labeled statement. + * + * This cursor kind is used to describe the jump to "start_over" in the + * goto statement in the following example: + * + * \code + * start_over: + * ++counter; + * + * goto start_over; + * \endcode + * + * A label reference cursor refers to a label statement. + */ + CXCursor_LabelRef = 48, + + /** + * \brief A reference to a set of overloaded functions or function templates + * that has not yet been resolved to a specific function or function template. + * + * An overloaded declaration reference cursor occurs in C++ templates where + * a dependent name refers to a function. For example: + * + * \code + * template void swap(T&, T&); + * + * struct X { ... }; + * void swap(X&, X&); + * + * template + * void reverse(T* first, T* last) { + * while (first < last - 1) { + * swap(*first, *--last); + * ++first; + * } + * } + * + * struct Y { }; + * void swap(Y&, Y&); + * \endcode + * + * Here, the identifier "swap" is associated with an overloaded declaration + * reference. In the template definition, "swap" refers to either of the two + * "swap" functions declared above, so both results will be available. At + * instantiation time, "swap" may also refer to other functions found via + * argument-dependent lookup (e.g., the "swap" function at the end of the + * example). + * + * The functions \c clang_getNumOverloadedDecls() and + * \c clang_getOverloadedDecl() can be used to retrieve the definitions + * referenced by this cursor. + */ + CXCursor_OverloadedDeclRef = 49, + + /** + * \brief A reference to a variable that occurs in some non-expression + * context, e.g., a C++ lambda capture list. + */ + CXCursor_VariableRef = 50, + + CXCursor_LastRef = CXCursor_VariableRef, + + /* Error conditions */ + CXCursor_FirstInvalid = 70, + CXCursor_InvalidFile = 70, + CXCursor_NoDeclFound = 71, + CXCursor_NotImplemented = 72, + CXCursor_InvalidCode = 73, + CXCursor_LastInvalid = CXCursor_InvalidCode, + + /* Expressions */ + CXCursor_FirstExpr = 100, + + /** + * \brief An expression whose specific kind is not exposed via this + * interface. + * + * Unexposed expressions have the same operations as any other kind + * of expression; one can extract their location information, + * spelling, children, etc. However, the specific kind of the + * expression is not reported. + */ + CXCursor_UnexposedExpr = 100, + + /** + * \brief An expression that refers to some value declaration, such + * as a function, variable, or enumerator. + */ + CXCursor_DeclRefExpr = 101, + + /** + * \brief An expression that refers to a member of a struct, union, + * class, Objective-C class, etc. + */ + CXCursor_MemberRefExpr = 102, + + /** \brief An expression that calls a function. */ + CXCursor_CallExpr = 103, + + /** \brief An expression that sends a message to an Objective-C + object or class. */ + CXCursor_ObjCMessageExpr = 104, + + /** \brief An expression that represents a block literal. */ + CXCursor_BlockExpr = 105, + + /** \brief An integer literal. + */ + CXCursor_IntegerLiteral = 106, + + /** \brief A floating point number literal. + */ + CXCursor_FloatingLiteral = 107, + + /** \brief An imaginary number literal. + */ + CXCursor_ImaginaryLiteral = 108, + + /** \brief A string literal. + */ + CXCursor_StringLiteral = 109, + + /** \brief A character literal. + */ + CXCursor_CharacterLiteral = 110, + + /** \brief A parenthesized expression, e.g. "(1)". + * + * This AST node is only formed if full location information is requested. + */ + CXCursor_ParenExpr = 111, + + /** \brief This represents the unary-expression's (except sizeof and + * alignof). + */ + CXCursor_UnaryOperator = 112, + + /** \brief [C99 6.5.2.1] Array Subscripting. + */ + CXCursor_ArraySubscriptExpr = 113, + + /** \brief A builtin binary operation expression such as "x + y" or + * "x <= y". + */ + CXCursor_BinaryOperator = 114, + + /** \brief Compound assignment such as "+=". + */ + CXCursor_CompoundAssignOperator = 115, + + /** \brief The ?: ternary operator. + */ + CXCursor_ConditionalOperator = 116, + + /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++ + * (C++ [expr.cast]), which uses the syntax (Type)expr. + * + * For example: (int)f. + */ + CXCursor_CStyleCastExpr = 117, + + /** \brief [C99 6.5.2.5] + */ + CXCursor_CompoundLiteralExpr = 118, + + /** \brief Describes an C or C++ initializer list. + */ + CXCursor_InitListExpr = 119, + + /** \brief The GNU address of label extension, representing &&label. + */ + CXCursor_AddrLabelExpr = 120, + + /** \brief This is the GNU Statement Expression extension: ({int X=4; X;}) + */ + CXCursor_StmtExpr = 121, + + /** \brief Represents a C11 generic selection. + */ + CXCursor_GenericSelectionExpr = 122, + + /** \brief Implements the GNU __null extension, which is a name for a null + * pointer constant that has integral type (e.g., int or long) and is the same + * size and alignment as a pointer. + * + * The __null extension is typically only used by system headers, which define + * NULL as __null in C++ rather than using 0 (which is an integer that may not + * match the size of a pointer). + */ + CXCursor_GNUNullExpr = 123, + + /** \brief C++'s static_cast<> expression. + */ + CXCursor_CXXStaticCastExpr = 124, + + /** \brief C++'s dynamic_cast<> expression. + */ + CXCursor_CXXDynamicCastExpr = 125, + + /** \brief C++'s reinterpret_cast<> expression. + */ + CXCursor_CXXReinterpretCastExpr = 126, + + /** \brief C++'s const_cast<> expression. + */ + CXCursor_CXXConstCastExpr = 127, + + /** \brief Represents an explicit C++ type conversion that uses "functional" + * notion (C++ [expr.type.conv]). + * + * Example: + * \code + * x = int(0.5); + * \endcode + */ + CXCursor_CXXFunctionalCastExpr = 128, + + /** \brief A C++ typeid expression (C++ [expr.typeid]). + */ + CXCursor_CXXTypeidExpr = 129, + + /** \brief [C++ 2.13.5] C++ Boolean Literal. + */ + CXCursor_CXXBoolLiteralExpr = 130, + + /** \brief [C++0x 2.14.7] C++ Pointer Literal. + */ + CXCursor_CXXNullPtrLiteralExpr = 131, + + /** \brief Represents the "this" expression in C++ + */ + CXCursor_CXXThisExpr = 132, + + /** \brief [C++ 15] C++ Throw Expression. + * + * This handles 'throw' and 'throw' assignment-expression. When + * assignment-expression isn't present, Op will be null. + */ + CXCursor_CXXThrowExpr = 133, + + /** \brief A new expression for memory allocation and constructor calls, e.g: + * "new CXXNewExpr(foo)". + */ + CXCursor_CXXNewExpr = 134, + + /** \brief A delete expression for memory deallocation and destructor calls, + * e.g. "delete[] pArray". + */ + CXCursor_CXXDeleteExpr = 135, + + /** \brief A unary expression. + */ + CXCursor_UnaryExpr = 136, + + /** \brief An Objective-C string literal i.e. @"foo". + */ + CXCursor_ObjCStringLiteral = 137, + + /** \brief An Objective-C \@encode expression. + */ + CXCursor_ObjCEncodeExpr = 138, + + /** \brief An Objective-C \@selector expression. + */ + CXCursor_ObjCSelectorExpr = 139, + + /** \brief An Objective-C \@protocol expression. + */ + CXCursor_ObjCProtocolExpr = 140, + + /** \brief An Objective-C "bridged" cast expression, which casts between + * Objective-C pointers and C pointers, transferring ownership in the process. + * + * \code + * NSString *str = (__bridge_transfer NSString *)CFCreateString(); + * \endcode + */ + CXCursor_ObjCBridgedCastExpr = 141, + + /** \brief Represents a C++0x pack expansion that produces a sequence of + * expressions. + * + * A pack expansion expression contains a pattern (which itself is an + * expression) followed by an ellipsis. For example: + * + * \code + * template + * void forward(F f, Types &&...args) { + * f(static_cast(args)...); + * } + * \endcode + */ + CXCursor_PackExpansionExpr = 142, + + /** \brief Represents an expression that computes the length of a parameter + * pack. + * + * \code + * template + * struct count { + * static const unsigned value = sizeof...(Types); + * }; + * \endcode + */ + CXCursor_SizeOfPackExpr = 143, + + /* \brief Represents a C++ lambda expression that produces a local function + * object. + * + * \code + * void abssort(float *x, unsigned N) { + * std::sort(x, x + N, + * [](float a, float b) { + * return std::abs(a) < std::abs(b); + * }); + * } + * \endcode + */ + CXCursor_LambdaExpr = 144, + + /** \brief Objective-c Boolean Literal. + */ + CXCursor_ObjCBoolLiteralExpr = 145, + + /** \brief Represents the "self" expression in an Objective-C method. + */ + CXCursor_ObjCSelfExpr = 146, + + /** \brief OpenMP 4.0 [2.4, Array Section]. + */ + CXCursor_OMPArraySectionExpr = 147, + + CXCursor_LastExpr = CXCursor_OMPArraySectionExpr, + + /* Statements */ + CXCursor_FirstStmt = 200, + /** + * \brief A statement whose specific kind is not exposed via this + * interface. + * + * Unexposed statements have the same operations as any other kind of + * statement; one can extract their location information, spelling, + * children, etc. However, the specific kind of the statement is not + * reported. + */ + CXCursor_UnexposedStmt = 200, + + /** \brief A labelled statement in a function. + * + * This cursor kind is used to describe the "start_over:" label statement in + * the following example: + * + * \code + * start_over: + * ++counter; + * \endcode + * + */ + CXCursor_LabelStmt = 201, + + /** \brief A group of statements like { stmt stmt }. + * + * This cursor kind is used to describe compound statements, e.g. function + * bodies. + */ + CXCursor_CompoundStmt = 202, + + /** \brief A case statement. + */ + CXCursor_CaseStmt = 203, + + /** \brief A default statement. + */ + CXCursor_DefaultStmt = 204, + + /** \brief An if statement + */ + CXCursor_IfStmt = 205, + + /** \brief A switch statement. + */ + CXCursor_SwitchStmt = 206, + + /** \brief A while statement. + */ + CXCursor_WhileStmt = 207, + + /** \brief A do statement. + */ + CXCursor_DoStmt = 208, + + /** \brief A for statement. + */ + CXCursor_ForStmt = 209, + + /** \brief A goto statement. + */ + CXCursor_GotoStmt = 210, + + /** \brief An indirect goto statement. + */ + CXCursor_IndirectGotoStmt = 211, + + /** \brief A continue statement. + */ + CXCursor_ContinueStmt = 212, + + /** \brief A break statement. + */ + CXCursor_BreakStmt = 213, + + /** \brief A return statement. + */ + CXCursor_ReturnStmt = 214, + + /** \brief A GCC inline assembly statement extension. + */ + CXCursor_GCCAsmStmt = 215, + CXCursor_AsmStmt = CXCursor_GCCAsmStmt, + + /** \brief Objective-C's overall \@try-\@catch-\@finally statement. + */ + CXCursor_ObjCAtTryStmt = 216, + + /** \brief Objective-C's \@catch statement. + */ + CXCursor_ObjCAtCatchStmt = 217, + + /** \brief Objective-C's \@finally statement. + */ + CXCursor_ObjCAtFinallyStmt = 218, + + /** \brief Objective-C's \@throw statement. + */ + CXCursor_ObjCAtThrowStmt = 219, + + /** \brief Objective-C's \@synchronized statement. + */ + CXCursor_ObjCAtSynchronizedStmt = 220, + + /** \brief Objective-C's autorelease pool statement. + */ + CXCursor_ObjCAutoreleasePoolStmt = 221, + + /** \brief Objective-C's collection statement. + */ + CXCursor_ObjCForCollectionStmt = 222, + + /** \brief C++'s catch statement. + */ + CXCursor_CXXCatchStmt = 223, + + /** \brief C++'s try statement. + */ + CXCursor_CXXTryStmt = 224, + + /** \brief C++'s for (* : *) statement. + */ + CXCursor_CXXForRangeStmt = 225, + + /** \brief Windows Structured Exception Handling's try statement. + */ + CXCursor_SEHTryStmt = 226, + + /** \brief Windows Structured Exception Handling's except statement. + */ + CXCursor_SEHExceptStmt = 227, + + /** \brief Windows Structured Exception Handling's finally statement. + */ + CXCursor_SEHFinallyStmt = 228, + + /** \brief A MS inline assembly statement extension. + */ + CXCursor_MSAsmStmt = 229, + + /** \brief The null statement ";": C99 6.8.3p3. + * + * This cursor kind is used to describe the null statement. + */ + CXCursor_NullStmt = 230, + + /** \brief Adaptor class for mixing declarations with statements and + * expressions. + */ + CXCursor_DeclStmt = 231, + + /** \brief OpenMP parallel directive. + */ + CXCursor_OMPParallelDirective = 232, + + /** \brief OpenMP SIMD directive. + */ + CXCursor_OMPSimdDirective = 233, + + /** \brief OpenMP for directive. + */ + CXCursor_OMPForDirective = 234, + + /** \brief OpenMP sections directive. + */ + CXCursor_OMPSectionsDirective = 235, + + /** \brief OpenMP section directive. + */ + CXCursor_OMPSectionDirective = 236, + + /** \brief OpenMP single directive. + */ + CXCursor_OMPSingleDirective = 237, + + /** \brief OpenMP parallel for directive. + */ + CXCursor_OMPParallelForDirective = 238, + + /** \brief OpenMP parallel sections directive. + */ + CXCursor_OMPParallelSectionsDirective = 239, + + /** \brief OpenMP task directive. + */ + CXCursor_OMPTaskDirective = 240, + + /** \brief OpenMP master directive. + */ + CXCursor_OMPMasterDirective = 241, + + /** \brief OpenMP critical directive. + */ + CXCursor_OMPCriticalDirective = 242, + + /** \brief OpenMP taskyield directive. + */ + CXCursor_OMPTaskyieldDirective = 243, + + /** \brief OpenMP barrier directive. + */ + CXCursor_OMPBarrierDirective = 244, + + /** \brief OpenMP taskwait directive. + */ + CXCursor_OMPTaskwaitDirective = 245, + + /** \brief OpenMP flush directive. + */ + CXCursor_OMPFlushDirective = 246, + + /** \brief Windows Structured Exception Handling's leave statement. + */ + CXCursor_SEHLeaveStmt = 247, + + /** \brief OpenMP ordered directive. + */ + CXCursor_OMPOrderedDirective = 248, + + /** \brief OpenMP atomic directive. + */ + CXCursor_OMPAtomicDirective = 249, + + /** \brief OpenMP for SIMD directive. + */ + CXCursor_OMPForSimdDirective = 250, + + /** \brief OpenMP parallel for SIMD directive. + */ + CXCursor_OMPParallelForSimdDirective = 251, + + /** \brief OpenMP target directive. + */ + CXCursor_OMPTargetDirective = 252, + + /** \brief OpenMP teams directive. + */ + CXCursor_OMPTeamsDirective = 253, + + /** \brief OpenMP taskgroup directive. + */ + CXCursor_OMPTaskgroupDirective = 254, + + /** \brief OpenMP cancellation point directive. + */ + CXCursor_OMPCancellationPointDirective = 255, + + /** \brief OpenMP cancel directive. + */ + CXCursor_OMPCancelDirective = 256, + + /** \brief OpenMP target data directive. + */ + CXCursor_OMPTargetDataDirective = 257, + + /** \brief OpenMP taskloop directive. + */ + CXCursor_OMPTaskLoopDirective = 258, + + /** \brief OpenMP taskloop simd directive. + */ + CXCursor_OMPTaskLoopSimdDirective = 259, + + /** \brief OpenMP distribute directive. + */ + CXCursor_OMPDistributeDirective = 260, + + CXCursor_LastStmt = CXCursor_OMPDistributeDirective, + + /** + * \brief Cursor that represents the translation unit itself. + * + * The translation unit cursor exists primarily to act as the root + * cursor for traversing the contents of a translation unit. + */ + CXCursor_TranslationUnit = 300, + + /* Attributes */ + CXCursor_FirstAttr = 400, + /** + * \brief An attribute whose specific kind is not exposed via this + * interface. + */ + CXCursor_UnexposedAttr = 400, + + CXCursor_IBActionAttr = 401, + CXCursor_IBOutletAttr = 402, + CXCursor_IBOutletCollectionAttr = 403, + CXCursor_CXXFinalAttr = 404, + CXCursor_CXXOverrideAttr = 405, + CXCursor_AnnotateAttr = 406, + CXCursor_AsmLabelAttr = 407, + CXCursor_PackedAttr = 408, + CXCursor_PureAttr = 409, + CXCursor_ConstAttr = 410, + CXCursor_NoDuplicateAttr = 411, + CXCursor_CUDAConstantAttr = 412, + CXCursor_CUDADeviceAttr = 413, + CXCursor_CUDAGlobalAttr = 414, + CXCursor_CUDAHostAttr = 415, + CXCursor_CUDASharedAttr = 416, + CXCursor_VisibilityAttr = 417, + CXCursor_DLLExport = 418, + CXCursor_DLLImport = 419, + CXCursor_LastAttr = CXCursor_DLLImport, + + /* Preprocessing */ + CXCursor_PreprocessingDirective = 500, + CXCursor_MacroDefinition = 501, + CXCursor_MacroExpansion = 502, + CXCursor_MacroInstantiation = CXCursor_MacroExpansion, + CXCursor_InclusionDirective = 503, + CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, + CXCursor_LastPreprocessing = CXCursor_InclusionDirective, + + /* Extra Declarations */ + /** + * \brief A module import declaration. + */ + CXCursor_ModuleImportDecl = 600, + CXCursor_TypeAliasTemplateDecl = 601, + CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, + CXCursor_LastExtraDecl = CXCursor_TypeAliasTemplateDecl, + + /** + * \brief A code completion overload candidate. + */ + CXCursor_OverloadCandidate = 700 +}; + +/** + * \brief A cursor representing some element in the abstract syntax tree for + * a translation unit. + * + * The cursor abstraction unifies the different kinds of entities in a + * program--declaration, statements, expressions, references to declarations, + * etc.--under a single "cursor" abstraction with a common set of operations. + * Common operation for a cursor include: getting the physical location in + * a source file where the cursor points, getting the name associated with a + * cursor, and retrieving cursors for any child nodes of a particular cursor. + * + * Cursors can be produced in two specific ways. + * clang_getTranslationUnitCursor() produces a cursor for a translation unit, + * from which one can use clang_visitChildren() to explore the rest of the + * translation unit. clang_getCursor() maps from a physical source location + * to the entity that resides at that location, allowing one to map from the + * source code into the AST. + */ +typedef struct { + enum CXCursorKind kind; + int xdata; + const void *data[3]; +} CXCursor; + +/** + * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations + * + * @{ + */ + +/** + * \brief Retrieve the NULL cursor, which represents no entity. + */ +CINDEX_LINKAGE CXCursor clang_getNullCursor(void); + +/** + * \brief Retrieve the cursor that represents the given translation unit. + * + * The translation unit cursor can be used to start traversing the + * various declarations within the given translation unit. + */ +CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); + +/** + * \brief Determine whether two cursors are equivalent. + */ +CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); + +/** + * \brief Returns non-zero if \p cursor is null. + */ +CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); + +/** + * \brief Compute a hash value for the given cursor. + */ +CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); + +/** + * \brief Retrieve the kind of the given cursor. + */ +CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); + +/** + * \brief Determine whether the given cursor kind represents a declaration. + */ +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); + +/** + * \brief Determine whether the given cursor kind represents a simple + * reference. + * + * Note that other kinds of cursors (such as expressions) can also refer to + * other cursors. Use clang_getCursorReferenced() to determine whether a + * particular cursor refers to another entity. + */ +CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); + +/** + * \brief Determine whether the given cursor kind represents an expression. + */ +CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); + +/** + * \brief Determine whether the given cursor kind represents a statement. + */ +CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); + +/** + * \brief Determine whether the given cursor kind represents an attribute. + */ +CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); + +/** + * \brief Determine whether the given cursor kind represents an invalid + * cursor. + */ +CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); + +/** + * \brief Determine whether the given cursor kind represents a translation + * unit. + */ +CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); + +/*** + * \brief Determine whether the given cursor represents a preprocessing + * element, such as a preprocessor directive or macro instantiation. + */ +CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); + +/*** + * \brief Determine whether the given cursor represents a currently + * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). + */ +CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); + +/** + * \brief Describe the linkage of the entity referred to by a cursor. + */ +enum CXLinkageKind { + /** \brief This value indicates that no linkage information is available + * for a provided CXCursor. */ + CXLinkage_Invalid, + /** + * \brief This is the linkage for variables, parameters, and so on that + * have automatic storage. This covers normal (non-extern) local variables. + */ + CXLinkage_NoLinkage, + /** \brief This is the linkage for static variables and static functions. */ + CXLinkage_Internal, + /** \brief This is the linkage for entities with external linkage that live + * in C++ anonymous namespaces.*/ + CXLinkage_UniqueExternal, + /** \brief This is the linkage for entities with true, external linkage. */ + CXLinkage_External +}; + +/** + * \brief Determine the linkage of the entity referred to by a given cursor. + */ +CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); + +enum CXVisibilityKind { + /** \brief This value indicates that no visibility information is available + * for a provided CXCursor. */ + CXVisibility_Invalid, + + /** \brief Symbol not seen by the linker. */ + CXVisibility_Hidden, + /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */ + CXVisibility_Protected, + /** \brief Symbol seen by the linker and acts like a normal symbol. */ + CXVisibility_Default +}; + +/** + * \brief Describe the visibility of the entity referred to by a cursor. + * + * This returns the default visibility if not explicitly specified by + * a visibility attribute. The default visibility may be changed by + * commandline arguments. + * + * \param cursor The cursor to query. + * + * \returns The visibility of the cursor. + */ +CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); + +/** + * \brief Determine the availability of the entity that this cursor refers to, + * taking the current target platform into account. + * + * \param cursor The cursor to query. + * + * \returns The availability of the cursor. + */ +CINDEX_LINKAGE enum CXAvailabilityKind +clang_getCursorAvailability(CXCursor cursor); + +/** + * Describes the availability of a given entity on a particular platform, e.g., + * a particular class might only be available on Mac OS 10.7 or newer. + */ +typedef struct CXPlatformAvailability { + /** + * \brief A string that describes the platform for which this structure + * provides availability information. + * + * Possible values are "ios" or "macosx". + */ + CXString Platform; + /** + * \brief The version number in which this entity was introduced. + */ + CXVersion Introduced; + /** + * \brief The version number in which this entity was deprecated (but is + * still available). + */ + CXVersion Deprecated; + /** + * \brief The version number in which this entity was obsoleted, and therefore + * is no longer available. + */ + CXVersion Obsoleted; + /** + * \brief Whether the entity is unconditionally unavailable on this platform. + */ + int Unavailable; + /** + * \brief An optional message to provide to a user of this API, e.g., to + * suggest replacement APIs. + */ + CXString Message; +} CXPlatformAvailability; + +/** + * \brief Determine the availability of the entity that this cursor refers to + * on any platforms for which availability information is known. + * + * \param cursor The cursor to query. + * + * \param always_deprecated If non-NULL, will be set to indicate whether the + * entity is deprecated on all platforms. + * + * \param deprecated_message If non-NULL, will be set to the message text + * provided along with the unconditional deprecation of this entity. The client + * is responsible for deallocating this string. + * + * \param always_unavailable If non-NULL, will be set to indicate whether the + * entity is unavailable on all platforms. + * + * \param unavailable_message If non-NULL, will be set to the message text + * provided along with the unconditional unavailability of this entity. The + * client is responsible for deallocating this string. + * + * \param availability If non-NULL, an array of CXPlatformAvailability instances + * that will be populated with platform availability information, up to either + * the number of platforms for which availability information is available (as + * returned by this function) or \c availability_size, whichever is smaller. + * + * \param availability_size The number of elements available in the + * \c availability array. + * + * \returns The number of platforms (N) for which availability information is + * available (which is unrelated to \c availability_size). + * + * Note that the client is responsible for calling + * \c clang_disposeCXPlatformAvailability to free each of the + * platform-availability structures returned. There are + * \c min(N, availability_size) such structures. + */ +CINDEX_LINKAGE int +clang_getCursorPlatformAvailability(CXCursor cursor, + int *always_deprecated, + CXString *deprecated_message, + int *always_unavailable, + CXString *unavailable_message, + CXPlatformAvailability *availability, + int availability_size); + +/** + * \brief Free the memory associated with a \c CXPlatformAvailability structure. + */ +CINDEX_LINKAGE void +clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); + +/** + * \brief Describe the "language" of the entity referred to by a cursor. + */ +enum CXLanguageKind { + CXLanguage_Invalid = 0, + CXLanguage_C, + CXLanguage_ObjC, + CXLanguage_CPlusPlus +}; + +/** + * \brief Determine the "language" of the entity referred to by a given cursor. + */ +CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); + +/** + * \brief Returns the translation unit that a cursor originated from. + */ +CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); + +/** + * \brief A fast container representing a set of CXCursors. + */ +typedef struct CXCursorSetImpl *CXCursorSet; + +/** + * \brief Creates an empty CXCursorSet. + */ +CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void); + +/** + * \brief Disposes a CXCursorSet and releases its associated memory. + */ +CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); + +/** + * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. + * + * \returns non-zero if the set contains the specified cursor. +*/ +CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, + CXCursor cursor); + +/** + * \brief Inserts a CXCursor into a CXCursorSet. + * + * \returns zero if the CXCursor was already in the set, and non-zero otherwise. +*/ +CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, + CXCursor cursor); + +/** + * \brief Determine the semantic parent of the given cursor. + * + * The semantic parent of a cursor is the cursor that semantically contains + * the given \p cursor. For many declarations, the lexical and semantic parents + * are equivalent (the lexical parent is returned by + * \c clang_getCursorLexicalParent()). They diverge when declarations or + * definitions are provided out-of-line. For example: + * + * \code + * class C { + * void f(); + * }; + * + * void C::f() { } + * \endcode + * + * In the out-of-line definition of \c C::f, the semantic parent is + * the class \c C, of which this function is a member. The lexical parent is + * the place where the declaration actually occurs in the source code; in this + * case, the definition occurs in the translation unit. In general, the + * lexical parent for a given entity can change without affecting the semantics + * of the program, and the lexical parent of different declarations of the + * same entity may be different. Changing the semantic parent of a declaration, + * on the other hand, can have a major impact on semantics, and redeclarations + * of a particular entity should all have the same semantic context. + * + * In the example above, both declarations of \c C::f have \c C as their + * semantic context, while the lexical context of the first \c C::f is \c C + * and the lexical context of the second \c C::f is the translation unit. + * + * For global declarations, the semantic parent is the translation unit. + */ +CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); + +/** + * \brief Determine the lexical parent of the given cursor. + * + * The lexical parent of a cursor is the cursor in which the given \p cursor + * was actually written. For many declarations, the lexical and semantic parents + * are equivalent (the semantic parent is returned by + * \c clang_getCursorSemanticParent()). They diverge when declarations or + * definitions are provided out-of-line. For example: + * + * \code + * class C { + * void f(); + * }; + * + * void C::f() { } + * \endcode + * + * In the out-of-line definition of \c C::f, the semantic parent is + * the class \c C, of which this function is a member. The lexical parent is + * the place where the declaration actually occurs in the source code; in this + * case, the definition occurs in the translation unit. In general, the + * lexical parent for a given entity can change without affecting the semantics + * of the program, and the lexical parent of different declarations of the + * same entity may be different. Changing the semantic parent of a declaration, + * on the other hand, can have a major impact on semantics, and redeclarations + * of a particular entity should all have the same semantic context. + * + * In the example above, both declarations of \c C::f have \c C as their + * semantic context, while the lexical context of the first \c C::f is \c C + * and the lexical context of the second \c C::f is the translation unit. + * + * For declarations written in the global scope, the lexical parent is + * the translation unit. + */ +CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); + +/** + * \brief Determine the set of methods that are overridden by the given + * method. + * + * In both Objective-C and C++, a method (aka virtual member function, + * in C++) can override a virtual method in a base class. For + * Objective-C, a method is said to override any method in the class's + * base class, its protocols, or its categories' protocols, that has the same + * selector and is of the same kind (class or instance). + * If no such method exists, the search continues to the class's superclass, + * its protocols, and its categories, and so on. A method from an Objective-C + * implementation is considered to override the same methods as its + * corresponding method in the interface. + * + * For C++, a virtual member function overrides any virtual member + * function with the same signature that occurs in its base + * classes. With multiple inheritance, a virtual member function can + * override several virtual member functions coming from different + * base classes. + * + * In all cases, this function determines the immediate overridden + * method, rather than all of the overridden methods. For example, if + * a method is originally declared in a class A, then overridden in B + * (which in inherits from A) and also in C (which inherited from B), + * then the only overridden method returned from this function when + * invoked on C's method will be B's method. The client may then + * invoke this function again, given the previously-found overridden + * methods, to map out the complete method-override set. + * + * \param cursor A cursor representing an Objective-C or C++ + * method. This routine will compute the set of methods that this + * method overrides. + * + * \param overridden A pointer whose pointee will be replaced with a + * pointer to an array of cursors, representing the set of overridden + * methods. If there are no overridden methods, the pointee will be + * set to NULL. The pointee must be freed via a call to + * \c clang_disposeOverriddenCursors(). + * + * \param num_overridden A pointer to the number of overridden + * functions, will be set to the number of overridden functions in the + * array pointed to by \p overridden. + */ +CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, + CXCursor **overridden, + unsigned *num_overridden); + +/** + * \brief Free the set of overridden cursors returned by \c + * clang_getOverriddenCursors(). + */ +CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); + +/** + * \brief Retrieve the file that is included by the given inclusion directive + * cursor. + */ +CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code + * + * Cursors represent a location within the Abstract Syntax Tree (AST). These + * routines help map between cursors and the physical locations where the + * described entities occur in the source code. The mapping is provided in + * both directions, so one can map from source code to the AST and back. + * + * @{ + */ + +/** + * \brief Map a source location to the cursor that describes the entity at that + * location in the source code. + * + * clang_getCursor() maps an arbitrary source location within a translation + * unit down to the most specific cursor that describes the entity at that + * location. For example, given an expression \c x + y, invoking + * clang_getCursor() with a source location pointing to "x" will return the + * cursor for "x"; similarly for "y". If the cursor points anywhere between + * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() + * will return a cursor referring to the "+" expression. + * + * \returns a cursor representing the entity at the given source location, or + * a NULL cursor if no such entity can be found. + */ +CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); + +/** + * \brief Retrieve the physical location of the source constructor referenced + * by the given cursor. + * + * The location of a declaration is typically the location of the name of that + * declaration, where the name of that declaration would occur if it is + * unnamed, or some keyword that introduces that particular declaration. + * The location of a reference is where that reference occurs within the + * source code. + */ +CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); + +/** + * \brief Retrieve the physical extent of the source construct referenced by + * the given cursor. + * + * The extent of a cursor starts with the file/line/column pointing at the + * first character within the source construct that the cursor refers to and + * ends with the last character within that source construct. For a + * declaration, the extent covers the declaration itself. For a reference, + * the extent covers the location of the reference (e.g., where the referenced + * entity was actually used). + */ +CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_TYPES Type information for CXCursors + * + * @{ + */ + +/** + * \brief Describes the kind of type + */ +enum CXTypeKind { + /** + * \brief Represents an invalid type (e.g., where no type is available). + */ + CXType_Invalid = 0, + + /** + * \brief A type whose specific kind is not exposed via this + * interface. + */ + CXType_Unexposed = 1, + + /* Builtin types */ + CXType_Void = 2, + CXType_Bool = 3, + CXType_Char_U = 4, + CXType_UChar = 5, + CXType_Char16 = 6, + CXType_Char32 = 7, + CXType_UShort = 8, + CXType_UInt = 9, + CXType_ULong = 10, + CXType_ULongLong = 11, + CXType_UInt128 = 12, + CXType_Char_S = 13, + CXType_SChar = 14, + CXType_WChar = 15, + CXType_Short = 16, + CXType_Int = 17, + CXType_Long = 18, + CXType_LongLong = 19, + CXType_Int128 = 20, + CXType_Float = 21, + CXType_Double = 22, + CXType_LongDouble = 23, + CXType_NullPtr = 24, + CXType_Overload = 25, + CXType_Dependent = 26, + CXType_ObjCId = 27, + CXType_ObjCClass = 28, + CXType_ObjCSel = 29, + CXType_FirstBuiltin = CXType_Void, + CXType_LastBuiltin = CXType_ObjCSel, + + CXType_Complex = 100, + CXType_Pointer = 101, + CXType_BlockPointer = 102, + CXType_LValueReference = 103, + CXType_RValueReference = 104, + CXType_Record = 105, + CXType_Enum = 106, + CXType_Typedef = 107, + CXType_ObjCInterface = 108, + CXType_ObjCObjectPointer = 109, + CXType_FunctionNoProto = 110, + CXType_FunctionProto = 111, + CXType_ConstantArray = 112, + CXType_Vector = 113, + CXType_IncompleteArray = 114, + CXType_VariableArray = 115, + CXType_DependentSizedArray = 116, + CXType_MemberPointer = 117, + CXType_Auto = 118 +}; + +/** + * \brief Describes the calling convention of a function type + */ +enum CXCallingConv { + CXCallingConv_Default = 0, + CXCallingConv_C = 1, + CXCallingConv_X86StdCall = 2, + CXCallingConv_X86FastCall = 3, + CXCallingConv_X86ThisCall = 4, + CXCallingConv_X86Pascal = 5, + CXCallingConv_AAPCS = 6, + CXCallingConv_AAPCS_VFP = 7, + /* Value 8 was PnaclCall, but it was never used, so it could safely be re-used. */ + CXCallingConv_IntelOclBicc = 9, + CXCallingConv_X86_64Win64 = 10, + CXCallingConv_X86_64SysV = 11, + CXCallingConv_X86VectorCall = 12, + + CXCallingConv_Invalid = 100, + CXCallingConv_Unexposed = 200 +}; + +/** + * \brief The type of an element in the abstract syntax tree. + * + */ +typedef struct { + enum CXTypeKind kind; + void *data[2]; +} CXType; + +/** + * \brief Retrieve the type of a CXCursor (if any). + */ +CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); + +/** + * \brief Pretty-print the underlying type using the rules of the + * language of the translation unit from which it came. + * + * If the type is invalid, an empty string is returned. + */ +CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT); + +/** + * \brief Retrieve the underlying type of a typedef declaration. + * + * If the cursor does not reference a typedef declaration, an invalid type is + * returned. + */ +CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); + +/** + * \brief Retrieve the integer type of an enum declaration. + * + * If the cursor does not reference an enum declaration, an invalid type is + * returned. + */ +CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); + +/** + * \brief Retrieve the integer value of an enum constant declaration as a signed + * long long. + * + * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. + * Since this is also potentially a valid constant value, the kind of the cursor + * must be verified before calling this function. + */ +CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); + +/** + * \brief Retrieve the integer value of an enum constant declaration as an unsigned + * long long. + * + * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. + * Since this is also potentially a valid constant value, the kind of the cursor + * must be verified before calling this function. + */ +CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C); + +/** + * \brief Retrieve the bit width of a bit field declaration as an integer. + * + * If a cursor that is not a bit field declaration is passed in, -1 is returned. + */ +CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C); + +/** + * \brief Retrieve the number of non-variadic arguments associated with a given + * cursor. + * + * The number of arguments can be determined for calls as well as for + * declarations of functions or methods. For other cursors -1 is returned. + */ +CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); + +/** + * \brief Retrieve the argument cursor of a function or method. + * + * The argument cursor can be determined for calls as well as for declarations + * of functions or methods. For other cursors and for invalid indices, an + * invalid cursor is returned. + */ +CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i); + +/** + * \brief Describes the kind of a template argument. + * + * See the definition of llvm::clang::TemplateArgument::ArgKind for full + * element descriptions. + */ +enum CXTemplateArgumentKind { + CXTemplateArgumentKind_Null, + CXTemplateArgumentKind_Type, + CXTemplateArgumentKind_Declaration, + CXTemplateArgumentKind_NullPtr, + CXTemplateArgumentKind_Integral, + CXTemplateArgumentKind_Template, + CXTemplateArgumentKind_TemplateExpansion, + CXTemplateArgumentKind_Expression, + CXTemplateArgumentKind_Pack, + /* Indicates an error case, preventing the kind from being deduced. */ + CXTemplateArgumentKind_Invalid +}; + +/** + *\brief Returns the number of template args of a function decl representing a + * template specialization. + * + * If the argument cursor cannot be converted into a template function + * declaration, -1 is returned. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * The value 3 would be returned from this call. + */ +CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C); + +/** + * \brief Retrieve the kind of the I'th template argument of the CXCursor C. + * + * If the argument CXCursor does not represent a FunctionDecl, an invalid + * template argument kind is returned. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * For I = 0, 1, and 2, Type, Integral, and Integral will be returned, + * respectively. + */ +CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( + CXCursor C, unsigned I); + +/** + * \brief Retrieve a CXType representing the type of a TemplateArgument of a + * function decl representing a template specialization. + * + * If the argument CXCursor does not represent a FunctionDecl whose I'th + * template argument has a kind of CXTemplateArgKind_Integral, an invalid type + * is returned. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * If called with I = 0, "float", will be returned. + * Invalid types will be returned for I == 1 or 2. + */ +CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C, + unsigned I); + +/** + * \brief Retrieve the value of an Integral TemplateArgument (of a function + * decl representing a template specialization) as a signed long long. + * + * It is undefined to call this function on a CXCursor that does not represent a + * FunctionDecl or whose I'th template argument is not an integral value. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * If called with I = 1 or 2, -7 or true will be returned, respectively. + * For I == 0, this function's behavior is undefined. + */ +CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C, + unsigned I); + +/** + * \brief Retrieve the value of an Integral TemplateArgument (of a function + * decl representing a template specialization) as an unsigned long long. + * + * It is undefined to call this function on a CXCursor that does not represent a + * FunctionDecl or whose I'th template argument is not an integral value. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * If called with I = 1 or 2, 2147483649 or true will be returned, respectively. + * For I == 0, this function's behavior is undefined. + */ +CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue( + CXCursor C, unsigned I); + +/** + * \brief Determine whether two CXTypes represent the same type. + * + * \returns non-zero if the CXTypes represent the same type and + * zero otherwise. + */ +CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); + +/** + * \brief Return the canonical type for a CXType. + * + * Clang's type system explicitly models typedefs and all the ways + * a specific type can be represented. The canonical type is the underlying + * type with all the "sugar" removed. For example, if 'T' is a typedef + * for 'int', the canonical type for 'T' would be 'int'. + */ +CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); + +/** + * \brief Determine whether a CXType has the "const" qualifier set, + * without looking through typedefs that may have added "const" at a + * different level. + */ +CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); + +/** + * \brief Determine whether a CXType has the "volatile" qualifier set, + * without looking through typedefs that may have added "volatile" at + * a different level. + */ +CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); + +/** + * \brief Determine whether a CXType has the "restrict" qualifier set, + * without looking through typedefs that may have added "restrict" at a + * different level. + */ +CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); + +/** + * \brief For pointer types, returns the type of the pointee. + */ +CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); + +/** + * \brief Return the cursor for the declaration of the given type. + */ +CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); + +/** + * Returns the Objective-C type encoding for the specified declaration. + */ +CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); + +/** + * \brief Retrieve the spelling of a given CXTypeKind. + */ +CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); + +/** + * \brief Retrieve the calling convention associated with a function type. + * + * If a non-function type is passed in, CXCallingConv_Invalid is returned. + */ +CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); + +/** + * \brief Retrieve the return type associated with a function type. + * + * If a non-function type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getResultType(CXType T); + +/** + * \brief Retrieve the number of non-variadic parameters associated with a + * function type. + * + * If a non-function type is passed in, -1 is returned. + */ +CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); + +/** + * \brief Retrieve the type of a parameter of a function type. + * + * If a non-function type is passed in or the function does not have enough + * parameters, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); + +/** + * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise. + */ +CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); + +/** + * \brief Retrieve the return type associated with a given cursor. + * + * This only returns a valid type if the cursor refers to a function or method. + */ +CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); + +/** + * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 + * otherwise. + */ +CINDEX_LINKAGE unsigned clang_isPODType(CXType T); + +/** + * \brief Return the element type of an array, complex, or vector type. + * + * If a type is passed in that is not an array, complex, or vector type, + * an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getElementType(CXType T); + +/** + * \brief Return the number of elements of an array or vector type. + * + * If a type is passed in that is not an array or vector type, + * -1 is returned. + */ +CINDEX_LINKAGE long long clang_getNumElements(CXType T); + +/** + * \brief Return the element type of an array type. + * + * If a non-array type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); + +/** + * \brief Return the array size of a constant array. + * + * If a non-array type is passed in, -1 is returned. + */ +CINDEX_LINKAGE long long clang_getArraySize(CXType T); + +/** + * \brief List the possible error codes for \c clang_Type_getSizeOf, + * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and + * \c clang_Cursor_getOffsetOf. + * + * A value of this enumeration type can be returned if the target type is not + * a valid argument to sizeof, alignof or offsetof. + */ +enum CXTypeLayoutError { + /** + * \brief Type is of kind CXType_Invalid. + */ + CXTypeLayoutError_Invalid = -1, + /** + * \brief The type is an incomplete Type. + */ + CXTypeLayoutError_Incomplete = -2, + /** + * \brief The type is a dependent Type. + */ + CXTypeLayoutError_Dependent = -3, + /** + * \brief The type is not a constant size type. + */ + CXTypeLayoutError_NotConstantSize = -4, + /** + * \brief The Field name is not valid for this record. + */ + CXTypeLayoutError_InvalidFieldName = -5 +}; + +/** + * \brief Return the alignment of a type in bytes as per C++[expr.alignof] + * standard. + * + * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + * is returned. + * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + * returned. + * If the type declaration is not a constant size type, + * CXTypeLayoutError_NotConstantSize is returned. + */ +CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T); + +/** + * \brief Return the class type of an member pointer type. + * + * If a non-member-pointer type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T); + +/** + * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard. + * + * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + * is returned. + * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + * returned. + */ +CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); + +/** + * \brief Return the offset of a field named S in a record of type T in bits + * as it would be returned by __offsetof__ as per C++11[18.2p4] + * + * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid + * is returned. + * If the field's type declaration is an incomplete type, + * CXTypeLayoutError_Incomplete is returned. + * If the field's type declaration is a dependent type, + * CXTypeLayoutError_Dependent is returned. + * If the field's name S is not found, + * CXTypeLayoutError_InvalidFieldName is returned. + */ +CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); + +/** + * \brief Return the offset of the field represented by the Cursor. + * + * If the cursor is not a field declaration, -1 is returned. + * If the cursor semantic parent is not a record field declaration, + * CXTypeLayoutError_Invalid is returned. + * If the field's type declaration is an incomplete type, + * CXTypeLayoutError_Incomplete is returned. + * If the field's type declaration is a dependent type, + * CXTypeLayoutError_Dependent is returned. + * If the field's name S is not found, + * CXTypeLayoutError_InvalidFieldName is returned. + */ +CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C); + +/** + * \brief Determine whether the given cursor represents an anonymous record + * declaration. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); + +enum CXRefQualifierKind { + /** \brief No ref-qualifier was provided. */ + CXRefQualifier_None = 0, + /** \brief An lvalue ref-qualifier was provided (\c &). */ + CXRefQualifier_LValue, + /** \brief An rvalue ref-qualifier was provided (\c &&). */ + CXRefQualifier_RValue +}; + +/** + * \brief Returns the number of template arguments for given class template + * specialization, or -1 if type \c T is not a class template specialization. + * + * Variadic argument packs count as only one argument, and can not be inspected + * further. + */ +CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); + +/** + * \brief Returns the type template argument of a template class specialization + * at given index. + * + * This function only returns template type arguments and does not handle + * template template arguments or variadic packs. + */ +CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i); + +/** + * \brief Retrieve the ref-qualifier kind of a function or method. + * + * The ref-qualifier is returned for C++ functions or methods. For other types + * or non-C++ declarations, CXRefQualifier_None is returned. + */ +CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T); + +/** + * \brief Returns non-zero if the cursor specifies a Record member that is a + * bitfield. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C); + +/** + * \brief Returns 1 if the base class specified by the cursor with kind + * CX_CXXBaseSpecifier is virtual. + */ +CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); + +/** + * \brief Represents the C++ access control level to a base class for a + * cursor with kind CX_CXXBaseSpecifier. + */ +enum CX_CXXAccessSpecifier { + CX_CXXInvalidAccessSpecifier, + CX_CXXPublic, + CX_CXXProtected, + CX_CXXPrivate +}; + +/** + * \brief Returns the access control level for the referenced object. + * + * If the cursor refers to a C++ declaration, its access control level within its + * parent scope is returned. Otherwise, if the cursor refers to a base specifier or + * access specifier, the specifier itself is returned. + */ +CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); + +/** + * \brief Represents the storage classes as declared in the source. CX_SC_Invalid + * was added for the case that the passed cursor in not a declaration. + */ +enum CX_StorageClass { + CX_SC_Invalid, + CX_SC_None, + CX_SC_Extern, + CX_SC_Static, + CX_SC_PrivateExtern, + CX_SC_OpenCLWorkGroupLocal, + CX_SC_Auto, + CX_SC_Register +}; + +/** + * \brief Returns the storage class for a function or variable declaration. + * + * If the passed in Cursor is not a function or variable declaration, + * CX_SC_Invalid is returned else the storage class. + */ +CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); + +/** + * \brief Determine the number of overloaded declarations referenced by a + * \c CXCursor_OverloadedDeclRef cursor. + * + * \param cursor The cursor whose overloaded declarations are being queried. + * + * \returns The number of overloaded declarations referenced by \c cursor. If it + * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. + */ +CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); + +/** + * \brief Retrieve a cursor for one of the overloaded declarations referenced + * by a \c CXCursor_OverloadedDeclRef cursor. + * + * \param cursor The cursor whose overloaded declarations are being queried. + * + * \param index The zero-based index into the set of overloaded declarations in + * the cursor. + * + * \returns A cursor representing the declaration referenced by the given + * \c cursor at the specified \c index. If the cursor does not have an + * associated set of overloaded declarations, or if the index is out of bounds, + * returns \c clang_getNullCursor(); + */ +CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, + unsigned index); + +/** + * @} + */ + +/** + * \defgroup CINDEX_ATTRIBUTES Information for attributes + * + * @{ + */ + +/** + * \brief For cursors representing an iboutletcollection attribute, + * this function returns the collection element type. + * + */ +CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors + * + * These routines provide the ability to traverse the abstract syntax tree + * using cursors. + * + * @{ + */ + +/** + * \brief Describes how the traversal of the children of a particular + * cursor should proceed after visiting a particular child cursor. + * + * A value of this enumeration type should be returned by each + * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. + */ +enum CXChildVisitResult { + /** + * \brief Terminates the cursor traversal. + */ + CXChildVisit_Break, + /** + * \brief Continues the cursor traversal with the next sibling of + * the cursor just visited, without visiting its children. + */ + CXChildVisit_Continue, + /** + * \brief Recursively traverse the children of this cursor, using + * the same visitor and client data. + */ + CXChildVisit_Recurse +}; + +/** + * \brief Visitor invoked for each cursor found by a traversal. + * + * This visitor function will be invoked for each cursor found by + * clang_visitCursorChildren(). Its first argument is the cursor being + * visited, its second argument is the parent visitor for that cursor, + * and its third argument is the client data provided to + * clang_visitCursorChildren(). + * + * The visitor should return one of the \c CXChildVisitResult values + * to direct clang_visitCursorChildren(). + */ +typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, + CXCursor parent, + CXClientData client_data); + +/** + * \brief Visit the children of a particular cursor. + * + * This function visits all the direct children of the given cursor, + * invoking the given \p visitor function with the cursors of each + * visited child. The traversal may be recursive, if the visitor returns + * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if + * the visitor returns \c CXChildVisit_Break. + * + * \param parent the cursor whose child may be visited. All kinds of + * cursors can be visited, including invalid cursors (which, by + * definition, have no children). + * + * \param visitor the visitor function that will be invoked for each + * child of \p parent. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the visitor each time it is invoked. + * + * \returns a non-zero value if the traversal was terminated + * prematurely by the visitor returning \c CXChildVisit_Break. + */ +CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, + CXCursorVisitor visitor, + CXClientData client_data); +#ifdef __has_feature +# if __has_feature(blocks) +/** + * \brief Visitor invoked for each cursor found by a traversal. + * + * This visitor block will be invoked for each cursor found by + * clang_visitChildrenWithBlock(). Its first argument is the cursor being + * visited, its second argument is the parent visitor for that cursor. + * + * The visitor should return one of the \c CXChildVisitResult values + * to direct clang_visitChildrenWithBlock(). + */ +typedef enum CXChildVisitResult + (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent); + +/** + * Visits the children of a cursor using the specified block. Behaves + * identically to clang_visitChildren() in all other respects. + */ +unsigned clang_visitChildrenWithBlock(CXCursor parent, + CXCursorVisitorBlock block); +# endif +#endif + +/** + * @} + */ + +/** + * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST + * + * These routines provide the ability to determine references within and + * across translation units, by providing the names of the entities referenced + * by cursors, follow reference cursors to the declarations they reference, + * and associate declarations with their definitions. + * + * @{ + */ + +/** + * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced + * by the given cursor. + * + * A Unified Symbol Resolution (USR) is a string that identifies a particular + * entity (function, class, variable, etc.) within a program. USRs can be + * compared across translation units to determine, e.g., when references in + * one translation refer to an entity defined in another translation unit. + */ +CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); + +/** + * \brief Construct a USR for a specified Objective-C class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); + +/** + * \brief Construct a USR for a specified Objective-C category. + */ +CINDEX_LINKAGE CXString + clang_constructUSR_ObjCCategory(const char *class_name, + const char *category_name); + +/** + * \brief Construct a USR for a specified Objective-C protocol. + */ +CINDEX_LINKAGE CXString + clang_constructUSR_ObjCProtocol(const char *protocol_name); + +/** + * \brief Construct a USR for a specified Objective-C instance variable and + * the USR for its containing class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, + CXString classUSR); + +/** + * \brief Construct a USR for a specified Objective-C method and + * the USR for its containing class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, + unsigned isInstanceMethod, + CXString classUSR); + +/** + * \brief Construct a USR for a specified Objective-C property and the USR + * for its containing class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, + CXString classUSR); + +/** + * \brief Retrieve a name for the entity referenced by this cursor. + */ +CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); + +/** + * \brief Retrieve a range for a piece that forms the cursors spelling name. + * Most of the times there is only one range for the complete spelling but for + * Objective-C methods and Objective-C message expressions, there are multiple + * pieces for each selector identifier. + * + * \param pieceIndex the index of the spelling name piece. If this is greater + * than the actual number of pieces, it will return a NULL (invalid) range. + * + * \param options Reserved. + */ +CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor, + unsigned pieceIndex, + unsigned options); + +/** + * \brief Retrieve the display name for the entity referenced by this cursor. + * + * The display name contains extra information that helps identify the cursor, + * such as the parameters of a function or template or the arguments of a + * class template specialization. + */ +CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); + +/** \brief For a cursor that is a reference, retrieve a cursor representing the + * entity that it references. + * + * Reference cursors refer to other entities in the AST. For example, an + * Objective-C superclass reference cursor refers to an Objective-C class. + * This function produces the cursor for the Objective-C class from the + * cursor for the superclass reference. If the input cursor is a declaration or + * definition, it returns that declaration or definition unchanged. + * Otherwise, returns the NULL cursor. + */ +CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); + +/** + * \brief For a cursor that is either a reference to or a declaration + * of some entity, retrieve a cursor that describes the definition of + * that entity. + * + * Some entities can be declared multiple times within a translation + * unit, but only one of those declarations can also be a + * definition. For example, given: + * + * \code + * int f(int, int); + * int g(int x, int y) { return f(x, y); } + * int f(int a, int b) { return a + b; } + * int f(int, int); + * \endcode + * + * there are three declarations of the function "f", but only the + * second one is a definition. The clang_getCursorDefinition() + * function will take any cursor pointing to a declaration of "f" + * (the first or fourth lines of the example) or a cursor referenced + * that uses "f" (the call to "f' inside "g") and will return a + * declaration cursor pointing to the definition (the second "f" + * declaration). + * + * If given a cursor for which there is no corresponding definition, + * e.g., because there is no definition of that entity within this + * translation unit, returns a NULL cursor. + */ +CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); + +/** + * \brief Determine whether the declaration pointed to by this cursor + * is also a definition of that entity. + */ +CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); + +/** + * \brief Retrieve the canonical cursor corresponding to the given cursor. + * + * In the C family of languages, many kinds of entities can be declared several + * times within a single translation unit. For example, a structure type can + * be forward-declared (possibly multiple times) and later defined: + * + * \code + * struct X; + * struct X; + * struct X { + * int member; + * }; + * \endcode + * + * The declarations and the definition of \c X are represented by three + * different cursors, all of which are declarations of the same underlying + * entity. One of these cursor is considered the "canonical" cursor, which + * is effectively the representative for the underlying entity. One can + * determine if two cursors are declarations of the same underlying entity by + * comparing their canonical cursors. + * + * \returns The canonical cursor for the entity referred to by the given cursor. + */ +CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); + +/** + * \brief If the cursor points to a selector identifier in an Objective-C + * method or message expression, this returns the selector index. + * + * After getting a cursor with #clang_getCursor, this can be called to + * determine if the location points to a selector identifier. + * + * \returns The selector index if the cursor is an Objective-C method or message + * expression and the cursor is pointing to a selector identifier, or -1 + * otherwise. + */ +CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); + +/** + * \brief Given a cursor pointing to a C++ method call or an Objective-C + * message, returns non-zero if the method/message is "dynamic", meaning: + * + * For a C++ method: the call is virtual. + * For an Objective-C message: the receiver is an object instance, not 'super' + * or a specific class. + * + * If the method/message is "static" or the cursor does not point to a + * method/message, it will return zero. + */ +CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C); + +/** + * \brief Given a cursor pointing to an Objective-C message, returns the CXType + * of the receiver. + */ +CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C); + +/** + * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl. + */ +typedef enum { + CXObjCPropertyAttr_noattr = 0x00, + CXObjCPropertyAttr_readonly = 0x01, + CXObjCPropertyAttr_getter = 0x02, + CXObjCPropertyAttr_assign = 0x04, + CXObjCPropertyAttr_readwrite = 0x08, + CXObjCPropertyAttr_retain = 0x10, + CXObjCPropertyAttr_copy = 0x20, + CXObjCPropertyAttr_nonatomic = 0x40, + CXObjCPropertyAttr_setter = 0x80, + CXObjCPropertyAttr_atomic = 0x100, + CXObjCPropertyAttr_weak = 0x200, + CXObjCPropertyAttr_strong = 0x400, + CXObjCPropertyAttr_unsafe_unretained = 0x800 +} CXObjCPropertyAttrKind; + +/** + * \brief Given a cursor that represents a property declaration, return the + * associated property attributes. The bits are formed from + * \c CXObjCPropertyAttrKind. + * + * \param reserved Reserved for future use, pass 0. + */ +CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, + unsigned reserved); + +/** + * \brief 'Qualifiers' written next to the return and parameter types in + * Objective-C method declarations. + */ +typedef enum { + CXObjCDeclQualifier_None = 0x0, + CXObjCDeclQualifier_In = 0x1, + CXObjCDeclQualifier_Inout = 0x2, + CXObjCDeclQualifier_Out = 0x4, + CXObjCDeclQualifier_Bycopy = 0x8, + CXObjCDeclQualifier_Byref = 0x10, + CXObjCDeclQualifier_Oneway = 0x20 +} CXObjCDeclQualifierKind; + +/** + * \brief Given a cursor that represents an Objective-C method or parameter + * declaration, return the associated Objective-C qualifiers for the return + * type or the parameter respectively. The bits are formed from + * CXObjCDeclQualifierKind. + */ +CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C); + +/** + * \brief Given a cursor that represents an Objective-C method or property + * declaration, return non-zero if the declaration was affected by "@optional". + * Returns zero if the cursor is not such a declaration or it is "@required". + */ +CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C); + +/** + * \brief Returns non-zero if the given cursor is a variadic function or method. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C); + +/** + * \brief Given a cursor that represents a declaration, return the associated + * comment's source range. The range may include multiple consecutive comments + * with whitespace in between. + */ +CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C); + +/** + * \brief Given a cursor that represents a declaration, return the associated + * comment text, including comment markers. + */ +CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C); + +/** + * \brief Given a cursor that represents a documentable entity (e.g., + * declaration), return the associated \\brief paragraph; otherwise return the + * first paragraph. + */ +CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); + +/** + * @} + */ + +/** \defgroup CINDEX_MANGLE Name Mangling API Functions + * + * @{ + */ + +/** + * \brief Retrieve the CXString representing the mangled name of the cursor. + */ +CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor); + +/** + * \brief Retrieve the CXStrings representing the mangled symbols of the C++ + * constructor or destructor at the cursor. + */ +CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_MODULE Module introspection + * + * The functions in this group provide access to information about modules. + * + * @{ + */ + +typedef void *CXModule; + +/** + * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module. + */ +CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C); + +/** + * \brief Given a CXFile header file, return the module that contains it, if one + * exists. + */ +CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile); + +/** + * \param Module a module object. + * + * \returns the module file where the provided module object came from. + */ +CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the parent of a sub-module or NULL if the given module is top-level, + * e.g. for 'std.vector' it will return the 'std' module. + */ +CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the name of the module, e.g. for the 'std.vector' sub-module it + * will return "vector". + */ +CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the full name of the module, e.g. "std.vector". + */ +CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module); + +/** + * \param Module a module object. + * + * \returns non-zero if the module is a system one. + */ +CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the number of top level headers associated with this module. + */ +CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit, + CXModule Module); + +/** + * \param Module a module object. + * + * \param Index top level header index (zero-based). + * + * \returns the specified top level header associated with the module. + */ +CINDEX_LINKAGE +CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, + CXModule Module, unsigned Index); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CPP C++ AST introspection + * + * The routines in this group provide access information in the ASTs specific + * to C++ language features. + * + * @{ + */ + +/** + * \brief Determine if a C++ field is declared 'mutable'. + */ +CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C); + +/** + * \brief Determine if a C++ member function or member function template is + * pure virtual. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C); + +/** + * \brief Determine if a C++ member function or member function template is + * declared 'static'. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); + +/** + * \brief Determine if a C++ member function or member function template is + * explicitly declared 'virtual' or if it overrides a virtual method from + * one of the base classes. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); + +/** + * \brief Determine if a C++ member function or member function template is + * declared 'const'. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); + +/** + * \brief Given a cursor that represents a template, determine + * the cursor kind of the specializations would be generated by instantiating + * the template. + * + * This routine can be used to determine what flavor of function template, + * class template, or class template partial specialization is stored in the + * cursor. For example, it can describe whether a class template cursor is + * declared with "struct", "class" or "union". + * + * \param C The cursor to query. This cursor should represent a template + * declaration. + * + * \returns The cursor kind of the specializations that would be generated + * by instantiating the template \p C. If \p C is not a template, returns + * \c CXCursor_NoDeclFound. + */ +CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); + +/** + * \brief Given a cursor that may represent a specialization or instantiation + * of a template, retrieve the cursor that represents the template that it + * specializes or from which it was instantiated. + * + * This routine determines the template involved both for explicit + * specializations of templates and for implicit instantiations of the template, + * both of which are referred to as "specializations". For a class template + * specialization (e.g., \c std::vector), this routine will return + * either the primary template (\c std::vector) or, if the specialization was + * instantiated from a class template partial specialization, the class template + * partial specialization. For a class template partial specialization and a + * function template specialization (including instantiations), this + * this routine will return the specialized template. + * + * For members of a class template (e.g., member functions, member classes, or + * static data members), returns the specialized or instantiated member. + * Although not strictly "templates" in the C++ language, members of class + * templates have the same notions of specializations and instantiations that + * templates do, so this routine treats them similarly. + * + * \param C A cursor that may be a specialization of a template or a member + * of a template. + * + * \returns If the given cursor is a specialization or instantiation of a + * template or a member thereof, the template or member that it specializes or + * from which it was instantiated. Otherwise, returns a NULL cursor. + */ +CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); + +/** + * \brief Given a cursor that references something else, return the source range + * covering that reference. + * + * \param C A cursor pointing to a member reference, a declaration reference, or + * an operator call. + * \param NameFlags A bitset with three independent flags: + * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and + * CXNameRange_WantSinglePiece. + * \param PieceIndex For contiguous names or when passing the flag + * CXNameRange_WantSinglePiece, only one piece with index 0 is + * available. When the CXNameRange_WantSinglePiece flag is not passed for a + * non-contiguous names, this index can be used to retrieve the individual + * pieces of the name. See also CXNameRange_WantSinglePiece. + * + * \returns The piece of the name pointed to by the given cursor. If there is no + * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. + */ +CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, + unsigned NameFlags, + unsigned PieceIndex); + +enum CXNameRefFlags { + /** + * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the + * range. + */ + CXNameRange_WantQualifier = 0x1, + + /** + * \brief Include the explicit template arguments, e.g. \ in x.f, + * in the range. + */ + CXNameRange_WantTemplateArgs = 0x2, + + /** + * \brief If the name is non-contiguous, return the full spanning range. + * + * Non-contiguous names occur in Objective-C when a selector with two or more + * parameters is used, or in C++ when using an operator: + * \code + * [object doSomething:here withValue:there]; // Objective-C + * return some_vector[1]; // C++ + * \endcode + */ + CXNameRange_WantSinglePiece = 0x4 +}; + +/** + * @} + */ + +/** + * \defgroup CINDEX_LEX Token extraction and manipulation + * + * The routines in this group provide access to the tokens within a + * translation unit, along with a semantic mapping of those tokens to + * their corresponding cursors. + * + * @{ + */ + +/** + * \brief Describes a kind of token. + */ +typedef enum CXTokenKind { + /** + * \brief A token that contains some kind of punctuation. + */ + CXToken_Punctuation, + + /** + * \brief A language keyword. + */ + CXToken_Keyword, + + /** + * \brief An identifier (that is not a keyword). + */ + CXToken_Identifier, + + /** + * \brief A numeric, string, or character literal. + */ + CXToken_Literal, + + /** + * \brief A comment. + */ + CXToken_Comment +} CXTokenKind; + +/** + * \brief Describes a single preprocessing token. + */ +typedef struct { + unsigned int_data[4]; + void *ptr_data; +} CXToken; + +/** + * \brief Determine the kind of the given token. + */ +CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); + +/** + * \brief Determine the spelling of the given token. + * + * The spelling of a token is the textual representation of that token, e.g., + * the text of an identifier or keyword. + */ +CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); + +/** + * \brief Retrieve the source location of the given token. + */ +CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, + CXToken); + +/** + * \brief Retrieve a source range that covers the given token. + */ +CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); + +/** + * \brief Tokenize the source code described by the given range into raw + * lexical tokens. + * + * \param TU the translation unit whose text is being tokenized. + * + * \param Range the source range in which text should be tokenized. All of the + * tokens produced by tokenization will fall within this source range, + * + * \param Tokens this pointer will be set to point to the array of tokens + * that occur within the given source range. The returned pointer must be + * freed with clang_disposeTokens() before the translation unit is destroyed. + * + * \param NumTokens will be set to the number of tokens in the \c *Tokens + * array. + * + */ +CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, + CXToken **Tokens, unsigned *NumTokens); + +/** + * \brief Annotate the given set of tokens by providing cursors for each token + * that can be mapped to a specific entity within the abstract syntax tree. + * + * This token-annotation routine is equivalent to invoking + * clang_getCursor() for the source locations of each of the + * tokens. The cursors provided are filtered, so that only those + * cursors that have a direct correspondence to the token are + * accepted. For example, given a function call \c f(x), + * clang_getCursor() would provide the following cursors: + * + * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. + * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. + * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. + * + * Only the first and last of these cursors will occur within the + * annotate, since the tokens "f" and "x' directly refer to a function + * and a variable, respectively, but the parentheses are just a small + * part of the full syntax of the function call expression, which is + * not provided as an annotation. + * + * \param TU the translation unit that owns the given tokens. + * + * \param Tokens the set of tokens to annotate. + * + * \param NumTokens the number of tokens in \p Tokens. + * + * \param Cursors an array of \p NumTokens cursors, whose contents will be + * replaced with the cursors corresponding to each token. + */ +CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, + CXToken *Tokens, unsigned NumTokens, + CXCursor *Cursors); + +/** + * \brief Free the given set of tokens. + */ +CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, + CXToken *Tokens, unsigned NumTokens); + +/** + * @} + */ + +/** + * \defgroup CINDEX_DEBUG Debugging facilities + * + * These routines are used for testing and debugging, only, and should not + * be relied upon. + * + * @{ + */ + +/* for debug/testing */ +CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); +CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, + const char **startBuf, + const char **endBuf, + unsigned *startLine, + unsigned *startColumn, + unsigned *endLine, + unsigned *endColumn); +CINDEX_LINKAGE void clang_enableStackTraces(void); +CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, + unsigned stack_size); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CODE_COMPLET Code completion + * + * Code completion involves taking an (incomplete) source file, along with + * knowledge of where the user is actively editing that file, and suggesting + * syntactically- and semantically-valid constructs that the user might want to + * use at that particular point in the source code. These data structures and + * routines provide support for code completion. + * + * @{ + */ + +/** + * \brief A semantic string that describes a code-completion result. + * + * A semantic string that describes the formatting of a code-completion + * result as a single "template" of text that should be inserted into the + * source buffer when a particular code-completion result is selected. + * Each semantic string is made up of some number of "chunks", each of which + * contains some text along with a description of what that text means, e.g., + * the name of the entity being referenced, whether the text chunk is part of + * the template, or whether it is a "placeholder" that the user should replace + * with actual code,of a specific kind. See \c CXCompletionChunkKind for a + * description of the different kinds of chunks. + */ +typedef void *CXCompletionString; + +/** + * \brief A single result of code completion. + */ +typedef struct { + /** + * \brief The kind of entity that this completion refers to. + * + * The cursor kind will be a macro, keyword, or a declaration (one of the + * *Decl cursor kinds), describing the entity that the completion is + * referring to. + * + * \todo In the future, we would like to provide a full cursor, to allow + * the client to extract additional information from declaration. + */ + enum CXCursorKind CursorKind; + + /** + * \brief The code-completion string that describes how to insert this + * code-completion result into the editing buffer. + */ + CXCompletionString CompletionString; +} CXCompletionResult; + +/** + * \brief Describes a single piece of text within a code-completion string. + * + * Each "chunk" within a code-completion string (\c CXCompletionString) is + * either a piece of text with a specific "kind" that describes how that text + * should be interpreted by the client or is another completion string. + */ +enum CXCompletionChunkKind { + /** + * \brief A code-completion string that describes "optional" text that + * could be a part of the template (but is not required). + * + * The Optional chunk is the only kind of chunk that has a code-completion + * string for its representation, which is accessible via + * \c clang_getCompletionChunkCompletionString(). The code-completion string + * describes an additional part of the template that is completely optional. + * For example, optional chunks can be used to describe the placeholders for + * arguments that match up with defaulted function parameters, e.g. given: + * + * \code + * void f(int x, float y = 3.14, double z = 2.71828); + * \endcode + * + * The code-completion string for this function would contain: + * - a TypedText chunk for "f". + * - a LeftParen chunk for "(". + * - a Placeholder chunk for "int x" + * - an Optional chunk containing the remaining defaulted arguments, e.g., + * - a Comma chunk for "," + * - a Placeholder chunk for "float y" + * - an Optional chunk containing the last defaulted argument: + * - a Comma chunk for "," + * - a Placeholder chunk for "double z" + * - a RightParen chunk for ")" + * + * There are many ways to handle Optional chunks. Two simple approaches are: + * - Completely ignore optional chunks, in which case the template for the + * function "f" would only include the first parameter ("int x"). + * - Fully expand all optional chunks, in which case the template for the + * function "f" would have all of the parameters. + */ + CXCompletionChunk_Optional, + /** + * \brief Text that a user would be expected to type to get this + * code-completion result. + * + * There will be exactly one "typed text" chunk in a semantic string, which + * will typically provide the spelling of a keyword or the name of a + * declaration that could be used at the current code point. Clients are + * expected to filter the code-completion results based on the text in this + * chunk. + */ + CXCompletionChunk_TypedText, + /** + * \brief Text that should be inserted as part of a code-completion result. + * + * A "text" chunk represents text that is part of the template to be + * inserted into user code should this particular code-completion result + * be selected. + */ + CXCompletionChunk_Text, + /** + * \brief Placeholder text that should be replaced by the user. + * + * A "placeholder" chunk marks a place where the user should insert text + * into the code-completion template. For example, placeholders might mark + * the function parameters for a function declaration, to indicate that the + * user should provide arguments for each of those parameters. The actual + * text in a placeholder is a suggestion for the text to display before + * the user replaces the placeholder with real code. + */ + CXCompletionChunk_Placeholder, + /** + * \brief Informative text that should be displayed but never inserted as + * part of the template. + * + * An "informative" chunk contains annotations that can be displayed to + * help the user decide whether a particular code-completion result is the + * right option, but which is not part of the actual template to be inserted + * by code completion. + */ + CXCompletionChunk_Informative, + /** + * \brief Text that describes the current parameter when code-completion is + * referring to function call, message send, or template specialization. + * + * A "current parameter" chunk occurs when code-completion is providing + * information about a parameter corresponding to the argument at the + * code-completion point. For example, given a function + * + * \code + * int add(int x, int y); + * \endcode + * + * and the source code \c add(, where the code-completion point is after the + * "(", the code-completion string will contain a "current parameter" chunk + * for "int x", indicating that the current argument will initialize that + * parameter. After typing further, to \c add(17, (where the code-completion + * point is after the ","), the code-completion string will contain a + * "current paremeter" chunk to "int y". + */ + CXCompletionChunk_CurrentParameter, + /** + * \brief A left parenthesis ('('), used to initiate a function call or + * signal the beginning of a function parameter list. + */ + CXCompletionChunk_LeftParen, + /** + * \brief A right parenthesis (')'), used to finish a function call or + * signal the end of a function parameter list. + */ + CXCompletionChunk_RightParen, + /** + * \brief A left bracket ('['). + */ + CXCompletionChunk_LeftBracket, + /** + * \brief A right bracket (']'). + */ + CXCompletionChunk_RightBracket, + /** + * \brief A left brace ('{'). + */ + CXCompletionChunk_LeftBrace, + /** + * \brief A right brace ('}'). + */ + CXCompletionChunk_RightBrace, + /** + * \brief A left angle bracket ('<'). + */ + CXCompletionChunk_LeftAngle, + /** + * \brief A right angle bracket ('>'). + */ + CXCompletionChunk_RightAngle, + /** + * \brief A comma separator (','). + */ + CXCompletionChunk_Comma, + /** + * \brief Text that specifies the result type of a given result. + * + * This special kind of informative chunk is not meant to be inserted into + * the text buffer. Rather, it is meant to illustrate the type that an + * expression using the given completion string would have. + */ + CXCompletionChunk_ResultType, + /** + * \brief A colon (':'). + */ + CXCompletionChunk_Colon, + /** + * \brief A semicolon (';'). + */ + CXCompletionChunk_SemiColon, + /** + * \brief An '=' sign. + */ + CXCompletionChunk_Equal, + /** + * Horizontal space (' '). + */ + CXCompletionChunk_HorizontalSpace, + /** + * Vertical space ('\n'), after which it is generally a good idea to + * perform indentation. + */ + CXCompletionChunk_VerticalSpace +}; + +/** + * \brief Determine the kind of a particular chunk within a completion string. + * + * \param completion_string the completion string to query. + * + * \param chunk_number the 0-based index of the chunk in the completion string. + * + * \returns the kind of the chunk at the index \c chunk_number. + */ +CINDEX_LINKAGE enum CXCompletionChunkKind +clang_getCompletionChunkKind(CXCompletionString completion_string, + unsigned chunk_number); + +/** + * \brief Retrieve the text associated with a particular chunk within a + * completion string. + * + * \param completion_string the completion string to query. + * + * \param chunk_number the 0-based index of the chunk in the completion string. + * + * \returns the text associated with the chunk at index \c chunk_number. + */ +CINDEX_LINKAGE CXString +clang_getCompletionChunkText(CXCompletionString completion_string, + unsigned chunk_number); + +/** + * \brief Retrieve the completion string associated with a particular chunk + * within a completion string. + * + * \param completion_string the completion string to query. + * + * \param chunk_number the 0-based index of the chunk in the completion string. + * + * \returns the completion string associated with the chunk at index + * \c chunk_number. + */ +CINDEX_LINKAGE CXCompletionString +clang_getCompletionChunkCompletionString(CXCompletionString completion_string, + unsigned chunk_number); + +/** + * \brief Retrieve the number of chunks in the given code-completion string. + */ +CINDEX_LINKAGE unsigned +clang_getNumCompletionChunks(CXCompletionString completion_string); + +/** + * \brief Determine the priority of this code completion. + * + * The priority of a code completion indicates how likely it is that this + * particular completion is the completion that the user will select. The + * priority is selected by various internal heuristics. + * + * \param completion_string The completion string to query. + * + * \returns The priority of this completion string. Smaller values indicate + * higher-priority (more likely) completions. + */ +CINDEX_LINKAGE unsigned +clang_getCompletionPriority(CXCompletionString completion_string); + +/** + * \brief Determine the availability of the entity that this code-completion + * string refers to. + * + * \param completion_string The completion string to query. + * + * \returns The availability of the completion string. + */ +CINDEX_LINKAGE enum CXAvailabilityKind +clang_getCompletionAvailability(CXCompletionString completion_string); + +/** + * \brief Retrieve the number of annotations associated with the given + * completion string. + * + * \param completion_string the completion string to query. + * + * \returns the number of annotations associated with the given completion + * string. + */ +CINDEX_LINKAGE unsigned +clang_getCompletionNumAnnotations(CXCompletionString completion_string); + +/** + * \brief Retrieve the annotation associated with the given completion string. + * + * \param completion_string the completion string to query. + * + * \param annotation_number the 0-based index of the annotation of the + * completion string. + * + * \returns annotation string associated with the completion at index + * \c annotation_number, or a NULL string if that annotation is not available. + */ +CINDEX_LINKAGE CXString +clang_getCompletionAnnotation(CXCompletionString completion_string, + unsigned annotation_number); + +/** + * \brief Retrieve the parent context of the given completion string. + * + * The parent context of a completion string is the semantic parent of + * the declaration (if any) that the code completion represents. For example, + * a code completion for an Objective-C method would have the method's class + * or protocol as its context. + * + * \param completion_string The code completion string whose parent is + * being queried. + * + * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. + * + * \returns The name of the completion parent, e.g., "NSObject" if + * the completion string represents a method in the NSObject class. + */ +CINDEX_LINKAGE CXString +clang_getCompletionParent(CXCompletionString completion_string, + enum CXCursorKind *kind); + +/** + * \brief Retrieve the brief documentation comment attached to the declaration + * that corresponds to the given completion string. + */ +CINDEX_LINKAGE CXString +clang_getCompletionBriefComment(CXCompletionString completion_string); + +/** + * \brief Retrieve a completion string for an arbitrary declaration or macro + * definition cursor. + * + * \param cursor The cursor to query. + * + * \returns A non-context-sensitive completion string for declaration and macro + * definition cursors, or NULL for other kinds of cursors. + */ +CINDEX_LINKAGE CXCompletionString +clang_getCursorCompletionString(CXCursor cursor); + +/** + * \brief Contains the results of code-completion. + * + * This data structure contains the results of code completion, as + * produced by \c clang_codeCompleteAt(). Its contents must be freed by + * \c clang_disposeCodeCompleteResults. + */ +typedef struct { + /** + * \brief The code-completion results. + */ + CXCompletionResult *Results; + + /** + * \brief The number of code-completion results stored in the + * \c Results array. + */ + unsigned NumResults; +} CXCodeCompleteResults; + +/** + * \brief Flags that can be passed to \c clang_codeCompleteAt() to + * modify its behavior. + * + * The enumerators in this enumeration can be bitwise-OR'd together to + * provide multiple options to \c clang_codeCompleteAt(). + */ +enum CXCodeComplete_Flags { + /** + * \brief Whether to include macros within the set of code + * completions returned. + */ + CXCodeComplete_IncludeMacros = 0x01, + + /** + * \brief Whether to include code patterns for language constructs + * within the set of code completions, e.g., for loops. + */ + CXCodeComplete_IncludeCodePatterns = 0x02, + + /** + * \brief Whether to include brief documentation within the set of code + * completions returned. + */ + CXCodeComplete_IncludeBriefComments = 0x04 +}; + +/** + * \brief Bits that represent the context under which completion is occurring. + * + * The enumerators in this enumeration may be bitwise-OR'd together if multiple + * contexts are occurring simultaneously. + */ +enum CXCompletionContext { + /** + * \brief The context for completions is unexposed, as only Clang results + * should be included. (This is equivalent to having no context bits set.) + */ + CXCompletionContext_Unexposed = 0, + + /** + * \brief Completions for any possible type should be included in the results. + */ + CXCompletionContext_AnyType = 1 << 0, + + /** + * \brief Completions for any possible value (variables, function calls, etc.) + * should be included in the results. + */ + CXCompletionContext_AnyValue = 1 << 1, + /** + * \brief Completions for values that resolve to an Objective-C object should + * be included in the results. + */ + CXCompletionContext_ObjCObjectValue = 1 << 2, + /** + * \brief Completions for values that resolve to an Objective-C selector + * should be included in the results. + */ + CXCompletionContext_ObjCSelectorValue = 1 << 3, + /** + * \brief Completions for values that resolve to a C++ class type should be + * included in the results. + */ + CXCompletionContext_CXXClassTypeValue = 1 << 4, + + /** + * \brief Completions for fields of the member being accessed using the dot + * operator should be included in the results. + */ + CXCompletionContext_DotMemberAccess = 1 << 5, + /** + * \brief Completions for fields of the member being accessed using the arrow + * operator should be included in the results. + */ + CXCompletionContext_ArrowMemberAccess = 1 << 6, + /** + * \brief Completions for properties of the Objective-C object being accessed + * using the dot operator should be included in the results. + */ + CXCompletionContext_ObjCPropertyAccess = 1 << 7, + + /** + * \brief Completions for enum tags should be included in the results. + */ + CXCompletionContext_EnumTag = 1 << 8, + /** + * \brief Completions for union tags should be included in the results. + */ + CXCompletionContext_UnionTag = 1 << 9, + /** + * \brief Completions for struct tags should be included in the results. + */ + CXCompletionContext_StructTag = 1 << 10, + + /** + * \brief Completions for C++ class names should be included in the results. + */ + CXCompletionContext_ClassTag = 1 << 11, + /** + * \brief Completions for C++ namespaces and namespace aliases should be + * included in the results. + */ + CXCompletionContext_Namespace = 1 << 12, + /** + * \brief Completions for C++ nested name specifiers should be included in + * the results. + */ + CXCompletionContext_NestedNameSpecifier = 1 << 13, + + /** + * \brief Completions for Objective-C interfaces (classes) should be included + * in the results. + */ + CXCompletionContext_ObjCInterface = 1 << 14, + /** + * \brief Completions for Objective-C protocols should be included in + * the results. + */ + CXCompletionContext_ObjCProtocol = 1 << 15, + /** + * \brief Completions for Objective-C categories should be included in + * the results. + */ + CXCompletionContext_ObjCCategory = 1 << 16, + /** + * \brief Completions for Objective-C instance messages should be included + * in the results. + */ + CXCompletionContext_ObjCInstanceMessage = 1 << 17, + /** + * \brief Completions for Objective-C class messages should be included in + * the results. + */ + CXCompletionContext_ObjCClassMessage = 1 << 18, + /** + * \brief Completions for Objective-C selector names should be included in + * the results. + */ + CXCompletionContext_ObjCSelectorName = 1 << 19, + + /** + * \brief Completions for preprocessor macro names should be included in + * the results. + */ + CXCompletionContext_MacroName = 1 << 20, + + /** + * \brief Natural language completions should be included in the results. + */ + CXCompletionContext_NaturalLanguage = 1 << 21, + + /** + * \brief The current context is unknown, so set all contexts. + */ + CXCompletionContext_Unknown = ((1 << 22) - 1) +}; + +/** + * \brief Returns a default set of code-completion options that can be + * passed to\c clang_codeCompleteAt(). + */ +CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); + +/** + * \brief Perform code completion at a given location in a translation unit. + * + * This function performs code completion at a particular file, line, and + * column within source code, providing results that suggest potential + * code snippets based on the context of the completion. The basic model + * for code completion is that Clang will parse a complete source file, + * performing syntax checking up to the location where code-completion has + * been requested. At that point, a special code-completion token is passed + * to the parser, which recognizes this token and determines, based on the + * current location in the C/Objective-C/C++ grammar and the state of + * semantic analysis, what completions to provide. These completions are + * returned via a new \c CXCodeCompleteResults structure. + * + * Code completion itself is meant to be triggered by the client when the + * user types punctuation characters or whitespace, at which point the + * code-completion location will coincide with the cursor. For example, if \c p + * is a pointer, code-completion might be triggered after the "-" and then + * after the ">" in \c p->. When the code-completion location is afer the ">", + * the completion results will provide, e.g., the members of the struct that + * "p" points to. The client is responsible for placing the cursor at the + * beginning of the token currently being typed, then filtering the results + * based on the contents of the token. For example, when code-completing for + * the expression \c p->get, the client should provide the location just after + * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the + * client can filter the results based on the current token text ("get"), only + * showing those results that start with "get". The intent of this interface + * is to separate the relatively high-latency acquisition of code-completion + * results from the filtering of results on a per-character basis, which must + * have a lower latency. + * + * \param TU The translation unit in which code-completion should + * occur. The source files for this translation unit need not be + * completely up-to-date (and the contents of those source files may + * be overridden via \p unsaved_files). Cursors referring into the + * translation unit may be invalidated by this invocation. + * + * \param complete_filename The name of the source file where code + * completion should be performed. This filename may be any file + * included in the translation unit. + * + * \param complete_line The line at which code-completion should occur. + * + * \param complete_column The column at which code-completion should occur. + * Note that the column should point just after the syntactic construct that + * initiated code completion, and not in the middle of a lexical token. + * + * \param unsaved_files the Tiles that have not yet been saved to disk + * but may be required for parsing or code completion, including the + * contents of those files. The contents and name of these files (as + * specified by CXUnsavedFile) are copied when necessary, so the + * client only needs to guarantee their validity until the call to + * this function returns. + * + * \param num_unsaved_files The number of unsaved file entries in \p + * unsaved_files. + * + * \param options Extra options that control the behavior of code + * completion, expressed as a bitwise OR of the enumerators of the + * CXCodeComplete_Flags enumeration. The + * \c clang_defaultCodeCompleteOptions() function returns a default set + * of code-completion options. + * + * \returns If successful, a new \c CXCodeCompleteResults structure + * containing code-completion results, which should eventually be + * freed with \c clang_disposeCodeCompleteResults(). If code + * completion fails, returns NULL. + */ +CINDEX_LINKAGE +CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, + const char *complete_filename, + unsigned complete_line, + unsigned complete_column, + struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, + unsigned options); + +/** + * \brief Sort the code-completion results in case-insensitive alphabetical + * order. + * + * \param Results The set of results to sort. + * \param NumResults The number of results in \p Results. + */ +CINDEX_LINKAGE +void clang_sortCodeCompletionResults(CXCompletionResult *Results, + unsigned NumResults); + +/** + * \brief Free the given set of code-completion results. + */ +CINDEX_LINKAGE +void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); + +/** + * \brief Determine the number of diagnostics produced prior to the + * location where code completion was performed. + */ +CINDEX_LINKAGE +unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); + +/** + * \brief Retrieve a diagnostic associated with the given code completion. + * + * \param Results the code completion results to query. + * \param Index the zero-based diagnostic number to retrieve. + * + * \returns the requested diagnostic. This diagnostic must be freed + * via a call to \c clang_disposeDiagnostic(). + */ +CINDEX_LINKAGE +CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, + unsigned Index); + +/** + * \brief Determines what completions are appropriate for the context + * the given code completion. + * + * \param Results the code completion results to query + * + * \returns the kinds of completions that are appropriate for use + * along with the given code completion results. + */ +CINDEX_LINKAGE +unsigned long long clang_codeCompleteGetContexts( + CXCodeCompleteResults *Results); + +/** + * \brief Returns the cursor kind for the container for the current code + * completion context. The container is only guaranteed to be set for + * contexts where a container exists (i.e. member accesses or Objective-C + * message sends); if there is not a container, this function will return + * CXCursor_InvalidCode. + * + * \param Results the code completion results to query + * + * \param IsIncomplete on return, this value will be false if Clang has complete + * information about the container. If Clang does not have complete + * information, this value will be true. + * + * \returns the container kind, or CXCursor_InvalidCode if there is not a + * container + */ +CINDEX_LINKAGE +enum CXCursorKind clang_codeCompleteGetContainerKind( + CXCodeCompleteResults *Results, + unsigned *IsIncomplete); + +/** + * \brief Returns the USR for the container for the current code completion + * context. If there is not a container for the current context, this + * function will return the empty string. + * + * \param Results the code completion results to query + * + * \returns the USR for the container + */ +CINDEX_LINKAGE +CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); + +/** + * \brief Returns the currently-entered selector for an Objective-C message + * send, formatted like "initWithFoo:bar:". Only guaranteed to return a + * non-empty string for CXCompletionContext_ObjCInstanceMessage and + * CXCompletionContext_ObjCClassMessage. + * + * \param Results the code completion results to query + * + * \returns the selector (or partial selector) that has been entered thus far + * for an Objective-C message send. + */ +CINDEX_LINKAGE +CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); + +/** + * @} + */ + +/** + * \defgroup CINDEX_MISC Miscellaneous utility functions + * + * @{ + */ + +/** + * \brief Return a version string, suitable for showing to a user, but not + * intended to be parsed (the format is not guaranteed to be stable). + */ +CINDEX_LINKAGE CXString clang_getClangVersion(void); + +/** + * \brief Enable/disable crash recovery. + * + * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero + * value enables crash recovery, while 0 disables it. + */ +CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); + + /** + * \brief Visitor invoked for each file in a translation unit + * (used with clang_getInclusions()). + * + * This visitor function will be invoked by clang_getInclusions() for each + * file included (either at the top-level or by \#include directives) within + * a translation unit. The first argument is the file being included, and + * the second and third arguments provide the inclusion stack. The + * array is sorted in order of immediate inclusion. For example, + * the first element refers to the location that included 'included_file'. + */ +typedef void (*CXInclusionVisitor)(CXFile included_file, + CXSourceLocation* inclusion_stack, + unsigned include_len, + CXClientData client_data); + +/** + * \brief Visit the set of preprocessor inclusions in a translation unit. + * The visitor function is called with the provided data for every included + * file. This does not include headers included by the PCH file (unless one + * is inspecting the inclusions in the PCH file itself). + */ +CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, + CXInclusionVisitor visitor, + CXClientData client_data); + +/** + * @} + */ + +/** \defgroup CINDEX_REMAPPING Remapping functions + * + * @{ + */ + +/** + * \brief A remapping of original source files and their translated files. + */ +typedef void *CXRemapping; + +/** + * \brief Retrieve a remapping. + * + * \param path the path that contains metadata about remappings. + * + * \returns the requested remapping. This remapping must be freed + * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. + */ +CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); + +/** + * \brief Retrieve a remapping. + * + * \param filePaths pointer to an array of file paths containing remapping info. + * + * \param numFiles number of file paths. + * + * \returns the requested remapping. This remapping must be freed + * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. + */ +CINDEX_LINKAGE +CXRemapping clang_getRemappingsFromFileList(const char **filePaths, + unsigned numFiles); + +/** + * \brief Determine the number of remappings. + */ +CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); + +/** + * \brief Get the original and the associated filename from the remapping. + * + * \param original If non-NULL, will be set to the original filename. + * + * \param transformed If non-NULL, will be set to the filename that the original + * is associated with. + */ +CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, + CXString *original, CXString *transformed); + +/** + * \brief Dispose the remapping. + */ +CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); + +/** + * @} + */ + +/** \defgroup CINDEX_HIGH Higher level API functions + * + * @{ + */ + +enum CXVisitorResult { + CXVisit_Break, + CXVisit_Continue +}; + +typedef struct { + void *context; + enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); +} CXCursorAndRangeVisitor; + +typedef enum { + /** + * \brief Function returned successfully. + */ + CXResult_Success = 0, + /** + * \brief One of the parameters was invalid for the function. + */ + CXResult_Invalid = 1, + /** + * \brief The function was terminated by a callback (e.g. it returned + * CXVisit_Break) + */ + CXResult_VisitBreak = 2 + +} CXResult; + +/** + * \brief Find references of a declaration in a specific file. + * + * \param cursor pointing to a declaration or a reference of one. + * + * \param file to search for references. + * + * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + * each reference found. + * The CXSourceRange will point inside the file; if the reference is inside + * a macro (and not a macro argument) the CXSourceRange will be invalid. + * + * \returns one of the CXResult enumerators. + */ +CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file, + CXCursorAndRangeVisitor visitor); + +/** + * \brief Find #import/#include directives in a specific file. + * + * \param TU translation unit containing the file to query. + * + * \param file to search for #import/#include directives. + * + * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + * each directive found. + * + * \returns one of the CXResult enumerators. + */ +CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU, + CXFile file, + CXCursorAndRangeVisitor visitor); + +#ifdef __has_feature +# if __has_feature(blocks) + +typedef enum CXVisitorResult + (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange); + +CINDEX_LINKAGE +CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile, + CXCursorAndRangeVisitorBlock); + +CINDEX_LINKAGE +CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile, + CXCursorAndRangeVisitorBlock); + +# endif +#endif + +/** + * \brief The client's data object that is associated with a CXFile. + */ +typedef void *CXIdxClientFile; + +/** + * \brief The client's data object that is associated with a semantic entity. + */ +typedef void *CXIdxClientEntity; + +/** + * \brief The client's data object that is associated with a semantic container + * of entities. + */ +typedef void *CXIdxClientContainer; + +/** + * \brief The client's data object that is associated with an AST file (PCH + * or module). + */ +typedef void *CXIdxClientASTFile; + +/** + * \brief Source location passed to index callbacks. + */ +typedef struct { + void *ptr_data[2]; + unsigned int_data; +} CXIdxLoc; + +/** + * \brief Data for ppIncludedFile callback. + */ +typedef struct { + /** + * \brief Location of '#' in the \#include/\#import directive. + */ + CXIdxLoc hashLoc; + /** + * \brief Filename as written in the \#include/\#import directive. + */ + const char *filename; + /** + * \brief The actual file that the \#include/\#import directive resolved to. + */ + CXFile file; + int isImport; + int isAngled; + /** + * \brief Non-zero if the directive was automatically turned into a module + * import. + */ + int isModuleImport; +} CXIdxIncludedFileInfo; + +/** + * \brief Data for IndexerCallbacks#importedASTFile. + */ +typedef struct { + /** + * \brief Top level AST file containing the imported PCH, module or submodule. + */ + CXFile file; + /** + * \brief The imported module or NULL if the AST file is a PCH. + */ + CXModule module; + /** + * \brief Location where the file is imported. Applicable only for modules. + */ + CXIdxLoc loc; + /** + * \brief Non-zero if an inclusion directive was automatically turned into + * a module import. Applicable only for modules. + */ + int isImplicit; + +} CXIdxImportedASTFileInfo; + +typedef enum { + CXIdxEntity_Unexposed = 0, + CXIdxEntity_Typedef = 1, + CXIdxEntity_Function = 2, + CXIdxEntity_Variable = 3, + CXIdxEntity_Field = 4, + CXIdxEntity_EnumConstant = 5, + + CXIdxEntity_ObjCClass = 6, + CXIdxEntity_ObjCProtocol = 7, + CXIdxEntity_ObjCCategory = 8, + + CXIdxEntity_ObjCInstanceMethod = 9, + CXIdxEntity_ObjCClassMethod = 10, + CXIdxEntity_ObjCProperty = 11, + CXIdxEntity_ObjCIvar = 12, + + CXIdxEntity_Enum = 13, + CXIdxEntity_Struct = 14, + CXIdxEntity_Union = 15, + + CXIdxEntity_CXXClass = 16, + CXIdxEntity_CXXNamespace = 17, + CXIdxEntity_CXXNamespaceAlias = 18, + CXIdxEntity_CXXStaticVariable = 19, + CXIdxEntity_CXXStaticMethod = 20, + CXIdxEntity_CXXInstanceMethod = 21, + CXIdxEntity_CXXConstructor = 22, + CXIdxEntity_CXXDestructor = 23, + CXIdxEntity_CXXConversionFunction = 24, + CXIdxEntity_CXXTypeAlias = 25, + CXIdxEntity_CXXInterface = 26 + +} CXIdxEntityKind; + +typedef enum { + CXIdxEntityLang_None = 0, + CXIdxEntityLang_C = 1, + CXIdxEntityLang_ObjC = 2, + CXIdxEntityLang_CXX = 3 +} CXIdxEntityLanguage; + +/** + * \brief Extra C++ template information for an entity. This can apply to: + * CXIdxEntity_Function + * CXIdxEntity_CXXClass + * CXIdxEntity_CXXStaticMethod + * CXIdxEntity_CXXInstanceMethod + * CXIdxEntity_CXXConstructor + * CXIdxEntity_CXXConversionFunction + * CXIdxEntity_CXXTypeAlias + */ +typedef enum { + CXIdxEntity_NonTemplate = 0, + CXIdxEntity_Template = 1, + CXIdxEntity_TemplatePartialSpecialization = 2, + CXIdxEntity_TemplateSpecialization = 3 +} CXIdxEntityCXXTemplateKind; + +typedef enum { + CXIdxAttr_Unexposed = 0, + CXIdxAttr_IBAction = 1, + CXIdxAttr_IBOutlet = 2, + CXIdxAttr_IBOutletCollection = 3 +} CXIdxAttrKind; + +typedef struct { + CXIdxAttrKind kind; + CXCursor cursor; + CXIdxLoc loc; +} CXIdxAttrInfo; + +typedef struct { + CXIdxEntityKind kind; + CXIdxEntityCXXTemplateKind templateKind; + CXIdxEntityLanguage lang; + const char *name; + const char *USR; + CXCursor cursor; + const CXIdxAttrInfo *const *attributes; + unsigned numAttributes; +} CXIdxEntityInfo; + +typedef struct { + CXCursor cursor; +} CXIdxContainerInfo; + +typedef struct { + const CXIdxAttrInfo *attrInfo; + const CXIdxEntityInfo *objcClass; + CXCursor classCursor; + CXIdxLoc classLoc; +} CXIdxIBOutletCollectionAttrInfo; + +typedef enum { + CXIdxDeclFlag_Skipped = 0x1 +} CXIdxDeclInfoFlags; + +typedef struct { + const CXIdxEntityInfo *entityInfo; + CXCursor cursor; + CXIdxLoc loc; + const CXIdxContainerInfo *semanticContainer; + /** + * \brief Generally same as #semanticContainer but can be different in + * cases like out-of-line C++ member functions. + */ + const CXIdxContainerInfo *lexicalContainer; + int isRedeclaration; + int isDefinition; + int isContainer; + const CXIdxContainerInfo *declAsContainer; + /** + * \brief Whether the declaration exists in code or was created implicitly + * by the compiler, e.g. implicit Objective-C methods for properties. + */ + int isImplicit; + const CXIdxAttrInfo *const *attributes; + unsigned numAttributes; + + unsigned flags; + +} CXIdxDeclInfo; + +typedef enum { + CXIdxObjCContainer_ForwardRef = 0, + CXIdxObjCContainer_Interface = 1, + CXIdxObjCContainer_Implementation = 2 +} CXIdxObjCContainerKind; + +typedef struct { + const CXIdxDeclInfo *declInfo; + CXIdxObjCContainerKind kind; +} CXIdxObjCContainerDeclInfo; + +typedef struct { + const CXIdxEntityInfo *base; + CXCursor cursor; + CXIdxLoc loc; +} CXIdxBaseClassInfo; + +typedef struct { + const CXIdxEntityInfo *protocol; + CXCursor cursor; + CXIdxLoc loc; +} CXIdxObjCProtocolRefInfo; + +typedef struct { + const CXIdxObjCProtocolRefInfo *const *protocols; + unsigned numProtocols; +} CXIdxObjCProtocolRefListInfo; + +typedef struct { + const CXIdxObjCContainerDeclInfo *containerInfo; + const CXIdxBaseClassInfo *superInfo; + const CXIdxObjCProtocolRefListInfo *protocols; +} CXIdxObjCInterfaceDeclInfo; + +typedef struct { + const CXIdxObjCContainerDeclInfo *containerInfo; + const CXIdxEntityInfo *objcClass; + CXCursor classCursor; + CXIdxLoc classLoc; + const CXIdxObjCProtocolRefListInfo *protocols; +} CXIdxObjCCategoryDeclInfo; + +typedef struct { + const CXIdxDeclInfo *declInfo; + const CXIdxEntityInfo *getter; + const CXIdxEntityInfo *setter; +} CXIdxObjCPropertyDeclInfo; + +typedef struct { + const CXIdxDeclInfo *declInfo; + const CXIdxBaseClassInfo *const *bases; + unsigned numBases; +} CXIdxCXXClassDeclInfo; + +/** + * \brief Data for IndexerCallbacks#indexEntityReference. + */ +typedef enum { + /** + * \brief The entity is referenced directly in user's code. + */ + CXIdxEntityRef_Direct = 1, + /** + * \brief An implicit reference, e.g. a reference of an Objective-C method + * via the dot syntax. + */ + CXIdxEntityRef_Implicit = 2 +} CXIdxEntityRefKind; + +/** + * \brief Data for IndexerCallbacks#indexEntityReference. + */ +typedef struct { + CXIdxEntityRefKind kind; + /** + * \brief Reference cursor. + */ + CXCursor cursor; + CXIdxLoc loc; + /** + * \brief The entity that gets referenced. + */ + const CXIdxEntityInfo *referencedEntity; + /** + * \brief Immediate "parent" of the reference. For example: + * + * \code + * Foo *var; + * \endcode + * + * The parent of reference of type 'Foo' is the variable 'var'. + * For references inside statement bodies of functions/methods, + * the parentEntity will be the function/method. + */ + const CXIdxEntityInfo *parentEntity; + /** + * \brief Lexical container context of the reference. + */ + const CXIdxContainerInfo *container; +} CXIdxEntityRefInfo; + +/** + * \brief A group of callbacks used by #clang_indexSourceFile and + * #clang_indexTranslationUnit. + */ +typedef struct { + /** + * \brief Called periodically to check whether indexing should be aborted. + * Should return 0 to continue, and non-zero to abort. + */ + int (*abortQuery)(CXClientData client_data, void *reserved); + + /** + * \brief Called at the end of indexing; passes the complete diagnostic set. + */ + void (*diagnostic)(CXClientData client_data, + CXDiagnosticSet, void *reserved); + + CXIdxClientFile (*enteredMainFile)(CXClientData client_data, + CXFile mainFile, void *reserved); + + /** + * \brief Called when a file gets \#included/\#imported. + */ + CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, + const CXIdxIncludedFileInfo *); + + /** + * \brief Called when a AST file (PCH or module) gets imported. + * + * AST files will not get indexed (there will not be callbacks to index all + * the entities in an AST file). The recommended action is that, if the AST + * file is not already indexed, to initiate a new indexing job specific to + * the AST file. + */ + CXIdxClientASTFile (*importedASTFile)(CXClientData client_data, + const CXIdxImportedASTFileInfo *); + + /** + * \brief Called at the beginning of indexing a translation unit. + */ + CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data, + void *reserved); + + void (*indexDeclaration)(CXClientData client_data, + const CXIdxDeclInfo *); + + /** + * \brief Called to index a reference of an entity. + */ + void (*indexEntityReference)(CXClientData client_data, + const CXIdxEntityRefInfo *); + +} IndexerCallbacks; + +CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind); +CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo * +clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo * +clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE +const CXIdxObjCCategoryDeclInfo * +clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo * +clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo * +clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo * +clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *); + +CINDEX_LINKAGE const CXIdxCXXClassDeclInfo * +clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *); + +/** + * \brief For retrieving a custom CXIdxClientContainer attached to a + * container. + */ +CINDEX_LINKAGE CXIdxClientContainer +clang_index_getClientContainer(const CXIdxContainerInfo *); + +/** + * \brief For setting a custom CXIdxClientContainer attached to a + * container. + */ +CINDEX_LINKAGE void +clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer); + +/** + * \brief For retrieving a custom CXIdxClientEntity attached to an entity. + */ +CINDEX_LINKAGE CXIdxClientEntity +clang_index_getClientEntity(const CXIdxEntityInfo *); + +/** + * \brief For setting a custom CXIdxClientEntity attached to an entity. + */ +CINDEX_LINKAGE void +clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity); + +/** + * \brief An indexing action/session, to be applied to one or multiple + * translation units. + */ +typedef void *CXIndexAction; + +/** + * \brief An indexing action/session, to be applied to one or multiple + * translation units. + * + * \param CIdx The index object with which the index action will be associated. + */ +CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx); + +/** + * \brief Destroy the given index action. + * + * The index action must not be destroyed until all of the translation units + * created within that index action have been destroyed. + */ +CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction); + +typedef enum { + /** + * \brief Used to indicate that no special indexing options are needed. + */ + CXIndexOpt_None = 0x0, + + /** + * \brief Used to indicate that IndexerCallbacks#indexEntityReference should + * be invoked for only one reference of an entity per source file that does + * not also include a declaration/definition of the entity. + */ + CXIndexOpt_SuppressRedundantRefs = 0x1, + + /** + * \brief Function-local symbols should be indexed. If this is not set + * function-local symbols will be ignored. + */ + CXIndexOpt_IndexFunctionLocalSymbols = 0x2, + + /** + * \brief Implicit function/class template instantiations should be indexed. + * If this is not set, implicit instantiations will be ignored. + */ + CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, + + /** + * \brief Suppress all compiler warnings when parsing for indexing. + */ + CXIndexOpt_SuppressWarnings = 0x8, + + /** + * \brief Skip a function/method body that was already parsed during an + * indexing session associated with a \c CXIndexAction object. + * Bodies in system headers are always skipped. + */ + CXIndexOpt_SkipParsedBodiesInSession = 0x10 + +} CXIndexOptFlags; + +/** + * \brief Index the given source file and the translation unit corresponding + * to that file via callbacks implemented through #IndexerCallbacks. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the invoked callbacks. + * + * \param index_callbacks Pointer to indexing callbacks that the client + * implements. + * + * \param index_callbacks_size Size of #IndexerCallbacks structure that gets + * passed in index_callbacks. + * + * \param index_options A bitmask of options that affects how indexing is + * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. + * + * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be + * reused after indexing is finished. Set to \c NULL if you do not require it. + * + * \returns 0 on success or if there were errors from which the compiler could + * recover. If there is a failure from which there is no recovery, returns + * a non-zero \c CXErrorCode. + * + * The rest of the parameters are the same as #clang_parseTranslationUnit. + */ +CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction, + CXClientData client_data, + IndexerCallbacks *index_callbacks, + unsigned index_callbacks_size, + unsigned index_options, + const char *source_filename, + const char * const *command_line_args, + int num_command_line_args, + struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, + CXTranslationUnit *out_TU, + unsigned TU_options); + +/** + * \brief Same as clang_indexSourceFile but requires a full command line + * for \c command_line_args including argv[0]. This is useful if the standard + * library paths are relative to the binary. + */ +CINDEX_LINKAGE int clang_indexSourceFileFullArgv( + CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, + unsigned index_callbacks_size, unsigned index_options, + const char *source_filename, const char *const *command_line_args, + int num_command_line_args, struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); + +/** + * \brief Index the given translation unit via callbacks implemented through + * #IndexerCallbacks. + * + * The order of callback invocations is not guaranteed to be the same as + * when indexing a source file. The high level order will be: + * + * -Preprocessor callbacks invocations + * -Declaration/reference callbacks invocations + * -Diagnostic callback invocations + * + * The parameters are the same as #clang_indexSourceFile. + * + * \returns If there is a failure from which there is no recovery, returns + * non-zero, otherwise returns 0. + */ +CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction, + CXClientData client_data, + IndexerCallbacks *index_callbacks, + unsigned index_callbacks_size, + unsigned index_options, + CXTranslationUnit); + +/** + * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by + * the given CXIdxLoc. + * + * If the location refers into a macro expansion, retrieves the + * location of the macro expansion and if it refers into a macro argument + * retrieves the location of the argument. + */ +CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc, + CXIdxClientFile *indexFile, + CXFile *file, + unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc. + */ +CINDEX_LINKAGE +CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc); + +/** + * \brief Visitor invoked for each field found by a traversal. + * + * This visitor function will be invoked for each field found by + * \c clang_Type_visitFields. Its first argument is the cursor being + * visited, its second argument is the client data provided to + * \c clang_Type_visitFields. + * + * The visitor should return one of the \c CXVisitorResult values + * to direct \c clang_Type_visitFields. + */ +typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C, + CXClientData client_data); + +/** + * \brief Visit the fields of a particular type. + * + * This function visits all the direct fields of the given cursor, + * invoking the given \p visitor function with the cursors of each + * visited field. The traversal may be ended prematurely, if + * the visitor returns \c CXFieldVisit_Break. + * + * \param T the record type whose field may be visited. + * + * \param visitor the visitor function that will be invoked for each + * field of \p T. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the visitor each time it is invoked. + * + * \returns a non-zero value if the traversal was terminated + * prematurely by the visitor returning \c CXFieldVisit_Break. + */ +CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, + CXFieldVisitor visitor, + CXClientData client_data); + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/extra/clang-c/Platform.h b/extra/clang-c/Platform.h new file mode 100644 index 0000000..e2a4dcc --- /dev/null +++ b/extra/clang-c/Platform.h @@ -0,0 +1,45 @@ +/*===-- clang-c/Platform.h - C Index platform decls -------------*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides platform specific macros (dllimport, deprecated, ...) *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_PLATFORM_H +#define LLVM_CLANG_C_PLATFORM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* MSVC DLL import/export. */ +#ifdef _MSC_VER + #ifdef _CINDEX_LIB_ + #define CINDEX_LINKAGE __declspec(dllexport) + #else + #define CINDEX_LINKAGE __declspec(dllimport) + #endif +#else + #define CINDEX_LINKAGE +#endif + +#ifdef __GNUC__ + #define CINDEX_DEPRECATED __attribute__((deprecated)) +#else + #ifdef _MSC_VER + #define CINDEX_DEPRECATED __declspec(deprecated) + #else + #define CINDEX_DEPRECATED + #endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libcycript.py b/libcycript.py new file mode 100755 index 0000000..682e2d1 --- /dev/null +++ b/libcycript.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +import os +import sqlite3 +import sys + +keys = {} + +for db in sys.argv[2:]: + with sqlite3.connect(db) as sql: + c = sql.cursor() + for name, system, value in c.execute('select name, system, value from cache'): + key = (name, value) + keys[key] = keys.get(key, 0) | system + +db = sys.argv[1] +with sqlite3.connect(db) as sql: + many = [] + for key, system in keys.items(): + name, value = key + many.append((name, system, value)) + c = sql.cursor() + c.executemany("insert into cache (name, system, value) values (?, ?, ?)", many) diff --git a/libcycript.sh b/libcycript.sh new file mode 100755 index 0000000..1ff3ace --- /dev/null +++ b/libcycript.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Cycript - Optimizing JavaScript Compiler/Runtime +# Copyright (C) 2009-2015 Jay Freeman (saurik) + +# GNU Affero General Public License, Version 3 {{{ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# }}} + +set -e + +sys=$1 +sql=$2 + +rm -f "${sql}" +echo "create table cache (name text not null, system int not null, value text not null, primary key (name, system));" | sqlite3 "${sql}" + +def=$3 +if [[ -n "${def}" ]]; then + { echo "begin;"; cat "$def"; echo "commit;"; } | sed -e 's/^\([^|]*\)|\"\(.*\)\"$/insert into cache (name, system, value) values (<<\1>>, '"$sys"', <<\2>>);/;s/'"'"'/'"'"''"'"'/g;s/\(<<\|>>\)/'"'"'/g' | sqlite3 "${sql}" +fi diff --git a/m4/ax_prog_cxx_for_build.m4 b/m4/ax_prog_cxx_for_build.m4 new file mode 100644 index 0000000..8cc0f73 --- /dev/null +++ b/m4/ax_prog_cxx_for_build.m4 @@ -0,0 +1,110 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_cxx_for_build.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_CXX_FOR_BUILD +# +# DESCRIPTION +# +# This macro searches for a C++ compiler that generates native +# executables, that is a C++ compiler that surely is not a cross-compiler. +# This can be useful if you have to generate source code at compile-time +# like for example GCC does. +# +# The macro sets the CXX_FOR_BUILD and CXXCPP_FOR_BUILD macros to anything +# needed to compile or link (CXX_FOR_BUILD) and preprocess +# (CXXCPP_FOR_BUILD). The value of these variables can be overridden by +# the user by specifying a compiler with an environment variable (like you +# do for standard CXX). +# +# LICENSE +# +# Copyright (c) 2008 Paolo Bonzini +# Copyright (c) 2012 Avionic Design GmbH +# +# Based on the AX_PROG_CC_FOR_BUILD macro by Paolo Bonzini. +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AU_ALIAS([AC_PROG_CXX_FOR_BUILD], [AX_PROG_CXX_FOR_BUILD]) +AC_DEFUN([AX_PROG_CXX_FOR_BUILD], [dnl +AC_REQUIRE([AX_PROG_CC_FOR_BUILD])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl + +dnl Use the standard macros, but make them use other variable names +dnl +pushdef([ac_cv_prog_CXXCPP], ac_cv_build_prog_CXXCPP)dnl +pushdef([ac_cv_prog_gxx], ac_cv_build_prog_gxx)dnl +pushdef([ac_cv_prog_cxx_works], ac_cv_build_prog_cxx_works)dnl +pushdef([ac_cv_prog_cxx_cross], ac_cv_build_prog_cxx_cross)dnl +pushdef([ac_cv_prog_cxx_g], ac_cv_build_prog_cxx_g)dnl +pushdef([CXX], CXX_FOR_BUILD)dnl +pushdef([CXXCPP], CXXCPP_FOR_BUILD)dnl +pushdef([CXXFLAGS], CXXFLAGS_FOR_BUILD)dnl +pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl +pushdef([CXXCPPFLAGS], CXXCPPFLAGS_FOR_BUILD)dnl +pushdef([host], build)dnl +pushdef([host_alias], build_alias)dnl +pushdef([host_cpu], build_cpu)dnl +pushdef([host_vendor], build_vendor)dnl +pushdef([host_os], build_os)dnl +pushdef([ac_cv_host], ac_cv_build)dnl +pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl +pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl +pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl +pushdef([ac_cv_host_os], ac_cv_build_os)dnl +pushdef([ac_cxxcpp], ac_build_cxxcpp)dnl +pushdef([ac_compile], ac_build_compile)dnl +pushdef([ac_link], ac_build_link)dnl + +save_cross_compiling=$cross_compiling +save_ac_tool_prefix=$ac_tool_prefix +cross_compiling=no +ac_tool_prefix= + +AC_PROG_CXX +AC_PROG_CXXCPP + +ac_tool_prefix=$save_ac_tool_prefix +cross_compiling=$save_cross_compiling + +dnl Restore the old definitions +dnl +popdef([ac_link])dnl +popdef([ac_compile])dnl +popdef([ac_cxxcpp])dnl +popdef([ac_cv_host_os])dnl +popdef([ac_cv_host_vendor])dnl +popdef([ac_cv_host_cpu])dnl +popdef([ac_cv_host_alias])dnl +popdef([ac_cv_host])dnl +popdef([host_os])dnl +popdef([host_vendor])dnl +popdef([host_cpu])dnl +popdef([host_alias])dnl +popdef([host])dnl +popdef([CXXCPPFLAGS])dnl +popdef([CPPFLAGS])dnl +popdef([CXXFLAGS])dnl +popdef([CXXCPP])dnl +popdef([CXX])dnl +popdef([ac_cv_prog_cxx_g])dnl +popdef([ac_cv_prog_cxx_cross])dnl +popdef([ac_cv_prog_cxx_works])dnl +popdef([ac_cv_prog_gxx])dnl +popdef([ac_cv_prog_CXXCPP])dnl + +dnl Finally, set Makefile variables +dnl +AC_SUBST([CXXFLAGS_FOR_BUILD])dnl +AC_SUBST([CXXCPPFLAGS_FOR_BUILD])dnl +]) -- 2.47.2