Copyright: © 1999-2004 Southampton University, 2004-2009 Andy Rushton
License: BSD
- Portion: yajl
- Source: http://lloyd.github.com/yajl/
-Copyright: © 2009, Lloyd Hilaiel
- License: BSD
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DATA_FILES=$(echo $(cd data; \
- find . -name "*.json" \
- -o -name "*.lua" \
+ find . -name "*.lua" \
-o -name "*.ogg" \
-o -name "*.png" \
- -o -name "*.xm" \
-o -name "yoinkrc"))
AC_SUBST([DATA_FILES])
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+++ /dev/null
-{
- "tiles_s": 1,
- "tiles_t": 1,
- "min_filter": "linear",
- "mag_filter": "linear",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 1
+tiles_t = 1
+min_filter = LINEAR
+mag_filter = LINEAR
+wrap_s = CLAMP
+wrap_t = CLAMP
+++ /dev/null
-{
- "tiles_s": 1,
- "tiles_t": 1,
- "min_filter": "linear",
- "mag_filter": "linear",
- "wrap_s": "repeat",
- "wrap_t": "repeat"
-}
--- /dev/null
+tiles_s = 1
+tiles_t = 1
+min_filter = LINEAR
+mag_filter = LINEAR
+wrap_s = REPEAT
+wrap_t = REPEAT
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 1,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 1
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = CLAMP
+wrap_t = CLAMP
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = CLAMP
+wrap_t = CLAMP
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = CLAMP
+wrap_t = CLAMP
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 8,
- "min_filter": "nearest",
- "mag_filter": "nearest"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 8
+min_filter = NEAREST
+mag_filter = NEAREST
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+++ /dev/null
-{
- "tiles_s": 4,
- "tiles_t": 2,
- "min_filter": "nearest",
- "mag_filter": "nearest"
-}
--- /dev/null
+tiles_s = 4
+tiles_t = 2
+min_filter = NEAREST
+mag_filter = NEAREST
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = CLAMP
+wrap_t = CLAMP
+++ /dev/null
-{
- "tiles_s": 8,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest"
-}
--- /dev/null
+tiles_s = 8
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+++ /dev/null
-{
- "tiles_s": 4,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "repeat",
- "wrap_t": "repeat"
-}
--- /dev/null
+tiles_s = 4
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = REPEAT
+wrap_t = REPEAT
+++ /dev/null
-{
- "tiles_s": 4,
- "tiles_t": 1,
- "min_filter": "nearest",
- "mag_filter": "nearest"
-}
--- /dev/null
+tiles_s = 4
+tiles_t = 1
+min_filter = NEAREST
+mag_filter = NEAREST
+++ /dev/null
-{
- "tiles_s": 4,
- "tiles_t": 4,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 4
+tiles_t = 4
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = CLAMP
+wrap_t = CLAMP
+++ /dev/null
-{
- "tiles_s": 2,
- "tiles_t": 1,
- "min_filter": "nearest",
- "mag_filter": "nearest",
- "wrap_s": "clamp",
- "wrap_t": "clamp"
-}
--- /dev/null
+tiles_s = 2
+tiles_t = 1
+min_filter = NEAREST
+mag_filter = NEAREST
+wrap_s = CLAMP
+wrap_t = CLAMP
#include <map>
#include <vector>
-#include "Animation.hh"
-#include "Mippleton.hh"
-#include "Serializable.hh"
-
+#include <Moof/Log.hh>
+#include <Moof/Mippleton.hh>
+#include <Moof/Script.hh>
-namespace Mf {
+#include "Animation.hh"
/**
* which wants to use these loaded sequences.
*/
- class Data : public Mippleton<Data>
+ class Data : public Mf::Mippleton<Data>
{
friend class Impl;
- friend class Mippleton<Data>;
+ friend class Mf::Mippleton<Data>;
/**
* A frame of an animation sequence. A frame is merely an index which
struct Frame
{
unsigned index; ///< Frame index.
- Scalar duration; ///< Frame duration.
+ Mf::Scalar duration; ///< Frame duration.
/**
* Construction is initialization. The frame data is loaded from a
* frame map which is probably loaded within an animation file.
*/
- Frame(SerializableP root) :
+ Frame(Mf::Script& script, Mf::Script::Value table) :
index(0),
duration(1.0)
{
- Serializable::Map rootObj;
-
- if (root->get(rootObj))
- {
- Serializable::Map::iterator it;
+ table.pushField("index");
+ script[-1].get(index);
+ script.pop();
- for (it = rootObj.begin(); it != rootObj.end(); ++it)
- {
- std::string key = (*it).first;
- if (key == "index")
- {
- long value = 0;
- (*it).second->get(value);
- index = unsigned(value);
- }
- else if (key == "duration")
- {
- double value = 0.0;
- (*it).second->getNumber(value);
- duration = Scalar(value);
- }
- }
- }
+ table.pushField("duration");
+ script[-1].get(duration);
+ script.pop();
}
};
struct Sequence
{
std::vector<Frame> frames; ///< List of frames.
- Scalar delay; ///< Scale frame durations.
+ Mf::Scalar delay; ///< Scale frame durations.
bool loop; ///< Does the sequence repeat?
std::string next; ///< Next sequence name.
* constructor which loads each individual frame.
*/
- Sequence(SerializableP root) :
+ Sequence(Mf::Script& script, Mf::Script::Value table) :
delay(0.0),
loop(true)
{
- Serializable::Map rootObj;
+ table.pushField("delay");
+ script[-1].get(delay);
+ script.pop();
- if (root->get(rootObj))
+ table.pushField("loop");
+ script[-1].get(loop);
+ script.pop();
+
+ table.pushField("next");
+ script[-1].get(next);
+ script.pop();
+
+ // TODO - sequence class/type not yet implemented
+
+ table.pushField("frames");
+ Mf::Script::Value frameTable = script.getTop();
+ if (frameTable.isTable())
{
- Serializable::Map::iterator it;
- for (it = rootObj.begin(); it != rootObj.end(); ++it)
+ Mf::Script::Value top = script[-1];
+ int index = 1;
+
+ for (;;)
{
- std::string key = (*it).first;
-
- if (key == "frames")
- {
- Serializable::Array framesObj;
-
- if ((*it).second->get(framesObj))
- {
- Serializable::Array::iterator jt;
-
- for (jt = framesObj.begin();
- jt != framesObj.end(); ++jt)
- {
- if (*jt)
- {
- frames.push_back(Frame(*jt));
- }
- }
- }
- }
- else if (key == "delay")
- {
- double value;
- (*it).second->getNumber(value);
- delay = Scalar(value);
- }
- else if (key == "loop")
- {
- (*it).second->get(loop);
- }
- else if (key == "next")
- {
- (*it).second->get(next);
- }
+ script.push(index);
+ frameTable.pushField();
+
+ if (top.isTable()) frames.push_back(Frame(script, top));
+ else break;
+
+ ++index;
}
}
+ script.pop();
}
};
void loadFromFile()
{
+ Mf::Script script;
std::string filePath = Animation::getPath(getName());
- Deserializer deserializer(filePath);
+ script.importStandardLibraries();
+ importLogScript(script);
+ importAnimationBindings(script);
- SerializableP root = deserializer.deserialize();
-
- if (root)
+ if (script.doFile(filePath) != Mf::Script::SUCCESS)
{
- Serializable::Map rootObj;
+ std::string str;
+ script[-1].get(str);
+ Mf::logScript("%s", str.c_str());
+ }
+ }
- if (root->get(rootObj))
- {
- Serializable::Map::iterator it;
+ int defineSequence(Mf::Script& script)
+ {
+ Mf::Script::Value name = script[1].requireString();
+ Mf::Script::Value table = script[2].requireTable();
- for (it = rootObj.begin(); it != rootObj.end(); ++it)
- {
- sequences.insert(std::pair<std::string,Sequence>((*it).first,
- Sequence((*it).second)));
- }
- }
- }
+ std::string nameStr;
+ name.get(nameStr);
+
+ sequences.insert(std::pair<std::string,Sequence>(nameStr,
+ Sequence(script, table)));
+
+ return 0;
}
+
+ void importAnimationBindings(Mf::Script& script)
+ {
+ script.importFunction("DefineSequence",
+ boost::bind(&Data::defineSequence, this, _1));
+
+ script.push(1); script.set("ATTACK");
+ script.push(2); script.set("CHARGE");
+ script.push(3); script.set("FLY");
+ script.push(4); script.set("HIT");
+ script.push(5); script.set("JUMP");
+ script.push(6); script.set("RUN");
+ script.push(7); script.set("STAND");
+ }
+
+
/**
* Construction is initialization. The animation class data container
* registers itself as a mippleton and then loads the animation data.
*/
explicit Data(const std::string& name) :
- Mippleton<Data>(name)
+ Mf::Mippleton<Data>(name)
{
loadFromFile();
}
/**
* Sets up the animation classes to "play" a named sequence. If another
- * sequence was active, it will be replaced as the current sequence. Future
- * updates will progress the new sequence.
+ * sequence was active, it will be replaced. Future updates will progress
+ * the new sequence.
*/
void startSequence(const std::string& name)
* starts over again.
*/
- void update(Scalar t, Scalar dt)
+ void update(Mf::Scalar t, Mf::Scalar dt)
{
if (currentSequence)
{
Data::Sequence* currentSequence; ///< Active sequence.
unsigned frameCounter; ///< Current frame.
unsigned frameIndex; ///< Index of current frame.
- Scalar timeAccum; ///< Time accumulation.
- Scalar frameDuration; ///< Scaled frame duration.
+ Mf::Scalar timeAccum; ///< Time accumulation.
+ Mf::Scalar frameDuration; ///< Scaled frame duration.
};
impl_->startSequence(name);
}
-void Animation::update(Scalar t, Scalar dt)
+void Animation::update(Mf::Scalar t, Mf::Scalar dt)
{
// pass through
impl_->update(t, dt);
std::string Animation::getPath(const std::string& name)
{
- return Resource::getPath("animations/" + name + ".json");
+ return Mf::Resource::getPath("animations/" + name + ".lua");
}
-} // namespace Mf
-
/** vim: set ts=4 sw=4 tw=80: *************************************************/
*******************************************************************************/
-#ifndef _MOOF_ANIMATION_HH_
-#define _MOOF_ANIMATION_HH_
+#ifndef _ANIMATION_HH_
+#define _ANIMATION_HH_
/**
* @file Animation.hh
#include <Moof/Resource.hh>
-namespace Mf {
-
-
class Animation;
typedef boost::shared_ptr<Animation> AnimationP;
* anything to whatever drawing context is used to render the frame.
*/
-class Animation : public Resource
+class Animation : public Mf::Resource
{
class Impl;
boost::shared_ptr<Impl> impl_;
public:
+ Animation(const std::string& name);
+
static AnimationP alloc(const std::string& name)
{
return AnimationP(new Animation(name));
}
- Animation(const std::string& name);
void startSequence(const std::string& name);
- void update(Scalar t, Scalar dt);
+ void update(Mf::Scalar t, Mf::Scalar dt);
unsigned getFrame() const;
static std::string getPath(const std::string& name);
};
-} // namespace Mf
-
-#endif // _MOOF_ANIMATION_HH_
+#endif // _ANIMATION_HH_
/** vim: set ts=4 sw=4 tw=80: *************************************************/
Character::Character(const std::string& name) :
- tilemap_(name),
- animation_(name)
+ tilemap(name),
+ animation(name)
{
current.init();
current.force = userForce;
current.integrate(t, dt);
- animation_.update(t, dt);
+ animation.update(t, dt);
}
Mf::Vector2 position = cml::lerp(previous.position, current.position, alpha);
//glColor3f(1.0f, 1.0f, 1.0f);
- tilemap_.bind();
+ tilemap.bind();
- Mf::Tilemap::Index frame = animation_.getFrame();
+ Tilemap::Index frame = animation.getFrame();
- Mf::Tilemap::Orientation orientation = Mf::Tilemap::NORMAL;
+ Tilemap::Orientation orientation = Tilemap::NORMAL;
- if (current.velocity[0] < 0.0) orientation = Mf::Tilemap::REVERSE;
+ if (current.velocity[0] < 0.0) orientation = Tilemap::REVERSE;
Mf::Scalar coords[8];
- tilemap_.getTileCoords(frame, coords, orientation);
+ tilemap.getTileCoords(frame, coords, orientation);
Mf::Scalar s = 16.0;
}
-Mf::Tilemap& Character::getTilemap()
-{
- return tilemap_;
-}
-
-Mf::Animation& Character::getAnimation()
-{
- return animation_;
-}
-
-
/** vim: set ts=4 sw=4 tw=80: *************************************************/
#include <boost/shared_ptr.hpp>
-#include <Moof/Animation.hh>
#include <Moof/Entity.hh>
#include <Moof/Event.hh>
#include <Moof/Math.hh>
#include <Moof/RK4.hh>
-#include <Moof/Tilemap.hh>
+
+#include "Animation.hh"
+#include "Tilemap.hh"
+
struct Character;
static const Mf::Scalar z = 96.0;
- Mf::Tilemap tilemap_;
- Mf::Animation animation_;
-
protected:
Mf::Vector2 userForce;
virtual void update(Mf::Scalar t, Mf::Scalar dt);
virtual void draw(Mf::Scalar alpha) const;
- Mf::Tilemap& getTilemap();
- Mf::Animation& getAnimation();
+
+ Tilemap tilemap;
+ Animation animation;
};
music.stream();
heroine = Heroine::alloc();
- heroine->getAnimation().startSequence("FlyDiagonallyUp");
+ heroine->animation.startSequence("FlyDiagonallyUp");
Mf::Scalar a[6] = {0.0, 1.5, -0.5, 3.0, -2.0, 1.0};
interp.init(a, 2.0, Mf::Interpolator::OSCILLATE);
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_SPACE)
{
- heroine->getAnimation().startSequence("Flattened");
+ heroine->animation.startSequence("Flattened");
Mf::logInfo("thump!");
punchSound.play();
return true;
#include <boost/shared_ptr.hpp>
-#include <Moof/Animation.hh>
-#include <Moof/Entity.hh>
#include <Moof/Event.hh>
-#include <Moof/Math.hh>
-#include <Moof/Octree.hh>
-#include <Moof/RK4.hh>
-#include <Moof/Tilemap.hh>
#include "Character.hh"
#include <iostream>
-ProgressBar::ProgressBar(const Mf::Tilemap& tilemap, Mf::Tilemap::Index index) :
+ProgressBar::ProgressBar(const Tilemap& tilemap, Tilemap::Index index) :
progress_(0.0),
tilemap_(tilemap)
{
Hud::Hud() :
- bar1_(Mf::Tilemap("StatusBars"), 0),
- bar2_(Mf::Tilemap("StatusBars"), 2),
+ bar1_(Tilemap("StatusBars"), 0),
+ bar2_(Tilemap("StatusBars"), 2),
font_("Font")
{
resize(800, 600);
#include <Moof/Layer.hh>
#include <Moof/Math.hh>
#include <Moof/Rectangle.hh>
-#include <Moof/Tilemap.hh>
+
+#include "Tilemap.hh"
class ProgressBar : public Mf::Drawable
{
public:
- ProgressBar(const Mf::Tilemap& tilemap, Mf::Tilemap::Index index);
+ ProgressBar(const Tilemap& tilemap, Tilemap::Index index);
void resize(const Mf::Rectangle& rect);
Mf::Vector2 vertices_[8];
Mf::Scalar width_;
- Mf::Tilemap tilemap_;
+ Tilemap tilemap_;
Mf::Scalar texCoords_[8];
Mf::Scalar midCoords_[2];
};
ProgressBar bar2_;
unsigned number_;
- Mf::Tilemap font_;
+ Tilemap font_;
Mf::Matrix4 projection_;
};
libmoof_a_SOURCES = \
Moof/Aabb.cc \
Moof/Aabb.hh \
- Moof/Animation.cc \
- Moof/Animation.hh \
Moof/Camera.cc \
Moof/Camera.hh \
Moof/ConvertUTF.c \
Moof/ConvertUTF.h \
Moof/Cullable.hh \
- Moof/Deserializer.cc \
- Moof/Deserializer.hh \
Moof/Dispatcher.cc \
Moof/Dispatcher.hh \
Moof/Drawable.hh \
Moof/Resource.hh \
Moof/RK4.hh \
Moof/Script.hh \
- Moof/Serializable.cc \
- Moof/Serializable.hh \
- Moof/Serializer.cc \
- Moof/Serializer.hh \
Moof/Settings.cc \
Moof/Settings.hh \
Moof/Sound.cc \
Moof/Texture.cc \
Moof/Texture.hh \
Moof/Thread.hh \
- Moof/Tilemap.cc \
- Moof/Tilemap.hh \
Moof/Timer.cc \
Moof/Timer.hh \
Moof/Transition.hh \
Moof/fastevents.h \
$(ENDLIST)
-libmoof_a_SOURCES += \
- Moof/yajl/src/yajl.c \
- Moof/yajl/src/yajl_alloc.c \
- Moof/yajl/src/yajl_alloc.h \
- Moof/yajl/src/yajl_buf.c \
- Moof/yajl/src/yajl_buf.h \
- Moof/yajl/src/yajl_bytestack.h \
- Moof/yajl/src/yajl_encode.c \
- Moof/yajl/src/yajl_encode.h \
- Moof/yajl/src/yajl_gen.c \
- Moof/yajl/src/yajl_lex.c \
- Moof/yajl/src/yajl_lex.h \
- Moof/yajl/src/yajl_parser.c \
- Moof/yajl/src/yajl_parser.h \
- $(ENDLIST)
+libmoof_a_CPPFLAGS = -I$(top_srcdir)/src/Moof
-libmoof_a_CPPFLAGS = -I$(top_srcdir)/src/Moof -I$(top_srcdir)/src/Moof/yajl/src
-
-EXTRA_DIST = Moof/cml Moof/stlplus Moof/yajl
+EXTRA_DIST = Moof/cml Moof/stlplus
#
bin_PROGRAMS = yoink
yoink_SOURCES = \
+ Animation.cc \
+ Animation.hh \
Character.cc \
Character.hh \
GameLayer.cc \
MainLayer.hh \
Scene.cc \
Scene.hh \
+ Tilemap.cc \
+ Tilemap.hh \
TilemapFont.cc \
TilemapFont.hh \
TitleLayer.cc \
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 <fstream>
-#include <queue>
-
-#include <yajl/yajl_parse.h>
-
-#include "Deserializer.hh"
-#include "Log.hh"
-#include "Serializable.hh"
-
-
-namespace Mf {
-
-
-class Deserializer::Impl
-{
-public:
- Impl(const std::string& filePath, bool comments = false,
- bool check = false)
- {
- std::ifstream* input = new std::ifstream(filePath.c_str());
- init(*input, true, comments, check);
- }
-
- Impl(std::istream& input, bool comments = false,
- bool check = false)
- {
- init(input, false, comments, check);
- }
-
- ~Impl()
- {
- while (!parsed.empty())
- {
- delete parsed.front();
- parsed.pop();
- }
-
- if (deleteWhenDone)
- {
- delete in;
- }
- yajl_free(hand);
- }
-
- void raise()
- {
- unsigned char* errorStr = yajl_get_error(hand, 0, 0, 0);
- logError("parser error: %s", errorStr);
- yajl_free_error(hand, errorStr);
-
- throw Exception(Exception::PARSING_FAILED);
- }
-
-
- static int parsedNull(void* ctx)
- {
- ((Impl*)ctx)->parsed.push(new SerializableNull);
- return 1;
- }
-
- static int parsedBoolean(void* ctx, int value)
- {
- ((Impl*)ctx)->parsed.push(new SerializableBasic<Serializable::Boolean>(value));
- return 1;
- }
-
- static int parsedInteger(void* ctx, long value)
- {
- ((Impl*)ctx)->parsed.push(new SerializableBasic<Serializable::Integer>(value));
- return 1;
- }
-
- static int parsedFloat(void* ctx, double value)
- {
- ((Impl*)ctx)->parsed.push(new SerializableBasic<Serializable::Float>(value));
- return 1;
- }
-
- static int parsedString(void* ctx, const unsigned char* value,
- unsigned length)
- {
- ((Impl*)ctx)->parsed.push(new SerializableBasic<Serializable::String>(std::string((char*)value, length)));
- return 1;
- }
-
- static int parsedBeginMap(void* ctx)
- {
- ((Impl*)ctx)->parsed.push(new SerializableBasic<Serializable::Map>);
- return 1;
- }
-
- static int parsedMapKey(void* ctx, const unsigned char* value,
- unsigned length)
- {
- // same thing as a string
- return parsedString(ctx, value, length);
- }
-
- static int parsedEndMap(void* ctx)
- {
- // null means the end of a structure
- ((Impl*)ctx)->parsed.push(0);
- return 1;
- }
-
- static int parsedBeginArray(void* ctx)
- {
- ((Impl*)ctx)->parsed.push(new SerializableBasic<Serializable::Array>);
- return 1;
- }
-
- static int parsedEndArray(void* ctx)
- {
- // null means the end of a structure
- ((Impl*)ctx)->parsed.push(0);
- return 1;
- }
-
-
- void parse()
- {
- unsigned char buffer[4096];
-
- yajl_status stat;
-
- while (parsed.empty() && in->good())
- {
- in->read((char*)buffer, sizeof(buffer));
- unsigned readIn = in->gcount();
-
- if (readIn > 0)
- {
- stat = yajl_parse(hand, buffer, readIn);
- }
- else
- {
- stat = yajl_parse_complete(hand);
- }
-
- if (stat != yajl_status_ok &&
- stat != yajl_status_insufficient_data)
- {
- raise();
- }
- }
- }
-
-
- yajl_handle hand;
-
- std::istream* in;
- bool deleteWhenDone;
-
- std::queue<Serializable*> parsed;
-
-private:
- void init(std::istream& input, bool deleteIn, bool comments, bool check)
- {
- // this has to be static because yajl actually does not copy it into its
- // internal data structures but rather keeps a pointer to this
- static const yajl_callbacks callbacks =
- {
- Impl::parsedNull,
- Impl::parsedBoolean,
- Impl::parsedInteger,
- Impl::parsedFloat,
- 0,
- Impl::parsedString,
- Impl::parsedBeginMap,
- Impl::parsedMapKey,
- Impl::parsedEndMap,
- Impl::parsedBeginArray,
- Impl::parsedEndArray
- };
-
- in = &input;
- deleteWhenDone = deleteIn;
-
- yajl_parser_config config = {comments, check};
- hand = yajl_alloc(&callbacks, &config, NULL, this);
- }
-};
-
-
-Deserializer::Deserializer(const std::string& filePath, bool comments,
- bool check) :
- // pass through
- impl_(new Deserializer::Impl(filePath, comments, check)) {}
-
-Deserializer::Deserializer(std::istream& input, bool comments, bool check) :
- // pass through
- impl_(new Deserializer::Impl(input, comments, check)) {}
-
-
-SerializableP Deserializer::deserialize()
-{
- Serializable* ptr = pullNext();
- if (ptr)
- {
- ptr->deserialize(*this);
- }
- return SerializableP(ptr);
-}
-
-
-Serializable* Deserializer::pullNext()
-{
- impl_->parse();
- if (!impl_->parsed.empty())
- {
- Serializable* ptr = impl_->parsed.front();
- return ptr;
- }
- return 0;
-}
-
-void Deserializer::pop()
-{
- // pass through
- impl_->parsed.pop();
-}
-
-
-} // namespace Mf
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 _MOOF_DESERIALIZER_HH_
-#define _MOOF_DESERIALIZER_HH_
-
-/**
- * @file Deserializer.hh
- * Deserialize structures and types from input on a stream.
- */
-
-#include <istream>
-#include <string>
-#include <stdexcept>
-
-#include <boost/shared_ptr.hpp>
-
-#include <Moof/Exception.hh>
-
-
-namespace Mf {
-
-
-class Serializable; // forward declaration
-typedef boost::shared_ptr<Serializable> SerializableP;
-
-
-class Deserializer
-{
- class Impl;
- boost::shared_ptr<Impl> impl_;
-
-public:
-
- /**
- * Construction is initialization. A deserializer can be constructed with
- * either an input stream or a string representing a filename that will be
- * read from. If a stream is provided, it will not be closed after parsing,
- * but the parser may read past the end of usable bytes, so you should not
- * use a deserializer on a stream that you expect to continue to use after
- * the deserialization.
- * @param comments If true, C and C++-style comments will be allowed and
- * ignored by the parser.
- * @param check If true, UTF-8 strings will be checked for validity and an
- * exception thrown if such a problem exists. Otherwise strings will not be
- * checked.
- */
-
- Deserializer(const std::string& filePath, bool comments = false,
- bool check = false);
- Deserializer(std::istream& input, bool comments = false, bool check = false);
-
-
- /**
- * Parse the object from of the stream. The stream is considered to be
- * dominated by the parser and may read and discard bytes past the end of
- * the actual parsed object. Only one object can be deserialized by the
- * deserializer.
- */
-
- SerializableP deserialize();
-
- /**
- * Used by serializable objects to parse themselves. These methods should
- * generally not be used directory for deserialization. This one returns
- * the next object in the queue which has been parsed. This method may
- * block if more data is pending and an object has not bee constructed yet.
- * The caller takes ownership of the object which has been allocated with
- * the new operator and must therefore be sure to delete the object as
- * appropriated. Null (0) will be returned by this method to signify one of
- * three things: 1) the end of an array, 2) the end of a map/dictionary, or
- * 3) there is nothing more to be obtained. Container objects will be empty
- * and will have to be filled with their contained elements by repeatedly
- * calling this method until a null is returned. This method will continue
- * to return the same value until pop() is called which will cause this
- * method to return the next object as expected.
- */
-
- Serializable* pullNext();
-
- /**
- * If the object returned by pullNext() has been received successfully and
- * the caller is ready for the next object, this method should be called to
- * take that object off of the queue.
- */
-
- void pop();
-
-
- /**
- * This exception is thrown upon deserialization errors.
- */
-
- struct Exception : public Mf::Exception
- {
- enum
- {
- PARSING_FAILED = 1024
- };
-
- explicit Exception(unsigned error) :
- Mf::Exception(error) {}
-
- void raise()
- {
- throw *this;
- }
-
- const char* what() const throw()
- {
- switch (code)
- {
- case PARSING_FAILED:
- return "parsing failed";
- }
- return Mf::Exception::what();
- }
- };
-};
-
-
-} // namespace Mf
-
-
-#endif // _MOOF_DESERIALIZER_HH_
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
index(i),
state(s) {}
+ /**
+ * A copied value presently points to the same value, except the real
+ * index is used. That means that if a value that refers to a frame
+ * referenced from the top of the stack will have its normalized index
+ * copied into the new value object.
+ */
+
+ Value(const Value& copy) :
+ index(copy.getRealIndex()),
+ state(copy.state) {}
+
+
// check the type of the value
bool isBoolean() const { return (bool)lua_isboolean(state, index); }
bool isFunction() const { return (bool)lua_isfunction(state, index); }
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 "Serializable.hh"
-
-
-namespace Mf {
-
-
-Serializable::~Serializable()
-{
-}
-
-
-bool Serializable::get(Integer& value)
-{
- return false;
-}
-
-bool Serializable::get(Float& value)
-{
- return false;
-}
-
-bool Serializable::get(Boolean& value)
-{
- return false;
-}
-
-bool Serializable::get(String& value)
-{
- return false;
-}
-
-bool Serializable::get(WideString& value)
-{
- return false;
-}
-
-bool Serializable::get(Array& value)
-{
- return false;
-}
-
-bool Serializable::get(Map& value)
-{
- return false;
-}
-
-
-bool Serializable::isNull()
-{
- return false;
-}
-
-
-bool Serializable::getNumber(Integer& value)
-{
- if (get(value))
- {
- return true;
- }
- else
- {
- Float doubleValue;
- if (get(doubleValue))
- {
- value = Integer(doubleValue);
- return true;
- }
- }
- return false;
-}
-
-bool Serializable::getNumber(Float& value)
-{
- if (get(value))
- {
- return true;
- }
- else
- {
- Integer longValue;
- if (get(longValue))
- {
- value = Float(longValue);
- return true;
- }
- }
- return false;
-}
-
-
-} // namespace Mf
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 _MOOF_SERIALIZABLE_HH_
-#define _MOOF_SERIALIZABLE_HH_
-
-#include <iostream>
-#include <map>
-#include <string>
-#include <vector>
-
-#include <Moof/Deserializer.hh>
-#include <Moof/Serializer.hh>
-#include <Moof/StringTools.hh>
-
-
-namespace Mf {
-
-
-/**
- * Interface for a type which can be serialized and deserialized.
- */
-
-struct Serializable
-{
- // basic types which are serializable
- typedef long Integer;
- typedef double Float;
- typedef bool Boolean;
- typedef std::string String;
- typedef std::wstring WideString;
- typedef std::vector<SerializableP> Array;
- typedef std::map<String,SerializableP> Map;
-
-
- virtual ~Serializable();
-
- virtual void serialize(Serializer& out) const = 0;
- virtual void deserialize(Deserializer& in) = 0;
-
- virtual void print() const = 0;
-
- virtual bool get(Integer& value);
- virtual bool get(Float& value);
- virtual bool get(Boolean& value);
- virtual bool get(String& value);
- virtual bool get(WideString& value);
- virtual bool get(Array& value);
- virtual bool get(Map& value);
-
- /*
- * To get a number value which may have been parsed as either an integer or
- * double, use these getters instead.
- */
-
- bool getNumber(Integer& value);
- bool getNumber(Float& value);
-
- virtual bool isNull();
-};
-
-
-template <class T>
-class SerializableBasic : public Serializable
-{
- T value_;
-
-public:
-
- SerializableBasic() {}
- SerializableBasic(const T& value) :
- value_(value) {}
-
- void serialize(Serializer& out) const;
- void deserialize(Deserializer& in);
-
- void print() const;
- bool get(T& value);
-};
-
-
-struct SerializableNull : public Serializable
-{
- SerializableNull() {}
-
- void serialize(Serializer& out) const;
- void deserialize(Deserializer& in);
-
- void print() const;
- bool isNull();
-};
-
-
-template <class T>
-inline void SerializableBasic<T>::serialize(Serializer& out) const
-{
- out.push(value_);
-}
-
-template <>
-inline void
-SerializableBasic<Serializable::Array>::serialize(Serializer& out) const
-{
- out.pushArrayHead();
-
- std::vector<SerializableP>::const_iterator it;
- for (it = value_.begin(); it < value_.end(); ++it)
- {
- (*it)->serialize(out);
- }
-
- out.pushArrayTail();
-}
-
-template <>
-inline void
-SerializableBasic<Serializable::Map>::serialize(Serializer& out) const
-{
- out.pushMapHead();
-
- for (Map::const_iterator it = value_.begin(); it != value_.end(); ++it)
- {
- out.push((*it).first);
- (*it).second->serialize(out);
- }
-
- out.pushMapTail();
-}
-
-inline void SerializableNull::serialize(Serializer& out) const
-{
- out.pushNull();
-}
-
-
-template <class T>
-inline void SerializableBasic<T>::deserialize(Deserializer& in)
-{
- in.pop();
-}
-
-template <>
-inline void
-SerializableBasic<Serializable::Array>::deserialize(Deserializer& in)
-{
- SerializableP obj;
-
- in.pop();
-
- while (obj = in.deserialize())
- {
- value_.push_back(obj);
- }
-
- in.pop();
-}
-
-template <>
-inline void
-SerializableBasic<Serializable::Map>::deserialize(Deserializer& in)
-{
- SerializableP obj;
-
- in.pop();
-
- while (obj = in.deserialize())
- {
- std::string key;
- if (obj->get(key))
- {
- value_[key] = in.deserialize();
- }
- }
-
- in.pop();
-}
-
-inline void SerializableNull::deserialize(Deserializer& in)
-{
- in.pop();
-}
-
-
-template <class T>
-inline void SerializableBasic<T>::print() const
-{
- std::cout << std::boolalpha << typeid(T).name() << "(" << value_ << ")";
-}
-
-template <>
-inline void SerializableBasic<Serializable::WideString>::print() const
-{
- std::wcout << value_;
-}
-
-template <>
-inline void SerializableBasic<Serializable::Array>::print() const
-{
- std::cout << "array";
-}
-
-template <>
-inline void SerializableBasic<Serializable::Map>::print() const
-{
- std::cout << "map";
-}
-
-inline void SerializableNull::print() const
-{
- std::cout << "null";
-}
-
-
-template <class T>
-inline bool SerializableBasic<T>::get(T& value)
-{
- value = value_;
- return true;
-}
-
-inline bool SerializableNull::isNull()
-{
- return true;
-}
-
-
-} // namespace Mf
-
-#endif // _MOOF_SERIALIZABLE_HH_
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 <fstream>
-
-#include <yajl/yajl_gen.h>
-
-#include "Serializer.hh"
-#include "StringTools.hh"
-
-
-namespace Mf {
-
-
-struct Serializer::Impl
-{
- Impl(const std::string& filePath, const std::string& indent = "")
- {
- std::ofstream* output = new std::ofstream(filePath.c_str());
- init(*output, true, indent);
- }
-
- Impl(std::ostream& output, const std::string& indent = "")
- {
- init(output, false, indent);
- }
-
- ~Impl()
- {
- if (deleteWhenDone)
- {
- delete out;
- }
- yajl_gen_free(gen);
- }
-
- static void raise(yajl_gen_status err)
- {
- switch (err)
- {
- case yajl_gen_generation_complete:
- throw Serializer::Exception(Exception::ARCHIVE_TERMINATED);
- case yajl_gen_keys_must_be_strings:
- throw Serializer::Exception(Exception::KEYS_MUST_BE_STRINGS);
- case yajl_max_depth_exceeded:
- throw Serializer::Exception(Exception::RECURSION_TOO_DEEP);
- case yajl_gen_in_error_state:
- throw Serializer::Exception(Exception::ALREADY_FAILED);
- case yajl_gen_status_ok:
- ; // There is no error here. Move along...
- }
- }
-
- yajl_gen gen;
-
- std::ostream* out;
- bool deleteWhenDone;
-
-private:
-
- void init(std::ostream& output, bool deleteOut, const std::string& indent)
- {
- yajl_gen_config config;
-
- out = &output;
- deleteWhenDone = deleteOut;
-
- if (indent != "")
- {
- config.beautify = true;
- config.indentString = 0;
- // FIXME a yajl bug prevents using heap-allocated strings
- //config.indentString = indent.c_str();
- }
- else
- {
- config.beautify = false;
- }
- gen = yajl_gen_alloc(&config, 0);
- }
-};
-
-
-Serializer::Serializer(const std::string& filePath, const std::string& indent) :
- // pass through
- impl_(new Serializer::Impl(filePath, indent)) {}
-
-Serializer::Serializer(std::ostream& output, const std::string& indent) :
- // pass through
- impl_(new Serializer::Impl(output, indent)) {}
-
-Serializer::~Serializer()
-{
- flush();
-}
-
-
-void Serializer::push(long value)
-{
- yajl_gen_status stat = yajl_gen_integer(impl_->gen, value);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::push(double value)
-{
- yajl_gen_status stat = yajl_gen_double(impl_->gen, value);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::push(bool value)
-{
- yajl_gen_status stat = yajl_gen_bool(impl_->gen, value);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::push(const std::string& value)
-{
- yajl_gen_status stat = yajl_gen_string(impl_->gen,
- (const unsigned char*)value.c_str(), value.length());
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::push(const std::wstring& value)
-{
- push(wideToMulti(value));
-}
-
-void Serializer::pushNull()
-{
- yajl_gen_status stat = yajl_gen_null(impl_->gen);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-
-void Serializer::pushMapHead()
-{
- yajl_gen_status stat = yajl_gen_map_open(impl_->gen);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::pushMapTail()
-{
- yajl_gen_status stat = yajl_gen_map_close(impl_->gen);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::pushArrayHead()
-{
- yajl_gen_status stat = yajl_gen_array_open(impl_->gen);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-void Serializer::pushArrayTail()
-{
- yajl_gen_status stat = yajl_gen_array_close(impl_->gen);
- if (stat != yajl_gen_status_ok) Serializer::Impl::raise(stat);
-}
-
-
-void Serializer::flush()
-{
- const unsigned char* buffer;
- unsigned length;
-
- yajl_gen_get_buf(impl_->gen, &buffer, &length);
- impl_->out->write((const char*)buffer, length);
- yajl_gen_clear(impl_->gen);
-}
-
-
-} // namespace Mf
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 _MOOF_SERIALIZER_HH_
-#define _MOOF_SERIALIZER_HH_
-
-/**
- * @file Serializer.hh
- * Serialize structures and types for output on a stream.
- */
-
-#include <stdexcept>
-#include <string>
-#include <ostream>
-
-#include <boost/shared_ptr.hpp>
-
-#include <Moof/Exception.hh>
-
-
-namespace Mf {
-
-
-class Serializer
-{
- class Impl;
- boost::shared_ptr<Impl> impl_;
-
-public:
-
- /**
- * Construction is initialization. Use either an output stream or a string
- * representing a path to a fill to which the serialized data will be
- * written (replacing any previous file).
- * @param indent If non-empty, the string's characters will be used as
- * indentation. Otherwise, the serialized data will not be formatted neatly
- * but will be tightly packed.
- */
-
- Serializer(const std::string& filePath, const std::string& indent = "");
- Serializer(std::ostream& output, const std::string& indent = "");
-
- ~Serializer();
-
- /**
- * Push various types of data onto the stream.
- */
-
- void push(long value);
- void push(double value);
- void push(bool value);
- void push(const std::string& value);
- void push(const std::wstring& value);
- void pushNull();
-
- /**
- * Push a map onto the stream. Each map head must be matched by a map tail.
- */
-
- void pushMapHead();
- void pushMapTail();
-
- /**
- * Push an array onto the stream. Each array head must be matched by an
- * array tail.
- */
-
- void pushArrayHead();
- void pushArrayTail();
-
- /**
- * Write any pending bytes to the stream. This is called automatically by
- * the destructor of this class.
- */
-
- void flush();
-
-
- /**
- * This exception is thrown for serializer-related exceptional errors.
- */
-
- struct Exception : public Mf::Exception
- {
- enum
- {
- ARCHIVE_TERMINATED = 1024,
- KEYS_MUST_BE_STRINGS = 1025,
- RECURSION_TOO_DEEP = 1026,
- ALREADY_FAILED = 1027,
- };
-
- explicit Exception(unsigned error) :
- Mf::Exception(error) {}
-
- void raise()
- {
- throw *this;
- }
-
- const char* what() const throw()
- {
- switch (code)
- {
- case ARCHIVE_TERMINATED:
- return "archive is already terminated";
- case KEYS_MUST_BE_STRINGS:
- return "map keys must be strings";
- case RECURSION_TOO_DEEP:
- return "generator recursion too deep";
- case ALREADY_FAILED:
- return "generator already errored out";
- }
- return Mf::Exception::what();
- }
- };
-};
-
-} // namespace Mf
-
-
-#endif // _MOOF_SERIALIZER_HH_
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * 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.
-
- 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 HOLDER 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 "Deserializer.hh"
-#include "Mippleton.hh"
-#include "OpenGL.hh"
-#include "Serializable.hh"
-#include "Tilemap.hh"
-
-
-namespace Mf {
-
-
-class Tilemap::Impl : public Mippleton<Impl>
-{
- static GLint filterFromString(const std::string& filter)
- {
- if (filter == "linear")
- {
- return GL_LINEAR;
- }
- else if (filter == "nearest_mipmap_nearest")
- {
- return GL_NEAREST_MIPMAP_NEAREST;
- }
- else if (filter == "nearest_mipmap_linear")
- {
- return GL_NEAREST_MIPMAP_LINEAR;
- }
- else if (filter == "linear_mipmap_nearest")
- {
- return GL_LINEAR_MIPMAP_NEAREST;
- }
- else if (filter == "linear_mipmap_linear")
- {
- return GL_LINEAR_MIPMAP_LINEAR;
- }
-
- return GL_NEAREST;
- }
-
- static GLint wrapFromString(const std::string& wrap)
- {
- if (wrap == "repeat")
- {
- return GL_REPEAT;
- }
-
- return GL_CLAMP;
- }
-
-public:
- Impl(const std::string& name) :
- Mippleton<Impl>(name),
- magFilter_(GL_NEAREST),
- minFilter_(GL_NEAREST),
- nTilesS_(1),
- nTilesT_(1),
- wrapS_(GL_CLAMP),
- wrapT_(GL_CLAMP)
- {
- loadFromFile();
- }
-
- void loadFromFile()
- {
- Deserializer deserializer(Tilemap::getPath(getName()));
-
- SerializableP root = deserializer.deserialize();
-
- if (root)
- {
- Serializable::Map rootObj;
-
- if (root->get(rootObj))
- {
- Serializable::Map::iterator it;
-
- if ((it = rootObj.find("tiles_s")) != rootObj.end())
- {
- long value;
- if ((*it).second->get(value))
- {
- nTilesS_ = unsigned(value);
- }
- }
- if ((it = rootObj.find("tiles_t")) != rootObj.end())
- {
- long value;
- if ((*it).second->get(value))
- {
- nTilesT_ = unsigned(value);
- }
- }
- if ((it = rootObj.find("min_filter")) != rootObj.end())
- {
- std::string value;
- if ((*it).second->get(value))
- {
- minFilter_ = filterFromString(value);
- }
- }
- if ((it = rootObj.find("mag_filter")) != rootObj.end())
- {
- std::string value;
- if ((*it).second->get(value))
- {
- magFilter_ = filterFromString(value);
- }
- }
- if ((it = rootObj.find("wrap_s")) != rootObj.end())
- {
- std::string value;
- if ((*it).second->get(value))
- {
- wrapS_ = wrapFromString(value);
- }
- }
- if ((it = rootObj.find("wrap_t")) != rootObj.end())
- {
- std::string value;
- if ((*it).second->get(value))
- {
- wrapT_ = wrapFromString(value);
- }
- }
- }
- }
- }
-
- GLuint magFilter_;
- GLuint minFilter_;
- unsigned nTilesS_;
- unsigned nTilesT_;
- GLuint wrapS_;
- GLuint wrapT_;
-};
-
-
-Tilemap::Tilemap(const std::string& name) :
- Texture(name),
- impl_(Tilemap::Impl::getInstance(name))
-{
- setMinFilter(impl_->minFilter_);
- setMagFilter(impl_->magFilter_);
- setWrapS(impl_->wrapS_);
- setWrapT(impl_->wrapT_);
-}
-
-
-bool Tilemap::getTileCoords(unsigned index, Scalar coords[8]) const
-{
- // make sure the index represents a real tile
- if (index >= impl_->nTilesS_ * impl_->nTilesT_) return false;
-
- Scalar w = 1.0 / Scalar(impl_->nTilesS_);
- Scalar h = 1.0 / Scalar(impl_->nTilesT_);
-
- coords[0] = Scalar(index % impl_->nTilesS_) * w;
- coords[1] = (Scalar(impl_->nTilesT_ - 1) -
- Scalar(index / impl_->nTilesS_)) * h;
- coords[2] = coords[0] + w;
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = coords[1] + h;
- coords[6] = coords[0];
- coords[7] = coords[5];
-
- return true;
-}
-
-bool Tilemap::getTileCoords(unsigned index, Scalar coords[8],
- Orientation orientation) const
-{
- if (getTileCoords(index, coords))
- {
- if (orientation & FLIP)
- {
- // this looks kinda weird, but it's just swapping in a way that
- // doesn't require an intermediate variable
- coords[1] = coords[5];
- coords[5] = coords[3];
- coords[3] = coords[7];
- coords[7] = coords[5];
- }
- if (orientation & REVERSE)
- {
- coords[0] = coords[2];
- coords[2] = coords[6];
- coords[4] = coords[6];
- coords[6] = coords[0];
- }
-
- return true;
- }
-
- return false;
-}
-
-
-std::string Tilemap::getPath(const std::string& name)
-{
- return Resource::getPath("tilemaps/" + name + ".json");
-}
-
-
-} // namespace Mf
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-Short story (If you already have ruby and cmake):
-
-./configure && make install
-
-When things go wrong:
-
-attain CMake (http://www.cmake.org) and ruby (http://ruby-lang.org) and
-try again.
-
-OR, attain CMake and build by hand:
-
-1. mkdir build
-2. cd build
-3. cmake ..
-4. make
-5. build output left in yajl-X.Y.Z
-
-best,
-lloyd
+++ /dev/null
-YAJL has been successfully built using Visual Studio 8. CMake is used to
-build the software and by specifying a generator explicitly at cmake:
-
-1. acquire cmake (http://www.cmake.org)
-2. mkdir build
-3. cd build
-4. cmake ..
-5. devenv YetAnotherJSONParser.sln
-6. build the ALL_BUILD target
-7. build output is left in build/yajl-X.Y.Z
-
-Earlier versions of visual studio have not been tested, but should
-work without any major issues.
+++ /dev/null
-# Copyright 2007-2009, Lloyd Hilaiel.
-#
-# 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
-
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-PROJECT(YetAnotherJSONParser)
-
-SET (YAJL_MAJOR 1)
-SET (YAJL_MINOR 0)
-SET (YAJL_MICRO 5)
-
-SET (YAJL_DIST_NAME "yajl-${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}")
-
-IF (NOT CMAKE_BUILD_TYPE)
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF (NOT CMAKE_BUILD_TYPE)
-
-SET(CMAKE_C_FLAGS "-Wall")
-IF (WIN32)
- SET(linkFlags "/PDB:NONE /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF")
- SET(CMAKE_EXE_LINKER_FLAGS "${linkFlags}"
- CACHE STRING "YAJL linker flags" FORCE)
- SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ""
- CACHE STRING "YAJL debug linker flags" FORCE)
- SET(CMAKE_EXE_LINKER_FLAGS_RELEASE
- CACHE STRING "YAJL release linker flags" FORCE)
- SET(CMAKE_SHARED_LINKER_FLAGS "${linkFlags}"
- CACHE STRING "YAJL shared linker flags" FORCE)
- SET(CMAKE_MODULE_LINKER_FLAGS "${linkFlags}"
- CACHE STRING "YAJL module linker flags" FORCE)
-
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4255 /wd4130 /wd4100 /wd4711")
- SET(CMAKE_C_FLAGS_DEBUG "/D DEBUG /Od /Z7")
- SET(CMAKE_C_FLAGS_RELEASE "/D NDEBUG /O2")
-ELSE (WIN32)
- SET(CMAKE_C_FLAGS
- "${CMAKE_C_FLAGS} -fPIC -ansi -pedantic -Wpointer-arith -Wno-format-y2k -Wstrict-prototypes -Wmissing-declarations -Wnested-externs -Wextra -Wundef -Wwrite-strings -Wold-style-definition -Wno-missing-field-initializers -Wredundant-decls -Wno-unused-parameter -Wno-sign-compare -Wmissing-prototypes")
-
- SET(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g")
- SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -Wuninitialized")
-ENDIF (WIN32)
-
-
-ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(test)
-ADD_SUBDIRECTORY(reformatter)
-ADD_SUBDIRECTORY(verify)
-
-INCLUDE(YAJLDoc.cmake)
-
-# a test target
-ADD_CUSTOM_TARGET(test
- ./run_tests.sh
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
-
+++ /dev/null
-Copyright 2007-2009, Lloyd Hilaiel.
-
-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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
+++ /dev/null
-* add a test for 0x1F bug
-* numeric overflow in integers and double
-* line and char offsets in the lexer and in error messages
-* testing:
- a. the permuter
- b. some performance comparison against json_checker.
-* investigate pull instead of push parsing
-* Handle memory allocation failures gracefully
-* cygwin/msys support on win32
+++ /dev/null
-FIND_PROGRAM(doxygenPath doxygen)
-
-IF (doxygenPath)
- SET (YAJL_VERSION ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO})
- SET(yajlDirName yajl-${YAJL_VERSION})
- SET(docPath
- "${CMAKE_CURRENT_BINARY_DIR}/${yajlDirName}/share/doc/${yajlDirName}")
- MESSAGE("** using doxygen at: ${doxygenPath}")
- MESSAGE("** documentation output to: ${docPath}")
-
- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/YAJL.dxy
- ${CMAKE_CURRENT_BINARY_DIR}/YAJL.dxy @ONLY)
-
- FILE(MAKE_DIRECTORY "${docPath}")
-
- ADD_CUSTOM_TARGET(doc
- ${doxygenPath} YAJL.dxy
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-
-ELSE (doxygenPath)
- MESSAGE("!! doxygen not found, not generating documentation")
- ADD_CUSTOM_TARGET(
- doc
- echo doxygen not installed, not generating documentation
- )
-ENDIF (doxygenPath)
+++ /dev/null
-# Copyright 2007-2009, Lloyd Hilaiel.
-#
-# 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
-
-# set up a paths
-SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/bin)
-
-# create a directories
-FILE(MAKE_DIRECTORY ${binDir})
-
-SET (SRCS json_reformat.c)
-
-# use the library we build, duh.
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include)
-LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
-
-ADD_EXECUTABLE(json_reformat ${SRCS})
-
-TARGET_LINK_LIBRARIES(json_reformat yajl_s)
-
-# copy the binary into the output directory
-GET_TARGET_PROPERTY(binPath json_reformat LOCATION)
-
-ADD_CUSTOM_COMMAND(TARGET json_reformat POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${binPath} ${binDir})
-
-IF (NOT WIN32)
- INSTALL(TARGETS json_reformat RUNTIME DESTINATION bin)
-ENDIF ()
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 <yajl/yajl_parse.h>
-#include <yajl/yajl_gen.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static int reformat_null(void * ctx)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_null(g);
- return 1;
-}
-
-static int reformat_boolean(void * ctx, int boolean)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_bool(g, boolean);
- return 1;
-}
-
-static int reformat_number(void * ctx, const char * s, unsigned int l)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_number(g, s, l);
- return 1;
-}
-
-static int reformat_string(void * ctx, const unsigned char * stringVal,
- unsigned int stringLen)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_string(g, stringVal, stringLen);
- return 1;
-}
-
-static int reformat_map_key(void * ctx, const unsigned char * stringVal,
- unsigned int stringLen)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_string(g, stringVal, stringLen);
- return 1;
-}
-
-static int reformat_start_map(void * ctx)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_map_open(g);
- return 1;
-}
-
-
-static int reformat_end_map(void * ctx)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_map_close(g);
- return 1;
-}
-
-static int reformat_start_array(void * ctx)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_array_open(g);
- return 1;
-}
-
-static int reformat_end_array(void * ctx)
-{
- yajl_gen g = (yajl_gen) ctx;
- yajl_gen_array_close(g);
- return 1;
-}
-
-static yajl_callbacks callbacks = {
- reformat_null,
- reformat_boolean,
- NULL,
- NULL,
- reformat_number,
- reformat_string,
- reformat_start_map,
- reformat_map_key,
- reformat_end_map,
- reformat_start_array,
- reformat_end_array
-};
-
-static void
-usage(const char * progname)
-{
- fprintf(stderr, "usage: %s <filename>\n"
- " -m minimize json rather than beautify (default)\n"
- " -u allow invalid UTF8 inside strings during parsing\n",
- progname);
- exit(1);
-
-}
-
-int
-main(int argc, char ** argv)
-{
- yajl_handle hand;
- static unsigned char fileData[65536];
- /* generator config */
- yajl_gen_config conf = { 1, " " };
- yajl_gen g;
- yajl_status stat;
- size_t rd;
- /* allow comments */
- yajl_parser_config cfg = { 1, 1 };
- int done = 0;
-
- /* check arguments. We expect exactly one! */
- if (argc == 2) {
- if (!strcmp("-m", argv[1])) {
- conf.beautify = 0;
-
- } else if (!strcmp("-u", argv[1])) {
- cfg.checkUTF8 = 0;
- } else {
- usage(argv[0]);
- }
- } else if (argc != 1) {
- usage(argv[0]);
- }
-
- g = yajl_gen_alloc(&conf, NULL);
-
- /* ok. open file. let's read and parse */
- hand = yajl_alloc(&callbacks, &cfg, NULL, (void *) g);
-
- while (!done) {
- rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin);
-
- if (rd == 0) {
- if (!feof(stdin)) {
- fprintf(stderr, "error on file read.\n");
- break;
- }
- done = 1;
- }
- fileData[rd] = 0;
-
- if (done)
- /* parse any remaining buffered data */
- stat = yajl_parse_complete(hand);
- else
- /* read file data, pass to parser */
- stat = yajl_parse(hand, fileData, rd);
-
- if (stat != yajl_status_ok &&
- stat != yajl_status_insufficient_data)
- {
- unsigned char * str = yajl_get_error(hand, 1, fileData, rd);
- fprintf(stderr, (const char *) str);
- yajl_free_error(hand, str);
- } else {
- const unsigned char * buf;
- unsigned int len;
- yajl_gen_get_buf(g, &buf, &len);
- fwrite(buf, 1, len, stdout);
- yajl_gen_clear(g);
- }
- }
-
- yajl_gen_free(g);
- yajl_free(hand);
-
- return 0;
-}
+++ /dev/null
-
-
-
-
-
-
-Network Working Group D. Crockford
-Request for Comments: 4627 JSON.org
-Category: Informational July 2006
-
-
- The application/json Media Type for JavaScript Object Notation (JSON)
-
-Status of This Memo
-
- This memo provides information for the Internet community. It does
- not specify an Internet standard of any kind. Distribution of this
- memo is unlimited.
-
-Copyright Notice
-
- Copyright (C) The Internet Society (2006).
-
-Abstract
-
- JavaScript Object Notation (JSON) is a lightweight, text-based,
- language-independent data interchange format. It was derived from
- the ECMAScript Programming Language Standard. JSON defines a small
- set of formatting rules for the portable representation of structured
- data.
-
-1. Introduction
-
- JavaScript Object Notation (JSON) is a text format for the
- serialization of structured data. It is derived from the object
- literals of JavaScript, as defined in the ECMAScript Programming
- Language Standard, Third Edition [ECMA].
-
- JSON can represent four primitive types (strings, numbers, booleans,
- and null) and two structured types (objects and arrays).
-
- A string is a sequence of zero or more Unicode characters [UNICODE].
-
- An object is an unordered collection of zero or more name/value
- pairs, where a name is a string and a value is a string, number,
- boolean, null, object, or array.
-
- An array is an ordered sequence of zero or more values.
-
- The terms "object" and "array" come from the conventions of
- JavaScript.
-
- JSON's design goals were for it to be minimal, portable, textual, and
- a subset of JavaScript.
-
-
-
-Crockford Informational [Page 1]
-\f
-RFC 4627 JSON July 2006
-
-
-1.1. Conventions Used in This Document
-
- The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
- "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
- document are to be interpreted as described in [RFC2119].
-
- The grammatical rules in this document are to be interpreted as
- described in [RFC4234].
-
-2. JSON Grammar
-
- A JSON text is a sequence of tokens. The set of tokens includes six
- structural characters, strings, numbers, and three literal names.
-
- A JSON text is a serialized object or array.
-
- JSON-text = object / array
-
- These are the six structural characters:
-
- begin-array = ws %x5B ws ; [ left square bracket
-
- begin-object = ws %x7B ws ; { left curly bracket
-
- end-array = ws %x5D ws ; ] right square bracket
-
- end-object = ws %x7D ws ; } right curly bracket
-
- name-separator = ws %x3A ws ; : colon
-
- value-separator = ws %x2C ws ; , comma
-
- Insignificant whitespace is allowed before or after any of the six
- structural characters.
-
- ws = *(
- %x20 / ; Space
- %x09 / ; Horizontal tab
- %x0A / ; Line feed or New line
- %x0D ; Carriage return
- )
-
-2.1. Values
-
- A JSON value MUST be an object, array, number, or string, or one of
- the following three literal names:
-
- false null true
-
-
-
-Crockford Informational [Page 2]
-\f
-RFC 4627 JSON July 2006
-
-
- The literal names MUST be lowercase. No other literal names are
- allowed.
-
- value = false / null / true / object / array / number / string
-
- false = %x66.61.6c.73.65 ; false
-
- null = %x6e.75.6c.6c ; null
-
- true = %x74.72.75.65 ; true
-
-2.2. Objects
-
- An object structure is represented as a pair of curly brackets
- surrounding zero or more name/value pairs (or members). A name is a
- string. A single colon comes after each name, separating the name
- from the value. A single comma separates a value from a following
- name. The names within an object SHOULD be unique.
-
- object = begin-object [ member *( value-separator member ) ]
- end-object
-
- member = string name-separator value
-
-2.3. Arrays
-
- An array structure is represented as square brackets surrounding zero
- or more values (or elements). Elements are separated by commas.
-
- array = begin-array [ value *( value-separator value ) ] end-array
-
-2.4. Numbers
-
- The representation of numbers is similar to that used in most
- programming languages. A number contains an integer component that
- may be prefixed with an optional minus sign, which may be followed by
- a fraction part and/or an exponent part.
-
- Octal and hex forms are not allowed. Leading zeros are not allowed.
-
- A fraction part is a decimal point followed by one or more digits.
-
- An exponent part begins with the letter E in upper or lowercase,
- which may be followed by a plus or minus sign. The E and optional
- sign are followed by one or more digits.
-
- Numeric values that cannot be represented as sequences of digits
- (such as Infinity and NaN) are not permitted.
-
-
-
-Crockford Informational [Page 3]
-\f
-RFC 4627 JSON July 2006
-
-
- number = [ minus ] int [ frac ] [ exp ]
-
- decimal-point = %x2E ; .
-
- digit1-9 = %x31-39 ; 1-9
-
- e = %x65 / %x45 ; e E
-
- exp = e [ minus / plus ] 1*DIGIT
-
- frac = decimal-point 1*DIGIT
-
- int = zero / ( digit1-9 *DIGIT )
-
- minus = %x2D ; -
-
- plus = %x2B ; +
-
- zero = %x30 ; 0
-
-2.5. Strings
-
- The representation of strings is similar to conventions used in the C
- family of programming languages. A string begins and ends with
- quotation marks. All Unicode characters may be placed within the
- quotation marks except for the characters that must be escaped:
- quotation mark, reverse solidus, and the control characters (U+0000
- through U+001F).
-
- Any character may be escaped. If the character is in the Basic
- Multilingual Plane (U+0000 through U+FFFF), then it may be
- represented as a six-character sequence: a reverse solidus, followed
- by the lowercase letter u, followed by four hexadecimal digits that
- encode the character's code point. The hexadecimal letters A though
- F can be upper or lowercase. So, for example, a string containing
- only a single reverse solidus character may be represented as
- "\u005C".
-
- Alternatively, there are two-character sequence escape
- representations of some popular characters. So, for example, a
- string containing only a single reverse solidus character may be
- represented more compactly as "\\".
-
- To escape an extended character that is not in the Basic Multilingual
- Plane, the character is represented as a twelve-character sequence,
- encoding the UTF-16 surrogate pair. So, for example, a string
- containing only the G clef character (U+1D11E) may be represented as
- "\uD834\uDD1E".
-
-
-
-Crockford Informational [Page 4]
-\f
-RFC 4627 JSON July 2006
-
-
- string = quotation-mark *char quotation-mark
-
- char = unescaped /
- escape (
- %x22 / ; " quotation mark U+0022
- %x5C / ; \ reverse solidus U+005C
- %x2F / ; / solidus U+002F
- %x62 / ; b backspace U+0008
- %x66 / ; f form feed U+000C
- %x6E / ; n line feed U+000A
- %x72 / ; r carriage return U+000D
- %x74 / ; t tab U+0009
- %x75 4HEXDIG ) ; uXXXX U+XXXX
-
- escape = %x5C ; \
-
- quotation-mark = %x22 ; "
-
- unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
-
-3. Encoding
-
- JSON text SHALL be encoded in Unicode. The default encoding is
- UTF-8.
-
- Since the first two characters of a JSON text will always be ASCII
- characters [RFC0020], it is possible to determine whether an octet
- stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
- at the pattern of nulls in the first four octets.
-
- 00 00 00 xx UTF-32BE
- 00 xx 00 xx UTF-16BE
- xx 00 00 00 UTF-32LE
- xx 00 xx 00 UTF-16LE
- xx xx xx xx UTF-8
-
-4. Parsers
-
- A JSON parser transforms a JSON text into another representation. A
- JSON parser MUST accept all texts that conform to the JSON grammar.
- A JSON parser MAY accept non-JSON forms or extensions.
-
- An implementation may set limits on the size of texts that it
- accepts. An implementation may set limits on the maximum depth of
- nesting. An implementation may set limits on the range of numbers.
- An implementation may set limits on the length and character contents
- of strings.
-
-
-
-
-Crockford Informational [Page 5]
-\f
-RFC 4627 JSON July 2006
-
-
-5. Generators
-
- A JSON generator produces JSON text. The resulting text MUST
- strictly conform to the JSON grammar.
-
-6. IANA Considerations
-
- The MIME media type for JSON text is application/json.
-
- Type name: application
-
- Subtype name: json
-
- Required parameters: n/a
-
- Optional parameters: n/a
-
- Encoding considerations: 8bit if UTF-8; binary if UTF-16 or UTF-32
-
- JSON may be represented using UTF-8, UTF-16, or UTF-32. When JSON
- is written in UTF-8, JSON is 8bit compatible. When JSON is
- written in UTF-16 or UTF-32, the binary content-transfer-encoding
- must be used.
-
- Security considerations:
-
- Generally there are security issues with scripting languages. JSON
- is a subset of JavaScript, but it is a safe subset that excludes
- assignment and invocation.
-
- A JSON text can be safely passed into JavaScript's eval() function
- (which compiles and executes a string) if all the characters not
- enclosed in strings are in the set of characters that form JSON
- tokens. This can be quickly determined in JavaScript with two
- regular expressions and calls to the test and replace methods.
-
- var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
- text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
- eval('(' + text + ')');
-
- Interoperability considerations: n/a
-
- Published specification: RFC 4627
-
-
-
-
-
-
-
-
-Crockford Informational [Page 6]
-\f
-RFC 4627 JSON July 2006
-
-
- Applications that use this media type:
-
- JSON has been used to exchange data between applications written
- in all of these programming languages: ActionScript, C, C#,
- ColdFusion, Common Lisp, E, Erlang, Java, JavaScript, Lua,
- Objective CAML, Perl, PHP, Python, Rebol, Ruby, and Scheme.
-
- Additional information:
-
- Magic number(s): n/a
- File extension(s): .json
- Macintosh file type code(s): TEXT
-
- Person & email address to contact for further information:
- Douglas Crockford
- douglas@crockford.com
-
- Intended usage: COMMON
-
- Restrictions on usage: none
-
- Author:
- Douglas Crockford
- douglas@crockford.com
-
- Change controller:
- Douglas Crockford
- douglas@crockford.com
-
-7. Security Considerations
-
- See Security Considerations in Section 6.
-
-8. Examples
-
- This is a JSON object:
-
- {
- "Image": {
- "Width": 800,
- "Height": 600,
- "Title": "View from 15th Floor",
- "Thumbnail": {
- "Url": "http://www.example.com/image/481989943",
- "Height": 125,
- "Width": "100"
- },
- "IDs": [116, 943, 234, 38793]
-
-
-
-Crockford Informational [Page 7]
-\f
-RFC 4627 JSON July 2006
-
-
- }
- }
-
- Its Image member is an object whose Thumbnail member is an object
- and whose IDs member is an array of numbers.
-
- This is a JSON array containing two objects:
-
- [
- {
- "precision": "zip",
- "Latitude": 37.7668,
- "Longitude": -122.3959,
- "Address": "",
- "City": "SAN FRANCISCO",
- "State": "CA",
- "Zip": "94107",
- "Country": "US"
- },
- {
- "precision": "zip",
- "Latitude": 37.371991,
- "Longitude": -122.026020,
- "Address": "",
- "City": "SUNNYVALE",
- "State": "CA",
- "Zip": "94085",
- "Country": "US"
- }
- ]
-
-9. References
-
-9.1. Normative References
-
- [ECMA] European Computer Manufacturers Association, "ECMAScript
- Language Specification 3rd Edition", December 1999,
- <http://www.ecma-international.org/publications/files/
- ecma-st/ECMA-262.pdf>.
-
- [RFC0020] Cerf, V., "ASCII format for network interchange", RFC 20,
- October 1969.
-
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
- Requirement Levels", BCP 14, RFC 2119, March 1997.
-
- [RFC4234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
- Specifications: ABNF", RFC 4234, October 2005.
-
-
-
-Crockford Informational [Page 8]
-\f
-RFC 4627 JSON July 2006
-
-
- [UNICODE] The Unicode Consortium, "The Unicode Standard Version 4.0",
- 2003, <http://www.unicode.org/versions/Unicode4.1.0/>.
-
-Author's Address
-
- Douglas Crockford
- JSON.org
- EMail: douglas@crockford.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Crockford Informational [Page 9]
-\f
-RFC 4627 JSON July 2006
-
-
-Full Copyright Statement
-
- Copyright (C) The Internet Society (2006).
-
- This document is subject to the rights, licenses and restrictions
- contained in BCP 78, and except as set forth therein, the authors
- retain all their rights.
-
- This document and the information contained herein are provided on an
- "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
- OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
- ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
- INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
- INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
- WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
-Intellectual Property
-
- The IETF takes no position regarding the validity or scope of any
- Intellectual Property Rights or other rights that might be claimed to
- pertain to the implementation or use of the technology described in
- this document or the extent to which any license under such rights
- might or might not be available; nor does it represent that it has
- made any independent effort to identify any such rights. Information
- on the procedures with respect to rights in RFC documents can be
- found in BCP 78 and BCP 79.
-
- Copies of IPR disclosures made to the IETF Secretariat and any
- assurances of licenses to be made available, or the result of an
- attempt made to obtain a general license or permission for the use of
- such proprietary rights by implementers or users of this
- specification can be obtained from the IETF on-line IPR repository at
- http://www.ietf.org/ipr.
-
- The IETF invites any interested party to bring to its attention any
- copyrights, patents or patent applications, or other proprietary
- rights that may cover technology that may be required to implement
- this standard. Please address the information to the IETF at
- ietf-ipr@ietf.org.
-
-Acknowledgement
-
- Funding for the RFC Editor function is provided by the IETF
- Administrative Support Activity (IASA).
-
-
-
-
-
-
-
-Crockford Informational [Page 10]
-\f
+++ /dev/null
-# Copyright 2007-2009, Lloyd Hilaiel.
-#
-# 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
-
-SET (SRCS yajl.c yajl_lex.c yajl_parser.c yajl_buf.c
- yajl_encode.c yajl_gen.c yajl_alloc.c)
-SET (HDRS yajl_parser.h yajl_lex.h yajl_buf.h yajl_encode.h yajl_alloc.h)
-SET (PUB_HDRS api/yajl_parse.h api/yajl_gen.h api/yajl_common.h)
-
-# useful when fixing lexer bugs.
-#ADD_DEFINITIONS(-DYAJL_LEXER_DEBUG)
-
-# set up some paths
-SET (libDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
-SET (incDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include/yajl)
-
-# set the output path for libraries
-SET(LIBRARY_OUTPUT_PATH ${libDir})
-
-ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS})
-
-ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS})
-
-#### setup shared library version number
-SET_TARGET_PROPERTIES(yajl PROPERTIES
- SOVERSION ${YAJL_MAJOR}
- VERSION ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO})
-
-#### build up an sdk as a post build step
-
-# create some directories
-FILE(MAKE_DIRECTORY ${libDir})
-FILE(MAKE_DIRECTORY ${incDir})
-
-# copy public headers to output directory
-FOREACH (header ${PUB_HDRS})
- SET (header ${CMAKE_CURRENT_SOURCE_DIR}/${header})
-
- EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E copy_if_different ${header} ${incDir})
-
- ADD_CUSTOM_COMMAND(TARGET yajl_s POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header} ${incDir})
-ENDFOREACH (header ${PUB_HDRS})
-
-INCLUDE_DIRECTORIES(${incDir}/..)
-
-IF(NOT WIN32)
- INSTALL(TARGETS yajl LIBRARY DESTINATION lib)
- INSTALL(TARGETS yajl_s ARCHIVE DESTINATION lib)
- INSTALL(DIRECTORY api/ DESTINATION include/yajl
- FILES_MATCHING PATTERN "*.h")
-ENDIF()
+++ /dev/null
-# Doxyfile 1.5.2
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file that
-# follow. The default is UTF-8 which is also the encoding used for all text before
-# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into
-# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of
-# possible encodings.
-
-DOXYFILE_ENCODING = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME = YAJL
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER = @YAJL_VERSION@
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = yajl-@YAJL_VERSION@/share
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian,
-# Italian, Japanese, Japanese-en (Japanese with English messages), Korean,
-# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian,
-# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like the Qt-style comments (thus requiring an
-# explicit @brief command for a brief description.
-
-JAVADOC_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member
-# documentation.
-
-DETAILS_AT_TOP = YES
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 4
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = YES
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for Java.
-# For instance, namespaces will be presented as packages, qualified scopes
-# will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
-# include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-
-CPP_CLI_SUPPORT = NO
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = NO
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = YES
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = YES
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = NO
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES = NO
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from the
-# version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = ../src/yajl ../src/api
-
-# This tag can be used to specify the character encoding of the source files that
-# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default
-# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding.
-# See http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-INPUT_ENCODING = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
-
-FILE_PATTERNS = *.h
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the output.
-# The symbol name can be a fully qualified name, a word, or if the wildcard * is used,
-# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output. If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES (the default)
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES (the default)
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = YES
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code. Otherwise they will link to the documentstion.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = doc/yajl-@YAJL_VERSION@
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = NO
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = NO
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = YES
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = YES
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to
-# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to
-# specify the directory where the mscgen tool resides. If left empty the tool is assumed to
-# be found in the default search path.
-
-MSCGEN_PATH =
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a call dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a caller dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable caller graphs for selected
-# functions only using the \callergraph command.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen will always
-# show the root nodes and its direct children regardless of this setting.
-
-DOT_GRAPH_MAX_NODES = 50
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, which results in a white background.
-# Warning: Depending on the platform used, enabling this option may lead to
-# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
-# read).
-
-DOT_TRANSPARENT = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE = NO
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 __YAJL_COMMON_H__
-#define __YAJL_COMMON_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define YAJL_MAX_DEPTH 128
-
-/* msft dll export gunk. To build a DLL on windows, you
- * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared
- * DLL, you must define YAJL_SHARED and WIN32 */
-#if defined(WIN32) && defined(YAJL_SHARED)
-# ifdef YAJL_BUILD
-# define YAJL_API __declspec(dllexport)
-# else
-# define YAJL_API __declspec(dllimport)
-# endif
-#else
-# define YAJL_API
-#endif
-
-/** pointer to a malloc function, supporting client overriding memory
- * allocation routines */
-typedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz);
-
-/** pointer to a free function, supporting client overriding memory
- * allocation routines */
-typedef void (*yajl_free_func)(void *ctx, void * ptr);
-
-/** pointer to a realloc function which can resize an allocation. */
-typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz);
-
-/** A structure which can be passed to yajl_*_alloc routines to allow the
- * client to specify memory allocation functions to be used. */
-typedef struct
-{
- /** pointer to a function that can allocate uninitialized memory */
- yajl_malloc_func malloc;
- /** pointer to a function that can resize memory allocations */
- yajl_realloc_func realloc;
- /** pointer to a function that can free memory allocated using
- * reallocFunction or mallocFunction */
- yajl_free_func free;
- /** a context pointer that will be passed to above allocation routines */
- void * ctx;
-} yajl_alloc_funcs;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/**
- * \file yajl_gen.h
- * Interface to YAJL's JSON generation facilities.
- */
-
-#include <yajl/yajl_common.h>
-
-#ifndef __YAJL_GEN_H__
-#define __YAJL_GEN_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- /** generator status codes */
- typedef enum {
- /** no error */
- yajl_gen_status_ok = 0,
- /** at a point where a map key is generated, a function other than
- * yajl_gen_string was called */
- yajl_gen_keys_must_be_strings,
- /** YAJL's maximum generation depth was exceeded. see
- * YAJL_MAX_DEPTH */
- yajl_max_depth_exceeded,
- /** A generator function (yajl_gen_XXX) was called while in an error
- * state */
- yajl_gen_in_error_state,
- /** A complete JSON document has been generated */
- yajl_gen_generation_complete
- } yajl_gen_status;
-
- /** an opaque handle to a generator */
- typedef struct yajl_gen_t * yajl_gen;
-
- /** configuration structure for the generator */
- typedef struct {
- /** generate indented (beautiful) output */
- unsigned int beautify;
- /** an opportunity to define an indent string. such as \\t or
- * some number of spaces. default is four spaces ' '. This
- * member is only relevant when beautify is true */
- const char * indentString;
- } yajl_gen_config;
-
- /** allocate a generator handle
- * \param config a pointer to a structure containing parameters which
- * configure the behavior of the json generator
- * \param allocFuncs an optional pointer to a structure which allows
- * the client to overide the memory allocation
- * used by yajl. May be NULL, in which case
- * malloc/free/realloc will be used.
- *
- * \returns an allocated handle on success, NULL on failure (bad params)
- */
- yajl_gen YAJL_API yajl_gen_alloc(const yajl_gen_config * config,
- const yajl_alloc_funcs * allocFuncs);
-
- /** free a generator handle */
- void YAJL_API yajl_gen_free(yajl_gen handle);
-
- yajl_gen_status YAJL_API yajl_gen_integer(yajl_gen hand, long int number);
- yajl_gen_status YAJL_API yajl_gen_double(yajl_gen hand, double number);
- yajl_gen_status YAJL_API yajl_gen_number(yajl_gen hand,
- const char * num,
- unsigned int len);
- yajl_gen_status YAJL_API yajl_gen_string(yajl_gen hand,
- const unsigned char * str,
- unsigned int len);
- yajl_gen_status YAJL_API yajl_gen_null(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_bool(yajl_gen hand, int boolean);
- yajl_gen_status YAJL_API yajl_gen_map_open(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_map_close(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_array_open(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_array_close(yajl_gen hand);
-
- /** access the null terminated generator buffer. If incrementally
- * outputing JSON, one should call yajl_gen_clear to clear the
- * buffer. This allows stream generation. */
- yajl_gen_status YAJL_API yajl_gen_get_buf(yajl_gen hand,
- const unsigned char ** buf,
- unsigned int * len);
-
- /** clear yajl's output buffer, but maintain all internal generation
- * state. This function will not "reset" the generator state, and is
- * intended to enable incremental JSON outputing. */
- void YAJL_API yajl_gen_clear(yajl_gen hand);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/**
- * \file yajl_parse.h
- * Interface to YAJL's JSON parsing facilities.
- */
-
-#include <yajl/yajl_common.h>
-
-#ifndef __YAJL_PARSE_H__
-#define __YAJL_PARSE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- /** error codes returned from this interface */
- typedef enum {
- /** no error was encountered */
- yajl_status_ok,
- /** a client callback returned zero, stopping the parse */
- yajl_status_client_canceled,
- /** The parse cannot yet complete because more json input text
- * is required, call yajl_parse with the next buffer of input text.
- * (pertinent only when stream parsing) */
- yajl_status_insufficient_data,
- /** An error occured during the parse. Call yajl_get_error for
- * more information about the encountered error */
- yajl_status_error
- } yajl_status;
-
- /** attain a human readable, english, string for an error */
- const char * YAJL_API yajl_status_to_string(yajl_status code);
-
- /** an opaque handle to a parser */
- typedef struct yajl_handle_t * yajl_handle;
-
- /** yajl is an event driven parser. this means as json elements are
- * parsed, you are called back to do something with the data. The
- * functions in this table indicate the various events for which
- * you will be called back. Each callback accepts a "context"
- * pointer, this is a void * that is passed into the yajl_parse
- * function which the client code may use to pass around context.
- *
- * All callbacks return an integer. If non-zero, the parse will
- * continue. If zero, the parse will be canceled and
- * yajl_status_client_canceled will be returned from the parse.
- *
- * Note about handling of numbers:
- * yajl will only convert numbers that can be represented in a double
- * or a long int. All other numbers will be passed to the client
- * in string form using the yajl_number callback. Furthermore, if
- * yajl_number is not NULL, it will always be used to return numbers,
- * that is yajl_integer and yajl_double will be ignored. If
- * yajl_number is NULL but one of yajl_integer or yajl_double are
- * defined, parsing of a number larger than is representable
- * in a double or long int will result in a parse error.
- */
- typedef struct {
- int (* yajl_null)(void * ctx);
- int (* yajl_boolean)(void * ctx, int boolVal);
- int (* yajl_integer)(void * ctx, long integerVal);
- int (* yajl_double)(void * ctx, double doubleVal);
- /** A callback which passes the string representation of the number
- * back to the client. Will be used for all numbers when present */
- int (* yajl_number)(void * ctx, const char * numberVal,
- unsigned int numberLen);
-
- /** strings are returned as pointers into the JSON text when,
- * possible, as a result, they are _not_ null padded */
- int (* yajl_string)(void * ctx, const unsigned char * stringVal,
- unsigned int stringLen);
-
- int (* yajl_start_map)(void * ctx);
- int (* yajl_map_key)(void * ctx, const unsigned char * key,
- unsigned int stringLen);
- int (* yajl_end_map)(void * ctx);
-
- int (* yajl_start_array)(void * ctx);
- int (* yajl_end_array)(void * ctx);
- } yajl_callbacks;
-
- /** configuration structure for the generator */
- typedef struct {
- /** if nonzero, javascript style comments will be allowed in
- * the json input, both slash star and slash slash */
- unsigned int allowComments;
- /** if nonzero, invalid UTF8 strings will cause a parse
- * error */
- unsigned int checkUTF8;
- } yajl_parser_config;
-
- /** allocate a parser handle
- * \param callbacks a yajl callbacks structure specifying the
- * functions to call when different JSON entities
- * are encountered in the input text. May be NULL,
- * which is only useful for validation.
- * \param config configuration parameters for the parse.
- * \param ctx a context pointer that will be passed to callbacks.
- */
- yajl_handle YAJL_API yajl_alloc(const yajl_callbacks * callbacks,
- const yajl_parser_config * config,
- const yajl_alloc_funcs * allocFuncs,
- void * ctx);
-
- /** free a parser handle */
- void YAJL_API yajl_free(yajl_handle handle);
-
- /** Parse some json!
- * \param hand - a handle to the json parser allocated with yajl_alloc
- * \param jsonText - a pointer to the UTF8 json text to be parsed
- * \param jsonTextLength - the length, in bytes, of input text
- */
- yajl_status YAJL_API yajl_parse(yajl_handle hand,
- const unsigned char * jsonText,
- unsigned int jsonTextLength);
-
- /** Parse any remaining buffered json.
- * Since yajl is a stream-based parser, without an explicit end of
- * input, yajl sometimes can't decide if content at the end of the
- * stream is valid or not. For example, if "1" has been fed in,
- * yajl can't know whether another digit is next or some character
- * that would terminate the integer token.
- *
- * \param hand - a handle to the json parser allocated with yajl_alloc
- */
- yajl_status yajl_parse_complete(yajl_handle hand);
-
- /** get an error string describing the state of the
- * parse.
- *
- * If verbose is non-zero, the message will include the JSON
- * text where the error occured, along with an arrow pointing to
- * the specific char.
- *
- * A dynamically allocated string will be returned which should
- * be freed with yajl_free_error
- */
- unsigned char * YAJL_API yajl_get_error(yajl_handle hand, int verbose,
- const unsigned char * jsonText,
- unsigned int jsonTextLength);
-
- /** free an error returned from yajl_get_error */
- void YAJL_API yajl_free_error(yajl_handle hand, unsigned char * str);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 "api/yajl_parse.h"
-#include "yajl_lex.h"
-#include "yajl_parser.h"
-#include "yajl_alloc.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-const char *
-yajl_status_to_string(yajl_status stat)
-{
- const char * statStr = "unknown";
- switch (stat) {
- case yajl_status_ok:
- statStr = "ok, no error";
- break;
- case yajl_status_client_canceled:
- statStr = "client canceled parse";
- break;
- case yajl_status_insufficient_data:
- statStr = "eof was met before the parse could complete";
- break;
- case yajl_status_error:
- statStr = "parse error";
- break;
- }
- return statStr;
-}
-
-yajl_handle
-yajl_alloc(const yajl_callbacks * callbacks,
- const yajl_parser_config * config,
- const yajl_alloc_funcs * afs,
- void * ctx)
-{
- unsigned int allowComments = 0;
- unsigned int validateUTF8 = 0;
- yajl_handle hand = NULL;
- yajl_alloc_funcs afsBuffer;
-
- /* first order of business is to set up memory allocation routines */
- if (afs != NULL) {
- if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL)
- {
- return NULL;
- }
- } else {
- yajl_set_default_alloc_funcs(&afsBuffer);
- afs = &afsBuffer;
- }
-
- hand = (yajl_handle) YA_MALLOC(afs, sizeof(struct yajl_handle_t));
-
- /* copy in pointers to allocation routines */
- memcpy((void *) &(hand->alloc), (void *) afs, sizeof(yajl_alloc_funcs));
-
- if (config != NULL) {
- allowComments = config->allowComments;
- validateUTF8 = config->checkUTF8;
- }
-
- hand->callbacks = callbacks;
- hand->ctx = ctx;
- hand->lexer = yajl_lex_alloc(&(hand->alloc), allowComments, validateUTF8);
- hand->errorOffset = 0;
- hand->decodeBuf = yajl_buf_alloc(&(hand->alloc));
- yajl_bs_init(hand->stateStack, &(hand->alloc));
-
- yajl_bs_push(hand->stateStack, yajl_state_start);
-
- return hand;
-}
-
-void
-yajl_free(yajl_handle handle)
-{
- yajl_bs_free(handle->stateStack);
- yajl_buf_free(handle->decodeBuf);
- yajl_lex_free(handle->lexer);
- YA_FREE(&(handle->alloc), handle);
-}
-
-yajl_status
-yajl_parse(yajl_handle hand, const unsigned char * jsonText,
- unsigned int jsonTextLen)
-{
- unsigned int offset = 0;
- yajl_status status;
- status = yajl_do_parse(hand, &offset, jsonText, jsonTextLen);
- return status;
-}
-
-yajl_status
-yajl_parse_complete(yajl_handle hand)
-{
- /* The particular case we want to handle is a trailing number.
- * Further input consisting of digits could cause our interpretation
- * of the number to change (buffered "1" but "2" comes in).
- * A very simple approach to this is to inject whitespace to terminate
- * any number in the lex buffer.
- */
- return yajl_parse(hand, (const unsigned char *)" ", 1);
-}
-
-unsigned char *
-yajl_get_error(yajl_handle hand, int verbose,
- const unsigned char * jsonText, unsigned int jsonTextLen)
-{
- return yajl_render_error_string(hand, jsonText, jsonTextLen, verbose);
-}
-
-void
-yajl_free_error(yajl_handle hand, unsigned char * str)
-{
- /* use memory allocation functions if set */
- YA_FREE(&(hand->alloc), str);
-}
-
-/* XXX: add utility routines to parse from file */
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/**
- * \file yajl_alloc.h
- * default memory allocation routines for yajl which use malloc/realloc and
- * free
- */
-
-#include "yajl_alloc.h"
-#include <stdlib.h>
-
-static void * yajl_internal_malloc(void *ctx, unsigned int sz)
-{
- return malloc(sz);
-}
-
-static void * yajl_internal_realloc(void *ctx, void * previous,
- unsigned int sz)
-{
- return realloc(previous, sz);
-}
-
-static void yajl_internal_free(void *ctx, void * ptr)
-{
- free(ptr);
-}
-
-void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf)
-{
- yaf->malloc = yajl_internal_malloc;
- yaf->free = yajl_internal_free;
- yaf->realloc = yajl_internal_realloc;
- yaf->ctx = NULL;
-}
-
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/**
- * \file yajl_alloc.h
- * default memory allocation routines for yajl which use malloc/realloc and
- * free
- */
-
-#ifndef __YAJL_ALLOC_H__
-#define __YAJL_ALLOC_H__
-
-#include "api/yajl_common.h"
-
-#define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
-#define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
-#define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
-
-void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 "yajl_buf.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define YAJL_BUF_INIT_SIZE 2048
-
-struct yajl_buf_t {
- unsigned int len;
- unsigned int used;
- unsigned char * data;
- yajl_alloc_funcs * alloc;
-};
-
-static
-void yajl_buf_ensure_available(yajl_buf buf, unsigned int want)
-{
- unsigned int need;
-
- assert(buf != NULL);
-
- /* first call */
- if (buf->data == NULL) {
- buf->len = YAJL_BUF_INIT_SIZE;
- buf->data = (unsigned char *) YA_MALLOC(buf->alloc, buf->len);
- buf->data[0] = 0;
- }
-
- need = buf->len;
-
- while (want >= (need - buf->used)) need <<= 1;
-
- if (need != buf->len) {
- buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need);
- buf->len = need;
- }
-}
-
-yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc)
-{
- yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t));
- memset((void *) b, 0, sizeof(struct yajl_buf_t));
- b->alloc = alloc;
- return b;
-}
-
-void yajl_buf_free(yajl_buf buf)
-{
- assert(buf != NULL);
- if (buf->data) YA_FREE(buf->alloc, buf->data);
- YA_FREE(buf->alloc, buf);
-}
-
-void yajl_buf_append(yajl_buf buf, const void * data, unsigned int len)
-{
- yajl_buf_ensure_available(buf, len);
- if (len > 0) {
- assert(data != NULL);
- memcpy(buf->data + buf->used, data, len);
- buf->used += len;
- buf->data[buf->used] = 0;
- }
-}
-
-void yajl_buf_clear(yajl_buf buf)
-{
- buf->used = 0;
- if (buf->data) buf->data[buf->used] = 0;
-}
-
-const unsigned char * yajl_buf_data(yajl_buf buf)
-{
- return buf->data;
-}
-
-unsigned int yajl_buf_len(yajl_buf buf)
-{
- return buf->used;
-}
-
-void
-yajl_buf_truncate(yajl_buf buf, unsigned int len)
-{
- assert(len <= buf->used);
- buf->used = len;
-}
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 __YAJL_BUF_H__
-#define __YAJL_BUF_H__
-
-#include "api/yajl_common.h"
-#include "yajl_alloc.h"
-
-/*
- * Implementation/performance notes. If this were moved to a header
- * only implementation using #define's where possible we might be
- * able to sqeeze a little performance out of the guy by killing function
- * call overhead. YMMV.
- */
-
-/**
- * yajl_buf is a buffer with exponential growth. the buffer ensures that
- * you are always null padded.
- */
-typedef struct yajl_buf_t * yajl_buf;
-
-/* allocate a new buffer */
-yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc);
-
-/* free the buffer */
-void yajl_buf_free(yajl_buf buf);
-
-/* append a number of bytes to the buffer */
-void yajl_buf_append(yajl_buf buf, const void * data, unsigned int len);
-
-/* empty the buffer */
-void yajl_buf_clear(yajl_buf buf);
-
-/* get a pointer to the beginning of the buffer */
-const unsigned char * yajl_buf_data(yajl_buf buf);
-
-/* get the length of the buffer */
-unsigned int yajl_buf_len(yajl_buf buf);
-
-/* truncate the buffer */
-void yajl_buf_truncate(yajl_buf buf, unsigned int len);
-
-#endif
+++ /dev/null
-/*
- * Copyright 2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/*
- * A header only implementation of a simple stack of bytes, used in YAJL
- * to maintain parse state.
- */
-
-#ifndef __YAJL_BYTESTACK_H__
-#define __YAJL_BYTESTACK_H__
-
-#include "api/yajl_common.h"
-
-#define YAJL_BS_INC 128
-
-typedef struct yajl_bytestack_t
-{
- unsigned char * stack;
- unsigned int size;
- unsigned int used;
- yajl_alloc_funcs * yaf;
-} yajl_bytestack;
-
-/* initialize a bytestack */
-#define yajl_bs_init(obs, _yaf) { \
- (obs).stack = NULL; \
- (obs).size = 0; \
- (obs).used = 0; \
- (obs).yaf = (_yaf); \
- } \
-
-
-/* initialize a bytestack */
-#define yajl_bs_free(obs) \
- if ((obs).stack) (obs).yaf->free((obs).yaf->ctx, (obs).stack);
-
-#define yajl_bs_current(obs) \
- (assert((obs).used > 0), (obs).stack[(obs).used - 1])
-
-#define yajl_bs_push(obs, byte) { \
- if (((obs).size - (obs).used) == 0) { \
- (obs).size += YAJL_BS_INC; \
- (obs).stack = (obs).yaf->realloc((obs).yaf->ctx,\
- (void *) (obs).stack, (obs).size);\
- } \
- (obs).stack[((obs).used)++] = (byte); \
-}
-
-/* removes the top item of the stack, returns nothing */
-#define yajl_bs_pop(obs) { ((obs).used)--; }
-
-#define yajl_bs_set(obs, byte) \
- (obs).stack[((obs).used) - 1] = (byte);
-
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 "yajl_encode.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-static void CharToHex(unsigned char c, char * hexBuf)
-{
- const char * hexchar = "0123456789ABCDEF";
- hexBuf[0] = hexchar[c >> 4];
- hexBuf[1] = hexchar[c & 0x0F];
-}
-
-void
-yajl_string_encode(yajl_buf buf, const unsigned char * str,
- unsigned int len)
-{
- unsigned int beg = 0;
- unsigned int end = 0;
- char hexBuf[7];
- hexBuf[0] = '\\'; hexBuf[1] = 'u'; hexBuf[2] = '0'; hexBuf[3] = '0';
- hexBuf[6] = 0;
-
- while (end < len) {
- const char * escaped = NULL;
- switch (str[end]) {
- case '\r': escaped = "\\r"; break;
- case '\n': escaped = "\\n"; break;
- case '\\': escaped = "\\\\"; break;
- /* case '/': escaped = "\\/"; break; */
- case '"': escaped = "\\\""; break;
- case '\f': escaped = "\\f"; break;
- case '\b': escaped = "\\b"; break;
- case '\t': escaped = "\\t"; break;
- default:
- if ((unsigned char) str[end] < 32) {
- CharToHex(str[end], hexBuf + 4);
- escaped = hexBuf;
- }
- break;
- }
- if (escaped != NULL) {
- yajl_buf_append(buf, str + beg, end - beg);
- yajl_buf_append(buf, escaped, strlen(escaped));
- beg = ++end;
- } else {
- ++end;
- }
- }
- yajl_buf_append(buf, str + beg, end - beg);
-}
-
-static void hexToDigit(unsigned int * val, const unsigned char * hex)
-{
- unsigned int i;
- for (i=0;i<4;i++) {
- unsigned char c = hex[i];
- if (c >= 'A') c = (c & ~0x20) - 7;
- c -= '0';
- assert(!(c & 0xF0));
- *val = (*val << 4) | c;
- }
-}
-
-static void Utf32toUtf8(unsigned int codepoint, char * utf8Buf)
-{
- if (codepoint < 0x80) {
- utf8Buf[0] = (char) codepoint;
- utf8Buf[1] = 0;
- } else if (codepoint < 0x0800) {
- utf8Buf[0] = (char) ((codepoint >> 6) | 0xC0);
- utf8Buf[1] = (char) ((codepoint & 0x3F) | 0x80);
- utf8Buf[2] = 0;
- } else if (codepoint < 0x10000) {
- utf8Buf[0] = (char) ((codepoint >> 12) | 0xE0);
- utf8Buf[1] = (char) (((codepoint >> 6) & 0x3F) | 0x80);
- utf8Buf[2] = (char) ((codepoint & 0x3F) | 0x80);
- utf8Buf[3] = 0;
- } else if (codepoint < 0x200000) {
- utf8Buf[0] =(char)((codepoint >> 18) | 0xF0);
- utf8Buf[1] =(char)(((codepoint >> 12) & 0x3F) | 0x80);
- utf8Buf[2] =(char)(((codepoint >> 6) & 0x3F) | 0x80);
- utf8Buf[3] =(char)((codepoint & 0x3F) | 0x80);
- utf8Buf[4] = 0;
- } else {
- utf8Buf[0] = '?';
- utf8Buf[1] = 0;
- }
-}
-
-void yajl_string_decode(yajl_buf buf, const unsigned char * str,
- unsigned int len)
-{
- unsigned int beg = 0;
- unsigned int end = 0;
-
- while (end < len) {
- if (str[end] == '\\') {
- char utf8Buf[5];
- const char * unescaped = "?";
- yajl_buf_append(buf, str + beg, end - beg);
- switch (str[++end]) {
- case 'r': unescaped = "\r"; break;
- case 'n': unescaped = "\n"; break;
- case '\\': unescaped = "\\"; break;
- case '/': unescaped = "/"; break;
- case '"': unescaped = "\""; break;
- case 'f': unescaped = "\f"; break;
- case 'b': unescaped = "\b"; break;
- case 't': unescaped = "\t"; break;
- case 'u': {
- unsigned int codepoint = 0;
- hexToDigit(&codepoint, str + ++end);
- end+=3;
- /* check if this is a surrogate */
- if ((codepoint & 0xFC00) == 0xD800) {
- end++;
- if (str[end] == '\\' && str[end + 1] == 'u') {
- unsigned int surrogate = 0;
- hexToDigit(&surrogate, str + end + 2);
- codepoint =
- (((codepoint & 0x3F) << 10) |
- ((((codepoint >> 6) & 0xF) + 1) << 16) |
- (surrogate & 0x3FF));
- end += 5;
- } else {
- unescaped = "?";
- break;
- }
- }
-
- Utf32toUtf8(codepoint, utf8Buf);
- unescaped = utf8Buf;
- break;
- }
- default:
- assert("this should never happen" == NULL);
- }
- yajl_buf_append(buf, unescaped, strlen(unescaped));
- beg = ++end;
- } else {
- end++;
- }
- }
- yajl_buf_append(buf, str + beg, end - beg);
-}
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 __YAJL_ENCODE_H__
-#define __YAJL_ENCODE_H__
-
-#include "yajl_buf.h"
-
-void yajl_string_encode(yajl_buf buf, const unsigned char * str,
- unsigned int length);
-
-void yajl_string_decode(yajl_buf buf, const unsigned char * str,
- unsigned int length);
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 "api/yajl_gen.h"
-#include "yajl_buf.h"
-#include "yajl_encode.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-typedef enum {
- yajl_gen_start,
- yajl_gen_map_start,
- yajl_gen_map_key,
- yajl_gen_map_val,
- yajl_gen_array_start,
- yajl_gen_in_array,
- yajl_gen_complete,
- yajl_gen_error
-} yajl_gen_state;
-
-struct yajl_gen_t
-{
- unsigned int depth;
- unsigned int pretty;
- const char * indentString;
- yajl_gen_state state[YAJL_MAX_DEPTH];
- yajl_buf buf;
- /* memory allocation routines */
- yajl_alloc_funcs alloc;
-};
-
-yajl_gen
-yajl_gen_alloc(const yajl_gen_config * config,
- const yajl_alloc_funcs * afs)
-{
- yajl_gen g = NULL;
- yajl_alloc_funcs afsBuffer;
-
- /* first order of business is to set up memory allocation routines */
- if (afs != NULL) {
- if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL)
- {
- return NULL;
- }
- } else {
- yajl_set_default_alloc_funcs(&afsBuffer);
- afs = &afsBuffer;
- }
-
- g = (yajl_gen) YA_MALLOC(afs, sizeof(struct yajl_gen_t));
- memset((void *) g, 0, sizeof(struct yajl_gen_t));
- /* copy in pointers to allocation routines */
- memcpy((void *) &(g->alloc), (void *) afs, sizeof(yajl_alloc_funcs));
-
- if (config) {
- g->pretty = config->beautify;
- g->indentString = config->indentString ? config->indentString : " ";
- }
- g->buf = yajl_buf_alloc(&(g->alloc));
-
- return g;
-}
-
-void
-yajl_gen_free(yajl_gen g)
-{
- yajl_buf_free(g->buf);
- YA_FREE(&(g->alloc), g);
-}
-
-#define INSERT_SEP \
- if (g->state[g->depth] == yajl_gen_map_key || \
- g->state[g->depth] == yajl_gen_in_array) { \
- yajl_buf_append(g->buf, ",", 1); \
- if (g->pretty) yajl_buf_append(g->buf, "\n", 1); \
- } else if (g->state[g->depth] == yajl_gen_map_val) { \
- yajl_buf_append(g->buf, ":", 1); \
- if (g->pretty) yajl_buf_append(g->buf, " ", 1); \
- }
-
-#define INSERT_WHITESPACE \
- if (g->pretty) { \
- if (g->state[g->depth] != yajl_gen_map_val) { \
- unsigned int _i; \
- for (_i=0;_i<g->depth;_i++) \
- yajl_buf_append(g->buf, g->indentString, \
- strlen(g->indentString)); \
- } \
- }
-
-#define ENSURE_NOT_KEY \
- if (g->state[g->depth] == yajl_gen_map_key) { \
- return yajl_gen_keys_must_be_strings; \
- } \
-
-/* check that we're not complete, or in error state. in a valid state
- * to be generating */
-#define ENSURE_VALID_STATE \
- if (g->state[g->depth] == yajl_gen_error) { \
- return yajl_gen_in_error_state;\
- } else if (g->state[g->depth] == yajl_gen_complete) { \
- return yajl_gen_generation_complete; \
- }
-
-#define INCREMENT_DEPTH \
- if (++(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded;
-
-#define APPENDED_ATOM \
- switch (g->state[g->depth]) { \
- case yajl_gen_start: \
- g->state[g->depth] = yajl_gen_complete; \
- break; \
- case yajl_gen_map_start: \
- case yajl_gen_map_key: \
- g->state[g->depth] = yajl_gen_map_val; \
- break; \
- case yajl_gen_array_start: \
- g->state[g->depth] = yajl_gen_in_array; \
- break; \
- case yajl_gen_map_val: \
- g->state[g->depth] = yajl_gen_map_key; \
- break; \
- default: \
- break; \
- } \
-
-#define FINAL_NEWLINE \
- if (g->pretty && g->state[g->depth] == yajl_gen_complete) \
- yajl_buf_append(g->buf, "\n", 1);
-
-yajl_gen_status
-yajl_gen_integer(yajl_gen g, long int number)
-{
- char i[32];
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- sprintf(i, "%ld", number);
- yajl_buf_append(g->buf, i, strlen(i));
- APPENDED_ATOM;
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_double(yajl_gen g, double number)
-{
- char i[32];
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- sprintf(i, "%g", number);
- yajl_buf_append(g->buf, i, strlen(i));
- APPENDED_ATOM;
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_number(yajl_gen g, const char * s, unsigned int l)
-{
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- yajl_buf_append(g->buf, s, l);
- APPENDED_ATOM;
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_string(yajl_gen g, const unsigned char * str,
- unsigned int len)
-{
- ENSURE_VALID_STATE; INSERT_SEP; INSERT_WHITESPACE;
- yajl_buf_append(g->buf, "\"", 1);
- yajl_string_encode(g->buf, str, len);
- yajl_buf_append(g->buf, "\"", 1);
- APPENDED_ATOM;
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_null(yajl_gen g)
-{
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- yajl_buf_append(g->buf, "null", strlen("null"));
- APPENDED_ATOM;
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_bool(yajl_gen g, int boolean)
-{
- const char * val = boolean ? "true" : "false";
-
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- yajl_buf_append(g->buf, val, strlen(val));
- APPENDED_ATOM;
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_map_open(yajl_gen g)
-{
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- INCREMENT_DEPTH;
-
- g->state[g->depth] = yajl_gen_map_start;
- yajl_buf_append(g->buf, "{", 1);
- if (g->pretty) yajl_buf_append(g->buf, "\n", 1);
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_map_close(yajl_gen g)
-{
- ENSURE_VALID_STATE;
- (g->depth)--;
- if (g->pretty) yajl_buf_append(g->buf, "\n", 1);
- APPENDED_ATOM;
- INSERT_WHITESPACE;
- yajl_buf_append(g->buf, "}", 1);
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_array_open(yajl_gen g)
-{
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
- INCREMENT_DEPTH;
- g->state[g->depth] = yajl_gen_array_start;
- yajl_buf_append(g->buf, "[", 1);
- if (g->pretty) yajl_buf_append(g->buf, "\n", 1);
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_array_close(yajl_gen g)
-{
- ENSURE_VALID_STATE;
- if (g->pretty) yajl_buf_append(g->buf, "\n", 1);
- (g->depth)--;
- APPENDED_ATOM;
- INSERT_WHITESPACE;
- yajl_buf_append(g->buf, "]", 1);
- FINAL_NEWLINE;
- return yajl_gen_status_ok;
-}
-
-yajl_gen_status
-yajl_gen_get_buf(yajl_gen g, const unsigned char ** buf,
- unsigned int * len)
-{
- *buf = yajl_buf_data(g->buf);
- *len = yajl_buf_len(g->buf);
- return yajl_gen_status_ok;
-}
-
-void
-yajl_gen_clear(yajl_gen g)
-{
- yajl_buf_clear(g->buf);
-}
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 "yajl_lex.h"
-#include "yajl_buf.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-
-#ifdef YAJL_LEXER_DEBUG
-static const char *
-tokToStr(yajl_tok tok)
-{
- switch (tok) {
- case yajl_tok_bool: return "bool";
- case yajl_tok_colon: return "colon";
- case yajl_tok_comma: return "comma";
- case yajl_tok_eof: return "eof";
- case yajl_tok_error: return "error";
- case yajl_tok_left_brace: return "brace";
- case yajl_tok_left_bracket: return "bracket";
- case yajl_tok_null: return "null";
- case yajl_tok_integer: return "integer";
- case yajl_tok_double: return "double";
- case yajl_tok_right_brace: return "brace";
- case yajl_tok_right_bracket: return "bracket";
- case yajl_tok_string: return "string";
- case yajl_tok_string_with_escapes: return "string_with_escapes";
- }
- return "unknown";
-}
-#endif
-
-/* Impact of the stream parsing feature on the lexer:
- *
- * YAJL support stream parsing. That is, the ability to parse the first
- * bits of a chunk of JSON before the last bits are available (still on
- * the network or disk). This makes the lexer more complex. The
- * responsibility of the lexer is to handle transparently the case where
- * a chunk boundary falls in the middle of a token. This is
- * accomplished is via a buffer and a character reading abstraction.
- *
- * Overview of implementation
- *
- * When we lex to end of input string before end of token is hit, we
- * copy all of the input text composing the token into our lexBuf.
- *
- * Every time we read a character, we do so through the readChar function.
- * readChar's responsibility is to handle pulling all chars from the buffer
- * before pulling chars from input text
- */
-
-struct yajl_lexer_t {
- /* the overal line and char offset into the data */
- unsigned int lineOff;
- unsigned int charOff;
-
- /* error */
- yajl_lex_error error;
-
- /* a input buffer to handle the case where a token is spread over
- * multiple chunks */
- yajl_buf buf;
-
- /* in the case where we have data in the lexBuf, bufOff holds
- * the current offset into the lexBuf. */
- unsigned int bufOff;
-
- /* are we using the lex buf? */
- unsigned int bufInUse;
-
- /* shall we allow comments? */
- unsigned int allowComments;
-
- /* shall we validate utf8 inside strings? */
- unsigned int validateUTF8;
-
- yajl_alloc_funcs * alloc;
-};
-
-#define readChar(lxr, txt, off) \
- (((lxr)->bufInUse && yajl_buf_len((lxr)->buf) && lxr->bufOff < yajl_buf_len((lxr)->buf)) ? \
- (*((const unsigned char *) yajl_buf_data((lxr)->buf) + ((lxr)->bufOff)++)) : \
- ((txt)[(*(off))++]))
-
-#define unreadChar(lxr, off) ((*(off) > 0) ? (*(off))-- : ((lxr)->bufOff--))
-
-yajl_lexer
-yajl_lex_alloc(yajl_alloc_funcs * alloc,
- unsigned int allowComments, unsigned int validateUTF8)
-{
- yajl_lexer lxr = (yajl_lexer) YA_MALLOC(alloc, sizeof(struct yajl_lexer_t));
- memset((void *) lxr, 0, sizeof(struct yajl_lexer_t));
- lxr->buf = yajl_buf_alloc(alloc);
- lxr->allowComments = allowComments;
- lxr->validateUTF8 = validateUTF8;
- lxr->alloc = alloc;
- return lxr;
-}
-
-void
-yajl_lex_free(yajl_lexer lxr)
-{
- yajl_buf_free(lxr->buf);
- YA_FREE(lxr->alloc, lxr);
- return;
-}
-
-/* a lookup table which lets us quickly determine three things:
- * VEC - valid escaped conrol char
- * IJC - invalid json char
- * VHC - valid hex char
- * note. the solidus '/' may be escaped or not.
- * note. the
- */
-#define VEC 1
-#define IJC 2
-#define VHC 4
-static const char charLookupTable[256] =
-{
-/*00*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
-/*08*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
-/*10*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
-/*18*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
-
-/*20*/ 0 , 0 , VEC|IJC, 0 , 0 , 0 , 0 , 0 ,
-/*28*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , VEC ,
-/*30*/ VHC , VHC , VHC , VHC , VHC , VHC , VHC , VHC ,
-/*38*/ VHC , VHC , 0 , 0 , 0 , 0 , 0 , 0 ,
-
-/*40*/ 0 , VHC , VHC , VHC , VHC , VHC , VHC , 0 ,
-/*48*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
-/*50*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
-/*58*/ 0 , 0 , 0 , 0 , VEC|IJC, 0 , 0 , 0 ,
-
-/*60*/ 0 , VHC , VEC|VHC, VHC , VHC , VHC , VEC|VHC, 0 ,
-/*68*/ 0 , 0 , 0 , 0 , 0 , 0 , VEC , 0 ,
-/*70*/ 0 , 0 , VEC , 0 , VEC , 0 , 0 , 0 ,
-/*78*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
-
-/* include these so we don't have to always check the range of the char */
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
-
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
-
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
-
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
-};
-
-/** process a variable length utf8 encoded codepoint.
- *
- * returns:
- * yajl_tok_string - if valid utf8 char was parsed and offset was
- * advanced
- * yajl_tok_eof - if end of input was hit before validation could
- * complete
- * yajl_tok_error - if invalid utf8 was encountered
- *
- * NOTE: on error the offset will point to the first char of the
- * invalid utf8 */
-#define UTF8_CHECK_EOF if (*offset >= jsonTextLen) { return yajl_tok_eof; }
-
-static yajl_tok
-yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int * offset,
- unsigned char curChar)
-{
- if (curChar <= 0x7f) {
- /* single byte */
- return yajl_tok_string;
- } else if ((curChar >> 5) == 0x6) {
- /* two byte */
- UTF8_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if ((curChar >> 6) == 0x2) return yajl_tok_string;
- } else if ((curChar >> 4) == 0x0e) {
- /* three byte */
- UTF8_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if ((curChar >> 6) == 0x2) {
- UTF8_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if ((curChar >> 6) == 0x2) return yajl_tok_string;
- }
- } else if ((curChar >> 3) == 0x1e) {
- /* four byte */
- UTF8_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if ((curChar >> 6) == 0x2) {
- UTF8_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if ((curChar >> 6) == 0x2) {
- UTF8_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if ((curChar >> 6) == 0x2) return yajl_tok_string;
- }
- }
- }
-
- return yajl_tok_error;
-}
-
-/* lex a string. input is the lexer, pointer to beginning of
- * json text, and start of string (offset).
- * a token is returned which has the following meanings:
- * yajl_tok_string: lex of string was successful. offset points to
- * terminating '"'.
- * yajl_tok_eof: end of text was encountered before we could complete
- * the lex.
- * yajl_tok_error: embedded in the string were unallowable chars. offset
- * points to the offending char
- */
-#define STR_CHECK_EOF \
-if (*offset >= jsonTextLen) { \
- tok = yajl_tok_eof; \
- goto finish_string_lex; \
-}
-
-static yajl_tok
-yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int * offset)
-{
- yajl_tok tok = yajl_tok_error;
- int hasEscapes = 0;
-
- for (;;) {
- unsigned char curChar;
-
- STR_CHECK_EOF;
-
- curChar = readChar(lexer, jsonText, offset);
-
- /* quote terminates */
- if (curChar == '"') {
- tok = yajl_tok_string;
- break;
- }
- /* backslash escapes a set of control chars, */
- else if (curChar == '\\') {
- hasEscapes = 1;
- STR_CHECK_EOF;
-
- /* special case \u */
- curChar = readChar(lexer, jsonText, offset);
- if (curChar == 'u') {
- unsigned int i = 0;
-
- for (i=0;i<4;i++) {
- STR_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
- if (!(charLookupTable[curChar] & VHC)) {
- /* back up to offending char */
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_string_invalid_hex_char;
- goto finish_string_lex;
- }
- }
- } else if (!(charLookupTable[curChar] & VEC)) {
- /* back up to offending char */
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_string_invalid_escaped_char;
- goto finish_string_lex;
- }
- }
- /* when not validating UTF8 it's a simple table lookup to determine
- * if the present character is invalid */
- else if(charLookupTable[curChar] & IJC) {
- /* back up to offending char */
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_string_invalid_json_char;
- goto finish_string_lex;
- }
- /* when in validate UTF8 mode we need to do some extra work */
- else if (lexer->validateUTF8) {
- yajl_tok t = yajl_lex_utf8_char(lexer, jsonText, jsonTextLen,
- offset, curChar);
-
- if (t == yajl_tok_eof) {
- tok = yajl_tok_eof;
- goto finish_string_lex;
- } else if (t == yajl_tok_error) {
- lexer->error = yajl_lex_string_invalid_utf8;
- goto finish_string_lex;
- }
- }
- /* accept it, and move on */
- }
- finish_string_lex:
- /* tell our buddy, the parser, wether he needs to process this string
- * again */
- if (hasEscapes && tok == yajl_tok_string) {
- tok = yajl_tok_string_with_escapes;
- }
-
- return tok;
-}
-
-#define RETURN_IF_EOF if (*offset >= jsonTextLen) return yajl_tok_eof;
-
-static yajl_tok
-yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int * offset)
-{
- /** XXX: numbers are the only entities in json that we must lex
- * _beyond_ in order to know that they are complete. There
- * is an ambiguous case for integers at EOF. */
-
- unsigned char c;
-
- yajl_tok tok = yajl_tok_integer;
-
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
-
- /* optional leading minus */
- if (c == '-') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- }
-
- /* a single zero, or a series of integers */
- if (c == '0') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- } else if (c >= '1' && c <= '9') {
- do {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- } while (c >= '0' && c <= '9');
- } else {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_missing_integer_after_minus;
- return yajl_tok_error;
- }
-
- /* optional fraction (indicates this is floating point) */
- if (c == '.') {
- int numRd = 0;
-
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
-
- while (c >= '0' && c <= '9') {
- numRd++;
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- }
-
- if (!numRd) {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_missing_integer_after_decimal;
- return yajl_tok_error;
- }
- tok = yajl_tok_double;
- }
-
- /* optional exponent (indicates this is floating point) */
- if (c == 'e' || c == 'E') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
-
- /* optional sign */
- if (c == '+' || c == '-') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- }
-
- if (c >= '0' && c <= '9') {
- do {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- } while (c >= '0' && c <= '9');
- } else {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_missing_integer_after_exponent;
- return yajl_tok_error;
- }
- tok = yajl_tok_double;
- }
-
- /* we always go "one too far" */
- unreadChar(lexer, offset);
-
- return tok;
-}
-
-static yajl_tok
-yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int * offset)
-{
- unsigned char c;
-
- yajl_tok tok = yajl_tok_comment;
-
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
-
- /* either slash or star expected */
- if (c == '/') {
- /* now we throw away until end of line */
- do {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- } while (c != '\n');
- } else if (c == '*') {
- /* now we throw away until end of comment */
- for (;;) {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- if (c == '*') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- if (c == '/') {
- break;
- } else {
- unreadChar(lexer, offset);
- }
- }
- }
- } else {
- lexer->error = yajl_lex_invalid_char;
- tok = yajl_tok_error;
- }
-
- return tok;
-}
-
-yajl_tok
-yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int * offset,
- const unsigned char ** outBuf, unsigned int * outLen)
-{
- yajl_tok tok = yajl_tok_error;
- unsigned char c;
- unsigned int startOffset = *offset;
-
- *outBuf = NULL;
- *outLen = 0;
-
- for (;;) {
- assert(*offset <= jsonTextLen);
-
- if (*offset >= jsonTextLen) {
- tok = yajl_tok_eof;
- goto lexed;
- }
-
- c = readChar(lexer, jsonText, offset);
-
- switch (c) {
- case '{':
- tok = yajl_tok_left_bracket;
- goto lexed;
- case '}':
- tok = yajl_tok_right_bracket;
- goto lexed;
- case '[':
- tok = yajl_tok_left_brace;
- goto lexed;
- case ']':
- tok = yajl_tok_right_brace;
- goto lexed;
- case ',':
- tok = yajl_tok_comma;
- goto lexed;
- case ':':
- tok = yajl_tok_colon;
- goto lexed;
- case '\t': case '\n': case '\v': case '\f': case '\r': case ' ':
- startOffset++;
- break;
- case 't': {
- const char * want = "rue";
- do {
- if (*offset >= jsonTextLen) {
- tok = yajl_tok_eof;
- goto lexed;
- }
- c = readChar(lexer, jsonText, offset);
- if (c != *want) {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_invalid_string;
- tok = yajl_tok_error;
- goto lexed;
- }
- } while (*(++want));
- tok = yajl_tok_bool;
- goto lexed;
- }
- case 'f': {
- const char * want = "alse";
- do {
- if (*offset >= jsonTextLen) {
- tok = yajl_tok_eof;
- goto lexed;
- }
- c = readChar(lexer, jsonText, offset);
- if (c != *want) {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_invalid_string;
- tok = yajl_tok_error;
- goto lexed;
- }
- } while (*(++want));
- tok = yajl_tok_bool;
- goto lexed;
- }
- case 'n': {
- const char * want = "ull";
- do {
- if (*offset >= jsonTextLen) {
- tok = yajl_tok_eof;
- goto lexed;
- }
- c = readChar(lexer, jsonText, offset);
- if (c != *want) {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_invalid_string;
- tok = yajl_tok_error;
- goto lexed;
- }
- } while (*(++want));
- tok = yajl_tok_null;
- goto lexed;
- }
- case '"': {
- tok = yajl_lex_string(lexer, (const unsigned char *) jsonText,
- jsonTextLen, offset);
- goto lexed;
- }
- case '-':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': {
- /* integer parsing wants to start from the beginning */
- unreadChar(lexer, offset);
- tok = yajl_lex_number(lexer, (const unsigned char *) jsonText,
- jsonTextLen, offset);
- goto lexed;
- }
- case '/':
- /* hey, look, a probable comment! If comments are disabled
- * it's an error. */
- if (!lexer->allowComments) {
- unreadChar(lexer, offset);
- lexer->error = yajl_lex_unallowed_comment;
- tok = yajl_tok_error;
- goto lexed;
- }
- /* if comments are enabled, then we should try to lex
- * the thing. possible outcomes are
- * - successful lex (tok_comment, which means continue),
- * - malformed comment opening (slash not followed by
- * '*' or '/') (tok_error)
- * - eof hit. (tok_eof) */
- tok = yajl_lex_comment(lexer, (const unsigned char *) jsonText,
- jsonTextLen, offset);
- if (tok == yajl_tok_comment) {
- /* "error" is silly, but that's the initial
- * state of tok. guilty until proven innocent. */
- tok = yajl_tok_error;
- yajl_buf_clear(lexer->buf);
- lexer->bufInUse = 0;
- startOffset = *offset;
- break;
- }
- /* hit error or eof, bail */
- goto lexed;
- default:
- lexer->error = yajl_lex_invalid_char;
- tok = yajl_tok_error;
- goto lexed;
- }
- }
-
-
- lexed:
- /* need to append to buffer if the buffer is in use or
- * if it's an EOF token */
- if (tok == yajl_tok_eof || lexer->bufInUse) {
- if (!lexer->bufInUse) yajl_buf_clear(lexer->buf);
- lexer->bufInUse = 1;
- yajl_buf_append(lexer->buf, jsonText + startOffset, *offset - startOffset);
- lexer->bufOff = 0;
-
- if (tok != yajl_tok_eof) {
- *outBuf = yajl_buf_data(lexer->buf);
- *outLen = yajl_buf_len(lexer->buf);
- lexer->bufInUse = 0;
- }
- } else if (tok != yajl_tok_error) {
- *outBuf = jsonText + startOffset;
- *outLen = *offset - startOffset;
- }
-
- /* special case for strings. skip the quotes. */
- if (tok == yajl_tok_string || tok == yajl_tok_string_with_escapes)
- {
- assert(*outLen >= 2);
- (*outBuf)++;
- *outLen -= 2;
- }
-
-
-#ifdef YAJL_LEXER_DEBUG
- if (tok == yajl_tok_error) {
- printf("lexical error: %s\n",
- yajl_lex_error_to_string(yajl_lex_get_error(lexer)));
- } else if (tok == yajl_tok_eof) {
- printf("EOF hit\n");
- } else {
- printf("lexed %s: '", tokToStr(tok));
- fwrite(*outBuf, 1, *outLen, stdout);
- printf("'\n");
- }
-#endif
-
- return tok;
-}
-
-const char *
-yajl_lex_error_to_string(yajl_lex_error error)
-{
- switch (error) {
- case yajl_lex_e_ok:
- return "ok, no error";
- case yajl_lex_string_invalid_utf8:
- return "invalid bytes in UTF8 string.";
- case yajl_lex_string_invalid_escaped_char:
- return "inside a string, '\\' occurs before a character "
- "which it may not.";
- case yajl_lex_string_invalid_json_char:
- return "invalid character inside string.";
- case yajl_lex_string_invalid_hex_char:
- return "invalid (non-hex) character occurs after '\\u' inside "
- "string.";
- case yajl_lex_invalid_char:
- return "invalid char in json text.";
- case yajl_lex_invalid_string:
- return "invalid string in json text.";
- case yajl_lex_missing_integer_after_exponent:
- return "malformed number, a digit is required after the exponent.";
- case yajl_lex_missing_integer_after_decimal:
- return "malformed number, a digit is required after the "
- "decimal point.";
- case yajl_lex_missing_integer_after_minus:
- return "malformed number, a digit is required after the "
- "minus sign.";
- case yajl_lex_unallowed_comment:
- return "probable comment found in input text, comments are "
- "not enabled.";
- }
- return "unknown error code";
-}
-
-
-/** allows access to more specific information about the lexical
- * error when yajl_lex_lex returns yajl_tok_error. */
-yajl_lex_error
-yajl_lex_get_error(yajl_lexer lexer)
-{
- if (lexer == NULL) return (yajl_lex_error) -1;
- return lexer->error;
-}
-
-unsigned int yajl_lex_current_line(yajl_lexer lexer)
-{
- return lexer->lineOff;
-}
-
-unsigned int yajl_lex_current_char(yajl_lexer lexer)
-{
- return lexer->charOff;
-}
-
-yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int offset)
-{
- const unsigned char * outBuf;
- unsigned int outLen;
- unsigned int bufLen = yajl_buf_len(lexer->buf);
- unsigned int bufOff = lexer->bufOff;
- unsigned int bufInUse = lexer->bufInUse;
- yajl_tok tok;
-
- tok = yajl_lex_lex(lexer, jsonText, jsonTextLen, &offset,
- &outBuf, &outLen);
-
- lexer->bufOff = bufOff;
- lexer->bufInUse = bufInUse;
- yajl_buf_truncate(lexer->buf, bufLen);
-
- return tok;
-}
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 __YAJL_LEX_H__
-#define __YAJL_LEX_H__
-
-#include "api/yajl_common.h"
-
-typedef enum {
- yajl_tok_bool,
- yajl_tok_colon,
- yajl_tok_comma,
- yajl_tok_eof,
- yajl_tok_error,
- yajl_tok_left_brace,
- yajl_tok_left_bracket,
- yajl_tok_null,
- yajl_tok_right_brace,
- yajl_tok_right_bracket,
-
- /* we differentiate between integers and doubles to allow the
- * parser to interpret the number without re-scanning */
- yajl_tok_integer,
- yajl_tok_double,
-
- /* we differentiate between strings which require further processing,
- * and strings that do not */
- yajl_tok_string,
- yajl_tok_string_with_escapes,
-
- /* comment tokens are not currently returned to the parser, ever */
- yajl_tok_comment
-} yajl_tok;
-
-typedef struct yajl_lexer_t * yajl_lexer;
-
-yajl_lexer yajl_lex_alloc(yajl_alloc_funcs * alloc,
- unsigned int allowComments,
- unsigned int validateUTF8);
-
-void yajl_lex_free(yajl_lexer lexer);
-
-/**
- * run/continue a lex. "offset" is an input/output parameter.
- * It should be initialized to zero for a
- * new chunk of target text, and upon subsetquent calls with the same
- * target text should passed with the value of the previous invocation.
- *
- * the client may be interested in the value of offset when an error is
- * returned from the lexer. This allows the client to render useful
-n * error messages.
- *
- * When you pass the next chunk of data, context should be reinitialized
- * to zero.
- *
- * Finally, the output buffer is usually just a pointer into the jsonText,
- * however in cases where the entity being lexed spans multiple chunks,
- * the lexer will buffer the entity and the data returned will be
- * a pointer into that buffer.
- *
- * This behavior is abstracted from client code except for the performance
- * implications which require that the client choose a reasonable chunk
- * size to get adequate performance.
- */
-yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int * offset,
- const unsigned char ** outBuf, unsigned int * outLen);
-
-/** have a peek at the next token, but don't move the lexer forward */
-yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText,
- unsigned int jsonTextLen, unsigned int offset);
-
-
-typedef enum {
- yajl_lex_e_ok = 0,
- yajl_lex_string_invalid_utf8,
- yajl_lex_string_invalid_escaped_char,
- yajl_lex_string_invalid_json_char,
- yajl_lex_string_invalid_hex_char,
- yajl_lex_invalid_char,
- yajl_lex_invalid_string,
- yajl_lex_missing_integer_after_decimal,
- yajl_lex_missing_integer_after_exponent,
- yajl_lex_missing_integer_after_minus,
- yajl_lex_unallowed_comment
-} yajl_lex_error;
-
-const char * yajl_lex_error_to_string(yajl_lex_error error);
-
-/** allows access to more specific information about the lexical
- * error when yajl_lex_lex returns yajl_tok_error. */
-yajl_lex_error yajl_lex_get_error(yajl_lexer lexer);
-
-/** get the current offset into the most recently lexed json string. */
-unsigned int yajl_lex_current_offset(yajl_lexer lexer);
-
-/** get the number of lines lexed by this lexer instance */
-unsigned int yajl_lex_current_line(yajl_lexer lexer);
-
-/** get the number of chars lexed by this lexer instance since the last
- * \n or \r */
-unsigned int yajl_lex_current_char(yajl_lexer lexer);
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 "yajl_lex.h"
-#include "yajl_parser.h"
-#include "yajl_encode.h"
-#include "yajl_bytestack.h"
-
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-#include <math.h>
-
-unsigned char *
-yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
- unsigned int jsonTextLen, int verbose)
-{
- unsigned int offset = hand->errorOffset;
- unsigned char * str;
- const char * errorType = NULL;
- const char * errorText = NULL;
- char text[72];
- const char * arrow = " (right here) ------^\n";
-
- if (yajl_bs_current(hand->stateStack) == yajl_state_parse_error) {
- errorType = "parse";
- errorText = hand->parseError;
- } else if (yajl_bs_current(hand->stateStack) == yajl_state_lexical_error) {
- errorType = "lexical";
- errorText = yajl_lex_error_to_string(yajl_lex_get_error(hand->lexer));
- } else {
- errorType = "unknown";
- }
-
- {
- unsigned int memneeded = 0;
- memneeded += strlen(errorType);
- memneeded += strlen(" error");
- if (errorText != NULL) {
- memneeded += strlen(": ");
- memneeded += strlen(errorText);
- }
- str = (unsigned char *) YA_MALLOC(&(hand->alloc), memneeded + 2);
- str[0] = 0;
- strcat((char *) str, errorType);
- strcat((char *) str, " error");
- if (errorText != NULL) {
- strcat((char *) str, ": ");
- strcat((char *) str, errorText);
- }
- strcat((char *) str, "\n");
- }
-
- /* now we append as many spaces as needed to make sure the error
- * falls at char 41, if verbose was specified */
- if (verbose) {
- unsigned int start, end, i;
- unsigned int spacesNeeded;
-
- spacesNeeded = (offset < 30 ? 40 - offset : 10);
- start = (offset >= 30 ? offset - 30 : 0);
- end = (offset + 30 > jsonTextLen ? jsonTextLen : offset + 30);
-
- for (i=0;i<spacesNeeded;i++) text[i] = ' ';
-
- for (;start < end;start++, i++) {
- if (jsonText[start] != '\n' && jsonText[start] != '\r')
- {
- text[i] = jsonText[start];
- }
- else
- {
- text[i] = ' ';
- }
- }
- assert(i <= 71);
- text[i++] = '\n';
- text[i] = 0;
- {
- char * newStr = (char *)
- YA_MALLOC(&(hand->alloc), (strlen((char *) str) +
- strlen((char *) text) +
- strlen(arrow) + 1));
- newStr[0] = 0;
- strcat((char *) newStr, (char *) str);
- strcat((char *) newStr, text);
- strcat((char *) newStr, arrow);
- YA_FREE(&(hand->alloc), str);
- str = (unsigned char *) newStr;
- }
- }
- return str;
-}
-
-/* check for client cancelation */
-#define _CC_CHK(x) \
- if (!(x)) { \
- yajl_bs_set(hand->stateStack, yajl_state_parse_error); \
- hand->parseError = \
- "client cancelled parse via callback return value"; \
- return yajl_status_client_canceled; \
- }
-
-
-yajl_status
-yajl_do_parse(yajl_handle hand, unsigned int * offset,
- const unsigned char * jsonText, unsigned int jsonTextLen)
-{
- yajl_tok tok;
- const unsigned char * buf;
- unsigned int bufLen;
-
- around_again:
- switch (yajl_bs_current(hand->stateStack)) {
- case yajl_state_parse_complete:
- return yajl_status_ok;
- case yajl_state_lexical_error:
- case yajl_state_parse_error:
- hand->errorOffset = *offset;
- return yajl_status_error;
- case yajl_state_start:
- case yajl_state_map_need_val:
- case yajl_state_array_need_val:
- case yajl_state_array_start: {
- /* for arrays and maps, we advance the state for this
- * depth, then push the state of the next depth.
- * If an error occurs during the parsing of the nesting
- * enitity, the state at this level will not matter.
- * a state that needs pushing will be anything other
- * than state_start */
- yajl_state stateToPush = yajl_state_start;
-
- tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
- offset, &buf, &bufLen);
-
- switch (tok) {
- case yajl_tok_eof:
- return yajl_status_insufficient_data;
- case yajl_tok_error:
- yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
- goto around_again;
- case yajl_tok_string:
- if (hand->callbacks && hand->callbacks->yajl_string) {
- _CC_CHK(hand->callbacks->yajl_string(hand->ctx,
- buf, bufLen));
- }
- break;
- case yajl_tok_string_with_escapes:
- if (hand->callbacks && hand->callbacks->yajl_string) {
- yajl_buf_clear(hand->decodeBuf);
- yajl_string_decode(hand->decodeBuf, buf, bufLen);
- _CC_CHK(hand->callbacks->yajl_string(
- hand->ctx, yajl_buf_data(hand->decodeBuf),
- yajl_buf_len(hand->decodeBuf)));
- }
- break;
- case yajl_tok_bool:
- if (hand->callbacks && hand->callbacks->yajl_boolean) {
- _CC_CHK(hand->callbacks->yajl_boolean(hand->ctx,
- *buf == 't'));
- }
- break;
- case yajl_tok_null:
- if (hand->callbacks && hand->callbacks->yajl_null) {
- _CC_CHK(hand->callbacks->yajl_null(hand->ctx));
- }
- break;
- case yajl_tok_left_bracket:
- if (hand->callbacks && hand->callbacks->yajl_start_map) {
- _CC_CHK(hand->callbacks->yajl_start_map(hand->ctx));
- }
- stateToPush = yajl_state_map_start;
- break;
- case yajl_tok_left_brace:
- if (hand->callbacks && hand->callbacks->yajl_start_array) {
- _CC_CHK(hand->callbacks->yajl_start_array(hand->ctx));
- }
- stateToPush = yajl_state_array_start;
- break;
- case yajl_tok_integer:
- /*
- * note. strtol does not respect the length of
- * the lexical token. in a corner case where the
- * lexed number is a integer with a trailing zero,
- * immediately followed by the end of buffer,
- * sscanf could run off into oblivion and cause a
- * crash. for this reason we copy the integer
- * (and doubles), into our parse buffer (the same
- * one used for unescaping strings), before
- * calling strtol. yajl_buf ensures null padding,
- * so we're safe.
- */
- if (hand->callbacks) {
- if (hand->callbacks->yajl_number) {
- _CC_CHK(hand->callbacks->yajl_number(
- hand->ctx,(const char *) buf, bufLen));
- } else if (hand->callbacks->yajl_integer) {
- long int i = 0;
- yajl_buf_clear(hand->decodeBuf);
- yajl_buf_append(hand->decodeBuf, buf, bufLen);
- buf = yajl_buf_data(hand->decodeBuf);
- i = strtol((const char *) buf, NULL, 10);
- if ((i == LONG_MIN || i == LONG_MAX) &&
- errno == ERANGE)
- {
- yajl_bs_set(hand->stateStack,
- yajl_state_parse_error);
- hand->parseError = "integer overflow" ;
- /* try to restore error offset */
- if (*offset >= bufLen) *offset -= bufLen;
- else *offset = 0;
- goto around_again;
- }
- _CC_CHK(hand->callbacks->yajl_integer(hand->ctx,
- i));
- }
- }
- break;
- case yajl_tok_double:
- if (hand->callbacks) {
- if (hand->callbacks->yajl_number) {
- _CC_CHK(hand->callbacks->yajl_number(
- hand->ctx, (const char *) buf, bufLen));
- } else if (hand->callbacks->yajl_double) {
- double d = 0.0;
- yajl_buf_clear(hand->decodeBuf);
- yajl_buf_append(hand->decodeBuf, buf, bufLen);
- buf = yajl_buf_data(hand->decodeBuf);
- d = strtod((char *) buf, NULL);
- if ((d == HUGE_VAL || d == -HUGE_VAL) &&
- errno == ERANGE)
- {
- yajl_bs_set(hand->stateStack,
- yajl_state_parse_error);
- hand->parseError = "numeric (floating point) "
- "overflow";
- /* try to restore error offset */
- if (*offset >= bufLen) *offset -= bufLen;
- else *offset = 0;
- goto around_again;
- }
- _CC_CHK(hand->callbacks->yajl_double(hand->ctx,
- d));
- }
- }
- break;
- case yajl_tok_right_brace: {
- if (yajl_bs_current(hand->stateStack) ==
- yajl_state_array_start)
- {
- if (hand->callbacks &&
- hand->callbacks->yajl_end_array)
- {
- _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx));
- }
- yajl_bs_pop(hand->stateStack);
- goto around_again;
- }
- /* intentional fall-through */
- }
- case yajl_tok_colon:
- case yajl_tok_comma:
- case yajl_tok_right_bracket:
- yajl_bs_set(hand->stateStack, yajl_state_parse_error);
- hand->parseError =
- "unallowed token at this point in JSON text";
- goto around_again;
- default:
- yajl_bs_set(hand->stateStack, yajl_state_parse_error);
- hand->parseError = "invalid token, internal error";
- goto around_again;
- }
- /* got a value. transition depends on the state we're in. */
- {
- yajl_state s = yajl_bs_current(hand->stateStack);
- if (s == yajl_state_start) {
- yajl_bs_set(hand->stateStack, yajl_state_parse_complete);
- } else if (s == yajl_state_map_need_val) {
- yajl_bs_set(hand->stateStack, yajl_state_map_got_val);
- } else {
- yajl_bs_set(hand->stateStack, yajl_state_array_got_val);
- }
- }
- if (stateToPush != yajl_state_start) {
- yajl_bs_push(hand->stateStack, stateToPush);
- }
-
- goto around_again;
- }
- case yajl_state_map_start:
- case yajl_state_map_need_key: {
- /* only difference between these two states is that in
- * start '}' is valid, whereas in need_key, we've parsed
- * a comma, and a string key _must_ follow */
- tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
- offset, &buf, &bufLen);
- switch (tok) {
- case yajl_tok_eof:
- return yajl_status_insufficient_data;
- case yajl_tok_error:
- yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
- goto around_again;
- case yajl_tok_string_with_escapes:
- if (hand->callbacks && hand->callbacks->yajl_map_key) {
- yajl_buf_clear(hand->decodeBuf);
- yajl_string_decode(hand->decodeBuf, buf, bufLen);
- buf = yajl_buf_data(hand->decodeBuf);
- bufLen = yajl_buf_len(hand->decodeBuf);
- }
- /* intentional fall-through */
- case yajl_tok_string:
- if (hand->callbacks && hand->callbacks->yajl_map_key) {
- _CC_CHK(hand->callbacks->yajl_map_key(hand->ctx, buf,
- bufLen));
- }
- yajl_bs_set(hand->stateStack, yajl_state_map_sep);
- goto around_again;
- case yajl_tok_right_bracket:
- if (yajl_bs_current(hand->stateStack) ==
- yajl_state_map_start)
- {
- if (hand->callbacks && hand->callbacks->yajl_end_map) {
- _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx));
- }
- yajl_bs_pop(hand->stateStack);
- goto around_again;
- }
- default:
- yajl_bs_set(hand->stateStack, yajl_state_parse_error);
- hand->parseError =
- "invalid object key (must be a string)";
- goto around_again;
- }
- }
- case yajl_state_map_sep: {
- tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
- offset, &buf, &bufLen);
- switch (tok) {
- case yajl_tok_colon:
- yajl_bs_set(hand->stateStack, yajl_state_map_need_val);
- goto around_again;
- case yajl_tok_eof:
- return yajl_status_insufficient_data;
- case yajl_tok_error:
- yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
- goto around_again;
- default:
- yajl_bs_set(hand->stateStack, yajl_state_parse_error);
- hand->parseError = "object key and value must "
- "be separated by a colon (':')";
- goto around_again;
- }
- }
- case yajl_state_map_got_val: {
- tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
- offset, &buf, &bufLen);
- switch (tok) {
- case yajl_tok_right_bracket:
- if (hand->callbacks && hand->callbacks->yajl_end_map) {
- _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx));
- }
- yajl_bs_pop(hand->stateStack);
- goto around_again;
- case yajl_tok_comma:
- yajl_bs_set(hand->stateStack, yajl_state_map_need_key);
- goto around_again;
- case yajl_tok_eof:
- return yajl_status_insufficient_data;
- case yajl_tok_error:
- yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
- goto around_again;
- default:
- yajl_bs_set(hand->stateStack, yajl_state_parse_error);
- hand->parseError = "after key and value, inside map, "
- "I expect ',' or '}'";
- /* try to restore error offset */
- if (*offset >= bufLen) *offset -= bufLen;
- else *offset = 0;
- goto around_again;
- }
- }
- case yajl_state_array_got_val: {
- tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
- offset, &buf, &bufLen);
- switch (tok) {
- case yajl_tok_right_brace:
- if (hand->callbacks && hand->callbacks->yajl_end_array) {
- _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx));
- }
- yajl_bs_pop(hand->stateStack);
- goto around_again;
- case yajl_tok_comma:
- yajl_bs_set(hand->stateStack, yajl_state_array_need_val);
- goto around_again;
- case yajl_tok_eof:
- return yajl_status_insufficient_data;
- case yajl_tok_error:
- yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
- goto around_again;
- default:
- yajl_bs_set(hand->stateStack, yajl_state_parse_error);
- hand->parseError =
- "after array element, I expect ',' or ']'";
- goto around_again;
- }
- }
- }
-
- abort();
- return yajl_status_error;
-}
-
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 __YAJL_PARSER_H__
-#define __YAJL_PARSER_H__
-
-#include "api/yajl_parse.h"
-#include "yajl_bytestack.h"
-#include "yajl_buf.h"
-
-
-typedef enum {
- yajl_state_start = 0,
- yajl_state_parse_complete,
- yajl_state_parse_error,
- yajl_state_lexical_error,
- yajl_state_map_start,
- yajl_state_map_sep,
- yajl_state_map_need_val,
- yajl_state_map_got_val,
- yajl_state_map_need_key,
- yajl_state_array_start,
- yajl_state_array_got_val,
- yajl_state_array_need_val
-} yajl_state;
-
-struct yajl_handle_t {
- const yajl_callbacks * callbacks;
- void * ctx;
- yajl_lexer lexer;
- const char * parseError;
- unsigned int errorOffset;
- /* temporary storage for decoded strings */
- yajl_buf decodeBuf;
- /* a stack of states. access with yajl_state_XXX routines */
- yajl_bytestack stateStack;
- /* memory allocation routines */
- yajl_alloc_funcs alloc;
-};
-
-yajl_status
-yajl_do_parse(yajl_handle handle, unsigned int * offset,
- const unsigned char * jsonText, unsigned int jsonTextLen);
-
-unsigned char *
-yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
- unsigned int jsonTextLen, int verbose);
-
-
-#endif
+++ /dev/null
-# Copyright 2007-2009, Lloyd Hilaiel.
-#
-# 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
-
-SET (SRCS yajl_test.c)
-
-# use the library we build, duh.
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include)
-LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
-
-ADD_EXECUTABLE(yajl_test ${SRCS})
-
-TARGET_LINK_LIBRARIES(yajl_test yajl_s)
+++ /dev/null
-["foo",
- "bar", "baz",
- true,false,null,{"key":"value"},
- [null,null,null,[]],
- "\n\r\\"
-]
+++ /dev/null
-array open '['
-string: 'foo'
-string: 'bar'
-string: 'baz'
-bool: true
-bool: false
-null
-map open '{'
-key: 'key'
-string: 'value'
-map close '}'
-array open '['
-null
-null
-null
-array open '['
-array close ']'
-array close ']'
-string: '
-\r\'
-array close ']'
-memory leaks: 0
+++ /dev/null
-parse error: unallowed token at this point in JSON text
-memory leaks: 0
+++ /dev/null
-array open '['
-memory leaks: 0
+++ /dev/null
-["this","is","what","should","be",
- "a happy bit of json",
- "but someone, misspelled \"true\"", ture,
- "who says JSON is easy for humans to generate?"]
+++ /dev/null
-array open '['
-string: 'this'
-string: 'is'
-string: 'what'
-string: 'should'
-string: 'be'
-string: 'a happy bit of json'
-string: 'but someone, misspelled "true"'
-lexical error: invalid string in json text.
-memory leaks: 0
+++ /dev/null
-"\u004d\u0430\u4e8c\ud800\udf02"
+++ /dev/null
-string: 'Mа二𐌂'
-memory leaks: 0
+++ /dev/null
-{
- "this": "is", // ignore this
- "really": "simple",
- /* ignore
-this
-too * /
-** //
-(/
-******/
- "json": "right?"
-}
+++ /dev/null
-map open '{'
-key: 'this'
-string: 'is'
-lexical error: probable comment found in input text, comments are not enabled.
-memory leaks: 0
+++ /dev/null
-[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
\ No newline at end of file
+++ /dev/null
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array open '['
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-array close ']'
-memory leaks: 0
+++ /dev/null
-{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML", "markup"] } ] } } }
+++ /dev/null
-map open '{'
-key: 'glossary'
-map open '{'
-key: 'title'
-string: 'example glossary'
-key: 'GlossDiv'
-map open '{'
-key: 'title'
-string: 'S'
-key: 'GlossList'
-array open '['
-map open '{'
-key: 'ID'
-string: 'SGML'
-key: 'SortAs'
-string: 'SGML'
-key: 'GlossTerm'
-string: 'Standard Generalized Markup Language'
-key: 'Acronym'
-string: 'SGML'
-key: 'Abbrev'
-string: 'ISO 8879:1986'
-key: 'GlossDef'
-string: 'A meta-markup language, used to create markup languages such as DocBook.'
-key: 'GlossSeeAlso'
-array open '['
-string: 'GML'
-string: 'XML'
-string: 'markup'
-array close ']'
-map close '}'
-array close ']'
-map close '}'
-map close '}'
-map close '}'
-memory leaks: 0
+++ /dev/null
-{ "glossary": { /* you */ "title": /**/ "example glossary", /*should*/"GlossDiv": { "title": /*never*/"S", /*ever*/"GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", /*see*/"GlossSeeAlso"/*this*/:/*coming*/[/*out*/"GML"/*of*/,/*the*/"XML"/*parser!*/, "markup"] /*hey*/}/*ho*/]/*hey*/}/*ho*/} } // and the parser won't even get this far, so chill. /* hah!
+++ /dev/null
-map open '{'
-key: 'glossary'
-map open '{'
-key: 'title'
-string: 'example glossary'
-key: 'GlossDiv'
-map open '{'
-key: 'title'
-string: 'S'
-key: 'GlossList'
-array open '['
-map open '{'
-key: 'ID'
-string: 'SGML'
-key: 'SortAs'
-string: 'SGML'
-key: 'GlossTerm'
-string: 'Standard Generalized Markup Language'
-key: 'Acronym'
-string: 'SGML'
-key: 'Abbrev'
-string: 'ISO 8879:1986'
-key: 'GlossDef'
-string: 'A meta-markup language, used to create markup languages such as DocBook.'
-key: 'GlossSeeAlso'
-array open '['
-string: 'GML'
-string: 'XML'
-string: 'markup'
-array close ']'
-map close '}'
-array close ']'
-map close '}'
-map close '}'
-map close '}'
-memory leaks: 0
+++ /dev/null
-[ 0.1e2, 1e1, 3.141569, 10000000000000e-10]
+++ /dev/null
-array open '['
-double: 10
-double: 10
-double: 3.14157
-double: 1000
-array close ']'
-memory leaks: 0
+++ /dev/null
-[]
\ No newline at end of file
+++ /dev/null
-array open '['
-array close ']'
-memory leaks: 0
+++ /dev/null
-string: ''
-memory leaks: 0
+++ /dev/null
-["\u0414\u0430",
- "\u041c\u0443",
- "\u0415\u0431\u0430",
- "\u041c\u0430\u0439\u043a\u0430\u0442\u0430"]
+++ /dev/null
-array open '['
-string: 'Да'
-string: 'Му'
-string: 'Еба'
-string: 'Майката'
-array close ']'
-memory leaks: 0
+++ /dev/null
-"\u0066\u006f\u006f\u0062\u0061\u0072"
+++ /dev/null
-string: 'foobar'
-memory leaks: 0
+++ /dev/null
-bool: false
-memory leaks: 0
+++ /dev/null
-falsex
\ No newline at end of file
+++ /dev/null
-bool: false
-memory leaks: 0
+++ /dev/null
-{ "U+10ABCD": "" }
-
+++ /dev/null
-map open '{'
-key: 'U+10ABCD'
-string: ''
-map close '}'
-memory leaks: 0
+++ /dev/null
-[ 1,2,3,4,5,6,7,
- 123456789 , -123456789,
- 2147483647, -2147483647,
- 2147483648 ]
+++ /dev/null
-array open '['
-integer: 1
-integer: 2
-integer: 3
-integer: 4
-integer: 5
-integer: 6
-integer: 7
-integer: 123456789
-integer: -123456789
-integer: 2147483647
-integer: -2147483647
-parse error: integer overflow
-memory leaks: 0
+++ /dev/null
-["Ð\94а Ð\9cÑ Ð\95ба Ð\9cайкаÑ\82а"]
+++ /dev/null
-array open '['
-lexical error: invalid bytes in UTF8 string.
-memory leaks: 0
+++ /dev/null
-string: '?'
-memory leaks: 0
+++ /dev/null
-{ "bad thing": 01 }
+++ /dev/null
-map open '{'
-key: 'bad thing'
-integer: 0
-parse error: after key and value, inside map, I expect ',' or '}'
-memory leaks: 0
+++ /dev/null
-[
- "foo", true,
- true, "blue",
- "baby where are you?", "oh boo hoo!",
- -
-]
-
+++ /dev/null
-array open '['
-string: 'foo'
-bool: true
-bool: true
-string: 'blue'
-string: 'baby where are you?'
-string: 'oh boo hoo!'
-lexical error: malformed number, a digit is required after the minus sign.
-memory leaks: 0
+++ /dev/null
-123456789
\ No newline at end of file
+++ /dev/null
-integer: 123456789
-memory leaks: 0
+++ /dev/null
-parse error: unallowed token at this point in JSON text
-memory leaks: 0
+++ /dev/null
-map open '{'
-memory leaks: 0
+++ /dev/null
-lexical error: malformed number, a digit is required after the decimal point.
-memory leaks: 0
+++ /dev/null
-lexical error: malformed number, a digit is required after the exponent.
-memory leaks: 0
+++ /dev/null
-{"CoreletAPIVersion":2,"CoreletType":"standalone","documentation":"A corelet that provides the capability to upload a folder\92s contents into a user\92s locker.","functions":[{"documentation":"Displays a dialog box that allows user to select a folder on the local system.","name":"ShowBrowseDialog","parameters":[{"documentation":"The callback function for results.","name":"callback","required":true,"type":"callback"}]},{"documentation":"Uploads all mp3 files in the folder provided.","name":"UploadFolder","parameters":[{"documentation":"The path to upload mp3 files from.","name":"path","required":true,"type":"string"},{"documentation":"The callback function for progress.","name":"callback","required":true,"type":"callback"}]},{"documentation":"Returns the server name to the current locker service.","name":"GetLockerService","parameters":[]},{"documentation":"Changes the name of the locker service.","name":"SetLockerService","parameters":[{"documentation":"The value of the locker service to set active.","name":"LockerService","required":true,"type":"string"}]},{"documentation":"Downloads locker files to the suggested folder.","name":"DownloadFile","parameters":[{"documentation":"The origin path of the locker file.","name":"path","required":true,"type":"string"},{"documentation":"The Window destination path of the locker file.","name":"destination","required":true,"type":"integer"},{"documentation":"The callback function for progress.","name":"callback","required":true,"type":"callback"}]}],"name":"LockerUploader","version":{"major":0,"micro":1,"minor":0},"versionString":"0.0.1"}
\ No newline at end of file
+++ /dev/null
-map open '{'
-key: 'CoreletAPIVersion'
-integer: 2
-key: 'CoreletType'
-string: 'standalone'
-key: 'documentation'
-lexical error: invalid bytes in UTF8 string.
-memory leaks: 0
+++ /dev/null
-null
-memory leaks: 0
+++ /dev/null
-null
-memory leaks: 0
+++ /dev/null
-{
- "boolean, true": true,
- "boolean, false": false,
- "null": null
-}
+++ /dev/null
-map open '{'
-key: 'boolean, true'
-bool: true
-key: 'boolean, false'
-bool: false
-key: 'null'
-null
-map close '}'
-memory leaks: 0
+++ /dev/null
-{
- "this": "is",
- "really": "simple",
- "json": "right?"
-}
+++ /dev/null
-map open '{'
-key: 'this'
-string: 'is'
-key: 'really'
-string: 'simple'
-key: 'json'
-string: 'right?'
-map close '}'
-memory leaks: 0
+++ /dev/null
-{
- "this": "is", // ignore this
- "really": "simple",
- /* ignore
-this
-too * /
-** //
-(/
-******/
- "json": "right?"
-}
+++ /dev/null
-map open '{'
-key: 'this'
-string: 'is'
-key: 'really'
-string: 'simple'
-key: 'json'
-string: 'right?'
-map close '}'
-memory leaks: 0
+++ /dev/null
-["\n foo \/ bar \r\f\\\uffff\t\b\"\\ and you can't escape thi\s"]
+++ /dev/null
-array open '['
-lexical error: inside a string, '\' occurs before a character which it may not.
-memory leaks: 0
+++ /dev/null
-"foo foo, blah blah \u0123 \u4567 \u89ab \uc/ef \uABCD \uEFFE bar baz bing"
+++ /dev/null
-lexical error: invalid (non-hex) character occurs after '\u' inside string.
-memory leaks: 0
+++ /dev/null
-["\n foo \/ bar \r\f\\\uffff\t\b\"\\",
- "\"and this string has an escape at the beginning",
- "and this string has no escapes" ]
+++ /dev/null
-array open '['
-string: '
- foo / bar \r\f\ \b"\'
-string: '"and this string has an escape at the beginning'
-string: 'and this string has no escapes'
-array close ']'
-memory leaks: 0
+++ /dev/null
-"la di dah. this is a string, and I can do this, \n, but not this
-"
+++ /dev/null
-lexical error: invalid character inside string.
-memory leaks: 0
+++ /dev/null
-{"matzue": "松江", "asakusa": "浅草"}
+++ /dev/null
-map open '{'
-key: 'matzue'
-string: '松江'
-key: 'asakusa'
-string: '浅草'
-map close '}'
-memory leaks: 0
+++ /dev/null
-bool: true
-memory leaks: 0
+++ /dev/null
-truex
\ No newline at end of file
+++ /dev/null
-bool: true
-memory leaks: 0
+++ /dev/null
-["Да Му Еба Майката"]
+++ /dev/null
-array open '['
-string: 'Да Му Еба Майката'
-array close ']'
-memory leaks: 0
+++ /dev/null
-#!/usr/bin/env bash
-
-DIFF_FLAGS="-u"
-if [[ `uname` == *W32* ]] ; then
- DIFF_FLAGS="-wu"
-fi
-
-# find test binary on both platforms. allow the caller to force a
-# particular test binary (useful for non-cmake build systems).
-if [ -z "$testBin" ]; then
- testBin="../build/test/Debug/yajl_test.exe"
- if [[ ! -x $testBin ]] ; then
- testBin="../build/test/yajl_test"
- if [[ ! -x $testBin ]] ; then
- echo "cannot execute test binary: '$testBin'"
- exit 1;
- fi
- fi
-fi
-
-echo "using test binary: $testBin"
-
-let testsSucceeded=0
-let testsTotal=0
-
-for file in cases/*.json ; do
- allowComments="-c"
-
- # if the filename starts with dc_, we disallow comments for this test
- if [[ $(basename $file) == dc_* ]] ; then
- allowComments=""
- fi
- echo -n " test case: '$file': "
- let iter=1
- success="success"
-
- # parse with a read buffer size ranging from 1-31 to stress stream parsing
- while (( $iter < 32 )) && [ $success == "success" ] ; do
- $testBin $allowComments -b $iter < $file > ${file}.test 2>&1
- diff ${DIFF_FLAGS} ${file}.gold ${file}.test
- if [[ $? == 0 ]] ; then
- if (( $iter == 31 )) ; then let testsSucceeded+=1 ; fi
- else
- success="FAILURE"
- let iter=32
- fi
- let iter+=1
- rm ${file}.test
- done
-
- echo $success
- let testsTotal+=1
-done
-
-echo $testsSucceeded/$testsTotal tests successful
-
-if [[ $testsSucceeded != $testsTotal ]] ; then
- exit 1
-fi
-
-exit 0
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 <yajl/yajl_parse.h>
-#include <yajl/yajl_gen.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <assert.h>
-
-/* memory debugging routines */
-typedef struct
-{
- unsigned int numFrees;
- unsigned int numMallocs;
- /* XXX: we really need a hash table here with per-allocation
- * information */
-} yajlTestMemoryContext;
-
-/* cast void * into context */
-#define TEST_CTX(vptr) ((yajlTestMemoryContext *) (vptr))
-
-static void yajlTestFree(void * ctx, void * ptr)
-{
- assert(ptr != NULL);
- TEST_CTX(ctx)->numFrees++;
- free(ptr);
-}
-
-static void * yajlTestMalloc(void * ctx, unsigned int sz)
-{
- assert(sz != 0);
- TEST_CTX(ctx)->numMallocs++;
- return malloc(sz);
-}
-
-static void * yajlTestRealloc(void * ctx, void * ptr, unsigned int sz)
-{
- if (ptr == NULL) {
- assert(sz != 0);
- TEST_CTX(ctx)->numMallocs++;
- } else if (sz == 0) {
- TEST_CTX(ctx)->numFrees++;
- }
-
- return realloc(ptr, sz);
-}
-
-
-/* begin parsing callback routines */
-#define BUF_SIZE 2048
-
-static int test_yajl_null(void *ctx)
-{
- printf("null\n");
- return 1;
-}
-
-static int test_yajl_boolean(void * ctx, int boolVal)
-{
- printf("bool: %s\n", boolVal ? "true" : "false");
- return 1;
-}
-
-static int test_yajl_integer(void *ctx, long integerVal)
-{
- printf("integer: %ld\n", integerVal);
- return 1;
-}
-
-static int test_yajl_double(void *ctx, double doubleVal)
-{
- printf("double: %g\n", doubleVal);
- return 1;
-}
-
-static int test_yajl_string(void *ctx, const unsigned char * stringVal,
- unsigned int stringLen)
-{
- printf("string: '");
- fwrite(stringVal, 1, stringLen, stdout);
- printf("'\n");
- return 1;
-}
-
-static int test_yajl_map_key(void *ctx, const unsigned char * stringVal,
- unsigned int stringLen)
-{
- char * str = (char *) malloc(stringLen + 1);
- str[stringLen] = 0;
- memcpy(str, stringVal, stringLen);
- printf("key: '%s'\n", str);
- free(str);
- return 1;
-}
-
-static int test_yajl_start_map(void *ctx)
-{
- printf("map open '{'\n");
- return 1;
-}
-
-
-static int test_yajl_end_map(void *ctx)
-{
- printf("map close '}'\n");
- return 1;
-}
-
-static int test_yajl_start_array(void *ctx)
-{
- printf("array open '['\n");
- return 1;
-}
-
-static int test_yajl_end_array(void *ctx)
-{
- printf("array close ']'\n");
- return 1;
-}
-
-static yajl_callbacks callbacks = {
- test_yajl_null,
- test_yajl_boolean,
- test_yajl_integer,
- test_yajl_double,
- NULL,
- test_yajl_string,
- test_yajl_start_map,
- test_yajl_map_key,
- test_yajl_end_map,
- test_yajl_start_array,
- test_yajl_end_array
-};
-
-static void usage(const char * progname)
-{
- fprintf(stderr,
- "usage: %s [options] <filename>\n"
- " -c allow comments\n"
- " -b set the read buffer size\n",
- progname);
- exit(1);
-}
-
-int
-main(int argc, char ** argv)
-{
- yajl_handle hand;
- const char * fileName;
- static unsigned char * fileData = NULL;
- unsigned int bufSize = BUF_SIZE;
- yajl_status stat;
- size_t rd;
- yajl_parser_config cfg = { 0, 1 };
- int i, j, done;
-
- /* memory allocation debugging: allocate a structure which collects
- * statistics */
- yajlTestMemoryContext memCtx = { 0,0 };
-
- /* memory allocation debugging: allocate a structure which holds
- * allocation routines */
- yajl_alloc_funcs allocFuncs = {
- yajlTestMalloc,
- yajlTestRealloc,
- yajlTestFree,
- (void *) NULL
- };
-
- allocFuncs.ctx = (void *) &memCtx;
-
- /* check arguments. We expect exactly one! */
- for (i=1;i<argc;i++) {
- if (!strcmp("-c", argv[i])) {
- cfg.allowComments = 1;
- } else if (!strcmp("-b", argv[i])) {
- if (++i >= argc) usage(argv[0]);
-
- /* validate integer */
- for (j=0;j<(int)strlen(argv[i]);j++) {
- if (argv[i][j] <= '9' && argv[i][j] >= '0') continue;
- fprintf(stderr, "-b requires an integer argument. '%s' "
- "is invalid\n", argv[i]);
- usage(argv[0]);
- }
-
- bufSize = atoi(argv[i]);
- if (!bufSize) {
- fprintf(stderr, "%d is an invalid buffer size\n",
- bufSize);
- }
- } else {
- fprintf(stderr, "invalid command line option: '%s'\n",
- argv[i]);
- usage(argv[0]);
- }
- }
-
- fileData = (unsigned char *) malloc(bufSize);
-
- if (fileData == NULL) {
- fprintf(stderr,
- "failed to allocate read buffer of %u bytes, exiting.",
- bufSize);
- exit(2);
- }
-
- fileName = argv[argc-1];
-
- /* ok. open file. let's read and parse */
- hand = yajl_alloc(&callbacks, &cfg, &allocFuncs, NULL);
-
- done = 0;
- while (!done) {
- rd = fread((void *) fileData, 1, bufSize, stdin);
-
- if (rd == 0) {
- if (!feof(stdin)) {
- fprintf(stderr, "error reading from '%s'\n", fileName);
- break;
- }
- done = 1;
- }
-
- if (done)
- /* parse any remaining buffered data */
- stat = yajl_parse_complete(hand);
- else
- /* read file data, pass to parser */
- stat = yajl_parse(hand, fileData, rd);
-
- if (stat != yajl_status_insufficient_data &&
- stat != yajl_status_ok)
- {
- unsigned char * str = yajl_get_error(hand, 0, fileData, rd);
- fflush(stdout);
- fprintf(stderr, (char *) str);
- yajl_free_error(hand, str);
- break;
- }
- }
-
- yajl_free(hand);
- free(fileData);
-
- /* finally, print out some memory statistics */
-
-/* (lth) only print leaks here, as allocations and frees may vary depending
- * on read buffer size, causing false failures.
- *
- * printf("allocations:\t%u\n", memCtx.numMallocs);
- * printf("frees:\t\t%u\n", memCtx.numFrees);
-*/
- fflush(stderr);
- fflush(stdout);
- printf("memory leaks:\t%u\n", memCtx.numMallocs - memCtx.numFrees);
-
- return 0;
-}
+++ /dev/null
-# Copyright 2007-2009, Lloyd Hilaiel.
-#
-# 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
-
-# set up some paths
-SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/bin)
-
-# create some directories
-FILE(MAKE_DIRECTORY ${binDir})
-
-SET (SRCS json_verify.c)
-
-# use the library we build, duh.
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include)
-LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
-
-ADD_EXECUTABLE(json_verify ${SRCS})
-
-TARGET_LINK_LIBRARIES(json_verify yajl_s)
-
-# copy in the binary
-GET_TARGET_PROPERTY(binPath json_verify LOCATION)
-
-ADD_CUSTOM_COMMAND(TARGET json_verify POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${binPath} ${binDir})
-
-IF (NOT WIN32)
- INSTALL(TARGETS json_verify RUNTIME DESTINATION bin)
-ENDIF ()
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 <yajl/yajl_parse.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void
-usage(const char * progname)
-{
- fprintf(stderr, "%s: validate json from stdin\n"
- "usage: json_verify [options]\n"
- " -q quiet mode\n"
- " -c allow comments\n"
- " -u allow invalid utf8 inside strings\n",
- progname);
- exit(1);
-}
-
-int
-main(int argc, char ** argv)
-{
- yajl_status stat;
- size_t rd;
- yajl_handle hand;
- static unsigned char fileData[65536];
- int quiet = 0;
- int retval = 0, done = 0;
- yajl_parser_config cfg = { 0, 1 };
-
- /* check arguments.*/
- if (argc > 1 && argc < 4) {
- int i;
-
- for (i=1; i < argc;i++) {
- if (!strcmp("-q", argv[i])) {
- quiet = 1;
- } else if (!strcmp("-c", argv[i])) {
- cfg.allowComments = 1;
- } else if (!strcmp("-u", argv[i])) {
- cfg.checkUTF8 = 0;
- } else {
- fprintf(stderr, "unrecognized option: '%s'\n\n", argv[i]);
- usage(argv[0]);
- }
- }
- } else if (argc != 1) {
- usage(argv[0]);
- }
-
- /* allocate a parser */
- hand = yajl_alloc(NULL, &cfg, NULL, NULL);
-
- while (!done) {
- rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin);
-
- retval = 0;
-
- if (rd == 0) {
- if (!feof(stdin)) {
- if (!quiet) {
- fprintf(stderr, "error encountered on file read\n");
- }
- retval = 1;
- break;
- }
- done = 1;
- }
- fileData[rd] = 0;
-
- if (done)
- /* parse any remaining buffered data */
- stat = yajl_parse_complete(hand);
- else
- /* read file data, pass to parser */
- stat = yajl_parse(hand, fileData, rd);
-
- if (stat != yajl_status_ok &&
- stat != yajl_status_insufficient_data)
- {
- if (!quiet) {
- unsigned char * str = yajl_get_error(hand, 1, fileData, rd);
- fprintf(stderr, (const char *) str);
- yajl_free_error(hand, str);
- }
- retval = 1;
- break;
- }
- }
-
- yajl_free(hand);
-
- if (!quiet) {
- printf("JSON is %s\n", retval ? "invalid" : "valid");
- }
-
- return retval;
-}
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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 __YAJL_COMMON_H__
-#define __YAJL_COMMON_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define YAJL_MAX_DEPTH 128
-
-/* msft dll export gunk. To build a DLL on windows, you
- * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared
- * DLL, you must define YAJL_SHARED and WIN32 */
-#if defined(WIN32) && defined(YAJL_SHARED)
-# ifdef YAJL_BUILD
-# define YAJL_API __declspec(dllexport)
-# else
-# define YAJL_API __declspec(dllimport)
-# endif
-#else
-# define YAJL_API
-#endif
-
-/** pointer to a malloc function, supporting client overriding memory
- * allocation routines */
-typedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz);
-
-/** pointer to a free function, supporting client overriding memory
- * allocation routines */
-typedef void (*yajl_free_func)(void *ctx, void * ptr);
-
-/** pointer to a realloc function which can resize an allocation. */
-typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz);
-
-/** A structure which can be passed to yajl_*_alloc routines to allow the
- * client to specify memory allocation functions to be used. */
-typedef struct
-{
- /** pointer to a function that can allocate uninitialized memory */
- yajl_malloc_func malloc;
- /** pointer to a function that can resize memory allocations */
- yajl_realloc_func realloc;
- /** pointer to a function that can free memory allocated using
- * reallocFunction or mallocFunction */
- yajl_free_func free;
- /** a context pointer that will be passed to above allocation routines */
- void * ctx;
-} yajl_alloc_funcs;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/**
- * \file yajl_gen.h
- * Interface to YAJL's JSON generation facilities.
- */
-
-#include <yajl/yajl_common.h>
-
-#ifndef __YAJL_GEN_H__
-#define __YAJL_GEN_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- /** generator status codes */
- typedef enum {
- /** no error */
- yajl_gen_status_ok = 0,
- /** at a point where a map key is generated, a function other than
- * yajl_gen_string was called */
- yajl_gen_keys_must_be_strings,
- /** YAJL's maximum generation depth was exceeded. see
- * YAJL_MAX_DEPTH */
- yajl_max_depth_exceeded,
- /** A generator function (yajl_gen_XXX) was called while in an error
- * state */
- yajl_gen_in_error_state,
- /** A complete JSON document has been generated */
- yajl_gen_generation_complete
- } yajl_gen_status;
-
- /** an opaque handle to a generator */
- typedef struct yajl_gen_t * yajl_gen;
-
- /** configuration structure for the generator */
- typedef struct {
- /** generate indented (beautiful) output */
- unsigned int beautify;
- /** an opportunity to define an indent string. such as \\t or
- * some number of spaces. default is four spaces ' '. This
- * member is only relevant when beautify is true */
- const char * indentString;
- } yajl_gen_config;
-
- /** allocate a generator handle
- * \param config a pointer to a structure containing parameters which
- * configure the behavior of the json generator
- * \param allocFuncs an optional pointer to a structure which allows
- * the client to overide the memory allocation
- * used by yajl. May be NULL, in which case
- * malloc/free/realloc will be used.
- *
- * \returns an allocated handle on success, NULL on failure (bad params)
- */
- yajl_gen YAJL_API yajl_gen_alloc(const yajl_gen_config * config,
- const yajl_alloc_funcs * allocFuncs);
-
- /** free a generator handle */
- void YAJL_API yajl_gen_free(yajl_gen handle);
-
- yajl_gen_status YAJL_API yajl_gen_integer(yajl_gen hand, long int number);
- yajl_gen_status YAJL_API yajl_gen_double(yajl_gen hand, double number);
- yajl_gen_status YAJL_API yajl_gen_number(yajl_gen hand,
- const char * num,
- unsigned int len);
- yajl_gen_status YAJL_API yajl_gen_string(yajl_gen hand,
- const unsigned char * str,
- unsigned int len);
- yajl_gen_status YAJL_API yajl_gen_null(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_bool(yajl_gen hand, int boolean);
- yajl_gen_status YAJL_API yajl_gen_map_open(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_map_close(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_array_open(yajl_gen hand);
- yajl_gen_status YAJL_API yajl_gen_array_close(yajl_gen hand);
-
- /** access the null terminated generator buffer. If incrementally
- * outputing JSON, one should call yajl_gen_clear to clear the
- * buffer. This allows stream generation. */
- yajl_gen_status YAJL_API yajl_gen_get_buf(yajl_gen hand,
- const unsigned char ** buf,
- unsigned int * len);
-
- /** clear yajl's output buffer, but maintain all internal generation
- * state. This function will not "reset" the generator state, and is
- * intended to enable incremental JSON outputing. */
- void YAJL_API yajl_gen_clear(yajl_gen hand);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007-2009, Lloyd Hilaiel.
- *
- * 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 name of Lloyd Hilaiel 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 AUTHOR ``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 AUTHOR 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.
- */
-
-/**
- * \file yajl_parse.h
- * Interface to YAJL's JSON parsing facilities.
- */
-
-#include <yajl/yajl_common.h>
-
-#ifndef __YAJL_PARSE_H__
-#define __YAJL_PARSE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- /** error codes returned from this interface */
- typedef enum {
- /** no error was encountered */
- yajl_status_ok,
- /** a client callback returned zero, stopping the parse */
- yajl_status_client_canceled,
- /** The parse cannot yet complete because more json input text
- * is required, call yajl_parse with the next buffer of input text.
- * (pertinent only when stream parsing) */
- yajl_status_insufficient_data,
- /** An error occured during the parse. Call yajl_get_error for
- * more information about the encountered error */
- yajl_status_error
- } yajl_status;
-
- /** attain a human readable, english, string for an error */
- const char * YAJL_API yajl_status_to_string(yajl_status code);
-
- /** an opaque handle to a parser */
- typedef struct yajl_handle_t * yajl_handle;
-
- /** yajl is an event driven parser. this means as json elements are
- * parsed, you are called back to do something with the data. The
- * functions in this table indicate the various events for which
- * you will be called back. Each callback accepts a "context"
- * pointer, this is a void * that is passed into the yajl_parse
- * function which the client code may use to pass around context.
- *
- * All callbacks return an integer. If non-zero, the parse will
- * continue. If zero, the parse will be canceled and
- * yajl_status_client_canceled will be returned from the parse.
- *
- * Note about handling of numbers:
- * yajl will only convert numbers that can be represented in a double
- * or a long int. All other numbers will be passed to the client
- * in string form using the yajl_number callback. Furthermore, if
- * yajl_number is not NULL, it will always be used to return numbers,
- * that is yajl_integer and yajl_double will be ignored. If
- * yajl_number is NULL but one of yajl_integer or yajl_double are
- * defined, parsing of a number larger than is representable
- * in a double or long int will result in a parse error.
- */
- typedef struct {
- int (* yajl_null)(void * ctx);
- int (* yajl_boolean)(void * ctx, int boolVal);
- int (* yajl_integer)(void * ctx, long integerVal);
- int (* yajl_double)(void * ctx, double doubleVal);
- /** A callback which passes the string representation of the number
- * back to the client. Will be used for all numbers when present */
- int (* yajl_number)(void * ctx, const char * numberVal,
- unsigned int numberLen);
-
- /** strings are returned as pointers into the JSON text when,
- * possible, as a result, they are _not_ null padded */
- int (* yajl_string)(void * ctx, const unsigned char * stringVal,
- unsigned int stringLen);
-
- int (* yajl_start_map)(void * ctx);
- int (* yajl_map_key)(void * ctx, const unsigned char * key,
- unsigned int stringLen);
- int (* yajl_end_map)(void * ctx);
-
- int (* yajl_start_array)(void * ctx);
- int (* yajl_end_array)(void * ctx);
- } yajl_callbacks;
-
- /** configuration structure for the generator */
- typedef struct {
- /** if nonzero, javascript style comments will be allowed in
- * the json input, both slash star and slash slash */
- unsigned int allowComments;
- /** if nonzero, invalid UTF8 strings will cause a parse
- * error */
- unsigned int checkUTF8;
- } yajl_parser_config;
-
- /** allocate a parser handle
- * \param callbacks a yajl callbacks structure specifying the
- * functions to call when different JSON entities
- * are encountered in the input text. May be NULL,
- * which is only useful for validation.
- * \param config configuration parameters for the parse.
- * \param ctx a context pointer that will be passed to callbacks.
- */
- yajl_handle YAJL_API yajl_alloc(const yajl_callbacks * callbacks,
- const yajl_parser_config * config,
- const yajl_alloc_funcs * allocFuncs,
- void * ctx);
-
- /** free a parser handle */
- void YAJL_API yajl_free(yajl_handle handle);
-
- /** Parse some json!
- * \param hand - a handle to the json parser allocated with yajl_alloc
- * \param jsonText - a pointer to the UTF8 json text to be parsed
- * \param jsonTextLength - the length, in bytes, of input text
- */
- yajl_status YAJL_API yajl_parse(yajl_handle hand,
- const unsigned char * jsonText,
- unsigned int jsonTextLength);
-
- /** Parse any remaining buffered json.
- * Since yajl is a stream-based parser, without an explicit end of
- * input, yajl sometimes can't decide if content at the end of the
- * stream is valid or not. For example, if "1" has been fed in,
- * yajl can't know whether another digit is next or some character
- * that would terminate the integer token.
- *
- * \param hand - a handle to the json parser allocated with yajl_alloc
- */
- yajl_status yajl_parse_complete(yajl_handle hand);
-
- /** get an error string describing the state of the
- * parse.
- *
- * If verbose is non-zero, the message will include the JSON
- * text where the error occured, along with an arrow pointing to
- * the specific char.
- *
- * A dynamically allocated string will be returned which should
- * be freed with yajl_free_error
- */
- unsigned char * YAJL_API yajl_get_error(yajl_handle hand, int verbose,
- const unsigned char * jsonText,
- unsigned int jsonTextLength);
-
- /** free an error returned from yajl_get_error */
- void YAJL_API yajl_free_error(yajl_handle hand, unsigned char * str);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
#include <Moof/Octree.hh>
#include <Moof/Script.hh>
#include <Moof/Settings.hh>
-#include <Moof/Tilemap.hh>
#include "Scene.hh"
+#include "Tilemap.hh"
struct Scene::Impl : public Mf::Mippleton<Impl>
Mf::Scalar vertices_[12];
Mf::Scalar texCoords_[8];
- Mf::Tilemap tilemap_;
+ Tilemap tilemap_;
bool blending_;
bool fog_;
};
Quad(const Mf::Vector3 vertices[4], const std::string& texture,
- Mf::Tilemap::Index tileIndex) :
+ Tilemap::Index tileIndex) :
tilemap_(texture),
blending_(false),
fog_(false)
- Mf::Script script;
-
Mf::Matrix4 transform;
std::string texture;
explicit Impl(const std::string& name) :
Mf::Mippleton<Impl>(name)
{
- script.importStandardLibraries();
- importLogScript(script);
-
- importSceneBindings(script);
loadFromFile();
}
void loadFromFile()
{
+ Mf::Script script;
std::string filePath = Scene::getPath(getName());
+ script.importStandardLibraries();
+ importLogScript(script);
+ importSceneBindings(script);
+
if (script.doFile(filePath) != Mf::Script::SUCCESS)
{
std::string str;
if (nTiles % width != 0) table.throwError("invalid number of tiles");
- std::vector< std::vector<Mf::Tilemap::Index> > indices;
+ std::vector< std::vector<Tilemap::Index> > indices;
int i, w, h;
i = 1;
for (h = height - 1; h >= 0; --h)
{
- std::vector<Mf::Tilemap::Index> row;
+ std::vector<Tilemap::Index> row;
for (w = 0; w < width; ++w, ++i)
{
script.push(long(i));
tiles.pushField();
- long index;
+ Tilemap::Index index;
top.get(index);
- row.push_back(Mf::Tilemap::Index(index));
+ row.push_back(index);
}
indices[h] = row;
{
for (int w = 0; w <= width; ++w)
{
- vertices[h][w] = Mf::Vector4(Mf::Scalar(w), Mf::Scalar(h), 0.0, 1.0) *
- transposedTransform;
+ vertices[h][w] = Mf::Vector4(w, h, 0.0, 1.0) * transposedTransform;
}
}
{
for (int w = 0; w < width; ++w)
{
- if (indices[h][w] == Mf::Tilemap::NO_TILE) continue;
+ if (indices[h][w] == Tilemap::NO_TILE) continue;
Mf::Vector3 quadVertices[4];
quadVertices[2] = Mf::demote(vertices[1][w+1]);
quadVertices[3] = Mf::demote(vertices[1][w]);
- Quad* quad = new Quad(quadVertices, texture, Mf::Tilemap::Index(index));
+ Quad* quad = new Quad(quadVertices, texture, Tilemap::Index(index));
quad->setBlending(blending);
quad->setFog(fog);
--- /dev/null
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * 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.
+
+ 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 HOLDER 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 <Moof/Mippleton.hh>
+#include <Moof/OpenGL.hh>
+#include <Moof/Script.hh>
+
+#include "Tilemap.hh"
+
+
+struct Tilemap::Impl : public Mf::Mippleton<Impl>
+{
+ Impl(const std::string& name) :
+ Mf::Mippleton<Impl>(name),
+ magFilter_(GL_NEAREST),
+ minFilter_(GL_NEAREST),
+ nTilesS_(1),
+ nTilesT_(1),
+ wrapS_(GL_CLAMP),
+ wrapT_(GL_CLAMP)
+ {
+ loadFromFile();
+ }
+
+
+ static void bindScriptConstants(Mf::Script& script)
+ {
+ script.push(GL_CLAMP); script.set("CLAMP");
+ script.push(GL_REPEAT); script.set("REPEAT");
+ script.push(GL_LINEAR); script.set("LINEAR");
+ script.push(GL_NEAREST); script.set("NEAREST");
+ script.push(GL_LINEAR_MIPMAP_LINEAR); script.set("LINEAR_MIPMAP_LINEAR");
+ script.push(GL_LINEAR_MIPMAP_NEAREST); script.set("LINEAR_MIPMAP_NEAREST");
+ script.push(GL_NEAREST_MIPMAP_LINEAR); script.set("NEAREST_MIPMAP_LINEAR");
+ script.push(GL_NEAREST_MIPMAP_NEAREST); script.set("NEAREST_MIPMAP_NEAREST");
+ }
+
+ void loadFromFile()
+ {
+ Mf::Script script;
+ std::string filePath = Tilemap::getPath(getName());
+
+ script.importStandardLibraries();
+ importLogScript(script);
+ bindScriptConstants(script);
+
+ if (script.doFile(filePath) != Mf::Script::SUCCESS)
+ {
+ std::string str;
+ script[-1].get(str);
+ Mf::logScript("%s", str.c_str());
+ return; // TODO needs a better exit strategy
+ }
+
+ Mf::logInfo("loading tiles from tilemap %s", filePath.c_str());
+
+ Mf::Script::Value globals = script.getGlobalTable();
+ Mf::Script::Value top = script[-1];
+
+ globals.pushField("tiles_s");
+ top.get(nTilesS_);
+
+ globals.pushField("tiles_t");
+ top.get(nTilesT_);
+
+ globals.pushField("min_filter");
+ top.get(minFilter_);
+
+ globals.pushField("mag_filter");
+ top.get(magFilter_);
+
+ globals.pushField("wrap_s");
+ top.get(wrapS_);
+
+ globals.pushField("wrap_t");
+ top.get(wrapT_);
+ }
+
+
+ bool getTileCoords(Tilemap::Index index, Mf::Scalar coords[8]) const
+ {
+ // make sure the index represents a real tile
+ if (index >= nTilesS_ * nTilesT_) return false;
+
+ Mf::Scalar w = 1.0 / Mf::Scalar(nTilesS_);
+ Mf::Scalar h = 1.0 / Mf::Scalar(nTilesT_);
+
+ coords[0] = Mf::Scalar(index % nTilesS_) * w;
+ coords[1] = (Mf::Scalar(nTilesT_ - 1) -
+ Mf::Scalar(index / nTilesS_)) * h;
+ coords[2] = coords[0] + w;
+ coords[3] = coords[1];
+ coords[4] = coords[2];
+ coords[5] = coords[1] + h;
+ coords[6] = coords[0];
+ coords[7] = coords[5];
+
+ return true;
+ }
+
+
+ GLuint magFilter_;
+ GLuint minFilter_;
+ unsigned nTilesS_;
+ unsigned nTilesT_;
+ GLuint wrapS_;
+ GLuint wrapT_;
+};
+
+
+Tilemap::Tilemap(const std::string& name) :
+ Texture(name),
+ impl_(Tilemap::Impl::getInstance(name))
+{
+ setMinFilter(impl_->minFilter_);
+ setMagFilter(impl_->magFilter_);
+ setWrapS(impl_->wrapS_);
+ setWrapT(impl_->wrapT_);
+}
+
+
+bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8]) const
+{
+ // pass through
+ return impl_->getTileCoords(index, coords);
+}
+
+bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8],
+ Orientation orientation) const
+{
+ if (getTileCoords(index, coords))
+ {
+ if (orientation & FLIP)
+ {
+ // this looks kinda weird, but it's just swapping in a way that
+ // doesn't require an intermediate variable
+ coords[1] = coords[5];
+ coords[5] = coords[3];
+ coords[3] = coords[7];
+ coords[7] = coords[5];
+ }
+ if (orientation & REVERSE)
+ {
+ coords[0] = coords[2];
+ coords[2] = coords[6];
+ coords[4] = coords[6];
+ coords[6] = coords[0];
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+
+std::string Tilemap::getPath(const std::string& name)
+{
+ return Resource::getPath("tilemaps/" + name + ".lua");
+}
+
+
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
*******************************************************************************/
-#ifndef _MOOF_TILEMAP_HH_
-#define _MOOF_TILEMAP_HH_
+#ifndef _TILEMAP_HH_
+#define _TILEMAP_HH_
/**
* @file Tilemap.hh
#include <Moof/Texture.hh>
-namespace Mf {
-
-
/**
* A tilemap is a texture which is meant to be divided into smaller sprites.
* This class provides all the functionality of a texture and adds some methods
* simplicity, this class assumes square tiles.
*/
-class Tilemap : public Texture
+class Tilemap : public Mf::Texture
{
public:
/**
* @return True if index is valid, false otherwise.
*/
- bool getTileCoords(Index index, Scalar coords[8]) const;
+ bool getTileCoords(Index index, Mf::Scalar coords[8]) const;
/**
* @return True if index is valid, false otherwise.
*/
- bool getTileCoords(Index index, Scalar coords[8], Orientation what) const;
+ bool getTileCoords(Index index, Mf::Scalar coords[8], Orientation what) const;
static std::string getPath(const std::string& name);
};
-} // namespace Mf
-
-#endif // _MOOF_TILEMAP_HH_
+#endif // _TILEMAP_HH_
/** vim: set ts=4 sw=4 tw=80: *************************************************/
TilemapFont::TilemapFont() :
- Mf::Tilemap("Font") {}
+ Tilemap("Font") {}
void TilemapFont::getTileCoords(char symbol, Mf::Scalar coords[8],
- Mf::Tilemap::Orientation what)
+ Tilemap::Orientation what)
{
- Mf::Tilemap::Index index = 0;
+ Tilemap::Index index = 0;
if (symbol >= ' ' && symbol <= '_')
{
index = 0;
}
- Mf::Tilemap::getTileCoords(index, coords, what);
+ Tilemap::getTileCoords(index, coords, what);
}
* Text on the screen.
*/
-#include <Moof/Tilemap.hh>
+#include "Tilemap.hh"
-class TilemapFont : public Mf::Tilemap
+class TilemapFont : public Tilemap
{
public:
TilemapFont();
void getTileCoords(char symbol, Mf::Scalar coords[8],
- Mf::Tilemap::Orientation what = Mf::Tilemap::NORMAL);
+ Tilemap::Orientation what = Tilemap::NORMAL);
};