2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
20 using Tizen.Applications;
22 internal static partial class Interop
24 internal static partial class Bundle
26 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
27 internal delegate void Iterator(string key, int type, IntPtr keyval, IntPtr userData);
29 [DllImport(Libraries.Bundle, EntryPoint = "bundle_create")]
30 internal static extern SafeBundleHandle Create();
32 [DllImport(Libraries.Bundle, EntryPoint = "bundle_free")]
33 internal static extern int DangerousFree(IntPtr handle);
35 [DllImport(Libraries.Bundle, EntryPoint = "bundle_del")]
36 internal static extern int RemoveItem(SafeBundleHandle handle, string key);
38 [DllImport(Libraries.Bundle, EntryPoint = "bundle_add_str")]
39 internal static extern int AddString(SafeBundleHandle handle, string key, string value);
41 [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_type")]
42 internal static extern int GetType(SafeBundleHandle handle, string key);
44 [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_str")]
45 internal static extern int GetString(SafeBundleHandle handle, string key, out IntPtr value);
47 [DllImport(Libraries.Bundle, EntryPoint = "bundle_add_byte")]
48 internal static extern unsafe int AddByte(SafeBundleHandle handle, string key, byte* value, int size);
50 [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_byte")]
51 internal static extern int GetByte(SafeBundleHandle handle, string key, out IntPtr value, out int size);
53 [DllImport(Libraries.Bundle, EntryPoint = "bundle_add_str_array")]
54 internal static extern int AddStringArray(SafeBundleHandle handle, string key, string[] value, int size);
56 [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_str_array")]
57 internal static extern IntPtr GetStringArray(SafeBundleHandle handle, string key, out int size);
59 [DllImport(Libraries.Bundle, EntryPoint = "bundle_foreach")]
60 internal static extern void Foreach(SafeBundleHandle handle, Iterator iterator, IntPtr userData);
62 [DllImport(Libraries.Bundle, EntryPoint = "bundle_encode")]
63 internal static extern void BundleEncode(SafeBundleHandle handle, out string str, out int len);
65 [DllImport(Libraries.Bundle, EntryPoint = "bundle_decode")]
66 internal static extern SafeBundleHandle BundleDecode(string bundleRaw, int len);
68 [DllImport(Libraries.Bundle, EntryPoint = "bundle_dup")]
69 internal static extern SafeBundleHandle DangerousClone(IntPtr handle);
71 internal static class UnsafeCode
73 internal static unsafe int AddItem(SafeBundleHandle handle, string key, byte[] value, int offset, int count)
75 fixed (byte* pointer = value)
77 return AddByte(handle, key, pointer + offset, count);