LCOV - code coverage report
Current view: top level - lib - version.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 3 100.0 %
Date: 2014-11-22 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* version.cpp -- written by Alexis WILKE for Made to Order Software Corp. (c) 2005-2014 */
       2             : 
       3             : /*
       4             : 
       5             : Copyright (c) 2005-2014 Made to Order Software Corp.
       6             : 
       7             : http://snapwebsites.org/project/as2js
       8             : 
       9             : Permission is hereby granted, free of charge, to any
      10             : person obtaining a copy of this software and
      11             : associated documentation files (the "Software"), to
      12             : deal in the Software without restriction, including
      13             : without limitation the rights to use, copy, modify,
      14             : merge, publish, distribute, sublicense, and/or sell
      15             : copies of the Software, and to permit persons to whom
      16             : the Software is furnished to do so, subject to the
      17             : following conditions:
      18             : 
      19             : The above copyright notice and this permission notice
      20             : shall be included in all copies or substantial
      21             : portions of the Software.
      22             : 
      23             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
      24             : ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
      25             : LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
      26             : FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
      27             : EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
      28             : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      29             : WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      30             : ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      31             : SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      32             : SOFTWARE.
      33             : 
      34             : */
      35             : 
      36             : #include    "as2js/as2js.h"
      37             : 
      38             : #include    <iostream>
      39             : 
      40             : /** \file
      41             :  * \brief Define the version of the as2js library.
      42             :  *
      43             :  * This file implements the function used to retrieve the library
      44             :  * version at runtime. This can be used to compare with the version
      45             :  * used to compile the library. If the first or second numbers have
      46             :  * changed, then the library may not be compatible. The third number
      47             :  * can change and it should not be a problem as only internals would
      48             :  * have changed in that case.
      49             :  *
      50             :  * It should always be safe to use this version function, even when
      51             :  * the library changes drastically.
      52             :  */
      53             : 
      54             : 
      55             : /** \mainpage
      56             :  *
      57             :  * The idea of creating the as2js project was born from the time I worked
      58             :  * on my ActionScript compiler for my sswf project, a library to create
      59             :  * Flash animations.
      60             :  *
      61             :  * While working with ActionScript, I learned that it would be "easy" to
      62             :  * write a JavaScript compiler that would support classes and other
      63             :  * advance declarations that JavaScript does not support.
      64             :  *
      65             :  * Today, I am bringing this to life by working on the as2js project:
      66             :  *
      67             :  * AlexScript to JavaScript.
      68             :  *
      69             :  * So... how does it work? I have better documentation online on how to
      70             :  * use the compiler itself (the as2js command line tool.) Here I
      71             :  * mainly document the as2js library. This library can directly be used
      72             :  * by your project instead of the as2js command line tool. Hence, allowing
      73             :  * you do everything in memory!
      74             :  *
      75             :  * At time of writing, I do not have a complete compiler so I cannot
      76             :  * give a full example on how to use the library, but the as2js command
      77             :  * line tool will show you how it gets done. Also, the numerous tests
      78             :  * can be reviewed to see how things work and make use of some of that
      79             :  * code in your own project.
      80             :  *
      81             :  * The following should be close to what you'd want to do:
      82             :  *
      83             :  * \code
      84             :  *      class message_callback : public as2js::MessageCallback
      85             :  *      {
      86             :  *          virtual void output(as2js::message_level_t message_level, as2js::err_code_t error_code, as2js::Position const& pos, std::string const& message)
      87             :  *          {
      88             :  *              ... output message ...
      89             :  *          }
      90             :  *      } message_handler;
      91             :  *      as2js::Message::set_message_callback(&message_handler);
      92             :  *      as2js::FileInput in;
      93             :  *      if(in.open("script.js"))
      94             :  *      {
      95             :  *          as2js::Options::pointer_t opt(new as2js::Options);
      96             :  *          opt->set_option(as2js::Options::OPTION_STRICT, 1);
      97             :  *          as2js::Parser::pointer_t p(new as2js::Parser(in, opt));
      98             :  *          as2js::Node::pointer_t root(p->parse());
      99             :  *          if(as2js::Message::error_count() == 0)
     100             :  *          {
     101             :  *              as2js::Compiler::pointer_t c(new as2js::Compiler);
     102             :  *              c->set_options(opt);
     103             :  *              if(c->compile(root) == 0)
     104             :  *              {
     105             :  *                  ... assemble (not implemented yet) ...
     106             :  *              }
     107             :  *          }
     108             :  *      }
     109             :  * \endcode
     110             :  *
     111             :  * The result is JavaScript code that any browser is capable of running,
     112             :  * assuming your own code does not use features not available in a browser,
     113             :  * of course...
     114             :  */
     115             : 
     116             : 
     117             : 
     118             : 
     119             : /** \brief The AlexScript to JavaScript namespace.
     120             :  *
     121             :  * All the definitions from the as2js compiler are found inside this
     122             :  * namespace. There are other sub-namespaces used here and there, but
     123             :  * this is the major one.
     124             :  *
     125             :  * Of course, we use a few \#define and those are not protected with
     126             :  * a namespace. All of the \#define should start with AS2JS_ though,
     127             :  * to avoid potential conflicts.
     128             :  */
     129             : namespace as2js
     130             : {
     131             : 
     132             : /** \brief Return the library version.
     133             :  *
     134             :  * This function can be used to get the current version of the as2js
     135             :  * library. It returns a string of the form:
     136             :  *
     137             :  * \code
     138             :  * <major>.<minor>.<release>
     139             :  * \endcode
     140             :  *
     141             :  * where each entry is a number (only numerics are used.)
     142             :  *
     143             :  * Note that this is different from using the AS2JS_VERSION macro
     144             :  * (defined in as2js.h) in that the macro defines the version you
     145             :  * are compiling against and not automatically the version that
     146             :  * your code will run against.
     147             :  *
     148             :  * \todo
     149             :  * Add another function that checks whether your code is compatible
     150             :  * with this library.
     151             :  *
     152             :  * \return The version of the loaded library.
     153             :  */
     154           1 : char const *as2js_library_version()
     155             : {
     156           1 :         return AS2JS_VERSION;
     157             : }
     158             : 
     159             : 
     160          63 : }
     161             : // namespace as2js
     162             : 
     163             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.10