<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: idlctypes.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-07 18:04:36 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _IDLC_IDLCTYPES_HXX_
#define _IDLC_IDLCTYPES_HXX_

#include <stdio.h>

#include <hash_map>
#include <list>
#include <vector>
#include <set>

#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif

struct EqualString
{
    sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
    {
        return (str1 == str2);
    }
};

struct HashString
{
    sal_Int32 operator()(const ::rtl::OString& str) const
    {
        return str.hashCode();
    }
};

struct LessString
{
    sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
    {
        return (str1 < str2);
    }
};

typedef ::std::list< ::rtl::OString >               StringList;
typedef ::std::vector< ::rtl::OString >             StringVector;
typedef ::std::set< ::rtl::OString, LessString >    StringSet;

class AstExpression;
typedef ::std::list< AstExpression* >   ExprList;

class AstUnionLabel;
typedef ::std::list< AstUnionLabel* >   LabelList;

class AstDeclaration;

typedef ::std::hash_map< ::rtl::OString, AstDeclaration*, HashString, EqualString > DeclMap;
typedef ::std::list< AstDeclaration* > DeclList;

class AstScope;
AstDeclaration* SAL_CALL scopeAsDecl(AstScope* pScope);
AstScope* SAL_CALL declAsScope(AstDeclaration* pDecl);

#ifdef WIN32
#pragma warning( disable : 4541 )
#endif

// flags used for attributes, properties and services
#define AF_INVALID          0x0000
#define AF_READONLY         0x0001
#define AF_OPTIONAL         0x0002
#define AF_MAYBEVOID        0x0004
#define AF_BOUND            0x0008
#define AF_CONSTRAINED      0x0010
#define AF_TRANSIENT        0x0020
#define AF_MAYBEAMBIGUOUS   0x0040
#define AF_MAYBEDEFAULT     0x0080
#define AF_REMOVEABLE       0x0100
#define AF_ATTRIBUTE        0x0200
#define AF_PROPERTY         0x0400

enum ParseState
{
    PS_NoState,
    PS_TypeDeclSeen,        // Seen complete typedef declaration
    PS_ConstantDeclSeen,    // Seen complete const declaration
    PS_ExceptionDeclSeen,   // Seen complete exception declaration
    PS_InterfaceDeclSeen,   // Seen complete interface declaration
    PS_ServiceDeclSeen,     // Seen complete service declaration
    PS_SingletonDeclSeen,   // Seen complete singleton declaration
    PS_ModuleDeclSeen,      // Seen complete module declaration
    PS_AttributeDeclSeen,   // Seen complete attribute declaration
    PS_PropertyDeclSeen,    // Seen complete property declaration
    PS_OperationDeclSeen,   // Seen complete operation declaration
    PS_InterfaceInheritanceDeclSeen, // Seen complete interface inheritance decl
    PS_ConstantsDeclSeen,   // Seen complete constants declaration

    PS_ServiceSeen,         // Seen a SERVICE keyword
    PS_ServiceIDSeen,       // Seen the service ID
    PS_ServiceSqSeen,       // '{' seen for service
    PS_ServiceQsSeen,       // '}' seen for service
    PS_ServiceBodySeen,     // Seen complete service body
    PS_ServiceMemberSeen,   // Seen a service member
    PS_ServiceIFHeadSeen,   // Seen an interface member header
    PS_ServiceSHeadSeen,    // Seen an service member header

    PS_SingletonSeen,       // Seen a SINGLETON keyword
    PS_SingletonIDSeen,     // Seen the singleton ID
    PS_SingletonSqSeen,     // '{' seen for singleton
    PS_SingletonQsSeen,     // '}' seen for singleton
    PS_SingletonBodySeen,   // Seen complete singleton body
    PS_SingletonMemberSeen, // Seen a singleton member

    PS_ModuleSeen,          // Seen a MODULE keyword
    PS_ModuleIDSeen,        // Seen the module ID
    PS_ModuleSqSeen,        // '{' seen for module
    PS_ModuleQsSeen,        // '}' seen for module
    PS_ModuleBodySeen,      // Seen complete module body

    PS_ConstantsSeen,       // Seen a CONSTANTS keyword
    PS_ConstantsIDSeen,     // Seen the constants ID
    PS_ConstantsSqSeen,     // '{' seen for constants
    PS_ConstantsQsSeen,     // '}' seen for constants
    PS_ConstantsBodySeen,   // Seen complete constants body

    PS_InterfaceSeen,       // Seen an INTERFACE keyword
    PS_InterfaceIDSeen,     // Seen the interface ID
    PS_InterfaceHeadSeen,   // Seen the interface head
    PS_InheritSpecSeen,     // Seen a complete inheritance spec
    PS_ForwardDeclSeen,     // Forward interface decl seen
    PS_InterfaceSqSeen,     // '{' seen for interface
    PS_InterfaceQsSeen,     // '}' seen for interface
    PS_InterfaceBodySeen,   // Seen an interface body
    PS_InheritColonSeen,    // Seen ':' in inheritance list

    PS_SNListCommaSeen,     // Seen ',' in list of scoped names
    PS_ScopedNameSeen,      // Seen a complete scoped name
    PS_SN_IDSeen,           // Seen an identifier as part of a scoped name
    PS_ScopeDelimSeen,      // Seen a scope delim as party of a scoped name

    PS_ConstSeen,           // Seen a CONST keyword
    PS_ConstTypeSeen,       // Parsed the type of a constant
    PS_ConstIDSeen,         // Seen the constant ID
    PS_ConstAssignSeen,     // Seen the '='
    PS_ConstExprSeen,       // Seen the constant value expression

    PS_TypedefSeen,         // Seen a TYPEDEF keyword
    PS_TypeSpecSeen,        // Seen a complete type specification
    PS_DeclaratorsSeen,     // Seen a complete list of declarators

    PS_StructSeen,          // Seen a STRUCT keyword
    PS_StructHeaderSeen,    // Seen struct header
    PS_StructIDSeen,        // Seen the struct ID
    PS_StructSqSeen,        // '{' seen for struct
    PS_StructQsSeen,        // '}' seen for struct
    PS_StructBodySeen,      // Seen complete body of struct decl

    PS_MemberTypeSeen,      // Seen type of struct or except member
    PS_MemberDeclsSeen,     // Seen decls of struct or except members
    PS_MemberDeclsCompleted,// Completed one struct or except member to ';'

    PS_UnionSeen,           // Seen a UNION keyword
    PS_UnionIDSeen,         // Seen the union ID
    PS_SwitchSeen,          // Seen the SWITCH keyword
    PS_SwitchOpenParSeen,   // Seen the switch open par.
    PS_SwitchTypeSeen,      // Seen the switch type spec
    PS_SwitchCloseParSeen,  // Seen the switch close par.
    PS_UnionSqSeen,         // '{' seen for union
    PS_UnionQsSeen,         // '}' seen for union
    PS_DefaultSeen,         // Seen DEFAULT keyword
    PS_UnionLabelSeen,      // Seen label of union element
    PS_LabelColonSeen,      // Seen ':' of union branch label
    PS_LabelExprSeen,       // Seen expression of union branch label
    PS_UnionElemSeen,       // Seen a union element
    PS_UnionElemCompleted,  // Completed one union member up to ';'
    PS_CaseSeen,            // Seen a CASE keyword
    PS_UnionElemTypeSeen,   // Seen type spec for union element
    PS_UnionElemDeclSeen,   // Seen declarator for union element
    PS_UnionBodySeen,       // Seen completed union body

    PS_EnumSeen,            // Seen an ENUM keyword
    PS_EnumIDSeen,          // Seen the enum ID
    PS_EnumSqSeen,          // Seen '{' for enum
    PS_EnumQsSeen,          // Seen '}' for enum
    PS_EnumBodySeen,        // Seen complete enum body
    PS_EnumCommaSeen,       // Seen ',' in list of enumerators

    PS_SequenceSeen,        // Seen a SEQUENCE keyword
    PS_SequenceSqSeen,      // Seen '<' for sequence
    PS_SequenceQsSeen,      // Seen '>' for sequence
    PS_SequenceTypeSeen,    // Seen type decl for sequence

    PS_ArrayIDSeen,         // Seen array ID
    PS_ArrayTypeSeen,       // Seen array type
    PS_ArrayCompleted,      // Seen completed array declaration
    PS_DimSqSeen,           // Seen '[' for array dimension
    PS_DimQsSeen,           // Seen ']' for array dimension
    PS_DimExprSeen,         // Seen size expression for array dimension

    PS_FlagHeaderSeen,      // Seen the attribute|property|interface member head
    PS_AttrSeen,            // Seen ATTRIBUTE keyword
    PS_AttrTypeSeen,        // Seen type decl for attribute
    PS_AttrCompleted,       // Seen complete attribute declaration
    PS_ReadOnlySeen,        // Seen READONLY keyword
    PS_OptionalSeen,        // Seen OPTIONAL keyword
    PS_MayBeVoidSeen,       // Seen MAYBEVOID yword
    PS_BoundSeen,           // Seen BOUND  keyword
    PS_ConstrainedSeen,     // Seen CONSTRAINED keyword
    PS_TransientSeen,       // Seen TRANSIENT keyword
    PS_MayBeAmbigiousSeen,  // Seen MAYBEAMBIGIOUS keyword
    PS_MayBeDefaultSeen,    // Seen MAYBEDEFAULT keyword
    PS_RemoveableSeen,      // Seen REMOVEABLE keyword

    PS_PropertySeen,        // Seen PROPERTY keyword
    PS_PropertyTypeSeen,    // Seen type decl for property
    PS_PropertyCompleted,   // Seen complete property declaration

    PS_ExceptSeen,          // Seen EXCEPTION keyword
    PS_ExceptHeaderSeen,    // Seen exception header keyword
    PS_ExceptIDSeen,        // Seen exception identifier
    PS_ExceptSqSeen,        // Seen '{' for exception
    PS_ExceptQsSeen,        // Seen '}' for exception
    PS_ExceptBodySeen,      // Seen complete exception body

    PS_OpHeadSeen,          // Seen the operation head
    PS_OpTypeSeen,          // Seen operation return type
    PS_OpIDSeen,            // Seen operation ID
    PS_OpParsCompleted,     // Completed operation param list
    PS_OpCompleted,         // Completed operation statement
    PS_OpSqSeen,            // Seen '(' for operation
    PS_OpQsSeen,            // Seen ')' for operation
    PS_OpParCommaSeen,      // Seen ',' in list of op params
    PS_OpParDirSeen,        // Seen parameter direction
    PS_OpParTypeSeen,       // Seen parameter type
    PS_OpParDeclSeen,       // Seen parameter declaration
    PS_OpOnewaySeen,        // Seen ONEWAY keyword

    PS_RaiseSeen,           // Seen RAISES keyword
    PS_RaiseSqSeen,         // Seen '(' for RAISES
    PS_RaiseQsSeen,         // Seen ')' for RAISES

    PS_DeclsCommaSeen,      // Seen ',' in declarators list
    PS_DeclsDeclSeen        // Seen complete decl in decls list
};

#endif // _IDLC_IDLCTYPES_HXX_

<commit_msg>INTEGRATION: CWS mingwport06 (1.6.66); FILE MERGED 2007/08/24 13:05:14 vg 1.6.66.1: #i75499# pragma is for MSVC<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: idlctypes.hxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: kz $ $Date: 2007-09-06 13:44:53 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _IDLC_IDLCTYPES_HXX_
#define _IDLC_IDLCTYPES_HXX_

#include <stdio.h>

#include <hash_map>
#include <list>
#include <vector>
#include <set>

#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif

struct EqualString
{
    sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
    {
        return (str1 == str2);
    }
};

struct HashString
{
    sal_Int32 operator()(const ::rtl::OString& str) const
    {
        return str.hashCode();
    }
};

struct LessString
{
    sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
    {
        return (str1 < str2);
    }
};

typedef ::std::list< ::rtl::OString >               StringList;
typedef ::std::vector< ::rtl::OString >             StringVector;
typedef ::std::set< ::rtl::OString, LessString >    StringSet;

class AstExpression;
typedef ::std::list< AstExpression* >   ExprList;

class AstUnionLabel;
typedef ::std::list< AstUnionLabel* >   LabelList;

class AstDeclaration;

typedef ::std::hash_map< ::rtl::OString, AstDeclaration*, HashString, EqualString > DeclMap;
typedef ::std::list< AstDeclaration* > DeclList;

class AstScope;
AstDeclaration* SAL_CALL scopeAsDecl(AstScope* pScope);
AstScope* SAL_CALL declAsScope(AstDeclaration* pDecl);

#ifdef _MSC_VER
#pragma warning( disable : 4541 )
#endif

// flags used for attributes, properties and services
#define AF_INVALID          0x0000
#define AF_READONLY         0x0001
#define AF_OPTIONAL         0x0002
#define AF_MAYBEVOID        0x0004
#define AF_BOUND            0x0008
#define AF_CONSTRAINED      0x0010
#define AF_TRANSIENT        0x0020
#define AF_MAYBEAMBIGUOUS   0x0040
#define AF_MAYBEDEFAULT     0x0080
#define AF_REMOVEABLE       0x0100
#define AF_ATTRIBUTE        0x0200
#define AF_PROPERTY         0x0400

enum ParseState
{
    PS_NoState,
    PS_TypeDeclSeen,        // Seen complete typedef declaration
    PS_ConstantDeclSeen,    // Seen complete const declaration
    PS_ExceptionDeclSeen,   // Seen complete exception declaration
    PS_InterfaceDeclSeen,   // Seen complete interface declaration
    PS_ServiceDeclSeen,     // Seen complete service declaration
    PS_SingletonDeclSeen,   // Seen complete singleton declaration
    PS_ModuleDeclSeen,      // Seen complete module declaration
    PS_AttributeDeclSeen,   // Seen complete attribute declaration
    PS_PropertyDeclSeen,    // Seen complete property declaration
    PS_OperationDeclSeen,   // Seen complete operation declaration
    PS_InterfaceInheritanceDeclSeen, // Seen complete interface inheritance decl
    PS_ConstantsDeclSeen,   // Seen complete constants declaration

    PS_ServiceSeen,         // Seen a SERVICE keyword
    PS_ServiceIDSeen,       // Seen the service ID
    PS_ServiceSqSeen,       // '{' seen for service
    PS_ServiceQsSeen,       // '}' seen for service
    PS_ServiceBodySeen,     // Seen complete service body
    PS_ServiceMemberSeen,   // Seen a service member
    PS_ServiceIFHeadSeen,   // Seen an interface member header
    PS_ServiceSHeadSeen,    // Seen an service member header

    PS_SingletonSeen,       // Seen a SINGLETON keyword
    PS_SingletonIDSeen,     // Seen the singleton ID
    PS_SingletonSqSeen,     // '{' seen for singleton
    PS_SingletonQsSeen,     // '}' seen for singleton
    PS_SingletonBodySeen,   // Seen complete singleton body
    PS_SingletonMemberSeen, // Seen a singleton member

    PS_ModuleSeen,          // Seen a MODULE keyword
    PS_ModuleIDSeen,        // Seen the module ID
    PS_ModuleSqSeen,        // '{' seen for module
    PS_ModuleQsSeen,        // '}' seen for module
    PS_ModuleBodySeen,      // Seen complete module body

    PS_ConstantsSeen,       // Seen a CONSTANTS keyword
    PS_ConstantsIDSeen,     // Seen the constants ID
    PS_ConstantsSqSeen,     // '{' seen for constants
    PS_ConstantsQsSeen,     // '}' seen for constants
    PS_ConstantsBodySeen,   // Seen complete constants body

    PS_InterfaceSeen,       // Seen an INTERFACE keyword
    PS_InterfaceIDSeen,     // Seen the interface ID
    PS_InterfaceHeadSeen,   // Seen the interface head
    PS_InheritSpecSeen,     // Seen a complete inheritance spec
    PS_ForwardDeclSeen,     // Forward interface decl seen
    PS_InterfaceSqSeen,     // '{' seen for interface
    PS_InterfaceQsSeen,     // '}' seen for interface
    PS_InterfaceBodySeen,   // Seen an interface body
    PS_InheritColonSeen,    // Seen ':' in inheritance list

    PS_SNListCommaSeen,     // Seen ',' in list of scoped names
    PS_ScopedNameSeen,      // Seen a complete scoped name
    PS_SN_IDSeen,           // Seen an identifier as part of a scoped name
    PS_ScopeDelimSeen,      // Seen a scope delim as party of a scoped name

    PS_ConstSeen,           // Seen a CONST keyword
    PS_ConstTypeSeen,       // Parsed the type of a constant
    PS_ConstIDSeen,         // Seen the constant ID
    PS_ConstAssignSeen,     // Seen the '='
    PS_ConstExprSeen,       // Seen the constant value expression

    PS_TypedefSeen,         // Seen a TYPEDEF keyword
    PS_TypeSpecSeen,        // Seen a complete type specification
    PS_DeclaratorsSeen,     // Seen a complete list of declarators

    PS_StructSeen,          // Seen a STRUCT keyword
    PS_StructHeaderSeen,    // Seen struct header
    PS_StructIDSeen,        // Seen the struct ID
    PS_StructSqSeen,        // '{' seen for struct
    PS_StructQsSeen,        // '}' seen for struct
    PS_StructBodySeen,      // Seen complete body of struct decl

    PS_MemberTypeSeen,      // Seen type of struct or except member
    PS_MemberDeclsSeen,     // Seen decls of struct or except members
    PS_MemberDeclsCompleted,// Completed one struct or except member to ';'

    PS_UnionSeen,           // Seen a UNION keyword
    PS_UnionIDSeen,         // Seen the union ID
    PS_SwitchSeen,          // Seen the SWITCH keyword
    PS_SwitchOpenParSeen,   // Seen the switch open par.
    PS_SwitchTypeSeen,      // Seen the switch type spec
    PS_SwitchCloseParSeen,  // Seen the switch close par.
    PS_UnionSqSeen,         // '{' seen for union
    PS_UnionQsSeen,         // '}' seen for union
    PS_DefaultSeen,         // Seen DEFAULT keyword
    PS_UnionLabelSeen,      // Seen label of union element
    PS_LabelColonSeen,      // Seen ':' of union branch label
    PS_LabelExprSeen,       // Seen expression of union branch label
    PS_UnionElemSeen,       // Seen a union element
    PS_UnionElemCompleted,  // Completed one union member up to ';'
    PS_CaseSeen,            // Seen a CASE keyword
    PS_UnionElemTypeSeen,   // Seen type spec for union element
    PS_UnionElemDeclSeen,   // Seen declarator for union element
    PS_UnionBodySeen,       // Seen completed union body

    PS_EnumSeen,            // Seen an ENUM keyword
    PS_EnumIDSeen,          // Seen the enum ID
    PS_EnumSqSeen,          // Seen '{' for enum
    PS_EnumQsSeen,          // Seen '}' for enum
    PS_EnumBodySeen,        // Seen complete enum body
    PS_EnumCommaSeen,       // Seen ',' in list of enumerators

    PS_SequenceSeen,        // Seen a SEQUENCE keyword
    PS_SequenceSqSeen,      // Seen '<' for sequence
    PS_SequenceQsSeen,      // Seen '>' for sequence
    PS_SequenceTypeSeen,    // Seen type decl for sequence

    PS_ArrayIDSeen,         // Seen array ID
    PS_ArrayTypeSeen,       // Seen array type
    PS_ArrayCompleted,      // Seen completed array declaration
    PS_DimSqSeen,           // Seen '[' for array dimension
    PS_DimQsSeen,           // Seen ']' for array dimension
    PS_DimExprSeen,         // Seen size expression for array dimension

    PS_FlagHeaderSeen,      // Seen the attribute|property|interface member head
    PS_AttrSeen,            // Seen ATTRIBUTE keyword
    PS_AttrTypeSeen,        // Seen type decl for attribute
    PS_AttrCompleted,       // Seen complete attribute declaration
    PS_ReadOnlySeen,        // Seen READONLY keyword
    PS_OptionalSeen,        // Seen OPTIONAL keyword
    PS_MayBeVoidSeen,       // Seen MAYBEVOID yword
    PS_BoundSeen,           // Seen BOUND  keyword
    PS_ConstrainedSeen,     // Seen CONSTRAINED keyword
    PS_TransientSeen,       // Seen TRANSIENT keyword
    PS_MayBeAmbigiousSeen,  // Seen MAYBEAMBIGIOUS keyword
    PS_MayBeDefaultSeen,    // Seen MAYBEDEFAULT keyword
    PS_RemoveableSeen,      // Seen REMOVEABLE keyword

    PS_PropertySeen,        // Seen PROPERTY keyword
    PS_PropertyTypeSeen,    // Seen type decl for property
    PS_PropertyCompleted,   // Seen complete property declaration

    PS_ExceptSeen,          // Seen EXCEPTION keyword
    PS_ExceptHeaderSeen,    // Seen exception header keyword
    PS_ExceptIDSeen,        // Seen exception identifier
    PS_ExceptSqSeen,        // Seen '{' for exception
    PS_ExceptQsSeen,        // Seen '}' for exception
    PS_ExceptBodySeen,      // Seen complete exception body

    PS_OpHeadSeen,          // Seen the operation head
    PS_OpTypeSeen,          // Seen operation return type
    PS_OpIDSeen,            // Seen operation ID
    PS_OpParsCompleted,     // Completed operation param list
    PS_OpCompleted,         // Completed operation statement
    PS_OpSqSeen,            // Seen '(' for operation
    PS_OpQsSeen,            // Seen ')' for operation
    PS_OpParCommaSeen,      // Seen ',' in list of op params
    PS_OpParDirSeen,        // Seen parameter direction
    PS_OpParTypeSeen,       // Seen parameter type
    PS_OpParDeclSeen,       // Seen parameter declaration
    PS_OpOnewaySeen,        // Seen ONEWAY keyword

    PS_RaiseSeen,           // Seen RAISES keyword
    PS_RaiseSqSeen,         // Seen '(' for RAISES
    PS_RaiseQsSeen,         // Seen ')' for RAISES

    PS_DeclsCommaSeen,      // Seen ',' in declarators list
    PS_DeclsDeclSeen        // Seen complete decl in decls list
};

#endif // _IDLC_IDLCTYPES_HXX_

<|endoftext|>


<commit_before>//
// File implementing the required organisms for the ecosystem
// See other files for more info
// TODO: document the use of public almost everywhere...
//

class Organism {
public:
    int size;
    int orgs_eaten;
    int steps_alive;
    int x, y;
    string id;

    // Initializer
    Organism(x,y)
    {
        this.x  = x;
        this.y  = y;
        this.orgs_eaten  = 5; // you're fat organism!
        this.steps_alive = 0;
    }

    void eat_or_interaction(Organism l)
    {
        // TODO
    }

    void move_random()
    {
        // TODO
    }

    void die()
    {
        // TODO
    }

    void get_coords()
    {
        // TODO
    }

    void get_random_possible()
    {
        // TODO
    }

    //
    // one unit of time
    //
    void tick()
    {
        // TODO
    }
};

//
// Our friends the Planktons
//
class Phytoplankton: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Phytoplankton(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 1;
        this.id = "Ph"; // TODO: learn about C++ string best techniques
    }
};

class Zooplankton: public Organism {
public:
    // TODO: maybe use some form of metaprogramming by importing the same file
    // multiple times with a different symbol for these...?
    void Zooplankton(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 1;
        this.id = "Zo";
    }
};

//
// Phylums
// Of course there should be another class between these and Organism
// but I want to keep the code small
//
class Mollusca: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Mollusca(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 2;
    }
}

class Arthropoda: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Arthropoda(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 3;
    }
}

class Chordata: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Chordata(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 4;
    }
}

//
// Actual useable organisms
//
class Squid: public Mollusca {
public:
    void Squid(x,y)
    {
        // TODO super call...
        this.id = "Sq";
    }
}

class Mylittus: public Mollusca {
public:
    void Squid(x,y)
    {
        // TODO super call...
        this.id = "My";
    }
}

class Octopus: public Mollusca {
public:
    void Octopus(x,y)
    {
        // TODO super call...
        this.id = "Oc";
    }
}

class Shrimp: public Arthropoda {
public:
    void Shrimp(x,y)
    {
        // TODO super call...
        this.id = "Sh";
    }
}

class Crab: public Arthropoda {
public:
    void Crab(x,y)
    {
        // TODO super call...
        this.id = "Cr";
    }
}

class Sprattus: public Chordata {
public:
    void Sprattus(x,y)
    {
        // TODO super call...
        this.id = "Sp";
    }
}

class Dolphin: public Chordata {
public:
    void Dolphin(x,y)
    {
        // TODO super call...
        this.id = "Do";
    }
}

class Shark: public Chordata {
public:
    void Shark(x,y)
    {
        // TODO super call...
        this.id = "Sk";
    }
}
<commit_msg>c++: implement the most Organism() functions<commit_after>//
// File implementing the required organisms for the ecosystem
// See other files for more info
// TODO: document the use of public almost everywhere...
//

//
// in the spirit of ruby, get a random element from an array...
//
int sample(int* ar)
{
    int size = sizeof(ar)/sizeof(ar[0]);

    return ar[rand() % size];
}

class Organism {
public:
    int size;
    int orgs_eaten;
    int steps_alive;
    int x, y;
    string id;

    // Initializer. The lack of type is ugly.
    Organism(x,y)
    {
        this.x  = x;
        this.y  = y;
        this.orgs_eaten  = 5; // you're fat organism!
        this.steps_alive = 0;
    }

    //
    // a 'tick' is a one unit of time
    //
    void tick(void)
    {
        // TODO
    }

    //
    // Interacting with a fellow cell
    // Returns true if we are still alive afterwards
    //
    bool eat_or_interaction(x, y)
    {
        if (this.x == x && this.y == y)
            return true;
        if (world.map[x][y].size > this.size) {
            // I just got eaten. Bye life...
            world.map[x][y].orgs_eaten += 1;
            die();
            return false;
        } else {
            // I am bigger.. nom nom nom
            this.orgs_eaten += 1;
            this.x = x;
            this.y = y;
            world.map[x][y]   = this;
            world.map[@x][@y] = NULL;
            return true;
        }
    }

    //
    // moving to the a neighbor cell and interacting with anything that is there
    //
    void move_random(void)
    {
        int coords[2];

        coords = get_coords(get_random_possible(world.dim_x, world.dim_y));
        eat_or_interact(coords[0], coords[1]);
        return;
    }

    void die(void)
    {
        delete this;
    }

    //
    // The following functions are here to make us capable of moving in
    // a square board. Need a way to note the fellow cells...
    // +-----------+
    // | 1 | 2 | 3 |
    // | 4 | 5 | 6 |
    // | 7 | 8 | 9 |
    // +-----------+
    //
    void get_random_possible(max_x, max_y)
    {
        // for brevity
        int x = this.x;
        int y = this.y;

        if (x == 0) {
            if (y == 0) {
                return sample([5,6,8,9]);
            } else if (y == max_y) {
                return sample([2,3,5,6]);
            } else {
                return sample([2,3,5,6,8,9]);
            }
        } else if (y == 0) {
            if (x == max_x) {
                return sample([4,5,7,8]);
            } else {
                return sample([4,5,6,7,8,9]);
            }
        } else if (x == max_x) {
            if (y == max_y) {
                return sample([1,2,4,5]);
            } else {
                return sample([1,2,4,5,7,8]);
            }
        } else if (y == max_y) {
            return sample([1,2,3,4,5,6]);
        } else {
            return sample([1,2,3,4,5,6,7,8,9]);
        }
    }

    int* get_coords(int cell)
    {
        int a[2];
        if (1 <= cell || cell <= 3) {
            a[1] = this.y - 1;
            switch (cell) {
            case 1:
                a[0] = this.x - 1;
                break;
            case 2:
                a[0] = this.x;
                break;
            case 3:
                a[0] = this.x + 1;
                break;
            default:
                fatal("BUG in get_coords");
            }
        } else if (4 <= cell || cell <= 6) {
            a[1] = this.y;
            switch (cell) {
            case 4:
                a[0] = this.x - 1;
                break;
            case 5:
                a[0] = this.x;
                break;
            case 6:
                a[0] = this.x + 1;
                break;
            default:
                fatal("BUG in get_coords");
            }
        } else {
            a[1] = this.y + 1;
            switch (cell) {
            case 7:
                a[0] = this.x - 1;
                break;
            case 8:
                a[0] = this.x;
                break;
            case 9:
                a[0] = this.x + 1;
                break;
            default:
                fatal("BUG in get_coords");
            }
        }
        return a;
    }
};

//
// Our friends the Planktons
//
class Phytoplankton: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Phytoplankton(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 1;
        this.id = "Ph"; // TODO: learn about C++ string best techniques
    }
};

class Zooplankton: public Organism {
public:
    // TODO: maybe use some form of metaprogramming by importing the same file
    // multiple times with a different symbol for these...?
    void Zooplankton(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 1;
        this.id = "Zo";
    }
};

//
// Phylums
// Of course there should be another class between these and Organism
// but I want to keep the code small
//
class Mollusca: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Mollusca(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 2;
    }
}

class Arthropoda: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Arthropoda(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 3;
    }
}

class Chordata: public Organism {
public:
    // initializer (TODO: does this needs to be 'void'??)
    void Chordata(x,y)
    {
        // TODO: need to call the one above the chain (ruby: super)
        this.size = 4;
    }
}

//
// Actual useable organisms
//
class Squid: public Mollusca {
public:
    void Squid(x,y)
    {
        // TODO super call...
        this.id = "Sq";
    }
}

class Mylittus: public Mollusca {
public:
    void Squid(x,y)
    {
        // TODO super call...
        this.id = "My";
    }
}

class Octopus: public Mollusca {
public:
    void Octopus(x,y)
    {
        // TODO super call...
        this.id = "Oc";
    }
}

class Shrimp: public Arthropoda {
public:
    void Shrimp(x,y)
    {
        // TODO super call...
        this.id = "Sh";
    }
}

class Crab: public Arthropoda {
public:
    void Crab(x,y)
    {
        // TODO super call...
        this.id = "Cr";
    }
}

class Sprattus: public Chordata {
public:
    void Sprattus(x,y)
    {
        // TODO super call...
        this.id = "Sp";
    }
}

class Dolphin: public Chordata {
public:
    void Dolphin(x,y)
    {
        // TODO super call...
        this.id = "Do";
    }
}

class Shark: public Chordata {
public:
    void Shark(x,y)
    {
        // TODO super call...
        this.id = "Sk";
    }
}
<|endoftext|>


<commit_before>#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "filesystem.h"
#include "utils.h"

FileSystem::FileSystem(const std::string &partfname):part_filename(partfname), initialized(false){
  memset(fat, 0x00, sizeof(fat));
  memset(datablocks, 0x00, sizeof(datablocks));
  memset(rootdir, 0x00, sizeof(rootdir));
}

FileSystem::~FileSystem(){
}

void FileSystem::debug(){

  ::debug("Debugging the filesystem class...");
  if (this->init() != RET_OK){
    ::debug("Init failed.");
  }
  if (this->load() != RET_OK){
    ::debug("Load failed.");
  }
  //this->dumpfat();
  this->makedir("/home");

}

int FileSystem::init(){

  remove(part_filename.c_str());
  createdummy();

  // step 1: writeout 1024 0xbb's
  unsigned char bootblock[1024];
  memset(bootblock, 0xbb, sizeof(bootblock));
  if (!writeblock(bootblock, 0)){
    return RET_CANNOT_INITIALIZE;
  }

  // step 2: writeout the fat "header"
  unsigned char fatheader[8192] = {0xff, 0xfd,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xff};

  memset(fatheader+20, 0x00, sizeof(fatheader)-20);
  for (unsigned int i=0; i<8; i++){
    if (!writeblock(&(fatheader[i*1024]), (i+1)*1024)){
      return RET_CANNOT_INITIALIZE;
    }
  }

  // step 3: we no longer have to writeout the blank rest because we now have a whole blankened dummy file from the beginning

  initialized = true;
  return RET_OK;
}

int FileSystem::load(){
  CHECK_INIT

  for (unsigned int i=0; i<8; i++){

    if (!readblock(&(fat[i*1024]), (i+1) * 1024)){
      return RET_CANNOT_INITIALIZE;
    }

  }

  return RET_OK;

}

int FileSystem::makedir(const std::string &path){
  CHECK_INIT

  std::vector<std::string> ret = tokenize_path(path);

  for (unsigned int i=0; i<ret.size(); i++){

    int const rid = find_free_rootdir();
    if (rid == -1){
      return RET_ROOTDIR_FULL;
    }

    if (i==0){ // root dir
    } else {
    }

  }

  return RET_OK;
}

int FileSystem::listdir(const std::string &path, std::vector<std::string> &result){
  CHECK_INIT

  (void)path;
  (void)result;
  return -1;
}

int FileSystem::createfile(const std::string &path){
  CHECK_INIT
  (void)path;
  return -1;
}

int FileSystem::unlink(const std::string &path){
  CHECK_INIT
  (void)path;
  return -1;
}

int FileSystem::write(const std::string &path, const std::string &content){
  CHECK_INIT
  (void)path;
  (void)content;
  return -1;
}

int FileSystem::append(const std::string &path, const std::string &content){
  CHECK_INIT
  (void)path;
  (void)content;
  return -1;
}

int FileSystem::read(const std::string &path, std::string &content){
  CHECK_INIT

  (void)path;
  (void)content;
  return -1;
}

int FileSystem::find_free_rootdir() const {
  for (unsigned int i=0; i<sizeof(rootdir); i++){
    if (rootdir[i].filename[0] == 0x00){
      return i;
    }
  }
  return -1;
}

bool FileSystem::readblock(void *into, const unsigned int offset) const {

  FILE* fd = fopen(part_filename.c_str(), "rb");
  if (fd == NULL){
    return false;
  }
  fseek(fd, offset, SEEK_SET);
  fread(into, 1, 1024, fd);
  fclose(fd);

  return true;

}

bool FileSystem::writeblock(const void * buf, const unsigned int offset){

  // we have to read and overwrite the whole file :S
  unsigned char *wholebuffer = 0;
  long fsize = 0;

  // open up partition file
  FILE* fd_read = fopen(part_filename.c_str(), "rb");
  if (fd_read == NULL){
    return false;
  }

  // get its filesize
  fseek(fd_read, 0L, SEEK_END);
  fsize = ftell(fd_read);
  //fseek(fd_read, 0L, SEEK_SET);
  rewind(fd_read);

  // allocate whole buffer (to store the whole file, yes!) and read into it
  wholebuffer = (unsigned char*)calloc(fsize, 1);
  fread(wholebuffer, 1, fsize, fd_read);
  fclose(fd_read);

  // change wholebuff contents with what this function was given
  memcpy(wholebuffer+offset, buf, 1024);

  // and finally write the whole thing back
  FILE* fd_write = fopen(part_filename.c_str(), "wb");
  if (fd_write == NULL){
    return false;
  }

  // write, close, dealloc.. clenaup code.
  fwrite(wholebuffer, 1, fsize, fd_write);
  fclose(fd_write);
  free(wholebuffer);

  return true;

}

void FileSystem::createdummy() const {

  FILE* fd_write = fopen(part_filename.c_str(), "wb+");
  // mvtodo: fopen error treating

  // MV: for some reason, using more than a handful of K's on the stack was causing a segfault.
  // took hours to figure it out, but theres a really DUMB solution down below
  const unsigned long total = 4*1024*1024; // 4 mbs
  const unsigned int piece = total / 16;

  unsigned char dummybuf[piece];
  memset(dummybuf, 0x00, sizeof(dummybuf));
  for (unsigned int i=0; i<total/piece; i++){
    fwrite(dummybuf, 1, sizeof(dummybuf), fd_write);
  }

  fclose(fd_write);

}

void FileSystem::dumpfat() {
  for (unsigned int i=0; i<8; i++){
    writeblock(&(fat[i*1024]), (i+1)*1024);
  }
}

<commit_msg>adding call to dumpfat upon FS destruction<commit_after>#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "filesystem.h"
#include "utils.h"

FileSystem::FileSystem(const std::string &partfname):part_filename(partfname), initialized(false){
  memset(fat, 0x00, sizeof(fat));
  memset(datablocks, 0x00, sizeof(datablocks));
  memset(rootdir, 0x00, sizeof(rootdir));
}

FileSystem::~FileSystem(){
  dumpfat();
}

void FileSystem::debug(){

  ::debug("Debugging the filesystem class...");
  if (this->init() != RET_OK){
    ::debug("Init failed.");
  }
  if (this->load() != RET_OK){
    ::debug("Load failed.");
  }
  this->makedir("/home");

}

int FileSystem::init(){

  remove(part_filename.c_str());
  createdummy();

  // step 1: writeout 1024 0xbb's
  unsigned char bootblock[1024];
  memset(bootblock, 0xbb, sizeof(bootblock));
  if (!writeblock(bootblock, 0)){
    return RET_CANNOT_INITIALIZE;
  }

  // step 2: writeout the fat "header"
  unsigned char fatheader[8192] = {0xff, 0xfd,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xfe,
                                   0xff, 0xff};

  memset(fatheader+20, 0x00, sizeof(fatheader)-20);
  for (unsigned int i=0; i<8; i++){
    if (!writeblock(&(fatheader[i*1024]), (i+1)*1024)){
      return RET_CANNOT_INITIALIZE;
    }
  }

  // step 3: we no longer have to writeout the blank rest because we now have a whole blankened dummy file from the beginning

  initialized = true;
  return RET_OK;
}

int FileSystem::load(){
  CHECK_INIT

  for (unsigned int i=0; i<8; i++){

    if (!readblock(&(fat[i*1024]), (i+1) * 1024)){
      return RET_CANNOT_INITIALIZE;
    }

  }

  return RET_OK;

}

int FileSystem::makedir(const std::string &path){
  CHECK_INIT

  std::vector<std::string> ret = tokenize_path(path);

  for (unsigned int i=0; i<ret.size(); i++){

    int const rid = find_free_rootdir();
    if (rid == -1){
      return RET_ROOTDIR_FULL;
    }

    if (i==0){ // root dir
    } else {
    }

  }

  return RET_OK;
}

int FileSystem::listdir(const std::string &path, std::vector<std::string> &result){
  CHECK_INIT

  (void)path;
  (void)result;
  return -1;
}

int FileSystem::createfile(const std::string &path){
  CHECK_INIT
  (void)path;
  return -1;
}

int FileSystem::unlink(const std::string &path){
  CHECK_INIT
  (void)path;
  return -1;
}

int FileSystem::write(const std::string &path, const std::string &content){
  CHECK_INIT
  (void)path;
  (void)content;
  return -1;
}

int FileSystem::append(const std::string &path, const std::string &content){
  CHECK_INIT
  (void)path;
  (void)content;
  return -1;
}

int FileSystem::read(const std::string &path, std::string &content){
  CHECK_INIT

  (void)path;
  (void)content;
  return -1;
}

int FileSystem::find_free_rootdir() const {
  for (unsigned int i=0; i<sizeof(rootdir); i++){
    if (rootdir[i].filename[0] == 0x00){
      return i;
    }
  }
  return -1;
}

bool FileSystem::readblock(void *into, const unsigned int offset) const {

  FILE* fd = fopen(part_filename.c_str(), "rb");
  if (fd == NULL){
    return false;
  }
  fseek(fd, offset, SEEK_SET);
  fread(into, 1, 1024, fd);
  fclose(fd);

  return true;

}

bool FileSystem::writeblock(const void * buf, const unsigned int offset){

  // we have to read and overwrite the whole file :S
  unsigned char *wholebuffer = 0;
  long fsize = 0;

  // open up partition file
  FILE* fd_read = fopen(part_filename.c_str(), "rb");
  if (fd_read == NULL){
    return false;
  }

  // get its filesize
  fseek(fd_read, 0L, SEEK_END);
  fsize = ftell(fd_read);
  //fseek(fd_read, 0L, SEEK_SET);
  rewind(fd_read);

  // allocate whole buffer (to store the whole file, yes!) and read into it
  wholebuffer = (unsigned char*)calloc(fsize, 1);
  fread(wholebuffer, 1, fsize, fd_read);
  fclose(fd_read);

  // change wholebuff contents with what this function was given
  memcpy(wholebuffer+offset, buf, 1024);

  // and finally write the whole thing back
  FILE* fd_write = fopen(part_filename.c_str(), "wb");
  if (fd_write == NULL){
    return false;
  }

  // write, close, dealloc.. clenaup code.
  fwrite(wholebuffer, 1, fsize, fd_write);
  fclose(fd_write);
  free(wholebuffer);

  return true;

}

void FileSystem::createdummy() const {

  FILE* fd_write = fopen(part_filename.c_str(), "wb+");
  // mvtodo: fopen error treating

  // MV: for some reason, using more than a handful of K's on the stack was causing a segfault.
  // took hours to figure it out, but theres a really DUMB solution down below
  const unsigned long total = 4*1024*1024; // 4 mbs
  const unsigned int piece = total / 16;

  unsigned char dummybuf[piece];
  memset(dummybuf, 0x00, sizeof(dummybuf));
  for (unsigned int i=0; i<total/piece; i++){
    fwrite(dummybuf, 1, sizeof(dummybuf), fd_write);
  }

  fclose(fd_write);

}

void FileSystem::dumpfat() {
  for (unsigned int i=0; i<8; i++){
    writeblock(&(fat[i*1024]), (i+1)*1024);
  }
}

<|endoftext|>


<commit_before>#include "BinaryTree.hpp"
#include <catch.hpp>

SCENARIO("default constructor")
{
	Tree<int> node;
	REQUIRE(node.root_() == nullptr);
}

SCENARIO("insert")
{
	Tree<int> tree;
	tree.insert(7);
	REQUIRE(tree.x_() == 7);
	REQUIRE(tree.left_() == nullptr);
	REQUIRE(tree.right_() == nullptr);
}

SCENARIO("search")
{
	Tree<int> tree;
	bool a;
	tree.insert(7);
	a = tree.check_search(7);
	REQUIRE(a == true);
}

SCENARIO("size")
{
	Tree<int> tree;
	int size = 0;
	tree.insert(7);
	size = tree.size(tree.root_());
	REQUIRE(size == 1);
}
<commit_msg>Update init.cpp<commit_after>#include "BinaryTree.hpp"
#include <catch.hpp>

SCENARIO("default constructor")
{
	Tree<int> node;
	REQUIRE(node.root_() == nullptr);
}

SCENARIO("insert")
{
	Tree<int> tree;
	tree.insert(7);
	REQUIRE(tree.x_() == 7);
	REQUIRE(tree.left_() == nullptr);
	REQUIRE(tree.right_() == nullptr);
}

SCENARIO("search")
{
	Tree<int> tree;
	bool a;
	tree.insert(7);
	a = tree.check_search(7);
	REQUIRE(a == true);
}

SCENARIO("size")
{
	Tree<int> tree;
	int size = 0;
	tree.insert(7);
	size = tree.size(tree.root_());
	REQUIRE(size == 1);
}

SCENARIO("out_to_file")
{
	Tree<int> tree1, tree2;
	int size1, size2;
	tree1.fIn("Tree.txt");
	size1 = tree1.size(tree1.root_());
	tree1.out_to_file("TreeOut.txt");
	tree2.fIn("TreeOut.txt");
	size2 = tree2.size(tree2.root_());
	REQUIRE(size1 == size2);
}
<|endoftext|>


<commit_before>#include <binary_search_tree.hpp>
#include <catch.hpp>

SCENARIO("default constructor")
{
	BinarySearchTree<int> bst;
	REQUIRE(bst.root() == nullptr);
}

SCENARIO("insertElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE(bst.value_() == 7);
	REQUIRE(bst.leftNode_() == nullptr);
	REQUIRE(bst.rightNode_() == nullptr);
}

SCENARIO("findElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE(bst.isFound(7) == 1);
}

SCENARIO("infile")
{
	BinarySearchTree<int> bst;
	bst.infile("file.txt");
	REQUIRE(bst.count_(bst.root()) == 0);
}

SCENARIO("count_")
{
	BinarySearchTree<int> bst;
	int count = 0;
	bst.insert(7);
	count = bst.count_(bst.root ());
	REQUIRE(count == 1);
}

SCENARIO("deleteNode")
{
	BinarySearchTree<int> bst;
	int size1, size2, size3, size4;
	tree.insert(5);
	tree.insert(3);
	tree.insert(2);
	tree.insert(4);
	tree.insert(7);
	tree.insert(6);
	tree.insert(8);
	size1 = bst.count_(bst.root ());
	tree.deleteNode(8);
	size2 = bst.count_(bst.root ());
	tree.deleteNode(7);
	size3 = bst.count_(bst.root ());
	tree.deleteNode(3);
	size4 = bst.count_(bst.root ());
	REQUIRE(size1 == 7);
	REQUIRE(size2 == 6);
	REQUIRE(size3 == 5);
	REQUIRE(size4 == 4);
}
<commit_msg>Update init.cpp<commit_after>#include <binary_search_tree.hpp>
#include <catch.hpp>

SCENARIO("default constructor")
{
	BinarySearchTree<int> bst;
	REQUIRE(bst.root() == nullptr);
}

SCENARIO("insertElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE(bst.value_() == 7);
	REQUIRE(bst.leftNode_() == nullptr);
	REQUIRE(bst.rightNode_() == nullptr);
}

SCENARIO("findElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE(bst.isFound(7) == 1);
}

SCENARIO("infile")
{
	BinarySearchTree<int> bst;
	bst.infile("file.txt");
	REQUIRE(bst.count_(bst.root()) == 0);
}

SCENARIO("count_")
{
	BinarySearchTree<int> bst;
	int count = 0;
	bst.insert(7);
	count = bst.count_(bst.root ());
	REQUIRE(count == 1);
}

SCENARIO("deleteNode")
{
	BinarySearchTree<int> bst;
	int size1, size2, size3, size4;
	bst.insert(5);
	bst.insert(3);
	bst.insert(2);
	bst.insert(4);
	bst.insert(7);
	bst.insert(6);
	bst.insert(8);
	size1 = bst.count_(bst.root ());
	tree.deleteNode(8);
	size2 = bst.count_(bst.root ());
	tree.deleteNode(7);
	size3 = bst.count_(bst.root ());
	tree.deleteNode(3);
	size4 = bst.count_(bst.root ());
	REQUIRE(size1 == 7);
	REQUIRE(size2 == 6);
	REQUIRE(size3 == 5);
	REQUIRE(size4 == 4);
}
<|endoftext|>


<commit_before>#include <binary_search_tree.hpp>
#include <catch.hpp>

SCENARIO("default constructor")
{
	BinarySearchTree<int> bst;
	REQUIRE(bst.root() == nullptr);
}

SCENARIO("insertElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE(bst.value_() == 7);
	REQUIRE(bst.leftNode_() == nullptr);
	REQUIRE(bst.rightNode_() == nullptr);
}

SCENARIO("findElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE( bst.isFound(7) == 1);
}

SCENARIO("infile")
{
	BinarySearchTree<int> bst;
	bst.infile("file.txt");
	REQUIRE( bst.count() == 1);
}
<commit_msg>Update init.cpp<commit_after>#include <binary_search_tree.hpp>
#include <catch.hpp>

SCENARIO("default constructor")
{
	BinarySearchTree<int> bst;
	REQUIRE(bst.root() == nullptr);
}

SCENARIO("insertElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE(bst.value_() == 7);
	REQUIRE(bst.leftNode_() == nullptr);
	REQUIRE(bst.rightNode_() == nullptr);
}

SCENARIO("findElement")
{
	BinarySearchTree<int> bst;
	bst.insert(7);
	REQUIRE( bst.isFound(7) == 1);
}

SCENARIO("infile")
{
	BinarySearchTree<int> bst;
	bst.infile("file.txt");
	REQUIRE( bst.count() == 0);
}
<|endoftext|>


<commit_before>/**
* Copyright (c) 2017 committers of YAKINDU and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     committers of YAKINDU - initial API and implementation
*/
#include <string>
#include "gtest/gtest.h"
#include "Operations.h"
#include "OperationsRequired.h"
class InternalOperation3aMock{
	public:
	sc_real (InternalOperation3aMock::*internalOperation3aBehavior)(sc_real) = NULL;
	sc_real internalOperation3a1(const sc_real param1){
		return (param1+1.0);
	}
	void setInternalOperation3aBehavior(sc_real (InternalOperation3aMock::*func)(sc_real)){
		internalOperation3aBehavior = func;
	}
};
static InternalOperation3aMock* internalOperation3aMock;

class AlwaysTrueMock{
	public:
	sc_boolean (AlwaysTrueMock::*alwaysTrueBehavior)() = NULL;
	sc_boolean alwaysTrue1(){
		return (true);
	}
	void setAlwaysTrueBehavior(sc_boolean (AlwaysTrueMock::*func)()){
		alwaysTrueBehavior = func;
	}
};
static AlwaysTrueMock* alwaysTrueMock;

static struct {
	sc_boolean called;
} internalOperation1 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} internalOperation2 = {false, 0};

static struct {
	sc_boolean called;
} internalOperation3 = {false};

static struct {
	sc_boolean called;
	sc_real param1;
} internalOperation3a = {false, 0.0d};

static struct {
	sc_boolean called;
} internalOperation4 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} internalOperation4a = {false, 0};

static struct {
	sc_boolean called;
} internalOperation5 = {false};

static struct {
	sc_boolean called;
	char const * param1;
} internalOperation5a = {false, 0};

static struct {
	sc_boolean called;
} interface1InterfaceOperation1 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} interface1InterfaceOperation2 = {false, 0};

static struct {
	sc_boolean called;
} interface1InterfaceOperation3 = {false};

static struct {
	sc_boolean called;
	sc_real param1;
} interface1InterfaceOperation3a = {false, 0.0d};

static struct {
	sc_boolean called;
} interface1InterfaceOperation4 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} interface1InterfaceOperation4a = {false, 0};

static struct {
	sc_boolean called;
} interface1InterfaceOperation5 = {false};

static struct {
	sc_boolean called;
	char const * param1;
} interface1InterfaceOperation5a = {false, 0};

static struct {
	sc_boolean called;
} unnamedInterfaceOperation1 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} unnamedInterfaceOperation2 = {false, 0};

static struct {
	sc_boolean called;
} unnamedOperation3 = {false};

static struct {
	sc_boolean called;
	sc_real param1;
} unnamedOperation3a = {false, 0.0d};

static struct {
	sc_boolean called;
} unnamedOperation4 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} unnamedOperation4a = {false, 0};

static struct {
	sc_boolean called;
} unnamedOperation5 = {false};

static struct {
	sc_boolean called;
	char const * param1;
} unnamedOperation5a = {false, 0};

Operations handle;

TEST(StatemachineTest, operationsCalled) {
	operations_init(&handle);

	alwaysTrueMock = new AlwaysTrueMock();
	internalOperation3aMock = new InternalOperation3aMock();
	alwaysTrueMock->setAlwaysTrueBehavior(&AlwaysTrueMock::alwaysTrue1);
	internalOperation3aMock->setInternalOperation3aBehavior(&InternalOperation3aMock::internalOperation3a1);
	operations_enter(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_A));
	operations_runCycle(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_B));
	EXPECT_TRUE(internalOperation1.called);
	EXPECT_TRUE(internalOperation2.called);
	EXPECT_TRUE(internalOperation2.param1 == 4l);
	EXPECT_TRUE(internalOperation3.called);
	EXPECT_TRUE(internalOperation3a.called);
	EXPECT_TRUE(internalOperation4.called);
	EXPECT_TRUE(internalOperation4a.called);
	EXPECT_TRUE(internalOperation4a.param1 == 5l);
	EXPECT_TRUE(internalOperation5.called);
	EXPECT_TRUE(internalOperation5a.called);
	EXPECT_TRUE(strcmp(internalOperation5a.param1, "") == 0);
	EXPECT_TRUE(internalOperation2.called);
	EXPECT_TRUE(internalOperation2.param1 == 4l);
	operationsIface_raise_ev(&handle);
	operations_runCycle(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_C));
	EXPECT_TRUE(interface1InterfaceOperation1.called);
	EXPECT_TRUE(interface1InterfaceOperation2.called);
	EXPECT_TRUE(interface1InterfaceOperation2.param1 == 4l);
	EXPECT_TRUE(interface1InterfaceOperation3.called);
	EXPECT_TRUE(interface1InterfaceOperation3a.called);
	EXPECT_TRUE(interface1InterfaceOperation3a.param1 == 1.0);
	EXPECT_TRUE(interface1InterfaceOperation4.called);
	EXPECT_TRUE(interface1InterfaceOperation4a.called);
	EXPECT_TRUE(interface1InterfaceOperation4a.param1 == 5l);
	EXPECT_TRUE(interface1InterfaceOperation5.called);
	EXPECT_TRUE(interface1InterfaceOperation5a.called);
	EXPECT_TRUE(strcmp(interface1InterfaceOperation5a.param1, "") == 0);
	operationsIface_raise_ev(&handle);
	operations_runCycle(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_D));
	EXPECT_TRUE(unnamedInterfaceOperation1.called);
	EXPECT_TRUE(unnamedInterfaceOperation2.called);
	EXPECT_TRUE(unnamedInterfaceOperation2.param1 == 4l);
	EXPECT_TRUE(unnamedOperation3.called);
	EXPECT_TRUE(unnamedOperation3a.called);
	EXPECT_TRUE(unnamedOperation3a.param1 == 1.0);
	EXPECT_TRUE(unnamedOperation4.called);
	EXPECT_TRUE(unnamedOperation4a.called);
	EXPECT_TRUE(unnamedOperation4a.param1 == 5l);
	EXPECT_TRUE(unnamedOperation5.called);
	EXPECT_TRUE(unnamedOperation5a.called);
	EXPECT_TRUE(strcmp(unnamedOperation5a.param1, "") == 0);
}

void operationsInternal_internalOperation1(const Operations* handle){
internalOperation1.called = true;
}
sc_boolean operationsInternal_internalOperation2(const Operations* handle, const sc_integer param1){
internalOperation2.called = true;
internalOperation2.param1 = param1;
return true;
}
sc_real operationsInternal_internalOperation3(const Operations* handle){
internalOperation3.called = true;
return 0.0d;
}
sc_real operationsInternal_internalOperation3a(const Operations* handle, const sc_real param1){
internalOperation3a.called = true;
internalOperation3a.param1 = param1;
sc_real (InternalOperation3aMock::*func)(sc_real) = internalOperation3aMock->internalOperation3aBehavior;
return (internalOperation3aMock->*func)(param1);

}
sc_integer operationsInternal_internalOperation4(const Operations* handle){
internalOperation4.called = true;
return 0;
}
sc_integer operationsInternal_internalOperation4a(const Operations* handle, const sc_integer param1){
internalOperation4a.called = true;
internalOperation4a.param1 = param1;
return 0;
}
sc_string operationsInternal_internalOperation5(const Operations* handle){
internalOperation5.called = true;
return 0;
}
sc_string operationsInternal_internalOperation5a(const Operations* handle, const sc_string param1){
internalOperation5a.called = true;
internalOperation5a.param1 = param1;
return 0;
}
void operationsIfaceInterface1_interfaceOperation1(const Operations* handle){
interface1InterfaceOperation1.called = true;
}
sc_boolean operationsIfaceInterface1_interfaceOperation2(const Operations* handle, const sc_integer param1){
interface1InterfaceOperation2.called = true;
interface1InterfaceOperation2.param1 = param1;
return true;
}
sc_real operationsIfaceInterface1_interfaceOperation3(const Operations* handle){
interface1InterfaceOperation3.called = true;
return 0.0d;
}
sc_real operationsIfaceInterface1_interfaceOperation3a(const Operations* handle, const sc_real param1){
interface1InterfaceOperation3a.called = true;
interface1InterfaceOperation3a.param1 = param1;
return 0.0d;
}
sc_integer operationsIfaceInterface1_interfaceOperation4(const Operations* handle){
interface1InterfaceOperation4.called = true;
return 0;
}
sc_integer operationsIfaceInterface1_interfaceOperation4a(const Operations* handle, const sc_integer param1){
interface1InterfaceOperation4a.called = true;
interface1InterfaceOperation4a.param1 = param1;
return 0;
}
sc_string operationsIfaceInterface1_interfaceOperation5(const Operations* handle){
interface1InterfaceOperation5.called = true;
return 0;
}
sc_string operationsIfaceInterface1_interfaceOperation5a(const Operations* handle, const sc_string param1){
interface1InterfaceOperation5a.called = true;
interface1InterfaceOperation5a.param1 = param1;
return 0;
}
void operationsIface_unnamedInterfaceOperation1(const Operations* handle){
unnamedInterfaceOperation1.called = true;
}
sc_boolean operationsIface_unnamedInterfaceOperation2(const Operations* handle, const sc_integer param1){
unnamedInterfaceOperation2.called = true;
unnamedInterfaceOperation2.param1 = param1;
return true;
}
sc_real operationsIface_unnamedOperation3(const Operations* handle){
unnamedOperation3.called = true;
return 0.0d;
}
sc_real operationsIface_unnamedOperation3a(const Operations* handle, const sc_real param1){
unnamedOperation3a.called = true;
unnamedOperation3a.param1 = param1;
return 0.0d;
}
sc_integer operationsIface_unnamedOperation4(const Operations* handle){
unnamedOperation4.called = true;
return 0;
}
sc_integer operationsIface_unnamedOperation4a(const Operations* handle, const sc_integer param1){
unnamedOperation4a.called = true;
unnamedOperation4a.param1 = param1;
return 0;
}
sc_string operationsIface_unnamedOperation5(const Operations* handle){
unnamedOperation5.called = true;
return 0;
}
sc_string operationsIface_unnamedOperation5a(const Operations* handle, const sc_string param1){
unnamedOperation5a.called = true;
unnamedOperation5a.param1 = param1;
return 0;
}
sc_boolean operationsIface_alwaysTrue(const Operations* handle){
sc_boolean (AlwaysTrueMock::*func)() = alwaysTrueMock->alwaysTrueBehavior;
return (alwaysTrueMock->*func)();

}
<commit_msg>Deleted the initialization of the Behavior variable<commit_after>/**
* Copyright (c) 2017 committers of YAKINDU and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     committers of YAKINDU - initial API and implementation
*/
#include <string>
#include "gtest/gtest.h"
#include "Operations.h"
#include "OperationsRequired.h"
class InternalOperation3aMock{
	public:
	sc_real (InternalOperation3aMock::*internalOperation3aBehavior)(sc_real);
	sc_real internalOperation3a1(const sc_real param1){
		return (param1+1.0);
	}
	void setInternalOperation3aBehavior(sc_real (InternalOperation3aMock::*func)(sc_real)){
		internalOperation3aBehavior = func;
	}
};
static InternalOperation3aMock* internalOperation3aMock;

class AlwaysTrueMock{
	public:
	sc_boolean (AlwaysTrueMock::*alwaysTrueBehavior)();
	sc_boolean alwaysTrue1(){
		return (true);
	}
	void setAlwaysTrueBehavior(sc_boolean (AlwaysTrueMock::*func)()){
		alwaysTrueBehavior = func;
	}
};
static AlwaysTrueMock* alwaysTrueMock;

static struct {
	sc_boolean called;
} internalOperation1 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} internalOperation2 = {false, 0};

static struct {
	sc_boolean called;
} internalOperation3 = {false};

static struct {
	sc_boolean called;
	sc_real param1;
} internalOperation3a = {false, 0.0d};

static struct {
	sc_boolean called;
} internalOperation4 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} internalOperation4a = {false, 0};

static struct {
	sc_boolean called;
} internalOperation5 = {false};

static struct {
	sc_boolean called;
	char const * param1;
} internalOperation5a = {false, 0};

static struct {
	sc_boolean called;
} interface1InterfaceOperation1 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} interface1InterfaceOperation2 = {false, 0};

static struct {
	sc_boolean called;
} interface1InterfaceOperation3 = {false};

static struct {
	sc_boolean called;
	sc_real param1;
} interface1InterfaceOperation3a = {false, 0.0d};

static struct {
	sc_boolean called;
} interface1InterfaceOperation4 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} interface1InterfaceOperation4a = {false, 0};

static struct {
	sc_boolean called;
} interface1InterfaceOperation5 = {false};

static struct {
	sc_boolean called;
	char const * param1;
} interface1InterfaceOperation5a = {false, 0};

static struct {
	sc_boolean called;
} unnamedInterfaceOperation1 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} unnamedInterfaceOperation2 = {false, 0};

static struct {
	sc_boolean called;
} unnamedOperation3 = {false};

static struct {
	sc_boolean called;
	sc_real param1;
} unnamedOperation3a = {false, 0.0d};

static struct {
	sc_boolean called;
} unnamedOperation4 = {false};

static struct {
	sc_boolean called;
	sc_integer param1;
} unnamedOperation4a = {false, 0};

static struct {
	sc_boolean called;
} unnamedOperation5 = {false};

static struct {
	sc_boolean called;
	char const * param1;
} unnamedOperation5a = {false, 0};

Operations handle;

TEST(StatemachineTest, operationsCalled) {
	operations_init(&handle);

	alwaysTrueMock = new AlwaysTrueMock();
	internalOperation3aMock = new InternalOperation3aMock();
	alwaysTrueMock->setAlwaysTrueBehavior(&AlwaysTrueMock::alwaysTrue1);
	internalOperation3aMock->setInternalOperation3aBehavior(&InternalOperation3aMock::internalOperation3a1);
	operations_enter(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_A));
	operations_runCycle(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_B));
	EXPECT_TRUE(internalOperation1.called);
	EXPECT_TRUE(internalOperation2.called);
	EXPECT_TRUE(internalOperation2.param1 == 4l);
	EXPECT_TRUE(internalOperation3.called);
	EXPECT_TRUE(internalOperation3a.called);
	EXPECT_TRUE(internalOperation4.called);
	EXPECT_TRUE(internalOperation4a.called);
	EXPECT_TRUE(internalOperation4a.param1 == 5l);
	EXPECT_TRUE(internalOperation5.called);
	EXPECT_TRUE(internalOperation5a.called);
	EXPECT_TRUE(strcmp(internalOperation5a.param1, "") == 0);
	EXPECT_TRUE(internalOperation2.called);
	EXPECT_TRUE(internalOperation2.param1 == 4l);
	operationsIface_raise_ev(&handle);
	operations_runCycle(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_C));
	EXPECT_TRUE(interface1InterfaceOperation1.called);
	EXPECT_TRUE(interface1InterfaceOperation2.called);
	EXPECT_TRUE(interface1InterfaceOperation2.param1 == 4l);
	EXPECT_TRUE(interface1InterfaceOperation3.called);
	EXPECT_TRUE(interface1InterfaceOperation3a.called);
	EXPECT_TRUE(interface1InterfaceOperation3a.param1 == 1.0);
	EXPECT_TRUE(interface1InterfaceOperation4.called);
	EXPECT_TRUE(interface1InterfaceOperation4a.called);
	EXPECT_TRUE(interface1InterfaceOperation4a.param1 == 5l);
	EXPECT_TRUE(interface1InterfaceOperation5.called);
	EXPECT_TRUE(interface1InterfaceOperation5a.called);
	EXPECT_TRUE(strcmp(interface1InterfaceOperation5a.param1, "") == 0);
	operationsIface_raise_ev(&handle);
	operations_runCycle(&handle);
	EXPECT_TRUE(operations_isStateActive(&handle, Operations_main_region_D));
	EXPECT_TRUE(unnamedInterfaceOperation1.called);
	EXPECT_TRUE(unnamedInterfaceOperation2.called);
	EXPECT_TRUE(unnamedInterfaceOperation2.param1 == 4l);
	EXPECT_TRUE(unnamedOperation3.called);
	EXPECT_TRUE(unnamedOperation3a.called);
	EXPECT_TRUE(unnamedOperation3a.param1 == 1.0);
	EXPECT_TRUE(unnamedOperation4.called);
	EXPECT_TRUE(unnamedOperation4a.called);
	EXPECT_TRUE(unnamedOperation4a.param1 == 5l);
	EXPECT_TRUE(unnamedOperation5.called);
	EXPECT_TRUE(unnamedOperation5a.called);
	EXPECT_TRUE(strcmp(unnamedOperation5a.param1, "") == 0);
}

void operationsInternal_internalOperation1(const Operations* handle){
internalOperation1.called = true;
}
sc_boolean operationsInternal_internalOperation2(const Operations* handle, const sc_integer param1){
internalOperation2.called = true;
internalOperation2.param1 = param1;
return true;
}
sc_real operationsInternal_internalOperation3(const Operations* handle){
internalOperation3.called = true;
return 0.0d;
}
sc_real operationsInternal_internalOperation3a(const Operations* handle, const sc_real param1){
internalOperation3a.called = true;
internalOperation3a.param1 = param1;
sc_real (InternalOperation3aMock::*func)(sc_real) = internalOperation3aMock->internalOperation3aBehavior;
return (internalOperation3aMock->*func)(param1);

}
sc_integer operationsInternal_internalOperation4(const Operations* handle){
internalOperation4.called = true;
return 0;
}
sc_integer operationsInternal_internalOperation4a(const Operations* handle, const sc_integer param1){
internalOperation4a.called = true;
internalOperation4a.param1 = param1;
return 0;
}
sc_string operationsInternal_internalOperation5(const Operations* handle){
internalOperation5.called = true;
return 0;
}
sc_string operationsInternal_internalOperation5a(const Operations* handle, const sc_string param1){
internalOperation5a.called = true;
internalOperation5a.param1 = param1;
return 0;
}
void operationsIfaceInterface1_interfaceOperation1(const Operations* handle){
interface1InterfaceOperation1.called = true;
}
sc_boolean operationsIfaceInterface1_interfaceOperation2(const Operations* handle, const sc_integer param1){
interface1InterfaceOperation2.called = true;
interface1InterfaceOperation2.param1 = param1;
return true;
}
sc_real operationsIfaceInterface1_interfaceOperation3(const Operations* handle){
interface1InterfaceOperation3.called = true;
return 0.0d;
}
sc_real operationsIfaceInterface1_interfaceOperation3a(const Operations* handle, const sc_real param1){
interface1InterfaceOperation3a.called = true;
interface1InterfaceOperation3a.param1 = param1;
return 0.0d;
}
sc_integer operationsIfaceInterface1_interfaceOperation4(const Operations* handle){
interface1InterfaceOperation4.called = true;
return 0;
}
sc_integer operationsIfaceInterface1_interfaceOperation4a(const Operations* handle, const sc_integer param1){
interface1InterfaceOperation4a.called = true;
interface1InterfaceOperation4a.param1 = param1;
return 0;
}
sc_string operationsIfaceInterface1_interfaceOperation5(const Operations* handle){
interface1InterfaceOperation5.called = true;
return 0;
}
sc_string operationsIfaceInterface1_interfaceOperation5a(const Operations* handle, const sc_string param1){
interface1InterfaceOperation5a.called = true;
interface1InterfaceOperation5a.param1 = param1;
return 0;
}
void operationsIface_unnamedInterfaceOperation1(const Operations* handle){
unnamedInterfaceOperation1.called = true;
}
sc_boolean operationsIface_unnamedInterfaceOperation2(const Operations* handle, const sc_integer param1){
unnamedInterfaceOperation2.called = true;
unnamedInterfaceOperation2.param1 = param1;
return true;
}
sc_real operationsIface_unnamedOperation3(const Operations* handle){
unnamedOperation3.called = true;
return 0.0d;
}
sc_real operationsIface_unnamedOperation3a(const Operations* handle, const sc_real param1){
unnamedOperation3a.called = true;
unnamedOperation3a.param1 = param1;
return 0.0d;
}
sc_integer operationsIface_unnamedOperation4(const Operations* handle){
unnamedOperation4.called = true;
return 0;
}
sc_integer operationsIface_unnamedOperation4a(const Operations* handle, const sc_integer param1){
unnamedOperation4a.called = true;
unnamedOperation4a.param1 = param1;
return 0;
}
sc_string operationsIface_unnamedOperation5(const Operations* handle){
unnamedOperation5.called = true;
return 0;
}
sc_string operationsIface_unnamedOperation5a(const Operations* handle, const sc_string param1){
unnamedOperation5a.called = true;
unnamedOperation5a.param1 = param1;
return 0;
}
sc_boolean operationsIface_alwaysTrue(const Operations* handle){
sc_boolean (AlwaysTrueMock::*func)() = alwaysTrueMock->alwaysTrueBehavior;
return (alwaysTrueMock->*func)();

}
<|endoftext|>


<commit_before>/* vim: set ts=2 expandtab: */
/**
 *       @file  test.cpp
 *      @brief
 *
 *     @author  Josh King (jheretic), jking@chambana.net
 *
 *   @internal
 *      Created  11/17/2013 06:01:11 PM
 *     Compiler  gcc/g++
 * Organization  The Open Technology Institute
 *    Copyright  Copyright (c) 2013, Josh King
 *
 * This file is part of Commotion, Copyright (c) 2013, Josh King
 *
 * Commotion 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, either version 3 of the License,
 * or (at your option) any later version.
 *
 * Commotion 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 Commotion.  If not, see <http://www.gnu.org/licenses/>.
 *
 * =====================================================================================
 */
extern "C" {
#include "../src/obj.h"
#include "../src/list.h"
#include "../src/tree.h"
}
#include "gtest/gtest.h"

class ListTest : public ::testing::Test
{
  protected:
    co_obj_t *List16;
    co_obj_t *List32;
    void InsertObj();
    void DeleteObj();
    void FirstLast();
    co_obj_t *TestString1;
    co_obj_t *TestString2;
    co_obj_t *TestString3;
    co_obj_t *TestString4;
    co_obj_t *TestString5;
    co_obj_t *TestString6;

    int ret;
    co_obj_t *ptr;

    ListTest()
    {
      List16 = co_list16_create();
      List32 = co_list32_create();

      TestString1 = co_bin8_create("1TESTVALUE1", 12, 0);
      TestString2 = co_bin8_create("2TESTVALUE2", 12, 0);
      TestString3 = co_bin8_create("3TESTVALUE3", 12, 0);
      TestString4 = co_bin8_create("4TESTVALUE4", 12, 0);
      TestString5 = co_bin8_create("5TESTVALUE5", 12, 0);
      TestString6 = co_bin8_create("6TESTVALUE6", 12, 0);

      ret = 0;
      ptr = NULL;
    }

    virtual void SetUp()
    {
    }

    ~ListTest()
    {
      co_obj_free(List16);
      co_obj_free(List32);
    }
};

void ListTest::InsertObj()
{
  ret = co_list_append(List16, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List16, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List16, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List16, TestString2);
  ASSERT_EQ(1, ret);

  // insert before
  ret = co_list_insert_before(List16, TestString3, TestString1);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List16);
  ASSERT_EQ(ptr, TestString3);

  // insert after
  ret = co_list_insert_after(List16, TestString4, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List16, TestString4);
  ASSERT_EQ(1, ret);

  // append
  ret = co_list_append(List16, TestString5);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_last(List16);
  ASSERT_EQ(ptr, TestString5);

  // prepend
  ret = co_list_prepend(List16, TestString6);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List16);
  ASSERT_EQ(ptr, TestString6);

  // repeat for List32
  ret = co_list_append(List32, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List32, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List32, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List32, TestString2);
  ASSERT_EQ(1, ret);

  // insert before
  ret = co_list_insert_before(List32, TestString3, TestString1);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List32);
  ASSERT_EQ(ptr, TestString3);

  // insert after
  ret = co_list_insert_after(List32, TestString4, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List32, TestString4);
  ASSERT_EQ(1, ret);

  // append
  ret = co_list_append(List32, TestString5);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_last(List32);
  ASSERT_EQ(ptr, TestString5);

  // prepend
  ret = co_list_prepend(List32, TestString6);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List32);
  ASSERT_EQ(ptr, TestString6);
}

void ListTest::DeleteObj()
{
  ret = co_list_append(List16, TestString1);
  ASSERT_EQ(1, ret);

  co_obj_t *ptr = co_list_delete(List16, TestString1);
  ASSERT_EQ(TestString1, ptr);

  ret = co_list_append(List16, TestString2);
  ASSERT_EQ(1, ret);

  ptr = co_list_delete(List16, TestString2);
  ASSERT_EQ(TestString2, ptr);

  // confirm deletions
  ret = co_list_contains(List16, TestString1);
  ASSERT_EQ(0, ret);

  ret = co_list_contains(List16, TestString1);
  ASSERT_EQ(0, ret);

  // repeat for List32
  ret = co_list_append(List32, TestString1);
  ASSERT_EQ(1, ret);

  ptr = co_list_delete(List32, TestString1);
  ASSERT_EQ(TestString1, ptr);

  ret = co_list_append(List32, TestString2);
  ASSERT_EQ(1, ret);

  ptr = co_list_delete(List32, TestString2);
  ASSERT_EQ(TestString2, ptr);

  // confirm deletions
  ret = co_list_contains(List32, TestString1);
  ASSERT_EQ(0, ret);

  ret = co_list_contains(List32, TestString1);
  ASSERT_EQ(0, ret);
}

void ListTest::FirstLast()
{
  ret = co_list_append(List16, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List16, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List16, TestString3);
  ASSERT_EQ(1, ret);

  // get first node
  ptr = co_list_get_first(List16);
  ASSERT_EQ(TestString1, ptr);

  // get last node
  ptr = co_list_get_last(List16);
  ASSERT_EQ(TestString3, ptr);

  // repeat for List32
  ret = co_list_append(List32, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List32, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List32, TestString3);
  ASSERT_EQ(1, ret);

  // get first node
  ptr = co_list_get_first(List32);
  ASSERT_EQ(TestString1, ptr);

  // get last node
  ptr = co_list_get_last(List32);
  ASSERT_EQ(TestString3, ptr);
}

TEST_F(ListTest, ListInsertTest)
{
  InsertObj();
}

TEST_F(ListTest, ListDeleteTest)
{
  DeleteObj();
}

TEST_F(ListTest, FirstLast)
{
  FirstLast();
}<commit_msg>added specific retrieval tests<commit_after>/* vim: set ts=2 expandtab: */
/**
 *       @file  test.cpp
 *      @brief
 *
 *     @author  Josh King (jheretic), jking@chambana.net
 *
 *   @internal
 *      Created  11/17/2013 06:01:11 PM
 *     Compiler  gcc/g++
 * Organization  The Open Technology Institute
 *    Copyright  Copyright (c) 2013, Josh King
 *
 * This file is part of Commotion, Copyright (c) 2013, Josh King
 *
 * Commotion 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, either version 3 of the License,
 * or (at your option) any later version.
 *
 * Commotion 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 Commotion.  If not, see <http://www.gnu.org/licenses/>.
 *
 * =====================================================================================
 */
extern "C" {
#include "../src/obj.h"
#include "../src/list.h"
#include "../src/tree.h"
}
#include "gtest/gtest.h"

class ListTest : public ::testing::Test
{
  protected:
    co_obj_t *List16;
    co_obj_t *List32;
    void InsertObj();
    void DeleteObj();
    void FirstLast();
    co_obj_t *TestString1;
    co_obj_t *TestString2;
    co_obj_t *TestString3;
    co_obj_t *TestString4;
    co_obj_t *TestString5;
    co_obj_t *TestString6;

    int ret;
    co_obj_t *ptr;

    ListTest()
    {
      List16 = co_list16_create();
      List32 = co_list32_create();

      TestString1 = co_bin8_create("1TESTVALUE1", 12, 0);
      TestString2 = co_bin8_create("2TESTVALUE2", 12, 0);
      TestString3 = co_bin8_create("3TESTVALUE3", 12, 0);
      TestString4 = co_bin8_create("4TESTVALUE4", 12, 0);
      TestString5 = co_bin8_create("5TESTVALUE5", 12, 0);
      TestString6 = co_bin8_create("6TESTVALUE6", 12, 0);

      ret = 0;
      ptr = NULL;
    }

    virtual void SetUp()
    {
    }

    ~ListTest()
    {
      co_obj_free(List16);
      co_obj_free(List32);
    }
};

void ListTest::InsertObj()
{
  ret = co_list_append(List16, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List16, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List16, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List16, TestString2);
  ASSERT_EQ(1, ret);

  // insert before
  ret = co_list_insert_before(List16, TestString3, TestString1);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List16);
  ASSERT_EQ(ptr, TestString3);

  // insert after
  ret = co_list_insert_after(List16, TestString4, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List16, TestString4);
  ASSERT_EQ(1, ret);

  // append
  ret = co_list_append(List16, TestString5);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_last(List16);
  ASSERT_EQ(ptr, TestString5);

  // prepend
  ret = co_list_prepend(List16, TestString6);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List16);
  ASSERT_EQ(ptr, TestString6);

  // repeat for List32
  ret = co_list_append(List32, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List32, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List32, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List32, TestString2);
  ASSERT_EQ(1, ret);

  // insert before
  ret = co_list_insert_before(List32, TestString3, TestString1);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List32);
  ASSERT_EQ(ptr, TestString3);

  // insert after
  ret = co_list_insert_after(List32, TestString4, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_contains(List32, TestString4);
  ASSERT_EQ(1, ret);

  // append
  ret = co_list_append(List32, TestString5);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_last(List32);
  ASSERT_EQ(ptr, TestString5);

  // prepend
  ret = co_list_prepend(List32, TestString6);
  ASSERT_EQ(1, ret);

  ptr = co_list_get_first(List32);
  ASSERT_EQ(ptr, TestString6);
}

void ListTest::DeleteObj()
{
  ret = co_list_append(List16, TestString1);
  ASSERT_EQ(1, ret);

  co_obj_t *ptr = co_list_delete(List16, TestString1);
  ASSERT_EQ(TestString1, ptr);

  ret = co_list_append(List16, TestString2);
  ASSERT_EQ(1, ret);

  ptr = co_list_delete(List16, TestString2);
  ASSERT_EQ(TestString2, ptr);

  // confirm deletions
  ret = co_list_contains(List16, TestString1);
  ASSERT_EQ(0, ret);

  ret = co_list_contains(List16, TestString1);
  ASSERT_EQ(0, ret);

  // repeat for List32
  ret = co_list_append(List32, TestString1);
  ASSERT_EQ(1, ret);

  ptr = co_list_delete(List32, TestString1);
  ASSERT_EQ(TestString1, ptr);

  ret = co_list_append(List32, TestString2);
  ASSERT_EQ(1, ret);

  ptr = co_list_delete(List32, TestString2);
  ASSERT_EQ(TestString2, ptr);

  // confirm deletions
  ret = co_list_contains(List32, TestString1);
  ASSERT_EQ(0, ret);

  ret = co_list_contains(List32, TestString1);
  ASSERT_EQ(0, ret);
}

void ListTest::FirstLast()
{
  ret = co_list_append(List16, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List16, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List16, TestString3);
  ASSERT_EQ(1, ret);

  // get first node
  ptr = co_list_get_first(List16);
  ASSERT_EQ(TestString1, ptr);

  // get last node
  ptr = co_list_get_last(List16);
  ASSERT_EQ(TestString3, ptr);

  // get specific nodes
  ptr = co_list_element(List16, 1);
  ASSERT_EQ(TestString2, ptr);

  ptr = co_list_element(List16, 2);
  ASSERT_EQ(TestString3, ptr);

  // repeat for List32
  ret = co_list_append(List32, TestString1);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List32, TestString2);
  ASSERT_EQ(1, ret);

  ret = co_list_append(List32, TestString3);
  ASSERT_EQ(1, ret);

  // get first node
  ptr = co_list_get_first(List32);
  ASSERT_EQ(TestString1, ptr);

  // get last node
  ptr = co_list_get_last(List32);
  ASSERT_EQ(TestString3, ptr);

  // get specific nodes
  ptr = co_list_element(List32, 1);
  ASSERT_EQ(TestString2, ptr);

  ptr = co_list_element(List32, 2);
  ASSERT_EQ(TestString3, ptr);
}

TEST_F(ListTest, ListInsertTest)
{
  InsertObj();
}

TEST_F(ListTest, ListDeleteTest)
{
  DeleteObj();
}

TEST_F(ListTest, FirstLast)
{
  FirstLast();
}<|endoftext|>


<commit_before>#include "step.h"
#include "game/systems_stateless/item_system.h"
#include "cosmos.h"

#include "game/transcendental/types_specification/all_messages_includes.h"

augs::variable_delta viewing_step::get_delta() const {
	return delta;
}

viewing_step::viewing_step(
	const cosmos& cosm,
	const immediate_hud& hud,
	aabb_highlighter& world_hover_highlighter,
	const augs::variable_delta& delta,
	augs::renderer& renderer,
	state_for_drawing_camera camera_state) : cosm(cosm), hud(hud), world_hover_highlighter(world_hover_highlighter), delta(delta), renderer(renderer), camera_state(camera_state) {}

vec2 viewing_step::get_screen_space(vec2 pos) const {
	return pos - camera_state.transformed_visible_world_area_aabb.get_position();
}

const cosmos& viewing_step::get_cosmos() const {
	return cosm;
}

logic_step::logic_step(cosmos& cosm, const cosmic_entropy& entropy, storage_for_all_message_queues& messages) : cosm(cosm), entropy(entropy), messages(messages) {}

augs::fixed_delta logic_step::get_delta() const {
	return cosm.get_fixed_delta();
}

cosmos& logic_step::get_cosmos() const {
	return cosm;
}<commit_msg>build fixes to step<commit_after>#include "step.h"
#include "game/systems_stateless/item_system.h"
#include "cosmos.h"

#include "game/transcendental/types_specification/all_messages_includes.h"

augs::variable_delta viewing_step::get_delta() const {
	return delta;
}

viewing_step::viewing_step(
	const cosmos& cosm,
	const immediate_hud& hud,
	aabb_highlighter& world_hover_highlighter,
	const augs::variable_delta& delta,
	augs::renderer& renderer,
	state_for_drawing_camera camera_state)
	:
	const_cosmic_step(cosm),
	hud(hud),
	world_hover_highlighter(world_hover_highlighter),
	delta(delta), renderer(renderer), camera_state(camera_state)
	{}

vec2 viewing_step::get_screen_space(vec2 pos) const {
	return pos - camera_state.transformed_visible_world_area_aabb.get_position();
}

logic_step::logic_step(cosmos& cosm, const cosmic_entropy& entropy, storage_for_all_message_queues& messages) : cosmic_step(cosm), entropy(entropy), messages(messages) {}

augs::fixed_delta logic_step::get_delta() const {
	return cosm.get_fixed_delta();
}<|endoftext|>