Bug 1649121: part 9) Simplify `GetMostAncestorListOrTableElement`. r=masayuki
[gecko.git] / storage / Variant.cpp
blob1c0d91b958453d3bd97892249bbd0913f32e7043
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "Variant.h"
9 extern "C" {
11 using namespace mozilla::storage;
13 /**
14 * Return the data type of the given variant. This method used to be exposed
15 * to XPCOM, but since bug 1507540 it's marked [notxpcom] in the interface
16 * definition, so we need this C function to access it from Rust.
18 uint16_t NS_GetDataType(nsIVariant* aVariant) {
19 return aVariant->GetDataType();
22 // Convenience functions to create Storage variants from Rust.
23 void NS_NewStorageNullVariant(nsIVariant** aVariant) {
24 nsCOMPtr<nsIVariant> variant = new NullVariant();
25 variant.forget(aVariant);
28 void NS_NewStorageBooleanVariant(bool aValue, nsIVariant** aVariant) {
29 nsCOMPtr<nsIVariant> variant = new BooleanVariant(aValue);
30 variant.forget(aVariant);
33 void NS_NewStorageIntegerVariant(int64_t aValue, nsIVariant** aVariant) {
34 nsCOMPtr<nsIVariant> variant = new IntegerVariant(aValue);
35 variant.forget(aVariant);
38 void NS_NewStorageFloatVariant(double aValue, nsIVariant** aVariant) {
39 nsCOMPtr<nsIVariant> variant = new FloatVariant(aValue);
40 variant.forget(aVariant);
43 void NS_NewStorageTextVariant(const nsAString& aValue, nsIVariant** aVariant) {
44 nsCOMPtr<nsIVariant> variant = new TextVariant(aValue);
45 variant.forget(aVariant);
48 void NS_NewStorageUTF8TextVariant(const nsACString& aValue,
49 nsIVariant** aVariant) {
50 nsCOMPtr<nsIVariant> variant = new UTF8TextVariant(aValue);
51 variant.forget(aVariant);
54 } // extern "C"