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 88 89 90 91 92
|
/*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "grts/structs.wrapper.h"
#include "parser_ContextReference_impl.h"
using namespace parser;
//--------------------------------------------------------------------------------------------------
class parser_ContextReference::ImplData
{
public:
parser::ParserContext::Ref _ref;
ImplData(const ParserContext::Ref &ref)
{
_ref = ref;
}
};
//--------------------------------------------------------------------------------------------------
parser_ContextReference::~parser_ContextReference()
{
delete _data;
}
//--------------------------------------------------------------------------------------------------
void parser_ContextReference::init()
{
// Nothing to do. Use the reference only via parser_context_to_grt().
}
//--------------------------------------------------------------------------------------------------
grt::IntegerRef parser_ContextReference::valid() const
{
if (_data)
return grt::IntegerRef(1);
else
return grt::IntegerRef(0);
}
//--------------------------------------------------------------------------------------------------
void parser_ContextReference::set_data(ImplData *data)
{
_data = data;
}
//--------------------------------------------------------------------------------------------------
ParserContext::Ref parser_context_from_grt(parser_ContextReferenceRef object)
{
if (!object.is_valid() || !*object->valid())
return ParserContext::Ref();
return object->get_data()->_ref;
}
//--------------------------------------------------------------------------------------------------
parser_ContextReferenceRef parser_context_to_grt(grt::GRT *grt, const ParserContext::Ref &context)
{
if (context != NULL)
{
parser_ContextReferenceRef ref(grt);
parser_ContextReference::ImplData *data = new parser_ContextReference::ImplData(context);
ref->set_data(data);
return ref;
}
return parser_ContextReferenceRef();
}
//--------------------------------------------------------------------------------------------------
|