Skip to content

Commit

Permalink
Some *s and &s
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Sep 16, 2020
1 parent 9b51839 commit 5da2be5
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions wrappers/src/object_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,19 @@ extern "C" {
break;
}
case realm::PropertyType::Decimal: {
auto result = object.obj().get<Decimal128>(column_key).raw();
value.value.low_bytes = result->w[0];
value.value2.high_bytes = result->w[1];
auto result = *object.obj().get<Decimal128>(column_key).raw();
value.value.low_bytes = result.w[0];
value.value2.high_bytes = result.w[1];
break;
}
case realm::PropertyType::Decimal | realm::PropertyType::Nullable: {
auto result = object.obj().get<Decimal128>(column_key);
value.has_value = !result.is_null();
value.value.low_bytes = result.is_null() ? 0 : result.raw()->w[0];
value.value2.high_bytes = result.is_null() ? 0 : result.raw()->w[1];
if (value.has_value) {
auto dec = *result.raw();
value.value.low_bytes = dec.w[0];
value.value2.high_bytes = dec.w[1];
}
break;
}
default:
Expand Down Expand Up @@ -277,21 +280,21 @@ extern "C" {
{
return handle_errors(ex, [&] {
verify_can_get(object);

const ObjectSchema& source_object_schema = *object.realm()->schema().find(ObjectStore::object_type_for_table_name(source_table->get_name()));
const Property& source_property = *std::find_if(source_object_schema.persisted_properties.begin(), source_object_schema.persisted_properties.end(), [&](Property p) {
return p.column_key == source_column_key;
});

if (source_property.object_type != object.get_object_schema().name) {
throw std::logic_error(util::format("'%1.%2' is not a relationship to '%3'", source_object_schema.name, source_property.name, object.get_object_schema().name));
}

TableView backlink_view = object.obj().get_backlink_view(source_table, source_column_key);
return new Results(object.realm(), std::move(backlink_view));
});
}

REALM_EXPORT void object_set_link(Object& object, ColKey column_key, const Object& target_object, NativeException::Marshallable& ex)
{
return object_set<ObjKey>(object, column_key, target_object.obj().get_key(), ex);
Expand Down Expand Up @@ -319,7 +322,7 @@ extern "C" {
Utf16StringAccessor str(value, value_len);
return object_set<StringData>(object, column_key, str, ex);
}

REALM_EXPORT void object_set_binary(Object& object, ColKey column_key, char* value, size_t value_len, NativeException::Marshallable& ex)
{
return object_set<BinaryData>(object, column_key, BinaryData(value, value_len), ex);
Expand Down Expand Up @@ -372,12 +375,12 @@ extern "C" {
}, new ObjectSchema(object->get_object_schema()));
});
}

REALM_EXPORT void object_add_int64(Object& object, ColKey column_key, int64_t value, NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
verify_can_set(object);

object.obj().add_int(column_key, value);
});
}
Expand Down

0 comments on commit 5da2be5

Please sign in to comment.