File:  [parser3project] / parser3 / src / classes / bool.C
Revision 1.11: download - view: text, annotated - select for diffs - revision graph
Tue Dec 15 17:10:27 2020 UTC (5 years, 11 months ago) by moko
Branches: MAIN
CVS tags: release_3_4_6, HEAD
Copyright year updated

/** @file
	Parser: @b int parser class.

	Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com)
	Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
*/

#include "classes.h"
#include "pa_vmethod_frame.h"

#include "pa_request.h"
#include "pa_vdouble.h"
#include "pa_vint.h"
#include "pa_vbool.h"

volatile const char * IDENT_BOOL_C="$Id: bool.C,v 1.11 2020/12/15 17:10:27 moko Exp $" IDENT_PA_VBOOL_H;

// externs

void _string_format(Request& r, MethodParams&);

// class

class MBool: public Methoded {
public:
	MBool();
};

// global variable

DECLARE_CLASS_VAR(bool, new MBool);

// methods

static void _int(Request& r, MethodParams&) {
	VBool& vbool=GET_SELF(r, VBool);
	r.write(*new VInt(vbool.as_bool()));
}

static void _double(Request& r, MethodParams&) {
	VBool& vbool=GET_SELF(r, VBool);
	r.write(*new VDouble(vbool.as_bool()));
}

static void _bool(Request& r, MethodParams&) {
	r.write(GET_SELF(r, VBool));
}

// constructor

MBool::MBool(): Methoded("bool") {
	// ^bool.int[]
	// ^bool.int[default for ^string.int compatibility]
	add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1);
	// ^bool.double[]
	// ^bool.double[default for ^string.double compatibility]
	add_native_method("double", Method::CT_DYNAMIC, _double, 0, 1);
	// ^bool.bool[]
	// ^bool.bool[default for ^string.bool compatibility]
	add_native_method("bool", Method::CT_DYNAMIC, _bool, 0, 1);
}

E-mail: