Compare commits

...

6 Commits
1.0.2 ... 1.0.3

Author SHA1 Message Date
Slava Monich
a292ee46b8 Version 1.0.3 2018-08-06 19:18:16 +03:00
Slava Monich
4624e8064f Merge pull request #2 from monich/bool
Added two more convenience functions for completeness
2018-08-06 19:13:20 +03:00
Slava Monich
e468b27e69 [gbinder] Unit test for gbinder_local_reply_append_bool() 2018-08-06 17:50:31 +03:00
Slava Monich
a5c0bd0c62 [gbinder] Unit test for gbinder_local_request_append_bool() 2018-08-06 17:39:15 +03:00
Slava Monich
ad7701b5a9 [gbinder] Added gbinder_local_reply_append_bool(). JB#41335 2018-08-06 17:28:01 +03:00
Slava Monich
0a69f00787 [gbinder] Added gbinder_local_request_append_bool(). JB#41335 2018-08-06 17:26:08 +03:00
12 changed files with 158 additions and 17 deletions

View File

@@ -24,7 +24,7 @@ all: debug release pkgconfig
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_RELEASE = 2
VERSION_RELEASE = 3
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)

7
debian/changelog vendored
View File

@@ -1,3 +1,10 @@
libgbinder (1.0.3) unstable; urgency=low
* Added gbinder_local_request_append_bool()
* Added gbinder_local_reply_append_bool()
-- Slava Monich <slava.monich@jolla.com> Mon, 06 Aug 2018 19:15:29 +0300
libgbinder (1.0.2) unstable; urgency=low
* Added gbinder_remote_request_sender_pid()

View File

@@ -56,6 +56,11 @@ gbinder_local_reply_cleanup(
GDestroyNotify destroy,
gpointer pointer);
GBinderLocalReply*
gbinder_local_reply_append_bool(
GBinderLocalReply* reply,
gboolean value); /* since 1.0.3 */
GBinderLocalReply*
gbinder_local_reply_append_int32(
GBinderLocalReply* reply,

View File

@@ -56,6 +56,11 @@ gbinder_local_request_cleanup(
GDestroyNotify destroy,
gpointer pointer);
GBinderLocalRequest*
gbinder_local_request_append_bool(
GBinderLocalRequest* request,
gboolean value); /* since 1.0.3 */
GBinderLocalRequest*
gbinder_local_request_append_int32(
GBinderLocalRequest* request,

View File

@@ -56,11 +56,11 @@ gbinder_remote_request_init_reader(
pid_t
gbinder_remote_request_sender_pid(
GBinderRemoteRequest* req);
GBinderRemoteRequest* req); /* since 1.0.2 */
uid_t
gbinder_remote_request_sender_euid(
GBinderRemoteRequest* req);
GBinderRemoteRequest* req); /* since 1.0.2 */
/* Convenience function to decode requests with just one data item */

View File

@@ -1,5 +1,5 @@
Name: libgbinder
Version: 1.0.2
Version: 1.0.3
Release: 0
Summary: Binder client library
Group: Development/Libraries

View File

@@ -160,6 +160,17 @@ gbinder_local_reply_init_writer(
}
}
GBinderLocalReply*
gbinder_local_reply_append_bool(
GBinderLocalReply* self,
gboolean value)
{
if (G_LIKELY(self)) {
gbinder_writer_data_append_bool(&self->data, value);
}
return self;
}
GBinderLocalReply*
gbinder_local_reply_append_int32(
GBinderLocalReply* self,

View File

@@ -169,6 +169,17 @@ gbinder_local_request_init_writer(
}
}
GBinderLocalRequest*
gbinder_local_request_append_bool(
GBinderLocalRequest* self,
gboolean value)
{
if (G_LIKELY(self)) {
gbinder_writer_data_append_bool(&self->data, value);
}
return self;
}
GBinderLocalRequest*
gbinder_local_request_append_int32(
GBinderLocalRequest* self,

View File

@@ -96,6 +96,31 @@ gbinder_writer_init(
gbinder_writer_cast(self)->data = data;
}
void
gbinder_writer_append_bool(
GBinderWriter* self,
gboolean value)
{
GBinderWriterData* data = gbinder_writer_data(self);
if (G_LIKELY(data)) {
gbinder_writer_data_append_bool(data, value);
}
}
void
gbinder_writer_data_append_bool(
GBinderWriterData* data,
gboolean value)
{
guint8 padded[4];
/* Boolean values are padded to 4-byte boundary */
padded[0] = (value != FALSE);
padded[1] = padded[2] = padded[3] = 0xff;
g_byte_array_append(data->bytes, padded, sizeof(padded));
}
void
gbinder_writer_append_int32(
GBinderWriter* self,
@@ -291,19 +316,6 @@ gbinder_writer_data_append_string16_len(
}
}
void
gbinder_writer_append_bool(
GBinderWriter* self,
gboolean value)
{
guint8 padded[4];
/* Boolean values are padded to 4-byte boundary */
padded[0] = (value != FALSE);
padded[1] = padded[2] = padded[3] = 0xff;
gbinder_writer_append_bytes(self, padded, sizeof(padded));
}
void
gbinder_writer_append_bytes(
GBinderWriter* self,

View File

@@ -50,6 +50,11 @@ gbinder_writer_init(
GBinderWriter* writer,
GBinderWriterData* data);
void
gbinder_writer_data_append_bool(
GBinderWriterData* data,
gboolean value);
void
gbinder_writer_data_append_int32(
GBinderWriterData* data,

View File

@@ -110,6 +110,47 @@ test_cleanup(
g_assert(count == 2);
}
/*==========================================================================*
* bool
*==========================================================================*/
static
void
test_bool(
void)
{
static const guint8 output_true[] = { 0x01, 0xff, 0xff, 0xff };
static const guint8 output_false[] = { 0x00, 0xff, 0xff, 0xff };
GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
GBinderOutputData* data;
gbinder_local_reply_append_bool(reply, FALSE);
data = gbinder_local_reply_data(reply);
g_assert(!gbinder_output_data_offsets(data));
g_assert(!gbinder_output_data_buffers_size(data));
g_assert(data->bytes->len == sizeof(output_false));
g_assert(!memcmp(data->bytes->data, output_false, data->bytes->len));
gbinder_local_reply_unref(reply);
reply = gbinder_local_reply_new(&gbinder_io_32);
gbinder_local_reply_append_bool(reply, TRUE);
data = gbinder_local_reply_data(reply);
g_assert(!gbinder_output_data_offsets(data));
g_assert(!gbinder_output_data_buffers_size(data));
g_assert(data->bytes->len == sizeof(output_true));
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
gbinder_local_reply_unref(reply);
reply = gbinder_local_reply_new(&gbinder_io_32);
gbinder_local_reply_append_bool(reply, 42);
data = gbinder_local_reply_data(reply);
g_assert(!gbinder_output_data_offsets(data));
g_assert(!gbinder_output_data_buffers_size(data));
g_assert(data->bytes->len == sizeof(output_true));
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
gbinder_local_reply_unref(reply);
}
/*==========================================================================*
* int32
*==========================================================================*/
@@ -361,6 +402,7 @@ int main(int argc, char* argv[])
g_test_init(&argc, &argv, NULL);
g_test_add_func(TEST_PREFIX "null", test_null);
g_test_add_func(TEST_PREFIX "cleanup", test_cleanup);
g_test_add_func(TEST_PREFIX "bool", test_bool);
g_test_add_func(TEST_PREFIX "int32", test_int32);
g_test_add_func(TEST_PREFIX "int64", test_int64);
g_test_add_func(TEST_PREFIX "string8", test_string8);

View File

@@ -76,6 +76,7 @@ test_null(
g_assert(count == 1);
g_assert(!gbinder_local_request_data(NULL));
g_assert(!gbinder_local_request_append_bool(NULL, FALSE));
g_assert(!gbinder_local_request_append_int32(NULL, 0));
g_assert(!gbinder_local_request_append_int64(NULL, 0));
g_assert(!gbinder_local_request_append_string8(NULL, NULL));
@@ -140,6 +141,47 @@ test_init_data(
g_bytes_unref(init_bytes);
}
/*==========================================================================*
* bool
*==========================================================================*/
static
void
test_bool(
void)
{
static const guint8 output_true[] = { 0x01, 0xff, 0xff, 0xff };
static const guint8 output_false[] = { 0x00, 0xff, 0xff, 0xff };
GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
GBinderOutputData* data;
gbinder_local_request_append_bool(req, FALSE);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
g_assert(!gbinder_output_data_buffers_size(data));
g_assert(data->bytes->len == sizeof(output_false));
g_assert(!memcmp(data->bytes->data, output_false, data->bytes->len));
gbinder_local_request_unref(req);
req = gbinder_local_request_new(&gbinder_io_32, NULL);
gbinder_local_request_append_bool(req, TRUE);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
g_assert(!gbinder_output_data_buffers_size(data));
g_assert(data->bytes->len == sizeof(output_true));
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
gbinder_local_request_unref(req);
req = gbinder_local_request_new(&gbinder_io_32, NULL);
gbinder_local_request_append_bool(req, 42);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
g_assert(!gbinder_output_data_buffers_size(data));
g_assert(data->bytes->len == sizeof(output_true));
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
gbinder_local_request_unref(req);
}
/*==========================================================================*
* int32
*==========================================================================*/
@@ -360,6 +402,7 @@ int main(int argc, char* argv[])
g_test_add_func(TEST_PREFIX "null", test_null);
g_test_add_func(TEST_PREFIX "cleanup", test_cleanup);
g_test_add_func(TEST_PREFIX "init_data", test_init_data);
g_test_add_func(TEST_PREFIX "bool", test_bool);
g_test_add_func(TEST_PREFIX "int32", test_int32);
g_test_add_func(TEST_PREFIX "int64", test_int64);
g_test_add_func(TEST_PREFIX "string8", test_string8);