Tuukka Norri avatar Tuukka Norri committed 841bb5e

ABI changes, strict assertions
- Changed PGTS_EXPORT to BX_INTERNAL in most places.
- BX_INTERNAL will add __attribute__((visibility("hidden"))) to the symbols.
- Added version number to BX_DEPRECATED.
- Marked BXSetLogLevel deprecated; the replacement is BXLogSetLevel.
- BXLogger can now be set to abort() on assertion failure.
- Unit tests now use this functionality.

Comments (0)

Files changed (12)

Sources/BXDatabaseContext.h

 - (NSArray *) objectIDsForEntity: (BXEntityDescription *) anEntity error: (NSError **) error;
 - (NSArray *) objectIDsForEntity: (BXEntityDescription *) anEntity predicate: (NSPredicate *) predicate error: (NSError **) error;
 
-- (BOOL) canGiveEntities BX_DEPRECATED;
-- (BXEntityDescription *) entityForTable: (NSString *) tableName inSchema: (NSString *) schemaName error: (NSError **) error BX_DEPRECATED;
-- (BXEntityDescription *) entityForTable: (NSString *) tableName error: (NSError **) error BX_DEPRECATED;
-- (NSDictionary *) entitiesBySchemaAndName: (BOOL) reload error: (NSError **) error BX_DEPRECATED;
+- (BOOL) canGiveEntities BX_DEPRECATED_IN_1_8;
+- (BXEntityDescription *) entityForTable: (NSString *) tableName inSchema: (NSString *) schemaName error: (NSError **) error BX_DEPRECATED_IN_1_8;
+- (BXEntityDescription *) entityForTable: (NSString *) tableName error: (NSError **) error BX_DEPRECATED_IN_1_8;
+- (NSDictionary *) entitiesBySchemaAndName: (BOOL) reload error: (NSError **) error BX_DEPRECATED_IN_1_8;
 
-- (BOOL) entity: (NSEntityDescription *) entity existsInSchema: (NSString *) schemaName error: (NSError **) error BX_DEPRECATED;
-- (BXEntityDescription *) matchingEntity: (NSEntityDescription *) entity inSchema: (NSString *) schemaName error: (NSError **) error BX_DEPRECATED;
+- (BOOL) entity: (NSEntityDescription *) entity existsInSchema: (NSString *) schemaName error: (NSError **) error BX_DEPRECATED_IN_1_8;
+- (BXEntityDescription *) matchingEntity: (NSEntityDescription *) entity inSchema: (NSString *) schemaName error: (NSError **) error BX_DEPRECATED_IN_1_8;
 @end
 
 

Sources/BXDatabaseObjectID.h

  primaryKeyFields: (NSDictionary **) outPkeyDict;
 
 - (id) initWithURI: (NSURL *) anURI context: (BXDatabaseContext *) context;
-- (id) initWithURI: (NSURL *) anURI context: (BXDatabaseContext *) context error: (NSError **) error BX_DEPRECATED;
+- (id) initWithURI: (NSURL *) anURI context: (BXDatabaseContext *) context error: (NSError **) error BX_DEPRECATED_IN_1_8;
 - (NSURL *) URIRepresentation;
 
 - (BXEntityDescription *) entity;

Sources/BXExport.h

 //
 
 
-//FIXME: change this to private_extern?
-#ifndef PGTS_EXPORT
+#ifndef BX_INTERNAL
 #ifdef __cplusplus
-#define PGTS_EXPORT extern "C"
+#define BX_INTERNAL extern "C" __attribute__((visibility("hidden")))
 #else
-#define PGTS_EXPORT extern
+#define BX_INTERNAL extern     __attribute__((visibility("hidden")))
 #endif
 #endif
 
 
 #ifndef BX_EXPORT
 #ifdef __cplusplus
-#define BX_EXPORT extern "C"
+#define BX_EXPORT extern "C"   __attribute__((visibility("default")))
 #else
-#define BX_EXPORT extern
+#define BX_EXPORT extern       __attribute__((visibility("default")))
 #endif
 #endif
 
 
-#define BX_DEPRECATED DEPRECATED_ATTRIBUTE
+#define BX_DEPRECATED_IN_1_8 DEPRECATED_ATTRIBUTE

Sources/BXLogger.h

 	kBXLogLevelDebug    /**< Debugging information */
 };
 
-//Do not use outside this file in case we decide to change the implementation.
+// Do not use outside this file in case we decide to change the implementation.
+// The symbol is also needed by BaseTenAppKit.
 BX_EXPORT enum BXLogLevel BXLogLevel;
 
 
  *
  * \warning This function is not thread-safe.
  */
-BX_EXPORT void BXSetLogLevel (enum BXLogLevel level);
+BX_EXPORT void BXLogSetLevel (enum BXLogLevel level);
+BX_EXPORT void BXSetLogLevel (enum BXLogLevel level) BX_DEPRECATED_IN_1_8;
+
+/**
+ * \brief
+ * Set whether the logger should call abort() on assertion failure
+ *
+ * \warning This function is not thread-safe.
+ */
+BX_EXPORT void BXLogSetAbortsOnAssertionFailure (BOOL);
 
 
 /**

Sources/BXLogger.m

 #import <unistd.h>
 
 enum BXLogLevel BXLogLevel = kBXLogLevelWarning;
+static BOOL stAbortOnAssertionFailure = NO;
 
 
 void BXSetLogLevel (enum BXLogLevel level)
 {
+	BXDeprecationLog ();
 	BXLogLevel = level;
 }
 
+
+void BXLogSetLevel (enum BXLogLevel level)
+{
+	BXLogLevel = level;
+}
+
+
+void BXLogSetAbortsOnAssertionFailure (BOOL flag)
+{
+	stAbortOnAssertionFailure = flag;
+}
+
+
 static inline const char* LogLevel (enum BXLogLevel level)
 {
 	char* retval = NULL;
 
 void BXAssertionDebug ()
 {
-	BXLogError (@"Break on BXAssertionDebug to inspect.");
+	if (stAbortOnAssertionFailure)
+		abort ();
+	else
+		BXLogError (@"Break on BXAssertionDebug to inspect.");
 }
 
 void

Sources/NSString+PGTSAdditions.h

 
 @class PGTSConnection;
 
-PGTS_EXPORT char *PGTSCopyEscapedString (PGTSConnection *, const char *);
-PGTS_EXPORT NSString *PGTSReformatErrorMessage (NSString* message);
+BX_INTERNAL char *PGTSCopyEscapedString (PGTSConnection *, const char *);
+BX_INTERNAL NSString *PGTSReformatErrorMessage (NSString* message);
 
 @interface NSString (PGTSAdditions)
 - (NSString *) escapeForPGTSConnection: (PGTSConnection *) connection;

Sources/PGTSCFScannedMemoryAllocator.h

 #import <BaseTen/BXExport.h>
 
 
-PGTS_EXPORT CFAllocatorRef PGTSScannedMemoryAllocator ();
-PGTS_EXPORT CFSetCallBacks PGTSScannedSetCallbacks ();
+BX_INTERNAL CFAllocatorRef PGTSScannedMemoryAllocator ();
+BX_INTERNAL CFSetCallBacks PGTSScannedSetCallbacks ();

Sources/PGTSConstants.h

 #import <Foundation/Foundation.h>
 #import <BaseTen/BXExport.h>
 
+// Some of the following symbols are used in the unit tests,
+// which is why they have been exported.
+
 
 #define kPGTSPUBLICOid InvalidOid
 
 
-PGTS_EXPORT NSDictionary* kPGTSDefaultConnectionDictionary;
+BX_INTERNAL NSDictionary* kPGTSDefaultConnectionDictionary;
 
-PGTS_EXPORT NSString* const kPGTSHostKey;
-PGTS_EXPORT NSString* const kPGTSHostAddressKey;
-PGTS_EXPORT NSString* const kPGTSPortKey;
-PGTS_EXPORT NSString* const kPGTSDatabaseNameKey;
-PGTS_EXPORT NSString* const kPGTSUserNameKey;
-PGTS_EXPORT NSString* const kPGTSPasswordKey;
-PGTS_EXPORT NSString* const kPGTSConnectTimeoutKey;
-PGTS_EXPORT NSString* const kPGTSOptionsKey;
-PGTS_EXPORT NSString* const kPGTSSSLModeKey;
-PGTS_EXPORT NSString* const kPGTSServiceNameKey;
-PGTS_EXPORT NSArray* kPGTSConnectionDictionaryKeys;
+BX_EXPORT   NSString* const kPGTSHostKey;
+BX_INTERNAL NSString* const kPGTSHostAddressKey;
+BX_INTERNAL NSString* const kPGTSPortKey;
+BX_EXPORT   NSString* const kPGTSDatabaseNameKey;
+BX_EXPORT   NSString* const kPGTSUserNameKey;
+BX_INTERNAL NSString* const kPGTSPasswordKey;
+BX_INTERNAL NSString* const kPGTSConnectTimeoutKey;
+BX_INTERNAL NSString* const kPGTSOptionsKey;
+BX_EXPORT   NSString* const kPGTSSSLModeKey;
+BX_INTERNAL NSString* const kPGTSServiceNameKey;
+BX_INTERNAL NSArray* kPGTSConnectionDictionaryKeys;
 
-PGTS_EXPORT NSString* const kPGTSRetrievedResultNotification;
-PGTS_EXPORT NSString* const kPGTSBackendPIDKey;
-PGTS_EXPORT NSString* const kPGTSNotificationNameKey;
-PGTS_EXPORT NSString* const kPGTSNotificationExtraKey;
-PGTS_EXPORT NSString* const kPGTSWillDisconnectNotification;
-PGTS_EXPORT NSString* const kPGTSDidDisconnectNotification;
-PGTS_EXPORT NSString* const kPGTSNotice;
-PGTS_EXPORT NSString* const kPGTSNoticeMessageKey;
-PGTS_EXPORT NSString* const kPGTSConnectionPoolItemDidRemoveConnectionNotification;
-PGTS_EXPORT NSString* const kPGTSConnectionPoolItemDidAddConnectionNotification;
-PGTS_EXPORT NSString* const kPGTSRowKey;
-PGTS_EXPORT NSString* const kPGTSRowsKey;
-PGTS_EXPORT NSString* const kPGTSTableKey;
+BX_INTERNAL NSString* const kPGTSRetrievedResultNotification;
+BX_INTERNAL NSString* const kPGTSBackendPIDKey;
+BX_INTERNAL NSString* const kPGTSNotificationNameKey;
+BX_INTERNAL NSString* const kPGTSNotificationExtraKey;
+BX_INTERNAL NSString* const kPGTSWillDisconnectNotification;
+BX_INTERNAL NSString* const kPGTSDidDisconnectNotification;
+BX_INTERNAL NSString* const kPGTSNotice;
+BX_INTERNAL NSString* const kPGTSNoticeMessageKey;
+BX_INTERNAL NSString* const kPGTSConnectionPoolItemDidRemoveConnectionNotification;
+BX_INTERNAL NSString* const kPGTSConnectionPoolItemDidAddConnectionNotification;
+BX_INTERNAL NSString* const kPGTSRowKey;
+BX_INTERNAL NSString* const kPGTSRowsKey;
+BX_INTERNAL NSString* const kPGTSTableKey;
 
-PGTS_EXPORT NSString* const kPGTSConnectionKey;
-PGTS_EXPORT NSString* const kPGTSConnectionDelegateKey;
+BX_INTERNAL NSString* const kPGTSConnectionKey;
+BX_INTERNAL NSString* const kPGTSConnectionDelegateKey;
 
-PGTS_EXPORT NSString* const kPGTSFieldnameKey;
-PGTS_EXPORT NSString* const kPGTSFieldKey;
-PGTS_EXPORT NSString* const kPGTSValueKey;
-PGTS_EXPORT NSString* const kPGTSRowIndexKey;
-PGTS_EXPORT NSString* const kPGTSResultSetKey;
-PGTS_EXPORT NSString* const kPGTSDataSourceKey;
+BX_INTERNAL NSString* const kPGTSFieldnameKey;
+BX_INTERNAL NSString* const kPGTSFieldKey;
+BX_INTERNAL NSString* const kPGTSValueKey;
+BX_INTERNAL NSString* const kPGTSRowIndexKey;
+BX_INTERNAL NSString* const kPGTSResultSetKey;
+BX_INTERNAL NSString* const kPGTSDataSourceKey;
 
-PGTS_EXPORT NSString* const kPGTSNoKeyFieldsException;
-PGTS_EXPORT NSString* const kPGTSNoKeyFieldException;
-PGTS_EXPORT NSString* const kPGTSFieldNotFoundException;
-PGTS_EXPORT NSString* const kPGTSNoPrimaryKeyException;
-PGTS_EXPORT NSString* const kPGTSQueryFailedException;
-PGTS_EXPORT NSString* const kPGTSConnectionFailedException;
+BX_INTERNAL NSString* const kPGTSNoKeyFieldsException;
+BX_INTERNAL NSString* const kPGTSNoKeyFieldException;
+BX_INTERNAL NSString* const kPGTSFieldNotFoundException;
+BX_INTERNAL NSString* const kPGTSNoPrimaryKeyException;
+BX_INTERNAL NSString* const kPGTSQueryFailedException;
+BX_INTERNAL NSString* const kPGTSConnectionFailedException;
 
-PGTS_EXPORT NSString* const kPGTSModificationNameKey;
-PGTS_EXPORT NSString* const kPGTSInsertModification;
-PGTS_EXPORT NSString* const kPGTSUpdateModification;
-PGTS_EXPORT NSString* const kPGTSDeleteModification;
+BX_INTERNAL NSString* const kPGTSModificationNameKey;
+BX_INTERNAL NSString* const kPGTSInsertModification;
+BX_INTERNAL NSString* const kPGTSUpdateModification;
+BX_INTERNAL NSString* const kPGTSDeleteModification;
 
-PGTS_EXPORT NSString* const kPGTSLockedForUpdate;
-PGTS_EXPORT NSString* const kPGTSLockedForDelete;
-PGTS_EXPORT NSString* const kPGTSUnlockedRowsNotification;
-PGTS_EXPORT NSString* const kPGTSRowShareLock;
+BX_INTERNAL NSString* const kPGTSLockedForUpdate;
+BX_INTERNAL NSString* const kPGTSLockedForDelete;
+BX_INTERNAL NSString* const kPGTSUnlockedRowsNotification;
+BX_INTERNAL NSString* const kPGTSRowShareLock;
 
-PGTS_EXPORT NSString* const kPGTSUnsupportedPredicateOperatorTypeException;
-PGTS_EXPORT NSString* const kPGTSParametersKey;
-PGTS_EXPORT NSString* const kPGTSParameterIndexKey;
-PGTS_EXPORT NSString* const kPGTSExpressionParametersVerbatimKey;
+BX_INTERNAL NSString* const kPGTSUnsupportedPredicateOperatorTypeException;
+BX_INTERNAL NSString* const kPGTSParametersKey;
+BX_INTERNAL NSString* const kPGTSParameterIndexKey;
+BX_INTERNAL NSString* const kPGTSExpressionParametersVerbatimKey;
 
-PGTS_EXPORT NSString* const kPGTSErrorSeverity;
-PGTS_EXPORT NSString* const kPGTSErrorSQLState;
-PGTS_EXPORT NSString* const kPGTSErrorPrimaryMessage;
-PGTS_EXPORT NSString* const kPGTSErrorDetailMessage;
-PGTS_EXPORT NSString* const kPGTSErrorHint;
-PGTS_EXPORT NSString* const kPGTSErrorInternalQuery;
-PGTS_EXPORT NSString* const kPGTSErrorContext;
-PGTS_EXPORT NSString* const kPGTSErrorSourceFile;
-PGTS_EXPORT NSString* const kPGTSErrorSourceFunction;
-PGTS_EXPORT NSString* const kPGTSErrorStatementPosition;
-PGTS_EXPORT NSString* const kPGTSErrorInternalPosition;
-PGTS_EXPORT NSString* const kPGTSErrorSourceLine;
-PGTS_EXPORT NSString* const kPGTSErrorMessage;
-PGTS_EXPORT NSString* const kPGTSSSLAttemptedKey;
+BX_INTERNAL NSString* const kPGTSErrorSeverity;
+BX_INTERNAL NSString* const kPGTSErrorSQLState;
+BX_INTERNAL NSString* const kPGTSErrorPrimaryMessage;
+BX_INTERNAL NSString* const kPGTSErrorDetailMessage;
+BX_INTERNAL NSString* const kPGTSErrorHint;
+BX_INTERNAL NSString* const kPGTSErrorInternalQuery;
+BX_INTERNAL NSString* const kPGTSErrorContext;
+BX_INTERNAL NSString* const kPGTSErrorSourceFile;
+BX_INTERNAL NSString* const kPGTSErrorSourceFunction;
+BX_INTERNAL NSString* const kPGTSErrorStatementPosition;
+BX_INTERNAL NSString* const kPGTSErrorInternalPosition;
+BX_INTERNAL NSString* const kPGTSErrorSourceLine;
+BX_INTERNAL NSString* const kPGTSErrorMessage;
+BX_INTERNAL NSString* const kPGTSSSLAttemptedKey;
     
 
-PGTS_EXPORT NSString* const kPGTSErrorDomain;
-PGTS_EXPORT NSString* const kPGTSConnectionErrorDomain;
+BX_INTERNAL NSString* const kPGTSErrorDomain;
+BX_INTERNAL NSString* const kPGTSConnectionErrorDomain;
 enum PGTSErrors
 {
     kPGTSUnsuccessfulQueryError = 1

Sources/PGTSDeleteRule.h

 #import <BaseTen/BXExport.h>
 #import <Foundation/Foundation.h>
 
-PGTS_EXPORT enum PGTSDeleteRule PGTSDeleteRule (const unichar rule);
+BX_INTERNAL enum PGTSDeleteRule PGTSDeleteRule (const unichar rule);

Sources/PGTSOids.h

 #import <BaseTen/BXExport.h>
 #import <BaseTen/libpq-fe.h>
 
-PGTS_EXPORT id PGTSOidAsObject (Oid o);
+BX_INTERNAL id PGTSOidAsObject (Oid o);
 
 @interface NSNumber (PGTSOidAdditions)
 - (Oid) PGTSOidValue;

Sources/libpq_additions.h

 #import <BaseTen/BXExport.h>
 
 
-PGTS_EXPORT const char* pq_ssl_mode (const PGconn* connection);
+BX_INTERNAL const char* pq_ssl_mode (const PGconn* connection);

UnitTests/Sources/TestLoader.m

 @implementation BXTestLoader
 - (void) test
 {
-	BXSetLogLevel (kBXLogLevelWarning);
+	BXLogSetLevel (kBXLogLevelWarning);
+	BXLogSetAbortsOnAssertionFailure (YES);
 	
 	NSArray* testClasses = [NSArray arrayWithObjects:
 							[PGTSInvocationRecorderTests class],
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.