File: json.cpp

package info (click to toggle)
falconpl 0.9.6.9-git20120606-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 46,176 kB
  • sloc: cpp: 181,389; ansic: 109,025; yacc: 2,310; xml: 1,218; sh: 403; objc: 245; makefile: 82; sql: 20
file content (87 lines) | stat: -rw-r--r-- 2,297 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
   FALCON - The Falcon Programming Language
   FILE: json.cpp

   JSON module main file
   -------------------------------------------------------------------
   Author: Giancarlo Niccolai
   Begin: Sat, 06 Sep 2008 09:48:38 +0200

   -------------------------------------------------------------------
   (C) Copyright 2009: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/


/*#
   @module feathers.json JSON support
   @brief JavaScript Object Notation interface.

   This module exposes functions to dump and load variables
   encoded in JSON format. See @link http://json.org for more details.

   The module is meant to be included in a namespace (for example, json);
   it's not advisable to load it via load. Instead, use the import
   directive as in the following example:

   @code
      import from json
      > json.JSONencode( ["a", 1, 1.2] )
   @endcode
*/

/*#
   @beginmodule feathers.json
*/

#include <falcon/module.h>
#include <falcon/srv/json_srv.h>
#include "json_ext.h"
#include "json_st.h"

#include "version.h"
#include <stdio.h>

static Falcon::JSONService s_theJSONService;

FALCON_MODULE_DECL
{
   #define FALCON_DECLARE_MODULE self

   Falcon::Module *self = new Falcon::Module();
   self->name( "json" );
   self->language( "en_US" );
   self->engineVersion( FALCON_VERSION_NUM );
   self->version( VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION );

   //====================================
   // Message setting
   #include "json_st.h"

   self->addExtFunc( "JSONencode", &Falcon::Ext::JSONencode )->
      addParam("item")->addParam("stream")->addParam( "pretty" )->addParam( "readable" );


   self->addExtFunc( "JSONdecode", &Falcon::Ext::JSONdecode )->
      addParam("source");

   //======================================
   // The error class
   //
   Falcon::Symbol *error_class = self->addExternalRef( "Error" ); // it's external
   Falcon::Symbol *jerr_cls = self->addClass( "JSONError", &Falcon::Ext::JSONError_init );
   jerr_cls->setWKS( true );
   jerr_cls->getClassDef()->addInheritance(  new Falcon::InheritDef( error_class ) );

   //======================================
   // Publish the service
   //
   self->publishService( &s_theJSONService );

   return self;
}


/* end of funcext.cpp */