Skip to content

Commit

Permalink
Merge branch 'master' into fg-default-values
Browse files Browse the repository at this point in the history
  • Loading branch information
Fiel Guhit committed May 28, 2014
2 parents 4bb7a73 + 8854ea2 commit cd7b7a1
Show file tree
Hide file tree
Showing 14 changed files with 422 additions and 156 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
# sh build.sh build
/Realm/*.o
/Realm/*.d
/Realm/*.dylib

# sh build.sh test
*.realm
*.realm.lock
/Realm/Tests/*.o
/Realm/Tests/*.d
build/

# XCode
xcuserdata/
Expand All @@ -22,6 +24,9 @@ DerivedData
/iphone-lib/include
/iphone-lib/librealm-objc-ios.a
/iphone-lib/librealm-objc-ios-dbg.a
Realm/*.dylib
Realm/*.a
Realm/*.libdeps

# sh build.sh ios-framework
/Realm.framework
Expand All @@ -41,4 +46,3 @@ realm-ios-*.zip
# backup and crash files
*.swp
*~

38 changes: 16 additions & 22 deletions Realm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Realm/Realm-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down Expand Up @@ -739,6 +740,7 @@
ENABLE_NS_ASSERTIONS = NO;
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Realm/Realm-Prefix.pch";
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
Expand Down Expand Up @@ -843,17 +845,10 @@
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
src,
"$(SRCROOT)/../tightdb/iphone-lib/include",
);
HEADER_SEARCH_PATHS = "$(SRCROOT)/../tightdb/iphone-lib/include";
INFOPLIST_FILE = "";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
LIBRARY_SEARCH_PATHS = (
/usr/local/lib,
"$(SRCROOT)/../tightdb/iphone-lib",
"/Users/ari/src/tightdb/tightdb/iphone-lib",
);
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../tightdb/iphone-lib";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Realm;
PUBLIC_HEADERS_FOLDER_PATH = "include/$(PROJECT_NAME)";
Expand Down Expand Up @@ -881,17 +876,10 @@
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
src,
"$(SRCROOT)/../tightdb/iphone-lib/include",
);
HEADER_SEARCH_PATHS = "$(SRCROOT)/../tightdb/iphone-lib/include";
INFOPLIST_FILE = "";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
LIBRARY_SEARCH_PATHS = (
/usr/local/lib,
"$(SRCROOT)/../tightdb/iphone-lib",
"/Users/ari/src/tightdb/tightdb/iphone-lib",
);
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../tightdb/iphone-lib";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Realm;
PUBLIC_HEADERS_FOLDER_PATH = "include/$(PROJECT_NAME)";
Expand Down Expand Up @@ -1007,10 +995,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
src,
"$(SRCROOT)/../tightdb/src",
/usr/local/include,
);
LIBRARY_SEARCH_PATHS = /usr/local/lib;
LIBRARY_SEARCH_PATHS = (
"$(SRCROOT)/../tightdb/src/tightdb",
/usr/local/lib,
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
Expand Down Expand Up @@ -1049,10 +1040,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
src,
"$(SRCROOT)/../tightdb/src",
/usr/local/include,
);
LIBRARY_SEARCH_PATHS = /usr/local/lib;
LIBRARY_SEARCH_PATHS = (
"$(SRCROOT)/../tightdb/src/tightdb",
/usr/local/lib,
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
OTHER_CFLAGS = (
"-Wall",
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
@warning This method can only be called during a write transaction.
@param object An object (of the same type as returned from the objectClass selector).
@param anObject An object (of the same type as returned from the objectClass selector).
@param index The array index at which the object is inserted.
*/
- (void)insertObject:(RLMObject *)anObject atIndex:(NSUInteger)index;
Expand Down
39 changes: 20 additions & 19 deletions Realm/RLMArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//
@interface RLMArray ()
@property (nonatomic, assign) tightdb::Query *backingQuery;
// When getting the backingView using dot notation, the tableview is copied in core. Use _backingView instead when accessing.
@property (nonatomic, assign) tightdb::TableView backingView;
@property (nonatomic, copy) NSString *objectClassName;
@end
Expand All @@ -61,7 +62,7 @@ - (instancetype)initWithObjectClassName:(NSString *)objectClassName
if (self) {
self.objectClassName = objectClassName;
self.backingQuery = query;
self.backingView = view;
_backingView = view;
}
return self;
}
Expand Down Expand Up @@ -228,17 +229,17 @@ - (RLMArray *)objectsOrderedBy:(id)order where:(id)predicate, ... {
-(id)minOfProperty:(NSString *)property {
NSUInteger colIndex = RLMValidatedColumnIndex(_realm.schema[_objectClassName], property);

RLMPropertyType colType = RLMPropertyType(self.backingView.get_column_type(colIndex));
RLMPropertyType colType = RLMPropertyType(_backingView.get_column_type(colIndex));

switch (colType) {
case RLMPropertyTypeInt:
return @(self.backingView.minimum_int(colIndex));
return @(_backingView.minimum_int(colIndex));
case RLMPropertyTypeDouble:
return @(self.backingView.minimum_double(colIndex));
return @(_backingView.minimum_double(colIndex));
case RLMPropertyTypeFloat:
return @(self.backingView.minimum_float(colIndex));
return @(_backingView.minimum_float(colIndex));
case RLMPropertyTypeDate: {
tightdb::DateTime dt = self.backingView.minimum_datetime(colIndex);
tightdb::DateTime dt = _backingView.minimum_datetime(colIndex);
return [NSDate dateWithTimeIntervalSince1970:dt.get_datetime()];
}
default:
Expand All @@ -251,17 +252,17 @@ -(id)minOfProperty:(NSString *)property {
-(id)maxOfProperty:(NSString *)property {
NSUInteger colIndex = RLMValidatedColumnIndex(_realm.schema[_objectClassName], property);

RLMPropertyType colType = RLMPropertyType(self.backingView.get_column_type(colIndex));
RLMPropertyType colType = RLMPropertyType(_backingView.get_column_type(colIndex));

switch (colType) {
case RLMPropertyTypeInt:
return @(self.backingView.maximum_int(colIndex));
return @(_backingView.maximum_int(colIndex));
case RLMPropertyTypeDouble:
return @(self.backingView.maximum_double(colIndex));
return @(_backingView.maximum_double(colIndex));
case RLMPropertyTypeFloat:
return @(self.backingView.maximum_float(colIndex));
return @(_backingView.maximum_float(colIndex));
case RLMPropertyTypeDate: {
tightdb::DateTime dt = self.backingView.maximum_datetime(colIndex);
tightdb::DateTime dt = _backingView.maximum_datetime(colIndex);
return [NSDate dateWithTimeIntervalSince1970:dt.get_datetime()];
}
default:
Expand All @@ -274,15 +275,15 @@ -(id)maxOfProperty:(NSString *)property {
-(NSNumber *)sumOfProperty:(NSString *)property {
NSUInteger colIndex = RLMValidatedColumnIndex(_realm.schema[_objectClassName], property);

RLMPropertyType colType = RLMPropertyType(self.backingView.get_column_type(colIndex));
RLMPropertyType colType = RLMPropertyType(_backingView.get_column_type(colIndex));

switch (colType) {
case RLMPropertyTypeInt:
return @(self.backingView.sum_int(colIndex));
return @(_backingView.sum_int(colIndex));
case RLMPropertyTypeDouble:
return @(self.backingView.sum_double(colIndex));
return @(_backingView.sum_double(colIndex));
case RLMPropertyTypeFloat:
return @(self.backingView.sum_float(colIndex));
return @(_backingView.sum_float(colIndex));
default:
@throw [NSException exceptionWithName:@"RLMOperationNotSupportedException"
reason:@"sumOfProperty only supported for int, float and double properties."
Expand All @@ -293,15 +294,15 @@ -(NSNumber *)sumOfProperty:(NSString *)property {
-(NSNumber *)averageOfProperty:(NSString *)property {
NSUInteger colIndex = RLMValidatedColumnIndex(_realm.schema[_objectClassName], property);

RLMPropertyType colType = RLMPropertyType(self.backingView.get_column_type(colIndex));
RLMPropertyType colType = RLMPropertyType(_backingView.get_column_type(colIndex));

switch (colType) {
case RLMPropertyTypeInt:
return @(self.backingView.average_int(colIndex));
return @(_backingView.average_int(colIndex));
case RLMPropertyTypeDouble:
return @(self.backingView.average_double(colIndex));
return @(_backingView.average_double(colIndex));
case RLMPropertyTypeFloat:
return @(self.backingView.average_float(colIndex));
return @(_backingView.average_float(colIndex));
default:
@throw [NSException exceptionWithName:@"RLMOperationNotSupportedException"
reason:@"averageOfProperty only supported fornam int, float and double properties."
Expand Down
26 changes: 13 additions & 13 deletions Realm/RLMObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Initialize an unpersisted instance of this object.
Call addObject: on an RLMRealm to add standalone object to a realm.
@see addObject:
@see [RLMRealm addObject:]:
*/
-(instancetype)init;

Expand Down Expand Up @@ -107,7 +107,7 @@ typedef NS_ENUM(NSUInteger, RLMPropertyAttributes) {
exception will be thrown if no default value for this property is specified. If a default
value is specified it is set upon insertion into a Realm
@see defaultPropertyValues
@see [RLMObject defaultPropertyValues]
*/
RLMPropertyAttributeRequired = 1 << 5,

Expand Down Expand Up @@ -174,17 +174,17 @@ typedef NS_ENUM(NSUInteger, RLMPropertyAttributes) {
@end


/**---------------------------------------------------------------------------------------
* @name RLMArray Property Declaration
* ---------------------------------------------------------------------------------------
*
* Properties on RLMObjects of type RLMArray must have an associated type. A type is associated
* with an RLMArray property by defining a protocol for the object type which the RLMArray will
* hold. To define an protocol for an object you can use the macro RLM_OBJECT_PROTOCOL:
*
* ie. RLM_OBJECT_PROTOCOL(ObjectType)
* \@property RLMArray<ObjectType> *arrayOfObjectTypes;
*/
//---------------------------------------------------------------------------------------
// @name RLMArray Property Declaration
//---------------------------------------------------------------------------------------
//
// Properties on RLMObjects of type RLMArray must have an associated type. A type is associated
// with an RLMArray property by defining a protocol for the object type which the RLMArray will
// hold. To define an protocol for an object you can use the macro RLM_OBJECT_PROTOCOL:
//
// ie. RLM_OBJECT_PROTOCOL(ObjectType)
// \@property RLMArray<ObjectType> *arrayOfObjectTypes;
//
#define RLM_OBJECT_PROTOCOL(RLM_OBJECT_SUBCLASS)\
@protocol RLM_OBJECT_SUBCLASS <NSObject> \
@end
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMObjectSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
Lookup a property object by name.
@param key The properties name.
@param propertyName The properties name.
@return RLMProperty object or nil if there is no property with the given name.
*/
Expand Down
7 changes: 5 additions & 2 deletions Realm/RLMQueryUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@

#import "RLMObjectSchema.h"

extern NSString *const RLMPropertiesComparisonTypeMismatchException;
extern NSString *const RLMUnsupportedTypesFoundInPropertyComparisonException;

// apply the given predicate to the passed in query, returning the updated query
void RLMUpdateQueryWithPredicate(tightdb::Query *query, id predicate, RLMObjectSchema *desc);
void RLMUpdateQueryWithPredicate(tightdb::Query *query, id predicate, RLMObjectSchema *schema);

// apply a sort (column name or NSSortDescriptor) to an existing view
void RLMUpdateViewWithOrder(tightdb::TableView &view, id order, RLMObjectSchema *desc);
void RLMUpdateViewWithOrder(tightdb::TableView &view, id order, RLMObjectSchema *schema);

NSUInteger RLMValidatedColumnIndex(RLMObjectSchema *desc, NSString *columnName);

Expand Down
Loading

0 comments on commit cd7b7a1

Please sign in to comment.