8 Commits

Author SHA1 Message Date
67469cc575 Update version 2022-05-22 15:17:49 -07:00
01f48a394d Update rexylib 2022-05-21 12:36:26 -07:00
5c261ed7ed Update to new librexy 2022-05-21 09:58:26 -07:00
a3ea13fc03 Update to newer rexylib 2022-03-20 14:17:04 -07:00
0d9cebedc0 Remove broken rjp::cast and rjp::convert. Added const iterator access to object and array 2022-03-19 10:37:57 -07:00
f763438c47 Add object and array size queries to rjp++ 2021-04-11 14:51:54 -07:00
cceb4eda7a Change shared library SOVERSION 2021-04-04 09:30:16 -07:00
47da1d454d #include cleanups 2021-04-04 09:08:51 -07:00
23 changed files with 162 additions and 136 deletions

View File

@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0.2)
include(GNUInstallDirs)
set(rjp_VERSION_MAJOR 1)
set(rjp_VERSION_MINOR 0)
set(rjp_VERSION_MINOR 1)
set(rjp_VERSION_REVISION 0)
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
include_directories("${INCLUDE_PATH}")
@@ -20,10 +20,11 @@ mark_as_advanced(ENABLE_PROFILING)
set(SOURCE_LIST "src/rjp_lex.c" "src/rjp_ordered_object.c" "src/rjp_unordered_object.c" "src/rjp_parse.c" "src/output.c" "src/rjp_array.c" "src/rjp.c" "src/rjp_object.c" "src/rjp_string.c" "src/tree.c")
if(ENABLE_SHARED)
add_library(rjp SHARED ${SOURCE_LIST})
set_target_properties(rjp PROPERTIES SOVERSION "${rjp_VERSION_MAJOR}.${rjp_VERSION_MINOR}.${rjp_VERSION_REVISION}")
set_target_properties(rjp PROPERTIES SOVERSION "${rjp_VERSION_MAJOR}.${rjp_VERSION_MINOR}")
else()
add_library(rjp STATIC ${SOURCE_LIST})
endif()
set_target_properties(rjp PROPERTIES VERSION "${rjp_VERSION_MAJOR}.${rjp_VERSION_MINOR}.${rjp_VERSION_REVISION}")
if(ENABLE_DIAGNOSTICS)
set(RJP_ENABLE_DIAGNOSTICS 1)

View File

@@ -14,7 +14,7 @@ option(BUILD_TESTS "Build test programs" OFF)
option(ENABLE_PROFILING "Enable asan" OFF)
mark_as_advanced(ENABLE_PROFILING)
set(SOURCE_LIST "src/allocator.cpp" "src/array.cpp" "src/integral.cpp" "src/object.cpp" "src/rjp.cpp" "src/string.cpp" "src/string_val.cpp" "src/value.cpp" "src/vget_proxy.cpp" "src/container.cpp")
set(SOURCE_LIST "src/allocator.cpp" "src/array.cpp" "src/integral.cpp" "src/object.cpp" "src/rjp.cpp" "src/string.cpp" "src/string_val.cpp" "src/value.cpp" "src/vget_proxy.cpp" "src/container.cpp" "src/member.cpp")
if(ENABLE_SHARED)
set(RJP++_LIBFLAGS "-lrjp++ -lrexy")
add_library(rjp++ SHARED ${SOURCE_LIST})

View File

@@ -20,6 +20,7 @@
#define RJP_ARRAY_HPP
#include <rjp.h>
#include <cstdlib> //size_t
#include "iterator.hpp"
#include "value.hpp"
#include "integral.hpp"
@@ -57,6 +58,7 @@ namespace rjp{
public:
using iterator = array_iterator;
using const_iterator = const iterator;
using size_type = size_t;
public:
using value::value;
array(void);
@@ -101,6 +103,10 @@ namespace rjp{
iterator end(void);
const_iterator begin(void)const;
const_iterator end(void)const;
const_iterator cbegin(void)const;
const_iterator cend(void)const;
size_type size(void)const;
private:
static RJP_value* create_element(RJP_value* arr);

View File

@@ -52,8 +52,8 @@ namespace rjp{
member& operator=(const member&) = default;
member& operator=(member&&) = default;
rexy::static_string<char> key(void)const{
return rexy::static_string<char>(member_key(this->m_value)->value, member_key(this->m_value)->length);
rexy::string_view key(void)const{
return rexy::string_view(member_key(this->m_value)->value, member_key(this->m_value)->length);
}
string steal_key(void){
return string(this->m_value);
@@ -76,8 +76,8 @@ namespace rjp{
member& operator=(const member&) = default;
member& operator=(member&&) = default;
rexy::static_string<char> key(void)const{
return rexy::static_string<char>(member_key(m_value)->value, member_key(m_value)->length);
rexy::string_view key(void)const{
return rexy::string_view(member_key(m_value)->value, member_key(m_value)->length);
}
string steal_key(void){
return string(m_value);

View File

@@ -21,6 +21,7 @@
#include <rjp.h>
#include <rexy/string_base.hpp>
#include <cstdlib> //size_t
#include "value.hpp"
#include "iterator.hpp"
#include "member.hpp"
@@ -60,6 +61,7 @@ namespace rjp{
public:
using iterator = object_iterator;
using const_iterator = const iterator;
using size_type = size_t;
public:
using value::value;
object(void);
@@ -73,13 +75,13 @@ namespace rjp{
object& operator=(object&&) = default;
template<class Val>
member<std::decay_t<Val>> add(const rexy::string_base<char>& key, typename std::decay_t<Val>::underlying_type t){
member<std::decay_t<Val>> add(const rexy::string_view& key, typename std::decay_t<Val>::underlying_type t){
RJP_value* newmem = add_member_impl(key);
detail::set_to_underlying<std::decay_t<Val>>(newmem, t);
return create_unmanaged(newmem);
}
template<class Val = null>
member<std::decay_t<Val>> add(const rexy::string_base<char>& key){
member<std::decay_t<Val>> add(const rexy::string_view& key){
RJP_value* newmem = add_member_impl(key);
if constexpr(std::is_same<std::decay_t<Val>,rjp::array>::value)
set_array_value(newmem);
@@ -91,11 +93,11 @@ namespace rjp{
detail::set_to_underlying<std::decay_t<Val>>(newmem, 0);
return create_unmanaged(newmem);
}
member<string_val> add(const rexy::string_base<char>& key, const RJP_string&);
member<string_val> add(const rexy::string_base<char>& key, RJP_string&&);
member<string_val> add(const rexy::string_base<char>& key, const char*, RJP_index len = 0);
member<string_val> add(const rexy::string_base<char>& key, const rexy::string_base<char>&);
member<string_val> add(const rexy::string_base<char>& key, string&&);
member<string_val> add(const rexy::string_view& key, const RJP_string&);
member<string_val> add(const rexy::string_view& key, RJP_string&&);
member<string_val> add(const rexy::string_view& key, const char*, RJP_index len = 0);
member<string_val> add(const rexy::string_view& key, const rexy::string_view&);
member<string_val> add(const rexy::string_view& key, string&&);
template<class Val>
member<std::decay_t<Val>> add(string&& key, typename std::decay_t<Val>::underlying_type t){
@@ -119,25 +121,31 @@ namespace rjp{
member<string_val> add(string&& key, const RJP_string&);
member<string_val> add(string&& key, RJP_string&&);
member<string_val> add(string&& key, const char*, RJP_index len = 0);
member<string_val> add(string&& key, const rexy::string_base<char>&);
member<string_val> add(string&& key, const rexy::string_view&);
member<string_val> add(string&& key, string&&);
value remove(const rexy::string_base<char>& key);
value remove(const rexy::string_view& key);
value& remove(value& val);
void destroy(const rexy::string_base<char>& key);
void destroy(const rexy::string_view& key);
void destroy(value&& val);
bool has_child(const value&);
iterator begin(void);
const_iterator begin(void)const;
iterator end(void)const;
iterator end(void);
const_iterator end(void)const;
value search(const rexy::string_base<char>& key)const;
const_iterator cbegin(void)const;
const_iterator cend(void)const;
size_type size(void)const;
value search(const rexy::string_view& key)const;
private:
RJP_value* add_member_impl(const rexy::string_base<char>& key);
RJP_value* add_member_impl(const rexy::string_view& key);
RJP_value* add_member_impl(string&& key);
};

View File

@@ -48,8 +48,11 @@ namespace rjp{
string errstr(void)const;
};
[[nodiscard]]
string to_json(const value& val, int format = RJP_FORMAT_PRETTY);
[[nodiscard]]
parse_res parse_json(const rexy::string_base<char>& str, RJP_parse_flag = RJP_PARSE_NO_EXT);
[[nodiscard]]
parse_res parse_json(const char* str, RJP_parse_flag = RJP_PARSE_NO_EXT);
namespace detail{
template<int... Indexes>
@@ -91,6 +94,7 @@ namespace rjp{
int irjp_parse_callback(char* dest, int size, void* userdata);
}
template<class Func, class... Args>
[[nodiscard]]
parse_res parse_json(RJP_parse_flag f, Func&& func, Args&&... args){
RJP_parse_callback cb;
detail::invoker_impl<Func,Args...> inv(std::forward<Func>(func), std::forward<Args>(args)...);

View File

@@ -23,60 +23,19 @@
#include "integral.hpp"
namespace rjp{
namespace detail{
template<class To, class From, bool = std::is_same<std::remove_reference_t<To>,std::remove_reference_t<From>>::value>
struct convert_helper;
template<class To, class From>
struct convert_helper<To,From,false>{
static To perform(From&& t){
return To(std::move(t));
}
};
template<class To, class From>
struct convert_helper<To,From&,false>{
static To perform(const From& t){
return To(const_cast<RJP_value*>(t.raw()), false);
}
};
template<class To, class From>
struct convert_helper<To,From,true>{
static decltype(auto) perform(From&& t){
return std::forward<From>(t);
}
};
template<class To, class From>
auto convert_to(From&& from){
return To(std::forward<From>(from));
}
template<class To, class From>
To convert(From&& from){
return detail::convert_helper<To,From>::perform(std::forward<From>(from));
}
namespace detail{
template<class To, class From>
struct get_ref{
using type = std::remove_reference_t<To>;
};
template<class To, class From>
struct get_ref<To, From&>{
using type = std::remove_reference_t<To>&;
};
template<class To, class From>
struct get_ref<To, From&&>{
using type = std::remove_reference_t<To>&&;
};
template<class To, class From>
struct get_ref<To&&, From&>{
using type = To&&;
};
template<class To, class From>
struct get_ref<To&&, From&&>{
using type = To&&;
};
auto steal_as(From&& from){
return To(std::move(from));
}
template<class To, class From>
decltype(auto) cast(From&& from){
return static_cast<typename detail::get_ref<To,From&&>::type>(std::forward<From>(from));
auto borrow_as(From&& from){
return To(const_cast<RJP_value*>(from.raw()), false);
}
namespace detail{

View File

@@ -20,7 +20,7 @@
#define RJP_STRING_VAL_HPP
#include <rjp.h>
#include <rexy/string_base.hpp>
#include <rexy/string.hpp>
#include "string.hpp"
#include "value.hpp"
@@ -32,7 +32,7 @@ namespace rjp{
using underlying_type = RJP_string;
public:
using value::value;
string_val(const rexy::string_base<char>& str);
string_val(const rexy::string_view& str);
string_val(string&& str);
string_val(void);
string_val(const value& val);
@@ -48,7 +48,7 @@ namespace rjp{
string_val& operator=(const string_val&) = default;
string_val& operator=(string_val&&) = default;
rexy::static_string<char> get(void)const;
rexy::string_view get(void)const;
string steal(void);
void set(const rexy::string_base<char>& str);
void set(string&& str);

View File

@@ -35,7 +35,7 @@ namespace rjp{
vget_proxy(const rjp::value* v);
operator int(void)const;
operator bool(void)const;
operator rexy::static_string<char>(void)const;
operator rexy::string_view(void)const;
operator double(void)const;
};
}

View File

@@ -76,12 +76,24 @@ namespace rjp{
array::iterator array::begin(void){
return iterator(m_value);
}
array::iterator array::end(void){
return iterator();
}
array::const_iterator array::begin(void)const{
return const_iterator(m_value);
}
array::iterator array::end(void){
array::const_iterator array::end(void)const{
return iterator();
}
array::const_iterator array::cbegin(void)const{
return const_iterator(m_value);
}
array::const_iterator array::cend(void)const{
return iterator();
}
array::size_type array::size(void)const{
return rjp_num_elements(m_value);
}
RJP_value* array::create_element(RJP_value* arr){
return rjp_new_element(arr);
}

27
rjp++/src/member.cpp Normal file
View File

@@ -0,0 +1,27 @@
/**
rjp++
Copyright (C) 2022 rexy712
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 3 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "member.hpp"
namespace rjp{
const RJP_string* member_base::member_key(RJP_value* v){
return rjp_member_key(v);
}
}

View File

@@ -39,27 +39,27 @@ namespace rjp{
if(rjp_value_type(m_value) != rjp_json_object)
rjp_set_object(m_value);
}
member<string_val> object::add(const rexy::string_base<char>& key, const RJP_string& s){
member<string_val> object::add(const rexy::string_view& key, const RJP_string& s){
RJP_value* newmem = rjp_new_member(m_value, key.get(), key.length());
rjp_set_string(newmem, s.value, s.length);
return create_unmanaged(newmem);
}
member<string_val> object::add(const rexy::string_base<char>& key, RJP_string&& s){
member<string_val> object::add(const rexy::string_view& key, RJP_string&& s){
RJP_value* newmem = rjp_new_member(m_value, key.get(), key.length());
rjp_set_string_steal(newmem, s.value, s.length);
return create_unmanaged(newmem);
}
member<string_val> object::add(const rexy::string_base<char>& key, const char* s, RJP_index len){
member<string_val> object::add(const rexy::string_view& key, const char* s, RJP_index len){
RJP_value* newmem = rjp_new_member(m_value, key.get(), key.length());
rjp_set_string(newmem, s, len);
return create_unmanaged(newmem);
}
member<string_val> object::add(const rexy::string_base<char>& key, const rexy::string_base<char>& s){
member<string_val> object::add(const rexy::string_view& key, const rexy::string_view& s){
RJP_value* newmem = rjp_new_member(m_value, key.get(), key.length());
rjp_set_string(newmem, s.get(), s.length());
return create_unmanaged(newmem);
}
member<string_val> object::add(const rexy::string_base<char>& key, string&& s){
member<string_val> object::add(const rexy::string_view& key, string&& s){
RJP_value* newmem = rjp_new_member(m_value, key.get(), key.length());
auto len = s.length();
rjp_set_string_steal(newmem, s.release(), len);
@@ -81,7 +81,7 @@ namespace rjp{
rjp_set_string(newmem, s, len);
return create_unmanaged(newmem);
}
member<string_val> object::add(string&& key, const rexy::string_base<char>& s){
member<string_val> object::add(string&& key, const rexy::string_view& s){
RJP_value* newmem = rjp_new_member_steal_key(m_value, key.get(), key.length());
rjp_set_string(newmem, s.get(), s.length());
return create_unmanaged(newmem);
@@ -93,7 +93,7 @@ namespace rjp{
return create_unmanaged(newmem);
}
value object::remove(const rexy::string_base<char>& key){
value object::remove(const rexy::string_view& key){
RJP_value* removed = rjp_remove_member_by_key(m_value, key.get());
return create_managed(removed);
}
@@ -103,7 +103,7 @@ namespace rjp{
return val;
}
void object::destroy(const rexy::string_base<char>& key){
void object::destroy(const rexy::string_view& key){
rjp_free_member_by_key(m_value, key.get());
}
void object::destroy(value&& val){
@@ -119,15 +119,27 @@ namespace rjp{
object::const_iterator object::begin(void)const{
return const_iterator(m_value);
}
object::iterator object::end(void)const{
object::iterator object::end(void){
return iterator();
}
value object::search(const rexy::string_base<char>& key)const{
object::const_iterator object::end(void)const{
return const_iterator();
}
object::const_iterator object::cbegin(void)const{
return const_iterator(m_value);
}
object::const_iterator object::cend(void)const{
return const_iterator();
}
object::size_type object::size(void)const{
return rjp_num_members(m_value);
}
value object::search(const rexy::string_view& key)const{
RJP_value* result = rjp_search_member(m_value, key.get());
return create_unmanaged(result);
}
RJP_value* object::add_member_impl(const rexy::string_base<char>& key){
RJP_value* object::add_member_impl(const rexy::string_view& key){
return rjp_new_member(m_value, key.get(), key.length());
}
RJP_value* object::add_member_impl(string&& key){

View File

@@ -22,7 +22,7 @@
namespace rjp{
string_val::string_val(const rexy::string_base<char>& str):
string_val::string_val(const rexy::string_view& str):
value(rjp_new_string(str.get(), str.length()), true){}
string_val::string_val(string&& str):
value(rjp_new_string_steal(str.get(), str.length()), true)
@@ -30,7 +30,7 @@ namespace rjp{
str.release();
}
string_val::string_val(void):
string_val(""_ss){}
string_val(""_sv){}
string_val::string_val(const value& val):
value(val)
{
@@ -70,9 +70,9 @@ namespace rjp{
rjp_set_string_steal(m_value, i.release(), length);
}
rexy::static_string<char> string_val::get(void)const{
rexy::string_view string_val::get(void)const{
const RJP_string* str = rjp_get_cstring(m_value);
return rexy::static_string<char>(str->value, str->length);
return rexy::string_view(str->value, str->length);
}
string string_val::steal(void){
return string(m_value);

View File

@@ -27,16 +27,16 @@ namespace rjp::detail{
vget_proxy::vget_proxy(const rjp::value* v):
m_value(v){}
vget_proxy::operator int(void)const{
return rjp::cast<const rjp::integer>(*m_value).get();
return rjp::borrow_as<rjp::integer>(*m_value).get();
}
vget_proxy::operator bool(void)const{
return rjp::cast<const rjp::boolean>(*m_value).get();
return rjp::borrow_as<rjp::boolean>(*m_value).get();
}
vget_proxy::operator rexy::static_string<char>(void)const{
return rjp::cast<const rjp::string_val>(*m_value).get();
vget_proxy::operator rexy::string_view(void)const{
return rjp::borrow_as<rjp::string_val>(*m_value).get();
}
vget_proxy::operator double(void)const{
return rjp::cast<const rjp::dfloat>(*m_value).get();
return rjp::borrow_as<rjp::dfloat>(*m_value).get();
}
}

View File

@@ -34,31 +34,31 @@ rjp::value case_6(void){
//handle object with member
rjp::value case_8(void){
rjp::object obj;
obj.add<rjp::integer>("key"_ss, 7);
return rjp::cast<rjp::value&&>(obj);
obj.add<rjp::integer>("key"_sv, 7);
return rjp::steal_as<rjp::value>(obj);
}
//handle object with subobject
rjp::value case_9(void){
rjp::object obj;
rjp::object sub = obj.add<rjp::object>("key"_ss);
sub.add<rjp::boolean>("subkey"_ss, false);
return rjp::cast<rjp::value&&>(obj);
rjp::object sub = obj.add<rjp::object>("key"_sv);
sub.add<rjp::boolean>("subkey"_sv, false);
return rjp::steal_as<rjp::value>(obj);
}
//handle object with multiple members
rjp::value case_10(void){
rjp::object obj;
rjp::object sub = obj.add<rjp::object>("key"_ss);
sub.add<rjp::boolean>("subkey"_ss, false);
sub.add<rjp::boolean>("subkey2"_ss, true);
return rjp::cast<rjp::value&&>(obj);
rjp::object sub = obj.add<rjp::object>("key"_sv);
sub.add<rjp::boolean>("subkey"_sv, false);
sub.add<rjp::boolean>("subkey2"_sv, true);
return rjp::steal_as<rjp::value>(obj);
}
//handle object member ordering
rjp::value case_11(void){
rjp::object obj;
rjp::object sub = obj.add<rjp::object>("key"_ss);
sub.add<rjp::boolean>("subkey2"_ss, true);
sub.add<rjp::boolean>("subkey"_ss, false);
return rjp::cast<rjp::value&&>(obj);
rjp::object sub = obj.add<rjp::object>("key"_sv);
sub.add<rjp::boolean>("subkey2"_sv, true);
sub.add<rjp::boolean>("subkey"_sv, false);
return rjp::steal_as<rjp::value>(obj);
}
//handle orderedobject member ordering
/*RJP_value* case_12(void){
@@ -82,13 +82,13 @@ RJP_value* case_13(void){
rjp::value case_14(void){
rjp::array arr;
arr.add<rjp::integer>(5);
return rjp::cast<rjp::value&&>(arr);
return rjp::steal_as<rjp::value>(arr);
}
//handle array with subarray
rjp::value case_15(void){
rjp::array arr;
arr.add<rjp::array>().add<rjp::boolean>(false);
return rjp::cast<rjp::value&&>(arr);
return rjp::steal_as<rjp::value>(arr);
}
//handle array with multiple elements
rjp::value case_16(void){
@@ -96,7 +96,7 @@ rjp::value case_16(void){
rjp::array sub = arr.add<rjp::array>();
sub.add<rjp::boolean>(false);
sub.add<rjp::boolean>(true);
return rjp::cast<rjp::value&&>(arr);
return rjp::steal_as<rjp::value>(arr);
}
//handle array with multiple elements and subarray
rjp::value case_17(void){
@@ -105,16 +105,16 @@ rjp::value case_17(void){
rjp::array sub = arr.add<rjp::array>();
sub.add<rjp::boolean>(false);
sub.add<rjp::boolean>(true);
return rjp::cast<rjp::value&&>(arr);
return rjp::steal_as<rjp::value>(arr);
}
//handle array with subobject with subarray
rjp::value case_18(void){
rjp::array arr;
arr.add<rjp::integer>(5);
rjp::object subobj = arr.add<rjp::object>();
rjp::array subarr = subobj.add<rjp::array>("key"_ss);
rjp::array subarr = subobj.add<rjp::array>("key"_sv);
subarr.add<rjp::boolean>(false);
return rjp::cast<rjp::value&&>(arr);
return rjp::steal_as<rjp::value>(arr);
}
//handle object with many members
rjp::value case_19(void){
@@ -123,10 +123,10 @@ rjp::value case_19(void){
arr.add<rjp::integer>(5);
rjp::object subobj = arr.add<rjp::object>();
for(int i = 0;i < 10;++i){
subobj.add<rjp::boolean>(rexy::static_string<char>(c), i % 2 == 0);
subobj.add<rjp::boolean>(rexy::string_view(c), i % 2 == 0);
c[3] += 1;
}
return rjp::cast<rjp::value&&>(arr);
return rjp::steal_as<rjp::value>(arr);
}
//handle orderedobject with many members as array element
/*RJP_value* case_20(void){
@@ -148,10 +148,10 @@ rjp::value case_19(void){
//handle array with many element as object member
rjp::value case_21(void){
rjp::object obj;
rjp::array arr = obj.add<rjp::array>("arr"_ss);
rjp::array arr = obj.add<rjp::array>("arr"_sv);
for(int i = 0;i < 10;++i)
arr.add<rjp::integer>(i);
return rjp::cast<rjp::value&&>(obj);
return rjp::steal_as<rjp::value>(obj);
}
/*
//handle unorderedobject conversion
@@ -196,20 +196,20 @@ RJP_value* case_25(void){
}
*/
rjp::value case_26(void){
return rjp::string_val("string"_ss);
return rjp::string_val("string"_sv);
}
rjp::value case_27(void){
return rjp::string_val(""_ss);
return rjp::string_val(""_sv);
}
rjp::value case_28(void){
rjp::object obj;
obj.add("key"_ss, "string"_ss);
return rjp::cast<rjp::value&&>(obj);
obj.add("key"_sv, "string"_sv);
return rjp::steal_as<rjp::value>(obj);
}
rjp::value case_29(void){
rjp::object obj;
obj.add("key"_ss, ""_ss);
return rjp::cast<rjp::value&&>(obj);
obj.add("key"_sv, ""_sv);
return rjp::steal_as<rjp::value>(obj);
}
static test_pair tests[] = {

View File

@@ -16,9 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include "rjp.h"
#include "rjp_internal.h"
#include "rjp_string.h"
@@ -26,6 +23,8 @@
#include "rjp_value.h"
#include "rjp_array.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h> //PRId64
#include <string.h> //strlen
#include <stdio.h> //sprintf

View File

@@ -22,7 +22,7 @@
#include "rjp_array.h"
#include "rjp_value.h"
#include <stdlib.h> //free, malloc
#include <stdlib.h> //free, malloc, calloc
void* rjp_alloc(RJP_index nbytes){
return malloc(nbytes);

View File

@@ -16,14 +16,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stddef.h>
#include <string.h> //memset
#include "rjp_internal.h"
#include "rjp_array.h"
#include "rjp_value.h"
#include "rjp_array_element.h"
#include <string.h> //memset
void irjp_copy_array(RJP_value* dest, const RJP_value* src, const RJP_memory_fns* fns){
dest->array.elements = dest->array.last = NULL;
for(RJP_array_element* curr = src->array.elements;curr;curr = curr->next){

View File

@@ -18,6 +18,7 @@
#include "rjp_lex.h"
#include "rjp.h"
#include <ctype.h> //isalpha, etc
#include <string.h> //memcpy

View File

@@ -21,7 +21,6 @@
#include "rjp_object.h"
#include "rjp_object_member.h"
#include "rjp_value.h"
#include <string.h> //strlen
#include <string.h> //strlen, strncpy

View File

@@ -23,6 +23,7 @@
#include "rjp_value.h"
#include "rjp_string.h"
#include "rjp_lex.h"
#include <stdlib.h> //strtod, strtol
#include <string.h> //memcpy

View File

@@ -16,13 +16,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include "rjp_internal.h"
#include "rjp_string.h"
#include "rjp_value.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h> //PRId64
#include <stdio.h> //fprintf
#include <stdint.h> //uintN_t
#include <string.h> //strcpy

View File

@@ -18,13 +18,12 @@
#include "tree.h"
#include <string.h>
#include <stdio.h>
#include "rjp_string.h"
#include "rjp_internal.h"
#include "rjp_value.h"
#include <string.h> //memset, strcmp
#define BLACK 0
#define RED 1