2012-01-06 13:07:23 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-02-12 17:30:49 +01:00
|
|
|
* Copyright (c) 2012-2014, Tomasz Sowa
|
2012-01-06 13:07:23 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2012-01-06 13:07:23 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "core/request.h"
|
|
|
|
#include "core/misc.h"
|
|
|
|
#include "functions/functions.h"
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
2012-01-06 13:07:23 +01:00
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
|
|
|
static Functions::Iterator winixfun_iter;
|
2012-01-06 13:55:08 +01:00
|
|
|
static size_t winixfun_curreq = 0;
|
2012-02-27 18:43:59 +01:00
|
|
|
static Ezc::Stack * winixstack = &empty_stack;
|
2012-01-06 13:55:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool man_winixfun_tabcheck()
|
|
|
|
{
|
|
|
|
if( winixfun_curreq != cur->request->id )
|
|
|
|
{
|
|
|
|
winixfun_curreq = cur->request->id;
|
|
|
|
winixfun_iter = functions->Begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
return winixfun_iter != functions->End();
|
|
|
|
}
|
2012-01-06 13:07:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
void man_winixfun_tab(Info & i)
|
|
|
|
{
|
2012-01-06 13:55:08 +01:00
|
|
|
man_winixfun_tabcheck();
|
2014-10-18 20:12:04 +02:00
|
|
|
winixstack = &i.stack;
|
2012-01-06 13:55:08 +01:00
|
|
|
|
2012-01-06 13:07:23 +01:00
|
|
|
if( i.iter == 0 )
|
|
|
|
winixfun_iter = functions->Begin();
|
|
|
|
else
|
|
|
|
if( winixfun_iter != functions->End() )
|
|
|
|
++winixfun_iter;
|
2012-01-06 13:55:08 +01:00
|
|
|
|
|
|
|
i.res = winixfun_iter != functions->End();
|
2012-01-06 13:07:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void man_winixfun_tab_index(Info & i)
|
|
|
|
{
|
2012-02-27 18:43:59 +01:00
|
|
|
i.out << (winixstack->iter + 1);
|
2012-01-06 13:07:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void man_winixfun_tab_name(Info & i)
|
|
|
|
{
|
2012-01-06 13:55:08 +01:00
|
|
|
if( man_winixfun_tabcheck() )
|
2012-01-06 13:07:23 +01:00
|
|
|
i.out << winixfun_iter->first;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-06 13:55:08 +01:00
|
|
|
|
|
|
|
|
2012-01-06 13:07:23 +01:00
|
|
|
static EzcFun::Iterator ezcfun_iter;
|
2012-01-06 13:55:08 +01:00
|
|
|
static size_t ezcfun_curreq = 0;
|
2012-02-27 18:43:59 +01:00
|
|
|
static Ezc::Stack * ezcstack = &empty_stack;
|
2012-01-06 13:07:23 +01:00
|
|
|
|
|
|
|
|
2012-01-06 13:55:08 +01:00
|
|
|
bool man_ezcfun_tabcheck()
|
|
|
|
{
|
|
|
|
if( ezcfun_curreq != cur->request->id )
|
|
|
|
{
|
|
|
|
ezcfun_curreq = cur->request->id;
|
|
|
|
ezcfun_iter = ezc_functions.Begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ezcfun_iter != ezc_functions.End();
|
|
|
|
}
|
|
|
|
|
2012-01-06 13:07:23 +01:00
|
|
|
|
|
|
|
void man_ezcfun_tab(Info & i)
|
|
|
|
{
|
2012-01-06 13:55:08 +01:00
|
|
|
man_ezcfun_tabcheck();
|
2014-10-18 20:12:04 +02:00
|
|
|
ezcstack = &i.stack;
|
2012-01-06 13:55:08 +01:00
|
|
|
|
2012-01-06 13:07:23 +01:00
|
|
|
if( i.iter == 0 )
|
|
|
|
ezcfun_iter = ezc_functions.Begin();
|
|
|
|
else
|
|
|
|
if( ezcfun_iter != ezc_functions.End() )
|
|
|
|
++ezcfun_iter;
|
|
|
|
|
2012-01-06 13:55:08 +01:00
|
|
|
i.res = ezcfun_iter != ezc_functions.End();
|
2012-01-06 13:07:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void man_ezcfun_tab_index(Info & i)
|
|
|
|
{
|
2012-02-27 18:43:59 +01:00
|
|
|
i.out << (ezcstack->iter + 1);
|
2012-01-06 13:07:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void man_ezcfun_tab_name(Info & i)
|
|
|
|
{
|
2012-01-06 13:55:08 +01:00
|
|
|
if( man_ezcfun_tabcheck() )
|
2012-01-06 13:07:23 +01:00
|
|
|
i.out << ezcfun_iter->first;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
|
|
|
|
2012-01-06 13:07:23 +01:00
|
|
|
|
|
|
|
|