Skip to content

Commit

Permalink
Merge pull request #10 from smartdevicelink/feature/lua_port
Browse files Browse the repository at this point in the history
Added Lua port
  • Loading branch information
jacobkeeler authored Nov 30, 2017
2 parents 854740d + 8da4811 commit c128ac4
Show file tree
Hide file tree
Showing 10 changed files with 1,264 additions and 19 deletions.
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
if BUILD_LUA
SUBDIRS += lua
endif
5 changes: 3 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@BUILD_LUA_TRUE@am__append_1 = lua
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
Expand Down Expand Up @@ -159,7 +160,7 @@ am__define_uniq_tagged_files = \
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
DIST_SUBDIRS = src lua
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in compile \
config.guess config.sub install-sh ltmain.sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
Expand Down Expand Up @@ -322,7 +323,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
SUBDIRS = src $(am__append_1)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive

Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,48 @@ make
sudo make install
```

## Build Lua wrapper ##

### Install Dependencies ###
```bash
sudo apt-get install liblua5.2-dev
```

### Build Library ###
```bash
./configure --with-lua-wrapper=yes
make
```

### Using the Lua Library ###
```lua
bson = require("bson4lua");

bsonBytes = bson.to_bytes({
doubleValue = {
type = 0x01, --Double type
value = 3.141592653589793
},
intValue = {
type = 0x10, --Int32 Type
value = 360
},
stringValue = {
type = 0x02, --String type
value = "A string of characters"
}
});

print(bsonBytes:byte(1, string.len(bsonBytes)));

bsonTable = bson.to_table(string.char(0x05, 0x00, 0x00, 0x00, 0x00)); --Empty BSON document

print("Table: ");
for k, v in pairs(bsonTable) do
print(k, v);
end
```

### Apple Platforms ###
There is a CocoaPod for iOS, MacOS, tvOS, and watchOS. Add to your podfile:

Expand Down
6 changes: 3 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#define PACKAGE_NAME "bson_c_lib"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "bson_c_lib 0.1"
#define PACKAGE_STRING "bson_c_lib 1.1.0"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "bson_c_lib"
Expand All @@ -66,13 +66,13 @@
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "0.1"
#define PACKAGE_VERSION "1.1.0"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#define VERSION "0.1"
#define VERSION "1.1.0"

/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
Expand Down
58 changes: 47 additions & 11 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for bson_c_lib 0.1.
# Generated by GNU Autoconf 2.69 for bson_c_lib 1.1.0.
#
# Report bugs to <jacob@livio.io>.
#
Expand Down Expand Up @@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bson_c_lib'
PACKAGE_TARNAME='bson_c_lib'
PACKAGE_VERSION='0.1'
PACKAGE_STRING='bson_c_lib 0.1'
PACKAGE_VERSION='1.1.0'
PACKAGE_STRING='bson_c_lib 1.1.0'
PACKAGE_BUGREPORT='jacob@livio.io'
PACKAGE_URL=''

Expand Down Expand Up @@ -635,6 +635,8 @@ ac_unique_file="examples/sample.c"
ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
BUILD_LUA_FALSE
BUILD_LUA_TRUE
LIBOBJS
CPP
LT_SYS_LIBRARY_PATH
Expand Down Expand Up @@ -763,6 +765,7 @@ enable_dependency_tracking
with_gnu_ld
with_sysroot
enable_libtool_lock
with_lua_wrapper
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1324,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures bson_c_lib 0.1 to adapt to many kinds of systems.
\`configure' configures bson_c_lib 1.1.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1395,7 +1398,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of bson_c_lib 0.1:";;
short | recursive ) echo "Configuration of bson_c_lib 1.1.0:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1426,6 +1429,7 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-lua-wrapper Build Lua wrapper library
Some influential environment variables:
CC C compiler command
Expand Down Expand Up @@ -1505,7 +1509,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bson_c_lib configure 0.1
bson_c_lib configure 1.1.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2058,7 +2062,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bson_c_lib $as_me 0.1, which was
It was created by bson_c_lib $as_me 1.1.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -2921,7 +2925,7 @@ fi

# Define the identity of the package.
PACKAGE='bson_c_lib'
VERSION='0.1'
VERSION='1.1.0'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -13174,7 +13178,34 @@ fi
done


ac_config_files="$ac_config_files Makefile src/Makefile src/emhashmap/Makefile"

# Check whether --with-lua-wrapper was given.
if test "${with_lua_wrapper+set}" = set; then :
withval=$with_lua_wrapper; case ${withval} in #(
yes) :
with_lua=yes ;; #(
no) :
with_lua=no ;; #(
*) :
as_fn_error $? "invalid value (${withval}) for --with-lua-wrapper
" "$LINENO" 5
;;
esac
else
with_lua=no
fi


if test x$with_lua = xyes; then
BUILD_LUA_TRUE=
BUILD_LUA_FALSE='#'
else
BUILD_LUA_TRUE='#'
BUILD_LUA_FALSE=
fi


ac_config_files="$ac_config_files Makefile src/Makefile src/emhashmap/Makefile lua/Makefile"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -13313,6 +13344,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${BUILD_LUA_TRUE}" && test -z "${BUILD_LUA_FALSE}"; then
as_fn_error $? "conditional \"BUILD_LUA\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
Expand Down Expand Up @@ -13710,7 +13745,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by bson_c_lib $as_me 0.1, which was
This file was extended by bson_c_lib $as_me 1.1.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -13776,7 +13811,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
bson_c_lib config.status 0.1
bson_c_lib config.status 1.1.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down Expand Up @@ -14194,6 +14229,7 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"src/emhashmap/Makefile") CONFIG_FILES="$CONFIG_FILES src/emhashmap/Makefile" ;;
"lua/Makefile") CONFIG_FILES="$CONFIG_FILES lua/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
Expand Down
26 changes: 24 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT(bson_c_lib, 0.1, jacob@livio.io)
AC_INIT(bson_c_lib, 1.1.0, jacob@livio.io)
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIRS([m4])
LT_INIT
Expand Down Expand Up @@ -31,4 +31,26 @@ AC_TYPE_UINT8_T
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset])

AC_OUTPUT(Makefile src/Makefile src/emhashmap/Makefile)
AC_ARG_WITH(
[lua-wrapper],
[AS_HELP_STRING(
[--with-lua-wrapper],
[Build Lua wrapper library]
)],
[AS_CASE(
${withval},
[yes],
[with_lua=yes],
[no],
[with_lua=no],
[AC_MSG_ERROR(
[invalid value (${withval}) for --with-lua-wrapper]
)]
)],
[with_lua=no])

AM_CONDITIONAL(
[BUILD_LUA],
[test x$with_lua = xyes])

AC_OUTPUT(Makefile src/Makefile src/emhashmap/Makefile lua/Makefile)
5 changes: 5 additions & 0 deletions lua/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AM_CFLAGS = -Wall

lib_LTLIBRARIES = libluabson.la
libluabson_la_SOURCES = bson_lua_wrapper.c
libluabson_la_LIBADD = ../src/libbson.la
Loading

0 comments on commit c128ac4

Please sign in to comment.