Skip to content

Commit

Permalink
private Realm.Private module
Browse files Browse the repository at this point in the history
Conflicts:
	Realm/RLMSwiftBridgingHeader.h
	Realm/RealmSwift/Aliases.swift
	Realm/RealmSwift/List.swift
	Realm/RealmSwift/Object.swift
	Realm/RealmSwift/Property.swift
	Realm/RealmSwift/Realm.swift
	Realm/RealmSwift/Results.swift
  • Loading branch information
alazier committed Jan 30, 2015
1 parent 022eaf6 commit b8e2074
Show file tree
Hide file tree
Showing 26 changed files with 125 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Realm/RLMAccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

#import <Foundation/Foundation.h>
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"

@class RLMObjectSchema, RLMProperty, RLMObjectBase;

Expand Down
7 changes: 4 additions & 3 deletions Realm/RLMAccessor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMObject_Private.h"
#import "RLMProperty_Private.h"
#import "RLMRealm_Private.hpp"
#import "RLMObject_Private.hpp"
#import "RLMArray_Private.hpp"
#import "RLMProperty_Private.h"
#import "RLMUtil.hpp"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"

#import <objc/runtime.h>

Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

#import <Foundation/Foundation.h>
#import <Realm/RLMCollection.h>
#import "RLMCollection.h"

@class RLMObject, RLMRealm, RLMResults;

Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#import "RLMObject.h"
#import "RLMObjectSchema.h"
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"
#import "RLMQueryUtil.hpp"
#import "RLMSwiftSupport.h"
#import "RLMUtil.hpp"
Expand Down
10 changes: 5 additions & 5 deletions Realm/RLMArrayLinkView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
////////////////////////////////////////////////////////////////////////////

#import "RLMArray_Private.hpp"
#import "RLMConstants.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObjectStore.hpp"
#import "RLMObject_Private.h"
#import "RLMProperty_Private.h"
#import "RLMObject_Private.hpp"
#import "RLMQueryUtil.hpp"
#import "RLMRealm_Private.hpp"
#import "RLMObjectSchema_Private.hpp"
#import "RLMProperty_Private.h"
#import "RLMObjectStore.h"
#import "RLMConstants.h"
#import "RLMSchema.h"
#import "RLMUtil.hpp"

Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMMigration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#import "RLMSchema_Private.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObject_Private.h"
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"
#import "RLMArray.h"
#import "RLMUtil.hpp"

Expand Down
3 changes: 2 additions & 1 deletion Realm/RLMObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMRealm_Private.hpp"
#import "RLMObject_Private.h"
#import "RLMSchema_Private.h"
#import "RLMProperty_Private.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"
#import "RLMQueryUtil.hpp"
#import "RLMUtil.hpp"
#import "RLMSwiftSupport.h"
Expand Down
10 changes: 6 additions & 4 deletions Realm/RLMObjectBase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMObject_Private.h"

#import "RLMRealm_Private.hpp"
#import "RLMObject_Private.hpp"
#import "RLMSchema_Private.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObjectStore.hpp"
#import "RLMProperty_Private.h"

#import "RLMObjectStore.h"
#import "RLMSwiftSupport.h"
#import "RLMUtil.hpp"

Expand Down Expand Up @@ -263,4 +265,4 @@ - (NSUInteger)hash {
}
}

@end
@end
5 changes: 3 additions & 2 deletions Realm/RLMObjectSchema.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMRealm_Private.hpp"
#import "RLMArray.h"
#import "RLMListBase.h"
#import "RLMObjectSchema_Private.hpp"
Expand Down Expand Up @@ -97,7 +98,7 @@ + (instancetype)schemaForObjectClass:(Class)objectClass {
schema.objectClass = objectClass;
schema.accessorClass = RLMObject.class;
schema.isSwiftClass = isSwift;

// create array of RLMProperties, inserting properties of superclasses first
Class cls = objectClass;
Class superClass = class_getSuperclass(cls);
Expand Down Expand Up @@ -195,7 +196,7 @@ +(instancetype)schemaFromTableForClassName:(NSString *)className realm:(RLMRealm
if (!table) {
return nil;
}

// create array of RLMProperties
size_t count = table->get_column_count();
NSMutableArray *propArray = [NSMutableArray arrayWithCapacity:count];
Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMObjectStore.hpp → Realm/RLMObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

#import <Foundation/Foundation.h>

@class RLMRealm, RLMSchema, RLMObjectSchema, RLMObjectBase, RLMResults;

#ifdef __cplusplus
extern "C" {
#endif

@class RLMRealm, RLMSchema, RLMObjectSchema, RLMObjectBase, RLMResults;

//
// Table modifications
Expand Down Expand Up @@ -100,6 +99,7 @@ RLMObjectBase *RLMCreateObjectAccessor(__unsafe_unretained RLMRealm *realm,
__unsafe_unretained RLMObjectSchema *objectSchema,
NSUInteger index);


#ifdef __cplusplus
}
#endif
6 changes: 3 additions & 3 deletions Realm/RLMObjectStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"

#import "RLMArray_Private.hpp"
#import "RLMListBase.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObject_Private.h"
#import "RLMObject_Private.hpp"
#import "RLMRealm_Private.hpp"
#import "RLMProperty_Private.h"
#import "RLMQueryUtil.hpp"
#import "RLMRealm_Private.hpp"
#import "RLMUtil.hpp"

#import <objc/message.h>
Expand Down
3 changes: 0 additions & 3 deletions Realm/RLMObject_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMRealm_Private.hpp"
#import "RLMObject.h"
#import "RLMObjectSchema.h"
#import <tightdb/row.hpp>

// RLMObject accessor and read/write realm
@interface RLMObjectBase () {
@public
tightdb::Row _row;
RLMRealm *_realm;
// objectSchema is a cached pointer to an object stored in the RLMSchema
// owned by _realm, so it's guaranteed to stay alive as long as this object
Expand Down
30 changes: 30 additions & 0 deletions Realm/RLMObject_Private.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#import "RLMObject_Private.h"

#import <tightdb/row.hpp>

// RLMObject accessor and read/write realm
@interface RLMObjectBase () {
@public
tightdb::Row _row;
}

@end

3 changes: 1 addition & 2 deletions Realm/RLMProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
////////////////////////////////////////////////////////////////////////////

#import <Foundation/Foundation.h>
#import <Realm/RLMConstants.h>
#import <Realm/RLMObject.h>
#import "RLMConstants.h"

/**
This class models properties persisted to Realm in an RLMObjectSchema.
Expand Down
2 changes: 2 additions & 0 deletions Realm/RLMProperty_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#import "RLMProperty.h"
#import <objc/runtime.h>

@class RLMObjectBase;

// private property interface
@interface RLMProperty ()

Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMQueryUtil.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import "RLMQueryUtil.hpp"
#import "RLMArray.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObject_Private.h"
#import "RLMObject_Private.hpp"
#import "RLMProperty_Private.h"
#import "RLMUtil.hpp"

Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMRealm.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#import "RLMArray_Private.hpp"
#import "RLMMigration_Private.h"
#import "RLMConstants.h"
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMQueryUtil.hpp"
#import "RLMUpdateChecker.hpp"
Expand Down
35 changes: 35 additions & 0 deletions Realm/RLMRealm_Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#import "RLMRealm_Dynamic.h"

// RLMRealm private members
@interface RLMRealm () {
@public
// expose ivar to to avoid objc messages in accessors
BOOL _inWriteTransaction;
mach_port_t _threadID;
}
@property (nonatomic, readonly) BOOL inWriteTransaction;
@property (nonatomic, readonly) BOOL dynamic;
@property (nonatomic, readwrite) RLMSchema *schema;

+ (void)resetRealmState;

- (instancetype)initWithPath:(NSString *)path key:(NSData *)key readOnly:(BOOL)readonly inMemory:(BOOL)inMemory error:(NSError **)error;
@end
17 changes: 3 additions & 14 deletions Realm/RLMRealm_Private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

extern "C" {
#import "RLMRealm_Dynamic.h"
#import "RLMRealm_Private.h"
#import "RLMSchema_Private.h"
#import "RLMAccessor.h"
}
Expand All @@ -27,23 +27,12 @@ extern "C" {
#import <tightdb/link_view.hpp>
#import <tightdb/group.hpp>

// RLMRealm private members
@interface RLMRealm () {
@public
// expose ivar to to avoid objc messages in accessors
BOOL _inWriteTransaction;
mach_port_t _threadID;
}
@property (nonatomic, readonly) BOOL inWriteTransaction;
@property (nonatomic, readonly) BOOL dynamic;
@interface RLMRealm ()
@property (nonatomic, readonly, getter=getOrCreateGroup) tightdb::Group *group;
@property (nonatomic, readwrite) RLMSchema *schema;

- (instancetype)initWithPath:(NSString *)path key:(NSData *)key readOnly:(BOOL)readonly inMemory:(BOOL)inMemory dynamic:(BOOL)dynamic error:(NSError **)error;
@end

// throw an exception if the realm is being used from the wrong thread
inline void RLMCheckThread(__unsafe_unretained RLMRealm *realm) {
static inline void RLMCheckThread(__unsafe_unretained RLMRealm *realm) {
if (realm->_threadID != pthread_mach_thread_np(pthread_self())) {
@throw RLMException(@"Realm accessed from incorrect thread");
}
Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMResults.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMObject_Private.h"
#import "RLMObject_Private.hpp"
#import "RLMArray_Private.hpp"
#import "RLMRealm_Private.hpp"
#import "RLMSchema_Private.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObjectStore.hpp"
#import "RLMObjectStore.h"
#import "RLMQueryUtil.hpp"
#import "RLMConstants.h"
#import "RLMUtil.hpp"
Expand Down
5 changes: 2 additions & 3 deletions Realm/Tests/DynamicTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
////////////////////////////////////////////////////////////////////////////

#import "RLMTestCase.h"
#import "RLMSchema.h"
#import "RLMRealm_Dynamic.h"
#import "RLMSchema_Private.h"

@import Realm.Private;

@interface DynamicTests : RLMTestCase
@end
Expand Down
6 changes: 0 additions & 6 deletions Realm/Tests/ObjectTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ @interface DataObject : RLMObject
@implementation DataObject
@end

#pragma mark - Private

@interface RLMRealm ()
@property (nonatomic) RLMSchema *schema;
@end

#pragma mark - Tests

@interface ObjectTests : RLMTestCase
Expand Down
1 change: 0 additions & 1 deletion Realm/Tests/RLMTestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
////////////////////////////////////////////////////////////////////////////

#import <XCTest/XCTest.h>
#import <Realm/Realm.h>
#import "RLMTestObjects.h"

#ifdef __cplusplus
Expand Down
7 changes: 3 additions & 4 deletions Realm/Tests/Swift/Swift-Tests-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

#import <Realm/Realm.h>

#import "RLMSwiftBridgingHeader.h"
#import "RLMTestObjects.h"
#import "RLMRealm_Dynamic.h"



1 change: 1 addition & 0 deletions Realm/Tests/Swift/SwiftTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import XCTest
import Realm
import Realm.Private

func testRealmPath() -> String {
return realmPathForFile("test.realm")
Expand Down
Loading

0 comments on commit b8e2074

Please sign in to comment.