[-]
[+]
|
Changed |
_service:tar_git:libgbinder.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/mer-hybris/libgbinder.git</param>
<param name="branch">master</param>
- <param name="revision">5ddc9d94d64d8aefc785dbe28372868b1da07a4d</param>
+ <param name="revision">e8c5a0c0bb7f31509f4c1e6d41cb8050afc65c0d</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.12.tar.bz2/Makefile
^
|
@@ -16,7 +16,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 1
-VERSION_RELEASE = 11
+VERSION_RELEASE = 12
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.12.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,9 @@
+libgbinder (1.1.12) unstable; urgency=low
+
+ * Added binder-call test tool
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 24 Sep 2021 16:46:05 +0300
+
libgbinder (1.1.11) unstable; urgency=low
* Fix potential deadlock in gbinder_ipc_looper_free()
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.12.tar.bz2/debian/control
^
|
@@ -2,7 +2,7 @@
Section: libs
Priority: optional
Maintainer: Slava Monich <slava.monich@jolla.com>
-Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0), libglibutil (>= 1.0.52)
+Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0), libglibutil (>= 1.0.52), flex, bison
Standards-Version: 3.8.4
Package: libgbinder
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.12.tar.bz2/debian/rules
^
|
@@ -9,12 +9,14 @@
override_dh_auto_build:
dh_auto_build -- LIBDIR=$(LIBDIR) release pkgconfig debian/libgbinder.install debian/libgbinder-dev.install
dh_auto_build -- -C test/binder-bridge release
+ dh_auto_build -- -C test/binder-call release
dh_auto_build -- -C test/binder-list release
dh_auto_build -- -C test/binder-ping release
override_dh_auto_install:
dh_auto_install -- LIBDIR=$(LIBDIR) install-dev
dh_auto_install -- -C test/binder-bridge
+ dh_auto_install -- -C test/binder-call
dh_auto_install -- -C test/binder-list
dh_auto_install -- -C test/binder-ping
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.12.tar.bz2/test/Makefile
^
|
@@ -8,4 +8,5 @@
@$(MAKE) -C binder-list $*
@$(MAKE) -C binder-ping $*
@$(MAKE) -C binder-service $*
+ @$(MAKE) -C binder-call $*
@$(MAKE) -C rild-card-status $*
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.12.tar.bz2/test/binder-call/Makefile
^
|
@@ -0,0 +1,178 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: all debug release install clean cleaner
+.PHONY: libgbinder-release libgbinder-debug
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Executable
+#
+
+EXE = binder-call
+
+#
+# Sources
+#
+
+SRC = $(EXE).c
+GEN_SRC = \
+ cmdline.tab.c \
+ lex.cmdline.c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+GEN_DIR = $(BUILD_DIR)
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC ?= $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include -I$(GEN_DIR) -I$(SRC_DIR)
+BASE_FLAGS = -fPIC
+CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
+QUIET_MAKE = make --no-print-directory
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+KEEP_SYMBOLS ?= 0
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = \
+ $(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = \
+ $(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+
+DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
+RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
+DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
+RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
+DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
+RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
+GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
+.PRECIOUS: $(GEN_FILES)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(GEN_FILES): | $(GEN_DIR)
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: libgbinder-debug $(DEBUG_EXE)
+
+release: libgbinder-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(GEN_DIR):
+ mkdir -p $@
+
+$(GEN_DIR)/%.tab.c : $(SRC_DIR)/%.y
+ bison -pcmdline -bcmdline -d -o $@ $<
+
+$(GEN_DIR)/lex.%.c : $(SRC_DIR)/%.l
+ flex -o $@ $<
+
+$(DEBUG_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
+ $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
+
+$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
+ $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+libgbinder-debug:
+ @$(MAKE) $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
+
+libgbinder-release:
+ @$(MAKE) $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
+
+#
+# Install
+#
+
+INSTALL = install
+
+INSTALL_BIN_DIR = $(DESTDIR)/usr/bin
+
+install: release $(INSTALL_BIN_DIR)
+ $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_BIN_DIR)
+
+$(INSTALL_BIN_DIR):
+ $(INSTALL) -d $@
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.12.tar.bz2/test/binder-call/binder-call.c
^
|
@@ -0,0 +1,814 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Franz-Josef Haider <franz.haider@jolla.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gbinder.h>
+#include <gutil_log.h>
+
+#include <unistd.h>
+#include <binder-call.h>
+#include <stdlib.h>
+
+#define RET_OK (0)
+#define RET_NOTFOUND (1)
+#define RET_INVARG (2)
+#define RET_ERR (3)
+
+#define DEFAULT_DEVICE GBINDER_DEFAULT_BINDER
+
+#define GBINDER_TRANSACTION(c2,c3,c4) GBINDER_FOURCC('_',c2,c3,c4)
+#define GBINDER_INTERFACE_TRANSACTION GBINDER_TRANSACTION('N','T','F')
+
+static const char pname[] = "binder-call";
+
+struct transaction_and_reply* ast;
+
+enum transaction_pass {
+ COMPUTE_SIZES = 0,
+ FILL_BUFFERS,
+ BUILD_TRANSACTION
+};
+
+enum reply_pass {
+ PRINT_REPLY = 0,
+ COMPUTE_SIZES_REPLY
+};
+
+static
+int
+go_through_transaction_ast(
+ App* app,
+ GList* node_list,
+ int parent_idx,
+ void* buf,
+ enum transaction_pass cur_pass,
+ int cont_offset)
+{
+ GList* l;
+ int offset = cont_offset;
+
+ for (l = node_list; l; l = l->next) {
+ struct value_info* v = l->data;
+
+ switch(v->type) {
+ case INT8_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("int8");
+ if (parent_idx == -1) {
+ gbinder_writer_append_int32(&app->writer, *((int*)v->value));
+ } else if (cur_pass == FILL_BUFFERS) {
+ *((unsigned char*)(((char*)buf)+offset)) =
+ *((unsigned char*)v->value);
+ }
+ offset++;
+ break;
+
+ case INT32_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("int32");
+ if (parent_idx == -1) {
+ gbinder_writer_append_int32(&app->writer, *((int*)v->value));
+ } else if (cur_pass == FILL_BUFFERS) {
+ *((int*)(((char*)buf)+offset)) = *((int*)v->value);
+ }
+ offset += sizeof(gint32);
+ break;
+
+ case INT64_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("int64");
+ if (parent_idx == -1) {
+ gbinder_writer_append_int64(&app->writer, *((gint64*)v->value));
+ } else if (cur_pass == FILL_BUFFERS) {
+ *((gint64*)(((char*)buf)+offset)) = *((gint64*)v->value);
+ }
+ offset += sizeof(gint64);
+ break;
+
+ case FLOAT_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("float");
+ if (parent_idx == -1) {
+ gbinder_writer_append_float(&app->writer, *((float*)v->value));
+ } else if (cur_pass == FILL_BUFFERS) {
+ *((float*)(((char*)buf)+offset)) = *((float*)v->value);
+ }
+ offset += sizeof(float);
+ break;
+ case DOUBLE_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("double");
+ if (parent_idx == -1) {
+ gbinder_writer_append_double(&app->writer,*((double*)v->value));
+ } else if (cur_pass == FILL_BUFFERS) {
+ *((double*)(((char*)buf)+offset)) = *((double*)v->value);
+ }
+ offset += sizeof(double);
+ break;
+
+ case STRING8_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("string8");
+ gbinder_writer_append_string8(&app->writer, v->value);
+ /* offset not incremented since it only makes sense for hidl */
+ break;
+
+ case STRING16_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("string16");
+ gbinder_writer_append_string16(&app->writer, v->value);
+ /* offset not incremented since it only makes sense for hidl */
+ break;
+
+ case HSTRING_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("hstring");
+ if (parent_idx == -1) {
+ gbinder_writer_append_hidl_string(&app->writer, v->value);
+ } else {
+ GBinderHidlString* hidl_str = (GBinderHidlString*)
+ (((char*)buf)+offset);
+
+ if (cur_pass == FILL_BUFFERS) {
+ hidl_str->data.str = v->value;
+ hidl_str->len = strlen(v->value);
+ hidl_str->owns_buffer = TRUE;
+ } else if (cur_pass == BUILD_TRANSACTION) {
+ GBinderParent p;
+
+ p.index = parent_idx;
+ p.offset = offset;
+ gbinder_writer_append_buffer_object_with_parent
+ (&app->writer, hidl_str->data.str, hidl_str->len+1, &p);
+ }
+ }
+ offset += sizeof(GBinderHidlString);
+ break;
+
+ case STRUCT_TYPE:
+ if (cur_pass == BUILD_TRANSACTION) GDEBUG("struct");
+ if (!app->opt->aidl) {
+ if (parent_idx == -1) {
+ int s = go_through_transaction_ast(app, v->value, 0,
+ NULL, COMPUTE_SIZES, 0);
+ void* new_buf = gbinder_writer_malloc(&app->writer, s);
+ int new_parent_idx;
+
+ go_through_transaction_ast(app, v->value, 0, new_buf,
+ FILL_BUFFERS, 0);
+ new_parent_idx = gbinder_writer_append_buffer_object
+ (&app->writer, new_buf, s);
+ /*
+ * if parent_idx == -1 there is no need to update the
+ * offset, since we are processing the argument list
+ * and are not inside an argument.
+ */
+ go_through_transaction_ast(app, v->value,
+ new_parent_idx, new_buf, BUILD_TRANSACTION, 0);
+ } else {
+ if (cur_pass == FILL_BUFFERS) {
+ /* fill struct mode */
+ offset += go_through_transaction_ast(app,
+ v->value, 0, ((char*)buf)+offset, cur_pass, 0);
+ } else if (cur_pass == BUILD_TRANSACTION) {
+ int s = go_through_transaction_ast(app,
+ v->value, 0, NULL, COMPUTE_SIZES, 0);
+
+ go_through_transaction_ast(app, v->value, 0,
+ buf, FILL_BUFFERS, offset);
+ go_through_transaction_ast(app, v->value, parent_idx,
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.12.tar.bz2/test/binder-call/binder-call.h
^
|
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BINDER_CALL_H__
+#define BINDER_CALL_H__
+
+#include <gbinder.h>
+
+typedef struct app_options {
+ char* dev;
+ char* iface;
+ gboolean oneway;
+ gboolean aidl;
+ gint transaction;
+ int argc;
+ char** argv;
+} AppOptions;
+
+typedef struct app {
+ const AppOptions* opt;
+ GMainLoop* loop;
+ GBinderServiceManager* sm;
+ GBinderWriter writer;
+ GBinderReader reader;
+ int code;
+ int rargc;
+ int ret;
+} App;
+
+enum TYPE_INFO {
+ INT8_TYPE = 0,
+ INT32_TYPE,
+ INT64_TYPE,
+ FLOAT_TYPE,
+ DOUBLE_TYPE,
+ STRING8_TYPE,
+ STRING16_TYPE,
+ HSTRING_TYPE,
+ STRUCT_TYPE,
+ VECTOR_TYPE
+};
+
+struct type_info {
+ enum TYPE_INFO type;
+ void* data;
+};
+
+struct value_info {
+ enum TYPE_INFO type;
+ void* value;
+};
+
+struct transaction_and_reply {
+ GList* tree_transaction;
+ GList* tree_reply;
+};
+
+int
+cmdline_parse(
+ App* app);
+
+int
+cmdlinelex(
+ void* args);
+
+extern struct transaction_and_reply* ast;
+
+#endif
+
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.12.tar.bz2/test/binder-call/cmdline.l
^
|
@@ -0,0 +1,98 @@
+D [0-9]
+l "l"
+L "L"
+u "u"
+U "U"
+h "h"
+H "H"
+COLON ":"
+EIGHT "8"
+
+INT8_SUFFIX {COLON}{EIGHT}
+INT64_SUFFIX [lL]
+UTF16_SUFFIX [uU]
+HSTRING_SUFFIX [hH]
+
+%{
+#include <glib.h>
+#include "cmdline.tab.h"
+#include "binder-call.h"
+
+#define YY_SKIP_YYWRAP
+int cmdlinewrap(App* app);
+#undef yywrap
+#define yywrap() cmdlinewrap( (App*) args )
+#define YY_DECL int cmdlinelex( void* args )
+
+char* handle_str(char* text) {
+ // extract str from "str"X
+ char* str = g_strndup(text + 1, strlen(text) - 3);
+ return str;
+}
+
+char* handle_str8(char* text) {
+ // extract str from "str"
+ char* str = g_strndup(text + 1, strlen(text) - 2);
+ return str;
+}
+
+%}
+
+%option never-interactive noinput nounput
+
+%%
+"i8" { return(INT8); }
+"i32" { return(INT32); }
+"i64" { return(INT64); }
+"s8" { return(STRING8); }
+"s16" { return(STRING16); }
+"float" { return(FLOAT); }
+"double" { return(DOUBLE); }
+"f" { return(FLOAT); }
+"d" { return(DOUBLE); }
+"hstr" { return(HSTRING); }
+"{" { return('{'); }
+"}" { return('}'); }
+"[" { return('['); }
+"]" { return(']'); }
+{D}*{INT8_SUFFIX} { cmdlinelval.int8_value = atoi(yytext); return(INT8_VALUE); }
+{D}*{INT64_SUFFIX} { cmdlinelval.int64_value = atol(yytext); return(INT64_VALUE); }
+{D}* { cmdlinelval.int32_value = atoi(yytext); return(INT32_VALUE); }
+{D}+"."{D}*{INT64_SUFFIX} { cmdlinelval.double_value = atof(yytext); return(DOUBLE_VALUE); }
+{D}+"."{D}* { cmdlinelval.float_value = atof(yytext); return(FLOAT_VALUE); }
+"reply" { return(REPLY); }
+\".*\"{HSTRING_SUFFIX} { cmdlinelval.hstring_value = handle_str(yytext); return(HSTRING_VALUE); }
+\".*\"{UTF16_SUFFIX} { cmdlinelval.string16_value = handle_str(yytext); return(STRING16_VALUE); }
+\".*\" { cmdlinelval.string8_value = handle_str8(yytext); return(STRING8_VALUE); }
+" " { /* eat */ }
+. { fprintf(stderr, "Unrecognized character: '%c'\n", yytext[0]); }
+
+%%
+
+#include "binder-call.h"
+
+int cmdlinewrap(App* app)
+{
+ if (YY_CURRENT_BUFFER) {
+ yy_delete_buffer( YY_CURRENT_BUFFER );
+ }
+
+ if (app->rargc == app->opt->argc) {
+ return 1;
+ }
+
+ yy_scan_string(app->opt->argv[app->rargc++]);
+
+ return 0;
+}
+
+int cmdline_parse(App* app) {
+ if (app->opt->argc > app->rargc) {
+ cmdlinewrap(app);
+ } else {
+ return 1;
+ }
+
+ return cmdlineparse (app);
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.12.tar.bz2/test/binder-call/cmdline.y
^
|
@@ -0,0 +1,399 @@
+%{
+#include <glib.h>
+#include "binder-call.h"
+
+struct transaction_and_reply* make_transaction_and_reply(GList* transaction, GList* reply);
+struct value_info* handle_int8(App* app, int value);
+struct value_info* handle_int32(App* app, int value);
+struct value_info* handle_int64(App* app, long value);
+struct value_info* handle_float(App* app, float value);
+struct value_info* handle_double(App* app, double value);
+struct value_info* handle_string8(App* app, char* value);
+struct value_info* handle_string16(App* app, char* value);
+struct value_info* handle_hstring(App* app, char* value);
+struct value_info* handle_vector(App* app, GList* values);
+struct value_info* handle_struct(App* app, GList* values);
+
+void cmdlineerror(App* app, char const* s);
+
+struct type_info* handle_type_int8(App* app);
+struct type_info* handle_type_int32(App* app);
+struct type_info* handle_type_int64(App* app);
+struct type_info* handle_type_float(App* app);
+struct type_info* handle_type_double(App* app);
+struct type_info* handle_type_string8(App* app);
+struct type_info* handle_type_string16(App* app);
+struct type_info* handle_type_hstring(App* app);
+
+
+struct type_info* handle_type_vector(App* app, struct type_info* t);
+struct type_info* handle_type_struct(App* app, GList* l);
+
+%}
+
+%union {
+ union {
+ int int8_value;
+ int int32_value;
+ long int64_value;
+ float float_value;
+ double double_value;
+ char* string8_value;
+ char* string16_value;
+ char* hstring_value;
+ };
+ struct value_info* value;
+ struct type_info* type;
+ GList* value_list;
+ GList* type_list;
+ GList* struct_type_list;
+ struct transaction_and_reply* trans_and_reply;
+}
+
+%parse-param { void* args }
+%lex-param { void* args }
+
+%token INT8 INT32 INT64 FLOAT DOUBLE STRING8 STRING16 HSTRING
+
+%token INT8_VALUE INT32_VALUE INT64_VALUE FLOAT_VALUE DOUBLE_VALUE STRING8_VALUE STRING16_VALUE HSTRING_VALUE
+%type <value> values
+
+%type <value> struct_values
+%type <value> vec_values
+%type <value> value_specifiers
+%type <trans_and_reply> translation_unit
+
+%type <value_list> values_list
+%type <type_list> specifiers_list
+
+%type <type> specifiers
+%type <type> type_specifier
+%type <type> vec_specifier
+%type <type> struct_specifier
+%type <struct_type_list> struct_declaration_list
+
+%token REPLY
+
+%start translation_unit
+%%
+
+type_specifier
+ : INT8 { $$ = handle_type_int8(args); }
+ | INT32 { $$ = handle_type_int32(args); }
+ | INT64 { $$ = handle_type_int64(args); }
+ | STRING8 { $$ = handle_type_string8(args); }
+ | STRING16 { $$ = handle_type_string16(args); }
+ | FLOAT { $$ = handle_type_float(args); }
+ | DOUBLE { $$ = handle_type_double(args); }
+ | HSTRING { $$ = handle_type_hstring(args); }
+ ;
+
+values
+ : INT8_VALUE { $$ = handle_int8(args, cmdlinelval.int8_value); }
+ | INT32_VALUE { $$ = handle_int32(args, cmdlinelval.int32_value); }
+ | INT64_VALUE { $$ = handle_int64(args, cmdlinelval.int64_value); }
+ | STRING8_VALUE { $$ = handle_string8(args, cmdlinelval.string8_value); }
+ | STRING16_VALUE { $$ = handle_string16(args, cmdlinelval.string16_value); }
+ | HSTRING_VALUE { $$ = handle_hstring(args, cmdlinelval.hstring_value); }
+ | FLOAT_VALUE { $$ = handle_float(args, cmdlinelval.float_value); }
+ | DOUBLE_VALUE { $$ = handle_double(args, cmdlinelval.double_value); }
+ ;
+
+struct
+ : '{'
+ ;
+
+struct_end
+ : '}'
+ ;
+
+vec
+ : '['
+ ;
+
+vec_end
+ : ']'
+ ;
+
+struct_specifier
+ : struct struct_declaration_list struct_end { $$ = handle_type_struct(args, $2); }
+ ;
+
+vec_specifier
+ : vec specifiers vec_end { $$ = handle_type_vector(args, $2); }
+ ;
+
+struct_declaration_list
+ : specifiers { $$ = NULL; $$ = g_list_append($$, $1); }
+ | struct_declaration_list specifiers { $$ = g_list_append($$, $2); }
+ ;
+
+specifiers
+ : type_specifier
+ | struct_specifier
+ | vec_specifier
+ ;
+
+specifiers_list
+ : specifiers { $$ = NULL; $$ = g_list_append($$, $1); }
+ | specifiers_list specifiers { $$ = g_list_append($$, $2); }
+ ;
+
+struct_values
+ : struct values_list struct_end { $$ = handle_struct(args, $2); }
+ ;
+
+vec_values
+ : vec values_list vec_end { $$ = handle_vector(args, $2); }
+ ;
+
+value_specifiers
+ : values
+ | struct_values
+ | vec_values
+ ;
+
+values_list
+ : value_specifiers { $$ = NULL; $$ = g_list_append($$, $1); }
+ | values_list value_specifiers { $$ = g_list_append($$, $2); }
+ ;
+
+reply
+ : REPLY
+ ;
+
+translation_unit
+ : values_list reply specifiers_list { $$ = make_transaction_and_reply($1, $3); ast = $$; }
+ | values_list { $$ = make_transaction_and_reply($1, 0); ast = $$; }
+ | reply specifiers_list { $$ = make_transaction_and_reply(0, $2); ast = $$; }
+ ;
+
+%%
+
+#include <stdio.h>
+#include <glib.h>
+#include <gutil_log.h>
+#include <binder-call.h>
+
+extern char yytext[];
+
+struct value_info* handle_int8(App* app, int value)
+{
+ struct value_info* v = g_new0(struct value_info, 1);
+
+ v->type = INT8_TYPE;
+ v->value = g_new0(unsigned char, 1);
+ * ((unsigned char*)v->value) = value;
+
+ return v;
+}
+
+struct value_info* handle_int32(App* app, int value)
+{
+ struct value_info* v = g_new0(struct value_info, 1);
+
+ v->type = INT32_TYPE;
+ v->value = g_new0(int, 1);
+ * ((int*)v->value) = value;
+
+ return v;
|