Commit ade11bda authored by Philipp Huebner's avatar Philipp Huebner

Imported Upstream version 1.0.2

parent ce57535b
......@@ -2,10 +2,20 @@ sudo: false
language: erlang
before_install:
- pip install --user cpp-coveralls coveralls-merge
install:
- ./configure --enable-gcov
- rebar get-deps
script: rebar compile xref && rebar skip_deps=true eunit
after_success:
- coveralls --exclude lib --exclude tests --gcov-options '\-lp' --dump c.json
- coveralls-merge c.json erlang.json
otp_release:
- 17.1
- 17.5
- 18.0
- 18.1
# Version 1.0.1
* Update to depend on p1_utils 1.0.3 (Mickaël Rémond)
# Version 1.0.0
* Initial release on Hex.pm (Mickaël Rémond)
* Project is renamed fast_yaml.
* Continuous integration with Travis CI and Coveralls (Mickaël Rémond)
* License changed to Apache v2, so that it can be used in a wide range
of software.
Copyright 2013 ProcessOne
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This diff is collapsed.
all: src
src:
rebar compile
rebar get-deps compile
clean:
rebar clean
......
# P1 YAML [![Build Status](https://travis-ci.org/processone/p1_yaml.svg?branch=master)](https://travis-ci.org/processone/p1_yaml)
# Fast YAML
P1 YAML is an Erlang wrapper for [libyaml](http://pyyaml.org/wiki/LibYAML) "C" library.
[![Build Status](https://travis-ci.org/processone/fast_yaml.svg?branch=master)](https://travis-ci.org/processone/fast_yaml) [![Coverage Status](https://coveralls.io/repos/processone/fast_yaml/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/fast_yaml?branch=master) [![Hex version](https://img.shields.io/hexpm/v/fast_yaml.svg "Hex version")](https://hex.pm/packages/fast_yaml)
Fast YAML is an Erlang wrapper for
[libyaml](http://pyyaml.org/wiki/LibYAML) "C" library.
It is designed to be fast and efficient.
## Installation
$ ./configure
$ make
### Dependencies
Fast YAML depends on native LibYaml library. You need development
headers for LibYaml library to build it.
### Generic build
You can trigger build with:
./configure && make
### OSX build example
You can install LibYaml and with Homebrew:
brew install libyaml
You can then export environment variable to use LibYaml as installed
by Homebrew, before issuing compilation commands:
export LDFLAGS="-L/usr/local/lib"
export CFLAGS="-I/usr/local/include"
export CPPFLAGS="-I/usr/local/include"
./configure && make
## Example usage
```erlang
1> application:start(p1_yaml).
erl -pa ebin -pa deps/*/ebin
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V7.1 (abort with ^G)
1> application:start(fast_yaml).
ok
2> p1_yaml:decode(<<"a: 1\nb: -3.0">>).
2> fast_yaml:decode(<<"a: 1\nb: -3.0">>).
{ok,[[{<<"a">>,1},{<<"b">>,-3.0}]]}
3> p1_yaml:decode(<<"a: 1\nb: -3.0">>, [{plain_as_atom, true}]).
3> fast_yaml:decode(<<"a: 1\nb: -3.0">>, [{plain_as_atom, true}]).
{ok,[[{a,1},{b,-3.0}]]}
4> p1_yaml:decode(<<"a: b\nc">>).
4> fast_yaml:decode(<<"a: b\nc">>).
{error,{scanner_error,<<"could not find expected ':'">>,2,
0}}.
5> p1_yaml:decode_from_file("test/test2.yml", [plain_as_atom]).
5> fast_yaml:decode_from_file("test/test2.yml", [plain_as_atom]).
{ok,[[[{step,[{instrument,<<"Lasik 2000">>},
{pulseEnergy,5.4},
{pulseDuration,12},
......@@ -39,3 +72,13 @@ ok
[{step,<<"id001">>}],
[{step,<<"id002">>}]]]}
```
## Development
### Test
#### Unit test
You can run eunit test with the command:
make test
/*
* ejabberd, Copyright (C) 2002-2015 ProcessOne
* Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* http://www.apache.org/licenses/LICENSE-2.0
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
......@@ -313,4 +310,4 @@ static ErlNifFunc nif_funcs[] =
{"nif_decode", 2, decode}
};
ERL_NIF_INIT(p1_yaml, nif_funcs, load, NULL, NULL, NULL)
ERL_NIF_INIT(fast_yaml, nif_funcs, load, NULL, NULL, NULL)
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for p1_yaml 0.1.0.
# Generated by GNU Autoconf 2.69 for fast_yaml 1.0.0.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -575,10 +575,10 @@ MFLAGS=
MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='p1_yaml'
PACKAGE_TARNAME='p1_yaml'
PACKAGE_VERSION='0.1.0'
PACKAGE_STRING='p1_yaml 0.1.0'
PACKAGE_NAME='fast_yaml'
PACKAGE_TARNAME='fast_yaml'
PACKAGE_VERSION='1.0.0'
PACKAGE_STRING='fast_yaml 1.0.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
......@@ -619,6 +619,7 @@ ac_includes_default="\
#endif"
ac_subst_vars='LTLIBOBJS
gcov
ERLCFLAGS
ERLC
ERL
......@@ -653,7 +654,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
......@@ -676,6 +676,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_gcov
'
ac_precious_vars='build_alias
host_alias
......@@ -727,7 +728,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
......@@ -980,15 +980,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
......@@ -1126,7 +1117,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
......@@ -1239,7 +1230,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 p1_yaml 0.1.0 to adapt to many kinds of systems.
\`configure' configures fast_yaml 1.0.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1279,7 +1270,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
......@@ -1288,7 +1278,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/p1_yaml]
--docdir=DIR documentation root [DATAROOTDIR/doc/fast_yaml]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
......@@ -1301,10 +1291,16 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of p1_yaml 0.1.0:";;
short | recursive ) echo "Configuration of fast_yaml 1.0.0:";;
esac
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-gcov compile with gcov enabled (default: no)
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
......@@ -1384,7 +1380,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
p1_yaml configure 0.1.0
fast_yaml configure 1.0.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1682,7 +1678,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 p1_yaml $as_me 0.1.0, which was
It was created by fast_yaml $as_me 1.0.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -3820,6 +3816,20 @@ else
fi
# Check whether --enable-gcov was given.
if test "${enable_gcov+set}" = set; then :
enableval=$enable_gcov; case "${enableval}" in
yes) gcov=true ;;
no) gcov=false ;;
*) as_fn_error $? "bad value ${enableval} for --enable-gcov" "$LINENO" 5 ;;
esac
else
gcov=false
fi
ac_config_files="$ac_config_files vars.config"
cat >confcache <<\_ACEOF
......@@ -4364,7 +4374,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 p1_yaml $as_me 0.1.0, which was
This file was extended by fast_yaml $as_me 1.0.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -4417,7 +4427,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="\\
p1_yaml config.status 0.1.0
fast_yaml config.status 1.0.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.53)
AC_PACKAGE_VERSION(0.1.0)
AC_INIT(p1_yaml, 0.1.0, [], [])
AC_PACKAGE_VERSION(1.0.0)
AC_INIT(fast_yaml, 1.0.0, [], [])
# Checks for programs.
AC_PROG_CC
......@@ -34,5 +34,15 @@ AC_CHECK_HEADERS([yaml.h], [], [
AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [
AC_MSG_ERROR([libyaml library was not found])])
AC_ARG_ENABLE(gcov,
[AC_HELP_STRING([--enable-gcov], [compile with gcov enabled (default: no)])],
[case "${enableval}" in
yes) gcov=true ;;
no) gcov=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gcov) ;;
esac],[gcov=false])
AC_SUBST(gcov)
AC_CONFIG_FILES([vars.config])
AC_OUTPUT
%%%----------------------------------------------------------------------
%%% File : rebar.config
%%% Author : Mickael Remond <mremond@process-one.net>
%%% Purpose : Rebar build script. Compliant with rebar and rebar3.
%%% Created : 11 Dec 2015 by Mickael Remond <mremond@process-one.net>
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%% http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
{erl_opts, [debug_info, {src_dirs, ["src"]}]}.
{port_env, [{"CFLAGS", "$CFLAGS"}, {"LDFLAGS", "$LDFLAGS"}]}.
{port_specs, [{"priv/lib/fast_yaml.so", ["c_src/fast_yaml.c"]}]}.
{deps, [{p1_utils, ".*", {git, "git://github.com/processone/p1_utils", {tag, "1.0.3"}}}]}.
{clean_files, ["c_src/fast_yaml.gcda", "c_src/fast_yaml.gcno"]}.
{cover_enabled, true}.
{cover_export_enabled, true}.
{xref_checks, [undefined_function_calls, undefined_functions, deprecated_function_calls, deprecated_functions]}.
{profiles, [{test, [{erl_opts, [{src_dirs, ["src", "test"]}]}]}]}.
%%%----------------------------------------------------------------------
%%% File : rebar.config.script
%%% Author : Mickael Remond <mremond@process-one.net>
%%% Purpose : Rebar build script. Compliant with rebar and rebar3.
%%% Created : 11 Dec 2015 by Mickael Remond <mremond@process-one.net>
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%% http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
Cfg = case file:consult("vars.config") of
{ok, Terms} ->
Terms;
_Err ->
[]
end ++ [{cflags, "-g -O2 -Wall"}, {ldflags, "-lyaml"}],
end ++ [{cflags, "-g -O2 -Wall"}, {ldflags, "-lyaml"}, {with_gcov, "false"}],
{cflags, CfgCFlags} = lists:keyfind(cflags, 1, Cfg),
{ldflags, CfgLDFlags} = lists:keyfind(ldflags, 1, Cfg),
{with_gcov, CfgWithGCov} = lists:keyfind(with_gcov, 1, Cfg),
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
end,
case Tail of
[] ->
[{Key, Op(OldVal)} | PartCfg];
_ ->
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
end
end,
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end.
ModCfgS = fun(Cfg, Keys, Val) -> ModCfg0(ModCfg0, Cfg, Keys, fun(_V) -> Val end, "") end.
Config = [
{erl_opts, [debug_info]},
Cfg0 = ModCfg(CONFIG, [port_env, "CFLAGS"], fun(V) -> V ++ " " ++ CfgCFlags end, "$CFLAGS"),
Cfg00 = ModCfg(Cfg0, [port_env, "LDFLAGS"], fun(V) -> V ++ " " ++ CfgLDFlags end, "$LDFLAGS"),
Cfg1 = case CfgWithGCov of
"true" ->
V1 = ModCfg(Cfg00, [post_hooks], fun(V) -> V ++ [{eunit, "gcov -o c_src fast_yaml"},
{eunit, "mv *.gcov .eunit/"}] end, []),
V2 = ModCfg(V1, [port_env, "LDFLAGS"], fun(V) -> V ++ " --coverage" end, ""),
ModCfg(V2, [port_env, "CFLAGS"], fun(V) -> V ++ " --coverage" end, "");
_ ->
Cfg00
end,
{port_env, [{"CFLAGS", "$CFLAGS " ++ CfgCFlags},
{"LDFLAGS", "$LDFLAGS " ++ CfgLDFlags}]},
%% Rebar3 support for hex.pm support:
%% - Transform dependencies specification to use hex.pm packages:
%% deps of the form: {Name, _Vsn, {git, _URL, {tag, Version}}}
%% are expected to refer to package and are rewritten for rebar3 as:
%% {Name, Version}
%% - Add rebar3_hex plugin
IsRebar3 = case application:get_key(rebar, vsn) of
{ok, VSN} ->
[VSN1 | _] = string:tokens(VSN, "-"),
[Maj, Min, Patch] = string:tokens(VSN1, "."),
(list_to_integer(Maj) >= 3);
undefined ->
lists:keymember(mix, 1, application:loaded_applications())
end,
Cfg2 = case IsRebar3 of
true ->
DepsFun = fun(DepsList) -> lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
{DepName, Version};
(Dep) ->
Dep
end, DepsList)
end,
RB1 = ModCfg(Cfg1, [deps], DepsFun, []),
ModCfg(RB1, [plugins], fun(V) -> V ++ [rebar3_hex] end, []);
false ->
Cfg1
end,
{deps, [{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}}]},
%% When running Travis test, upload test coverage result to coveralls:
Config = case os:getenv("TRAVIS") of
"true" ->
JobId = os:getenv("TRAVIS_JOB_ID"),
Cfg3 = ModCfg(Cfg2, [deps], fun(V) -> [{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}|V] end, []),
ModCfg(Cfg3, [post_hooks], fun(V) -> V ++ [{eunit, "echo '\n%%! -pa .eunit/ deps/coveralls/ebin\nmain(_)->{ok,F}=file:open(\"erlang.json\",[write]),io:fwrite(F,\"~s\",[coveralls:convert_file(\".eunit/cover.coverdata\", \""++JobId++"\", \"travis-ci\")]).' > getcover.erl"},
{eunit, "escript ./getcover.erl"}] end, []);
_ ->
Cfg2
end,
{port_specs, [{"priv/lib/p1_yaml.so", ["c_src/p1_yaml.c"]}]}
].
Config.
%% Local Variables:
%% mode: erlang
......
%%%----------------------------------------------------------------------
%%% File : fast_yaml.app.src
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : Application package description
%%% Created : 4 Apr 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%% http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
{application, fast_yaml,
[{description, "Fast YAML native library for Erlang / Elixir"},
{vsn, "1.0.1"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib]},
{mod, {fast_yaml_app,[]}},
%% hex.pm packaging:
{files, ["src/", "c_src/fast_yaml.c", "include/", "rebar.config", "rebar.config.script", "README.md", "LICENSE.txt"]},
{licenses, ["Apache 2.0"]},
{maintainers, ["ProcessOne"]},
{links, [{"Github", "https://github.com/processone/fast_yaml"}]}]}.
%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8:
%%%----------------------------------------------------------------------
%%% File : p1_yaml.erl
%%% File : fast_yaml.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : YAML parser
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% p1_yaml, Copyright (C) 2002-2015 ProcessOne
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%% http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
-module(p1_yaml).
-module(fast_yaml).
%% API
-export([load_nif/0, decode/1, decode/2, start/0, stop/0,
......@@ -43,18 +40,18 @@
%%% API
%%%===================================================================
start() ->
application:start(p1_yaml).
application:start(fast_yaml).
stop() ->
application:stop(p1_yaml).
application:stop(fast_yaml).
load_nif() ->
SOPath = p1_nif_utils:get_so_path(?MODULE, [p1_yaml], "p1_yaml"),
SOPath = p1_nif_utils:get_so_path(?MODULE, [fast_yaml], "fast_yaml"),
case catch erlang:load_nif(SOPath, 0) of
ok ->
ok;
Err ->
error_logger:warning_msg("unable to load p1_yaml NIF: ~p~n", [Err]),
error_logger:warning_msg("unable to load fast_yaml NIF: ~p~n", [Err]),
Err
end.
......@@ -143,13 +140,13 @@ make_flags([{plain_as_atom, false}|Opts]) ->
make_flags([plain_as_atom|Opts]) ->
?PLAIN_AS_ATOM bor make_flags(Opts);
make_flags([Opt|Opts]) ->
error_logger:warning_msg("p1_yaml: unknown option ~p", [Opt]),
error_logger:warning_msg("fast_yaml: unknown option ~p", [Opt]),
make_flags(Opts);
make_flags([]) ->
0.
nif_decode(_Data, _Flags) ->
error_logger:error_msg("p1_yaml NIF not loaded", []),
error_logger:error_msg("fast_yaml NIF not loaded", []),
erlang:nif_error(nif_not_loaded).
indent(N) ->
......
%%%----------------------------------------------------------------------
%%% File : p1_yaml_app.erl
%%% File : fast_yaml_app.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : YAML parser application
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% p1_yaml, Copyright (C) 2002-2015 ProcessOne
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%% http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
-module(p1_yaml_app).
-module(fast_yaml_app).
-behaviour(application).
......@@ -35,9 +32,9 @@
%%% Application callbacks
%%%===================================================================
start(_StartType, _StartArgs) ->
case p1_yaml:load_nif() of
case fast_yaml:load_nif() of
ok ->
p1_yaml_sup:start_link();
fast_yaml_sup:start_link();
Err ->
Err
end.
......
%%%----------------------------------------------------------------------
%%% File : p1_yaml_sup.erl
%%% File : fast_yaml_sup.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : YAML parser supervisor
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% p1_yaml, Copyright (C) 2002-2015 ProcessOne
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%% http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
-module(p1_yaml_sup).
-module(fast_yaml_sup).
-behaviour(supervisor).
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2013, Evgeniy Khramtsov