blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
listlengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
listlengths
1
16
author_lines
listlengths
1
16
7c55a3507d91f82c9705abe0d9265de52fc6fa25
580738f96494d426d6e5973c5b3493026caf8b6a
/Include/Vcl/stredit.hpp
ac8291d6b2b57373b4f7ec19c53e4536c7a8dcac
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
4,649
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'StrEdit.pas' rev: 6.00 #ifndef StrEditHPP #define StrEditHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <Menus.hpp> // Pascal unit #include <ComCtrls.hpp> // Pascal unit #include <ExtCtrls.hpp> // Pascal unit #include <StdCtrls.hpp> // Pascal unit #include <DesignIntf.hpp> // Pascal unit #include <DesignEditors.hpp> // Pascal unit #include <Dialogs.hpp> // Pascal unit #include <Buttons.hpp> // Pascal unit #include <Controls.hpp> // Pascal unit #include <Forms.hpp> // Pascal unit #include <Graphics.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <Windows.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Stredit { //-- type declarations ------------------------------------------------------- class DELPHICLASS TStrEditDlg; class PASCALIMPLEMENTATION TStrEditDlg : public Forms::TForm { typedef Forms::TForm inherited; __published: Stdctrls::TButton* CodeWndBtn; Dialogs::TOpenDialog* OpenDialog; Dialogs::TSaveDialog* SaveDialog; Stdctrls::TButton* HelpButton; Stdctrls::TButton* OKButton; Stdctrls::TButton* CancelButton; Menus::TPopupMenu* StringEditorMenu; Menus::TMenuItem* LoadItem; Menus::TMenuItem* SaveItem; Menus::TMenuItem* CodeEditorItem; void __fastcall FileOpen(System::TObject* Sender); void __fastcall FileSave(System::TObject* Sender); void __fastcall HelpButtonClick(System::TObject* Sender); void __fastcall CodeWndBtnClick(System::TObject* Sender); protected: bool FModified; virtual Classes::TStrings* __fastcall GetLines(void) = 0 ; virtual void __fastcall SetLines(const Classes::TStrings* Value) = 0 ; virtual Controls::TWinControl* __fastcall GetLinesControl(void) = 0 ; public: __property Classes::TStrings* Lines = {read=GetLines, write=SetLines}; public: #pragma option push -w-inl /* TCustomForm.Create */ inline __fastcall virtual TStrEditDlg(Classes::TComponent* AOwner) : Forms::TForm(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomForm.CreateNew */ inline __fastcall virtual TStrEditDlg(Classes::TComponent* AOwner, int Dummy) : Forms::TForm(AOwner, Dummy) { } #pragma option pop #pragma option push -w-inl /* TCustomForm.Destroy */ inline __fastcall virtual ~TStrEditDlg(void) { } #pragma option pop public: #pragma option push -w-inl /* TWinControl.CreateParented */ inline __fastcall TStrEditDlg(HWND ParentWindow) : Forms::TForm(ParentWindow) { } #pragma option pop }; class DELPHICLASS TStringListProperty; class PASCALIMPLEMENTATION TStringListProperty : public Designeditors::TClassProperty { typedef Designeditors::TClassProperty inherited; protected: virtual TStrEditDlg* __fastcall EditDialog(void); virtual Classes::TStrings* __fastcall GetStrings(void); virtual void __fastcall SetStrings(const Classes::TStrings* Value); public: virtual Designintf::TPropertyAttributes __fastcall GetAttributes(void); virtual void __fastcall Edit(void); public: #pragma option push -w-inl /* TPropertyEditor.Create */ inline __fastcall virtual TStringListProperty(const Designintf::_di_IDesigner ADesigner, int APropCount) : Designeditors::TClassProperty(ADesigner, APropCount) { } #pragma option pop #pragma option push -w-inl /* TPropertyEditor.Destroy */ inline __fastcall virtual ~TStringListProperty(void) { } #pragma option pop }; class DELPHICLASS TValueListProperty; class PASCALIMPLEMENTATION TValueListProperty : public TStringListProperty { typedef TStringListProperty inherited; protected: virtual TStrEditDlg* __fastcall EditDialog(void); public: #pragma option push -w-inl /* TPropertyEditor.Create */ inline __fastcall virtual TValueListProperty(const Designintf::_di_IDesigner ADesigner, int APropCount) : TStringListProperty(ADesigner, APropCount) { } #pragma option pop #pragma option push -w-inl /* TPropertyEditor.Destroy */ inline __fastcall virtual ~TValueListProperty(void) { } #pragma option pop }; //-- var, const, procedure --------------------------------------------------- } /* namespace Stredit */ using namespace Stredit; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // StrEdit
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 133 ] ] ]
2e0ee0d7972dbc72ac86956b3d1852f979492c69
a381a69db3bd4f37266bf0c7129817ebb999e7b8
/vdash/ImgConvert.cpp
2cae5366b1f70ac36a14e54bbbfddd2b8eaaceea
[]
no_license
oukiar/vdash
4420d6d6b462b7a833929b59d1ca232bd410e632
d2bff3090c7d1c081d5b7ab41abb963f03d6118b
refs/heads/master
2021-01-10T06:00:03.653067
2011-12-29T10:19:01
2011-12-29T10:19:01
49,607,897
0
0
null
null
null
null
UTF-8
C++
false
false
566
cpp
#include "stdafx.h" #include "ImgConvert.h" HRESULT ImgConvert(const char *srcFilename, const char * dstFilename, D3DXIMAGE_FILEFORMAT fmt){ #if 0 LPDIRECT3DTEXTURE9 texture = NULL; HRESULT hr= D3DXCreateTextureFromFileExA( g_pd3dDevice, srcFilename, 1280, 720, 1, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT , D3DX_FILTER_BOX , D3DX_FILTER_BOX , 0, NULL, NULL, &texture ); if(SUCCEEDED(hr)){ return D3DXSaveTextureToFileA(dstFilename,fmt,texture,NULL); } #endif return E_FAIL; }
[ [ [ 1, 31 ] ] ]
3923e8977ba7ce87eb3f7a3252b632ed9828dd99
993635387a5f4868e442df7d4a0d87cc215069c1
/OMV/PropertySystem/BaseProperty.h
0b5ad982b1e4c73f666c66442c6e7dce95b412cd
[]
no_license
windrobin/ogremeshviewer
90475b25f53f9d1aee821c150a8517ee4ee4d37d
679a2979320af09469894a6d99a90ec1adc5f658
refs/heads/master
2021-01-10T02:18:50.523143
2011-02-16T01:06:03
2011-02-16T01:06:03
43,444,741
0
2
null
null
null
null
GB18030
C++
false
false
5,199
h
/*============================================================================= * Copyright (C) 2006-2008, Zhang Kun. All Rights Reserved. * * File name: * BaseProperty.h * Description: * * Revision history: * 2006-7-13 * Created by Zhang Kun * Created =============================================================================*/ #pragma once #include "PreInclude.h" #include <Ogre/OgreString.h> #include <Ogre/OgreVector2.h> #include <Ogre/OgreVector3.h> #include <Ogre/OgreVector4.h> #include <Ogre/OgreColourValue.h> #include <Ogre/OgreQuaternion.h> #include <Ogre/OgreMatrix3.h> #include <Ogre/OgreMatrix4.h> namespace PropertySys { enum ePropertyType { eptBool, eptByte, // char eptShort, eptInt, eptLong, eptPtr, // pointer eptOgreReal, eptOgreString, //Ogre String eptOgreVector2, //Ogre Vector2 eptOgreVector3, //Ogre Vector3 eptOgreVector4, //Ogre Vector4 eptOgreColorValue, //Ogre ColorValue eptOgreQuaternion, //Ogre Quaternion eptOgreMatrix3, //Ogre Matrix3 eptOgreMatrix4, //Ogre Matrix4 eptMAX }; // This template class will associate compile-time types with unique enum members. template <class ValueType> class PropertyType { public : // Returns type ID associated with the template type. static ePropertyType GetTypeID(); private: static ePropertyType s_TypeID; }; template<class ValueType> ePropertyType PropertyType<ValueType>::GetTypeID() { return s_TypeID; } template<class ValueType> ePropertyType PropertyType<ValueType>::s_TypeID = eptPtr; template<> ePropertyType PropertyType<bool>::s_TypeID = eptBool; template<> ePropertyType PropertyType<char>::s_TypeID = eptByte; template<> ePropertyType PropertyType<short>::s_TypeID = eptShort; template<> ePropertyType PropertyType<int>::s_TypeID = eptInt; template<> ePropertyType PropertyType<long>::s_TypeID = eptLong; template<> ePropertyType PropertyType<Ogre::Real>::s_TypeID = eptOgreReal; template<> ePropertyType PropertyType<Ogre::String>::s_TypeID = eptOgreString; template<> ePropertyType PropertyType<Ogre::Vector2>::s_TypeID = eptOgreVector2; template<> ePropertyType PropertyType<Ogre::Vector3>::s_TypeID = eptOgreVector3; template<> ePropertyType PropertyType<Ogre::Vector4>::s_TypeID = eptOgreVector4; template<> ePropertyType PropertyType<Ogre::ColourValue>::s_TypeID = eptOgreColorValue; template<> ePropertyType PropertyType<Ogre::Quaternion>::s_TypeID = eptOgreQuaternion; template<> ePropertyType PropertyType<Ogre::Matrix3>::s_TypeID = eptOgreMatrix3; template<> ePropertyType PropertyType<Ogre::Matrix4>::s_TypeID = eptOgreMatrix4; enum EValueSpecify { eSpecifyNone, eValueRange, // value must in a range eValueList, // value must in a list eFilePathName, // value is disk file name eValueColor // value is color }; // Base class for all properties. class PROPERTYSYSTEM_API BaseProperty { public: enum EPropertyFlag { eReadOnly = 1 << 0, // property is read only eSerializable = 1 << 1, // property can be saved into to file eEditable = 1 << 2, // property can be seen in editor eNetworkSerializable = 1 << 4, // do synchronization through network eDefault = eSerializable | eEditable }; // Constructor. Takes in property name. BaseProperty() { _eValueSpecify = eSpecifyNone; } // Returns the type of this property. virtual ePropertyType GetTypeID() const = 0; size_t GetOffset() const { return _szOffset; } std::string GetName() const { return _strName; } std::string GetCategory() const { return _strCategory; } std::string GetDescription()const { return _strDescription; } std::string GetOwner() const { return _strOwner; } unsigned int GetFlag() const { return _uFlag; } int GetStartVersion() const { return _iStartClassVersion; } bool IsSerializeable() const { return (_uFlag & eSerializable) != 0; } bool IsNetworkSerializeable() const { return (_uFlag & eNetworkSerializable) != 0; } bool IsReadOnly() const { return (_uFlag & eReadOnly) != 0; } bool IsEditable() const { return (_uFlag & eEditable) != 0; } bool IsCommonProperty() const { return _bCommonProperty; } EValueSpecify GetValueSpecify(){ return _eValueSpecify; } void SetValueSpecify(EValueSpecify e, const std::string& str); const std::vector<std::string>& GetSpeValues(){ return _ValueSpecifies; } protected: std::string _strName; // 属性名 unsigned int _uFlag; // 标记 size_t _szOffset; // 偏移量 std::string _strCategory; // 类别 std::string _strOwner; // 宿主类名 std::string _strDescription; // 描述 int _iStartClassVersion; // 支持的宿主类的最低版本 bool _bCommonProperty; // 是否是简单属性 EValueSpecify _eValueSpecify; // 取值范围、列表等 std::string _strValueSpecify; // 取值描述<s;e>、<a;b;c;d> std::vector<std::string> _ValueSpecifies; }; }
[ "zhk.tiger@b3cfb0ba-c873-51ca-4d9f-db82523f9d23" ]
[ [ [ 1, 168 ] ] ]
37b1323f02c9a104c3fb280f6e4a860404990196
5e0422794380a8f3bf06d0c37ac2354f4b91fefb
/libfast/tcp_session.cpp
9f28c28e5f64f2127d1c2b017bc1c218db8930cc
[]
no_license
OrAlien/fastnetwork
1d8fb757b855b1f23cc844cda4d8dc7a568bc38e
792d28d8b5829c227aebe8378f60db17de4d6f14
refs/heads/master
2021-05-28T20:30:24.031458
2010-06-02T14:30:04
2010-06-02T14:30:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,352
cpp
#include "StdAfx.h" #include "tcp_session.h" #include "session_handler.h" #include "session_accept_handler.h" void fastnetwork::tcp_session::close() { connected = false; so->close(); } void fastnetwork::tcp_session::handle_read( const error_code & error, size_t bytes ) { if( ! handler->session_read(shared_from_this(), read_buffer, error, bytes ) ) { return ; } start_read(); } void fastnetwork::tcp_session::handle_written( write_buffer_ptr msg, const error_code & error, size_t bytes ) { if( ! handler->session_written( shared_from_this(), msg, error, bytes ) ) { return ; } } void fastnetwork::tcp_session::handle_connected( const error_code & error ) { if ( ! handler->session_connected(shared_from_this(), error) ) { so->close(); return ; } connected = true; } void fastnetwork::tcp_session::start_read() { cout << "reading data..." << endl; async_read( *(so.get()), read_buffer, boost::asio::transfer_at_least(1), ::boost::bind( &tcp_session::handle_read, this, placeholders::error, placeholders::bytes_transferred ) ); } void fastnetwork::tcp_session::do_write( write_buffer_ptr &msg ) { async_write( *(so.get()), buffer( *(msg.get()) ), ::boost::bind( & tcp_session::handle_written, this, msg, placeholders::error, placeholders::bytes_transferred ) ); }
[ "everwanna@8b0bd7a0-72c1-11de-90d8-1fdda9445408" ]
[ [ [ 1, 51 ] ] ]
5410beb471d0c92665fd08a46e01d89934ecb607
b2fa537cef03244de283e231932f22ee41aec051
/src/agg/agg_basics.h
3ed3a3b1639d436a7f62da02e4d1575937fa1d8f
[]
no_license
rebolsource/r3-hostkit
2e0037119cde8a161e2f7994fd3842cc3891e9d5
f331c6a46947e6e5afedc90f3d375bcd3f7ad8a1
refs/heads/master
2021-01-10T18:34:50.420402
2010-09-09T18:38:59
2010-09-10T11:59:58
813,301
0
0
null
null
null
null
UTF-8
C++
false
false
10,959
h
//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: [email protected] // [email protected] // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_BASICS_INCLUDED #define AGG_BASICS_INCLUDED #include "agg_config.h" //-------------------------------------------------------- Default basic types // // If the compiler has different capacity of the basic types you can redefine // them via the compiler command line or by generating agg_config.h that is // empty by default. // #ifndef AGG_INT8 #define AGG_INT8 signed char #endif #ifndef AGG_INT8U #define AGG_INT8U unsigned char #endif #ifndef AGG_INT16 #define AGG_INT16 short #endif #ifndef AGG_INT16U #define AGG_INT16U unsigned short #endif #ifndef AGG_INT32 #define AGG_INT32 int #endif #ifndef AGG_INT32U #define AGG_INT32U unsigned #endif #ifndef AGG_INT64 #if defined(_MSC_VER) || defined(__BORLANDC__) #define AGG_INT64 signed __int64 #else #define AGG_INT64 signed long long #endif #endif #ifndef AGG_INT64U #if defined(_MSC_VER) || defined(__BORLANDC__) #define AGG_INT64U unsigned __int64 #else #define AGG_INT64U unsigned long long #endif #endif //------------------------------------------------ Some fixes for MS Visual C++ #if defined(_MSC_VER) #pragma warning(disable:4786) // Identifier was truncated... #endif //#if defined(_MSC_VER) //#define AGG_INLINE __forceinline //#else #define AGG_INLINE inline //#endif namespace agg { //------------------------------------------------------------------------- typedef AGG_INT8 int8; //----int8 typedef AGG_INT8U int8u; //----int8u typedef AGG_INT16 int16; //----int16 typedef AGG_INT16U int16u; //----int16u typedef AGG_INT32 int32; //----int32 typedef AGG_INT32U int32u; //----int32u typedef AGG_INT64 int64; //----int64 typedef AGG_INT64U int64u; //----int64u //------------------------------------------------------------------------- typedef unsigned char cover_type; //----cover_type enum cover_scale_e { cover_shift = 8, //----cover_shift cover_size = 1 << cover_shift, //----cover_size cover_mask = cover_size - 1, //----cover_mask cover_none = 0, //----cover_none cover_full = cover_mask //----cover_full }; //-----------------------------------------------------------------------pi const double pi = 3.14159265358979323846; //------------------------------------------------------------------deg2rad inline double deg2rad(double deg) { return deg * pi / 180.0; } //------------------------------------------------------------------rad2deg inline double rad2deg(double rad) { return rad * 180.0 / pi; } //----------------------------------------------------------------rect_base template<class T> struct rect_base { typedef rect_base<T> self_type; T x1; T y1; T x2; T y2; rect_base() {} rect_base(T x1_, T y1_, T x2_, T y2_) : x1(x1_), y1(y1_), x2(x2_), y2(y2_) {} const self_type& normalize() { T t; if(x1 > x2) { t = x1; x1 = x2; x2 = t; } if(y1 > y2) { t = y1; y1 = y2; y2 = t; } return *this; } bool clip(const self_type& r) { if(x2 > r.x2) x2 = r.x2; if(y2 > r.y2) y2 = r.y2; if(x1 < r.x1) x1 = r.x1; if(y1 < r.y1) y1 = r.y1; return x1 <= x2 && y1 <= y2; } bool is_valid() const { return x1 <= x2 && y1 <= y2; } }; //-----------------------------------------------------intersect_rectangles template<class Rect> inline Rect intersect_rectangles(const Rect& r1, const Rect& r2) { Rect r = r1; // First process x2,y2 because the other order // results in Internal Compiler Error under // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in // case of "Maximize Speed" optimization option. //----------------- if(r.x2 > r2.x2) r.x2 = r2.x2; if(r.y2 > r2.y2) r.y2 = r2.y2; if(r.x1 < r2.x1) r.x1 = r2.x1; if(r.y1 < r2.y1) r.y1 = r2.y1; return r; } //---------------------------------------------------------unite_rectangles template<class Rect> inline Rect unite_rectangles(const Rect& r1, const Rect& r2) { Rect r = r1; if(r.x2 < r2.x2) r.x2 = r2.x2; if(r.y2 < r2.y2) r.y2 = r2.y2; if(r.x1 > r2.x1) r.x1 = r2.x1; if(r.y1 > r2.y1) r.y1 = r2.y1; return r; } typedef rect_base<int> rect; //----rect typedef rect_base<double> rect_d; //----rect_d //---------------------------------------------------------path_commands_e enum path_commands_e { path_cmd_stop = 0, //----path_cmd_stop path_cmd_move_to = 1, //----path_cmd_move_to path_cmd_line_to = 2, //----path_cmd_line_to path_cmd_curve3 = 3, //----path_cmd_curve3 path_cmd_curve4 = 4, //----path_cmd_curve4 path_cmd_curveN = 5, //----path_cmd_curveN path_cmd_catrom = 6, //----path_cmd_catrom path_cmd_ubspline = 7, //----path_cmd_ubspline path_cmd_end_poly = 0x0F, //----path_cmd_end_poly path_cmd_mask = 0x0F //----path_cmd_mask }; //------------------------------------------------------------path_flags_e enum path_flags_e { path_flags_none = 0, //----path_flags_none path_flags_ccw = 0x10, //----path_flags_ccw path_flags_cw = 0x20, //----path_flags_cw path_flags_close = 0x40, //----path_flags_close path_flags_mask = 0xF0 //----path_flags_mask }; //---------------------------------------------------------------is_vertex inline bool is_vertex(unsigned c) { return c >= path_cmd_move_to && c < path_cmd_end_poly; } //--------------------------------------------------------------is_drawing inline bool is_drawing(unsigned c) { return c >= path_cmd_line_to && c < path_cmd_end_poly; } //-----------------------------------------------------------------is_stop inline bool is_stop(unsigned c) { return c == path_cmd_stop; } //--------------------------------------------------------------is_move_to inline bool is_move_to(unsigned c) { return c == path_cmd_move_to; } //--------------------------------------------------------------is_line_to inline bool is_line_to(unsigned c) { return c == path_cmd_line_to; } //----------------------------------------------------------------is_curve inline bool is_curve(unsigned c) { return c == path_cmd_curve3 || c == path_cmd_curve4; } //---------------------------------------------------------------is_curve3 inline bool is_curve3(unsigned c) { return c == path_cmd_curve3; } //---------------------------------------------------------------is_curve4 inline bool is_curve4(unsigned c) { return c == path_cmd_curve4; } //-------------------------------------------------------------is_end_poly inline bool is_end_poly(unsigned c) { return (c & path_cmd_mask) == path_cmd_end_poly; } //----------------------------------------------------------------is_close inline bool is_close(unsigned c) { return (c & ~(path_flags_cw | path_flags_ccw)) == (path_cmd_end_poly | path_flags_close); } //------------------------------------------------------------is_next_poly inline bool is_next_poly(unsigned c) { return is_stop(c) || is_move_to(c) || is_end_poly(c); } //-------------------------------------------------------------------is_cw inline bool is_cw(unsigned c) { return (c & path_flags_cw) != 0; } //------------------------------------------------------------------is_ccw inline bool is_ccw(unsigned c) { return (c & path_flags_ccw) != 0; } //-------------------------------------------------------------is_oriented inline bool is_oriented(unsigned c) { return (c & (path_flags_cw | path_flags_ccw)) != 0; } //---------------------------------------------------------------is_closed inline bool is_closed(unsigned c) { return (c & path_flags_close) != 0; } //----------------------------------------------------------get_close_flag inline unsigned get_close_flag(unsigned c) { return c & path_flags_close; } //-------------------------------------------------------clear_orientation inline unsigned clear_orientation(unsigned c) { return c & ~(path_flags_cw | path_flags_ccw); } //---------------------------------------------------------get_orientation inline unsigned get_orientation(unsigned c) { return c & (path_flags_cw | path_flags_ccw); } //---------------------------------------------------------set_orientation inline unsigned set_orientation(unsigned c, unsigned o) { return clear_orientation(c) | o; } //--------------------------------------------------------------point_type struct point_type { double x, y; point_type() {} point_type(double x_, double y_) : x(x_), y(y_) {} }; //-------------------------------------------------------------vertex_type struct vertex_type { double x, y; unsigned cmd; vertex_type() {} vertex_type(double x_, double y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {} }; } #endif
[ [ [ 1, 352 ] ] ]
8e12b71cbd9b51e144d9ba94b9c25df04da32be2
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Common/langman.cpp
79614d00ca7461b22a55ee35f19ae5f29eb846b3
[]
no_license
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
3,393
cpp
#include "stdafx.h" #include "langman.h" #ifdef __LANG_1013 CLangMan::CLangMan() { } CLangMan::~CLangMan() { } BOOL CLangMan::Load( LPCTSTR lpszFileName ) { CScanner s; if( !s.Load( lpszFileName, TRUE ) ) return FALSE; DWORD dwLang = s.GetNumber(); // dwLang DWORD a, r, g, b; while( s.tok != FINISHED ) { ASSERT( dwLang < LANG_MAX ); PLANG_DATA pData = &m_aLangData[dwLang]; s.GetToken(); s.GetToken(); // szPath lstrcpy( pData->szPath, s.token ); s.GetToken(); s.GetToken(); // szFileName lstrcpy( pData->szFileName, s.token ); s.GetToken(); // szTitle lstrcpy( pData->szTitle, s.token ); s.GetToken(); s.GetToken(); // szFontFirst lstrcpy( pData->font.lfCaption.szFontFirst, s.token ); s.GetToken(); s.GetToken(); s.GetToken(); // szFontSecond lstrcpy( pData->font.lfCaption.szFontSecond, s.token ); s.GetToken(); pData->font.lfCaption.nDivTitle = s.GetNumber(); // nDivTitle pData->font.lfCaption.nDivCaption = s.GetNumber(); // nDivCaption pData->font.fdLang.charset = s.GetNumber(); // charset pData->font.fdLang.wCodePage = s.GetNumber(); // wCodePage s.GetToken(); s.GetToken(); lstrcpy( pData->font.fdLang.faceNT, s.token ); // faceNT s.GetToken(); s.GetToken(); s.GetToken(); lstrcpy( pData->font.fdLang.face9x, s.token ); // face9x s.GetToken(); s.GetToken(); s.GetToken(); // szFont0 lstrcpy( pData->font.afi[0].szFont, s.token ); s.GetToken(); s.GetToken(); s.GetToken(); // szFont1 lstrcpy( pData->font.afi[1].szFont, s.token ); s.GetToken(); s.GetToken(); s.GetToken(); // szFont2 lstrcpy( pData->font.afi[2].szFont, s.token ); s.GetToken(); s.GetToken(); s.GetToken(); // szFont3 lstrcpy( pData->font.afi[3].szFont, s.token ); s.GetToken(); a = s.GetNumber(); // dwBgColor3_a r = s.GetNumber(); // dwBgColor3_r g = s.GetNumber(); // dwBgColor3_g b = s.GetNumber(); // dwBgColor3_b pData->font.afi[3].dwBgColor = D3DCOLOR_ARGB( a, r, g, b ); pData->font.afi[3].nOutLine = s.GetNumber(); // nOutLine3 pData->font.afi[3].dwFlags = s.GetNumber(); // dwFlags3 s.GetToken(); s.GetToken(); // szFont4 lstrcpy( pData->font.afi[4].szFont, s.token ); s.GetToken(); a = s.GetNumber(); // dwBgColor4_a r = s.GetNumber(); // dwBgColor4_r g = s.GetNumber(); // dwBgColor4_g b = s.GetNumber(); // dwBgColor4_b pData->font.afi[4].dwBgColor = D3DCOLOR_ARGB( a, r, g, b ); pData->font.afi[4].nOutLine = s.GetNumber(); // nOutLine4 pData->font.afi[4].dwFlags = s.GetNumber(); // dwFlags4 s.GetToken(); s.GetToken(); // szFont5 lstrcpy( pData->font.afi[5].szFont, s.token ); s.GetToken(); a = s.GetNumber(); // dwBgColor5_a r = s.GetNumber(); // dwBgColor5_r g = s.GetNumber(); // dwBgColor5_g b = s.GetNumber(); // dwBgColor5_b pData->font.afi[5].dwBgColor = D3DCOLOR_ARGB( a, r, g, b ); pData->font.afi[5].nOutLine = s.GetNumber(); // nOutLine5 pData->font.afi[5].dwFlags = s.GetNumber(); // dwFlags5 dwLang = s.GetNumber(); // dwLang } return TRUE; } PLANG_DATA CLangMan::GetLangData( DWORD dwLang ) { ASSERT( dwLang < LANG_MAX ); return &m_aLangData[dwLang]; } CLangMan* CLangMan::GetInstance( void ) { static CLangMan sLocal; return &sLocal; } #endif // __LANG_1013
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 132 ] ] ]
0c399f1a1d520404bc5cf966b02f970c50fe21c4
8f889848ad8c34001b315c501938e17e630bb56d
/Text.cpp
7dd48655275bfb012300037cb9968b2eb29787a0
[ "MIT" ]
permissive
tylerc/Ignatus
08495dc94ab3b3741cbc20bc5ed613bba1379597
7ceb806554f5af4afa5b22af65bc8249071cfc50
refs/heads/master
2020-05-20T12:30:47.039753
2011-04-14T04:31:10
2011-04-14T04:31:10
1,602,368
2
1
null
null
null
null
UTF-8
C++
false
false
653
cpp
#include "All.hpp" namespace Ignatus{ Text::Text(std::string s, float size, std::string file="FreeSans.ttf") : GameObject(false) { Name = "Text"; AddName("Text"); Font = new sf::Font; if (!Font->LoadFromFile(file, (int)size)) { std::cout << "Couldn't load font " << file << std::endl; exit(1); } Label = new sf::String(s, *Font, size); Reset(); } void Text::Reset() { Dimensions.x = (int)Label->GetRect().GetWidth(); Dimensions.y = (int)Label->GetRect().GetHeight(); } void Text::Draw(sf::RenderWindow* App) { Label->SetPosition(Position.x, Position.y); App->Draw(*Label); } }
[ [ [ 1, 31 ] ] ]
b1e5b9cefe2271c0933f0df949df8db2671b57f2
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nscene/src/nscene/nscenegraph_cmds.cc
543d7b6838dab077d27c8aec1fa01b7f97f7d13d
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
36
cc
#include "precompiled/pchnscene.h"
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 1 ] ] ]
f08ab335d736f6c861733c7f0be07a55ad9eca83
e8d9619e262531453688550db22d0e78f1b51dab
/exip/main.cpp
a7753e1c5161fba9c49e334ae87621d611ae769e
[]
no_license
sje397/sje-miranda-plugins
e9c562f402daef2cfbe333ce9a8a888cd81c9573
effb7ea736feeab1c68db34a86da8a2be2b78626
refs/heads/master
2016-09-05T16:42:34.162442
2011-05-22T14:48:15
2011-05-22T14:48:15
1,784,020
2
1
null
null
null
null
WINDOWS-1252
C++
false
false
3,879
cpp
#include "common.h" #include "options.h" #include "getip.h" HINSTANCE hInst; PLUGINLINK *pluginLink; HANDLE hNetlibUser = 0; HANDLE mainThread; // plugin stuff PLUGININFO pluginInfo={ sizeof(PLUGININFO), "ExIP", PLUGIN_MAKE_VERSION(0, 0, 0, 1), "Retreive external IP address", "Scott Ellis", "[email protected]", "© 2005 Scott Ellis", "http://www.scottellis.com.au/", 0, //not transient 0 //doesn't replace anything built-in }; BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { hInst=hinstDLL; return TRUE; } extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) { return &pluginInfo; } unsigned long __stdcall GetIPThread(void *param) { RetreiveIP(); return 0; } /* bool power_message = false; LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); if(power_message) DrawText(hdc, "Power message!", strlen("Power message!"), &rt, DT_CENTER); else DrawText(hdc, "Hello world!", strlen("Hello world!"), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: case WM_CLOSE: DestroyWindow(hWnd); break; case WM_POWERBROADCAST: power_message = true; InvalidateRect(hWnd, 0, TRUE); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; //LoadIcon(hInstance, (LPCTSTR)IDI_SCREENDUMP); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = 0;//(LPCSTR)IDC_SCREENDUMP; wcex.lpszClassName = "TestPowerMessagesWindowClass"; wcex.hIconSm = 0;//LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } DWORD CALLBACK MessagePumpThread(LPVOID param) { CallService(MS_SYSTEM_THREAD_PUSH, 0, 0); MyRegisterClass(hInst); HWND hWnd = CreateWindow("TestPowerMessagesWindowClass", "Test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); MSG msg; // GetMessage returns -1 when hwndProgress is an invalid handle - so it exits when that window is destroyed while(GetMessage(&msg, hWnd, 0, 0) > 0 && !Miranda_Terminated()) { TranslateMessage(&msg); DispatchMessage(&msg); } CallService(MS_SYSTEM_THREAD_POP, 0, 0); return 0; } */ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { NETLIBUSER nl_user = {0}; nl_user.cbSize = sizeof(nl_user); nl_user.szSettingsModule = MODULE; nl_user.szDescriptiveName = "External IP"; nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS; hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); DWORD tid; CloseHandle(CreateThread(0, 0, GetIPThread, 0, 0, &tid)); //CloseHandle(CreateThread(0, 0, MessagePumpThread, 0, 0, &tid)); return 0; } extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) { pluginLink=link; DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 ); HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); HookEvent(ME_OPT_INITIALISE, OptInit ); return 0; } extern "C" __declspec(dllexport) int Unload(void) { CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); return 0; }
[ [ [ 1, 161 ] ] ]
0641881b6be5fe35953117696a4f946d91251458
4bdad21e723bba96bbdd1a736d27e4c54e20fcb3
/iPediaApplication.hpp
e8ac4d3943f66e2da7e897ba1c627433b364e017
[]
no_license
kjk/ipedia-sm
786b59be58f0364adcfb6a777f6bd4aac0b93d4d
97e22be5b859462d5cc8802182dcadf486c5e8ef
refs/heads/master
2016-09-06T19:47:35.305661
2005-05-09T11:12:09
2005-05-09T11:12:09
18,811
2
0
null
null
null
null
UTF-8
C++
false
false
3,756
hpp
#ifndef __WIN_IPEDIA_APPLICATION_HPP__ #define __WIN_IPEDIA_APPLICATION_HPP__ #include <windows.h> #include "iPediaHyperlinkHandler.hpp" #include <Logging.hpp> #include <SysUtils.hpp> #include <BaseTypes.hpp> using ArsLexis::char_t; class LookupManager; class LookupHistory; struct LookupFinishedEventData; struct DisplayAlertEventData { ushort_t alertId; DisplayAlertEventData(ushort_t aid): alertId(aid) {} DisplayAlertEventData(): alertId(0) {} }; struct ErrorInfo { int errorCode; const char_t * title; const char_t * message; ErrorInfo(int code, const char_t *tit, const char_t *msg) : errorCode(code), title(tit), message(msg) {} }; const char_t *getErrorTitle(int alertId); const char_t *getErrorMessage(int alertId); class iPediaApplication { ushort_t ticksPerSecond_; iPediaHyperlinkHandler hyperlinkHandler_; LookupHistory* history_; HINSTANCE hInst_; typedef std::list<ArsLexis::String> CustomAlerts_t; CustomAlerts_t customAlerts_; HWND hwndMain_; protected: bool handleApplicationEvent(ArsLexis::EventType& event); public: LookupManager* lookupManager; const char_t* serverAddress; bool fArticleCountChecked; #ifndef _PALM_OS // wince only SYSTEMTIME lastArticleCountCheckTime; #endif void savePreferences(); void loadPreferences(); iPediaApplication(); DWORD runEventLoop(); HWND getMainWindow() {return hwndMain_ ;} void setMainWindow(HWND hwndMain) {hwndMain_=hwndMain;} ~iPediaApplication(); bool fLookupInProgress() const; ushort_t ticksPerSecond() const {return ticksPerSecond_;} struct Preferences { enum {cookieLength=32}; ArsLexis::String cookie; enum {regCodeLength=32}; ArsLexis::String regCode; long articleCount; ArsLexis::String currentLang; ArsLexis::String availableLangs; Preferences(): articleCount(-1) {} ArsLexis::String databaseTime; }; Preferences& preferences() {return preferences_;} const Preferences& preferences() const {return preferences_;} enum { reservedLookupEventsCount=3 }; enum Event { appDisplayAlertEvent=WM_APP, appDisplayCustomAlertEvent, appLookupEventFirst, appLookupEventLast=appLookupEventFirst+reservedLookupEventsCount, appForceUpgrade, appLangNotAvailable, appFirstAvailableEvent }; static void sendDisplayAlertEvent(ushort_t alertId) {sendEvent(appDisplayAlertEvent, DisplayAlertEventData(alertId));} ArsLexis::String popCustomAlert(); void sendDisplayCustomAlertEvent(ushort_t alertId, const String& text1); static iPediaApplication& instance() {return instance_;} const LookupHistory& history() const { assert(0!=history_); return *history_; } iPediaHyperlinkHandler& hyperlinkHandler() {return hyperlinkHandler_;} void getErrorMessage(int alertId, bool customAlert, String& out); bool InitInstance (HINSTANCE hInstance, int CmdShow ); BOOL InitApplication ( HINSTANCE hInstance ); bool initApplication(HINSTANCE hInstance, HINSTANCE hPrevInstance, const String& cmdLine, int cmdShow); HINSTANCE getApplicationHandle() {return hInst_;} private: Preferences preferences_; static iPediaApplication instance_; bool logAllocation_; }; iPediaApplication& GetApp(); iPediaApplication::Preferences& GetPrefs(); #endif
[ "mareks@e1586a42-28db-0310-82f4-9a69bde6b091", "andrzejc@e1586a42-28db-0310-82f4-9a69bde6b091", "kjk@e1586a42-28db-0310-82f4-9a69bde6b091" ]
[ [ [ 1, 3 ], [ 6, 10 ], [ 13, 14 ], [ 16, 16 ], [ 42, 42 ], [ 47, 50 ], [ 52, 53 ], [ 55, 55 ], [ 71, 72 ], [ 74, 74 ], [ 77, 77 ], [ 82, 83 ], [ 86, 93 ], [ 96, 97 ], [ 103, 104 ], [ 108, 118 ], [ 122, 122 ], [ 130, 131 ], [ 134, 134 ], [ 138, 147 ], [ 160, 163 ], [ 165, 167 ], [ 171, 171 ] ], [ [ 4, 4 ], [ 57, 61 ], [ 105, 107 ], [ 132, 132 ], [ 136, 136 ], [ 150, 150 ], [ 153, 159 ] ], [ [ 5, 5 ], [ 11, 12 ], [ 15, 15 ], [ 17, 41 ], [ 43, 46 ], [ 51, 51 ], [ 54, 54 ], [ 56, 56 ], [ 62, 70 ], [ 73, 73 ], [ 75, 76 ], [ 78, 81 ], [ 84, 85 ], [ 94, 95 ], [ 98, 102 ], [ 119, 121 ], [ 123, 129 ], [ 133, 133 ], [ 135, 135 ], [ 137, 137 ], [ 148, 149 ], [ 151, 152 ], [ 164, 164 ], [ 168, 170 ] ] ]
0b45abacbe9e111382f9d0601bbe9fc4d3e653c9
1c9f99b2b2e3835038aba7ec0abc3a228e24a558
/Projects/elastix/elastix_sources_v4/src/Core/ComponentBaseClasses/elxRegistrationBase.hxx
e70373dd37c968eca1624f3279c78f6ff6d3ac9a
[]
no_license
mijc/Diploma
95fa1b04801ba9afb6493b24b53383d0fbd00b33
bae131ed74f1b344b219c0ffe0fffcd90306aeb8
refs/heads/master
2021-01-18T13:57:42.223466
2011-02-15T14:19:49
2011-02-15T14:19:49
1,369,569
0
0
null
null
null
null
UTF-8
C++
false
false
7,785
hxx
/*====================================================================== This file is part of the elastix software. Copyright (c) University Medical Center Utrecht. All rights reserved. See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. ======================================================================*/ #ifndef __elxRegistrationBase_hxx #define __elxRegistrationBase_hxx #include "elxRegistrationBase.h" namespace elastix { using namespace itk; /** * ********************* ReadMaskParameters ************************ */ template <class TElastix> bool RegistrationBase<TElastix> ::ReadMaskParameters( UseMaskErosionArrayType & useMaskErosionArray, const unsigned int nrOfMasks, const std::string & whichMask, const unsigned int level ) const { /** Read whether mask erosion is wanted, if any masks were supplied. */ /** Bool that remembers if mask erosion is wanted in any of the masks * remains false when no masks are used. This bool will be output. */ bool useMaskErosion = false; /** Array of bools, that remembers for each mask if erosion is wanted. */ useMaskErosionArray.resize( nrOfMasks, false ); /** "ErodeFixedMask" or "ErodeMovingMask". */ std::string whichErodeMaskOption( "Erode" ); whichErodeMaskOption += whichMask; whichErodeMaskOption += "Mask"; /** Read the parameters. */ if ( nrOfMasks > 0 ) { /** Default values for all masks. Look for ErodeMask, or Erode<Fixed,Moving>Mask. */ bool erosionOrNot = true; this->GetConfiguration()->ReadParameter( erosionOrNot, "ErodeMask", "", level, 0, false ); this->GetConfiguration()->ReadParameter( erosionOrNot, whichErodeMaskOption.c_str(), "", level, 0 ); if ( erosionOrNot ) { /** fill with 'true's. */ useMaskErosionArray.clear(); useMaskErosionArray.resize( nrOfMasks, true ); } /** Try to read an erode mask parameter given for a specified mask only: * (ErodeFixedMask0 "true" "false" ) for example. */ for ( unsigned int i = 0; i < nrOfMasks; ++i ) { std::ostringstream makestring; makestring << whichErodeMaskOption << i; // key for parameter file bool erosionOrNot_i = erosionOrNot; // default value this->GetConfiguration()->ReadParameter( erosionOrNot_i, makestring.str().c_str(), "", level, 0, false ); if ( erosionOrNot_i ) { useMaskErosionArray[ i ] = true; } else { useMaskErosionArray[ i ] = false; } /** Check if mask erosion is wanted in any of the masks. */ useMaskErosion |= useMaskErosionArray[ i ]; } } // end if nrOfMasks > 0 return useMaskErosion; } // end ReadMaskParameters() /** * ******************* GenerateFixedMaskSpatialObject ********************** */ template <class TElastix> typename RegistrationBase<TElastix>::FixedMaskSpatialObjectPointer RegistrationBase<TElastix> ::GenerateFixedMaskSpatialObject( const FixedMaskImageType * maskImage, bool useMaskErosion, const FixedImagePyramidType * pyramid, unsigned int level ) const { FixedMaskSpatialObjectPointer fixedMaskSpatialObject = 0; if ( !maskImage ) { return fixedMaskSpatialObject; } fixedMaskSpatialObject = FixedMaskSpatialObjectType::New(); /** Just convert to spatial object if no erosion is needed. */ if ( !useMaskErosion || !pyramid ) { fixedMaskSpatialObject->SetImage( maskImage ); return fixedMaskSpatialObject; } /** Erode, and convert to spatial object. */ FixedMaskErodeFilterPointer erosion = FixedMaskErodeFilterType::New(); erosion->SetInput( maskImage ); erosion->SetSchedule( pyramid->GetSchedule() ); erosion->SetIsMovingMask( false ); erosion->SetResolutionLevel( level ); /** Set output of the erosion to fixedImageMaskAsImage. */ FixedMaskImagePointer erodedFixedMaskAsImage = erosion->GetOutput(); /** Do the erosion. */ try { erodedFixedMaskAsImage->Update(); } catch( itk::ExceptionObject & excp ) { /** Add information to the exception. */ excp.SetLocation( "RegistrationBase - UpdateMasks()" ); std::string err_str = excp.GetDescription(); err_str += "\nError while eroding the fixed mask.\n"; excp.SetDescription( err_str ); /** Pass the exception to an higher level. */ throw excp; } /** Release some memory. */ erodedFixedMaskAsImage->DisconnectPipeline(); fixedMaskSpatialObject->SetImage( erodedFixedMaskAsImage ); return fixedMaskSpatialObject; } // end GenerateFixedMaskSpatialObject() /** * ******************* GenerateMovingMaskSpatialObject ********************** */ template <class TElastix> typename RegistrationBase<TElastix>::MovingMaskSpatialObjectPointer RegistrationBase<TElastix> ::GenerateMovingMaskSpatialObject( const MovingMaskImageType * maskImage, bool useMaskErosion, const MovingImagePyramidType * pyramid, unsigned int level ) const { MovingMaskSpatialObjectPointer movingMaskSpatialObject = 0; if ( !maskImage ) { return movingMaskSpatialObject; } movingMaskSpatialObject = MovingMaskSpatialObjectType::New(); /** Just convert to spatial object if no erosion is needed. */ if ( !useMaskErosion || !pyramid ) { movingMaskSpatialObject->SetImage( maskImage ); return movingMaskSpatialObject; } /** Erode, and convert to spatial object. */ MovingMaskErodeFilterPointer erosion = MovingMaskErodeFilterType::New(); erosion->SetInput( maskImage ); erosion->SetSchedule( pyramid->GetSchedule() ); erosion->SetIsMovingMask( true ); erosion->SetResolutionLevel( level ); /** Set output of the erosion to movingImageMaskAsImage. */ MovingMaskImagePointer erodedMovingMaskAsImage = erosion->GetOutput(); /** Do the erosion. */ try { erodedMovingMaskAsImage->Update(); } catch( itk::ExceptionObject & excp ) { /** Add information to the exception. */ excp.SetLocation( "RegistrationBase - UpdateMasks()" ); std::string err_str = excp.GetDescription(); err_str += "\nError while eroding the moving mask.\n"; excp.SetDescription( err_str ); /** Pass the exception to an higher level. */ throw excp; } /** Release some memory */ erodedMovingMaskAsImage->DisconnectPipeline(); movingMaskSpatialObject->SetImage( erodedMovingMaskAsImage ); return movingMaskSpatialObject; } // end GenerateMovingMaskSpatialObject() /** * ******************* AfterEachResolutionBase ********************** */ template <class TElastix> void RegistrationBase<TElastix> ::AfterEachResolutionBase( void ) { /** What is the current resolution level? */ const unsigned int level = this->m_Registration->GetAsITKBaseType()->GetCurrentLevel(); /** Release memory of the previous resolution. * This is already done in for example MultiResolutionImageRegistrationMethod2, * but perhaps we used another registration method that was not as careful * with memory. Therefore, we do it again. */ this->GetElastix()->GetElxFixedImagePyramidBase()->GetAsITKBaseType() ->GetOutput( level )->ReleaseData(); this->GetElastix()->GetElxMovingImagePyramidBase()->GetAsITKBaseType() ->GetOutput( level )->ReleaseData(); } // end AfterEachResolutionBase() } // end namespace elastix #endif // end #ifndef __elxRegistrationBase_hxx
[ [ [ 1, 243 ] ] ]
2be256a5e0afa080ae09c73159d184c2413e9742
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/Models/CONTROL2/OptLib/ZMatrixCode.hpp
3a649058bd43c8cfc3024dc3e34dd453e2edb86c
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,989
hpp
#ifndef Z_MATRIX_CODE_HPP #define Z_MATRIX_CODE_HPP //----------------------------------------------------------------------------- // This is the matrix template class. // The template type "Type" can be any sensible class or basic type, but must support // the following: // OPERATORS // Type + Type // Type += Type // Type*Type // Type *= Type // ostream << Type //----------------------------------------------------------------------------- #include <stdlib.h> #include "ZArr.hpp" #include "ZComplex.h" #include "ZException.hpp" #include "ZMatrix.hpp" //----------------------------------------------------------------------------- #ifdef DEBUG_MSG void print_ZMatrix_debug_msg(char *msg) { printf("ZMatrix::Debug:<%s>\n", msg); } #endif DEBUG_MSG //----------------------------------------------------------------------------- template <class Type> typename ZMatrix<Type>::EnumStreamMode ZMatrix<Type>::sm_enumDisplayMode = ZMatrix<Type>::smOneLine; //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type>::ZMatrix(int rows, int cols) { ZArr<Type> tempA(cols); prRows = rows; prCols = cols; prM = new ZArr<Type>[rows]; // Calls Default Constructor for each element of // array #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)prM, "ZMatrix::ZMatrix(int,int)"); #endif for (int i = 0; i < rows; i++) prM[i] = tempA; // Uses Assignment operator } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type>::ZMatrix(int rows, int cols, const Type & InitValue) { ZArr<Type> tempA(cols, InitValue); prRows = rows; prCols = cols; prM = new ZArr<Type>[rows]; // Calls Default Constructor for each element of // ZArr<Type> array #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)prM, "ZMatrix::ZMatrix(int,int,Type&)"); #endif for (int i = 0; i < rows; i++) prM[i] = tempA; // Uses Assignment operator } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type>::ZMatrix(const ZMatrix<Type> & Matrix) // Copy Constructor { prRows = Matrix.prRows; prCols = Matrix.prCols; prM = new ZArr<Type>[prRows]; // Calls Default Constructor for each element of // ZArr<Type> array #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)prM, "ZMatrix::ZMatrix(ZMatrix&)"); #endif for (int i = 0; i < prRows; i++) prM[i] = Matrix.prM[i]; // Calls ZArr<Type> Assignment operator method } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type>::~ZMatrix() { #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)prM, "ZMatrix::~ZMatrix()"); #endif delete [] prM; } //----------------------------------------------------------------------------- template <typename Type> ZArr<Type> & ZMatrix<Type>::operator[](int rowIndex) throw(ZException) { if ((rowIndex < 0) || (rowIndex >= prRows)) { throw ZException("ZMatrix::operator[]:Error: row Index out of range",0); } // ELSE return prM[rowIndex]; } //----------------------------------------------------------------------------- template <typename Type> const ZArr<Type> & ZMatrix<Type>::operator[](int rowIndex) const throw(ZException) { if ((rowIndex < 0) || (rowIndex >= prRows)) { throw ZException("ZMatrix::operator[]:Error: row Index out of range",0); } // ELSE return prM[rowIndex]; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator=(ZMatrix<Type> & rhs) { if (!((rhs.prRows == prRows) && (rhs.prCols == prCols))) { #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)prM, "ZMatrix::operator=(ZMatrix&)"); #endif delete [] prM; prRows = rhs.prRows; prCols = rhs.prCols; prM = new ZArr<Type>[prRows]; // Calls Default Constructor for each element of // ZArr<Type> array #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)prM, "ZMatrix::operator=(ZMatrix&)"); #endif for (int i = 0; i < prRows; i++) prM[i] = rhs.prM[i]; // Calls ZArr<Type> Assignment operator method } else { for (int row = 0; row < prRows; row++) prM[row] = rhs.prM[row]; } // ELSE return (*this); } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator=(int & scalar) { ZArr<Type> tempA(1); if ((1 != prRows) || (1 != prCols)) { #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)prM, "ZMatrix::operator=(int&)"); #endif delete [] prM; prRows = 1; prCols = 1; prM = new ZArr<Type>[1]; // Calls Default Constructor for each element of // ZArr<Type> array #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)prM, "ZMatrix::operator=(int&)"); #endif } tempA[0] = scalar; prM[0] = tempA; return (*this); } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> ZMatrix<Type>::operator+(ZMatrix<Type> & rhs) { // A = this + rhs // A = this.operator+(rhs) if (!((rhs.prRows == prRows) && (rhs.prCols == prCols))) { cout << "Error in matrix addition. Matrix sizes aren't identical\n"; return (*this); } ZMatrix<Type> A(*this); // Copy constructor for (int row = 0; row < prRows; row++) A.prM[row] += rhs.prM[row]; return A; // Returns a copy of A that is used as the rhs arguament for the } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> ZMatrix<Type>::operator-(ZMatrix<Type> & rhs) { // A = this - rhs // A = this.operator-(rhs) if (!((rhs.prRows == prRows) && (rhs.prCols == prCols))) { cout << "Error in matrix subtraction. Matrix sizes aren't identical\n"; return (*this); } ZMatrix<Type> A(*this); // Copy constructor for (int row = 0; row < prRows; row++) A.prM[row] -= rhs.prM[row]; return A; // Returns a copy of A that is used as the rhs arguament for the } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> ZMatrix<Type>::operator*(const Type & rhs) { // A = this*rhs; // rhs is scalar // this.operator*(rhs) ZMatrix<Type> A(*this); for (int i = 0; i < prRows; i++) A.prM[i] *= rhs; return A; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> ZMatrix<Type>::operator/(const Type & rhs) { // A = this*rhs; // rhs is scalar // this.operator*(rhs) ZMatrix<Type> A(*this); for (int i = 0; i < prRows; i++) A.prM[i] /= rhs; return A; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> ZMatrix<Type>::operator*(const ZMatrix<Type> & rhs) { // A = this*rhs; // rhs is a matrix // this.operator*(rhs) if (prCols != rhs.prRows) { cout << "Error in matrix multiplication. Left Matrix column count != Right Matrix Row Count\n"; return (*this); } ZMatrix<Type> A(prRows, rhs.prCols); for (int rows = 0; rows < prRows; rows++) for (int cols = 0; cols < rhs.prCols; cols++) { A.prM[rows][cols] = prM[rows][0]*rhs.prM[0][cols]; for (int i = 1; i < prCols; i++) A.prM[rows][cols] += prM[rows][i]*rhs.prM[i][cols]; } // FOR return A; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator+=(ZMatrix<Type> & rhs) { // this += rhs // this.operator+=(rhs) if (!((rhs.prRows == prRows) && (rhs.prCols == prCols))) { cout << "Error in matrix addition. Matrix sizes aren't identical\n" << endl; return (*this); } for (int row = 0; row < prRows; row++) prM[row] += rhs.prM[row]; return *this; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator-=(ZMatrix<Type> & rhs) { // this -= rhs // this.operator+=(rhs) if (!((rhs.prRows == prRows) && (rhs.prCols == prCols))) { cout << "Error in matrix subtraction. Matrix sizes aren't identical\n" << endl; return (*this); } for (int row = 0; row < prRows; row++) prM[row] -= rhs.prM[row]; return *this; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator*=(const Type & rhs) { // this *= rhs // rhs is scalar // this.operator*=(rhs) for (int row = 0; row < prRows; row++) prM[row] *= rhs; return *this; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator/=(const Type & rhs) { // this /= rhs // rhs is scalar // this.operator/=(rhs) for (int row = 0; row < prRows; row++) prM[row] /= rhs; return *this; } //----------------------------------------------------------------------------- template <typename Type> ZMatrix<Type> & ZMatrix<Type>::operator*=(const ZMatrix<Type> & rhs) { // If the two matrices aren't square, but satisfy the condition that // this.prCols == rhs.prRows, then the new this matrix will have changed // size. // // this *= rhs; // rhs is a matrix // this.operator*=(rhs) if (prCols != rhs.prRows) { cout << "Error in matrix multiplication. Left Matrix column count != Right Matrix Row Count\n"; return (*this); } ZMatrix<Type> A(prRows, rhs.prCols); for (int rows = 0; rows < prRows; rows++) for (int cols = 0; cols < rhs.prCols; cols++) { A.prM[rows][cols] = prM[rows][0]*rhs.prM[0][cols]; for (int i = 1; i < prCols; i++) A.prM[rows][cols] += prM[rows][i]*rhs.prM[i][cols]; } // FOR #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)prM, "ZMatrix::operator*=(ZMatrix&)"); #endif delete [] prM; prM = new ZArr<Type>[prRows]; #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)prM, "ZMatrix::operator*=(ZMatrix&)"); #endif prCols = rhs.prCols; for (int i = 0; i < prRows; i++) prM[i] = A.prM[i]; // Calls ZArr<Type> Assignment operator method return *this; } //----------------------------------------------------------------------------- // MISC UTILITIES //----------------------------------------------------------------------------- template <typename Type> void ZMatrix<Type>::Dim(int & RowCount, int & ColCount) const { RowCount = prRows; ColCount = prCols; } //----------------------------------------------------------------------------- template <typename Type> void ZMatrix<Type>::SetDim(int RowCount, int ColCount) { ZArr<Type> *pTempMat; ZArr<Type> tempArr(ColCount); if ((prRows == RowCount) && (prCols == ColCount)) return; pTempMat = new ZArr<Type>[RowCount]; #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)pTempMat, "ZMatrix::SetDim(int,int)"); #endif for (int i = 0; i < RowCount; i++) pTempMat[i] = tempArr; // Uses Assignment operator to set size for (int row = 0; row < Min(RowCount, prRows); row++) for (int col = 0; col < Min(ColCount, prCols); col++) pTempMat[row][col] = prM[row][col]; #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)prM, "ZMatrix::SetDim(int,int)"); #endif delete [] prM; prM = pTempMat; prRows = RowCount; prCols = ColCount; } //----------------------------------------------------------------------------- // MATH UTILITIES //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // FRIEND MEMBER FUNCTIONS //----------------------------------------------------------------------------- template <typename Type> std::ostream & operator<<(std::ostream & os, ZMatrix<Type> & rhs) { int row, col, i; if ((rhs.prRows == 0) || (rhs.prCols == 0)) { os << "[]"; return os; } if (rhs.ms_enumDisplayMode == ZMatrix<Type>::smOneLine) { os << "["; for (row = 0; row < rhs.prRows; row++) { os << rhs[row][0]; for (col = 1; col < rhs.prCols; col++) { os << "," << rhs[row][col]; } if (row < (rhs.prRows-1)) os << ";"; } // for os << "]"; } else { int *maxColumnStringSizes = new int[rhs.prCols]; #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)maxColumnStringSizes, "ZMatrix friend::operator<<(ostream&,ZMatrix&)"); #endif int maxStringSize = 0; // ZMatrix<char*> strArr(rhs.prRows, rhs.prCols); ZMatrix<char*> strArr(rhs.prRows, rhs.prCols); char tempStr[100], fmtStr[10]; memset(maxColumnStringSizes, sizeof(maxColumnStringSizes),0); int strWidth; for (row = 0; row < rhs.prRows; row++) { for (col = 0; col < rhs.prCols; col++) { strWidth = sprintf(tempStr, "%g", rhs.prM[row][col]); strArr[row][col] = new char[strWidth+1]; #ifdef DEBUG_MEMORY DebugMemAllocate((pvoid)strArr[row][col], "ZMatrix friend::operator<<(ostream&,ZMatrix&)"); #endif strcpy(strArr[row][col], tempStr); if (strWidth > maxColumnStringSizes[col]) maxColumnStringSizes[col] = strWidth; if (strWidth > maxStringSize) maxStringSize = strWidth; } // FOR } // FOR sprintf(fmtStr, "%c%ds", '%', maxStringSize); // We aim to get something like // _ _ // | 34.67 5.89 2.1 | // | 8.6 67.90 2.2 | // |_ 8 11.2 0_| // // Print the top line // _ _ printf("\n _"); for (col = 0; col < rhs.prCols; col++) // for (i = 0; i <= maxColumnStringSizes[col]; i++) for (i = 0; i < maxStringSize; i++) printf(" "); for (col = 0; col < (rhs.prCols-1); col++) printf(" "); printf("_\n"); for (row = 0; row < rhs.prRows; row++) { if (row != (rhs.prRows-1)) printf("| "); else printf("|_"); for (col = 0; col < rhs.prCols; col++) { // sprintf(fmtStr, "%c%ds", '%', maxColumnStringSizes[col]); printf(fmtStr, strArr[row][col]); if (col < (rhs.prCols-1)) printf(" "); } if (row == (rhs.prRows-1)) printf("_|\n"); else printf(" |\n"); } for (row = 0; row < rhs.prRows; row++) { for (col = 0; col < rhs.prCols; col++) { #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)strArr[row][col], "ZMatrix friend operator<<(ostream&,ZMatrix&)"); #endif delete strArr[row][col]; } } // FOR #ifdef DEBUG_MEMORY DebugMemDestroy((pvoid)maxColumnStringSizes, "ZMatrix friend operator<<(ostream&,ZMatrix&)"); #endif delete [] maxColumnStringSizes; } return os; } //----------------------------------------------------------------------------- #endif Z_MATRIX_CODE_HPP
[ [ [ 1, 545 ] ] ]
d97c5c13677912b197f5bcf5f08d853583fa5464
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/util/ValueArrayOf.hpp
75af69a6e89c970e879160ae5253da20da46fd17
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
5,277
hpp
/* * Copyright 1999-2000,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: ValueArrayOf.hpp 191054 2005-06-17 02:56:35Z jberry $ */ #if !defined(VALUEARRAY_HPP) #define VALUEARRAY_HPP #include <xercesc/util/XMLEnumerator.hpp> #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> #include <xercesc/util/IllegalArgumentException.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/framework/MemoryManager.hpp> XERCES_CPP_NAMESPACE_BEGIN template <class TElem> class ValueArrayOf : public XMemory { public : // ----------------------------------------------------------------------- // Contructors and Destructor // ----------------------------------------------------------------------- ValueArrayOf ( const unsigned int size , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); ValueArrayOf ( const TElem* values , const unsigned int size , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); ValueArrayOf(const ValueArrayOf<TElem>& source); ~ValueArrayOf(); // ----------------------------------------------------------------------- // Public operators // ----------------------------------------------------------------------- TElem& operator[](const unsigned int index); const TElem& operator[](const unsigned int index) const; ValueArrayOf<TElem>& operator=(const ValueArrayOf<TElem>& toAssign); bool operator==(const ValueArrayOf<TElem>& toCompare) const; bool operator!=(const ValueArrayOf<TElem>& toCompare) const; // ----------------------------------------------------------------------- // Copy operations // ----------------------------------------------------------------------- unsigned int copyFrom(const ValueArrayOf<TElem>& srcArray); // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- unsigned int length() const; TElem* rawData() const; // ----------------------------------------------------------------------- // Miscellaneous methods // ----------------------------------------------------------------------- void resize(const unsigned int newSize); private : // ----------------------------------------------------------------------- // Data members // ----------------------------------------------------------------------- unsigned int fSize; TElem* fArray; MemoryManager* fMemoryManager; }; // // An enumerator for a value array. It derives from the basic enumerator // class, so that value vectors can be generically enumerated. // template <class TElem> class ValueArrayEnumerator : public XMLEnumerator<TElem>, public XMemory { public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- ValueArrayEnumerator ( ValueArrayOf<TElem>* const toEnum , const bool adopt = false ); virtual ~ValueArrayEnumerator(); // ----------------------------------------------------------------------- // Enum interface // ----------------------------------------------------------------------- bool hasMoreElements() const; TElem& nextElement(); void Reset(); private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- ValueArrayEnumerator(const ValueArrayEnumerator<TElem>&); ValueArrayEnumerator<TElem>& operator=(const ValueArrayEnumerator<TElem>&); // ----------------------------------------------------------------------- // Data Members // // fAdopted // Indicates whether we have adopted the passed vector. If so then // we delete the vector when we are destroyed. // // fCurIndex // This is the current index into the vector. // // fToEnum // The value array being enumerated. // ----------------------------------------------------------------------- bool fAdopted; unsigned int fCurIndex; ValueArrayOf<TElem>* fToEnum; }; XERCES_CPP_NAMESPACE_END #if !defined(XERCES_TMPLSINC) #include <xercesc/util/ValueArrayOf.c> #endif #endif
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 150 ] ] ]
dee88d1d06e1fb354ea61f95902f9bcb28081984
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/_代码统计专用文件夹/C++Primer中文版(第4版)/第九章 顺序容器/20090210_代码9.6.3_只适用于string类型的操作_1_substr操作.cpp
c5b2588562c4b9e65104f6bc199fad7c609eda82
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
229
cpp
#include <iostream> #include <string> using namespace std; int main() { string s("hello world"); string s2 = s.substr(6, 5); string s3 = s.substr(6); cout << s << endl << s2 << endl << s3 << endl; return 0; }
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 14 ] ] ]
ede2dd42eab49fbd8efe40364d88409e698220ef
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
/OblivionOnline/GameClient.cpp
c2c52a12afb163afac4ed98b03c8a0d893c9ea46
[]
no_license
wlasser/oonline
51973b5ffec0b60407b63b010d0e4e1622cf69b6
fd37ee6985f1de082cbc9f8625d1d9307e8801a6
refs/heads/master
2021-05-28T23:39:16.792763
2010-05-12T22:35:20
2010-05-12T22:35:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,519
cpp
/* Copyright(c) 2007-2010 Julian Bangert This file is part of OblivionOnline. OblivionOnline 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. OblivionOnline 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, see <http://www.gnu.org/licenses/>. Linking OblivionOnline statically or dynamically with other modules is making a combined work based on OblivionOnline. Thus, the terms and conditions of the GNU General Public License cover the whole combination. In addition, as a special exception, the copyright holders of OblivionOnline give you permission to combine OblivionOnline program with free software programs or libraries that are released under the GNU LGPL and with code included in the standard release of Oblivion Script Extender by Ian Patterson (OBSE) under the OBSE license (or modified versions of such code, with unchanged license). You may copy and distribute such a system following the terms of the GNU GPL for OblivionOnline and the licenses of the other code concerned, provided that you include the source code of that other code when and as the GNU GPL requires distribution of source code. Note that people who make modified versions of OblivionOnline are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU General Public License gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. */ #include "main.h" #include "GameClient.h" #include "LogIOProvider.h" #include "UserInterface.h" #include "OutPacketStream.h" #include "OBSEFunctions.h" #include "ClientEntityUpdateManager.h" #include "NetworkConnection.h" #include "boost/foreach.hpp" #define MOVE_THRESHOLD 0.2 bool g_bRenderGUI = true; extern bool FindEquipped(TESObjectREFR* thisObj, UInt32 slotIdx, FoundEquipped* foundEquippedFunctor, double* result); static void SendActorPosition(TESObjectREFR *act,ClientEntity *ent) { if(abs(act->posX - ent->PosX())> MOVE_THRESHOLD || abs(act->posY - ent->PosY()) > MOVE_THRESHOLD || abs(act->posZ - ent->PosZ()) > MOVE_THRESHOLD || abs(act->rotZ - ent->RotZ()) > MOVE_THRESHOLD || abs(act->rotX - ent->RotX())>MOVE_THRESHOLD ||abs(act->rotY - ent->RotY()) > MOVE_THRESHOLD) { if(act->parentCell->worldSpace == NULL) ent->SetCell(act->parentCell->refID,true); else ent->SetCell(act->parentCell->worldSpace->refID,false); ent->MoveNRot(act->posX,act->posY,act->posZ,act->rotX,act->rotY,act->rotZ); } } static void SendActorValueMod(Actor *act,ClientEntity *ent) { for(BYTE i = 8;i <= 10;i++) // Only 8;9;10 { ent->SetActorValueMod(i,(short)act->GetActorValue(i)- (short)act->GetBaseActorValue(i)); } } static void SendActorValues(Actor *act,ClientEntity *ent) { ent->SetActorValue(8,act->GetBaseActorValue(8)); ent->SetActorValue(9,act->GetBaseActorValue(9)); ent->SetActorValue(10,act->GetBaseActorValue(10)); } static void SendActorEquip(Actor *act,ClientEntity *ent) { feGetObject getObject; double itemResult; UInt32* itemRef = (UInt32*)&itemResult; for(BYTE i = 0; i <= 20; i++) // traverse Slots { if(i == 18 || i == 19 || i== 9 || i == 10 || i == 11 || i == 12 || i == 14) // These do not exist continue; if (!FindEquipped(act, i, &getObject, &itemResult)) ent->SetEquip(i,0); else ent->SetEquip(i,*itemRef); } } static void SendActorAnimation(Actor *act,ClientEntity *ent) { ActorAnimData *animdata = GetActorAnimData(act); if(!animdata) return; for(int i = 0;i < 43;i++) { ent->SetAnimation(i,animdata->FindAnimInRange(i)); } } GameClient::GameClient(void) : UpdateQueue() { /* 1 IO 2 Network 3 ClientEntity */ IOSystem::Instance().RegisterIOProvider(new LogIOProvider(&IOSystem::Instance(),LogLevel::BootMessage,"OblivionOnline.log")); IOStream::Instance() << BootMessage << "Initializing game client: IO running" <<endl; Entities = new ClientEntityManager(&IOStream::Instance()); Entities->SetUpdateManager(new ClientEntityUpdateManager(Entities)); bIsConnected = false; bIsMasterClient = false; bIsInitialized = false; } GameClient::~GameClient(void) { delete Entities; } int GameClient::Initialize() { long rc; WSADATA wsa; rc = WSAStartup(MAKEWORD(2,0),&wsa); ServerSocket = socket(AF_INET,SOCK_STREAM,0); IOStream::Instance() << BootMessage<< "OblivionOnline connecting" <<endl; IOStream::Instance() <<BootMessage<<"Initializing GUI" <<endl; //InitialiseUI(); bIsInitialized = false; //Entities->DeleteEntities(); TotalPlayers = 0; LocalPlayer = MAXCLIENTS; return rc; } int GameClient::Deinitialize() { bIsInitialized = false; TotalPlayers = 0; GetEntities()->DeleteEntities(); closesocket(ServerSocket); ServerSocket = INVALID_SOCKET; WSACleanup(); DeinitialiseUI(); //D3DHookDeInit(); return 1; } bool GameClient::Connect() { char IP[15] = ""; SOCKADDR_IN ServerAddr; unsigned short ClientPort = 41805; long rc = 0; if(!bIsConnected) { IOStream::Instance() << BootMessage << "Initializing Connection" <<endl; Initialize(); FILE *Realmlist = fopen("realmlist.wth","r"); if(!Realmlist) { IOStream::Instance() << Error << "File realmlist.wth could not be found" << endl; return false; } while(!feof(Realmlist)) { fscanf(Realmlist,"%14s",IP); if(!fscanf(Realmlist,"%hu",&ClientPort)) ClientPort = 41805; IOStream::Instance() << BootMessage << "Trying to connect to "<<IP << " : "<<ClientPort <<endl; memset(&ServerAddr,NULL,sizeof(SOCKADDR_IN)); ServerAddr.sin_addr.s_addr = inet_addr(IP); ServerAddr.sin_port = htons(ClientPort); ServerAddr.sin_family = AF_INET; rc = connect(ServerSocket,(SOCKADDR *)&ServerAddr,sizeof(SOCKADDR)); if(rc == SOCKET_ERROR) { IOStream::Instance() << "Error" << WSAGetLastError() << " establishing connection " <<endl; continue; } else { ChunkPermissions all(MATCH_ALL); IOStream::Instance() << "Successfully connected" << endl; conn = new NetworkConnection(GetEntities(),ServerSocket,boost::bind<>(&GameClient::Disconnect,boost::ref(*this)) ); conn->SetPermissions(all); IOStream::Instance() << BootMessage << "Waiting for Player ID" <<endl; bIsConnected = true; break; } } fclose(Realmlist); } return true; } void GameClient::Disconnect() { if(bIsConnected) { Deinitialize(); bIsConnected = false; IOStream::Instance() << BootMessage << "Successfully disconnect" << endl; }else{ IOStream::Instance() << BootMessage << " You are not connected" << endl; } } bool GameClient::RunFrame() { ClientEntity * ent; Actor * actor = NULL; BYTE Status; if(!gClient->GetIsConnected()) return false; //Check if Menu Mode: InterfaceManager* intfc = InterfaceManager::GetSingleton(); if(!intfc->IsGameMode()) g_bRenderGUI = false; else g_bRenderGUI = true; if(!gClient->GetIsInitialized() ) { gClient->GetConnection().Process();//Poll connection until a player id is received return true; } // A heavy command xD // 1 - send local player data up . // 2 - send health magicka and fatigue + equip up. // if MC : // 2 - send up position , stat equip , etc of NPCs //(*g_thePlayer) is ignored ent = (ClientEntity *)gClient->GetEntities()->GetOrCreateEntity(gClient->GetLocalPlayer()); //gClient->GetServerStream()->Send(); // Prevent Lag SendActorPosition(*g_thePlayer,ent); SendActorValues(*g_thePlayer,ent); SendActorEquip(*g_thePlayer,ent); SendActorAnimation(*g_thePlayer,ent); //Find all cells any "ignored objects" are in. these are mostly players. std::set<TESObjectCELL *> cells; cells.insert((*g_thePlayer)->parentCell); BOOST_FOREACH(UINT32 i,ignore) { TESObjectREFR *form = (TESObjectREFR *)LookupFormByID(i); if(!form) continue; if(!form->parentCell) continue; if(cells.find(form->parentCell) == cells.end())//Not present cells.insert(form->parentCell); } //now we process each cell... BOOST_FOREACH(TESObjectCELL *Cell,cells) { TESObjectCELL::ObjectListEntry * ListIterator = &Cell->objectList; while(ListIterator) // Iterate the entities { if(IsRefIDIgnore(ListIterator->refr->refID)) // Do not synchronize objects used by OblivionOnline { ent = (ClientEntity *) gClient->GetEntities()->GetOrCreateEntity(ListIterator->refr->refID); if(GetIsMasterClient()) SendActorPosition(ListIterator->refr,ent); if(ListIterator->Info()->IsActor()) { Actor * actor = (Actor *)LookupFormByID(ListIterator->refr->refID); { if(GetIsMasterClient()) { SendActorValues(actor,ent); SendActorEquip(actor,ent); SendActorAnimation(actor,ent); } SendActorValueMod(actor,ent); } } } ListIterator = ListIterator->next; } } gClient->GetConnection().Process(); return true; } bool GameClient::EmptyPlayerCell() { const UINT32 storagecell = 98410; // marked "Testdungeon" TESObjectCELL::ObjectListEntry * iter = &(*g_thePlayer)->parentCell->objectList; //TODO: WIPE worldspace! while(iter) { if(iter->Info()->refID == (*g_thePlayer)->refID) { iter= iter->next; continue;} Entity * ent = gClient->GetEntities()->GetOrCreateEntity(iter->Info()->refID); assert(ent); ent->SetCell(storagecell,0,true); // Fake a network wipe! iter = iter->next; } return true; } void GameClient::IgnoreRefID(UINT32 val) /* to register OO pure ref IDs */ { if(ignore.find(val) == ignore.end()) ignore.insert(val); } bool GameClient::IsRefIDIgnore(UINT32 val) { return ignore.find(val) == ignore.end(); } void GameClient::SetPlayerID( UINT32 Value ) { LocalPlayer = Value; bIsInitialized = true; Console_Print("Received Player ID %u",Value); }
[ "obliviononline@2644d07b-d655-0410-af38-4bee65694944" ]
[ [ [ 1, 322 ] ] ]
6ca49500722ca0b7d1ec27ef6d16cd90103a97f2
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/mangalore/application/gamestatehandler.cc
4ce6fcc9474d555320f9364e7e0d63e81499b618
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
7,071
cc
//------------------------------------------------------------------------------ // application/gamestatehandler.cc // (C) 2003 RadonLabs GmbH //------------------------------------------------------------------------------ #include "application/gamestatehandler.h" #include "game/server.h" #include "audio/server.h" #include "graphics/server.h" #include "physics/server.h" #include "vfx/server.h" #include "input/server.h" #include "loader/server.h" #include "ui/server.h" #ifdef USE_MCEGUI #include "ceui/server.h" #endif #include "kernel/nscriptserver.h" #include "misc/nconserver.h" #include "gfx2/ngfxserver2.h" #include "particle/nparticleserver.h" #include "particle/nparticleserver2.h" #include "gui/nguiserver.h" #include "video/nvideoserver.h" #include "input/ninputserver.h" #include "navigation/server.h" #include "managers/setupmanager.h" #include "managers/timemanager.h" #include "managers/focusmanager.h" #include "managers/savegamemanager.h" namespace Application { ImplementRtti(Application::GameStateHandler, Application::StateHandler); ImplementFactory(Application::GameStateHandler); using namespace Managers; //------------------------------------------------------------------------------ /** */ GameStateHandler::GameStateHandler() : setupMode(EmptyWorld), exitState("Exit"), physicsVisualizationEnabled(false), fovVisualization(false), gameEntityVisualizationEnabled(false) { PROFILER_INIT(this->profCompleteFrame, "profMangaCompleteFrame"); PROFILER_INIT(this->profParticleUpdates, "profMangaParticleUpdates"); PROFILER_INIT(this->profRender, "profMangaRender"); } //------------------------------------------------------------------------------ /** */ GameStateHandler::~GameStateHandler() { // empty } //------------------------------------------------------------------------------ /** */ void GameStateHandler::OnStateEnter(const nString& prevState) { TimeManager::Instance()->ResetAll(); TimeManager::Instance()->Update(); this->physicsVisualizationEnabled = false; this->graphicsVisualizationEnabled = false; SetupManager* setupManager = SetupManager::Instance(); SaveGameManager* saveGameManager = SaveGameManager::Instance(); if (EmptyWorld == this->setupMode) { setupManager->SetupEmptyWorld(); } else if (NewGame == this->setupMode) { // use override start level, or the startup level from the world database? saveGameManager->SetStartLevelOverride(this->GetLevelName()); saveGameManager->NewGame(); } else if (ContinueGame == this->setupMode) { saveGameManager->ContinueGame(); } else if (LoadLevel == this->setupMode) { // show progress bar UI Loader::Server* loaderServer = Loader::Server::Instance(); loaderServer->OpenProgressIndicator(); loaderServer->SetProgressText("On Load Before..."); loaderServer->UpdateProgressDisplay(); setupManager->SetCurrentLevel(this->GetLevelName()); this->OnLoadBefore(); loaderServer->SetProgressText("Setup World..."); loaderServer->UpdateProgressDisplay(); setupManager->SetupWorldFromCurrentLevel(); loaderServer->SetProgressText("On Load After..."); loaderServer->UpdateProgressDisplay(); this->OnLoadAfter(); loaderServer->CloseProgressIndicator(); } else if (LoadSaveGame == this->setupMode) { saveGameManager->LoadGame(this->GetSaveGame()); } // clear the startup level and save game name this->SetLevelName(""); this->SetSaveGame(""); // update the focus manager, so that focus entities are set correctly FocusManager::Instance()->OnFrame(); } //------------------------------------------------------------------------------ /** */ void GameStateHandler::OnStateLeave(const nString& nextState) { SetupManager::Instance()->CleanupWorld(); } //------------------------------------------------------------------------------ /** The per-frame handler method. */ nString GameStateHandler::OnFrame() { PROFILER_START(this->profCompleteFrame); bool running = true; // let the time manager update its time TimeManager::Instance()->Update(); // toggle visualizations if (nInputServer::Instance()->GetButton("togglePhysicsVisualization")) { this->physicsVisualizationEnabled = !this->physicsVisualizationEnabled; } if (nInputServer::Instance()->GetButton("toggleGraphicsVisualization")) { this->graphicsVisualizationEnabled = !this->graphicsVisualizationEnabled; } if (nInputServer::Instance()->GetButton("toggleFOVVisualization")) { this->fovVisualization = !this->fovVisualization; } if (nInputServer::Instance()->GetButton("toggleGameEntityVisualization")) { this->gameEntityVisualizationEnabled = !this->gameEntityVisualizationEnabled; } // trigger subsystem and Nebula servers nVideoServer::Instance()->Trigger(); Input::Server::Instance()->Trigger(); running &= Foundation::Server::Instance()->GetScriptServer()->Trigger(); // trigger the audio and game subsystems Audio::Server::Instance()->BeginScene(); Navigation::Server::Instance()->OnBeginFrame(); Game::Server::Instance()->OnFrame(); Navigation::Server::Instance()->OnEndFrame(); Audio::Server::Instance()->EndScene(); VFX::Server::Instance()->BeginScene(); PROFILER_START(this->profParticleUpdates); nParticleServer::Instance()->Trigger(); nParticleServer2::Instance()->Trigger(); PROFILER_STOP(this->profParticleUpdates); PROFILER_START(this->profRender); running &= Graphics::Server::Instance()->Trigger(); if (Graphics::Server::Instance()->BeginRender()) { UI::Server::Instance()->Render(); Graphics::Server::Instance()->Render(); #ifdef USE_MCEGUI CEUI::Server::Instance()->Render(); #endif if (this->graphicsVisualizationEnabled) { Graphics::Server::Instance()->RenderDebug(); } if (this->physicsVisualizationEnabled) { Physics::Server::Instance()->RenderDebug(); } if (this->fovVisualization) { Navigation::Server::Instance()->RenderDebug(); } if (this->gameEntityVisualizationEnabled) { Game::Server::Instance()->RenderDebug(); } Graphics::Server::Instance()->EndRender(); } PROFILER_STOP(this->profRender); VFX::Server::Instance()->EndScene(); // trigger kernel server nKernelServer::Instance()->Trigger(); PROFILER_STOP(this->profCompleteFrame); if (!running) { return this->exitState; } else { return this->GetName(); } } } // namespace Application
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 225 ] ] ]
4fe34bb59840ae474ec1b5c40db78c907b7244c2
28aa23d9cb8f5f4e8c2239c70ef0f8f6ec6d17bc
/mytesgnikrow --username hotga2801/Project/MotionAdaboost/Develop/hbp/rlist.cpp
8eaa122a73a35995c2a380ce15682550eadebcaa
[]
no_license
taicent/mytesgnikrow
09aed8836e1297a24bef0f18dadd9e9a78ec8e8b
9264faa662454484ade7137ee8a0794e00bf762f
refs/heads/master
2020-04-06T04:25:30.075548
2011-02-17T13:37:16
2011-02-17T13:37:16
34,991,750
0
0
null
null
null
null
UTF-8
C++
false
false
13,885
cpp
/******************************************************* Mean Shift Analysis Library ============================================= The mean shift library is a collection of routines that use the mean shift algorithm. Using this algorithm, the necessary output will be generated needed to analyze a given input set of data. Region List Class: ================= During segmentation, data regions are defined. The RegionList class provides a mechanism for doing so, as well as defines some basic operations, such as region growing or small region pruning, on the defined regions. It is defined below. Its prototype is given in "region.h". The theory is described in the papers: D. Comaniciu, P. Meer: Mean Shift: A robust approach toward feature space analysis. C. Christoudias, B. Georgescu, P. Meer: Synergism in low level vision. and they are is available at: http://www.caip.rutgers.edu/riul/research/papers/ Implemented by Chris M. Christoudias, Bogdan Georgescu ********************************************************/ #include "stdafx.h" //#include "rlist.h" //#include <stdio.h> //#include <stdlib.h> /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PUBLIC METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/ /*** Class Constructor and Destructor ***/ /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/ /*******************************************************/ /*Constructor */ /*******************************************************/ /*Constructor */ /*******************************************************/ /*Pre: */ /* - modesPtr is a pointer to an array of modes */ /* - maxRegions_ is the maximum number of regions */ /* that can be defined */ /* - L_ is the number of data points being class- */ /* ified by the region list class */ /* - N is the dimension of the data set being cl- */ /* assified by the region list class */ /*Post: */ /* - a region list object has been properly init- */ /* ialized. */ /*******************************************************/ RegionList::RegionList(int maxRegions_, int L_, int N_) { //Obtain maximum number of regions that can be //defined by user if((maxRegions = maxRegions_) <= 0) ErrorHandler("RegionList", "Maximum number of regions is zero or negative.", FATAL); //Obtain dimension of data set being classified by //region list class if((N = N_) <= 0) ErrorHandler("RegionList", "Dimension is zero or negative.", FATAL); //Obtain length of input data set... if((L = L_) <= 0) ErrorHandler("RegionList", "Length of data set is zero or negative.", FATAL); //Allocate memory for index table if(!(indexTable = new int [L])) ErrorHandler("RegionList", "Not enough memory.", FATAL); //Allocate memory for region list array if(!(regionList = new REGION [maxRegions])) ErrorHandler("RegionList", "Not enough memory.", FATAL); //Initialize region list... numRegions = freeRegion = 0; //Initialize indexTable freeBlockLoc = 0; //done. return; } /*******************************************************/ /*Destructor */ /*******************************************************/ /*Destroys region list object. */ /*******************************************************/ /*Post: */ /* - region list object has been properly dest- */ /* oyed. */ /*******************************************************/ RegionList::~RegionList( void ) { //de-allocate memory... delete [] regionList; delete [] indexTable; //done. return; } /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/ /*** Region List Manipulation ***/ /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/ /*******************************************************/ /*Add Region */ /*******************************************************/ /*Adds a region to the region list. */ /*******************************************************/ /*Pre: */ /* - label is a positive integer used to uniquely */ /* identify a region */ /* - pointCount is the number of N-dimensional */ /* data points that exist in the region being */ /* classified. */ /* - indeces is a set of indeces specifying the */ /* data points contained within this region */ /* - pointCount must be > 0 */ /*Post: */ /* - a new region labeled using label and contai- */ /* ning pointCount number of points has been */ /* added to the region list. */ /*******************************************************/ void RegionList::AddRegion(int label, int pointCount, int *indeces) { //make sure that there is enough room for this new region //in the region list array... if(numRegions >= maxRegions) ErrorHandler("AddRegion", "Not enough memory allocated.", FATAL); //make sure that label is positive and point Count > 0... if((label < 0)||(pointCount <= 0)) ErrorHandler("AddRegion", "Label is negative or number of points in region is invalid.", FATAL); //make sure that there is enough memory in the indexTable //for this region... if((freeBlockLoc + pointCount) > L) ErrorHandler("AddRegion", "Adding more points than what is contained in data set.", FATAL); //place new region into region list array using //freeRegion index regionList[freeRegion].label = label; regionList[freeRegion].pointCount = pointCount; regionList[freeRegion].region = freeBlockLoc; //copy indeces into indexTable using freeBlock... int i; for(i = 0; i < pointCount; i++) indexTable[freeBlockLoc+i] = indeces[i]; //increment freeBlock to point to the next free //block freeBlockLoc += pointCount; //increment freeRegion to point to the next free region //also, increment numRegions to indicate that another //region has been added to the region list freeRegion++; numRegions++; //done. return; } /*******************************************************/ /*Reset */ /*******************************************************/ /*Resets the region list. */ /*******************************************************/ /*Post: */ /* - the region list has been reset. */ /*******************************************************/ void RegionList::Reset( void ) { //reset region list freeRegion = numRegions = freeBlockLoc = 0; //done. return; } /*/\/\/\/\/\/\/\/\/\/\*/ /* Query Region List */ /*\/\/\/\/\/\/\/\/\/\/*/ /*******************************************************/ /*Get Number Regions */ /*******************************************************/ /*Returns the number of regions stored by region list. */ /*******************************************************/ /*Post: */ /* - the number of regions stored by the region */ /* list is returned. */ /*******************************************************/ int RegionList::GetNumRegions( void ) { // return region count return numRegions; } /*******************************************************/ /*Get Label */ /*******************************************************/ /*Returns the label of a specified region. */ /*******************************************************/ /*Pre: */ /* - regionNum is an index into the region list */ /* array. */ /*Post: */ /* - the label of the region having region index */ /* specified by regionNum has been returned. */ /*******************************************************/ int RegionList::GetLabel(int regionNum) { //return the label of a specified region return regionList[regionNum].label; } /*******************************************************/ /*Get Region Count */ /*******************************************************/ /*Returns the point count of a specified region. */ /*******************************************************/ /*Pre: */ /* - regionNum is an index into the region list */ /* array. */ /*Post: */ /* - the number of points that classify the */ /* region whose index is specified by regionNum */ /* is returned. */ /*******************************************************/ int RegionList::GetRegionCount(int regionNum) { //return the region count of a specified region return regionList[regionNum].pointCount; } /*******************************************************/ /*Get Region Indeces */ /*******************************************************/ /*Returns the point indeces specifying a region. */ /*******************************************************/ /*Pre: */ /* - regionNum is an index into the region list */ /* array. */ /*Post: */ /* - the region indeces specifying the points */ /* contained by the region specified by region- */ /* Num are returned. */ /*******************************************************/ int *RegionList::GetRegionIndeces(int regionNum) { //return point indeces using regionNum return &indexTable[regionList[regionNum].region]; } /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PRIVATE METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*/\/\/\/\/\/\/\/\/\/\/\*/ /* Class Error Handler */ /*\/\/\/\/\/\/\/\/\/\/\/*/ /*******************************************************/ /*Error Handler */ /*******************************************************/ /*Class error handler. */ /*******************************************************/ /*Pre: */ /* - functName is the name of the function that */ /* caused an error */ /* - errmsg is the error message given by the */ /* calling function */ /* - status is the error status: FATAL or NON- */ /* FATAL */ /*Post: */ /* - the error message errmsg is flagged on beh- */ /* ave of function functName. */ /* - if the error status is FATAL then the program*/ /* is halted, otherwise execution is continued, */ /* error recovery is assumed to be handled by */ /* the calling function. */ /*******************************************************/ void RegionList::ErrorHandler(char *functName, char* errmsg, ErrorType status) { //flag error message on behalf of calling function, error format //specified by the error status... if(status == NONFATAL) fprintf(stderr, "\n%s Error: %s\n", functName, errmsg); else { fprintf(stderr, "\n%s Fatal Error: %s\n\nAborting Program.\n\n", functName, errmsg); exit(1); } } /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END OF CLASS DEFINITION @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
[ "hotga2801@ecd9aaca-b8df-3bf4-dfa7-576663c5f076" ]
[ [ [ 1, 340 ] ] ]
bc7b71a8558e6bb03e36a2bcb7c6cb0707ed4b20
a84b013cd995870071589cefe0ab060ff3105f35
/webdriver/branches/chrome_extension/chrome/src/cpp/npwebdriver/npwebdriver/src/include/webdriver/http_responses.h
0c7594bbb7bd6d4c9bee0d1cab45576f1086dc3a
[ "Apache-2.0" ]
permissive
vdt/selenium
137bcad58b7184690b8785859d77da0cd9f745a0
30e5e122b068aadf31bcd010d00a58afd8075217
refs/heads/master
2020-12-27T21:35:06.461381
2009-08-18T15:56:32
2009-08-18T15:56:32
13,650,409
1
0
null
null
null
null
UTF-8
C++
false
false
229
h
#ifndef WEBDRIVER_HTTP_RESPONSES_H_ #define WEBDRIVER_HTTP_RESPONSES_H_ namespace webdriver { const char *kNoContentReseponse = "HTTP/1.1 204 No Content"; } //namespace webdriver #endif //WEBDRIVER_HTTP_RESPONSES_H_
[ "dawagner@07704840-8298-11de-bf8c-fd130f914ac9" ]
[ [ [ 1, 9 ] ] ]
2e20b7021a1db83c9a7667c01654ccaa06401580
37334008977a7a644cbbc2f2a828bc1d150c0638
/win32/SNES/PlugDemo/tracePlug.cpp
09dd23f32997d97b6061aa2964846eb5f8e41330
[]
no_license
titanlab/neo-myth-plugins
91e797d69620981edf229c6186805bf0a49f0cc2
de41771c9772a5f02f165d4f36fb1ec6f134a29a
refs/heads/master
2021-09-08T12:17:24.494573
2011-11-19T15:17:42
2011-11-19T15:17:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
212
cpp
#include "tracePlug.hpp" #include "stdafx.h" static bool silentMode = false; const bool isSilentMode() { return silentMode; } void forceSilentMode(const bool silent) { silentMode = silent; }
[ "conleon1988@bb221dbb-59eb-094c-fa1a-8ce0a11b4692" ]
[ [ [ 1, 15 ] ] ]
868a03cbac9ccea0cf13c30a4aea51c2806e9f64
cc336f796b029620d6828804a866824daa6cc2e0
/cximage/CxImage/ximaj2k.h
503a48afc6b8379b401773e3a356382aac4068b2
[]
no_license
tokyovigilante/xbmc-sources-fork
84fa1a4b6fec5570ce37a69d667e9b48974e3dc3
ac3c6ef8c567f1eeb750ce6e74c63c2d53fcde11
refs/heads/master
2021-01-19T10:11:37.336476
2009-03-09T20:33:58
2009-03-09T20:33:58
29,232
2
0
null
null
null
null
UTF-8
C++
false
false
2,256
h
/* * File: ximaj2k.h * Purpose: J2K Image Class Loader and Writer */ /* === C R E D I T S & D I S C L A I M E R S ============== * CxImageJ2K (c) 04/Aug/2002 <[email protected]> * Permission is given by the author to freely redistribute and include * this code in any program as long as this credit is given where due. * * CxImage version 5.80 29/Sep/2003 * See the file history.htm for the complete bugfix and news report. * * based on LIBJ2K Copyright (c) 2001-2002, David Janssens - All rights reserved. * * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. * * Use at your own risk! * ========================================================== */ #if !defined(__ximaJ2K_h) #define __ximaJ2K_h #include "ximage.h" #if CXIMAGE_SUPPORT_J2K //#define LIBJ2K_EXPORTS extern "C" { #include "../j2k/j2k.h" }; class CxImageJ2K: public CxImage { public: CxImageJ2K(): CxImage(CXIMAGE_FORMAT_J2K) {} // bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_J2K);} // bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_J2K);} bool Decode(CxFile * hFile); bool Encode(CxFile * hFile); bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } protected: void j2k_calc_explicit_stepsizes(j2k_tccp_t *tccp, int prec); void j2k_encode_stepsize(int stepsize, int numbps, int *expn, int *mant); int j2k_floorlog2(int a); }; #endif #endif
[ "jmarshallnz@568bbfeb-2a22-0410-94d2-cc84cf5bfa90" ]
[ [ [ 1, 60 ] ] ]
71a78149fdf8b22bb0566d61a857c0883fa0225a
8253a563255bdd5797873c9f80d2a48a690c5bb0
/settingsengines/sdb/tests/native/FilterableFieldsTest/src/Tests.cpp
2484595ff309fdf5b1704aa538323f0f4a589f5e
[]
no_license
SymbianSource/oss.FCL.sftools.depl.swconfigmdw
4e6ab52bf564299f1ed7036755cf16321bd656ee
d2feb88baf0e94da760738fc3b436c3d5d1ff35f
refs/heads/master
2020-03-28T10:16:11.362176
2010-11-06T14:59:14
2010-11-06T14:59:14
73,009,096
0
0
null
null
null
null
UTF-8
C++
false
false
1,954
cpp
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" // which accompanies this distribution, and is available // at the URL "http://www.eclipse.org/legal/epl-v10.html". // // Initial Contributors: // Nokia Corporation - initial contribution. // // Contributors: // // Description: // #include "SdbTest.h" #include "ViewEngine.h" #include <cntdb.h> #include <cntitem.h> #include <cntfldst.h> #include <cntview.h> #include <cntviewbase.h> extern void RegisterTestL(const TDesC&, TTestFunction); // // // Add a test function prototype here int FilterTestL(RSdbTest& aTest); void FilterCountL(RSdbTest& aTest); CContactDatabase* OpenDefaultDbLC(RSdbTest& aTest); TInt32 DesToInt32(const TPtrC& aDes); // // // Register your test here // void RegisterTestsL() { _LIT(KExampleFilterTestName, "FilterTest"); RegisterTestL(KExampleFilterTestName, &FilterTestL); } int FilterTestL(RSdbTest& aTest) { CCommandLineArguments* cmdLine = aTest.CommandLineArgumentsL(); CDbViewEngine* viewEng = CDbViewEngine::NewL(&aTest, DesToInt32(cmdLine->Arg(2)), DesToInt32(cmdLine->Arg(3))); CleanupStack::PushL(viewEng); viewEng->StartL(); CActiveScheduler::Start(); aTest.AsyncEndL(); CleanupStack::PopAndDestroy(viewEng); return aTest.GetLastError(); } CContactDatabase* OpenDefaultDbLC(RSdbTest& aTest) { TBuf<64> dbName; CContactDatabase::GetDefaultNameL(dbName); aTest.Printf(_L("Reading database: %S\n"), &dbName); CContactDatabase *iDatabase = CContactDatabase::OpenL(dbName); CleanupStack::PushL(iDatabase); return iDatabase; } TInt32 DesToInt32(const TPtrC& aDes) { TLex lex; lex.Assign(aDes); TInt32 intVal; lex.Val(intVal); return intVal; }
[ "none@none" ]
[ [ [ 1, 82 ] ] ]
abc4f963255b3622318bbfe306a3e4c850b48660
1092bd6dc9b728f3789ba96e37e51cdfb9e19301
/loci/mocaps/detail/bvh/save.cpp
85fcdcdbc435da941f2d0826bf828553c31c4cfb
[]
no_license
dtbinh/loci-extended
772239e63b4e3e94746db82d0e23a56d860b6f0d
f4b5ad6c4412e75324d19b71559a66dd20f4f23f
refs/heads/master
2021-01-10T12:23:52.467480
2011-03-15T22:03:06
2011-03-15T22:03:06
36,032,427
0
0
null
null
null
null
UTF-8
C++
false
false
4,251
cpp
/** * Exports a bvh document. * Defines an exporter for a bvh document, saving a scope_list to a * file. * * @file save.cpp * @author David Gill * @date 23/04/2010 */ #include <string> #include <ostream> #include "loci/mocaps/detail/bvh/scope.h" namespace loci { namespace mocaps { namespace detail { namespace bvh { namespace // anonymous { std::ostream & indent(std::ostream & sink, unsigned int depth, bool in_scope = true) { depth += (in_scope ? 1 : 0); for (unsigned int i = 0; i < depth; ++i) { sink << " "; } return sink; } scope_list::const_iterator save_hierarchy_recurse(std::ostream & sink, scope_list::const_iterator current, scope_list::const_iterator end) { unsigned int depth = current->depth; sink << current->name << '\n'; indent(sink, depth, false) << "{\n"; indent(sink, depth) << "OFFSET " << current->offset.x() << ' ' << current->offset.y() << ' ' << current->offset.z() << '\n'; if (!current->end_site()) { indent(sink, depth) << "CHANNELS " << current->channels.size(); for (scope::channel_index_list::const_iterator channel_iter = current->channels.begin(); channel_iter != current->channels.end(); ++channel_iter) { if (*channel_iter == channel_indices::x_position) { sink << " Xposition"; } else if (*channel_iter == channel_indices::y_position) { sink << " Yposition"; } else if (*channel_iter == channel_indices::z_position) { sink << " Zposition"; } else if (*channel_iter == channel_indices::x_rotation) { sink << " Xrotation"; } else if (*channel_iter == channel_indices::y_rotation) { sink << " Yrotation"; } else if (*channel_iter == channel_indices::z_rotation) { sink << " Zrotation"; } } sink << '\n'; ++current; while (current != end && current->depth == depth + 1) { indent(sink, depth) << (current->end_site() ? "End Site " : "JOINT "); current = save_hierarchy_recurse(sink, current, end); } } else { ++current; } indent(sink, depth, false) << "}\n"; return current; } } // anonymous namespace void save_hierarchy(std::ostream & sink, const scope_list & scopes) { sink << "HIERARCHY\n"; sink << "ROOT "; save_hierarchy_recurse(sink, scopes.begin(), scopes.end()); } void save_motion(std::ostream & sink, const scope_list & scopes, unsigned int frame_count, float time_per_frame) { sink << "MOTION\n" << "Frames: " << frame_count << '\n' << "Frame Time: " << time_per_frame << '\n'; for (unsigned int frame = 0; frame < frame_count; ++frame) { for (scope_list::const_iterator joint_iter = scopes.begin(); joint_iter != scopes.end(); ++joint_iter) { unsigned int num_channels = joint_iter->channels.size(); scope::motion_channel_list::const_iterator motion_iter = joint_iter->motion.begin() + num_channels * frame; for (unsigned int channel = 0; channel < num_channels; ++channel, ++motion_iter) { sink << *motion_iter << ' '; } } sink << '\n'; } } void save(std::ostream & sink, const scope_list & scopes, unsigned int frame_count, float time_per_frame) { save_hierarchy(sink, scopes); save_motion(sink, scopes, frame_count, time_per_frame); } } // namespace bvh } // namespace detail } // namespace mocaps } // namespace loci
[ "[email protected]@0e8bac56-0901-9d1a-f0c4-3841fc69e132" ]
[ [ [ 1, 112 ] ] ]
013f2fd25513add255e86f75b090a676dc9ad94b
4891542ea31c89c0ab2377428e92cc72bd1d078f
/FindReplace/RDParser.h
650e8a6238d6f5ceab809db3e2e5e0931b3a514a
[]
no_license
koutsop/arcanoid
aa32c46c407955a06c6d4efe34748e50c472eea8
5bfef14317e35751fa386d841f0f5fa2b8757fb4
refs/heads/master
2021-01-18T14:11:00.321215
2008-07-17T21:50:36
2008-07-17T21:50:36
33,115,792
0
0
null
null
null
null
UTF-8
C++
false
false
1,221
h
/* * RDParser.h * author: Koutsopoulos Nikolaos * mail : [email protected] */ #ifndef RDPARSER_H #define RDPARSER_H #include "RegExpr.h" #include "Lexicalanalyser.h" namespace parser{ class RDParser { protected: typedef LexicalAnalyser::TokenList TokenList; typedef LexicalAnalyser::Token Token; TokenList::iterator tokenListIter; TokenList* tokens; Token lookAhead; bool hasError; std::string errorMsg; Token GetNextToken (void); //Token GetPrevToken (void); TokenList::iterator marck_input_position(void) {return tokenListIter;} void RetractCurrToken (void); void retruct_input_till_position(TokenList::iterator t) { tokenListIter = t; } Token & GetCurrToken(void); bool HasMoreTokens (void){ return tokenListIter != tokens->end(); } void Match(TokenType t); void Error(TokenType t); public: bool HasError(void) const { return hasError; } const std::string GetError(void) const { return errorMsg; } virtual RegExpr * Analyse (TokenList* _tokens) = 0; virtual void Clear(void) = 0; //virtual RDParser(void) { lookAhead = TokenSTART_SYMBOL; } virtual ~RDParser(void){} }; } #endif
[ "koutsop@5c4dd20e-9542-0410-abe3-ad2d610f3ba4" ]
[ [ [ 1, 58 ] ] ]
c6caf93740a5f4c553482dba1a5feb81a27463d9
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nphysics/src/nphysics/ncphycompositeobj_main.cc
5b34555e1291e33e15f26f816d6b7473337c3723
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
21,883
cc
//----------------------------------------------------------------------------- // ncphycompositeobj_main.cc // (C) 2004 Conjurer Services, S.A. //----------------------------------------------------------------------------- #include "precompiled/pchnphysics.h" #include "nphysics/ncphycompositeobj.h" #include "nphysics/nphysicsserver.h" #include "zombieentity/nctransform.h" #include "kernel/nlogclass.h" //----------------------------------------------------------------------------- /** Constructor history: - 18-Oct-2004 Zombie created */ ncPhyCompositeObj::ncPhyCompositeObj() : containerGeometries(NumInitialGeometries,NumGrowthGeometries), objectSpace(0), subSpaceAllowed(true) { this->ResetsContainer(); } //----------------------------------------------------------------------------- /** Destructor history: - 18-Oct-2004 Zombie created */ ncPhyCompositeObj::~ncPhyCompositeObj() { for( ;this->containerGeometries.Size(); ) { nPhysicsGeom* geom(this->containerGeometries.GetElementAt(0)); this->Remove( geom ); } if( this->objectSpace ) { this->objectSpace->Release(); this->objectSpace = 0; } } //----------------------------------------------------------------------------- /** Adds a geometry to the object @param geometry geometry to be added history: - 29-Sep-2004 Zombie created */ void ncPhyCompositeObj::AddContainer( nPhysicsGeom* geometry ) { this->containerGeometries.Add( phyGeomIDToInt( geometry->Id() ), geometry ); if( this->GetParentSpace() != NoValidID ) { geometry->MoveToSpace( this->GetParentSpace() ); } geometry->SetOwner(this); // now this object it's the owner if( this->GetMaterial() ) { geometry->SetMaterial( this->GetMaterial() ); } } //----------------------------------------------------------------------------- /** Removes a geometry from the object @param geometry geometry to be removed history: - 29-Sep-2004 Zombie created */ void ncPhyCompositeObj::RemoveContainer( nPhysicsGeom* geometry ) { this->containerGeometries.Rem( phyGeomIDToInt( geometry->Id() ) ); geometry->MoveToSpace( NoValidID ); geometry->SetOwner(0); // resets owner } //----------------------------------------------------------------------------- /** Adds a geometry to the object @param geometry geometry to be added history: - 18-Oct-2004 Zombie created */ void ncPhyCompositeObj::Add( nPhysicsGeom* geometry ) { n_assert2( geometry, "Null pointer" ); n_assert2( !geometry->IsSpace(), "It cannot be a space" ); #ifndef NGAME geometry->AddCollidesWith( nPhysicsGeom::Check ); #endif nPhyGeomTrans* geomTrans( static_cast<nPhyGeomTrans*>(nObject::kernelServer->New( "nphygeomtrans"))); n_assert2( geometry, "Run out of memory" ); geomTrans->SetOwner( this ); geomTrans->AddGeometry( geometry ); this->AddContainer( geomTrans ); } //----------------------------------------------------------------------------- /** Removes a geometry from the object @param geometry geometry to be removed history: - 18-Oct-2004 Zombie created */ void ncPhyCompositeObj::Remove( nPhysicsGeom* geometry ) { nPhysicsGeom* geomTrans(0); this->containerGeometries.Find( phyGeomIDToInt( geometry->Id() ), geomTrans ); /// removing the geometry static_cast<nPhyGeomTrans*>(geomTrans)->AddGeometry(0); this->RemoveContainer( geomTrans ); geomTrans->Release(); } //----------------------------------------------------------------------------- /** Sets the position of this physic object @param newposition new position history: - 18-Oct-2004 Zombie created */ void ncPhyCompositeObj::SetPosition( const vector3& newposition ) { nPhyRigidBody* body( this->GetBody() ); if( body ) { if( body->GetTweaked() ) { matrix33 rotation; this->GetOrientation( rotation ); vector3 pos(newposition + (rotation * body->GetTweakedOffset())); body->SetPosition( pos ); ncPhysicsObj::SetPosition( pos ); } else { body->SetPosition( newposition ); ncPhysicsObj::SetPosition( newposition ); } return; } int end(this->containerGeometries.Size()); for( int index(0); index < end; ++index ) { this->containerGeometries.GetElementAt(index)->SetPosition( newposition ); } ncPhysicsObj::SetPosition( newposition ); } //----------------------------------------------------------------------------- /** Sets the orientation of the rigid body. @param neworientation new orientation history: - 18-Oct-2004 Zombie created */ void ncPhyCompositeObj::SetRotation( const matrix33& neworientation ) { if( this->GetBody() ) { this->GetBody()->SetOrientation( neworientation ); ncPhysicsObj::SetRotation( neworientation ); return; } for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->SetOrientation( neworientation ); } ncPhysicsObj::SetRotation( neworientation ); } //----------------------------------------------------------------------------- /** Sets the euler orientation. @param ax orientation in the x axis @param ay orientation in the y axis @param az orientation in the z axis history: - 18-Oct-2004 Zombie created */ void ncPhyCompositeObj::SetRotation( phyreal ax, phyreal ay, phyreal az ) { matrix33 neworientation; neworientation.from_euler( vector3( ax,ay,az ) ); this->SetRotation( neworientation ); } //----------------------------------------------------------------------------- /** Sets the body of this object. @param body new object body history: - 19-Oct-2004 Zombie created */ void ncPhyCompositeObj::SetBody( nPhyRigidBody* body ) { ncPhysicsObj::SetBody( body ); for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->SetBody(body); } body->SetPhysicsObj( this ); } //----------------------------------------------------------------------------- /** Enables the physic object. history: - 29-Nov-2004 Zombie created */ void ncPhyCompositeObj::Enable() { // Enabling every object belonging to this physics object for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->Enable(); } if( this->GetBody() ) { this->GetBody()->Enable(); } ncPhysicsObj::Enable(); } //----------------------------------------------------------------------------- /** Disables the physic object. history: - 29-Nov-2004 Zombie created */ void ncPhyCompositeObj::Disable() { // Disabling every object belonging to this physics object for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->Disable(); } if( this->GetBody() ) { this->GetBody()->Disable(); } ncPhysicsObj::Disable(); } //----------------------------------------------------------------------------- /** Moves the physic object to another space. @param newspace the new object's space history: - 29-Nov-2004 Zombie created */ void ncPhyCompositeObj::MoveToSpace( nPhySpace* newspace ) { if( this->objectSpace ) { this->objectSpace->MoveToSpace( newspace ); } else { for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->MoveToSpace( newspace ); } } ncPhysicsObj::MoveToSpace( newspace ); } //----------------------------------------------------------------------------- /** Checks if collision with a geometry. @param geom geometry which whom collide @param numContacts number maximun of contacts expected @param contact array of contacts structures information @return number of contacts found history: - 29-Nov-2004 Zombie created */ int ncPhyCompositeObj::Collide( const nPhysicsGeom* geom, int numContacts, nPhyCollide::nContact* contact ) const { n_assert2( geom , "Null pointer" ); #ifndef NGAME if( !numContacts ) { // nothing to do return 0; } #endif n_assert2( contact , "Null pointer" ); int nContacts(numContacts); int nReportedContacts(0); for( int index(0); index < this->containerGeometries.Size(); ++index ) { int nReported ( this->containerGeometries.GetElementAt(index)->Collide( geom, nContacts, contact + nReportedContacts ) ); if( !nReported ) continue; nContacts -= nReported; nReportedContacts += nReported; if( !nContacts ) break; // no more space for more contacts } return nReportedContacts; } //----------------------------------------------------------------------------- /** Checks if collision with other physics objects. @param obj object which whom collide @param numContacts number maximun of contacts expected @param contact array of contacts structures information @return number of contacts found history: - 29-Nov-2004 Zombie created */ int ncPhyCompositeObj::Collide( const ncPhysicsObj* obj, int numContacts, nPhyCollide::nContact* contact ) const { n_assert2( obj , "Null pointer" ); #ifndef NGAME if( !numContacts ) { // nothing to do return 0; } #endif n_assert2( contact , "Null pointer" ); int nContacts(numContacts); int nReportedContacts(0); for( int index(0); index < this->containerGeometries.Size(); ++index ) { int nReported ( obj->Collide( this->containerGeometries.GetElementAt(index), nContacts, contact + nReportedContacts ) ); if( !nReported ) continue; nContacts -= nReported; nReportedContacts += nReported; if( !nContacts ) break; // no more space for more contacts } return nReportedContacts; } //----------------------------------------------------------------------------- /** Sets the material for all the geometries contain in the object. @param material material id history: - 29-Nov-2004 Zombie created */ void ncPhyCompositeObj::SetMaterial( nPhyMaterial::idmaterial material ) { for( int index(0); index < this->containerGeometries.Size(); ++index ) { static_cast<nPhyGeomTrans*>(this->containerGeometries.GetElementAt(index))->GetGeometry()->SetMaterial( material ); } ncPhysicsObj::SetMaterial( material ); } //----------------------------------------------------------------------------- /** Returns the bounding box of this geometry. @param material material id history: - 29-Nov-2004 Zombie created */ void ncPhyCompositeObj::GetAABB( nPhysicsAABB& boundingbox ) { if( this->objectSpace ) { this->objectSpace->GetAABB( boundingbox ); } #ifndef NGAME int NumGeometries(this->containerGeometries.Size()); if( !NumGeometries ) { return; } #endif this->containerGeometries.GetElementAt(0)->GetAABB( boundingbox ); for( int index(1); index < this->containerGeometries.Size(); ++index ) { nPhysicsAABB localBox; this->containerGeometries.GetElementAt(index)->GetAABB( localBox ); boundingbox += localBox; } } //----------------------------------------------------------------------------- /** Creates the object. @param world it's the world where the object will be come to existance history: - 29-Nov-2004 Zombie created */ void ncPhyCompositeObj::Create( nPhysicsWorld* world ) { n_assert2( world, "Null pointer" ); if( this->subSpaceAllowed ) { if( this->GetNumGeometries() > 1 ) { // if more than one geometry creating a sub-space this->CreateSpace(); // adding each geometry to the sub-space for( int index(0); index < this->GetNumGeometries(); ++index ) { this->GetGeometry(index)->MoveToSpace( this->objectSpace ); } } } ncPhysicsObj::Create( world ); nPhyRigidBody *body(this->GetBody()); if( body ) { this->SetBody( body ); vector3 position; this->GetPosition(position); this->GetBody()->SetPosition(position); nPhysicsAABB aabb; this->GetAABB( aabb ); vector3 center( aabb.maxx + aabb.minx, aabb.maxy + aabb.miny, aabb.maxz + aabb.minz ); center *= phyreal(.5); center = center - position; vector3 tweakedOffset; this->GetTweakedOffset( tweakedOffset ); if( tweakedOffset.lensquared() ) { center = tweakedOffset; } if( center.len() > phyreal( .001 ) ) { this->GetBody()->SetTweaked( true ); this->GetBody()->SetTweakedOffset( center ); for( int index(0); index < this->GetNumGeometries(); ++index ) { nPhyGeomTrans* trans( static_cast<nPhyGeomTrans*> (this->containerGeometries.GetElementAt(index))); vector3 geometryPosition; if( tweakedOffset.lensquared() == 0 ) { trans->GetGeometry()->GetPosition( geometryPosition ); trans->GetGeometry()->SetPosition( geometryPosition - center ); } } this->SetPosition( position ); } /// assigns to each geometry de body body->Update( this->containerGeometries, this->GetMass(), this->GetDensity() ); body->SetPhysicsObj( this ); if( this->objectSpace ) { this->objectSpace->SetCategories( this->GetCategories() ); this->objectSpace->SetCollidesWith( this->GetCollidesWith() ); } } } //----------------------------------------------------------------------------- /** Returns the orientation of the object. @param rotation matrix33 that will be filled with the object orientation history: - 08-Apr-2005 Zombie created */ void ncPhyCompositeObj::GetOrientation( matrix33& rotation ) { nPhyRigidBody* body( this->GetBody() ); if( body ) { body->GetOrientation( rotation ); return; } #ifndef NGAME if( !this->containerGeometries.Size() ) { NLOG( physicsLog , (1, "# Physics Object without collision." ) ); return; } #endif this->containerGeometries.GetElementAt(0)->GetOrientation( rotation ); } //----------------------------------------------------------------------------- /** User init instance code. @param loaded indicates if the instance is bare new of loaded history: - 09-May-2005 Zombie created */ void ncPhyCompositeObj::InitInstance(nObject::InitInstanceMsg initType) { ncPhysicsObj::InitInstance( initType ); } //----------------------------------------------------------------------------- /** Creates an object composited. @param name name of the geometry class to be created. @return the created geometry history: - 09-May-2005 Zombie created */ nPhysicsGeom* ncPhyCompositeObj::CreateGeometryObj( const nString& name ) { n_assert2( name != "", "Invalid geometry name object." ); nPhysicsGeom* geometry(static_cast<nPhysicsGeom*>(nKernelServer::Instance()->New( name.Get() ))); n_assert2( geometry, "Failed to create a geometry." ); nKernelServer::Instance()->GetPersistServer()->BeginObjectLoad(geometry, nObject::LoadedInstance); this->Add( geometry ); return geometry; } //------------------------------------------------------------------------------ /** Scales the object. @param factor scale factor history: - 12-May-2005 Zombie created */ void ncPhyCompositeObj::Scale( const phyreal factor ) { if( factor == this->GetLastScaledFactor() ) return; /// updating geometry for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->Scale( factor / this->GetLastScaledFactor() ); } /// updating mass distribution if( this->GetBody() ) { this->GetBody()->Update( this->containerGeometries, this->GetMass(), this->GetDensity() ); } this->SetLastScaledFactor( factor ); } //----------------------------------------------------------------------------- /** Checks if the object collides with anything in his own world. @param numContacts number maximun of contacts expected @param contact array of contacts structures information @return number of contacts reported history: - 13-May-2005 Zombie created */ int ncPhyCompositeObj::Collide( int numContacts, nPhyCollide::nContact* contact ) const { n_assert2( contact, "Null pointer." ); int contacts( 0 ); for( int index(0); index < this->containerGeometries.Size(); ++index ) { contacts += nPhysicsServer::Instance()->Collide( this->containerGeometries.GetElementAt(index), numContacts - contacts, &contact[contacts] ); if( numContacts == contacts ) break; } return contacts; } //----------------------------------------------------------------------------- /** Sets the categories where the object belongs. @param categories bit's mask with the a new set of categories history: - 13-May-2005 Zombie created */ void ncPhyCompositeObj::SetCategories( int categories ) { #ifndef NGAME if( !this->containerGeometries.Size() ) { NLOG( physicsLog , (1, "# It requieres at least a geometry." ) ); return; } #endif for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->SetCategories( categories ); } ncPhysicsObj::SetCategories( categories ); } //----------------------------------------------------------------------------- /** Sets the categories wich the object will collide with. @param categories bit's mask with the a new set of categories history: - 13-May-2005 Zombie created */ void ncPhyCompositeObj::SetCollidesWith( int categories ) { #ifndef NGAME if( !this->containerGeometries.Size() ) { NLOG( physicsLog , (1, "# Physics Object without collision." ) ); return; } #endif for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->SetCollidesWith( categories ); } } #ifndef NGAME //----------------------------------------------------------------------------- /** Removes a collide with. @param category a category history: - 13-Jun-2005 Zombie created */ void ncPhyCompositeObj::RemovesCollidesWith( int category ) { for( int index(0); index < this->containerGeometries.Size(); ++index ) { this->containerGeometries.GetElementAt(index)->RemovesCollidesWith( nPhysicsGeom::Category(category) ); } ncPhysicsObj::RemovesCollidesWith( category ); } #endif //----------------------------------------------------------------------------- /** Creates composite space. history: - 18-Jul-2005 Zombie created */ void ncPhyCompositeObj::CreateSpace() { this->objectSpace = static_cast<nPhyGeomSpace*>(nKernelServer::Instance()->New("nphygeomspace")); n_assert2( this->objectSpace, "Failed to create an space for the composite object" ); } //----------------------------------------------------------------------------- /** Sets if the creation of an object's sub-space. @param is specifies if the object can create a sub-space history: - 18-Jul-2005 Zombie created */ void ncPhyCompositeObj::AllowCreateSubSpace( const bool is ) { this->subSpaceAllowed = is; } //----------------------------------------------------------------------------- // EOF //-----------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 837 ] ] ]
8487d8e3442f799cdba5000f21ee95d307cdd469
172e5e180659a6a7242f95a367f5a879114bc38d
/SlideList/PrintingSupport.cpp
409352dff954df0b03426bd6ce90f404eba13f11
[]
no_license
urere/mfcslidelist
1e66fc1a7b34f7832f5d09d278d2dd145d30adec
7c7eb47122c6b7c3b52a93145ec8b2d6f2476519
refs/heads/master
2021-01-10T02:06:44.884376
2008-03-27T21:25:09
2008-03-27T21:25:09
47,465,994
0
0
null
null
null
null
UTF-8
C++
false
false
10,720
cpp
// PrintingSupport.cpp: implementation of the CPrintingSupport class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "SlideList.h" #include "PrintingSupport.h" #include "SlideListDoc.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif #define FORMFEED 0x0c #define REPORT_CONFIG_START "<START_REPORT_CONFIG>" #define REPORT_CONFIG_END "<END_REPORT_CONFIG>" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CPrintingSupport::CPrintingSupport( CSlideListDoc *pDocument, LPCTSTR pReportFileName ) { m_pDocument = pDocument; ASSERT(m_pDocument); // Store the name of the file containing the report to be printed m_csReportFileName = pReportFileName; // Set the size of the cache array to twice the number of films // If this is exceeded grow the array 10 entries at a time m_PageFilePosition.SetSize( 0, 1 ); // Ensure all of the cached pages are 0xffffffff int NumPages = m_PageFilePosition.GetSize(); for ( int Page = 0; Page < NumPages; Page++ ) { m_PageFilePosition[Page] = 0xffffffff; } // Default page layout m_pDC = NULL; m_pInfo = NULL; m_CurrentYPos = 0; m_TopMargin = 0; m_BottomMargin = 0; m_LeftMargin = 0; m_RightMargin = 0; m_CurrentRowHeight = 0; } CPrintingSupport::~CPrintingSupport() { // Delete all of the fonts from the cache DeleteFontCache(); } BOOL CPrintingSupport::OnPreparePrinting(CPrintInfo* pInfo) { // Scan through the report file and count the number of pages // Also record the position of each page so that it can be // quickly located later // Configuration information delimited by // <START_REPORT_CONFIG> and // <END_REPORT_CONFIG> // may appear at the start of the file. These delimiters will // be ignored after report data as been read BOOL bFileScanned = FALSE; CStdioFile ReportFile; if ( ReportFile.Open( m_csReportFileName, CFile::modeRead | CFile::typeText ) ) { CString csLine; DWORD FilePosition = 0; DWORD CurrentPage = 0; BOOL bReadingConfig = FALSE; BOOL bNewPage = TRUE; while ( ReportFile.ReadString( csLine ) ) { // Are we reading configuration information at the moment if ( bReadingConfig ) { // Process this line as configuration information if ( csLine == REPORT_CONFIG_END ) { bReadingConfig = FALSE; } } else { // Start of config ? if ( (CurrentPage == 0) && (csLine == REPORT_CONFIG_START) ) { bReadingConfig = TRUE; } else { // This is a report data line // First line of new page page ? if ( bNewPage ) { CurrentPage += 1; m_PageFilePosition.SetAtGrow( CurrentPage-1, FilePosition ); bNewPage = FALSE; } else { // Start of a new page ? if ( (csLine.GetLength() > 0) && (csLine[0] == FORMFEED) ) { // Rest of this line is one a new page if ( csLine.GetLength() > 1 ) { CurrentPage += 1; // Add 1 to the file position to skip over the FF m_PageFilePosition.SetAtGrow( CurrentPage-1, FilePosition+1 ); } else { // Next line starts the new page bNewPage = TRUE; } } } } } // Remember the current file position FilePosition = ReportFile.GetPosition(); } ReportFile.Close(); // Store the number of pages in the report pInfo->SetMinPage( 1 ); pInfo->SetMaxPage( CurrentPage ); bFileScanned = TRUE; } return ( bFileScanned ); } void CPrintingSupport::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) { pDC->SetMapMode( MM_TWIPS ); AddFont( pDC, "DEFAULT", "Courier New", 12, FALSE, FALSE, FALSE ); } void CPrintingSupport::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { pDC->SetMapMode( MM_TWIPS ); } void CPrintingSupport::OnPrint(CDC* pDC, CPrintInfo* pInfo) { // Print the requested page // Does this page already exist in the page case ? int PageCacheIndex = (int) pInfo->m_nCurPage - 1; // Is there room in the current page cache ? if ( PageCacheIndex <= m_PageFilePosition.GetUpperBound() ) { // Print the page starting at this file position CStdioFile ReportFile; if ( ReportFile.Open( m_csReportFileName, CFile::modeRead | CFile::typeText ) ) { CString csLine; // Set file position to the start of the requested page ReportFile.Seek( m_PageFilePosition[PageCacheIndex], CFile::begin ); // Output the page StartPage( pDC, pInfo ); while ( ReportFile.ReadString( csLine ) ) { // End of page yet ? if ( csLine.GetLength() > 0 ) { if ( csLine[0] != FORMFEED ) { // Output this line OutputText( "DEFAULT", csLine ); NextRow(); } else { // End of page reached break; } } else { // Blank line OutputText( "DEFAULT", " " ); NextRow(); } } ReportFile.Close(); } } } void CPrintingSupport::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // Delete all of the fonts from the cache DeleteFontCache(); } BOOL CPrintingSupport::AddFont( CDC *pDC, LPCTSTR pLocalName, LPCTSTR pFaceName, int PointSize, BOOL bBold /* = FALSE */, BOOL bItalic /* = FALSE */, BOOL bUnderLine /* = FALSE */ ) { // Creates a font matching the requested specification and stores in the cache using the local name // supplied BOOL bCreated = FALSE; // If it already exists, assume its already been created if ( GetFont( pLocalName ) == NULL ) { LOGFONT PointFont; // Common font attributes memset( &PointFont, 0, sizeof(PointFont) ); PointFont.lfOutPrecision = OUT_DEFAULT_PRECIS; PointFont.lfQuality = PROOF_QUALITY; PointFont.lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH; // Point size PointFont.lfHeight = 10 * PointSize; // Bold, italic, underline if ( bBold ) PointFont.lfWeight = FW_BOLD; else PointFont.lfWeight = FW_NORMAL; PointFont.lfItalic = bItalic; PointFont.lfUnderline = bUnderLine; // Face name strcpy( PointFont.lfFaceName, pFaceName ); // Create it CFont *pNewFont = new CFont(); if ( pNewFont ) { if ( pNewFont->CreatePointFontIndirect( &PointFont, pDC ) ) { // Add it to the cache m_FontCache.SetAt( pLocalName, (CObject *) pNewFont ); // Add a TEXTMETICS structure to the cache // First need to select the font CFont *pOldFont = pDC->SelectObject( pNewFont ); // Then store the info TEXTMETRIC *pFontInfo = new TEXTMETRIC; pDC->GetTextMetrics( pFontInfo ); m_FontInfoCache.SetAt( pLocalName, (void *) pFontInfo ); pDC->SelectObject( pOldFont ); bCreated = TRUE; } else { delete pNewFont; } } } else { // It already exists bCreated = TRUE; } return ( bCreated ); } CFont *CPrintingSupport::GetFont( LPCTSTR pLocalName ) { // Return the requested font, NULL if not found CFont *pFont = NULL; if ( !m_FontCache.Lookup( pLocalName, (CObject *&) pFont ) ) { // Failed to find the font pFont = NULL; } return( pFont ); } TEXTMETRIC *CPrintingSupport::GetFontInfo( LPCTSTR pLocalName ) { // Return the requested TEXTMETRIC, NULL if not found TEXTMETRIC *pFontInfo = NULL; if ( !m_FontInfoCache.Lookup( pLocalName, (void *&) pFontInfo ) ) { // Failed to find the font pFontInfo = NULL; } return( pFontInfo ); } void CPrintingSupport::DeleteFontCache() { // Delete all of the fonts in the cache POSITION Pos; // The fonts Pos = m_FontCache.GetStartPosition(); while ( Pos ) { CString csLocalName; CFont *pFont = NULL; // Get the next font m_FontCache.GetNextAssoc( Pos, csLocalName, (CObject *&) pFont ); ASSERT(pFont); delete pFont; } // Remove all of the keys m_FontCache.RemoveAll(); // The TEXTMETRIC Pos = m_FontInfoCache.GetStartPosition(); while ( Pos ) { CString csLocalName; TEXTMETRIC *pFontInfo = NULL; // Get the next font m_FontInfoCache.GetNextAssoc( Pos, csLocalName, (void *&) pFontInfo ); ASSERT(pFontInfo); delete (TEXTMETRIC *) pFontInfo; } // Remove all of the keys m_FontInfoCache.RemoveAll(); } // Page Layout function void CPrintingSupport::DefinePageLayout( int TopMargin, int BottomMargin, int LeftMargin, int RightMargin ) { m_TopMargin = TopMargin; m_BottomMargin = BottomMargin; m_LeftMargin = LeftMargin; m_RightMargin = RightMargin; } void CPrintingSupport::StartPage( CDC *pDC, CPrintInfo* pInfo ) { // This signals the start of a new page, clear all of the structures used to track // current position on the page m_CurrentYPos = 0; m_CurrentYPos -= m_TopMargin; m_CurrentRowHeight = 0; // Store the DC and printer information for later use m_pDC = pDC; m_pInfo = pInfo; } BOOL CPrintingSupport::OutputText( LPCTSTR pLocalFontName, LPCTSTR pText ) { // Output a single line of text // The YPos is the current YPos BOOL bOutput = FALSE; ASSERT(m_pDC); ASSERT(m_pInfo); // Change to the requested font CFont *pOldFont = m_pDC->SelectObject( GetFont( pLocalFontName ) ); m_pDC->TextOut( m_LeftMargin, m_CurrentYPos, pText ); // Use the font height to set of height for this row IF it is greater than any thing // already output at this position TEXTMETRIC *pFontInfo = GetFontInfo( pLocalFontName ); ASSERT(pFontInfo); int TextHeight = pFontInfo->tmHeight + pFontInfo->tmExternalLeading; if ( TextHeight > m_CurrentRowHeight ) { m_CurrentRowHeight = TextHeight; } m_pDC->SelectObject( pOldFont ); return ( bOutput ); } BOOL CPrintingSupport::DrawLine( int Width, int XStart /* = -1 */, int XStop /* = -1 */ ) { BOOL bOutput = FALSE; ASSERT(m_pDC); ASSERT(m_pInfo); // Complete current Row if ( m_CurrentRowHeight > 0 ) { NextRow(); } m_CurrentYPos -= 10+Width; m_pDC->MoveTo( m_LeftMargin, m_CurrentYPos ); m_pDC->LineTo( m_pInfo->m_rectDraw.Width() - m_RightMargin, m_CurrentYPos ); // set the new Y position down by twice the width of the line m_CurrentYPos -= 10+Width; return( bOutput ); } void CPrintingSupport::NextRow() { // Move the Y position down by the current row height and reset this to zero m_CurrentYPos -= m_CurrentRowHeight; m_CurrentRowHeight = 0; }
[ "ratcliffe.gary@e6454d50-7149-0410-9942-4ffd99bf3498" ]
[ [ [ 1, 453 ] ] ]
b1729a2f8656a9b19d565e70d505a5e130176c05
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/SupportWFLib/symbian/BTGPS/Reporter.cpp
0f6d95fce0345fb25b8727a34b68e8134a9f19c7
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,795
cpp
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 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. */ #if !(defined NAV2_CLIENT_UIQ || defined NAV2_CLIENT_UIQ3) #include "Reporter.h" #include <bttypes.h> CBtReporter::CBtReporter(class MGpsConnectionObserver* aObserver) : iObserver(aObserver) {} void CBtReporter::ConstructL() { iGenerator = CEventGenerator<CBtReporter, CBtEvent*>::NewL(*this); } class CBtReporter* CBtReporter::NewL(class MGpsConnectionObserver* aObserver) { class CBtReporter* self = new (ELeave) CBtReporter(aObserver); self->ConstructL(); return self; } void CBtReporter::HandleGeneratedEventL(class CBtEvent* aEvent) { aEvent->Report(iObserver); delete aEvent; } void CBtReporter::BluetoothDebug(const TDesC& aDbgMsg) { iGenerator->SendEvent(CBtEvent::NewDebugL(aDbgMsg)); } void CBtReporter::BluetoothError(const TDesC& aErrorMsg) { iGenerator->SendEvent(CBtEvent::NewErrorL(aErrorMsg)); } void CBtReporter::BluetoothError(TInt aErrorMsg) { iGenerator->SendEvent(CBtEvent::NewErrorL(aErrorMsg)); } void CBtReporter::BluetoothStatus(TBool aOk) { iGenerator->SendEvent(CBtEvent::NewStatusL(aOk)); } void CBtReporter::BluetoothDeviceChosen(TInt64 aAddr, const TDesC& aName) { iGenerator->SendEvent(CBtEvent::NewDeviceL(aAddr, aName)); } void CBtReporter::BluetoothDeviceChosen(const class TBTDevAddr& aAddr, const TDesC& aName) { iGenerator->SendEvent(CBtEvent::NewDeviceL(aAddr, aName)); } /// CBtEvent class CBtEvent* CBtEvent::NewDebugL(const TDesC& aDbgMsg) { return CBtTextDebugEvent::NewL(aDbgMsg); } class CBtEvent* CBtEvent::NewErrorL(const TDesC& aErrorMsg) { return CBtTextErrorEvent::NewL(aErrorMsg); } class CBtEvent* CBtEvent::NewErrorL(TInt aErrorMsg) { return CBtIntErrorEvent::NewL(aErrorMsg); } class CBtEvent* CBtEvent::NewStatusL(TBool aOk) { return CBtStatusEvent::NewL(aOk); } class CBtEvent* CBtEvent::NewDeviceL(TInt64 aAddr, const TDesC& aName) { return CBtDeviceEvent<TInt64>::NewL(aAddr, aName); } class CBtEvent* CBtEvent::NewDeviceL(const class TBTDevAddr& aAddr, const TDesC& aName) { return CBtDeviceEvent<TBTDevAddr>::NewL(aAddr, aName); } #endif
[ [ [ 1, 103 ] ] ]
133de87276b8ad9525ee040bd73c145f04799fe3
f2385a5a332401269b27f91a9d259c2395c3016c
/AHokey/AHokey/MainFrm.cpp
341769059470719953cc7894cb5f6d49aae528f8
[]
no_license
mohamedAAhassan/airhockey
33fe436131f6f693425ba3e83da2f53605388aac
35ce7c457f5c3ab2a2620deb5b8b844eca235071
refs/heads/master
2021-01-01T05:45:20.237879
2009-10-15T11:33:11
2009-10-15T11:33:11
56,930,383
0
0
null
null
null
null
UTF-8
C++
false
false
2,251
cpp
// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include "AHokey.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMainFrame IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() ON_WM_SETFOCUS() END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // create a view to occupy the client area of the frame if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) { TRACE0("Failed to create view window\n"); return -1; } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs cs.dwExStyle &= ~WS_EX_CLIENTEDGE; cs.lpszClass = AfxRegisterWndClass(0); return TRUE; } // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG // CMainFrame message handlers void CMainFrame::OnSetFocus(CWnd* /*pOldWnd*/) { // forward focus to the view window m_wndView.SetFocus(); } BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { // let the view have first crack at the command if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; // otherwise, do default handling return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
[ "mitjasantl@07432978-1335-11de-a4db-e31d5fa7c4f0" ]
[ [ [ 1, 114 ] ] ]
6beb495e69d5b7eb6be4a086939b53e2b95d0d4a
dd5c8920aa0ea96607f2498701c81bb1af2b3c96
/multicrewcore/hostconnection.cpp
edb694d635f79de07f724f791036408d2ef406e9
[]
no_license
BackupTheBerlios/multicrew-svn
913279401e9cf886476a3c912ecd3d2b8d28344c
5087f07a100f82c37d2b85134ccc9125342c58d1
refs/heads/master
2021-01-23T13:36:03.990862
2005-06-10T16:52:32
2005-06-10T16:52:32
40,747,367
0
0
null
null
null
null
UTF-8
C++
false
false
4,927
cpp
/* Multicrew Copyright (C) 2004,2005 Stefan Schimanski 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; either version 2 of the License, or (at your option) any later version. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "common.h" #include <windows.h> #include "../RakNet/source/PacketEnumerations.h" #include "../RakNet/source/RakNetworkFactory.h" #include "../RakNet/source/RakClientInterface.h" #include "../RakNet/source/RakServerInterface.h" #include "../RakNet/source/NetworkTypes.h" #include "../RakNet/source/Multiplayer.h" #include "streams.h" #include "log.h" #include "config.h" #include "network.h" #include "callback.h" class HostConnectionImpl : public Connection, public Multiplayer<RakServerInterface> { public: HostConnectionImpl( RakServerInterface* server ) { this->server = server; this->client = RakNetworkFactory::GetRakClientInterface(); // just for the dotted string function } virtual ~HostConnectionImpl() { if( server!=0 ) { server->Disconnect( 300 ); stopThread(); RakNetworkFactory::DestroyRakServerInterface( server ); } else stopThread(); RakNetworkFactory::DestroyRakClientInterface( client ); } void start() { // setState( connectingState ); setState( connectedState ); } bool sendImpl( char *buf, unsigned len, PacketPriority priority, PacketReliability reliability, unsigned orderingChannel ) { if( server->GetConnectedPlayers()>0 ) { return server->Send( buf, len, priority, reliability, orderingChannel, UNASSIGNED_PLAYER_ID, true ); } else return true; } void disconnect() { server->Disconnect( 300 ); setState( disconnectedState ); } void processImpl() { if( server!=0 ) ProcessPackets( server ); } protected: virtual void ProcessUnhandledPacket(Packet *packet, unsigned char packetIdentifier, RakServerInterface *interfaceType) { //dout << "Receive packet" << std::endl; processPacket( ((char*)packet->data)+1, packet->length-1 ); } virtual void ReceiveRemoteDisconnectionNotification(Packet *packet,RakServerInterface *interfaceType) { dlog << "Client " << client->PlayerIDToDottedIP( packet->playerId ) << " disconnected" << std::endl; } virtual void ReceiveDisconnectionNotification(Packet *packet,RakServerInterface *interfaceType) { dlog << "Client disconnected" << std::endl; } virtual void ReceiveNewIncomingConnection(Packet *packet,RakServerInterface *interfaceType) { dlog << "Incoming connection from " << client->PlayerIDToDottedIP( packet->playerId ) << std::endl; } virtual void ReceiveModifiedPacket(Packet *packet,RakServerInterface *interfaceType) { setState( disconnectedState, "Modified packet. Cheater!" ); } virtual void ReceiveConnectionLost(Packet *packet,RakServerInterface *interfaceType) { setState( disconnectedState, "Client connection lost" ); } RakServerInterface *server; RakClientInterface *client; }; /***********************************************************************/ struct HostConnectionSetup::Data { RakServerInterface* server; }; HostConnectionSetup::HostConnectionSetup() { d = new Data; d->server = 0; } HostConnectionSetup::~HostConnectionSetup() { dout << "~HostConnectionSetup()" << std::endl; if( d->server!=0 ) RakNetworkFactory::DestroyRakServerInterface( d->server ); delete d; } SmartPtr<Connection> HostConnectionSetup::host( int port, std::string sessionName, bool passwordEnabled, std::string password ) { // create server object dlog << "Creating server object" << std::endl; d->server = RakNetworkFactory::GetRakServerInterface(); if( d->server==0 ) { dlog << "Failed." << std::endl; return 0; } // setup connection parameters if( passwordEnabled ) d->server->SetPassword( (char*)password.c_str() ); //d->server->DisableSecurity(); // host the game dlog << "Hosting session" << std::endl; bool ok = d->server->Start( 8, 0, 50, port ); if( !ok ) { dlog << "Failed" << std::endl; return 0; } // create connection object SmartPtr<HostConnectionImpl> con( new HostConnectionImpl( d->server ) ); con->start(); d->server = 0; return &*con; }
[ "schimmi@cb9ff89a-abed-0310-8fc6-a4cabe7d48c9" ]
[ [ [ 1, 173 ] ] ]
fbf93e2c0b0886a6c49b4b3bd51aa77c99a014a5
3aa10cc23053d3f9804c948d7bf3cbf6c6bd4687
/Mods/CGsp/ZPseudo.h
18f119c5b1661bdf595f1c50ab3b424e7ccabc8e
[]
no_license
ASDen/ZParser
4ea86a4e2d3c5d9b7e389514136990789b2a58ca
fd19e2c935540b6c14b53018653cf1efd7525326
refs/heads/master
2020-05-26T09:03:22.637121
2010-07-07T14:54:11
2010-07-07T14:54:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
416
h
enum PClasses { _XAxis, _YAxis, _ZAxis }; template<PClasses T> class ZPseudo : public ZTBaseObject< ZPseudo<T> > { public: ZPseudo() {} ZPseudo(ZTvarS inp) {ZPseudo();} static void Init() { StProps.InitScope(); ZTObject::Inheriet(StProps); } }; typedef ZPseudo<PClasses::_XAxis> PXAxis; typedef ZPseudo<PClasses::_YAxis> PYAxis; typedef ZPseudo<PClasses::_ZAxis> PZAxis;
[ [ [ 1, 27 ] ] ]
fc35b50d53519a44f5824cdf2527aa16b46972d9
d1d0b65cc4346448f02908f8861fc82cb30b1afc
/include/GuiController.h
dd449eaef80ca2a7aa9d76402710f2ca6bb868de
[]
no_license
safetydank/netphyx
506abf3da64b2fc3be043296151b5d9cda17acd6
2206bd4f5c4cc353b8b1390332638b9382497aaf
refs/heads/master
2016-09-10T03:57:55.477745
2011-02-10T23:49:07
2011-02-10T23:49:07
1,352,958
3
1
null
null
null
null
UTF-8
C++
false
false
8,374
h
#pragma once #include <iosfwd> #include <list> #include <boost/smart_ptr.hpp> #include <boost/iostreams/categories.hpp> #include <map> #include <iostream> #include <sstream> #include <string> #include "cinder/app/KeyEvent.h" #include "cinder/app/MouseEvent.h" #include "cinder/Color.h" #include "cinder/Vector.h" #include "cinder/gl/Texture.h" namespace netphy { struct Shared; class GuiController; class GuiRenderer { GuiRenderer(GuiController& controller); void draw(); GuiController& mGui; }; struct GuiCallback { virtual bool operator()(std::string) = 0; }; struct GuiCallbackGG : public GuiCallback { Shared& GG; GuiCallbackGG(Shared& shared) : GG(shared) { } explicit GuiCallbackGG(); virtual bool operator()(std::string) = 0; }; typedef boost::shared_ptr<GuiCallback> GuiCallbackPtr; class GuiWidget; typedef boost::shared_ptr<GuiWidget> GuiWidgetPtr; class GuiWidget { protected: std::map<std::string, GuiCallbackPtr> mCallbacks; explicit GuiWidget(); GuiController& mGui; GuiWidget* mParent; std::list<GuiWidgetPtr> mChildren; ci::Vec2f mPos; ci::Vec2f mSize; virtual void drawImpl() { } virtual void updateImpl() { } bool mPurge; public: GuiWidget(GuiController& gui, GuiWidget* parent=0) : mGui(gui), mParent(0), mPos(0,0), mPurge(false) { } virtual ~GuiWidget() {} void draw(); void update(); ci::Vec2f getPos(); void setPos(const ci::Vec2f& pos); ci::Vec2f getWorldPos(); ci::Vec2f getSize(); void addChild(GuiWidgetPtr child); GuiWidgetPtr getFirstChild() { return *(mChildren.begin()); } // Detach from controller void detach(); // Purged widgets are safely detached from the controller at the end of update() void purge(bool value=true) { mPurge = value; } bool isPurged() { return mPurge; } virtual bool keyDown(ci::app::KeyEvent event) { return false; } virtual bool mouseDown(ci::app::MouseEvent event) { return false; } virtual bool mouseUp(ci::app::MouseEvent event) { return false; } virtual void mouseMove(ci::app::MouseEvent event) { } void signal(std::string name); // attach a callback to a given slot void slot(std::string name, GuiCallbackPtr callback); // remove any callbacks from a given slot void resetSlot(std::string name); }; struct GuiLabelData { std::string Text; int Justify; std::string Font; float FontSize; ci::ColorA FgColor; ci::ColorA BgColor; GuiLabelData() : Text(""), Justify(0), Font("Droid Sans"), FontSize(16.0f), FgColor(1.0f, 1.0f, 1.0f, 1.0f), BgColor(0, 0, 0, 1.0f) { } }; class GuiLabelWidget; typedef boost::shared_ptr<GuiLabelWidget> GuiLabelWidgetPtr; class GuiLabelWidget : public GuiWidget { protected: virtual void updateImpl(); virtual void drawImpl(); GuiLabelData mData; ci::gl::Texture mTexture; std::vector<std::string> mText; public: GuiLabelWidget(GuiController& gui, const GuiLabelData& spec); ~GuiLabelWidget(); GuiLabelData& getData() { return mData; } }; struct GuiQuadData { ci::Rectf Rect; ci::ColorA Color; }; class GuiQuadWidget : public GuiWidget { protected: virtual void updateImpl(); virtual void drawImpl(); GuiQuadData mData; ci::gl::Texture mTexture; public: GuiQuadWidget(GuiController& gui, const GuiQuadData& spec); ~GuiQuadWidget(); GuiQuadData& getData() { return mData; } }; typedef boost::shared_ptr<GuiQuadWidget> GuiQuadWidgetPtr; struct GuiBoxData { float Padding; }; class GuiBoxWidget : public GuiQuadWidget { protected: GuiBoxData mBoxData; virtual void updateImpl(); public: GuiBoxWidget(GuiController& gui, const GuiQuadData& quadData, const GuiBoxData& boxData); ~GuiBoxWidget(); GuiBoxData& getBoxData() { return mBoxData; } }; typedef boost::shared_ptr<GuiBoxWidget> GuiBoxWidgetPtr; class GuiButtonWidget : public GuiWidget { public: GuiButtonWidget(GuiController& gui); ~GuiButtonWidget() { } virtual bool mouseDown(ci::app::MouseEvent event); virtual bool mouseUp(ci::app::MouseEvent event); virtual void mouseMove(ci::app::MouseEvent event); protected: bool mMouseDown; bool mMouseInside; virtual void updateImpl(); virtual void drawImpl(); }; typedef boost::shared_ptr<GuiButtonWidget> GuiButtonWidgetPtr; class ConsoleInputBuffer { public: ConsoleInputBuffer(); ~ConsoleInputBuffer(); void insertCharAtCursor(char ch); void backspace(); void saveInput(); std::string getInput(); std::string getInputBuffer(); protected: // std::stringstream mBuffer; int mCursorPos; std::string mInput; std::string mInputBuffer; }; class GuiConsole; class GuiConsoleStream { public: GuiConsoleStream(GuiConsole& console) : mConsole(console) { } GuiConsoleStream(const GuiConsoleStream& stream) : mConsole(stream.mConsole) { } // boost::iostreams implementation typedef char char_type; typedef boost::iostreams::sink_tag category; std::streamsize write(const char* s, std::streamsize n); private: GuiConsole& mConsole; }; typedef boost::iostreams::stream<GuiConsoleStream> GuiConsoleOutput; class GuiConsole : public GuiWidget { public: GuiConsole(GuiController& gui, int lineCount, float fontSize); boost::iostreams::stream<GuiConsoleStream> output(); void appendString(const std::string& text); // clears buffer void clear(); // Set console widget width. Height is based on font height * number of lines void setWidth(float width); virtual bool keyDown(ci::app::KeyEvent event); std::string getInput(); protected: int mLineCount; std::list<std::string> mBuffer; std::list<GuiLabelWidgetPtr> mLines; // The point in the buffer where the display starts std::list<std::string>::iterator mConsoleStart; ConsoleInputBuffer mConsoleBuffer; // std::string mInput; // std::stringstream mInputBuffer; GuiLabelWidgetPtr mInputLine; virtual void updateImpl(); virtual void drawImpl(); private: explicit GuiConsole(); explicit GuiConsole(GuiConsole&); GuiConsoleStream mStream; }; typedef boost::shared_ptr<GuiConsole> GuiConsolePtr; class GuiFactory { public: GuiFactory(GuiController& gui) : mGui(gui) { } explicit GuiFactory(); ~GuiFactory() { } // XXX should not be attached by default!!! GuiButtonWidgetPtr createTextButton(std::string text, float fontSize, bool attach=false); GuiConsolePtr createConsole(int lines, float fontSize, bool attach=false); GuiButtonWidgetPtr createTextLabel(bool attach=false); private: GuiController& mGui; }; typedef boost::shared_ptr<GuiFactory> GuiFactoryPtr; class GuiController { public: GuiController(); void update(); void draw(); // Primitives GuiLabelWidgetPtr createLabel(const GuiLabelData& spec, bool attachWidget=true); GuiButtonWidgetPtr createButton(std::vector<GuiWidgetPtr> children, bool attachWidget=false); GuiQuadWidgetPtr createQuad(const GuiQuadData& data, bool attachWidget=true); GuiBoxWidgetPtr createBox(const GuiQuadData& data, const GuiBoxData& boxData, bool attachWidget=true); std::vector<GuiWidgetPtr>& widgets(); void attach(GuiWidgetPtr widget); void detach(GuiWidget* ptr); void detachAll(); bool keyDown(ci::app::KeyEvent event); void mouseMove(ci::app::MouseEvent event); bool mouseDown(ci::app::MouseEvent event); bool mouseUp(ci::app::MouseEvent event); void mouseDrag(ci::app::MouseEvent event); bool mouseWheel(ci::app::MouseEvent event); void setShared(boost::shared_ptr<Shared> shared) { mShared = shared; } protected: boost::shared_ptr<Shared> mShared; std::list<GuiWidgetPtr> mWidgets; boost::shared_ptr<GuiRenderer> mRenderer; }; }
[ [ [ 1, 328 ] ] ]
31d110d9f858b86be5b9b9574f4e73a349683e74
1724fb22a0b715c4597c5056ce571f0fbdb1cc46
/opengta2/input.cpp
717ddd3c9c465f7f6d2c526a85ec5cc7db5f0aa5
[]
no_license
basecq/OpenGTA2
71127e333b7b6c6a60388ad8b4fb5c4408aa5bdd
2266c354a638397b84ca4766c69e3a50f4e367de
refs/heads/master
2020-04-06T05:25:34.926813
2010-01-27T02:35:09
2010-01-27T02:35:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,875
cpp
#include "opengta_cl.h" //FIXME: temp, and only for debugging //add message manager PLEASE #include "opengta_sv.h" Input_Manager Input; void GLFWCALL charCallback(int key, int action) { if( action != GLFW_PRESS ) { return; } Console.keyboardInput(key); } void Input_Manager::Initialize() { Client = BAD_ID; glfwSetCharCallback(charCallback); } void Input_Manager::Frame() { for (int i = 0; i < NUM_KEYS; i++) { prevPressed[i] = keyPressed[i]; if (KeyRemap[i] && (!Console.Visible)) { //Block remappable input when console is active //if (KeyRemap[i] > 1024) [ //keyPressed[i] = glfwGetNumberOfProcessors keyPressed[i] = glfwGetKey(KeyRemap[i]); } else { keyPressed[i] = 0; } if (keyPressed[i] != prevPressed[i]) { if (Client != BAD_ID) Clients.List[Client]->PlayerKeys[i] = keyPressed[i]; } } } int Input_Manager::IsKeyPressed(int keyID) { return keyPressed[keyID]; } int Input_Manager::IsKBKeyPressed(int kbkeyID) { return glfwGetKey(kbkeyID); } int Input_Manager::IsKBKeyPressedOnce(int kbkeyID) { int state = glfwGetKey(kbkeyID); if (keyHeld[kbkeyID] && state) { if (Timer.Time() - holdStartTime > 0.5f) { if (Timer.Time() - prevHitTime > 0.025f) { prevHitTime = Timer.Time(); return 1; } else return 0; } else { return 0; } } if ((!keyHeld[kbkeyID]) && state) { keyHeld[kbkeyID] = 1; holdStartTime = Timer.Time(); prevHitTime = Timer.Time(); return 1; } if (keyHeld[kbkeyID] && (!state)) { keyHeld[kbkeyID] = 0; return 0; } return 0; } //Generate ID for joystick key int Input_Manager::getJoystickKey(int joystickID, int joybuttonID) { return 65536 + 256*joystickID + joybuttonID; } //bool keyPressed[KEY_LAST]; //Array of pressed key IDs //bool prevPressed[KEY_LAST]; //Arrays of keys pressed in last frame
[ [ [ 1, 75 ] ] ]
0cbbaa4907e9411768cda2b114ed92ce46f47a35
3c4f5bd6d7ac3878c181fb05ab41c1d755ddf343
/XViewWnd.cpp
c89c55bd98539caa5f337737be4c476cd79cd7a3
[]
no_license
imcooder/public
1078df18c1459e67afd1200346dd971ea3b71933
be947923c6e2fbd9c993a41115ace3e32dad74bf
refs/heads/master
2021-05-28T08:43:00.027020
2010-07-24T07:39:51
2010-07-24T07:39:51
32,301,120
2
1
null
null
null
null
GB18030
C++
false
false
8,729
cpp
/******************************************************************** Copyright (c) 2002-2003 汉王科技有限公司. 版权所有. 文件名称: XViewWnd.h 文件内容: 将view转换为wnd一样使用 版本历史: 1.0 作者: xuejuntao [email protected] 2008/04/05 *********************************************************************/ #include "stdafx.h" #include "XViewWnd.h" #include <vector> #include <algorithm> using namespace std; //using namespace Gdiplus; #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CXViewWnd CXString CXViewWnd:: m_strClassName = TEXT("HWX_VIEWWND"); CXString CXViewWnd:: m_strDefWndName = TEXT("HWX_RENDER"); IMPLEMENT_DYNCREATE(CXViewWnd, CScrollView) BEGIN_MESSAGE_MAP(CXViewWnd, CScrollView) //{{AFX_MSG_MAP(CXViewWnd) ON_WM_SIZE() ON_WM_ERASEBKGND() ON_WM_SETFOCUS() ON_WM_DESTROY() ON_WM_CREATE() ON_WM_CONTEXTMENU() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview) ON_WM_MOUSEACTIVATE() ON_WM_SETCURSOR() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CXViewWnd construction/destruction CXViewWnd::CXViewWnd() { m_bActive = TRUE;//FALSE; } CXViewWnd::~CXViewWnd() { } BOOL CXViewWnd::PreCreateWindow(CREATESTRUCT& cs) { ASSERT(cs.style & WS_CHILD); if (cs.lpszClass == NULL) cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CXViewWnd drawing void CXViewWnd::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { __super::OnPrepareDC(pDC, pInfo); } BOOL CXViewWnd::OnScrollBy(CSize sizeScroll, BOOL bDoScroll) { // do the scroll if (!__super::OnScrollBy(sizeScroll, bDoScroll)) return FALSE; // update the position of any in-place active item if (bDoScroll) { UpdateWindow(); } return TRUE; } void CXViewWnd::OnDraw(CDC* pDC) { CDC dc; CDC* pDrawDC = pDC; CBitmap bitmap; CBitmap* pOldBitmap = 0; // only paint the rect that needs repainting CRect client; pDC->GetClipBox(client); CRect rect = client; DocToClient(rect); if (dc.CreateCompatibleDC(pDC)) { if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height())) { OnPrepareDC(&dc, NULL); pDrawDC = &dc; dc.OffsetViewportOrg(-rect.left, -rect.top); pOldBitmap = dc.SelectObject(&bitmap); dc.SetBrushOrg(rect.left % 8, rect.top % 8); dc.IntersectClipRect(client); } } Draw(pDrawDC->GetSafeHdc()); if (pDrawDC != pDC) { pDC->SetViewportOrg(0, 0); pDC->SetWindowOrg(0, 0); pDC->SetMapMode(MM_TEXT); dc.SetViewportOrg(0, 0); dc.SetWindowOrg(0, 0); dc.SetMapMode(MM_TEXT); pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY); dc.SelectObject(pOldBitmap); } } void CXViewWnd::Draw( HDC pDC) { } void CXViewWnd::OnInitialUpdate() { SetScrollSizes(MM_TEXT, m_szPaper); } void CXViewWnd::SetPageSize(CSize size) { SetScrollSizes(MM_TEXT, size); m_szPaper = size; } ///////////////////////////////////////////////////////////////////////////// // CXViewWnd printing BOOL CXViewWnd::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CXViewWnd::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) { CScrollView::OnBeginPrinting(pDC,pInfo); } void CXViewWnd::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { } void CXViewWnd::ClientToDoc(CPoint& point) { CClientDC dc(this); OnPrepareDC(&dc, NULL); dc.DPtoLP(&point); } void CXViewWnd::ClientToDoc(CRect& rect) { CClientDC dc(this); OnPrepareDC(&dc, NULL); dc.DPtoLP(rect); ASSERT(rect.left <= rect.right); } void CXViewWnd::DocToClient(CPoint& point) { CClientDC dc(this); OnPrepareDC(&dc, NULL); dc.LPtoDP(&point); } void CXViewWnd::DocToClient(CRect& rect) { CClientDC dc(this); OnPrepareDC(&dc, NULL); dc.LPtoDP(rect); rect.NormalizeRect(); } BOOL CXViewWnd::OnEraseBkgnd(CDC*) { return TRUE; } void CXViewWnd::OnFilePrint() { CScrollView::OnFilePrint(); //GetDocument()->ComputePageSize(); } //////////////////////////////////////////////////////////////////////////// // CXViewWnd diagnostics #ifdef _DEBUG void CXViewWnd::AssertValid() const { CScrollView::AssertValid(); } void CXViewWnd::Dump(CDumpContext& dc) const { CScrollView::Dump(dc); } #endif //_DEBUG BOOL CXViewWnd::RegisterWndClass() { WNDCLASS tWC; HINSTANCE hInst = AfxGetInstanceHandle(); if (!(::GetClassInfo(hInst, m_strClassName, &tWC))) { tWC.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; tWC.lpfnWndProc = ::DefWindowProc; tWC.cbClsExtra = tWC.cbWndExtra = 0; tWC.hInstance = hInst; tWC.hIcon = NULL; tWC.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); tWC.hbrBackground = ::GetSysColorBrush(COLOR_WINDOW); tWC.lpszMenuName = NULL; tWC.lpszClassName = m_strClassName; if (!AfxRegisterClass(&tWC)) { AfxThrowResourceException(); return FALSE; } } return TRUE; } BOOL CXViewWnd::Create(CWnd * pParent, const CRect &rect, const CSize &szPaper, DWORD dwStyple, DWORD dwStypleEx, LPCTSTR pszWndName) { RegisterWndClass(); if (szPaper == CSize(0, 0)) { m_szPaper.cx = rect.Width(); m_szPaper.cy = rect.Height(); } else { m_szPaper = szPaper; } if (!pszWndName) { pszWndName = m_strDefWndName; } BOOL blCreated = __super::Create(m_strClassName, pszWndName, dwStyple | WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, rect, pParent, 0); if (blCreated) { SetPageSize(szPaper); } return blCreated; } BOOL CXViewWnd::Create(HWND hParent, const CRect &rect, const CSize &szPaper, DWORD dwStyple, DWORD dwStypleEx, LPCTSTR pszWndName) { return Create(CWnd::FromHandle(hParent), rect, szPaper, dwStyple, dwStypleEx); } void CXViewWnd::PostNcDestroy() { // TODO: 在此添加专用代码和/或调用基类 //CScrollView::PostNcDestroy(); } CSize CXViewWnd::GetPaperSize() { return m_szPaper; } int CXViewWnd::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { // TODO: 在此添加消息处理程序代码和/或调用默认值 LONG nResult = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); OnActivateView(TRUE, this, NULL); return nResult; } CXStringT CXViewWnd::GetWndClass() { RegisterWndClass(); return m_strClassName; } BOOL CXViewWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { return CreateEx(0, lpszClassName, lpszWindowName, dwStyle | WS_CHILD, rect, pParentWnd, nID, pContext); } BOOL CXViewWnd::CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam) { if (!lpszClassName) { return Create(pParentWnd, rect, CSize(_abs(rect.right - rect.left), _abs(rect.bottom - rect.top)), dwStyle, dwExStyle, lpszWindowName); } else { return __super::CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pParentWnd->GetSafeHwnd(), (HMENU)(UINT_PTR)nID, lpParam); } } void CXViewWnd::OnSize(UINT nType, int cx, int cy) { __super::OnSize(nType, cx, cy); //m_szPaper = CSize(cx, cy); } void CXViewWnd::OnActivateFrame(UINT nState, CFrameWnd* pDeactivateFrame) { // TODO: 在此添加专用代码和/或调用基类 __super::OnActivateFrame(nState, pDeactivateFrame); } void CXViewWnd::OnActivateView(BOOL bActivate, CView* pActiveView, CView* pDeactiveView) { CView::OnActivateView(bActivate, pActiveView, pDeactiveView); // invalidate selections when active status changes if (m_bActive != bActivate) { if (bActivate) // if becoming active update as if active m_bActive = bActivate; m_bActive = bActivate; } }
[ "jtxuee@716a2f10-c84c-11dd-bf7c-81814f527a11", "[email protected]@716a2f10-c84c-11dd-bf7c-81814f527a11" ]
[ [ [ 1, 12 ], [ 14, 32 ], [ 34, 352 ] ], [ [ 13, 13 ], [ 33, 33 ] ] ]
7ee42398c89cbd7bc9d9b71eb6dec170e69ac280
26b6f15c144c2f7a26ab415c3997597fa98ba30a
/rtsp_sdk/src/RTSPClientSession.cpp
2ac9db3d59de1f5b49e0cc586135265665466e41
[]
no_license
wangscript007/rtspsdk
fb0b52e63ad1671e8b2ded1d8f10ef6c3c63fddf
f5b095f0491e5823f50a83352945acb88f0b8aa0
refs/heads/master
2022-03-09T09:25:23.988183
2008-12-27T17:23:31
2008-12-27T17:23:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,757
cpp
/***************************************************************************** // RTSP SDK Base Classes // // RTSP Client Session Class // // revision of last commit: // $Rev$ // author of last commit: // $Author$ // date of last commit: // $Date$ // // created by Argenet {[email protected]} // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // ******************************************************************************/ #include <iostream> #include "Poco/Net/NetException.h" #include "Poco/NumberFormatter.h" #include "Poco/CountingStream.h" #include "RTSPStream.h" #include "RTSPHeaderStream.h" #include "RTSPFixedLengthStream.h" #include "RTSPClientSession.h" #include "RTSPRequest.h" #include "RTSPResponse.h" using Poco::NumberFormatter; using Poco::IllegalStateException; using Poco::Net::NetException; using Poco::Net::MessageException; namespace RTSP { RTSPClientSession::RTSPClientSession(): _port(RTSPSession::RTSP_PORT), _proxyPort(RTSPSession::RTSP_PORT), // _keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0), _reconnect(false), _mustReconnect(false), _pRequestStream(NULL), _pResponseStream(NULL) { } RTSPClientSession::RTSPClientSession(const StreamSocket& socket): RTSPSession(socket), _port(RTSPSession::RTSP_PORT), _proxyPort(RTSPSession::RTSP_PORT), // _keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0), _reconnect(false), _mustReconnect(false), _pRequestStream(NULL), _pResponseStream(NULL) { } RTSPClientSession::RTSPClientSession(const SocketAddress& address): _host(address.host().toString()), _port(address.port()), _proxyPort(RTSPSession::RTSP_PORT), // _keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0), _reconnect(false), _mustReconnect(false), _pRequestStream(NULL), _pResponseStream(NULL) { } RTSPClientSession::RTSPClientSession(const std::string& host, Poco::UInt16 port): _host(host), _port(port), _proxyPort(RTSPSession::RTSP_PORT), // _keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0), _reconnect(false), _mustReconnect(false), _pRequestStream(NULL), _pResponseStream(NULL) { } RTSPClientSession::~RTSPClientSession() { delete _pRequestStream; delete _pResponseStream; } void RTSPClientSession::setHost(const std::string& host) { if (!connected()) { _host = host; } else { throw IllegalStateException("Cannot set the host for an already connected session"); } } void RTSPClientSession::setPort(Poco::UInt16 port) { if (!connected()) { _port = port; } else { throw IllegalStateException("Cannot set the port number for an already connected session"); } } void RTSPClientSession::setProxy(const std::string& host, Poco::UInt16 port) { if (!connected()) { _proxyHost = host; _proxyPort = port; } else { throw IllegalStateException("Cannot set the proxy host and port for an already connected session"); } } void RTSPClientSession::setProxyHost(const std::string& host) { if (!connected()) { _proxyHost = host; } else { throw IllegalStateException("Cannot set the proxy host for an already connected session"); } } void RTSPClientSession::setProxyPort(Poco::UInt16 port) { if (!connected()) { _proxyPort = port; } else { throw IllegalStateException("Cannot set the proxy port number for an already connected session"); } } /* NB! void RTSPClientSession::setKeepAliveTimeout(const Poco::Timespan& timeout) { _keepAliveTimeout = timeout; } */ std::ostream& RTSPClientSession::sendRequest(RTSPRequest& request) { delete _pResponseStream; _pResponseStream = NULL; if (!connected()) { reconnect(); } Poco::UInt16 cSeq = getCSeq(); request.set("CSeq", NumberFormatter::format(cSeq)); ++cSeq; setCSeq(cSeq); if (!_proxyHost.empty()) request.setURI(getHostInfo() + request.getURI()); if (request.getContentLength() != RTSPMessage::UNKNOWN_CONTENT_LENGTH) { Poco::CountingOutputStream cs; request.write(cs); _pRequestStream = new RTSPFixedLengthOutputStream(*this, request.getContentLength() + cs.chars()); request.write(*_pRequestStream); } else { _pRequestStream = new RTSPOutputStream(*this); request.write(*_pRequestStream); } _lastRequest.update(); return *_pRequestStream; } std::istream& RTSPClientSession::receiveResponse(RTSPResponse& response) { delete _pRequestStream; _pRequestStream = NULL; do { response.clear(); RTSPHeaderInputStream his(*this); try { response.read(his); } catch (MessageException&) { if (networkException()) networkException()->rethrow(); else throw; } } while (response.getStatus() == RTSPResponse::RTSP_CONTINUE); if (RTSPMessage::UNKNOWN_CONTENT_LENGTH != response.getContentLength()) { _pResponseStream = new RTSPFixedLengthInputStream(*this, response.getContentLength()); } else { _pResponseStream = new RTSPFixedLengthInputStream(*this, 0); } return *_pResponseStream; } int RTSPClientSession::write(const char* buffer, std::streamsize length) { try { int rc = RTSPSession::write(buffer, length); _reconnect = false; return rc; } catch (NetException&) { if (_reconnect) { close(); reconnect(); int rc = RTSPSession::write(buffer, length); _reconnect = false; return rc; } else throw; } } void RTSPClientSession::reconnect() { if (_proxyHost.empty()) { SocketAddress addr(_host, _port); connect(addr); } else { SocketAddress addr(_proxyHost, _proxyPort); connect(addr); } } std::string RTSPClientSession::getHostInfo() const { std::string result("rtsp://"); result.append(_host); result.append(":"); result.append(NumberFormatter::format(_port)); return result; } void RTSPClientSession::deleteResponseStream() { delete _pResponseStream; _pResponseStream = NULL; } void RTSPClientSession::deleteRequestStream() { delete _pRequestStream; _pRequestStream = NULL; } void RTSPClientSession::setResponseStream(std::istream* pRespStream) { poco_assert(NULL == _pResponseStream); _pResponseStream = pRespStream; } void RTSPClientSession::setRequestStream(std::ostream* pRequestStream) { poco_assert (NULL == _pRequestStream); _pRequestStream = pRequestStream; } } // namespace RTSP
[ [ [ 1, 338 ] ] ]
21da26a4d3822c3296b5b57c6aeadf9d56d544a4
17306081dd4865faa69377c5fc7f6c11c676fac0
/MyFirstMateBarBand.h
2272b3d353f940da92d77753485793930e775f81
[]
no_license
jongha/myfirstmate
e1ee3547c66481ba28114e0126c49ca7e6c604f4
1663df04b305b4110c12c57f8c9241fcd64088f1
refs/heads/master
2021-01-23T20:49:48.437887
2010-09-28T05:11:04
2010-09-28T05:11:04
32,111,906
0
0
null
null
null
null
UTF-8
C++
false
false
2,453
h
// MyFirstMateBarBand.h : Declaration of the CMyFirstMateBarBand #ifndef __MyFirstMateBarBAND_H_ #define __MyFirstMateBarBAND_H_ #include "resource.h" // main symbols #include "NavigateToolBarCtrl.h" #define TB_MIN_SIZE_X 10 #define TB_MIN_SIZE_Y 25 #define TB_MAX_SIZE_Y 25 ///////////////////////////////////////////////////////////////////////////// // CMyFirstMateBarBand class ATL_NO_VTABLE CMyFirstMateBarBand : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CMyFirstMateBarBand, &CLSID_MyFirstMateBarBand>, public IObjectWithSiteImpl<CMyFirstMateBarBand>, public IDispatchImpl<IMyFirstMateBarBand, &IID_IMyFirstMateBarBand, &LIBID_MyFirstMateBarLib>, public IInputObject, public IDeskBand { public: CMyFirstMateBarBand() { } DECLARE_REGISTRY_RESOURCEID(IDR_MyFirstMateBarBAND) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(CMyFirstMateBarBand) COM_INTERFACE_ENTRY(IMyFirstMateBarBand) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IObjectWithSite) COM_INTERFACE_ENTRY(IInputObject) COM_INTERFACE_ENTRY(IDeskBand) COM_INTERFACE_ENTRY2(IOleWindow, IDeskBand) COM_INTERFACE_ENTRY2(IDockingWindow, IDeskBand) END_COM_MAP() // Interfaces public: IWebBrowser2Ptr m_pIE; //IOleWindow methods STDMETHOD (GetWindow) (HWND*); STDMETHOD (ContextSensitiveHelp) (BOOL); //IDockingWindow methods STDMETHOD (ShowDW) (BOOL fShow); STDMETHOD (CloseDW) (DWORD dwReserved); STDMETHOD (ResizeBorderDW) (LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved); //IDeskBand methods STDMETHOD (GetBandInfo) (DWORD, DWORD, DESKBANDINFO*); //IInputObject methods STDMETHOD (UIActivateIO) (BOOL, LPMSG); STDMETHOD (HasFocusIO) (void); STDMETHOD (TranslateAcceleratorIO) (LPMSG); //IObjectWithSite methods STDMETHOD (SetSite) (IUnknown*); STDMETHOD (GetSite) (REFIID, LPVOID*); // Implementation: public: void FocusChange(bool bFocus); bool CreateToolWindow(void); bool m_bFocus; IInputObjectSitePtr m_pIOSite; HWND m_hWndParent; DWORD m_dwBandID; DWORD m_dwViewMode; CNavigateToolBarCtrl m_wndToolBar; CWnd m_wndReflectionWnd; public: int ShowLogoutDlg(); int ShowLoginDlg(); long NavigateHomepage(); int ShowConfigurationDlg(); int ShowAboutDlg(); // Outer Methods STDMETHOD(SetSavePost)(BSTR Location, BSTR Contents); }; #endif //__MyFirstMateBarBAND_H_
[ [ [ 1, 94 ] ] ]
70dca1f1354d61252616c0e5bb4818d03728b965
a30b091525dc3f07cd7e12c80b8d168a0ee4f808
/EngineAll/Math/SparseMatrix.cpp
f8795467fb11a9788c81c3dcff15d025ee8c1aea
[]
no_license
ghsoftco/basecode14
f50dc049b8f2f8d284fece4ee72f9d2f3f59a700
57de2a24c01cec6dc3312cbfe200f2b15d923419
refs/heads/master
2021-01-10T11:18:29.585561
2011-01-23T02:25:21
2011-01-23T02:25:21
47,255,927
0
0
null
null
null
null
UTF-8
C++
false
false
55
cpp
/* SparseMatrix.cpp Written by Matthew Fisher */
[ "zhaodongmpii@7e7f00ea-7cf8-66b5-cf80-f378872134d2" ]
[ [ [ 1, 5 ] ] ]
4d4c94e207d38bad3d55360f669dcc07ab62e1fe
4d5ee0b6f7be0c3841c050ed1dda88ec128ae7b4
/src/nvmesh/raster/ClippedTriangle.h
6bd1dd6930357ec7e311dd0a4f0b4ec30d8ccdf1
[]
no_license
saggita/nvidia-mesh-tools
9df27d41b65b9742a9d45dc67af5f6835709f0c2
a9b7fdd808e6719be88520e14bc60d58ea57e0bd
refs/heads/master
2020-12-24T21:37:11.053752
2010-09-03T01:39:02
2010-09-03T01:39:02
56,893,300
0
1
null
null
null
null
UTF-8
C++
false
false
3,591
h
// Copyright NVIDIA Corporation 2007 -- Denis Kovacs <[email protected]> #ifndef NV_MESH_CLIPPEDTRIANGLE_H #define NV_MESH_CLIPPEDTRIANGLE_H #include <nvmath/Vector.h> namespace nv { class ClippedTriangle { public: ClippedTriangle(Vector2::Arg a, Vector2::Arg b, Vector2::Arg c) { m_numVertices = 3; m_activeVertexBuffer = 0; m_verticesA[0]=a; m_verticesA[1]=b; m_verticesA[2]=c; m_vertexBuffers[0] = m_verticesA; m_vertexBuffers[1] = m_verticesB; } uint vertexCount() { return m_numVertices; } const Vector2 * vertices() { return m_vertexBuffers[m_activeVertexBuffer]; } inline void clipHorizontalPlane(float offset, float clipdirection) { Vector2 * v = m_vertexBuffers[m_activeVertexBuffer]; m_activeVertexBuffer ^= 1; Vector2 * v2 = m_vertexBuffers[m_activeVertexBuffer]; v[m_numVertices] = v[0]; float dy2, dy1 = offset - v[0].y(); int dy2in, dy1in = clipdirection*dy1 >= 0; uint p=0; for (uint k=0; k<m_numVertices; k++) { dy2 = offset - v[k+1].y(); dy2in = clipdirection*dy2 >= 0; if (dy1in) v2[p++] = v[k]; if ( dy1in + dy2in == 1 ) // not both in/out { float dx = v[k+1].x() - v[k].x(); float dy = v[k+1].y() - v[k].y(); v2[p++] = Vector2(v[k].x() + dy1*(dx/dy), offset); } dy1 = dy2; dy1in = dy2in; } m_numVertices = p; //for (uint k=0; k<m_numVertices; k++) printf("(%f, %f)\n", v2[k].x(), v2[k].y()); printf("\n"); } inline void clipVerticalPlane(float offset, float clipdirection ) { Vector2 * v = m_vertexBuffers[m_activeVertexBuffer]; m_activeVertexBuffer ^= 1; Vector2 * v2 = m_vertexBuffers[m_activeVertexBuffer]; v[m_numVertices] = v[0]; float dx2, dx1 = offset - v[0].x(); int dx2in, dx1in = clipdirection*dx1 >= 0; uint p=0; for (uint k=0; k<m_numVertices; k++) { dx2 = offset - v[k+1].x(); dx2in = clipdirection*dx2 >= 0; if (dx1in) v2[p++] = v[k]; if ( dx1in + dx2in == 1 ) // not both in/out { float dx = v[k+1].x() - v[k].x(); float dy = v[k+1].y() - v[k].y(); v2[p++] = Vector2(offset, v[k].y() + dx1*(dy/dx)); } dx1 = dx2; dx1in = dx2in; } m_numVertices = p; //for (uint k=0; k<m_numVertices; k++) printf("(%f, %f)\n", v2[k].x(), v2[k].y()); printf("\n"); } void computeAreaCentroid() { Vector2 * v = m_vertexBuffers[m_activeVertexBuffer]; v[m_numVertices] = v[0]; m_area = 0; float centroidx=0, centroidy=0; for (uint k=0; k<m_numVertices; k++) { // http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ float f = v[k].x()*v[k+1].y() - v[k+1].x()*v[k].y(); m_area += f; centroidx += f * (v[k].x() + v[k+1].x()); centroidy += f * (v[k].y() + v[k+1].y()); } m_area = 0.5f * fabs(m_area); if (m_area==0) { m_centroid = Vector2(zero); } else { m_centroid = Vector2(centroidx/(6*m_area), centroidy/(6*m_area)); } } void clipAABox(float x0, float y0, float x1, float y1) { clipVerticalPlane ( x0, -1); clipHorizontalPlane( y0, -1); clipVerticalPlane ( x1, 1); clipHorizontalPlane( y1, 1); computeAreaCentroid(); } Vector2 centroid() { return m_centroid; } float area() { return m_area; } private: Vector2 m_verticesA[7+1]; Vector2 m_verticesB[7+1]; Vector2 * m_vertexBuffers[2]; uint m_numVertices; uint m_activeVertexBuffer; float m_area; Vector2 m_centroid; }; } // nv namespace #endif // NV_MESH_CLIPPEDTRIANGLE_H
[ "castano@0f2971b0-9fc2-11dd-b4aa-53559073bf4c" ]
[ [ [ 1, 158 ] ] ]
8622ad52dc79835b186fa38d70cb5ee2c59ead6c
a2ba072a87ab830f5343022ed11b4ac365f58ef0
/ urt-bumpy-q3map2 --username [email protected]/libs/splines/math_vector.h
9c5502b498dfe9f9b0f10c0dc05afca7338186d0
[]
no_license
Garey27/urt-bumpy-q3map2
7d0849fc8eb333d9007213b641138e8517aa092a
fcc567a04facada74f60306c01e68f410cb5a111
refs/heads/master
2021-01-10T17:24:51.991794
2010-06-22T13:19:24
2010-06-22T13:19:24
43,057,943
0
0
null
null
null
null
UTF-8
C++
false
false
14,362
h
/* This code is based on source provided under the terms of the Id Software LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of LICENSE_ID, please contact Id Software immediately at [email protected]. All changes and additions to the original source which have been developed by other contributors (see CONTRIBUTORS) are provided under the terms of the license the contributors choose (see LICENSE), to the extent permitted by the LICENSE_ID. If you did not receive a copy of the contributor license, please contact the GtkRadiant maintainers at [email protected] immediately. 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 REGENTS 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. */ #ifndef __MATH_VECTOR_H__ #define __MATH_VECTOR_H__ #ifdef WIN32 #pragma warning(disable : 4244) #endif #include <math.h> #include <assert.h> //#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2]) //#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) //#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) //#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) //#define VectorCopy(a,b) ((b).x=(a).x,(b).y=(a).y,(b).z=(a).z]) //#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) #define __VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) //#define CrossProduct(a,b,c) ((c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1],(c)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2],(c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0]) #define DotProduct4(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3]) #define VectorSubtract4(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3]) #define VectorAdd4(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3]) #define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) #define VectorScale4(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s)) #define VectorMA4(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s),(o)[3]=(v)[3]+(b)[3]*(s)) //#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) #define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) //#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) #define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) #define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];} //#include "util_heap.h" #ifndef EQUAL_EPSILON #define EQUAL_EPSILON 0.001 #endif float Q_fabs( float f ); #ifndef ID_INLINE #ifdef _WIN32 #define ID_INLINE __inline #else #define ID_INLINE inline #endif #endif // if this is defined, vec3 will take four elements, which may allow // easier SIMD optimizations //#define FAT_VEC3 //#ifdef __ppc__ //#pragma align(16) //#endif class angles_t; #ifdef __ppc__ // Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction, // runs *much* faster than calling sqrt(). We'll use two Newton-Raphson // refinement steps to get bunch more precision in the 1/sqrt() value for very little cost. // We'll then multiply 1/sqrt times the original value to get the sqrt. // This is about 12.4 times faster than sqrt() and according to my testing (not exhaustive) // it returns fairly accurate results (error below 1.0e-5 up to 100000.0 in 0.1 increments). static inline float idSqrt(float x) { const float half = 0.5; const float one = 1.0; float B, y0, y1; // This'll NaN if it hits frsqrte. Handle both +0.0 and -0.0 if (fabs(x) == 0.0) return x; B = x; #ifdef __GNUC__ asm("frsqrte %0,%1" : "=f" (y0) : "f" (B)); #else y0 = __frsqrte(B); #endif /* First refinement step */ y1 = y0 + half*y0*(one - B*y0*y0); /* Second refinement step -- copy the output of the last step to the input of this step */ y0 = y1; y1 = y0 + half*y0*(one - B*y0*y0); /* Get sqrt(x) from x * 1/sqrt(x) */ return x * y1; } #else static inline double idSqrt(double x) { return sqrt(x); } #endif //class idVec3 : public idHeap<idVec3> { class idVec3 { public: #ifndef FAT_VEC3 float x,y,z; #else float x,y,z,dist; #endif #ifndef FAT_VEC3 idVec3() {}; #else idVec3() {dist = 0.0f;}; #endif idVec3( const float x, const float y, const float z ); operator float *(); float operator[]( const int index ) const; float &operator[]( const int index ); void set( const float x, const float y, const float z ); idVec3 operator-() const; idVec3 &operator=( const idVec3 &a ); float operator*( const idVec3 &a ) const; idVec3 operator*( const float a ) const; friend idVec3 operator*( float a, idVec3 b ); idVec3 operator+( const idVec3 &a ) const; idVec3 operator-( const idVec3 &a ) const; idVec3 &operator+=( const idVec3 &a ); idVec3 &operator-=( const idVec3 &a ); idVec3 &operator*=( const float a ); int operator==( const idVec3 &a ) const; int operator!=( const idVec3 &a ) const; idVec3 Cross( const idVec3 &a ) const; idVec3 &Cross( const idVec3 &a, const idVec3 &b ); float Length( void ) const; float Normalize( void ); void Zero( void ); void Snap( void ); void SnapTowards( const idVec3 &to ); float toYaw( void ); float toPitch( void ); angles_t toAngles( void ); friend idVec3 LerpVector( const idVec3 &w1, const idVec3 &w2, const float t ); char *string( void ); }; extern idVec3 vec_zero; ID_INLINE idVec3::idVec3( const float x, const float y, const float z ) { this->x = x; this->y = y; this->z = z; #ifdef FAT_VEC3 this->dist = 0.0f; #endif } ID_INLINE float idVec3::operator[]( const int index ) const { return ( &x )[ index ]; } ID_INLINE float &idVec3::operator[]( const int index ) { return ( &x )[ index ]; } ID_INLINE idVec3::operator float *( void ) { return &x; } ID_INLINE idVec3 idVec3::operator-() const { return idVec3( -x, -y, -z ); } ID_INLINE idVec3 &idVec3::operator=( const idVec3 &a ) { x = a.x; y = a.y; z = a.z; return *this; } ID_INLINE void idVec3::set( const float x, const float y, const float z ) { this->x = x; this->y = y; this->z = z; } ID_INLINE idVec3 idVec3::operator-( const idVec3 &a ) const { return idVec3( x - a.x, y - a.y, z - a.z ); } ID_INLINE float idVec3::operator*( const idVec3 &a ) const { return x * a.x + y * a.y + z * a.z; } ID_INLINE idVec3 idVec3::operator*( const float a ) const { return idVec3( x * a, y * a, z * a ); } ID_INLINE idVec3 operator*( const float a, const idVec3 b ) { return idVec3( b.x * a, b.y * a, b.z * a ); } ID_INLINE idVec3 idVec3::operator+( const idVec3 &a ) const { return idVec3( x + a.x, y + a.y, z + a.z ); } ID_INLINE idVec3 &idVec3::operator+=( const idVec3 &a ) { x += a.x; y += a.y; z += a.z; return *this; } ID_INLINE idVec3 &idVec3::operator-=( const idVec3 &a ) { x -= a.x; y -= a.y; z -= a.z; return *this; } ID_INLINE idVec3 &idVec3::operator*=( const float a ) { x *= a; y *= a; z *= a; return *this; } ID_INLINE int idVec3::operator==( const idVec3 &a ) const { if ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) { return false; } if ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) { return false; } if ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) { return false; } return true; } ID_INLINE int idVec3::operator!=( const idVec3 &a ) const { if ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) { return true; } if ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) { return true; } if ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) { return true; } return false; } ID_INLINE idVec3 idVec3::Cross( const idVec3 &a ) const { return idVec3( y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x ); } ID_INLINE idVec3 &idVec3::Cross( const idVec3 &a, const idVec3 &b ) { x = a.y * b.z - a.z * b.y; y = a.z * b.x - a.x * b.z; z = a.x * b.y - a.y * b.x; return *this; } ID_INLINE float idVec3::Length( void ) const { float length; length = x * x + y * y + z * z; return ( float )idSqrt( length ); } ID_INLINE float idVec3::Normalize( void ) { float length; float ilength; length = this->Length(); if ( length ) { ilength = 1.0f / length; x *= ilength; y *= ilength; z *= ilength; } return length; } ID_INLINE void idVec3::Zero( void ) { x = 0.0f; y = 0.0f; z = 0.0f; } ID_INLINE void idVec3::Snap( void ) { x = float( int( x ) ); y = float( int( y ) ); z = float( int( z ) ); } /* ====================== SnapTowards Round a vector to integers for more efficient network transmission, but make sure that it rounds towards a given point rather than blindly truncating. This prevents it from truncating into a wall. ====================== */ ID_INLINE void idVec3::SnapTowards( const idVec3 &to ) { if ( to.x <= x ) { x = float( int( x ) ); } else { x = float( int( x ) + 1 ); } if ( to.y <= y ) { y = float( int( y ) ); } else { y = float( int( y ) + 1 ); } if ( to.z <= z ) { z = float( int( z ) ); } else { z = float( int( z ) + 1 ); } } //=============================================================== class Bounds { public: idVec3 b[2]; Bounds(); Bounds( const idVec3 &mins, const idVec3 &maxs ); void Clear(); void Zero(); float Radius(); // radius from origin, not from center idVec3 Center(); void AddPoint( const idVec3 &v ); void AddBounds( const Bounds &bb ); bool IsCleared(); bool ContainsPoint( const idVec3 &p ); bool IntersectsBounds( const Bounds &b2 ); // touching is NOT intersecting }; extern Bounds boundsZero; ID_INLINE Bounds::Bounds(){ } ID_INLINE bool Bounds::IsCleared() { return b[0][0] > b[1][0]; } ID_INLINE bool Bounds::ContainsPoint( const idVec3 &p ) { if ( p[0] < b[0][0] || p[1] < b[0][1] || p[2] < b[0][2] || p[0] > b[1][0] || p[1] > b[1][1] || p[2] > b[1][2] ) { return false; } return true; } ID_INLINE bool Bounds::IntersectsBounds( const Bounds &b2 ) { if ( b2.b[1][0] < b[0][0] || b2.b[1][1] < b[0][1] || b2.b[1][2] < b[0][2] || b2.b[0][0] > b[1][0] || b2.b[0][1] > b[1][1] || b2.b[0][2] > b[1][2] ) { return false; } return true; } ID_INLINE Bounds::Bounds( const idVec3 &mins, const idVec3 &maxs ) { b[0] = mins; b[1] = maxs; } ID_INLINE idVec3 Bounds::Center() { return idVec3( ( b[1][0] + b[0][0] ) * 0.5f, ( b[1][1] + b[0][1] ) * 0.5f, ( b[1][2] + b[0][2] ) * 0.5f ); } ID_INLINE void Bounds::Clear() { b[0][0] = b[0][1] = b[0][2] = 99999; b[1][0] = b[1][1] = b[1][2] = -99999; } ID_INLINE void Bounds::Zero() { b[0][0] = b[0][1] = b[0][2] = b[1][0] = b[1][1] = b[1][2] = 0; } ID_INLINE void Bounds::AddPoint( const idVec3 &v ) { if ( v[0] < b[0][0]) { b[0][0] = v[0]; } if ( v[0] > b[1][0]) { b[1][0] = v[0]; } if ( v[1] < b[0][1] ) { b[0][1] = v[1]; } if ( v[1] > b[1][1]) { b[1][1] = v[1]; } if ( v[2] < b[0][2] ) { b[0][2] = v[2]; } if ( v[2] > b[1][2]) { b[1][2] = v[2]; } } ID_INLINE void Bounds::AddBounds( const Bounds &bb ) { if ( bb.b[0][0] < b[0][0]) { b[0][0] = bb.b[0][0]; } if ( bb.b[0][1] < b[0][1]) { b[0][1] = bb.b[0][1]; } if ( bb.b[0][2] < b[0][2]) { b[0][2] = bb.b[0][2]; } if ( bb.b[1][0] > b[1][0]) { b[1][0] = bb.b[1][0]; } if ( bb.b[1][1] > b[1][1]) { b[1][1] = bb.b[1][1]; } if ( bb.b[1][2] > b[1][2]) { b[1][2] = bb.b[1][2]; } } ID_INLINE float Bounds::Radius( ) { int i; float total; float a, aa; total = 0; for (i=0 ; i<3 ; i++) { a = (float)fabs( b[0][i] ); aa = (float)fabs( b[1][i] ); if ( aa > a ) { a = aa; } total += a * a; } return (float)idSqrt( total ); } //=============================================================== class idVec2 { public: float x; float y; operator float *(); float operator[]( int index ) const; float &operator[]( int index ); }; ID_INLINE float idVec2::operator[]( int index ) const { return ( &x )[ index ]; } ID_INLINE float& idVec2::operator[]( int index ) { return ( &x )[ index ]; } ID_INLINE idVec2::operator float *( void ) { return &x; } class idVec4 : public idVec3 { public: #ifndef FAT_VEC3 float dist; #endif idVec4(); ~idVec4() {}; idVec4( float x, float y, float z, float dist ); float operator[]( int index ) const; float &operator[]( int index ); }; ID_INLINE idVec4::idVec4() {} ID_INLINE idVec4::idVec4( float x, float y, float z, float dist ) { this->x = x; this->y = y; this->z = z; this->dist = dist; } ID_INLINE float idVec4::operator[]( int index ) const { return ( &x )[ index ]; } ID_INLINE float& idVec4::operator[]( int index ) { return ( &x )[ index ]; } class idVec5_t : public idVec3 { public: float s; float t; float operator[]( int index ) const; float &operator[]( int index ); }; ID_INLINE float idVec5_t::operator[]( int index ) const { return ( &x )[ index ]; } ID_INLINE float& idVec5_t::operator[]( int index ) { return ( &x )[ index ]; } #endif /* !__MATH_VECTOR_H__ */
[ [ [ 1, 577 ] ] ]
9d74373b2e5d62408cf7e8d49a3bb60b8af97648
a09f709362521d701c08b2cdc6433c956f8815c9
/samples/simplemfc/SimpleMFC.h
a2de0016eb668ee561a122c0ac9c6173fda035bf
[]
no_license
alenl/jamplus
0eab8a5f8cd895804354b0cac844a0849549c3f6
5393a9b2f2467667b33fca542826498ce8ff2971
refs/heads/master
2021-01-18T10:29:38.604732
2008-11-20T20:48:04
2008-11-20T21:30:27
77,247
1
0
null
null
null
null
UTF-8
C++
false
false
550
h
// SimpleMFC.h : main header file for the SimpleMFC application // #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols // CSimpleMFCApp: // See SimpleMFC.cpp for the implementation of this class // class CSimpleMFCApp : public CWinApp { public: CSimpleMFCApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation afx_msg void OnAppAbout(); DECLARE_MESSAGE_MAP() }; extern CSimpleMFCApp theApp;
[ [ [ 1, 31 ] ] ]
c9939b20c970db147739017f16560fbdf79d78c1
4c6237dccf0d88085e1477c2678509cd75919fa0
/src/raytracer/projector_light.cxx
7dc2d0b70406215629d2e330fe8f90bfefe1cea4
[ "BSD-3-Clause" ]
permissive
tomka/copo-tracer
7ebd4670067bf404b19990bcd83db55384e7b87a
7a272acbf19acef9eea8330e503ad95e371bd9b3
refs/heads/master
2021-01-10T19:43:35.757275
2010-10-04T15:35:33
2010-10-04T15:35:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,837
cxx
// Copyright: The original source code was provided by Sören König (Soeren.Koenig // AT tu-dresden.de). You are free to modify and/or redistribute that code in // terms of the BSD license. #include "projector_light.h" tiny_vec<float,3> projector_light::get_attenuation_factors(const intersection_info* hit) { tiny_vec<float,3> pw = hit->get_location(); tiny_vec<float,2> pi =project(pw); if(dot(R.row(2),pw-get_eye())<0) return tiny_vec<float,3>(0.0f,0.0f,0.0f); return light_source::get_attenuation_factors(hit)*projector_image(pi[0],pi[1]); } void projector_light::calc_light_direction_and_distance(intersection_info *hit) { tiny_vec<float,3> light_dir = get_eye()-hit->get_location(); hit->set_light_distance(light_dir.length()); hit->set_light_dir( light_dir/hit->get_light_distance()); } tiny_vec<float,2> projector_light::project(const tiny_vec<float,3>& p) { tiny_vec<float,3> xh = K*(R*p+t); xh/=xh[2]; return tiny_vec<float,2>(xh[0],xh[1]); } tiny_vec<float,3> projector_light::get_eye() { return -transpose(R)*t; } void projector_light::set_look_at(const tiny_vec<float,3>& eye, const tiny_vec<float,3>& center,const tiny_vec<float,3>& up) { tiny_vec<float,3> w_dir = -(eye-center); w_dir.normalize(); tiny_vec<float,3> v_dir = up; v_dir.normalize(); tiny_vec<float,3> u_dir = -cross(v_dir,w_dir); u_dir.normalize(); v_dir = cross(w_dir,u_dir); v_dir.normalize(); R.set_row(0,u_dir); R.set_row(1,v_dir); R.set_row(2,w_dir); t =-R*eye; } projector_light::projector_light(mat<tiny_vec<float,3> >* img,float fovy) { projector_image.set_interpolation( sampler_2d< tiny_vec<float,3> >::BILINEAR); projector_image.set_wrapping( sampler_2d< tiny_vec<float,3> >::CLAMP_TO_BORDER); projector_image.set_border_color(tiny_vec<float,3>(0,0,0)); projector_image.bind_image(img); float f = 1.0f/tan(fovy*3.14159f/360.0f); float aspect = img->w()/(float)img->h(); K = eye<float>(3); K(0,2) = img->w()/2.0f; K(1,2) = img->h()/2.0f; K(0,0) = img->w()/2.0f*f/aspect; K(1,1) = img->h()/2.0f*f; R=eye<float>(3); } projector_light::projector_light() { projector_image.set_interpolation( sampler_2d< tiny_vec<float,3> >::BILINEAR); projector_image.set_wrapping( sampler_2d< tiny_vec<float,3> >::CLAMP_TO_BORDER); projector_image.set_border_color(tiny_vec<float,3>(0,0,0)); K = eye<float>(3); R = eye<float>(3); } void projector_light::set_projector_image(mat<tiny_vec<float,3> >* img,float fovy) { projector_image.bind_image(img); float f = 1.0f/tan(fovy*3.14159f/360.0f); float aspect = img->w()/(float)img->h(); K(0,2) = img->w()/2.0f; K(1,2) = img->h()/2.0f; K(0,0) = img->w()/2.0f*f/aspect; K(1,1) = img->h()/2.0f*f; }
[ [ [ 1, 111 ] ] ]
c5ffc31ad7e754b08f14f6edee7a345164cff974
741b36f4ddf392c4459d777930bc55b966c2111a
/incubator/happylib/HappyLib/HLTimer.h
7e2dd5c414af4bd5c72ebba8f700bfd05a3e57dd
[]
no_license
BackupTheBerlios/lwpp-svn
d2e905641f60a7c9ca296d29169c70762f5a9281
fd6f80cbba14209d4ca639f291b1a28a0ed5404d
refs/heads/master
2021-01-17T17:01:31.802187
2005-10-16T22:12:52
2005-10-16T22:12:52
40,805,554
0
0
null
null
null
null
UTF-8
C++
false
false
1,146
h
#ifndef _HLTIMER_H #define _HLTIMER_H #ifdef __unix__ #include <sys/time.h> inline static double ReadClock() { timeval tv; gettimeofday(&tv, 0); return (double)tv.tv_sec + tv.tv_usec * 0.000001; } #else // __unix__ #ifdef _WIN32 #include <time.h> #define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN #define NOSERVICE #define NOMCX #define NOIME #define NOSOUND #define NOCOMM #define NOKANJI #define NORPC #define NOPROXYSTUB #define NOIMAGE #define NOTAPE #include <windows.h> inline static double ReadClock() // [FIXME][NOW] ALL THESE are jittery :( { LONGLONG llTime, llFreq; QueryPerformanceCounter((LARGE_INTEGER*)&llTime); // [FIXME] jitters QueryPerformanceFrequency((LARGE_INTEGER*)&llFreq); return (double)llTime / (double)llFreq; } #else // _WIN32 #error No support for Timer class on this platform yet. #endif // _WIN32 #endif // __unix__ //// Timer class //// class Timer { private: double _initial; public: Timer() : _initial(ReadClock()) {} double getSeconds() const { return ReadClock() - _initial; } void reset() { _initial = ReadClock(); } }; #endif
[ "lightwolf@dac1304f-7ce9-0310-a59f-f2d444f72a61" ]
[ [ [ 1, 54 ] ] ]
b4411f782aad7c2255c049d884dc1cca4830845e
4bf5c354168d9701947158d9b4e2ec050a47a620
/sine/main.cpp
cdc1f389e13f9a03252939df7aa20f6d954a0425
[]
no_license
Fadis/SynthSamples
10a648298b72c29d45fcf36abe840cf434bf7dc4
62fc99845ba0207c23ef8a96b6c4202e09601a35
refs/heads/master
2021-01-17T09:39:33.491999
2011-09-23T04:59:32
2011-09-23T04:59:32
2,442,014
0
0
null
null
null
null
UTF-8
C++
false
false
579
cpp
#include "mbed.h" AnalogOut audio_out(p18); const float freq_table[ 8 ] = { 523.25113f, 587.32953f, 659.25511f, 698.45646f, 783.99087f, 880.00000f, 987.76660f, 1046.5022f, }; int main() { while(1) { for( int note = 0; note != 8; ++note ) for( float time = 0.0f; time < 1.0f; time += 1.0f/16000.0f ) { Timer used_time; used_time.start(); audio_out = sinf( time * freq_table[ note ] * 3.141592f * 2.0f ) * 0.5f + 0.5f; used_time.stop(); wait(1.0f/16000.0f-used_time.read()); } } }
[ [ [ 1, 20 ] ] ]
aae256ef28f608d306dee26e10247c7b84e8c42d
42b578d005c2e8870a03fe02807e5607fec68f40
/src/xyzzyenv.cc
71a4718f2e21b81341d1e548eba18a9edf6fda62
[ "MIT" ]
permissive
hylom/xom
e2b02470cd984d0539ded408d13f9945af6e5f6f
a38841cfe50c3e076b07b86700dfd01644bf4d4a
refs/heads/master
2021-01-23T02:29:51.908501
2009-10-30T08:41:30
2009-10-30T08:41:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,047
cc
#include <windows.h> #include <malloc.h> #pragma data_seg (".text") typedef unsigned long u_long; typedef unsigned char u_char; static char * skip_token (char *p) { if (*p == '"') { for (p++; *p && *p != '"'; p++) { if (IsDBCSLeadByte (*p) && p[1]) p++; } if (*p == '"') p++; } else { for (; *p && *p != ' ' && *p != '\t'; p++) if (IsDBCSLeadByte (*p) && p[1]) p++; } return p; } static char * skip_white (char *p) { for (; *p == ' ' || *p == '\t'; p++) ; return p; } static char * split (char *&beg) { char *p = skip_token (beg); if (*beg == '"') { beg++; if (*CharPrev (beg, p) == '"') p[-1] = 0; } else if (*p) *p++ = 0; return skip_white (p); } static char * split (char *&beg, int &l) { char *p = skip_token (beg); if (*beg == '"') { beg++; l = p - beg; if (*CharPrev (beg, p) == '"') l--; } else l = p - beg; return skip_white (p); } static u_long parse_long (const char *p) { u_long val = 0; for (; *p >= '0' && *p <= '9'; p++) val = val * 10 + *p - '0'; return val; } static inline int char_upcase (int c) { return c >= 'a' && c <= 'Z' ? c - ('a' - 'A') : c; } static int bcasecmp (const void *b1, const void *b2, int size) { const u_char *p = (const u_char *)b1, *const pe = p + size; const u_char *q = (const u_char *)b2; for (int f = 0; p < pe && !(f = char_upcase (*p) - char_upcase (*q)); p++, q++) ; return f; } static void doprint (const char *fmt, ...) { char buf[1024]; va_list ap; va_start (ap, fmt); wvsprintf (buf, fmt, ap); va_end (ap); DWORD n; WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, lstrlen (buf), &n, 0); } static void syserror (int e, char *buf, int size) { if (!FormatMessage ((FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK), 0, e, GetUserDefaultLangID (), buf, size, 0)) wsprintf (buf, "error %d", e); } static int cmdmatch (const char *p, const char *pe, const char *s) { if (pe - p >= 4 && (!bcasecmp (pe - 4, ".exe", 4) || !bcasecmp (pe - 4, ".com", 4))) pe -= 4; int l = lstrlen (s); return pe - p >= l && !bcasecmp (pe - l, s, l); } static void set_title (char *cmd) { int cmdl; char *opt = split (cmd, cmdl); if (cmdmatch (cmd, cmd + cmdl, "cmd") || cmdmatch (cmd, cmd + cmdl, "command")) { int optl; char *arg = split (opt, optl); if (optl == 2 && !bcasecmp (opt, "/c", 2)) { cmd = arg; split (cmd, cmdl); } } char *title = (char *)_alloca (cmdl + 1); memcpy (title, cmd, cmdl); title[cmdl] = 0; SetConsoleTitle (title); } extern "C" void process_startup () { char buf[256]; char *myname = skip_white (GetCommandLine ()); char *event = split (myname); char *cmdline = split (event); char *dir = 0; int no_events = !lstrcmp (event, "--"); if (no_events) { dir = cmdline; cmdline = split (dir); } set_title (cmdline); PROCESS_INFORMATION pi; STARTUPINFO si = {sizeof si}; si.dwFlags = STARTF_USESTDHANDLES; si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE); si.hStdError = GetStdHandle (STD_ERROR_HANDLE); if (!CreateProcess (0, cmdline, 0, 0, 1, CREATE_NEW_PROCESS_GROUP, 0, dir, &si, &pi)) { syserror (GetLastError (), buf, sizeof buf); doprint ("%s: %s: %s\n", myname, cmdline, buf); ExitProcess (2); } CloseHandle (pi.hThread); if (no_events) { if (WaitForSingleObject (pi.hProcess, INFINITE) == WAIT_FAILED) { syserror (GetLastError (), buf, sizeof buf); doprint ("%s: %s\n", myname, buf); ExitProcess (2); } } else { HANDLE hevent = HANDLE (parse_long (event)); HANDLE objects[2]; objects[0] = hevent; objects[1] = pi.hProcess; while (1) { DWORD r = WaitForMultipleObjects (2, objects, 0, INFINITE); if (r == WAIT_FAILED) { syserror (GetLastError (), buf, sizeof buf); doprint ("%s: %s\n", myname, buf); ExitProcess (2); } if (r == WAIT_OBJECT_0 + 1) break; GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, pi.dwProcessId); if (WaitForSingleObject (pi.hProcess, 3000) == WAIT_TIMEOUT) GenerateConsoleCtrlEvent (CTRL_C_EVENT, pi.dwProcessId); ResetEvent (hevent); } } DWORD code; GetExitCodeProcess (pi.hProcess, &code); ExitProcess (code); }
[ [ [ 1, 225 ] ] ]
6aeff12e6fab4a6a0e124b37d53d9736335b8ec8
fad6f9883d4ad2686c196dc532a9ecb9199500ee
/NXP-LPC/CommTest/CommTest/ChildFrm.cpp
10483a0285dbe5d0c173e5d294502ec0d0d88f4e
[]
no_license
aquarius20th/nxp-lpc
fe83d6a140d361a1737d950ff728c6ea9a16a1dd
4abfb804daf0ac9c59bd90d879256e7a3c1b2f30
refs/heads/master
2021-01-10T13:54:40.237682
2009-12-22T14:54:59
2009-12-22T14:54:59
48,420,260
0
0
null
null
null
null
GB18030
C++
false
false
1,285
cpp
// ChildFrm.cpp : CChildFrame 类的实现 // #include "stdafx.h" #include "CommTest.h" #include "ChildFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CChildFrame IMPLEMENT_DYNCREATE(CChildFrame, CBCGPMDIChildWnd) BEGIN_MESSAGE_MAP(CChildFrame, CBCGPMDIChildWnd) END_MESSAGE_MAP() // CChildFrame 构造/析构 CChildFrame::CChildFrame() { // TODO: 在此添加成员初始化代码 } CChildFrame::~CChildFrame() { } BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) { // TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或样式 if( !CBCGPMDIChildWnd::PreCreateWindow(cs) ) return FALSE; cs.style &= ~WS_SYSMENU; return TRUE; } // CChildFrame 诊断 #ifdef _DEBUG void CChildFrame::AssertValid() const { CBCGPMDIChildWnd::AssertValid(); } void CChildFrame::Dump(CDumpContext& dc) const { CBCGPMDIChildWnd::Dump(dc); } #endif //_DEBUG void CChildFrame::ActivateFrame(int nCmdShow) { CBCGPMDIChildWnd::ActivateFrame(SW_SHOWMAXIMIZED); } // CChildFrame 消息处理程序 BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { // TODO: 在此添加专用代码和/或调用基类 return CBCGPMDIChildWnd::OnCreateClient(lpcs, pContext); }
[ "lijin.unix@13de9a6c-71d3-11de-b374-81e7cb8b6ca2" ]
[ [ [ 1, 69 ] ] ]
d17f2041efbd771f1ccd74c409f3c19622c57cb0
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ObjectDLL/ObjectShared/DebugLineSystem.h
86eb693dc7729ebae99a6c9e9b1b46b364c63f4b
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
5,632
h
// ----------------------------------------------------------------------- // // // MODULE : DebugLineSystem.h // // PURPOSE : // // CREATED : 3/29/2000 // // (c) 1997-2000 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #ifndef __DEBUG_LINE_SYSTEM_H__ #define __DEBUG_LINE_SYSTEM_H__ #include "DebugLine.h" #pragma warning (disable : 4786) #include <deque> #include <map> #include <string> LINKTO_MODULE( DebugLineSystem ); class DebugLineSystem : public BaseClass { public: typedef std::deque<DebugLine> LineList; static DebugLineSystem * Spawn(const char * name, int max_lines = 300); public: DebugLineSystem() : BaseClass(OT_NORMAL), nextLineToSend(lines.begin()), m_nMaxLines(0), m_bClearOldLines(false), m_vVertexSum(0.0f,0.0f,0.0f), m_fNumSummedVertices(0.0f) {} // Called when a new client enters. void ResetNextLineToSend( ); void AddLine(const DebugLine & new_line); void AddLine(const LTVector & vSource, const LTVector & vDest, const DebugLine::Color & color = DebugLine::Color(255,255,255), uint8 nAlpha = 255 ) { AddLine(DebugLine(vSource,vDest,color,nAlpha)); } void AddBox( const LTVector & vBoxPos, const LTVector & vBoxDims, const DebugLine::Color & color = DebugLine::Color(255,255,255), uint8 nAlpha = 255 ); void Clear(); void SetMaxLines(uint32 max_lines) { m_nMaxLines = max_lines; } void SetDebugString(const char *pStr) { if (pStr) m_DebugString = pStr; else m_DebugString = ""; } protected: LTRESULT EngineMessageFn (LTRESULT messageID, void *pData, float lData); private: // These are called by EngineMessageFn. void ReadProp(ObjectCreateStruct *pStruct); void InitialUpdate(); void Update(); // Member Variables. LineList lines; LineList::iterator nextLineToSend; uint32 m_nMaxLines; bool m_bClearOldLines; LTVector m_vVertexSum; float m_fNumSummedVertices; std::string m_DebugString; }; namespace Color { const DebugLine::Color White(255,255,255); const DebugLine::Color Red(255,0,0); const DebugLine::Color Green(0,255,0); const DebugLine::Color Blue(0,0,255); const DebugLine::Color Yellow(255,255,0); const DebugLine::Color Purple(255,0,255); const DebugLine::Color Cyan(0,255,255); const DebugLine::Color DkRed(128,32,32); const DebugLine::Color DkGreen(32,128,32); const DebugLine::Color DkBlue(32,32,128); }; namespace LineSystem { DebugLineSystem & GetSystem(const std::string & name); DebugLineSystem & GetSystem(const void * pOwner, const std::string & name); void RemoveSystem( const std::string& name ); void RemoveSystem( const void * pOwner, const std::string & name ); void RemoveAll(); // Tells all systems to resend their lines. void ResendAll(); class Clear {}; class Line { public : const LTVector start; const LTVector end; const DebugLine::Color color; const uint8 alpha; Line( const LTVector & new_start, const LTVector & new_end, const DebugLine::Color & new_color = Color::White, uint8 new_alpha = 255 ) : start(new_start), end(new_end), color(new_color), alpha(new_alpha) {} }; inline DebugLineSystem & operator<<( DebugLineSystem & out, const LineSystem::Line & line) { out.AddLine(line.start,line.end,line.color,line.alpha); return out; } class Box { public : const LTVector position; const LTVector dimensions; const DebugLine::Color color; const uint8 alpha; Box(const LTVector & new_position, const LTVector & new_dimensions, const DebugLine::Color & new_color = Color::White, uint8 new_alpha = 255 ) : position(new_position), dimensions(new_dimensions), color(new_color), alpha(new_alpha) {} }; inline DebugLineSystem & operator<<( DebugLineSystem & out, const LineSystem::Box & box) { out.AddBox( box.position, box.dimensions, box.color, box.alpha ); return out; } class Arrow { public : const LTVector start; const LTVector end; const DebugLine::Color color; const uint8 alpha; Arrow( const LTVector & new_start, const LTVector & new_end, const DebugLine::Color & new_color = Color::White, uint8 new_alpha = 255 ) : start(new_start), end(new_end), color(new_color), alpha(new_alpha) {} }; inline DebugLineSystem & operator<<( DebugLineSystem & out, const LineSystem::Arrow & arrow) { const LTFLOAT head_size = 4.0f; LTVector vStartToEnd = arrow.end - arrow.start; vStartToEnd.Norm(head_size); out.AddLine(arrow.start,arrow.end,arrow.color,arrow.alpha); out.AddLine(arrow.end,arrow.end - vStartToEnd + LTVector(head_size/2.0f,0.0f,0.0f), arrow.color,arrow.alpha); out.AddLine(arrow.end,arrow.end - vStartToEnd + LTVector(-head_size/2.0f,0.0f,0.0f), arrow.color,arrow.alpha); out.AddLine(arrow.end,arrow.end - vStartToEnd + LTVector(0.0f,head_size/2.0f,0.0f), arrow.color,arrow.alpha); out.AddLine(arrow.end,arrow.end - vStartToEnd + LTVector(0.0f,-head_size/2.0f,0.0f), arrow.color,arrow.alpha); out.AddLine(arrow.end,arrow.end - vStartToEnd + LTVector(0.0f,0.0f,head_size/2.0f), arrow.color,arrow.alpha); out.AddLine(arrow.end,arrow.end - vStartToEnd + LTVector(0.0f,0.0f,-head_size/2.0f), arrow.color,arrow.alpha); return out; } } //namespace LineSystem #endif //__DEBUG_LINE_SYSTEM_H__
[ [ [ 1, 227 ] ] ]
6982f058e6c5ecae18c40247c25c3f1b780f0c94
be7df324d5509c7ebb368c884b53ea9445d32e4f
/GUI/Cardiac/arthurstyle.cpp
ae5b77f0061d0e770440f1d4f29c1b66b14afe4c
[]
no_license
shadimsaleh/thesis.code
b75281001aa0358282e9cceefa0d5d0ecfffdef1
085931bee5b07eec9e276ed0041d494c4a86f6a5
refs/heads/master
2021-01-11T12:20:13.655912
2011-10-19T13:34:01
2011-10-19T13:34:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,494
cpp
/**************************************************************************** ** ** Copyright (C) 2005-2006 Trolltech ASA. All rights reserved. ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://www.trolltech.com/products/qt/licensing.html or contact the ** sales department at [email protected]. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #include "arthurstyle.h" #include "arthurwidgets.h" #include <QLayout> #include <QPainter> #include <QPainterPath> #include <QPixmapCache> #include <QRadioButton> #include <QString> #include <QStyleOption> #include <QtDebug> QPixmap cached(const QString &img) { if (QPixmap *p = QPixmapCache::find(img)) return *p; QPixmap pm; pm = QPixmap::fromImage(QImage(img), Qt::OrderedDither | Qt::OrderedAlphaDither); if (pm.isNull()) return QPixmap(); QPixmapCache::insert(img, pm); return pm; } ArthurStyle::ArthurStyle() : QWindowsStyle() { Q_INIT_RESOURCE(shared); } void ArthurStyle::drawHoverRect(QPainter *painter, const QRect &r) const { double h = r.height(); double h2 = r.height() / 2.0; QPainterPath path; path.addRect(r.x() + h2, r.y() + 0, r.width() - h2 * 2, r.height()); path.addEllipse(r.x(), r.y(), h, h); path.addEllipse(r.x() + r.width() - h, r.y(), h, h); path.setFillRule(Qt::WindingFill); painter->setPen(Qt::NoPen); painter->setBrush(QColor(191, 215, 191)); painter->setRenderHint(QPainter::Antialiasing); painter->drawPath(path); } void ArthurStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { Q_ASSERT(option); switch (element) { case PE_FrameFocusRect: break; case PE_IndicatorRadioButton: if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); painter->save(); QPixmap radio; if (hover) drawHoverRect(painter, widget->rect()); if (button->state & State_Sunken) radio = cached(":res/images/radiobutton-on.png"); else if (button->state & State_On) radio = cached(":res/images/radiobutton_on.png"); else radio = cached(":res/images/radiobutton_off.png"); painter->drawPixmap(button->rect.topLeft(), radio); painter->restore(); } break; case PE_PanelButtonCommand: if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); painter->save(); const QPushButton *pushButton = qobject_cast<const QPushButton *>(widget); QWidget *parent = pushButton->parentWidget(); if (parent && qobject_cast<QGroupBox *>(parent)) { QLinearGradient lg(0, 0, 0, parent->height()); lg.setColorAt(0, QColor(224,224,224)); lg.setColorAt(1, QColor(255,255,255)); painter->setPen(Qt::NoPen); painter->setBrush(lg); painter->setBrushOrigin(-widget->mapToParent(QPoint(0,0))); painter->drawRect(button->rect); painter->setBrushOrigin(0,0); } bool down = pushButton && ((button->state & State_Sunken) || (button->state & State_On)); QPixmap left, right, mid; if (down) { left = cached(":res/images/button_pressed_cap_left.png"); right = cached(":res/images/button_pressed_cap_right.png"); mid = cached(":res/images/button_pressed_stretch.png"); } else { left = cached(":res/images/button_normal_cap_left.png"); right = cached(":res/images/button_normal_cap_right.png"); mid = cached(":res/images/button_normal_stretch.png"); } painter->drawPixmap(button->rect.topLeft(), left); painter->drawTiledPixmap(QRect(button->rect.x() + left.width(), button->rect.y(), button->rect.width() - left.width() - right.width(), left.height()), mid); painter->drawPixmap(button->rect.x() + button->rect.width() - right.width(), button->rect.y(), right); if (hover) painter->fillRect(widget->rect().adjusted(3,5,-3,-5), QColor(31,127,31,63)); painter->restore(); } break; case PE_FrameGroupBox: if (const QStyleOptionFrameV2 *group = qstyleoption_cast<const QStyleOptionFrameV2 *>(option)) { const QRect &r = group->rect; painter->save(); int radius = 14; int radius2 = radius*2; QPainterPath clipPath; clipPath.moveTo(radius, 0); clipPath.arcTo(r.right() - radius2, 0, radius2, radius2, 90, -90); clipPath.arcTo(r.right() - radius2, r.bottom() - radius2, radius2, radius2, 0, -90); clipPath.arcTo(r.left(), r.bottom() - radius2, radius2, radius2, 270, -90); clipPath.arcTo(r.left(), r.top(), radius2, radius2, 180, -90); painter->setClipPath(clipPath); QPixmap titleStretch = cached(":res/images/title_stretch.png"); QPixmap topLeft = cached(":res/images/groupframe_topleft.png"); QPixmap topRight = cached(":res/images/groupframe_topright.png"); QPixmap bottomLeft = cached(":res/images/groupframe_bottom_left.png"); QPixmap bottomRight = cached(":res/images/groupframe_bottom_right.png"); QPixmap leftStretch = cached(":res/images/groupframe_left_stretch.png"); QPixmap topStretch = cached(":res/images/groupframe_top_stretch.png"); QPixmap rightStretch = cached(":res/images/groupframe_right_stretch.png"); QPixmap bottomStretch = cached(":res/images/groupframe_bottom_stretch.png"); QLinearGradient lg(0, 0, 0, r.height()); lg.setColorAt(0, QColor(224,224,224)); lg.setColorAt(1, QColor(255,255,255)); painter->setPen(Qt::NoPen); painter->setBrush(lg); painter->drawRect(r.adjusted(0, titleStretch.height()/2, 0, 0)); painter->setClipping(false); int topFrameOffset = titleStretch.height()/2 - 2; painter->drawPixmap(r.topLeft() + QPoint(0, topFrameOffset), topLeft); painter->drawPixmap(r.topRight() - QPoint(topRight.width()-1, 0) + QPoint(0, topFrameOffset), topRight); painter->drawPixmap(r.bottomLeft() - QPoint(0, bottomLeft.height()-1), bottomLeft); painter->drawPixmap(r.bottomRight() - QPoint(bottomRight.width()-1, bottomRight.height()-1), bottomRight); QRect left = r; left.setY(r.y() + topLeft.height() + topFrameOffset); left.setWidth(leftStretch.width()); left.setHeight(r.height() - topLeft.height() - bottomLeft.height() - topFrameOffset); painter->drawTiledPixmap(left, leftStretch); QRect top = r; top.setX(r.x() + topLeft.width()); top.setY(r.y() + topFrameOffset); top.setWidth(r.width() - topLeft.width() - topRight.width()); top.setHeight(topLeft.height()); painter->drawTiledPixmap(top, topStretch); QRect right = r; right.setX(r.right() - rightStretch.width()+1); right.setY(r.y() + topRight.height() + topFrameOffset); right.setWidth(rightStretch.width()); right.setHeight(r.height() - topRight.height() - bottomRight.height() - topFrameOffset); painter->drawTiledPixmap(right, rightStretch); QRect bottom = r; bottom.setX(r.x() + bottomLeft.width()); bottom.setY(r.bottom() - bottomStretch.height()+1); bottom.setWidth(r.width() - bottomLeft.width() - bottomRight.width()); bottom.setHeight(bottomLeft.height()); painter->drawTiledPixmap(bottom, bottomStretch); painter->restore(); } break; default: QWindowsStyle::drawPrimitive(element, option, painter, widget); break; } return; } void ArthurStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget); painter->save(); bool hover = (slider->state & State_Enabled) && (slider->state & State_MouseOver); if (hover) { QRect moderated = widget->rect().adjusted(0, 4, 0, -4); drawHoverRect(painter, moderated); } if ((option->subControls & SC_SliderGroove) && groove.isValid()) { QPixmap grv = cached(":res/images/slider_bar.png"); painter->drawPixmap(QRect(groove.x() + 5, groove.y(), groove.width() - 10, grv.height()), grv); } if ((option->subControls & SC_SliderHandle) && handle.isValid()) { QPixmap hndl = cached(":res/images/slider_thumb_on.png"); painter->drawPixmap(handle.topLeft(), hndl); } painter->restore(); } break; case CC_GroupBox: if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { QStyleOptionGroupBox groupBoxCopy(*groupBox); groupBoxCopy.subControls &= ~SC_GroupBoxLabel; QWindowsStyle::drawComplexControl(control, &groupBoxCopy, painter, widget); if (groupBox->subControls & SC_GroupBoxLabel) { const QRect &r = groupBox->rect; QPixmap titleLeft = cached(":res/images/title_cap_left.png"); QPixmap titleRight = cached(":res/images/title_cap_right.png"); QPixmap titleStretch = cached(":res/images/title_stretch.png"); int txt_width = groupBox->fontMetrics.width(groupBox->text) + 20; painter->drawPixmap(r.center().x() - txt_width/2, 0, titleLeft); QRect tileRect = subControlRect(control, groupBox, SC_GroupBoxLabel, widget); painter->drawTiledPixmap(tileRect, titleStretch); painter->drawPixmap(tileRect.x() + tileRect.width(), 0, titleRight); int opacity = 31; painter->setPen(QColor(0, 0, 0, opacity)); painter->drawText(tileRect.translated(0, 1), Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); painter->drawText(tileRect.translated(2, 1), Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); painter->setPen(QColor(0, 0, 0, opacity * 2)); painter->drawText(tileRect.translated(1, 1), Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); painter->setPen(Qt::white); painter->drawText(tileRect, Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); } } break; default: QWindowsStyle::drawComplexControl(control, option, painter, widget); break; } return; } QRect ArthurStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const { QRect rect; switch (control) { default: rect = QWindowsStyle::subControlRect(control, option, subControl, widget); break; case CC_GroupBox: if (const QStyleOptionGroupBox *group = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { switch (subControl) { default: rect = QWindowsStyle::subControlRect(control, option, subControl, widget); break; case SC_GroupBoxContents: rect = QWindowsStyle::subControlRect(control, option, subControl, widget); rect.adjust(0, -8, 0, 0); break; case SC_GroupBoxFrame: rect = group->rect; break; case SC_GroupBoxLabel: QPixmap titleLeft = cached(":res/images/title_cap_left.png"); QPixmap titleRight = cached(":res/images/title_cap_right.png"); QPixmap titleStretch = cached(":res/images/title_stretch.png"); int txt_width = group->fontMetrics.width(group->text) + 20; rect = QRect(group->rect.center().x() - txt_width/2 + titleLeft.width(), 0, txt_width - titleLeft.width() - titleRight.width(), titleStretch.height()); break; } } break; } if (control == CC_Slider && subControl == SC_SliderHandle) { rect.setWidth(13); rect.setHeight(27); } else if (control == CC_Slider && subControl == SC_SliderGroove) { rect.setHeight(9); rect.moveTop(27/2 - 9/2); } return rect; } QSize ArthurStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const { QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); switch (type) { case CT_RadioButton: newSize += QSize(20, 0); break; case CT_PushButton: newSize.setHeight(26); break; case CT_Slider: newSize.setHeight(27); break; default: break; } return newSize; } int ArthurStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const { if (pm == PM_SliderLength) return 13; return QWindowsStyle::pixelMetric(pm, opt, widget); } void ArthurStyle::polish(QWidget *widget) { if (widget->layout() && qobject_cast<QGroupBox *>(widget)) { if (qFindChildren<QGroupBox *>(widget).size() == 0) widget->layout()->setSpacing(0); else widget->layout()->setMargin(10); } if (qobject_cast<QPushButton *>(widget) || qobject_cast<QRadioButton *>(widget) || qobject_cast<QSlider *>(widget)) { widget->setAttribute(Qt::WA_Hover); } QPalette pal = widget->palette(); if (widget->isWindow()) { pal.setColor(QPalette::Background, QColor(241, 241, 241)); widget->setPalette(pal); } } void ArthurStyle::unpolish(QWidget *widget) { if (qobject_cast<QPushButton *>(widget) || qobject_cast<QRadioButton *>(widget) || qobject_cast<QSlider *>(widget)) { widget->setAttribute(Qt::WA_Hover, false); } } void ArthurStyle::polish(QPalette &palette) { palette.setColor(QPalette::Background, QColor(241, 241, 241)); } QRect ArthurStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const { QRect r; switch(element) { case SE_RadioButtonClickRect: r = widget->rect(); break; case SE_RadioButtonContents: r = widget->rect().adjusted(20, 0, 0, 0); break; default: r = QWindowsStyle::subElementRect(element, option, widget); break; } if (qobject_cast<const QRadioButton*>(widget)) r = r.adjusted(5, 0, -5, 0); return r; }
[ [ [ 1, 431 ] ] ]
15bb1ca69107f57935935c902e5fca068b8f9dc0
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/nebula2/src/tools/npixelformat.cc
28dc16c4b0be8e40b9ccb0a2877c1203ea01ec7a
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,200
cc
#include "precompiled/pchntoollib.h" //------------------------------------------------------------------- // npixelformat.cc // (C) 1999 Andre Weissflog //------------------------------------------------------------------- #include <stdlib.h> #include <string.h> #include "tools/npixelformat.h" typedef unsigned long ulong ; //------------------------------------------------------------------- // nPixelFormat(bpp,palette) // 19-Nov-98 floh created // 17-Dec-99 floh updated //------------------------------------------------------------------- nPixelFormat::nPixelFormat(int _bpp, nPalEntry *_pal) { n_assert(_bpp == 8); int pal_size = (1<<_bpp) * sizeof(nPalEntry); this->type = N_PFTYPE_CLUT; this->bpp = _bpp; this->pal = (nPalEntry *) n_malloc(pal_size); if (_pal) memcpy(this->pal,_pal,pal_size); this->r_mask = this->g_mask = this->b_mask = this->a_mask = 0; this->r_shift = this->g_shift = this->b_mask = this->a_mask = 0; } //------------------------------------------------------------------- // nPixelFormat(bpp,r_mask,g_mask,b_mask,a_mask) // 19-Nov-98 floh created // 17-Dec-99 floh updated //------------------------------------------------------------------- nPixelFormat::nPixelFormat(int _bpp, unsigned int _r_mask, unsigned int _g_mask, unsigned int _b_mask, unsigned int _a_mask) { n_assert((_bpp==16)||(_bpp==24)||(_bpp==32)); unsigned int r,g,b,a; unsigned int m; this->type = N_PFTYPE_RGBA; this->bpp = _bpp; this->pal = NULL; this->r_mask = _r_mask; this->g_mask = _g_mask; this->b_mask = _b_mask; this->a_mask = _a_mask; // compute shift values to shift normalized 8 bit components // to the correct position in the pixel format if (this->r_mask) { for (r=0, m=_r_mask; !(m&1); r++,m>>=1); this->r_shift = r; for (r=0; m&1; r++,m>>=1); this->r_shift -= (8-r); } else this->r_shift = 0; if (this->g_mask) { for (g=0, m=_g_mask; !(m&1); g++,m>>=1); this->g_shift = g; for (g=0; m&1; g++,m>>=1); this->g_shift -= (8-g); } else this->g_shift = 0; if (this->b_mask) { for (b=0, m=_b_mask; !(m&1); b++,m>>=1); this->b_shift = b; for (b=0; m&1; b++,m>>=1); this->b_shift -= (8-b); } else this->b_shift = 0; if (this->a_mask) { for (a=0, m=_a_mask; !(m&1); a++,m>>=1); this->a_shift = a; for (a=0; m&1; a++,m>>=1); this->a_shift -= (8-a); } else this->a_shift = 0; } //------------------------------------------------------------------- // nPixelFormat(nPixelFormat *) // 19-Nov-98 floh created // 17-Dec-99 floh updated //------------------------------------------------------------------- nPixelFormat::nPixelFormat(nPixelFormat *pf) { this->type = pf->type; this->bpp = pf->bpp; if (pf->pal) { ulong pal_size = (1<<pf->bpp) * sizeof(nPalEntry); this->pal = (nPalEntry *) n_malloc(pal_size); memcpy(this->pal,pf->pal,pal_size); } else this->pal = NULL; this->r_mask = pf->r_mask; this->g_mask = pf->g_mask; this->b_mask = pf->b_mask; this->a_mask = pf->a_mask; this->r_shift = pf->r_shift; this->g_shift = pf->g_shift; this->b_shift = pf->b_shift; this->a_shift = pf->a_shift; this->pf_from = NULL; } //------------------------------------------------------------------- // ~nPixelFormat() // 24-Nov-98 floh created //------------------------------------------------------------------- nPixelFormat::~nPixelFormat() { if (this->pal) n_free(this->pal); } //------------------------------------------------------------------- // BeginConv() // 24-Nov-98 floh created // 17-Dec-99 floh updated //------------------------------------------------------------------- bool nPixelFormat::BeginConv(nPixelFormat *from) { this->pf_from = from; // check for illegal combinations... if ((from->type==N_PFTYPE_RGBA) && (this->type==N_PFTYPE_CLUT)) { n_message("nPixelFormat: illegal conversion, rgba->clut!"); return false; } // copy palette, if necessary if ((this->type==N_PFTYPE_CLUT) && (from->type==N_PFTYPE_CLUT)) { memcpy(this->pal,from->pal,(1<<from->bpp)*sizeof(nPalEntry)); } return true; } //------------------------------------------------------------------- // EndConv() // 24-Nov-98 floh created //------------------------------------------------------------------- void nPixelFormat::EndConv(void) { } //------------------------------------------------------------------- // getPixel() // 26-Nov-98 floh created //------------------------------------------------------------------- static ulong getPixel(int bpp, uchar *src) { ulong p = 0; switch(bpp) { case 16: p = (ulong) *(ushort *)src; break; case 24: { ulong p0 = (ulong) *src++; ulong p1 = (ulong) *src++; ulong p2 = (ulong) *src++; p = (p0<<16)|(p1<<8)|(p2); } break; case 32: p = *(ulong *)src; break; }; return p; } //------------------------------------------------------------------- // putPixel() // 26-Nov-98 floh created //------------------------------------------------------------------- static void putPixel(int bpp, uchar *tar, ulong p) { ulong p0,p1,p2; switch(bpp) { case 16: *(ushort *)tar = (ushort) p; break; case 24: p0 = p>>16 & 0xff; p1 = p>>8 & 0xff; p2 = p & 0xff; *tar++=(uchar)p0; *tar++=(uchar)p1; *tar=(uchar)p2; break; case 32: *(ulong *)tar = p; break; }; } //------------------------------------------------------------------- // Conv() // 24-Nov-98 floh created // 25-Nov-98 floh + wenn Source keinen Alpha-Kanal hat, wird // dieser jetzt automatisch auf voll // undurchsichtig gesetzt. // 17-Dec-99 floh + updated //------------------------------------------------------------------- void nPixelFormat::Conv(uchar *from_buf, uchar *to_buf, int num_pixels) { int i; int from_addr = 0; int to_addr = 0; uchar *src,*tar; // Fallunterscheidung // RGBA->RGBA if ((this->pf_from->type==N_PFTYPE_RGBA) && (this->type==N_PFTYPE_RGBA)) { // special case: identical pixel formats if ((this->pf_from->bpp == this->bpp) && (this->pf_from->r_mask == this->r_mask) && (this->pf_from->g_mask == this->g_mask) && (this->pf_from->b_mask == this->b_mask) && (this->pf_from->a_mask == this->a_mask)) { memcpy(to_buf,from_buf,num_pixels*(this->bpp/8)); } else { int rs,gs,bs,as; rs = this->r_shift - this->pf_from->r_shift; bs = this->b_shift - this->pf_from->b_shift; gs = this->g_shift - this->pf_from->g_shift; as = this->a_shift - this->pf_from->a_shift; src = from_buf; tar = to_buf; for (i=0; i<num_pixels; i++) { unsigned int s,t,r,g,b,a; // read source rgba pixel s = getPixel(this->pf_from->bpp,src); // generate target pixel by masking and shifting r = s & this->pf_from->r_mask; g = s & this->pf_from->g_mask; b = s & this->pf_from->b_mask; if (!this->pf_from->a_mask) a = 0xffffffff; else a = s & this->pf_from->a_mask; if (rs >= 0) r<<=rs; else r>>=-rs; if (gs >= 0) g<<=gs; else g>>=-gs; if (bs >= 0) b<<=bs; else b>>=-bs; if (as >= 0) a<<=as; else a>>=-as; t = r & this->r_mask; t |= g & this->g_mask; t |= b & this->b_mask; t |= a & this->a_mask; putPixel(this->bpp,tar,t); // pointers to next pixel from_addr += this->pf_from->bpp; to_addr += this->bpp; src = from_buf + (from_addr/8); tar = to_buf + (to_addr/8); } } // CLUT->RGBA } else if ((pf_from->type==N_PFTYPE_CLUT) && (type==N_PFTYPE_RGBA)) { int rs,gs,bs,as; rs = this->r_shift; bs = this->b_shift; gs = this->g_shift; as = this->a_shift; src = from_buf; tar = to_buf; for (i=0; i<num_pixels; i++) { unsigned int s,t,r,g,b,a; // read source pixel s = *src; // split to rgba format r = this->pf_from->pal[s].r; g = this->pf_from->pal[s].g; b = this->pf_from->pal[s].b; a = 0xffffffff; // CLUT generally has no alpha channel if (rs >= 0) r<<=rs; else r>>=-rs; if (gs >= 0) g<<=gs; else g>>=-gs; if (bs >= 0) b<<=bs; else b>>=-bs; if (as >= 0) a<<=as; else a>>=-as; t = r & this->r_mask; t |= g & this->g_mask; t |= b & this->b_mask; t |= a & this->a_mask; putPixel(this->bpp,tar,t); to_addr += this->bpp; src++; tar = to_buf + (to_addr/8); } // CLUT->CLUT } else memcpy(to_buf,from_buf,num_pixels); } //-------------------------------------------------------------------- // EOF //--------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 293 ] ] ]
bc200d71a9a2baf87d643d9511ee86af1c659bbf
6fd162d2cade2db745e68f11d7e9722a3855f033
/Source/BetterVSM_2009_08_31_SAVSM_64BitFloatSAT/SilhouetteBPMSSMKernel.h
39853ca4ab883fdffe0108a9b64c78bc7f22fe89
[]
no_license
SenichiFSeiei/oursavsm
8f418325bc9883bcb245e139dbd0249e72c18d78
379e77cab67b3b1423a4c6f480b664f79b03afa9
refs/heads/master
2021-01-10T21:00:52.797565
2010-04-27T13:18:19
2010-04-27T13:18:19
41,737,615
0
0
null
null
null
null
UTF-8
C++
false
false
9,451
h
#pragma once #include "CommonDef.h" #include "SoftShadowMap.h" #include "BasicSSMAlgorithm.h" #include "RenderObject.h" #include "DepthObject.h" #include "OGRE_LAYOUT.h" #include "FullRTQuadRender.h" class SilhouetteBPMSSMKernel:public BasicSSMAlgorithm { public: ID3D10Effect *m_pEffect; ID3D10InputLayout *m_pMaxLayout; ID3D10ShaderResourceView* m_pAreaTextureRV; FullRTQuadRender *m_pHSMKernel; FullRTQuadRender *m_pShadowResult; SilhouetteBPMSSMKernel(); HRESULT OnD3D10CreateDevice(ID3D10Device* pDev10, const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc, void* pUserContext); void OnD3D10FrameRender(bool render_ogre, bool render_scene, CDXUTDialog &g_SampleUI, S3UTMesh &g_MeshScene, float g_fFilterSize, SSMap &ssmap, S3UTCamera &g_CameraRef, S3UTCamera &g_LCameraRef, ID3D10Device* pDev10, double fTime, float fElapsedTime, void* pUserContext); void OnD3D10DestroyDevice(); HRESULT OnD3D10SwapChainResized( ID3D10Device* pDev10, IDXGISwapChain *pSwapChain, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ); void OnD3D10SwapChainReleasing( void* pUserContext ); ~SilhouetteBPMSSMKernel(); }; SilhouetteBPMSSMKernel::SilhouetteBPMSSMKernel() { m_pEffect = NULL; m_pMaxLayout = NULL; m_pAreaTextureRV = NULL; m_pHSMKernel = NULL; m_pShadowResult = NULL; } SilhouetteBPMSSMKernel::~SilhouetteBPMSSMKernel() { //OnD3D10DestroyDevice(); } HRESULT SilhouetteBPMSSMKernel::OnD3D10CreateDevice(ID3D10Device *pDev10, const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext) { HRESULT hr; //Effect Creation WCHAR str[MAX_PATH]; V_RETURN(DXUTFindDXSDKMediaFileCch(str, MAX_PATH, (SILHOUETTE_BP_EFFECT_FILE_NAME) )); ID3D10Blob *pErrors; if (D3DX10CreateEffectFromFile(str, NULL, NULL, "fx_4_0", D3D10_SHADER_DEBUG|D3D10_SHADER_SKIP_OPTIMIZATION, 0, pDev10, NULL, NULL, &m_pEffect, &pErrors, &hr) != S_OK) { MessageBoxA(NULL, (char *)pErrors->GetBufferPointer(), "Compilation error", MB_OK); exit(0); } //load texture for occluded area computation hr = D3DX10CreateShaderResourceViewFromFile( pDev10, L"areaT.dds", NULL, NULL, &m_pAreaTextureRV, NULL ); if( FAILED(hr) ) return hr; m_pHSMKernel = new FullRTQuadRender("RenderHSMKernel"); m_pHSMKernel->OnD3D10CreateDevice(m_pEffect,pDev10,pBackBufferSurfaceDesc,pUserContext); m_pShadowResult = new FullRTQuadRender("SSMBackprojection"); m_pShadowResult->OnD3D10CreateDevice(m_pEffect,pDev10,pBackBufferSurfaceDesc,pUserContext); return S_OK; } void SilhouetteBPMSSMKernel::OnD3D10SwapChainReleasing( void* pUserContext ) { if( m_pHSMKernel ) m_pHSMKernel->OnD3D10SwapChainReleasing(pUserContext); if( m_pShadowResult ) m_pShadowResult->OnD3D10SwapChainReleasing(pUserContext); } HRESULT SilhouetteBPMSSMKernel::OnD3D10SwapChainResized( ID3D10Device* pDev10, IDXGISwapChain *pSwapChain, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { D3D10_TEXTURE2D_DESC rtDesc_scrpos = { pBackBufferSurfaceDesc->Width, //UINT Width; pBackBufferSurfaceDesc->Height, //UINT Height; 1,//UINT MipLevels; 1,//UINT ArraySize; DXGI_FORMAT_R16G16B16A16_FLOAT,//DXGI_FORMAT Format; {1, 0}, //DXGI_SAMPLE_DESC SampleDesc; D3D10_USAGE_DEFAULT, //D3D10_USAGE Usage; D3D10_BIND_SHADER_RESOURCE | D3D10_BIND_RENDER_TARGET ,//UINT BindFlags; 0,//UINT CPUAccessFlags; 0,//UINT MiscFlags; }; //only position need 32 bit floating point, 16bit is enouth for others. save memory/traffic. m_pHSMKernel->OnD3D10SwapChainResized( rtDesc_scrpos, pDev10, pSwapChain, pBackBufferSurfaceDesc, pUserContext); m_pShadowResult->OnD3D10SwapChainResized( rtDesc_scrpos, pDev10, pSwapChain, pBackBufferSurfaceDesc, pUserContext); return S_OK; } void SilhouetteBPMSSMKernel::OnD3D10FrameRender(bool render_ogre, bool render_scene, CDXUTDialog &g_SampleUI, S3UTMesh &g_MeshScene, float g_fFilterSize, SSMap &ssmap, S3UTCamera &g_CameraRef, S3UTCamera &g_LCameraRef, ID3D10Device* pDev10, double fTime, float fElapsedTime, void* pUserContext ) { HRESULT hr; D3DXMATRIX mTmp, mWorldView, mWorldViewProj, mWorldViewInv; D3DXMatrixInverse(&mTmp, NULL, g_CameraRef.GetWorldMatrix()); D3DXMatrixMultiply(&mWorldView, &mTmp, g_CameraRef.GetViewMatrix()); D3DXMatrixMultiply(&mWorldViewProj, &mWorldView, g_CameraRef.GetProjMatrix()); D3DXMatrixInverse(&mWorldViewInv, NULL, &mWorldView); D3DXMATRIX mLightView; // here we compute light viewprojection so that light oversees the whole scene D3DXMATRIX mTranslate; D3DXMatrixInverse(&mTranslate, NULL, g_LCameraRef.GetWorldMatrix()); D3DXMatrixMultiply(&mLightView, &mTranslate, g_LCameraRef.GetViewMatrix()); D3DXMatrixMultiply(&ssmap.mLightViewProj, &mLightView, &ssmap.mLightProj); V(m_pEffect->GetVariableByName("fLightZn")->AsScalar()->SetFloat(m_par.fLightZn)); V(m_pEffect->GetVariableByName("mViewProj")->AsMatrix()->SetMatrix((float *)&ssmap.mLightViewProj)); V(m_pEffect->GetVariableByName("mLightView")->AsMatrix()->SetMatrix((float *)&mLightView)); V(m_pEffect->GetVariableByName("mLightProj")->AsMatrix()->SetMatrix((float *)&ssmap.mLightProj)); //--------------------- for specular D3DXVECTOR3 vCameraInLight, vZero = D3DXVECTOR3(0, 0, 0); D3DXVec3TransformCoord(&vCameraInLight, &vZero, &mWorldViewInv); D3DXVec3TransformCoord(&vCameraInLight, &vCameraInLight, &mLightView); V(m_pEffect->GetVariableByName("VCameraInLight")->AsVector()->SetRawValue(&vCameraInLight, 0, sizeof(vCameraInLight))); //------------------------------------------------------------------------------------------------------------------------- //Originally these are set inside soft shadow map class, I moved them our for more neat design V(m_pEffect->GetVariableByName("TexHSM")->AsShaderResource()->SetResource(ssmap.m_pBigDepth2SRView)); V(m_pEffect->GetVariableByName("TexDepthMap")->AsShaderResource()->SetResource(ssmap.m_pDepthSRView[0])); D3DXMATRIX mClip2Tex; mClip2Tex = D3DXMATRIX( 0.5, 0, 0, 0, 0, -0.5, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0, 1 ); D3DXMATRIX mLightViewProjClip2Tex, mLightProjClip2TexInv; D3DXMatrixMultiply(&mTmp, &ssmap.mLightProj, &mClip2Tex); D3DXMatrixInverse(&mLightProjClip2TexInv, NULL, &mTmp); V(m_pEffect->GetVariableByName("mLightProjClip2TexInv")->AsMatrix()->SetMatrix((float *)&mLightProjClip2TexInv)); pDev10->IASetInputLayout(m_pMaxLayout); { unsigned iTmp = g_SampleUI.GetCheckBox(IDC_BTEXTURED)->GetChecked(); V(m_pEffect->GetVariableByName("bTextured")->AsScalar()->SetRawValue(&iTmp, 0, sizeof(iTmp))); D3DXVECTOR4 vTmp = D3DXVECTOR4(1, 1, (float)iTmp, 1); V(m_pEffect->GetVariableByName("VLightFlux")->AsVector()->SetRawValue(&m_vec4LightColor, 0, sizeof(D3DXVECTOR4))); } V(m_pEffect->GetVariableByName("mViewProj")->AsMatrix()->SetMatrix((float *)&mWorldViewProj)); float fTmp = (FLOAT)(g_fFilterSize*LIGHT_SCALE_FACTOR); V(m_pEffect->GetVariableByName("fFilterSize")->AsScalar()->SetFloat(fTmp)); m_pEffect->GetVariableByName( "TexRadialArea" )->AsShaderResource()->SetResource(m_pAreaTextureRV); V(m_pEffect->GetVariableByName("TexPosInWorld")->AsShaderResource()->SetResource( m_pInputBuffer->m_pInputAttributes->m_pSRView0)); V(m_pEffect->GetVariableByName("TexNormalInWorld")->AsShaderResource()->SetResource( m_pInputBuffer->m_pInputAttributes->m_pSRView1)); V(m_pEffect->GetVariableByName("TexColor")->AsShaderResource()->SetResource( m_pInputBuffer->m_pInputAttributes->m_pSRView2)); m_pHSMKernel->SetUseMyRT(true); m_pHSMKernel->OnD3D10FrameRender( m_pEffect,m_pEffect->GetTechniqueByName("RenderHSMKernel"), pDev10,fTime,fElapsedTime,pUserContext); V(m_pEffect->GetVariableByName("TexHSMKernel")->AsShaderResource()->SetResource( m_pHSMKernel->m_pSRView )); const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc = DXUTGetDXGIBackBufferSurfaceDesc(); V(m_pEffect->GetVariableByName("fScreenWidth")->AsScalar()->SetFloat(pBackBufferSurfaceDesc->Width)); V(m_pEffect->GetVariableByName("fScreenHeight")->AsScalar()->SetFloat(pBackBufferSurfaceDesc->Height)); pDev10->OMSetRenderTargets(1,&m_pRTV,NULL); //in an alpha blending framework, clear is not allowed here float ClearColor[4] = { 1, 1, 1, 1 }; pDev10->ClearRenderTargetView(m_pRTV, ClearColor); m_pShadowResult->SetUseMyRT(false); m_pShadowResult->OnD3D10FrameRender( m_pEffect,m_pEffect->GetTechniqueByName("SSMBackprojection"), pDev10,fTime,fElapsedTime,pUserContext); } void SilhouetteBPMSSMKernel::OnD3D10DestroyDevice() { OnD3D10SwapChainReleasing(NULL); SAFE_RELEASE(m_pEffect); SAFE_RELEASE(m_pMaxLayout); SAFE_RELEASE(m_pAreaTextureRV); if( m_pHSMKernel ) m_pHSMKernel->OnD3D10DestroyDevice(); SAFE_DELETE(m_pHSMKernel); if( m_pShadowResult ) m_pShadowResult->OnD3D10DestroyDevice(); SAFE_DELETE(m_pShadowResult); }
[ "[email protected]", "flycooler@9eb8245e-93ee-11de-8d68-838d6ba51ce1" ]
[ [ [ 1, 226 ], [ 228, 233 ] ], [ [ 227, 227 ] ] ]
47982c3dca5933c5bf5b32dc801df5560799b9ad
bef7d0477a5cac485b4b3921a718394d5c2cf700
/vaikairoks/src/demo/Demo.cpp
002b58cc9f235eb713f9eac50fbb43849699aced
[ "MIT" ]
permissive
TomLeeLive/aras-p-dingus
ed91127790a604e0813cd4704acba742d3485400
22ef90c2bf01afd53c0b5b045f4dd0b59fe83009
refs/heads/master
2023-04-19T20:45:14.410448
2011-10-04T10:51:13
2011-10-04T10:51:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,565
cpp
#include "stdafx.h" #include "Demo.h" #include <dingus/gfx/gui/Gui.h> #include <dingus/utils/Random.h> #include <ctime> #include <dingus/audio/Sound.h> // -------------------------------------------------------------------------- // Common stuff IDingusAppContext* gAppContext; bool gFinished = false; bool gShowStats = false; CDemo::CDemo() { } bool CDemo::checkDevice( const CD3DDeviceCaps& caps, CD3DDeviceCaps::eVertexProcessing vproc, CD3DEnumErrors& errors ) { bool ok = true; if( caps.getVShaderVersion() < CD3DDeviceCaps::VS_1_1 ) { if( vproc != CD3DDeviceCaps::VP_SW ) ok = false; } return ok; } bool CDemo::shouldFinish() { return gFinished; } bool CDemo::shouldShowStats() { return gShowStats; } // -------------------------------------------------------------------------- // Demo data CUIDialog* gUIDlg; enum eFont { FNT_NORMAL = 0, FNT_HUGE = 1, FNT_LARGE = 2, }; // -------------------------------------------------------------------------- // game logic wchar_t LETTERS[1000]; wchar_t PRESSAKEY[1000]; CSound* gLetterSounds[1000]; struct SWordDesc { wchar_t word[100]; char picture[100]; }; std::vector<SWordDesc> gWordDescs; struct SPicture { CD3DTexture* texture; RECT uvs; const wchar_t* word; }; typedef std::vector<SPicture> TPictureVector; std::vector<TPictureVector> gLetterPictures; int gCurrLetterIdx = 0; int gCurrPictureIdx = -1; D3DXCOLOR gLetterColor = D3DXCOLOR(0,0,0,1); SUIElement gUIElem; void CDemo::initLetters() { FILE* f; // read available words f = fopen( "data/words.txt", "rb" ); // skip unicode mark fgetc( f ); fgetc( f ); // first line - letters fwscanf( f, L"%ls\n", LETTERS ); int nletters = wcslen( LETTERS ); // second line - sounds for letters wchar_t soundbuf[100]; for( int i = 0; i < nletters; ++i ) { fwscanf( f, L"%ls", soundbuf ); char soundID[100]; wcstombs( soundID, soundbuf, sizeof(soundID) ); gLetterSounds[i] = new CSound( *RGET_SOUND(CSoundDesc(soundID, true)) ); gLetterSounds[i]->setLooping( false ); } fgetws( soundbuf, 100, f ); // "press a key" fgetws( PRESSAKEY, 100, f ); // remaining lines - words while( !feof(f) ) { wchar_t apict[100]; gWordDescs.push_back( SWordDesc() ); SWordDesc& wd = gWordDescs.back(); fwscanf( f, L"%ls", wd.word ); fwscanf( f, L"%s\n", apict ); wcstombs( wd.picture, apict, sizeof(wd.picture) ); } fclose( f ); // resize letter pictures vector gLetterPictures.resize( nletters ); // read picture atlas definitions f = fopen( "data/Atlas.tai", "rt" ); while( !feof(f) ) { char apict[100]; char aatlas[100]; int aindex; float au, av; float adu, adv; float dummy; fscanf( f, "%s %s %i, 2D, %f, %f, %f, %f, %f\n", apict, aatlas, &aindex, &au, &av, &dummy, &adu, &adv ); // remove '?.png' from apict apict[strlen(apict)-5] = 0; // see if we have this word bool found = false; const wchar_t* word = 0; for( int i = 0; i < gWordDescs.size(); ++i ) { const SWordDesc& wd = gWordDescs[i]; if( 0 == stricmp( apict, wd.picture ) ) { found = true; word = wd.word; break; } } if( !found ) continue; // have this word, remember picture info int letterIdx = wcschr( LETTERS, word[0] ) - LETTERS; assert( letterIdx >= 0 && letterIdx < gLetterPictures.size() ); SPicture pict; // remove '.dds,' from aatlas aatlas[strlen(aatlas)-5] = 0; pict.texture = RGET_TEX(aatlas); D3DSURFACE_DESC desc; pict.texture->getObject()->GetLevelDesc( 0, &desc ); pict.uvs.left = au * desc.Width; pict.uvs.top = av * desc.Height; pict.uvs.right = (au+adu) * desc.Width; pict.uvs.bottom = (av+adv) * desc.Height; pict.word = word; gLetterPictures[letterIdx].push_back( pict ); } fclose( f ); // initial data gCurrLetterIdx = 0; fillLetterParams(); } void CDemo::nextLetter() { ++gCurrLetterIdx; if( LETTERS[gCurrLetterIdx] == 0 ) gCurrLetterIdx = 0; fillLetterParams(); // play sound gLetterSounds[gCurrLetterIdx]->start(); } void CDemo::fillLetterParams() { // color gLetterColor.r = gRandom.getFloat( 0.1f, 0.6f ); gLetterColor.g = gRandom.getFloat( 0.1f, 0.6f ); gLetterColor.b = gRandom.getFloat( 0.1f, 0.6f ); // picture index const TPictureVector& picts = gLetterPictures[gCurrLetterIdx]; if( picts.empty() ) gCurrPictureIdx = -1; else { gCurrPictureIdx = picts.size() * ((gRandom.getUInt()&1023)/1024.0f); CConsole::CON_WARNING << "picts: " << int(picts.size()) << " idx: " << gCurrPictureIdx << endl; } } void CALLBACK gUIRenderCallback( CUIDialog& dlg ) { SFRect r; // draw letter gUIElem.colorFont.current = gLetterColor; gUIElem.fontIdx = FNT_HUGE; gUIElem.textFormat = DT_CENTER | DT_VCENTER | DT_NOCLIP; wchar_t buf[10]; buf[0] = LETTERS[gCurrLetterIdx]; buf[1] = 0; r.left = 80; r.right = 270; r.top = 80; r.bottom = 300; dlg.drawText( buf, &gUIElem, &r, true ); // draw "press a key" gUIElem.fontIdx = FNT_LARGE; gUIElem.colorFont.current = 0xFF808080; r.left = 0; r.right = 640; r.top = 400; r.bottom = 480; dlg.drawText( PRESSAKEY, &gUIElem, &r, true ); // draw picture if we have one if( gCurrPictureIdx >= 0 ) { gUIElem.colorTexture.current = 0xFFffffff; const SPicture& pict = gLetterPictures[gCurrLetterIdx][gCurrPictureIdx]; gUIElem.texture = pict.texture; gUIElem.textureRect = pict.uvs; float dx = (pict.uvs.right - pict.uvs.left) * 0.5f; float dy = (pict.uvs.bottom - pict.uvs.top) * 0.5f; r.left = 280; r.right = r.left + dx - 2; r.top = 220 - dy/2 - 20; r.bottom = r.top + dy - 2; // rectangle dlg.drawRect( &r, 0xC0000000 ); r.left += 1; r.right -= 1; r.top += 1; r.bottom -= 1; // picture dlg.drawSprite( &gUIElem, &r ); // the word r.top = r.bottom + 5; r.bottom = r.top + 50; gUIElem.fontIdx = FNT_LARGE; gUIElem.textFormat = DT_CENTER | DT_TOP | DT_NOCLIP; gUIElem.colorFont.current = gLetterColor; dlg.drawText( pict.word, &gUIElem, &r, true ); } } // -------------------------------------------------------------------------- // initialization void CALLBACK gUICallback( UINT evt, int ctrlID, CUIControl* ctrl ) { } void CDemo::initialize( IDingusAppContext& appContext ) { gRandom.seed( time( NULL ) ); gAppContext = &appContext; CD3DDevice& dx = CD3DDevice::getInstance(); G_INPUTCTX->addListener( *this ); // -------------------------------- // letter pictures initLetters(); // -------------------------------- // GUI gUIDlg = new CUIDialog(); gUIDlg->setFont( FNT_HUGE, "Comic Sans MS", 240, FW_BOLD ); gUIDlg->setFont( FNT_LARGE, "Comic Sans MS", 32, FW_BOLD ); gUIDlg->setCallback( gUICallback ); gUIDlg->setRenderCallback( gUIRenderCallback ); gUIElem.fontIdx = FNT_HUGE; gUIElem.colorFont.current = 0xFF000000; } // -------------------------------------------------------------------------- // Perform code (main loop) bool CDemo::msgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { bool done = false; if( gUIDlg ) { done = gUIDlg->msgProc( hwnd, msg, wparam, lparam ); if( done ) return true; } return false; } void CDemo::onInputEvent( const CInputEvent& event ) { float dt = CSystemTimer::getInstance().getDeltaTimeS(); if( event.getType() == CKeyEvent::EVENT_TYPE ) { const CKeyEvent& ke = (const CKeyEvent&)event; switch( ke.getKeyCode() ) { case DIK_9: if( ke.getMode() == CKeyEvent::KEY_PRESSED ) gShowStats = !gShowStats; break; default: if( ke.getAscii() >= ' ' && ke.getMode() == CKeyEvent::KEY_PRESSED ) { nextLetter(); } } } } void CDemo::onInputStage() { } /// Main loop code void CDemo::perform() { G_INPUTCTX->perform(); float dt = CSystemTimer::getInstance().getDeltaTimeS(); CD3DDevice& dx = CD3DDevice::getInstance(); // render dx.clearTargets( true, true, false, 0xFFf0f0f0, 1.0f, 0L ); dx.sceneBegin(); // render GUI gUIDlg->onRender( dt ); dx.sceneEnd(); // sleep a bit - don't hog the CPU Sleep( 1 ); } // -------------------------------------------------------------------------- // Cleanup void CDemo::shutdown() { safeDelete( gUIDlg ); for( int i = 0; i < gLetterPictures.size(); ++i ) delete gLetterSounds[i]; }
[ [ [ 1, 386 ] ] ]
b46d046409c9d77878660e318bd8c00f90acf913
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/q3sqlcursor.h
cc81ffc4ef4399020060f2342dd9946a5558d620
[ "BSD-2-Clause" ]
permissive
pranet/bhuman2009fork
14e473bd6e5d30af9f1745311d689723bfc5cfdb
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
refs/heads/master
2021-01-15T17:55:37.058289
2010-02-28T13:52:56
2010-02-28T13:52:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,906
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the Qt3Support module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef Q3SQLCURSOR_H #define Q3SQLCURSOR_H #include <QtCore/qvariant.h> #include <QtSql/qsqldatabase.h> #include <QtSql/qsqlrecord.h> #include <QtCore/qstringlist.h> #include <QtSql/qsqlquery.h> #include <QtSql/qsqlindex.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Qt3Support) #ifndef QT_NO_SQL class Q3SqlCursorPrivate; class Q3SqlFieldInfo; class Q_COMPAT_EXPORT Q3SqlCursor : public QSqlRecord, public QSqlQuery { public: Q3SqlCursor(const QString & name = QString(), bool autopopulate = true, QSqlDatabase db = QSqlDatabase()); Q3SqlCursor(const Q3SqlCursor & other); Q3SqlCursor& operator=(const Q3SqlCursor& other); virtual ~Q3SqlCursor(); enum Mode { ReadOnly = 0, Insert = 1, Update = 2, Delete = 4, Writable = 7 }; QVariant value(int i) const; inline QVariant value(const QString &name) const { return value(indexOf(name)); } virtual void setValue(int i, const QVariant &val); inline void setValue(const QString &name, const QVariant &val) { setValue(indexOf(name), val); } virtual QSqlIndex primaryIndex(bool prime = true) const; virtual QSqlIndex index(const QStringList& fieldNames) const; QSqlIndex index(const QString& fieldName) const; virtual void setPrimaryIndex(const QSqlIndex& idx); virtual void append(const Q3SqlFieldInfo& fieldInfo); virtual void insert(int pos, const Q3SqlFieldInfo &fieldInfo); virtual void remove(int pos); virtual void clear(); virtual void setGenerated(const QString& name, bool generated); virtual void setGenerated(int i, bool generated); virtual QSqlRecord* editBuffer(bool copy = false); virtual QSqlRecord* primeInsert(); virtual QSqlRecord* primeUpdate(); virtual QSqlRecord* primeDelete(); virtual int insert(bool invalidate = true); virtual int update(bool invalidate = true); virtual int del(bool invalidate = true); virtual void setMode(int flags); int mode() const; virtual void setCalculated(const QString& name, bool calculated); bool isCalculated(const QString& name) const; virtual void setTrimmed(const QString& name, bool trim); bool isTrimmed(const QString& name) const; bool isReadOnly() const; bool canInsert() const; bool canUpdate() const; bool canDelete() const; bool select(); bool select(const QSqlIndex& sort); bool select(const QSqlIndex & filter, const QSqlIndex & sort); virtual bool select(const QString & filter, const QSqlIndex & sort = QSqlIndex()); virtual void setSort(const QSqlIndex& sort); QSqlIndex sort() const; virtual void setFilter(const QString& filter); QString filter() const; virtual void setName(const QString& name, bool autopopulate = true); QString name() const; QString toString(const QString& prefix = QString(), const QString& sep = QLatin1String(",")) const; bool isNull(int i) const; bool isNull(const QString& name) const; virtual bool seek(int i, bool relative = false); virtual bool next(); inline bool previous() { return prev(); } virtual bool prev(); virtual bool first(); virtual bool last(); protected: virtual bool exec(const QString & sql); virtual QVariant calculateField(const QString& name); virtual int update(const QString & filter, bool invalidate = true); virtual int del(const QString & filter, bool invalidate = true); virtual QString toString(const QString& prefix, QSqlField* field, const QString& fieldSep) const; virtual QString toString(QSqlRecord* rec, const QString& prefix, const QString& fieldSep, const QString& sep) const; virtual QString toString(const QSqlIndex& i, QSqlRecord* rec, const QString& prefix, const QString& fieldSep, const QString& sep) const; private: void sync(); int apply(const QString& q, bool invalidate); int applyPrepared(const QString& q, bool invalidate); QSqlRecord& operator=(const QSqlRecord & list); void append(const QSqlField& field); Q3SqlCursorPrivate* d; }; #endif // QT_NO_SQL QT_END_NAMESPACE QT_END_HEADER #endif // Q3SQLCURSOR_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 167 ] ] ]
e8a3bc23d32d838eb6add04c430dd41a3dd0c66a
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/techdemo2/engine/dialog/include/predicates/TalentWertPredicates.h
f6ba7f2d9285e47cad56cf45fe873bd096b10c7b
[ "ClArtistic", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,194
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2006 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Perl Artistic 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 * Perl Artistic License for more details. * * You should have received a copy of the Perl Artistic License * along with this program; if not you can get it here * http://www.perldoc.com/perl5.6/Artistic.html. */ #ifndef __Rl_TalentWertPredicates_H__ #define __Rl_TalentWertPredicates_H__ #include "CreaturePredicates.h" namespace rl { class Creature; class TalentWertPredicates : public CreaturePredicates { public: TalentWertPredicates(Creature* pCharacter); ~TalentWertPredicates(void); CeGuiString getPredicate(const CeGuiString& pName) const; void setPredicate(const CeGuiString& pName, const CeGuiString& pValue); CeGuiString getType() const; }; } #endif
[ "tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 39 ] ] ]
a742277985173ee3702da1fa5ba3a725def1ebf8
d926628900f408516a3fa3375509f604aababa6f
/mainwindow.cpp
5d78203016d645ce3d3277391b764c571c26d162
[]
no_license
StanislavKraev/YourTodo
113c2813ed20dd38a18f244df99ea8678b51d5ac
579eebd5c3151a10c4fccdba8a164da58a57d898
refs/heads/master
2020-04-09T15:19:46.976799
2011-09-19T12:30:59
2011-09-19T12:30:59
1,947,936
5
0
null
null
null
null
UTF-8
C++
false
false
6,488
cpp
#include "ui_mainwindow.h" #include <QStyledItemDelegate> #include <QPainter> #include <QTimer> #include <QAbstractEventDispatcher> #include <QDebug> #include <QSettings> #include <QApplication> #include <QDesktopWidget> #include <QxtGlobalShortcut> #ifdef Q_WS_WIN #include "windows.h" #endif #include "iuimanager.h" #include "tasktree/tasklist.h" #include "tasktree/treemodel.h" #include "utils.h" #include "application.h" #include "mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_globalShortcut(0), m_uiManager(0) { ui->setupUi(this); ui->treeView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed); ui->treeView->setUniformRowHeights(true); ui->treeView->setAlternatingRowColors(true); QList<int> sizes; sizes << 300 << 100; ui->splitter->setSizes(sizes); ui->textEdit->setText("comment"); restoreUiState(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::closeEvent(QCloseEvent *event) { if (true) { rememberUiState(); emit(onMainWindowClosing()); event->accept(); } else { event->ignore(); } } void MainWindow::changeEvent(QEvent * event) { if(event->type() == QEvent::WindowStateChange) { if (isMinimized()) { emit(onMainWindowMinimized()); qApp->processEvents(); QTimer::singleShot(250, this, SLOT(hide())); return; } else { QWindowStateChangeEvent *ev = (QWindowStateChangeEvent*)event; if (ev->oldState() == Qt::WindowMinimized) { emit(onMainWindowRestored()); qApp->processEvents(); QTimer::singleShot(250, this, SLOT(show())); return; } } } QMainWindow::changeEvent(event); } void MainWindow::SetupEventFilter() { if (!m_globalShortcut) { m_globalShortcut = new QxtGlobalShortcut(m_uiManager->globalHotkey(), this); connect(m_globalShortcut, SIGNAL(activated()), this, SLOT(onShortcut())); } } void MainWindow::onShortcut() { if (isMinimized()) { showNormal(); activateWindow(); } else showMinimized(); } QMenuBar * MainWindow::menuBar() { return ui->menuBar; } QStatusBar * MainWindow::statusBar() { return ui->statusBar; } QToolBar * MainWindow::toolBar() { return ui->mainToolBar; } void MainWindow::updateTreeModel(ITaskList *taskList, ITreeUiProvider *treeUi) { QAbstractItemModel *oldModel = ui->treeView->model(); TreeModel *model = new TreeModel(this, taskList, treeUi); ui->treeView->setModel(model); if (oldModel) delete oldModel; emit(onModelsChanged(ui->treeView->selectionModel(), model)); } void MainWindow::maximizeTaskList(bool maximized) { ui->textEdit->setVisible(!maximized); ui->controlsArea->setVisible(!maximized); } bool MainWindow::isTasklistMaximized() const { bool visible = ui->textEdit->isVisible(); return !visible; } QItemSelectionModel* MainWindow::selectionModel() { return ui->treeView->selectionModel(); } QAbstractItemModel * MainWindow::model() { return ui->treeView->model(); } TaskTreeView * MainWindow::treeView() const { return ui->treeView; } QWidget * MainWindow::controlsArea() const { return ui->controlsArea; } QTextEdit * MainWindow::commentsControl() const { return ui->textEdit; } void MainWindow::rememberUiState() { int windowWidth = width(); int windowHeight = height(); int left = pos().x(); int top = pos().y(); QList<int> splitter_sizes = ui->splitter->sizes(); QSettings settings; settings.beginGroup("Ui"); settings.setValue("width", windowWidth); settings.setValue("height", windowHeight); settings.setValue("left", left); settings.setValue("top", top); settings.beginWriteArray("splitter_size", splitter_sizes.length()); for(int i = 0; i < splitter_sizes.length(); ++i) { settings.setArrayIndex(i); settings.setValue("size", splitter_sizes[i]); } settings.endArray(); settings.endGroup(); } void MainWindow::restoreUiState() { QSettings settings; settings.beginGroup("Ui"); int windowWidth = settings.value("width", 800).toInt(); int windowHeight = settings.value("height", 600).toInt(); int left = settings.value("left", 50).toInt(); int top = settings.value("top", 50).toInt(); QList<int> splitter_sizes; int splitter_size_count = settings.beginReadArray("splitter_size"); for(int i = 0; i < splitter_size_count; ++i) { settings.setArrayIndex(i); int splitter_size = settings.value("size", 0).toInt(); splitter_sizes.append(fixIntToRange(50, 1950, splitter_size)); } settings.endArray(); settings.endGroup(); windowWidth = fixIntToRange(400, 2000, windowWidth); windowHeight = fixIntToRange(300, 1500, windowHeight); left = fixIntToRange(0, qApp->desktop()->width() - 50, left); top = fixIntToRange(0, qApp->desktop()->height() - 50, top); resize(windowWidth, windowHeight); move(left, top); ui->splitter->setSizes(splitter_sizes); settings.beginGroup("General"); bool onTop = settings.value("onTop", false).toBool(); settings.endGroup(); if (onTop) setWindowFlags(Qt::WindowStaysOnTopHint); } void MainWindow::setWindowTitle(const QString &title) { QWidget::setWindowTitle(title + " - YourTodo"); } void MainWindow::setUiManager(IUiManager *uiManager) { m_uiManager = uiManager; } void MainWindow::setGlobalHotkey(QKeySequence key) { if (m_globalShortcut) { m_globalShortcut->setShortcut(key); } } void MainWindow::onTopChanged(bool newState) { bool visible = isVisible(); Qt::WindowFlags curFlags = windowFlags(); if (newState) setWindowFlags(Qt::WindowStaysOnTopHint); else { curFlags.operator ^= (Qt::WindowStaysOnTopHint); setWindowFlags(curFlags); } if (visible) setVisible(visible); }
[ [ [ 1, 267 ] ] ]
42b785e168230c1118098126bade45d97ebed3b3
be7eef50e21e11340134d150f78db8d6f5423e66
/B14/B14G.cpp
44ffec4fc3352bbd56a784c951f16ea24b334b0f
[]
no_license
Maciej-Poleski/Algorytmika
8023aef976c1087e25a4f9079de65769cf690ae3
3a3818f82738d9ea42aba24dea89e9280d504f00
refs/heads/master
2023-07-06T03:57:54.430947
2011-05-26T15:57:11
2011-05-26T15:57:11
395,015,968
0
0
null
null
null
null
UTF-8
C++
false
false
378
cpp
#include <iostream> #include <fstream> using namespace std; int main(int argc,char**argv) { ofstream wyj(argv[1]); int n=500; int m=n*(n-1)/2; int s=1; int t=n; wyj<<1<<endl<<n<<' '<<m<<' '<<s<<' '<<t<<endl; for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j) wyj<<i<<' '<<j<<endl; wyj.close(); return 0; }
[ [ [ 1, 19 ] ] ]
5bda5e6133e5543e9fad842752bf6067beca8982
da1aa824deb8d7d7416151601e662629765780f0
/Seg3D/src/StandAlone/Apps/Seg3D/Seg3DwxGuiUtils.h
e7fefdc6e464e49322123a5db014d0f3f3ac3738
[ "MIT" ]
permissive
viscenter/educe
69b5402782a4455af6d4009cb69f0d9a47042095
2dca76e7def3e0620896f155af64f6ba84163d77
refs/heads/master
2021-01-02T22:44:36.560170
2009-06-12T15:16:15
2009-06-12T15:16:15
5,413,435
1
0
null
null
null
null
UTF-8
C++
false
false
301
h
#include <stdio.h> #include <iostream> #include <wx/wx.h> #include <wx/glcanvas.h> //! converts wxString to std:string std::string wx2std(const wxString& input, wxMBConv* conv = NULL); //! converts std:string to wxString wxString std2wx(const std::string& input, wxMBConv* conv = NULL);
[ [ [ 1, 11 ] ] ]
77f6b065dca9aade7b7ed4f994b68d705e1ad78a
f304b2f54319a444f8798bca884139b785c63026
/trunk/CSupport.cpp
e2e132cfd94e54826b383f4d7aaa9312ddb2f5a6
[]
no_license
BackupTheBerlios/zcplusplus-svn
4387877a71405be331e78bec6d792da5f8fe6737
ef85b9e4a78a52618014f501c9c1400c9d4f4a42
refs/heads/master
2016-08-05T18:34:41.051270
2011-10-08T10:15:31
2011-10-08T10:15:31
40,805,219
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
668,652
cpp
// CSupport.cpp // support for C/C++ parsing // (C)2009-2011 Kenneth Boyd, license: MIT.txt #include "CSupport.hpp" #include "_CSupport3.hpp" #include "_CSupport4.hpp" #include "_CSupport1.hpp" #include "_CSupport2.hpp" #include "Zaimoni.STL/MetaRAM2.hpp" #include "Zaimoni.STL/lite_alg.hpp" #include "Zaimoni.STL/LexParse/LangConf.hpp" #include "Zaimoni.STL/Perl_localize.hpp" #include "Zaimoni.STL/search.hpp" #include "Zaimoni.STL/simple_lock.hpp" #include "AtomicString.h" #include "str_aux.h" #include "Trigraph.hpp" #include "Flat_UNI.hpp" #include "end_lc.hpp" #include "end_nl.hpp" #include "errors.hpp" #include "errcount.hpp" #include "CPUInfo.hpp" #include "ParseTree.hpp" #include "type_system.hpp" #include "type_algebra.hpp" #include "weak_token.hpp" #include "C_PPDecimalInteger.hpp" #include "C_PPHexInteger.hpp" #include "C_PPOctalInteger.hpp" #include "C_PPDecimalFloat.hpp" #include "C_PPHexFloat.hpp" #include "enum_type.hpp" #include "struct_type.hpp" #include "kleene_star.hpp" #include "cond_act.hpp" #include "CheckReturn.hpp" // handle function signature differences between z_cpp and other users #ifdef SIG_CONST_TYPES #error internal macro SIG_CONST_TYPES already defined #endif #ifdef ARG_TYPES #error internal macro ARG_TYPES already defined #endif #define SIG_CONST_TYPES ,const type_system& types #define ARG_TYPES ,types using namespace zaimoni; using virtual_machine::umaxint; const char* const list_hexadecimal_digits = C_HEXADECIMAL_DIGITS; LangConf* CLexer = NULL; LangConf* CPlusPlusLexer = NULL; static const virtual_machine::CPUInfo* target_machine = NULL; /* fundamental type */ /* all atomic charcters are preprocessing punctuation */ #define CPP_FLAG_CHAR_LITERAL Flag1_LC #define CPP_FLAG_STRING_LITERAL Flag2_LC #define CPP_FLAG_PP_OP_PUNC Flag3_LC #define CPP_FLAG_IDENTIFIER Flag4_LC #define CPP_FLAG_PP_NUMERAL Flag5_LC /* general traits */ // wide character/string literals use this #define CPP_WIDE_LITERAL Flag13_LC // simplify macro preprocessing #define CPP_FLAG_PAST_MACROS Flag14_LC #define C_WHITESPACE_NO_NEWLINE " \t\r\v\f" #define C_WHITESPACE "\n \t\r\v\f" #define C_ATOMIC_CHAR "()[]{};~,?" // beginning of multilingual support #define ERR_STR "error: " #define WARN_STR "warning: " // would have been in ParseTree.hpp, except that we don't have AtomicString.h there template<size_t i> void register_token(parse_tree& x) { BOOST_STATIC_ASSERT(STATIC_SIZE(x.index_tokens)>i); if (!x.own_index_token<i>()) return; const char* const tmp = register_substring(x.index_tokens[i].token.first,x.index_tokens[i].token.second); assert(tmp!=x.index_tokens[i].token.first); free(const_cast<char*>(x.index_tokens[i].token.first)); x.index_tokens[i].token.first = tmp; x.control_index_token<i>(false); } /* need for compiler implementation */ /* remember to review pragma definitions from GCC, MSVC++, etc. */ /* Another way to prevent a header file from being included more than once is with the `#pragma once' directive. If `#pragma once' is seen when scanning a header file, that file will never be read again, no matter what. `#pragma once' does not have the problems that `#import' does, but it is not recognized by all preprocessors, so you cannot rely on it in a portable program. #pragma GCC diagnostic kind option Modifies the disposition of a diagnostic. Note that not all diagnostics are modifiable; at the moment only warnings (normally controlled by `-W...') can be controlled, and not all of them. Use -fdiagnostics-show-option to determine which diagnostics are controllable and which option controls them. kind is `error' to treat this diagnostic as an error, `warning' to treat it like a warning (even if -Werror is in effect), or `ignored' if the diagnostic is to be ignored. option is a double quoted string which matches the command line option. #pragma GCC diagnostic warning "-Wformat" #pragma GCC diagnostic error "-Wformat" #pragma GCC diagnostic ignored "-Wformat" Note that these pragmas override any command line options. Also, while it is syntactically valid to put these pragmas anywhere in your sources, the only supported location for them is before any data or functions are defined. Doing otherwise may result in unpredictable results depending on how the optimizer manages your sources. If the same option is listed multiple times, the last one specified is the one that is in effect. This pragma is not intended to be a general purpose replacement for command line options, but for implementing strict control over project policies. Preprocessor #pragma GCC dependency #pragma GCC dependency allows you to check the relative dates of the current file and another file. If the other file is more recent than the current file, a warning is issued. This is useful if the current file is derived from the other file, and should be regenerated. The other file is searched for using the normal include search path. Optional trailing text can be used to give more information in the warning message. #pragma GCC dependency "parse.y" #pragma GCC dependency "/usr/include/time.h" rerun fixincludes #pragma GCC poison Sometimes, there is an identifier that you want to remove completely from your program, and make sure that it never creeps back in. To enforce this, you can poison the identifier with this pragma. #pragma GCC poison is followed by a list of identifiers to poison. If any of those identifiers appears anywhere in the source after the directive, it is a hard error. For example, #pragma GCC poison printf sprintf fprintf sprintf(some_string, "hello"); will produce an error. If a poisoned identifier appears as part of the expansion of a macro which was defined before the identifier was poisoned, it will not cause an error. This lets you poison an identifier without worrying about system headers defining macros that use it. For example, #define strrchr rindex #pragma GCC poison rindex strrchr(some_string, 'h'); will not produce an error. #pragma GCC system_header This pragma takes no arguments. It causes the rest of the code in the current file to be treated as if it came from a system header. C99 #pragma STDC FP_CONTRACT on-off-switch #pragma STDC FENV_ACCESS on-off-switch #pragma STDC CX_LIMITED_RANGE on-off-switch 2 The usual mathematical formulas for complex multiply, divide, and absolute value are problematic because of their treatment of infinities and because of undue overflow and underflow. The CX_LIMITED_RANGE pragma can be used to inform the implementation that (where the state is defined) the usual mathematical formulas are acceptable.165) The pragma can occur either outside external declarations or preceding all explicit declarations and statements inside a compound statement. When outside external declarations, the pragma takes effect from its occurrence until another CX_LIMITED_RANGE pragma is encountered, or until the end of the translation unit. When inside a compound statement, the pragma takes effect from its occurrence until another CX_LIMITED_RANGE pragma is encountered (including within a nested 165) The purpose of the pragma is to allow the implementation to use the formulas: (x + iy) * (u + iv) = (xu . yv) + i(yu + xv) (x + iy) / (u + iv) = [(xu + yv) + i(yu . xv)]/(u2 + v2) | x + iy | = *. .... x2 + y2 where the programmer can determine they are safe. The FENV_ACCESS pragma provides a means to inform the implementation when a program might access the floating-point environment to test floating-point status flags or run under non-default floating-point control modes.178) The pragma shall occur either outside external declarations or preceding all explicit declarations and statements inside a compound statement. When outside external declarations, the pragma takes effect from its occurrence until another FENV_ACCESS pragma is encountered, or until the end of the translation unit. When inside a compound statement, the pragma takes effect from its occurrence until another FENV_ACCESS pragma is encountered (including within a nested compound statement), or until the end of the compound statement; at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement. If this pragma is used in any other context, the behavior is undefined. If part of a program tests floating-point status flags, sets floating-point control modes, or runs under non-default mode settings, but was translated with the state for the FENV_ACCESS pragma ‘‘off’’, the behavior is undefined. The default state (‘‘on’’ or ‘‘off’’) for the pragma is implementation-defined. (When execution passes from a part of the program translated with FENV_ACCESS ‘‘off’’ to a part translated with FENV_ACCESS ‘‘on’’, the state of the floating-point status flags is unspecified and the floating-point control modes have their default settings.) 178) The purpose of the FENV_ACCESS pragma is to allow certain optimizations that could subvert flag tests and mode changes (e.g., global common subexpression elimination, code motion, and constant folding). In general, if the state of FENV_ACCESS is ‘‘off’’, the translator can assume that default modes are in effect and the flags are not tested. The FP_CONTRACT pragma can be used to allow (if the state is ‘‘on’’) or disallow (if the state is ‘‘off’’) the implementation to contract expressions (6.5). Each pragma can occur either outside external declarations or preceding all explicit declarations and statements inside a compound statement. When outside external declarations, the pragma takes effect from its occurrence until another FP_CONTRACT pragma is encountered, or until the end of the translation unit. When inside a compound statement, the pragma takes effect from its occurrence until another FP_CONTRACT pragma is encountered (including within a nested compound statement), or until the end of the compound statement; at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement. If this pragma is used in any other context, the behavior is undefined. The default state (‘‘on’’ or ‘‘off’’) for the pragma is implementation-defined. 198) The term underflow here is intended to encompass both ‘‘gradual underflow’’ as in IEC 60559 and also ‘‘flush-to-zero’’ underflow. */ bool IsUnaccentedAlphabeticChar(unsigned char x) { // FORMALLY CORRECT: Kenneth Boyd, 7/29/2001 return in_range<'A','Z'>(x) || in_range<'a','z'>(x); } bool IsAlphabeticChar(unsigned char x) { // FORMALLY CORRECT: Kenneth Boyd, 7/27/2001 // META: uses ASCII/default ISO web encoding implicitly // NOTE: lower-case eth (240) will pass as partial differential operator! if ( IsUnaccentedAlphabeticChar(x) // || (unsigned char)('\x8c')==x // OE ligature // || (unsigned char)('\x9c')==x // oe ligature // || (unsigned char)('\x9f')==x // Y umlaut || in_range<'\xc0','\xd6'>(x) // various accented characters || in_range<'\xd8','\xf6'>(x) // various accented characters || ((unsigned char)('\xf8')<=x /* && (unsigned char)('\xff')>=x */)) // various accented characters return true; return false; } bool C_IsLegalSourceChar(char x) { if ( IsAlphabeticChar(x) || in_range<'0','9'>(x) || strchr(C_WHITESPACE,x) || strchr(C_ATOMIC_CHAR,x) || strchr("_#<>%:.*+­/^&|!=\\",x)) return true; return false; } static bool C_IsPrintableChar(unsigned char x) { return in_range<' ','~'>(x); //! \todo fix; assumes ASCII } #if 0 identifier nondigit identifier nondigit identifier digit nondigit: one of universal-character-name _ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z digit: one of 0 1 2 3 4 5 6 7 8 9 #endif size_t LengthOfCIdentifier(const char* const x) { //! \todo should handle universal character names assert(x); const char* x2 = x; if (IsAlphabeticChar(*x2) || '_'==*x2) while(IsCIdentifierChar(*++x2)); return x2-x; } #if 0 pp-number digit . digit pp-number digit pp-number nondigit pp-number e sign pp-number E sign pp-number . #endif size_t LengthOfCPreprocessingNumber(const char* const x) { assert(x); size_t i = 0; // Length if (IsNumericChar(*x)) i = 1; else if ('.'==*x && IsNumericChar(x[1])) i = 2; if (0<i) do if ('.'==x[i] || IsNumericChar(x[i])) ++i; else if (IsAlphabeticChar(x[i])) { if ( ('+'==x[i+1] || '-'==x[i+1]) && ('E'==x[i] || 'e'==x[i] || 'P'==x[i] || 'p'==x[i])) i += 2; else i += 1; } else return i; while(1); return 0; } size_t LengthOfCCharLiteral(const char* const x) { // FORMALLY CORRECT: Kenneth Boyd, 10/17/2004 size_t Length; if ('\''==*x) Length = 1; else if ('L'==x[0] && '\''==x[1]) Length = 2; else return 0; const char* base = x+Length; const char* find_end = strpbrk(base,"\\'\n"); while(find_end) { Length = find_end-x+1; if ('\''==find_end[0]) return Length; if ('\n'==find_end[0]) return Length-1; if ('\0'==find_end[1]) return Length; base = find_end+2; find_end = !base[0] ? NULL : strpbrk(base,"\\'\n"); }; return strlen(x); } size_t LengthOfCStringLiteral(const char* const x) { // FORMALLY CORRECT: Kenneth Boyd, 10/17/2004 size_t Length; if ('"'==*x) Length = 1; else if ('L'==x[0] && '"'==x[1]) Length = 2; else return 0; const char* base = x+Length; const char* find_end = strpbrk(base,"\\\"\n"); while(find_end) { Length = find_end-x+1; if ('"'==find_end[0]) return Length; if ('\n'==find_end[0]) return Length-1; if ('\0'==find_end[1]) return Length; base = find_end+2; find_end = !base[0] ? NULL : strpbrk(base,"\\\"\n"); }; return strlen(x); } #if 0 preprocessing-op-or-punc: one of { } [ ] # ## ( ) <: :> <% %> %: %:%: ; : ... new delete ? :: . .* + - * / % ^ & | ~ ! = < > += -= *= /= %= ^= &= |= << >> >>= <<= == != <= >= && || ++ -- , ->* -> and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq #endif #define ATOMIC_PREPROC_PUNC "()[]{};~,?" static const POD_triple<const char*,size_t,unsigned int> valid_pure_preprocessing_op_punc[] = { DICT2_STRUCT("{",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("}",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("[",0), DICT2_STRUCT("]",0), DICT2_STRUCT("(",0), DICT2_STRUCT(")",0), DICT2_STRUCT(";",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("~",0), DICT2_STRUCT(",",C_DISALLOW_CONSTANT_EXPR), // double-check this DICT2_STRUCT("?",0), // atomic DICT2_STRUCT(".",C_DISALLOW_IF_ELIF_CONTROL), DICT2_STRUCT("&",0), DICT2_STRUCT("+",0), DICT2_STRUCT("-",0), DICT2_STRUCT("*",0), DICT2_STRUCT("/",0), DICT2_STRUCT("%",0), DICT2_STRUCT("!",0), DICT2_STRUCT(":",0), DICT2_STRUCT("=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("<",0), DICT2_STRUCT(">",0), DICT2_STRUCT("^",0), DICT2_STRUCT("|",0), DICT2_STRUCT("#",C_DISALLOW_POSTPROCESSED_SOURCE), DICT2_STRUCT("##",C_DISALLOW_POSTPROCESSED_SOURCE), DICT2_STRUCT("->",C_DISALLOW_IF_ELIF_CONTROL), DICT2_STRUCT("++",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("--",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("<:",0), DICT2_STRUCT(":>",0), DICT2_STRUCT("<%",C_DISALLOW_CONSTANT_EXPR), // } DICT2_STRUCT("%>",C_DISALLOW_CONSTANT_EXPR), // { DICT2_STRUCT("%:",C_DISALLOW_POSTPROCESSED_SOURCE), // # DICT2_STRUCT("+=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("-=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("*=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("/=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("%=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("&=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("|=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("^=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("<<",0), DICT2_STRUCT(">>",0), DICT2_STRUCT("==",0), DICT2_STRUCT("!=",0), DICT2_STRUCT("<=",0), DICT2_STRUCT(">=",0), DICT2_STRUCT("&&",0), DICT2_STRUCT("||",0), DICT2_STRUCT("...",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("<<=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT(">>=",C_DISALLOW_CONSTANT_EXPR), DICT2_STRUCT("%:%:",C_DISALLOW_POSTPROCESSED_SOURCE), // ## // C99 DICT2_STRUCT("::",C_DISALLOW_IF_ELIF_CONTROL), DICT2_STRUCT(".*",C_DISALLOW_IF_ELIF_CONTROL), DICT2_STRUCT("->*",C_DISALLOW_IF_ELIF_CONTROL) // C++0x }; #define CPP_PREPROC_OP_STRICT_UB STATIC_SIZE(valid_pure_preprocessing_op_punc) #define C_PREPROC_OP_STRICT_UB (CPP_PREPROC_OP_STRICT_UB-3) #define NONATOMIC_PREPROC_OP_LB 10 BOOST_STATIC_ASSERT(NONATOMIC_PREPROC_OP_LB<C_PREPROC_OP_STRICT_UB); static const POD_pair<const char*,size_t> valid_keyword[] = { DICT_STRUCT("__asm"), // reserved to the implementation, so OK to make a keyword for C only DICT_STRUCT("_Static_assert"), // C1X keywords not in C++0X DICT_STRUCT("_Thread_local"), DICT_STRUCT("restrict"), // C99 keywords not in C++98 DICT_STRUCT("_Bool"), DICT_STRUCT("_Complex"), DICT_STRUCT("_Imaginary"), DICT_STRUCT("auto"), // joint keywords in C99 and C++98 DICT_STRUCT("break"), DICT_STRUCT("case"), DICT_STRUCT("char"), DICT_STRUCT("const"), DICT_STRUCT("continue"), DICT_STRUCT("default"), DICT_STRUCT("do"), DICT_STRUCT("double"), DICT_STRUCT("else"), DICT_STRUCT("enum"), DICT_STRUCT("extern"), DICT_STRUCT("float"), DICT_STRUCT("for"), DICT_STRUCT("goto"), DICT_STRUCT("if"), DICT_STRUCT("inline"), DICT_STRUCT("int"), DICT_STRUCT("long"), DICT_STRUCT("register"), DICT_STRUCT("return"), DICT_STRUCT("short"), DICT_STRUCT("signed"), DICT_STRUCT("sizeof"), DICT_STRUCT("static"), DICT_STRUCT("struct"), DICT_STRUCT("switch"), DICT_STRUCT("typedef"), DICT_STRUCT("union"), DICT_STRUCT("unsigned"), DICT_STRUCT("void"), DICT_STRUCT("volatile"), DICT_STRUCT("while"), // C99 keywords DICT_STRUCT("asm"), // common non-conforming extension to C99, C++98 keyword DICT_STRUCT("bool"), // start C++98 keywords DICT_STRUCT("catch"), DICT_STRUCT("class"), DICT_STRUCT("const_cast"), DICT_STRUCT("delete"), DICT_STRUCT("dynamic_cast"), DICT_STRUCT("explicit"), DICT_STRUCT("false"), DICT_STRUCT("friend"), DICT_STRUCT("mutable"), DICT_STRUCT("namespace"), DICT_STRUCT("new"), DICT_STRUCT("operator"), DICT_STRUCT("private"), DICT_STRUCT("protected"), DICT_STRUCT("public"), DICT_STRUCT("reinterpret_cast"), DICT_STRUCT("static_cast"), DICT_STRUCT("template"), DICT_STRUCT("this"), DICT_STRUCT("throw"), DICT_STRUCT("true"), DICT_STRUCT("try"), DICT_STRUCT("typeid"), DICT_STRUCT("typename"), DICT_STRUCT("using"), DICT_STRUCT("virtual"), DICT_STRUCT("wchar_t"), // end C++98 keywords DICT_STRUCT("and"), // C++98 alternate-operators DICT_STRUCT("and_eq"), DICT_STRUCT("bitand"), DICT_STRUCT("bitor"), DICT_STRUCT("compl"), DICT_STRUCT("not"), DICT_STRUCT("not_eq"), DICT_STRUCT("or"), DICT_STRUCT("or_eq"), DICT_STRUCT("xor"), DICT_STRUCT("xor_eq"), // end C++98 alternate-operators DICT_STRUCT("constexpr"), // C++0X keywords we pay attention to DICT_STRUCT("noexcept"), // C++0X n3090 DICT_STRUCT("static_assert"), DICT_STRUCT("thread_local") }; // think about C++0x keywords later. #define C_KEYWORD_NONSTRICT_LB 0 #define CPP_KEYWORD_NONSTRICT_LB 7 #define C_KEYWORD_STRICT_UB 40 #define CPP_KEYWORD_STRICT_UB STATIC_SIZE(valid_keyword) BOOST_STATIC_ASSERT(C_KEYWORD_NONSTRICT_LB<C_KEYWORD_STRICT_UB); BOOST_STATIC_ASSERT(CPP_KEYWORD_NONSTRICT_LB<C_KEYWORD_STRICT_UB); static const char* C99_echo_reserved_keyword(const char* x,size_t x_len) { assert(x); assert(x_len<=strlen(x)); size_t i = C_KEYWORD_STRICT_UB-C_KEYWORD_NONSTRICT_LB; do if (x_len==valid_keyword[C_KEYWORD_NONSTRICT_LB + --i].second && !strncmp(valid_keyword[C_KEYWORD_NONSTRICT_LB + i].first,x,x_len)) return valid_keyword[C_KEYWORD_NONSTRICT_LB + i].first; while(0<i); return NULL; } static const char* CPP_echo_reserved_keyword(const char* x,size_t x_len) { assert(x); assert(x_len<=strlen(x)); size_t i = CPP_KEYWORD_STRICT_UB-CPP_KEYWORD_NONSTRICT_LB; do if (x_len==valid_keyword[CPP_KEYWORD_NONSTRICT_LB + --i].second && !strncmp(valid_keyword[CPP_KEYWORD_NONSTRICT_LB + i].first,x,x_len)) return valid_keyword[CPP_KEYWORD_NONSTRICT_LB + i].first; while(0<i); return NULL; } static const char* C99_echo_reserved_symbol(const char* x,size_t x_len) { assert(x); assert(x_len<=strlen(x)); size_t i = C_PREPROC_OP_STRICT_UB; do if (x_len==valid_pure_preprocessing_op_punc[--i].second && !strncmp(valid_pure_preprocessing_op_punc[i].first,x,x_len)) return valid_pure_preprocessing_op_punc[i].first; while(0<i); return NULL; } static const char* CPP_echo_reserved_symbol(const char* x,size_t x_len) { assert(x); assert(x_len<=strlen(x)); size_t i = CPP_PREPROC_OP_STRICT_UB; do if (x_len==valid_pure_preprocessing_op_punc[--i].second && !strncmp(valid_pure_preprocessing_op_punc[i].first,x,x_len)) return valid_pure_preprocessing_op_punc[i].first; while(0<i); return NULL; } namespace C_TYPE { enum hard_type_indexes { VOID = 1, NOT_VOID, // needs to be omnicompatible early on BOOL, CHAR, SCHAR, UCHAR, SHRT, USHRT, INT, UINT, LONG, ULONG, LLONG, ULLONG, INTEGERLIKE, FLOAT, DOUBLE, LDOUBLE, FLOAT__COMPLEX, DOUBLE__COMPLEX, LDOUBLE__COMPLEX, WCHAR_T, // C++-specific TYPEINFO // C++-specific }; } static inline virtual_machine::std_int_enum machine_type_from_type_index(size_t base_type_index) { assert(C_TYPE::INT<=base_type_index && C_TYPE::ULLONG>=base_type_index); return (virtual_machine::std_int_enum)((base_type_index-C_TYPE::INT)/2+virtual_machine::std_int_int); } static inline size_t unsigned_type_from_machine_type(virtual_machine::std_int_enum x) { return C_TYPE::SCHAR+2*(x-virtual_machine::std_int_char)+1; } static bool is_innate_definite_type(size_t base_type_index) { return C_TYPE::BOOL<=base_type_index && C_TYPE::LDOUBLE__COMPLEX>=base_type_index; } static bool converts_to_integerlike(size_t base_type_index SIG_CONST_TYPES) { //! \todo handle cast operator overloading if (C_TYPE::BOOL<=base_type_index && C_TYPE::INTEGERLIKE>=base_type_index) return true; return types.get_enum_def(base_type_index); } static bool converts_to_integerlike(const type_spec& type_code SIG_CONST_TYPES) { //! \todo handle cast operator overloading if (0<type_code.pointer_power) return false; // pointers do not have a standard conversion to integers return converts_to_integerlike(type_code.base_type_index ARG_TYPES); } static bool converts_to_integer(const type_spec& type_code SIG_CONST_TYPES) { //! \todo handle cast operator overloading if (0<type_code.pointer_power) return false; // pointers do not have a standard conversion to integers if (C_TYPE::BOOL<=type_code.base_type_index && C_TYPE::INTEGERLIKE>type_code.base_type_index) return true; return types.get_enum_def(type_code.base_type_index); } static bool converts_to_reallike(size_t base_type_index SIG_CONST_TYPES) { //! \todo handle cast operator overloading if (C_TYPE::BOOL<=base_type_index && C_TYPE::LDOUBLE>=base_type_index) return true; return types.get_enum_def(base_type_index); } static bool converts_to_arithmeticlike(size_t base_type_index SIG_CONST_TYPES) { //! \todo handle cast operator overloading if (C_TYPE::BOOL<=base_type_index && C_TYPE::LDOUBLE__COMPLEX>=base_type_index) return true; return types.get_enum_def(base_type_index); } static bool converts_to_arithmeticlike(const type_spec& type_code SIG_CONST_TYPES) { //! \todo handle cast operator overloading if (0<type_code.pointer_power) return false; // pointers do not have a standard conversion to integers/floats/complex return converts_to_arithmeticlike(type_code.base_type_index ARG_TYPES); } static bool converts_to_bool(const type_spec& type_code SIG_CONST_TYPES) { if (0<type_code.pointer_power) return true; // pointers are comparable to NULL if (converts_to_arithmeticlike(type_code.base_type_index ARG_TYPES)) return true; // arithmetic types are comparable to zero, and include bool // C++: run through type conversion weirdness return false; } // the integer promotions rely on low-level weirdness, so test that here static size_t arithmetic_reconcile(size_t base_type_index1, size_t base_type_index2 SIG_CONST_TYPES) { { const enum_def* tmp = types.get_enum_def(base_type_index1); if (tmp) base_type_index1 = tmp->represent_as; tmp = types.get_enum_def(base_type_index2); if (tmp) base_type_index2 = tmp->represent_as; } assert(is_innate_definite_type(base_type_index1)); assert(is_innate_definite_type(base_type_index2)); // identity, do not do anything if (base_type_index1==base_type_index2) return base_type_index1; //! \todo --do-what-i-mean will try to value-preserve integers when promoting to a float type (use global target_machine) // long double _Complex if (C_TYPE::LDOUBLE__COMPLEX==base_type_index1) return C_TYPE::LDOUBLE__COMPLEX; if (C_TYPE::LDOUBLE__COMPLEX==base_type_index2) return C_TYPE::LDOUBLE__COMPLEX; if (C_TYPE::LDOUBLE==base_type_index1 && C_TYPE::FLOAT__COMPLEX<=base_type_index2) return C_TYPE::LDOUBLE__COMPLEX; if (C_TYPE::LDOUBLE==base_type_index2 && C_TYPE::FLOAT__COMPLEX<=base_type_index1) return C_TYPE::LDOUBLE__COMPLEX; // double _Complex if (C_TYPE::DOUBLE__COMPLEX==base_type_index1) return C_TYPE::DOUBLE__COMPLEX; if (C_TYPE::DOUBLE__COMPLEX==base_type_index2) return C_TYPE::DOUBLE__COMPLEX; if (C_TYPE::DOUBLE==base_type_index1 && C_TYPE::FLOAT__COMPLEX<=base_type_index2) return C_TYPE::DOUBLE__COMPLEX; if (C_TYPE::DOUBLE==base_type_index2 && C_TYPE::FLOAT__COMPLEX<=base_type_index1) return C_TYPE::DOUBLE__COMPLEX; // float _Complex if (C_TYPE::FLOAT__COMPLEX==base_type_index1) return C_TYPE::FLOAT__COMPLEX; if (C_TYPE::FLOAT__COMPLEX==base_type_index2) return C_TYPE::FLOAT__COMPLEX; // long double if (C_TYPE::LDOUBLE==base_type_index1) return C_TYPE::LDOUBLE; if (C_TYPE::LDOUBLE==base_type_index2) return C_TYPE::LDOUBLE; // double if (C_TYPE::DOUBLE==base_type_index1) return C_TYPE::DOUBLE; if (C_TYPE::DOUBLE==base_type_index2) return C_TYPE::DOUBLE; // float if (C_TYPE::FLOAT==base_type_index1) return C_TYPE::FLOAT; if (C_TYPE::FLOAT==base_type_index2) return C_TYPE::FLOAT; // bool fits in any integer type if (C_TYPE::BOOL==base_type_index1) return base_type_index2; if (C_TYPE::BOOL==base_type_index2) return base_type_index1; // any integer type fits in integerlike if (C_TYPE::INTEGERLIKE==base_type_index1) return C_TYPE::INTEGERLIKE; if (C_TYPE::INTEGERLIKE==base_type_index2) return C_TYPE::INTEGERLIKE; // handle indeterminacy of char now BOOST_STATIC_ASSERT(C_TYPE::SCHAR+1==C_TYPE::UCHAR); if (C_TYPE::CHAR==base_type_index1) { base_type_index1 = C_TYPE::SCHAR + bool_options[boolopt::char_is_unsigned]; // identity, do not do anything if (base_type_index1==base_type_index2) return base_type_index1; } if (C_TYPE::CHAR==base_type_index2) { base_type_index2 = C_TYPE::SCHAR + bool_options[boolopt::char_is_unsigned]; // identity, do not do anything if (base_type_index1==base_type_index2) return base_type_index1; } // types of the same sign should have a difference divisible by 2 BOOST_STATIC_ASSERT(0==(C_TYPE::SHRT-C_TYPE::SCHAR)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::INT-C_TYPE::SHRT)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::LONG-C_TYPE::INT)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::LLONG-C_TYPE::LONG)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::USHRT-C_TYPE::UCHAR)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::UINT-C_TYPE::USHRT)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::ULONG-C_TYPE::UINT)%2); BOOST_STATIC_ASSERT(0==(C_TYPE::ULLONG-C_TYPE::ULONG)%2); if (0==(base_type_index2-base_type_index1)%2) return (base_type_index1<base_type_index1) ? base_type_index1 : base_type_index1; // types of the same rank should calculate as having the same rank BOOST_STATIC_ASSERT((C_TYPE::SCHAR-1)/2==(C_TYPE::UCHAR-1)/2); BOOST_STATIC_ASSERT((C_TYPE::SHRT-1)/2==(C_TYPE::USHRT-1)/2); BOOST_STATIC_ASSERT((C_TYPE::INT-1)/2==(C_TYPE::UINT-1)/2); BOOST_STATIC_ASSERT((C_TYPE::LONG-1)/2==(C_TYPE::ULONG-1)/2); BOOST_STATIC_ASSERT((C_TYPE::LLONG-1)/2==(C_TYPE::ULLONG-1)/2); // signed types should be odd, unsigned types should be even BOOST_STATIC_ASSERT(0!=C_TYPE::SCHAR%2); BOOST_STATIC_ASSERT(0==C_TYPE::UCHAR%2); BOOST_STATIC_ASSERT(0!=C_TYPE::SHRT%2); BOOST_STATIC_ASSERT(0==C_TYPE::USHRT%2); BOOST_STATIC_ASSERT(0!=C_TYPE::INT%2); BOOST_STATIC_ASSERT(0==C_TYPE::UINT%2); BOOST_STATIC_ASSERT(0!=C_TYPE::LONG%2); BOOST_STATIC_ASSERT(0==C_TYPE::ULONG%2); BOOST_STATIC_ASSERT(0!=C_TYPE::LLONG%2); BOOST_STATIC_ASSERT(0==C_TYPE::ULLONG%2); //! \todo --do-what-i-mean is a bit more careful about signed/unsigned of the same rank; it promotes an equal-rank mismatch to the next larger signed integer type if (0==base_type_index1%2) { // first is unsigned if ((base_type_index1-1)/2>=(base_type_index2-1)/2) return base_type_index1; else return base_type_index2; } else{ // second is unsigned if ((base_type_index1-1)/2<=(base_type_index2-1)/2) return base_type_index2; else return base_type_index1; } } static size_t default_promote_type(size_t i SIG_CONST_TYPES) { { const enum_def* tmp = types.get_enum_def(i); if (tmp) i = tmp->represent_as; } switch(i) { case C_TYPE::BOOL: return C_TYPE::INT; case C_TYPE::SCHAR: return C_TYPE::INT; case C_TYPE::SHRT: return C_TYPE::INT; case C_TYPE::UCHAR: return (1<target_machine->C_sizeof_int()) ? C_TYPE::INT : C_TYPE::UINT; case C_TYPE::CHAR: return (1<target_machine->C_sizeof_int() || target_machine->char_is_signed_char()) ? C_TYPE::INT : C_TYPE::UINT; case C_TYPE::USHRT: return (target_machine->C_sizeof_short()<target_machine->C_sizeof_int()) ? C_TYPE::INT : C_TYPE::UINT; case C_TYPE::FLOAT: return C_TYPE::DOUBLE; }; return i; } static POD_pair<size_t,bool> default_promotion_is_integerlike(const type_spec& type_code SIG_CONST_TYPES) { // uses NRVO POD_pair<size_t,bool> tmp = {0,false}; if (0==type_code.pointer_power) // pointers do not have a standard conversion to integers { tmp.first = default_promote_type(type_code.base_type_index ARG_TYPES); tmp.second = (C_TYPE::BOOL<=tmp.first && C_TYPE::INTEGERLIKE>=tmp.first); } return tmp; } static POD_pair<size_t,bool> default_promotion_is_arithmeticlike(const type_spec& type_code SIG_CONST_TYPES) { // uses NRVO POD_pair<size_t,bool> tmp = {0,false}; if (0==type_code.pointer_power) // pointers do not have a standard conversion to integers { tmp.first = default_promote_type(type_code.base_type_index ARG_TYPES); tmp.second = (C_TYPE::BOOL<=tmp.first && C_TYPE::LDOUBLE__COMPLEX>=tmp.first); } return tmp; } // auxilliary structure to aggregate useful information for type promotions // this will malfunction badly for anything other than an integer type class promote_aux : public virtual_machine::promotion_info { public: promote_aux(size_t base_type_index SIG_CONST_TYPES) { const size_t promoted_type = default_promote_type(base_type_index ARG_TYPES); machine_type = machine_type_from_type_index(promoted_type); bitcount = target_machine->C_bit(machine_type); is_signed = !((promoted_type-C_TYPE::INT)%2); }; }; static const char* literal_suffix(size_t i) { switch(i) { case C_TYPE::UINT: return "U"; case C_TYPE::LDOUBLE: case C_TYPE::LONG: return "L"; case C_TYPE::ULONG: return "UL"; case C_TYPE::LLONG: return "LL"; case C_TYPE::ULLONG: return "ULL"; case C_TYPE::FLOAT: return "F"; } return NULL; } static lex_flags literal_flags(size_t i) { switch(i) { case C_TYPE::CHAR: return C_TESTFLAG_CHAR_LITERAL; case C_TYPE::INT: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER; case C_TYPE::UINT: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_U; case C_TYPE::LONG: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_L; case C_TYPE::ULONG: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_U | C_TESTFLAG_L; case C_TYPE::LLONG: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_LL; case C_TYPE::ULLONG: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_U | C_TESTFLAG_LL; case C_TYPE::FLOAT: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_FLOAT | C_TESTFLAG_F; case C_TYPE::DOUBLE: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_FLOAT; case C_TYPE::LDOUBLE: return C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_FLOAT | C_TESTFLAG_L; } return 0; } /* reference arrays for instantiating type_system class with */ /* typenames starting with $ are internal, as $ is not a legal C-source character */ const POD_pair<const char* const,size_t> C_atomic_types[] = { DICT_STRUCT("void"), DICT_STRUCT("$not-void"), DICT_STRUCT("_Bool"), DICT_STRUCT("char"), DICT_STRUCT("signed char"), DICT_STRUCT("unsigned char"), DICT_STRUCT("short"), DICT_STRUCT("unsigned short"), DICT_STRUCT("int"), DICT_STRUCT("unsigned"), DICT_STRUCT("long"), DICT_STRUCT("unsigned long"), DICT_STRUCT("long long"), DICT_STRUCT("unsigned long long"), DICT_STRUCT("$integer-like"), DICT_STRUCT("float"), DICT_STRUCT("double"), DICT_STRUCT("long double"), DICT_STRUCT("float _Complex"), /* start C++ extension support: C99 _Complex in C++ (we can do this as _Complex is reserved to the implementation) */ DICT_STRUCT("double _Complex"), DICT_STRUCT("long double _Complex") }; const POD_pair<const char* const,size_t> CPP_atomic_types[] = { DICT_STRUCT("void"), DICT_STRUCT("$not-void"), DICT_STRUCT("bool"), DICT_STRUCT("char"), DICT_STRUCT("signed char"), DICT_STRUCT("unsigned char"), DICT_STRUCT("short"), DICT_STRUCT("unsigned short"), DICT_STRUCT("int"), DICT_STRUCT("unsigned"), DICT_STRUCT("long"), DICT_STRUCT("unsigned long"), DICT_STRUCT("long long"), DICT_STRUCT("unsigned long long"), DICT_STRUCT("$integer-like"), DICT_STRUCT("float"), DICT_STRUCT("double"), DICT_STRUCT("long double"), DICT_STRUCT("float _Complex"), /* start C++ extension support: C99 _Complex in C++ (we can do this as _Complex is reserved to the implementation) */ DICT_STRUCT("double _Complex"), DICT_STRUCT("long double _Complex"), DICT_STRUCT("wchar_t"), // C++-specific DICT_STRUCT("std::typeinfo") // C++-specific }; BOOST_STATIC_ASSERT(STATIC_SIZE(C_atomic_types)==C_TYPE_MAX); BOOST_STATIC_ASSERT(STATIC_SIZE(CPP_atomic_types)==CPP_TYPE_MAX); static const POD_pair<const char*,size_t> C99_decl_specifiers[] = { DICT_STRUCT("typedef"), DICT_STRUCT("const"), DICT_STRUCT("volatile"), DICT_STRUCT("restrict"), DICT_STRUCT("register"), DICT_STRUCT("static"), DICT_STRUCT("extern"), DICT_STRUCT("inline"), DICT_STRUCT("auto"), DICT_STRUCT("_Thread_local") // C1X, but in reserved class of identifiers }; // we implement C++0X, not C++98. auto as storage specifier is pretty much a waste of source code anyway. // may have to invoke weirdness to deal with C headers that use restrict (and link with C standard library functions!) static const POD_pair<const char*,size_t> CPP0X_decl_specifiers[] = { DICT_STRUCT("typedef"), DICT_STRUCT("const"), DICT_STRUCT("volatile"), DICT_STRUCT("mutable"), DICT_STRUCT("register"), DICT_STRUCT("static"), DICT_STRUCT("extern"), DICT_STRUCT("inline"), DICT_STRUCT("constexpr"), DICT_STRUCT("thread_local"), DICT_STRUCT("virtual"), DICT_STRUCT("explicit"), DICT_STRUCT("friend") }; #define C99_CPP0X_DECLSPEC_TYPEDEF (1ULL<<0) #define C99_CPP0X_DECLSPEC_CONST (1ULL<<1) #define C99_CPP0X_DECLSPEC_VOLATILE (1ULL<<2) #define C99_CPP0X_DECLSPEC_REGISTER (1ULL<<4) #define C99_CPP0X_DECLSPEC_STATIC (1ULL<<5) #define C99_CPP0X_DECLSPEC_EXTERN (1ULL<<6) #define C99_CPP0X_DECLSPEC_INLINE (1ULL<<7) #define C99_CPP0X_DECLSPEC_THREAD_LOCAL (1ULL<<9) #define C99_DECLSPEC_AUTO (1ULL<<8) #define CPP_DECLSPEC_MUTABLE (1ULL<<3) #define CPP_DECLSPEC_VIRTUAL (1ULL<<10) #define CPP_DECLSPEC_EXPLICIT (1ULL<<11) #define CPP_DECLSPEC_FRIEND (1ULL<<12) BOOST_STATIC_ASSERT(C99_CPP0X_DECLSPEC_CONST==type_spec::_const); BOOST_STATIC_ASSERT(C99_CPP0X_DECLSPEC_VOLATILE==type_spec::_volatile); // todo: rewrite of decl-specifiers that actually can handle the reordering requirements. // decl-specifier-seq is mostly context-free, so first-pass should be in // the context-free section, if not integrated preprocessor static const POD_pair<const char*,size_t> C99_decl_specifier_list[] = { DICT_STRUCT("typedef"), DICT_STRUCT("const"), DICT_STRUCT("volatile"), DICT_STRUCT("restrict"), // C99-specific DICT_STRUCT("register"), DICT_STRUCT("static"), DICT_STRUCT("extern"), DICT_STRUCT("inline"), DICT_STRUCT("auto"), DICT_STRUCT("void"), DICT_STRUCT("char"), DICT_STRUCT("short"), DICT_STRUCT("int"), DICT_STRUCT("long"), DICT_STRUCT("float"), DICT_STRUCT("double"), DICT_STRUCT("signed"), DICT_STRUCT("unsigned"), DICT_STRUCT("_Complex"), DICT_STRUCT("_Bool"), DICT_STRUCT("_Thread_local"), // C1X, actually }; // we implement C++0X, not C++98. auto as storage specifier is pretty much a waste of source code anyway. // may have to invoke weirdness to deal with C headers that use restrict (and link with C standard library functions!) // we don't handle char16_t and char32_t yet static const POD_pair<const char*,size_t> CPP0X_decl_specifier_list[] = { DICT_STRUCT("typedef"), DICT_STRUCT("const"), DICT_STRUCT("volatile"), DICT_STRUCT("wchar_t"), // C++-specific DICT_STRUCT("register"), DICT_STRUCT("static"), DICT_STRUCT("extern"), DICT_STRUCT("inline"), DICT_STRUCT("auto"), // storage-class in C, type-specifier in C++ DICT_STRUCT("void"), DICT_STRUCT("char"), DICT_STRUCT("short"), DICT_STRUCT("int"), DICT_STRUCT("long"), DICT_STRUCT("float"), DICT_STRUCT("double"), DICT_STRUCT("signed"), DICT_STRUCT("unsigned"), DICT_STRUCT("_Complex"), // extension DICT_STRUCT("bool"), // _Bool in C DICT_STRUCT("thread_local"), // C1X _Thread_Local DICT_STRUCT("constexpr"), DICT_STRUCT("mutable"), DICT_STRUCT("virtual"), DICT_STRUCT("explicit"), DICT_STRUCT("friend") }; #define C99_CPP_TYPEDEF_IDX 0 #define C99_CPP_CONST_IDX 1 #define C99_CPP_VOLATILE_IDX 2 #define C99_RESTRICT_IDX 3 #define C99_CPP_REGISTER_IDX 4 #define C99_CPP_STATIC_IDX 5 #define C99_CPP_EXTERN_IDX 6 #define C99_CPP_AUTO_IDX 8 #define C99_CPP_CHAR_IDX 10 #define C99_CPP_SHORT_IDX 11 #define C99_CPP_INT_IDX 12 #define C99_CPP_LONG_IDX 13 #define C99_CPP_FLOAT_IDX 14 #define C99_CPP_DOUBLE_IDX 15 #define C99_CPP_SIGNED_IDX 16 #define C99_CPP_UNSIGNED_IDX 17 #define C99_CPP_COMPLEX_IDX 18 #define C1X_CPP0X_THREAD_LOCAL_IDX 20 #define CPP_MUTABLE_IDX 22 size_t C99_invariant_decl_specifier(const char* const x) { const errr i = linear_find(x,C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list)); if (STATIC_SIZE(C99_decl_specifier_list)>i) return i; return SIZE_MAX; } size_t CPP0X_invariant_decl_specifier(const char* const x) { const errr i = linear_find(x,CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list)); if (STATIC_SIZE(CPP0X_decl_specifier_list)>i) return i; return SIZE_MAX; } const size_t C_int_priority[] = { C_TYPE::INT, C_TYPE::UINT, C_TYPE::LONG, C_TYPE::ULONG, C_TYPE::LLONG, C_TYPE::ULLONG, C_TYPE::INTEGERLIKE }; BOOST_STATIC_ASSERT(C_INT_PRIORITY_SIZE==STATIC_SIZE(C_int_priority)); // this only has to work on full strings, not embedded substrings const char* const system_headers[] = { "assert.h", // C99 headers "complex.h", "ctype.h", "errno.h", "float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", "math.h", "setjmp.h", "signal.h", "stdarg.h", "stdbool.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h", "string.h", "tgmath.h", "time.h", "wchar.h", "wctype.h", // end C99 headers "cassert", // C++98 C-functionality headers "cctype", "cerrno", "cfloat", "ciso646", "climits", "clocale", "cmath", "csetjmp", "csignal", "cstdarg", "cstddef", "cstdio", "cstdlib", "cstring", "ctime", "cwchar", "cwctype", // end C++98 C-functionality headers "algorithm", // C++98 headers proper "bitset", "complex", "deque", "exception", "fstream", "functional", "iomanip", "ios", "iosfwd", "iostream", "istream", "iterator", "limits", "list", "locale", "map", "memory", "new", "numeric", "ostream", "queue", "set", "sstream", "stack", "stdexcept", "streambuf", "string", "typeinfo", "utility", "valarray", "vector" // end C++98 headers proper }; #define CPP_SYS_HEADER_STRICT_UB STATIC_SIZE(system_headers) #define C_SYS_HEADER_STRICT_UB 23 static size_t LengthOfCSystemHeader(const char* src) { const errr i = linear_find(src,system_headers,C_SYS_HEADER_STRICT_UB); if (0<=i) return strlen(system_headers[i]); return 0; } static size_t LengthOfCPPSystemHeader(const char* src) { const errr i = linear_find(src,system_headers,CPP_SYS_HEADER_STRICT_UB); if (0<=i) return strlen(system_headers[i]); return 0; } /* XXX this may belong with weak_token XXX */ static void message_header(const weak_token& src) { assert(src.src_filename && *src.src_filename); message_header(src.src_filename,src.logical_line.first); } /* XXX this may belong with enum_type XXX */ static void message_header(const enum_def& src) { assert(src.filename() && *src.filename()); message_header(src.filename(),src.loc().first); } /* XXX this may belong with C_union_struct_def XXX */ static void message_header(const union_struct_decl& src) { assert(src.filename() && *src.filename()); message_header(src.filename(),src.loc().first); } static void message_header(const zaimoni::POD_pair<const char*,zaimoni::POD_pair<size_t,size_t> >& src) { assert(src.first && *src.first); message_header(src.first,src.second.first); } // balanced character count static POD_pair<size_t,size_t> _balanced_character_count(const weak_token* tokenlist,size_t tokenlist_len,const char l_match,const char r_match) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = {0,0}; const weak_token* const iter_end = tokenlist+tokenlist_len; const weak_token* iter = tokenlist; do if (1==iter->token.second) { if (l_match==iter->token.first[0]) ++depth.first; else if (r_match==iter->token.first[0]) ++depth.second; } while(++iter!=iter_end); return depth; } template<char l_match,char r_match> inline static POD_pair<size_t,size_t> balanced_character_count(const weak_token* tokenlist,size_t tokenlist_len) { assert(tokenlist); assert(0<tokenlist_len); return _balanced_character_count(tokenlist,tokenlist_len,l_match,r_match); } template<> POD_pair<size_t,size_t> balanced_character_count<'[',']'>(const weak_token* tokenlist,size_t tokenlist_len) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = {0, 0}; const weak_token* const iter_end = tokenlist+tokenlist_len; const weak_token* iter = tokenlist; do if (detect_C_left_bracket_op(iter->token.first,iter->token.second)) ++depth.first; else if (detect_C_right_bracket_op(iter->token.first,iter->token.second)) ++depth.second; while(++iter!=iter_end); return depth; } template<> POD_pair<size_t,size_t> balanced_character_count<'{','}'>(const weak_token* tokenlist,size_t tokenlist_len) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = {0, 0}; const weak_token* const iter_end = tokenlist+tokenlist_len; const weak_token* iter = tokenlist; do if (detect_C_left_brace_op(iter->token.first,iter->token.second)) ++depth.first; else if (detect_C_right_brace_op(iter->token.first,iter->token.second)) ++depth.second; while(++iter!=iter_end); return depth; } static POD_pair<size_t,size_t> _balanced_character_count(const parse_tree* tokenlist,size_t tokenlist_len,const char l_match,const char r_match) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = {0, 0}; const parse_tree* const iter_end = tokenlist+tokenlist_len; const parse_tree* iter = tokenlist; do if (1==iter->index_tokens[0].token.second && !iter->index_tokens[1].token.first) { if (l_match==iter->index_tokens[0].token.first[0]) ++depth.first; else if (r_match==iter->index_tokens[0].token.first[0]) ++depth.second; } while(++iter!=iter_end); return depth; } template<char l_match,char r_match> inline static POD_pair<size_t,size_t> balanced_character_count(const parse_tree* tokenlist,size_t tokenlist_len) { assert(tokenlist); assert(0<tokenlist_len); return _balanced_character_count(tokenlist,tokenlist_len,l_match,r_match); } template<> POD_pair<size_t,size_t> balanced_character_count<'[',']'>(const parse_tree* tokenlist,size_t tokenlist_len) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = {0, 0}; const parse_tree* const iter_end = tokenlist+tokenlist_len; const parse_tree* iter = tokenlist; do if (!iter->index_tokens[1].token.first) { if (detect_C_left_bracket_op(iter->index_tokens[0].token.first,iter->index_tokens[0].token.second)) ++depth.first; else if (detect_C_right_bracket_op(iter->index_tokens[0].token.first,iter->index_tokens[0].token.second)) ++depth.second; } while(++iter!=iter_end); return depth; } template<> POD_pair<size_t,size_t> balanced_character_count<'{','}'>(const parse_tree* tokenlist,size_t tokenlist_len) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = {0, 0}; const parse_tree* const iter_end = tokenlist+tokenlist_len; const parse_tree* iter = tokenlist; do if (!iter->index_tokens[1].token.first) { if (detect_C_left_brace_op(iter->index_tokens[0].token.first,iter->index_tokens[0].token.second)) ++depth.first; else if (detect_C_right_brace_op(iter->index_tokens[0].token.first,iter->index_tokens[0].token.second)) ++depth.second; } while(++iter!=iter_end); return depth; } static void unbalanced_error(const weak_token& src,size_t count, char match) { assert(0<count); message_header(src); INC_INFORM(ERR_STR); INC_INFORM(count); INC_INFORM(" unbalanced '"); INC_INFORM(match); INFORM('\''); zcc_errors.inc_error(); } static void _construct_matched_pairs(const weak_token* tokenlist,size_t tokenlist_len, autovalarray_ptr<POD_pair<size_t,size_t> >& stack1,const char l_match,const char r_match) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = _balanced_character_count(tokenlist,tokenlist_len,l_match,r_match); // pre-scan std::pair<size_t,size_t> unbalanced_loc(0,0); const size_t starting_errors = zcc_errors.err_count(); if (0<depth.first && 0<depth.second) { // reality-check: balanced parentheses autovalarray_ptr_throws<size_t> fixedstack(depth.first); autovalarray_ptr_throws<POD_pair<size_t,size_t> > pair_fixedstack(depth.first<depth.second ? depth.first : depth.second); depth.first = 0; depth.second = 0; size_t balanced_paren = 0; size_t i = 0; do if (1==tokenlist[i].token.second) { assert(tokenlist[i].token.first); if (l_match==tokenlist[i].token.first[0]) { // soft-left: not an error if (0<depth.second) { unbalanced_error(tokenlist[i],depth.second,r_match); depth.second = 0; } if (0==depth.first) unbalanced_loc.first = i; fixedstack[depth.first++] = i; } else if (r_match==tokenlist[i].token.first[0]) { if (0<depth.first) { pair_fixedstack[balanced_paren].first = fixedstack[--depth.first]; pair_fixedstack[balanced_paren++].second = i; } else{ ++depth.second; unbalanced_loc.second = i; } }; } while(tokenlist_len > ++i); if (0==depth.first && 0==depth.second && starting_errors==zcc_errors.err_count()) // need to be more flexible here as well { assert(pair_fixedstack.size()==balanced_paren); // only for hard-left hard-right pair_fixedstack.MoveInto(stack1); } }; assert(0==depth.first || 0==depth.second); if (0<depth.second) // soft-left: not an error unbalanced_error(tokenlist[unbalanced_loc.second],depth.second,r_match); if (0<depth.first) // soft-right: not an error unbalanced_error(tokenlist[unbalanced_loc.first],depth.first,l_match); } template<char l_match,char r_match> static void construct_matched_pairs(const weak_token* tokenlist,size_t tokenlist_len, autovalarray_ptr<POD_pair<size_t,size_t> >& stack1) { assert(tokenlist); assert(0<tokenlist_len); _construct_matched_pairs(tokenlist,tokenlist_len,stack1,l_match,r_match); } template<> void construct_matched_pairs<'[',']'>(const weak_token* tokenlist,size_t tokenlist_len, autovalarray_ptr<POD_pair<size_t,size_t> >& stack1) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = balanced_character_count<'[',']'>(tokenlist,tokenlist_len); // pre-scan std::pair<size_t,size_t> unbalanced_loc(0,0); const size_t starting_errors = zcc_errors.err_count(); if (0<depth.first && 0<depth.second) { // reality-check: balanced parentheses autovalarray_ptr_throws<size_t> fixedstack(depth.first); autovalarray_ptr_throws<POD_pair<size_t,size_t> > pair_fixedstack(depth.first<depth.second ? depth.first : depth.second); depth.first = 0; depth.second = 0; size_t balanced_paren = 0; size_t i = 0; do if (1==tokenlist[i].token.second) { assert(tokenlist[i].token.first); if (detect_C_left_bracket_op(tokenlist[i].token.first,tokenlist[i].token.second)) { if (0<depth.second) { unbalanced_error(tokenlist[i],depth.second,']'); depth.second = 0; } if (0==depth.first) unbalanced_loc.first = i; fixedstack[depth.first++] = i; } else if (detect_C_right_bracket_op(tokenlist[i].token.first,tokenlist[i].token.second)) { if (0<depth.first) { pair_fixedstack[balanced_paren].first = fixedstack[--depth.first]; pair_fixedstack[balanced_paren++].second = i; } else{ ++depth.second; unbalanced_loc.second = i; } }; } while(tokenlist_len > ++i); if (0==depth.first && 0==depth.second && starting_errors==zcc_errors.err_count()) { assert(pair_fixedstack.size()==balanced_paren); pair_fixedstack.MoveInto(stack1); } }; assert(0==depth.first || 0==depth.second); if (0<depth.second) unbalanced_error(tokenlist[unbalanced_loc.second],depth.second,']'); if (0<depth.first) unbalanced_error(tokenlist[unbalanced_loc.first],depth.first,'['); } template<> void construct_matched_pairs<'{','}'>(const weak_token* tokenlist,size_t tokenlist_len, autovalarray_ptr<POD_pair<size_t,size_t> >& stack1) { assert(tokenlist); assert(0<tokenlist_len); POD_pair<size_t,size_t> depth = balanced_character_count<'{','}'>(tokenlist,tokenlist_len); // pre-scan std::pair<size_t,size_t> unbalanced_loc(0,0); const size_t starting_errors = zcc_errors.err_count(); if (0<depth.first && 0<depth.second) { // reality-check: balanced parentheses autovalarray_ptr_throws<size_t> fixedstack(depth.first); autovalarray_ptr_throws<POD_pair<size_t,size_t> > pair_fixedstack(depth.first<depth.second ? depth.first : depth.second); depth.first = 0; depth.second = 0; size_t balanced_paren = 0; size_t i = 0; do if (1==tokenlist[i].token.second) { assert(tokenlist[i].token.first); if (detect_C_left_brace_op(tokenlist[i].token.first,tokenlist[i].token.second)) { if (0<depth.second) { unbalanced_error(tokenlist[i],depth.second,'}'); depth.second = 0; } if (0==depth.first) unbalanced_loc.first = i; fixedstack[depth.first++] = i; } else if (detect_C_right_brace_op(tokenlist[i].token.first,tokenlist[i].token.second)) { if (0<depth.first) { pair_fixedstack[balanced_paren].first = fixedstack[--depth.first]; pair_fixedstack[balanced_paren++].second = i; } else{ ++depth.second; unbalanced_loc.second = i; } }; } while(tokenlist_len > ++i); if (0==depth.first && 0==depth.second && starting_errors==zcc_errors.err_count()) { assert(pair_fixedstack.size()==balanced_paren); pair_fixedstack.MoveInto(stack1); } }; assert(0==depth.first || 0==depth.second); if (0<depth.second) unbalanced_error(tokenlist[unbalanced_loc.second],depth.second,'}'); if (0<depth.first) unbalanced_error(tokenlist[unbalanced_loc.first],depth.first,'{'); } static void _slice_error(const weak_token& src,size_t slice_count,const char cut,const std::pair<char,char>& knife) { message_header(src); INC_INFORM(ERR_STR); INC_INFORM(slice_count); INC_INFORM(' '); INC_INFORM(cut); INC_INFORM(" are unbalanced by improper grouping within "); INC_INFORM(knife.first); INC_INFORM(' '); INFORM(knife.second); zcc_errors.inc_error(); } static void find_sliced_pairs(const weak_token* tokenlist, const autovalarray_ptr<POD_pair<size_t,size_t> >& stack1, const autovalarray_ptr<POD_pair<size_t,size_t> >& stack2,const std::pair<char,char>& pair1,const std::pair<char,char>& pair2) { assert(tokenlist); if (stack1.empty()) return; if (stack2.empty()) return; size_t i = 0; size_t j = 0; do { if (stack1[i].second<stack2[j].first) { // ok (disjoint) ++i; continue; }; if (stack2[j].second<stack1[i].first) { // ok (disjoint) ++j; continue; }; if (stack1[i].first<stack2[j].first) { if (stack2[j].second<stack1[i].second) { // ok (proper nesting) ++i; continue; } size_t slice_count = 1; while(++i < stack1.size() && stack1[i].first<stack2[j].first && stack2[j].second>=stack1[i].second) ++slice_count; _slice_error(tokenlist[stack1[i-1].first],slice_count,pair1.second,pair2); continue; } if (stack2[j].first<stack1[i].first) { if (stack1[i].second<stack2[j].second) { // ok (proper nesting) ++j; continue; } size_t slice_count = 1; while(++j < stack2.size() && stack2[j].first<stack1[i].first && stack1[i].second>=stack2[j].second) ++slice_count; _slice_error(tokenlist[stack2[j-1].first],slice_count,pair2.second,pair1); continue; } } while(i<stack1.size() && j<stack2.size()); } static bool C_like_BalancingCheck(const weak_token* tokenlist,size_t tokenlist_len,bool hard_start,bool hard_end) { assert(tokenlist); assert(0<tokenlist_len); autovalarray_ptr<POD_pair<size_t,size_t> > parenpair_stack; autovalarray_ptr<POD_pair<size_t,size_t> > bracketpair_stack; autovalarray_ptr<POD_pair<size_t,size_t> > bracepair_stack; const size_t starting_errors = zcc_errors.err_count(); // responsible for context-free error checking if (hard_start && hard_end) { // other test cases cannot be done from preprocessor construct_matched_pairs<'(',')'>(tokenlist,tokenlist_len,parenpair_stack); construct_matched_pairs<'[',']'>(tokenlist,tokenlist_len,bracketpair_stack); construct_matched_pairs<'{','}'>(tokenlist,tokenlist_len,bracepair_stack); if (starting_errors==zcc_errors.err_count()) { // check for slicing const int test_these = (!parenpair_stack.empty())+2*(!bracketpair_stack.empty())+4*(!bracepair_stack.empty()); switch(test_these) { default: break; case 7: { // all three find_sliced_pairs(tokenlist,bracketpair_stack,bracepair_stack,std::pair<char,char>('[',']'),std::pair<char,char>('{','}')); find_sliced_pairs(tokenlist,parenpair_stack,bracepair_stack,std::pair<char,char>('(',')'),std::pair<char,char>('{','}')); find_sliced_pairs(tokenlist,parenpair_stack,bracketpair_stack,std::pair<char,char>('(',')'),std::pair<char,char>('[',']')); break; } case 6: { // bracket and brace find_sliced_pairs(tokenlist,bracketpair_stack,bracepair_stack,std::pair<char,char>('[',']'),std::pair<char,char>('{','}')); break; } case 5: { // paren and brace find_sliced_pairs(tokenlist,parenpair_stack,bracepair_stack,std::pair<char,char>('(',')'),std::pair<char,char>('{','}')); break; } case 3: { // paren and bracket //! \test cpp/default/Error_if_control70.hpp, cpp/default/Error_if_control70.h //! \test cpp/default/Error_if_control71.hpp, cpp/default/Error_if_control71.h find_sliced_pairs(tokenlist,parenpair_stack,bracketpair_stack,std::pair<char,char>('(',')'),std::pair<char,char>('[',']')); break; } } } }; return starting_errors!=zcc_errors.err_count(); } template<size_t targ_len> static inline bool robust_token_is_string(const POD_pair<const char*,size_t>& x,const char* const target) { assert(target); assert(targ_len==strlen(target)); return x.first && targ_len==x.second && !strncmp(x.first,target,targ_len); } static inline bool robust_token_is_string(const POD_pair<const char*,size_t>& x,const char* const target) { assert(target); const size_t targ_len = strlen(target); return x.first && targ_len==x.second && !strncmp(x.first,target,targ_len); } template<size_t targ_len> static inline bool token_is_string(const POD_pair<const char*,size_t>& x,const char* const target) { assert(target); assert(targ_len==strlen(target)); assert(x.first); return targ_len==x.second && !strncmp(x.first,target,targ_len); } static inline bool token_is_string(const POD_pair<const char*,size_t>& x,const char* const target) { assert(target); assert(x.first); const size_t targ_len = strlen(target); return targ_len==x.second && !strncmp(x.first,target,targ_len); } template<size_t targ_len> static inline bool robust_token_is_string(const parse_tree& x,const char* const target) { return x.is_atomic() && token_is_string<targ_len>(x.index_tokens[0].token,target); } static inline bool robust_token_is_string(const parse_tree& x,const char* const target) { return x.is_atomic() && token_is_string(x.index_tokens[0].token,target); } template<char c> static inline bool token_is_char(const POD_pair<const char*,size_t>& x) { assert(x.first); return 1==x.second && c== *x.first; } template<> inline bool token_is_char<'#'>(const POD_pair<const char*,size_t>& x) { assert(x.first); return detect_C_stringize_op(x.first,x.second); } template<> inline bool token_is_char<'['>(const POD_pair<const char*,size_t>& x) { assert(x.first); return detect_C_left_bracket_op(x.first,x.second); } template<> inline bool token_is_char<']'>(const POD_pair<const char*,size_t>& x) { assert(x.first); return detect_C_right_bracket_op(x.first,x.second); } template<> inline bool token_is_char<'{'>(const POD_pair<const char*,size_t>& x) { assert(x.first); return detect_C_left_brace_op(x.first,x.second); } template<> inline bool token_is_char<'}'>(const POD_pair<const char*,size_t>& x) { assert(x.first); return detect_C_right_brace_op(x.first,x.second); } template<char c> inline bool robust_token_is_char(const POD_pair<const char*,size_t>& x) { return x.first && 1==x.second && c== *x.first; } template<> inline bool robust_token_is_char<'#'>(const POD_pair<const char*,size_t>& x) { return x.first && detect_C_stringize_op(x.first,x.second); } template<> inline bool robust_token_is_char<'['>(const POD_pair<const char*,size_t>& x) { return x.first && detect_C_left_bracket_op(x.first,x.second); } template<> inline bool robust_token_is_char<']'>(const POD_pair<const char*,size_t>& x) { return x.first && detect_C_right_bracket_op(x.first,x.second); } template<> inline bool robust_token_is_char<'{'>(const POD_pair<const char*,size_t>& x) { return x.first && detect_C_left_brace_op(x.first,x.second); } template<> inline bool robust_token_is_char<'}'>(const POD_pair<const char*,size_t>& x) { return x.first && detect_C_right_brace_op(x.first,x.second); } template<char c> inline bool robust_token_is_char(const parse_tree& x) { return x.is_atomic() && token_is_char<c>(x.index_tokens[0].token); } //! \todo if we have an asphyxiates_left_brace, suppress_naked_brackets_and_braces goes obsolete static bool asphyxiates_left_bracket(const weak_token& x) { if ((C_TESTFLAG_IDENTIFIER | C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_STRING_LITERAL | C_TESTFLAG_PP_NUMERAL) & x.flags) return false; if (token_is_char<')'>(x.token)) return false; if (token_is_char<']'>(x.token)) return false; return true; } //! \todo this forks when distinctions between C, C++ are supported // balancing errors are handled earlier static bool right_paren_asphyxiates(const weak_token& token) { if ( token_is_char<'&'>(token.token) // potentially unary operators || token_is_char<'*'>(token.token) || token_is_char<'+'>(token.token) || token_is_char<'-'>(token.token) || token_is_char<'~'>(token.token) || token_is_char<'!'>(token.token) || token_is_char<'/'>(token.token) // proper multiplicative operators || token_is_char<'%'>(token.token) // || token_is_string<2>(token.token,"<<") // shift operators -- watch out for parsing problems with templates, this really is C only // || token_is_string<2>(token.token,">>") // || token_is_char<'<'>(token.token) // relational operators -- watch out for parsing problems with templates // || token_is_char<'>'>(token.token) || token_is_string<2>(token.token,"<=") || token_is_string<2>(token.token,">=") || token_is_string<2>(token.token,"==") // equality operators || token_is_string<2>(token.token,"!=") || token_is_char<'^'>(token.token) // bitwise XOR || token_is_char<'|'>(token.token) // bitwise OR || token_is_string<2>(token.token,"&&") // logical AND || token_is_string<2>(token.token,"||") // logical OR || token_is_char<'?'>(token.token)) // operator ? : return true; return false; } //! \todo this forks when distinctions between C, C++ are supported static bool left_paren_asphyxiates(const weak_token& token) { if ( token_is_char<'/'>(token.token) // proper multiplicative operators || token_is_char<'%'>(token.token) // || token_is_string<2>(token.token,"<<") // shift operators -- watch out for parsing problems with templates, this really is C only // || token_is_string<2>(token.token,">>") // || token_is_char<'<'>(token.token) // relational operators -- watch out for parsing problems with templates // || token_is_char<'>'>(token.token) || token_is_string<2>(token.token,"<=") || token_is_string<2>(token.token,">=") || token_is_string<2>(token.token,"==") // equality operators || token_is_string<2>(token.token,"!=") || token_is_char<'^'>(token.token) // bitwise XOR || token_is_char<'|'>(token.token) // bitwise OR || token_is_string<2>(token.token,"&&") // logical AND || token_is_string<2>(token.token,"||") // logical OR || token_is_char<'?'>(token.token) // operator ? : || token_is_char<':'>(token.token)) // one of operator ? :, or a label return true; return false; } static bool paren_is_bad_news(const weak_token& lhs, const weak_token& rhs) { if (token_is_char<'['>(rhs.token) && asphyxiates_left_bracket(lhs)) { message_header(rhs); INC_INFORM(ERR_STR); INC_INFORM(lhs); INFORM(" denies [ ] its left argument (C99 6.5.2p1/C++98 5.2p1)"); zcc_errors.inc_error(); }; if (token_is_char<')'>(rhs.token) || token_is_char<']'>(rhs.token)) { if (right_paren_asphyxiates(lhs)) { message_header(rhs); INC_INFORM(ERR_STR); INC_INFORM(rhs); INC_INFORM(" denies "); INC_INFORM(lhs); INFORM(" its right argument (C99 6.5.3p1/C++98 5.3p1)"); zcc_errors.inc_error(); } } if (token_is_char<'('>(lhs.token) || token_is_char<'['>(lhs.token)) { if (left_paren_asphyxiates(rhs)) { message_header(lhs); INC_INFORM(ERR_STR); INC_INFORM(lhs); INC_INFORM(" denies "); INC_INFORM(rhs); INFORM(" its left argument"); zcc_errors.inc_error(); } } return false; //! \todo don't abuse std::adjacent_find } static bool C99_CoreControlExpressionContextFreeErrorCount(const weak_token* tokenlist,size_t tokenlist_len,bool hard_start,bool hard_end) { assert(tokenlist); assert(0<tokenlist_len); const size_t starting_errors = zcc_errors.err_count(); bool already_errored = false; if (hard_start && token_is_char<'['>(tokenlist[0].token)) { //! \test if.C99/Error_control3.h, if.C99/Error_control3.hpp message_header(tokenlist[0]); INC_INFORM(ERR_STR); INFORM("[ at start of expression denies [ ] its left argument (C99 6.5.2p1/C++98 5.2p1)"); zcc_errors.inc_error(); }; if (hard_start && left_paren_asphyxiates(tokenlist[0])) { //! \test if.C99/Error_control4.h, if.C99/Error_control4.hpp //! \test if.C99/Error_control11.h, if.C99/Error_control11.hpp //! \test if.C99/Error_control12.h, if.C99/Error_control12.hpp //! \test if.C99/Error_control13.h, if.C99/Error_control13.hpp //! \test if.C99/Error_control14.h, if.C99/Error_control14.hpp //! \test if.C99/Error_control15.h, if.C99/Error_control15.hpp //! \test if.C99/Error_control16.h, if.C99/Error_control16.hpp //! \test if.C99/Error_control17.h, if.C99/Error_control17.hpp //! \test if.C99/Error_control18.h, if.C99/Error_control18.hpp //! \test if.C99/Error_control19.h, if.C99/Error_control19.hpp //! \test if.C99/Error_control20.h, if.C99/Error_control20.hpp //! \test if.C99/Error_control21.h, if.C99/Error_control21.hpp message_header(tokenlist[0]); INC_INFORM(ERR_STR); INC_INFORM(tokenlist[0]); INFORM((1==tokenlist_len && hard_end && right_paren_asphyxiates(tokenlist[0])) ? " as only token doesn't have either of its arguments (C99 6.5.3p1/C++98 5.3p1)" : " as first token doesn't have its left argument (C99 6.5.3p1/C++98 5.3p1)"); zcc_errors.inc_error(); already_errored = 1==tokenlist_len; }; std::adjacent_find(tokenlist,tokenlist+tokenlist_len,paren_is_bad_news); if (hard_end && !already_errored && right_paren_asphyxiates(tokenlist[tokenlist_len-1])) { //! \test if.C99/Error_control5.h, if.C99/Error_control5.hpp //! \test if.C99/Error_control6.h, if.C99/Error_control6.hpp //! \test if.C99/Error_control7.h, if.C99/Error_control7.hpp //! \test if.C99/Error_control8.h, if.C99/Error_control8.hpp //! \test if.C99/Error_control9.h, if.C99/Error_control9.hpp //! \test if.C99/Error_control10.h, if.C99/Error_control10.hpp message_header(tokenlist[tokenlist_len-1]); INC_INFORM(ERR_STR); INC_INFORM(tokenlist[tokenlist_len-1]); INFORM(" as last token doesn't have its right argument (C99 6.5.3p1/C++98 5.3p1)"); zcc_errors.inc_error(); } return starting_errors!=zcc_errors.err_count(); } static bool C99_ControlExpressionContextFreeErrorCount(const weak_token* tokenlist,size_t tokenlist_len,bool hard_start,bool hard_end) { assert(tokenlist); assert(0<tokenlist_len); return C99_CoreControlExpressionContextFreeErrorCount(tokenlist,tokenlist_len,hard_start,hard_end); } static bool CPP_ControlExpressionContextFreeErrorCount(const weak_token* tokenlist,size_t tokenlist_len,bool hard_start,bool hard_end) { assert(tokenlist); assert(0<tokenlist_len); return C99_CoreControlExpressionContextFreeErrorCount(tokenlist,tokenlist_len,hard_start,hard_end); } size_t LengthOfCPurePreprocessingOperatorPunctuation(const char* const x) { assert(x && *x); if (strchr(ATOMIC_PREPROC_PUNC,*x)) return 1; const errr i = linear_reverse_find_prefix_in_lencached(x,valid_pure_preprocessing_op_punc+NONATOMIC_PREPROC_OP_LB,C_PREPROC_OP_STRICT_UB-NONATOMIC_PREPROC_OP_LB); if (0<=i) return valid_pure_preprocessing_op_punc[i+NONATOMIC_PREPROC_OP_LB].second; return 0; } size_t LengthOfCPPPurePreprocessingOperatorPunctuation(const char* const x) { assert(x && *x); if (strchr(ATOMIC_PREPROC_PUNC,*x)) return 1; const errr i = linear_reverse_find_prefix_in_lencached(x,valid_pure_preprocessing_op_punc+NONATOMIC_PREPROC_OP_LB,CPP_PREPROC_OP_STRICT_UB-NONATOMIC_PREPROC_OP_LB); if (0<=i) return valid_pure_preprocessing_op_punc[i+NONATOMIC_PREPROC_OP_LB].second; return 0; } static unsigned int CPurePreprocessingOperatorPunctuationFlags(signed int i) { assert(0<i && C_PREPROC_OP_STRICT_UB>=(unsigned int)i); return valid_pure_preprocessing_op_punc[i-1].third; } static unsigned int CPPPurePreprocessingOperatorPunctuationFlags(signed int i) { assert(0<i && CPP_PREPROC_OP_STRICT_UB>=(unsigned int)i); return valid_pure_preprocessing_op_punc[i-1].third; } // encoding reality checks BOOST_STATIC_ASSERT(PP_CODE_MASK>CPP_PREPROC_OP_STRICT_UB); BOOST_STATIC_ASSERT((PP_CODE_MASK>>1)<=CPP_PREPROC_OP_STRICT_UB); static signed int CPurePreprocessingOperatorPunctuationCode(const char* const x, size_t x_len) { BOOST_STATIC_ASSERT(INT_MAX-1>=C_PREPROC_OP_STRICT_UB); return 1+linear_reverse_find_lencached(x,x_len,valid_pure_preprocessing_op_punc,C_PREPROC_OP_STRICT_UB); } static signed int CPPPurePreprocessingOperatorPunctuationCode(const char* const x, size_t x_len) { BOOST_STATIC_ASSERT(INT_MAX-1>=CPP_PREPROC_OP_STRICT_UB); return 1+linear_reverse_find_lencached(x,x_len,valid_pure_preprocessing_op_punc,CPP_PREPROC_OP_STRICT_UB); } static void _bad_syntax_tokenized(const char* const x, size_t x_len, lex_flags& flags, const char* const src_filename, size_t line_no, func_traits<signed int (*)(const char* const, size_t)>::function_type find_pp_code) { assert(x); assert(src_filename && *src_filename); assert(x_len<=strlen(x)); assert((C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_PP_OP_PUNC | C_TESTFLAG_STRING_LITERAL | C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_IDENTIFIER) & flags); // reality checks on relation between flag constants and enums BOOST_STATIC_ASSERT((C_PPFloatCore::F<<10)==C_TESTFLAG_F); BOOST_STATIC_ASSERT((C_PPFloatCore::L<<10)==C_TESTFLAG_L); BOOST_STATIC_ASSERT((C_PPIntCore::U<<10)==C_TESTFLAG_U); BOOST_STATIC_ASSERT((C_PPIntCore::L<<10)==C_TESTFLAG_L); BOOST_STATIC_ASSERT((C_PPIntCore::UL<<10)==(C_TESTFLAG_L | C_TESTFLAG_U)); BOOST_STATIC_ASSERT((C_PPIntCore::LL<<10)==C_TESTFLAG_LL); BOOST_STATIC_ASSERT((C_PPIntCore::ULL<<10)==(C_TESTFLAG_LL | C_TESTFLAG_U)); if (C_TESTFLAG_PP_NUMERAL==flags) { union_quartet<C_PPIntCore,C_PPFloatCore,C_PPDecimalFloat,C_PPHexFloat> test; if (C_PPDecimalFloat::is(x,x_len,test.third)) flags |= C_TESTFLAG_FLOAT | C_TESTFLAG_DECIMAL; else if (C_PPHexFloat::is(x,x_len,test.fourth)) flags |= C_TESTFLAG_FLOAT | C_TESTFLAG_HEXADECIMAL; else if (C_PPIntCore::is(x,x_len,test.first)) { assert(C_PPIntCore::ULL>=test.first.hinted_type); flags |= (((lex_flags)(test.first.hinted_type))<<10); assert(8==test.first.radix || 10==test.first.radix || 16==test.first.radix); switch(test.first.radix) { case 8: { flags |= C_TESTFLAG_INTEGER | C_TESTFLAG_OCTAL; break; } case 10: { flags |= C_TESTFLAG_INTEGER | C_TESTFLAG_DECIMAL; break; } case 16: { flags |= C_TESTFLAG_INTEGER | C_TESTFLAG_HEXADECIMAL; break; } }; } if (flags & C_TESTFLAG_FLOAT) { assert(C_PPFloatCore::L>=test.second.hinted_type); flags |= (((lex_flags)(test.second.hinted_type))<<10); }; if (C_TESTFLAG_PP_NUMERAL==flags) { INC_INFORM(src_filename); INC_INFORM(':'); INC_INFORM(line_no); INC_INFORM(": "); INC_INFORM(ERR_STR); INC_INFORM("invalid preprocessing number"); INC_INFORM(x,x_len); INFORM(" (C99 6.4.4.1p1,6.4.4.2p1/C++98 2.13.1,2.13.3)"); zcc_errors.inc_error(); return; } } else if (C_TESTFLAG_PP_OP_PUNC & flags) { // language-sensitive token blacklisting const signed int pp_code = find_pp_code(x,x_len); assert(0<pp_code); C_PP_ENCODE(flags,pp_code); } else if (C_TESTFLAG_STRING_LITERAL==flags) { // This gets in by C99 6.6p10, as 6.6p6 doesn't list string literals as legitimate if (!IsLegalCString(x,x_len)) { INC_INFORM(src_filename); INC_INFORM(':'); INC_INFORM(line_no); INC_INFORM(": "); INC_INFORM(ERR_STR); INC_INFORM(x,x_len); INFORM(" : invalid string (C99 6.4.5p1/C++98 2.13.4)"); zcc_errors.inc_error(); return; } else if (bool_options[boolopt::pedantic]) { INC_INFORM(src_filename); INC_INFORM(':'); INC_INFORM(line_no); INC_INFORM(": "); INC_INFORM(WARN_STR); INC_INFORM(x,x_len); INFORM(" : string literals in integer constant expressions are only permitted, not required (C99 6.6p10)"); if (bool_options[boolopt::warnings_are_errors]) { zcc_errors.inc_error(); return; } } } else if (C_TESTFLAG_CHAR_LITERAL==flags) { if (!IsLegalCCharacterLiteral(x,x_len)) { INC_INFORM(src_filename); INC_INFORM(':'); INC_INFORM(line_no); INC_INFORM(": "); INC_INFORM(ERR_STR); INC_INFORM("invalid character literal "); INC_INFORM(x,x_len); INFORM(" (C99 6.4.4.4p1/C++98 2.13.2)"); zcc_errors.inc_error(); return; } } } static void C99_bad_syntax_tokenized(const char* const x, size_t x_len, lex_flags& flags, const char* const src_filename, size_t line_no) { _bad_syntax_tokenized(x,x_len,flags,src_filename,line_no,CPurePreprocessingOperatorPunctuationCode); } static void CPP_bad_syntax_tokenized(const char* const x, size_t x_len, lex_flags& flags, const char* const src_filename, size_t line_no) { _bad_syntax_tokenized(x,x_len,flags,src_filename,line_no,CPPPurePreprocessingOperatorPunctuationCode); } //! \todo fix these to not assume perfect matching character sets #define C99_SYMBOLIC_ESCAPED_ESCAPES "\a\b\f\n\r\t\v" #define C99_SYMBOLIC_ESCAPES "abfnrtv" #define C99_COPY_ESCAPES "\"'?\\" static const char* const c99_symbolic_escaped_escapes = C99_SYMBOLIC_ESCAPED_ESCAPES; static const char* const c99_symbolic_escapes = C99_SYMBOLIC_ESCAPES; static size_t LengthOfEscapedCString(const char* src, size_t src_len) { assert(src); assert(0<src_len); size_t actual_size = src_len; size_t i = 0; do { if ('\0'!=src[i]) { // deal with the symbolic escapes if ( strchr(c99_symbolic_escaped_escapes,src[i]) || strchr("\"\\?",src[i])) { ++actual_size; continue; }; if (!C_IsPrintableChar(src[i])) { // note that octal escaping can only go up to 511, which is a problem if our CHAR_BIT exceeds 9 unsigned char tmp = src[i]; bool must_escape = (1<src_len-i && strchr(list_hexadecimal_digits,src[i+1])); //! \todo fix to handle target CHAR_BIT different than ours #if 9>=CHAR_BIT if (7U>=tmp || must_escape) #else if (7U>=tmp || (must_escape && 511U>=tmp)) #endif { // octal-escape if it's readable, or if it prevents escaping the next printable character if (must_escape) { actual_size += 3; continue; } do { ++actual_size; tmp /= 8U; } while(0<tmp); continue; } #if 9<CHAR_BIT # if 16>=CHAR_BIT if (must_escape) { // hexadecimal breaks; try universal-char-encoding actual_size += 5; continue; } # elif 32>=CHAR_BIT if (must_escape) { // hexadecimal breaks; try universal-char-encoding actual_size += 5; if (65536<=tmp) actual_size += 4; continue; } # else if (must_escape && 65536*65536>tmp) { // hexadecimal breaks; try universal-char-encoding actual_size += 5; if (65536<=tmp) actual_size += 4; continue; } # endif #endif // hex-escape for legibility while(16<=tmp) { ++actual_size; tmp /= 16; }; actual_size += 2; continue; } }; } while(src_len > ++i); return actual_size; } static size_t LengthOfEscapedCString(const my_UNICODE* src, size_t src_len) { //! \todo synchronize with EscapeCString assert(src); assert(0<src_len); size_t actual_size = src_len; size_t i = 0; do { if ('\0'!=src[i]) { // deal with the symbolic escapes if ( strchr(c99_symbolic_escaped_escapes,src[i]) || strchr("\"\\?",src[i])) { ++actual_size; continue; }; if (!C_IsPrintableChar(src[i])) { // note that octal escaping can only go up to 511, which is a problem if our CHAR_BIT exceeds 9 my_UNICODE tmp = src[i]; bool must_escape = (1<src_len-i && strchr(list_hexadecimal_digits,src[i+1])); //! \todo fix to handle target CHAR_BIT different than ours #if 9>=CHAR_BIT*C_UNICODE_SIZE if (7U>=tmp || must_escape) #else if (7U>=tmp || (must_escape && 511U>=tmp)) #endif { // octal-escape if it's readable, or if it prevents escaping the next printable character if (must_escape) { actual_size += 3; continue; } do { ++actual_size; tmp /= 8; } while(0<tmp); continue; } #if 9<CHAR_BIT*C_UNICODE_SIZE # if 16>=CHAR_BIT*C_UNICODE_SIZE if (must_escape) { // hexadecimal breaks; try universal-char-encoding actual_size += 5; continue; } # elif 32>=CHAR_BIT*C_UNICODE_SIZE if (must_escape) { // hexadecimal breaks; try universal-char-encoding actual_size += 5; if (65536U<=tmp) actual_size += 4; continue; } # else if (must_escape && 65536ULL*65536ULL>tmp) { // hexadecimal breaks; try universal-char-encoding actual_size += 5; if (65536U<=tmp) actual_size += 4; continue; } # endif #endif // hex-escape for legibility while(16<=tmp) { ++actual_size; tmp /= 16; }; actual_size += 2; continue; } }; } while(src_len > ++i); return actual_size; } static void EscapeCString(char* dest, const char* src, size_t src_len) { // \todo fix ASCII dependency. assert(src); assert(0<src_len); size_t i = 0; do { if ('\0'!=src[i]) { // deal with the symbolic escapes const char* const symbolic_escaped_escape = strchr(c99_symbolic_escaped_escapes,src[i]); if (symbolic_escaped_escape) { *(dest++) = '\\'; *(dest++) = c99_symbolic_escapes[symbolic_escaped_escape-c99_symbolic_escaped_escapes]; continue; }; //! \todo probably too cautious; we need to escape ? only if a ? immediately precedes it (break trigraph sequences) if (strchr("\"\\?",src[i])) { *(dest++) = '\\'; *(dest++) = src[i]; continue; } }; // Note that hex escape sequence requires at least 2 bytes, so octal is just-as-cheap through decimal 63 (which takes 3 bytes in hex) // however, octal isn't that user friendly; we clearly want to octal-escape only through 7 // \bug need test cases if (!C_IsPrintableChar(src[i])) { // note that octal escaping can only go up to 511, which is a problem if our CHAR_BIT exceeds 9 unsigned char tmp = src[i]; bool must_escape = (1<src_len-i && strchr(list_hexadecimal_digits,src[i+1])); *(dest++) = '\\'; //! \todo fix to handle target CHAR_BIT different than ours #if 9>=CHAR_BIT if (7U>=tmp || must_escape) #else if (7U>=tmp || (must_escape && 511U>=tmp)) #endif { // octal-escape if it's readable, or if it prevents escaping the next printable character if (must_escape && 64U>tmp) { *(dest++) = '0'; if (8U>tmp) *(dest++) = '0'; }; do { *(dest++) = (tmp%8U)+(unsigned char)('0'); tmp /= 8U; } while(0<tmp); continue; } #if 9<CHAR_BIT # if 16>=CHAR_BIT if (must_escape) { *(dest++) = 'u'; # if 12<CHAR_BIT *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/4096U)%16]; # else *(dest++) = '0'; # endif *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/256U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/16U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[tmp%16U]; continue; } # elif 32>=CHAR_BIT if (must_escape) { if (65536U<=tmp) { *(dest++) = 'U'; # if 28<CHAR_BIT *(dest++) = C_HEXADECIMAL_DIGITS[tmp/(65536ULL*4096ULL)]; # else *(dest++) = '0'; # endif # if 24<CHAR_BIT *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*256ULL))%16]; # else *(dest++) = '0'; # endif # if 20<CHAR_BIT *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*16ULL))%16]; # else *(dest++) = '0'; # endif *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL))%16]; } else{ *(dest++) = 'u'; } *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/4096U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/256U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/16U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[tmp%16]; continue; } # else if (must_escape && 65536ULL*65536ULL>tmp) { if (65536U<=tmp) { *(dest++) = 'U'; *(dest++) = C_HEXADECIMAL_DIGITS[tmp/(65536ULL*4096ULL)]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*256ULL))%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*16ULL))%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL))%16]; } else{ *(dest++) = 'u'; } *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/4096U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/256U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/16U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[tmp%16]; continue; } if (must_escape) _fatal("unescapable string: escaping code points above 2^32-1 followed by a hexadecimal digit disallowed by C99; bug for C++ (should be escaping the hexadecimal digit as well)"); # endif #endif // hex-escape for legibility *(dest++) = 'x'; unsigned char power = 1; while(power<=tmp/16) power *= 16; do { *(dest++) = list_hexadecimal_digits[tmp/power]; tmp %= power; power /= 16; } while(0<power); continue; } *(dest++) = src[i]; } while(src_len > ++i); } static void EscapeCString(char* dest, const my_UNICODE* src, size_t src_len) { // \todo fix ASCII dependency. assert(src); assert(0<src_len); size_t i = 0; do { if (0!=src[i] && UCHAR_MAX>=src[i]) { // deal with the symbolic escapes const char* const symbolic_escaped_escape = strchr(c99_symbolic_escaped_escapes,src[i]); if (symbolic_escaped_escape) { *(dest++) = '\\'; *(dest++) = c99_symbolic_escapes[symbolic_escaped_escape-c99_symbolic_escaped_escapes]; continue; }; //! \todo probably too cautious; we need to escape ? only if a ? immediately precedes it (break trigraph sequences) if (strchr("\"\\?",src[i])) { *(dest++) = '\\'; *(dest++) = src[i]; continue; } }; // Note that hex escape sequence requires at least 2 bytes, so octal is just-as-cheap through decimal 63 (which takes 3 bytes in hex) // however, octal isn't that user friendly; we clearly want to octal-escape only through 7 // \bug need test cases if (!C_IsPrintableChar(src[i])) { // note that octal escaping can only go up to 511, which is a problem if our CHAR_BIT exceeds 9 my_UNICODE tmp = src[i]; bool must_escape = (1<src_len-i && UCHAR_MAX>=src[i] && strchr(list_hexadecimal_digits,src[i+1])); *(dest++) = '\\'; //! \todo fix to handle target CHAR_BIT different than ours #if 9>=CHAR_BIT*C_UNICODE_SIZE if (7U>=tmp || must_escape) #else if (7U>=tmp || (must_escape && 511U>=tmp)) #endif { // octal-escape if it's readable, or if it prevents escaping the next printable character if (must_escape && 64U>tmp) { *(dest++) = '0'; if (8U>tmp) *(dest++) = '0'; }; do { *(dest++) = (tmp%8U)+(unsigned char)('0'); tmp /= 8U; } while(0<tmp); continue; } #if 32>=CHAR_BIT*C_UNICODE_SIZE if (must_escape) { if (65536U<=tmp) { *(dest++) = 'U'; # if 28<CHAR_BIT*C_UNICODE_SIZE *(dest++) = C_HEXADECIMAL_DIGITS[tmp/(65536ULL*4096ULL)]; # else *(dest++) = '0'; # endif # if 24<CHAR_BIT*C_UNICODE_SIZE *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*256ULL))%16]; # else *(dest++) = '0'; # endif # if 20<CHAR_BIT*C_UNICODE_SIZE *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*16ULL))%16]; # else *(dest++) = '0'; # endif *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL))%16]; } else{ *(dest++) = 'u'; } *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/4096U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/256U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/16U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[tmp%16]; continue; } #else if (must_escape && 65536ULL*65536ULL>tmp) { if (65536U<=tmp) { *(dest++) = 'U'; *(dest++) = C_HEXADECIMAL_DIGITS[tmp/(65536ULL*4096ULL)]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*256ULL))%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL*16ULL))%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/(65536ULL))%16]; } else{ *(dest++) = 'u'; } *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/4096U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/256U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[(tmp/16U)%16]; *(dest++) = C_HEXADECIMAL_DIGITS[tmp%16]; continue; } if (must_escape) _fatal("unescapable string: escaping code points above 2^32-1 followed by a hexadecimal digit disallowed by C99; bug for C++ (should be escaping the hexadecimal digit as well)"); #endif // hex-escape for legibility *(dest++) = 'x'; unsigned char power = 1; while(power<=tmp/16) power *= 16; do { *(dest++) = list_hexadecimal_digits[tmp/power]; tmp %= power; power /= 16; } while(0<power); continue; } *(dest++) = src[i]; } while(src_len > ++i); } static size_t octal_escape_length(const char* const src, const size_t ub) { assert(src); const size_t oct_len = strspn(src,C_OCTAL_DIGITS); return (ub<oct_len) ? ub : oct_len; } static unsigned int eval_octal_escape(const char* src, size_t src_len) { assert(src); assert(0<src_len && src_len<=3); unsigned int tmp = 0; do { const unsigned char tmp2 = *(src++); assert((in_range<'0','7'>(tmp2))); tmp *= 8; tmp += (tmp2-'0'); } while(0< --src_len); return tmp; } static size_t hex_escape_length(const char* const src, const size_t ub) { assert(src); const size_t hex_len = strspn(src,C_HEXADECIMAL_DIGITS); return (ub<hex_len) ? ub : hex_len; } static umaxint eval_hex_escape(const char* src, size_t src_len) { assert(src); assert(0<src_len); unsigned_var_int tmp(0,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); #ifndef NDEBUG umaxint uchar_max(target_machine->unsigned_max<virtual_machine::std_int_long_long>()); uchar_max >>= 4; #endif do { const unsigned char tmp2 = *(src++); assert(strchr(C_HEXADECIMAL_DIGITS,tmp2)); assert(uchar_max>=tmp); tmp <<= 4; tmp += InterpretHexadecimalDigit(tmp2); } while(0< --src_len); return tmp; } // must remain synchronized with RobustEscapedCharLength_C static size_t EscapedCharLength_C(const char* src, size_t src_len) { assert(src); assert(0<src_len); if ('\\' != *src) return 1; assert(1<src_len && '\0'!=src[1]); if ( strchr(C99_SYMBOLIC_ESCAPES,src[1]) || strchr(C99_COPY_ESCAPES,src[1])) return 2; if ('U'==src[1] || 'u'==src[1] || 'x'==src[1]) { assert(3<=src_len); const size_t hex_len = hex_escape_length(src+2,src_len-2U); switch(src[1]) { case 'u': { // UNICODE escape assert(4<=hex_len); return 6; } case 'U': { // astral UNICODE escape assert(8<=hex_len); return 10; } case 'x': { // hexadecimal escape assert(0<hex_len); return hex_len+2; } } }; const size_t oct_len = octal_escape_length(src+1,(3U>src_len-1U) ? 3U : src_len-1U); assert(0<oct_len); return oct_len+1; } // must remain synchronized with EscapedCharLength_C static size_t RobustEscapedCharLength_C(const char* src, size_t src_len) { assert(src); assert(0<src_len); if ('\\' != *src) return 1; if (1>=src_len || '\0'==src[1]) return 0; if ( strchr(C99_SYMBOLIC_ESCAPES,src[1]) || strchr(C99_COPY_ESCAPES,src[1])) return 2; if ('U'==src[1] || 'u'==src[1] || 'x'==src[1]) { if (2>=src_len) return 0; const size_t hex_len = hex_escape_length(src+2,src_len-2U); switch(src[1]) { case 'u': { // UNICODE escape if (4>hex_len) return 0; return 6; } case 'U': { // astral UNICODE escape if (8>hex_len) return 0; return 10; } case 'x': { // hexadecimal escape if (0>=hex_len) return 0; return hex_len+2; } } }; const size_t oct_len = octal_escape_length(src+1,(3U>src_len-1U) ? 3U : src_len-1U); if (0>=oct_len) return 0; return oct_len+1; } static size_t LengthOfUnescapedCString(const char* src, size_t src_len) { assert(src); assert(0<src_len); size_t analyze_length = 0; size_t i = 0; do { ++analyze_length; i += EscapedCharLength_C(src+i,src_len-i); } while(src_len > i); return analyze_length; } static uintmax_t _eval_character(const char* src, size_t src_len) { assert(src); assert(0<src_len); if (1==src_len) return (unsigned char)(*src); const char* tmp_escape = strchr(C_OCTAL_DIGITS,src[1]); if (tmp_escape) { const size_t oct_len = octal_escape_length(src+1,(3U>src_len-1U) ? 3U : src_len-1U); assert(0<oct_len); return eval_octal_escape(src+1,oct_len); }; if (2==src_len) { tmp_escape = strchr(c99_symbolic_escapes,src[1]); if (tmp_escape) return (unsigned char)(c99_symbolic_escaped_escapes[tmp_escape-c99_symbolic_escapes]); assert(strchr(C99_COPY_ESCAPES,src[1])); return (unsigned char)(src[1]); } assert((strchr("uUx",src[1]))); assert(3<=src_len); return eval_hex_escape(src+2,src_len-2).to_uint(); } static void UnescapeCString(char* dest, const char* src, size_t src_len) { //! \todo cross-compiler augmentation target, dest needs to be able represent target strings assert(src); assert(0<src_len); assert(CHAR_BIT>=target_machine->C_char_bit()); size_t i = 0; do { const size_t step = EscapedCharLength_C(src+i,src_len-i); assert(UCHAR_MAX>=_eval_character(src+i,step)); *(dest++) = _eval_character(src+i,step); i += step; } while(src_len > i); } static void UnescapeCWideString(my_UNICODE* dest, const char* src, size_t src_len) { //! \todo cross-compiler change target, dest needs to be able represent target strings assert(src); assert(0<src_len); assert(C_UNICODE_MAX>=target_machine->unsigned_max(target_machine->UNICODE_wchar_t())); size_t i = 0; do { const size_t step = EscapedCharLength_C(src+i,src_len-i); assert(C_UNICODE_MAX>=_eval_character(src+i,step)); *(dest++) = _eval_character(src+i,step); i += step; } while(src_len > i); } bool IsLegalCString(const char* x, size_t x_len) { assert(x); assert(0<x_len); if ('"' != x[x_len-1]) return false; if (0 == --x_len) return false; const bool wide_string = 'L' == *x; if (wide_string) { if (0 == --x_len) return false; ++x; } if ('"' != *(x++)) return false; if (0 == --x_len) return true; // empty string is legal const umaxint& uchar_max = target_machine->unsigned_max((wide_string) ? target_machine->UNICODE_wchar_t() : virtual_machine::std_int_char); size_t i = 0; do { const size_t step = RobustEscapedCharLength_C(x+i,x_len-i); if (0==step) return false; if (uchar_max<_eval_character(x+i,step)) return false; i += step; } while(x_len > i); return true; } bool IsLegalCCharacterLiteral(const char* x, size_t x_len) { assert(x); assert(0<x_len); if ('\'' != x[x_len-1]) return false; if (0 == --x_len) return false; const bool wide_string = 'L' == *x; if (wide_string) { if (0 == --x_len) return false; ++x; } if ('\'' != *(x++)) return false; if (0 == --x_len) return false; // empty character literal is illegal const umaxint& uchar_max = target_machine->unsigned_max((wide_string) ? target_machine->UNICODE_wchar_t() : virtual_machine::std_int_char); size_t i = 0; do { const size_t step = RobustEscapedCharLength_C(x+i,x_len-i); if (0==step) return false; if (uchar_max<_eval_character(x+i,step)) return false; i += step; } while(x_len > i); return true; } static size_t LengthOfCStringLiteral(const char* src, size_t src_len) { assert(src); assert(2<=src_len); const bool wide_str = ('L'==src[0]); if (wide_str) { ++src; if (2 > --src_len) return 0; } if ('"'!=src[--src_len]) return 0; if ('"'!=*(src++)) return 0; if (0 == --src_len) return 1; return LengthOfUnescapedCString(src,src_len)+1; } static size_t LengthOfCCharLiteral(const char* src, size_t src_len) { assert(src); assert(2<=src_len); const bool wide_char = ('L'==src[0]); if (wide_char) { ++src; if (2 > --src_len) return 0; } if ('\''!=src[--src_len]) return 0; if ('\''!=*(src++)) return 0; if (0 == --src_len) return 1; return LengthOfUnescapedCString(src,src_len); } /*! * Locates the character in a character literal as a substring. Use this as preparation for "collapsing in place". * * \param src string to locate character in * \param src_len length of string * \param target_idx index we actually want * \param char_offset offset of character literal body * \param char_len length of character literal body * * \return bool true iff located as-is */ bool LocateCCharacterLiteralAt(const char* const src, size_t src_len, size_t target_idx, size_t& char_offset, size_t& char_len) { assert(src); assert(2<=src_len); assert(IsLegalCString(src,src_len)); const char* src2 = src; const size_t C_str_len = LengthOfCStringLiteral(src,src_len); assert(C_str_len>target_idx); // NUL; using <= to be failsafed in release mode if (target_idx+1<=C_str_len) return false; const bool wide_str = ('L'==src[0]); if (wide_str) { ++src2; --src_len; assert(2<=src_len); } ++src2; src_len -= 2; size_t i = 0; size_t j = 0; do { const size_t step = EscapedCharLength_C(src2+i,src_len-i); if (j==target_idx) { char_offset = i+(src2-src); char_len = step; return true; } i += step; ++j; } while(src_len > i); return false; } static char* GetCCharacterLiteralAt(const char* src, size_t src_len, size_t target_idx) { assert(src); assert(2<=src_len); assert(IsLegalCString(src,src_len)); char* tmp = NULL; const size_t C_str_len = LengthOfCStringLiteral(src,src_len); assert(C_str_len>target_idx); const bool wide_str = ('L'==src[0]); if (wide_str) { ++src; --src_len; assert(2<=src_len); } ++src; src_len -= 2; if (target_idx+1==C_str_len) { char* tmp2 = _new_buffer_nonNULL_throws<char>((wide_str) ? 6 : 5); tmp = tmp2; if (wide_str) *(tmp2++) = 'L'; strcpy(tmp2,"'\\0'"); return tmp; }; size_t i = 0; size_t j = 0; do { const size_t step = EscapedCharLength_C(src+i,src_len-i); if (j==target_idx) { char* tmp2 = _new_buffer_nonNULL_throws<char>(((wide_str) ? 3 : 2)+step); tmp = tmp2; if (wide_str) *(tmp2++) = 'L'; *(tmp2++) = '\''; strncpy(tmp2,src+i,step); *(tmp2 += step) = '\''; return tmp; } i += step; ++j; } while(src_len > i); return tmp; } /*! * concatenates two string literals into a string literal. * * \param src C string literal 1, escaped * \param src_len length of C string literal 1 * \param src2 C string literal 2, escaped * \param src2_len length of C string literal 2 * \param target where to put a dynamically created string literal, escaped * * \return 1: success, new token in target * \return 0: failure * \return -1: use first string as concatenation * \return -2: use second string as concatenation * \return -3: use first string as content, but wide-string header from second string * \return -4: use second string as content, but wide-string header from first string * \return -5: failed to allocate memory * * \post return value is between -5 and 1 inclusive * \post returns 1 iff NULL!=target * \post if NULL!=target, target points to a valid string literal */ static int ConcatenateCStringLiterals(const char* src, size_t src_len, const char* src2, size_t src2_len, char*& target) { assert(src); assert(src2); assert(2<=src_len); assert(2<=src2_len); assert(IsLegalCString(src,src_len)); assert(IsLegalCString(src2,src2_len)); assert(!target); const char* str1 = src; const char* str2 = src2; size_t str1_len = src_len; size_t str2_len = src2_len; const bool str1_wide = ('L'==src[0]); const bool str2_wide = ('L'==src2[0]); const bool str_target_wide = str1_wide || str2_wide; if (str1_wide) { ++str1; --str1_len; } if (str2_wide) { ++str2; --str2_len; } ++str1; ++str2; str1_len -= 2; str2_len -= 2; if (0==str1_len) { if (str2_wide==str_target_wide) return -2; return -4; } if (0==str2_len) { if (str1_wide==str_target_wide) return -1; return -3; } const size_t str1_un_len = LengthOfUnescapedCString(src,src_len); /* will simple algorithm work? */ bool simple_paste_ok = !strchr(C_HEXADECIMAL_DIGITS,*str2); if (!simple_paste_ok) { POD_pair<size_t,size_t> loc; #ifndef NDEBUG assert(LocateCCharacterLiteralAt(src,src_len,str1_un_len-1,loc.first,loc.second)); #else if (!LocateCCharacterLiteralAt(src,src_len,str1_un_len-1,loc.first,loc.second)) return 0; #endif // octal and hexadecimal are bad for simple pasting if (1==loc.second || !strchr("x01234567",src[loc.first+1])) simple_paste_ok = true; // but a 3-digit octal escape isn't else if ('x'!=src[loc.first+1] && 4==loc.second) simple_paste_ok = true; if (!simple_paste_ok) { // a hex escape of more than 8 effective digits will force a hexadecimal digit to be escaped, pretty much requires hex-escaping in C99 (charset weirdness) // C++ will let us off because it allows escaping printable characters, but this still is not good (charset weirdness) so we don't handle it yet // fail immediately because we haven't implemented cross-charset preprocessing yet if ('x'==src[loc.first+1] && 8<(loc.second-2)-strspn(src+loc.first+2,"0")) return 0; } } if (simple_paste_ok) { const size_t new_start = (str_target_wide) ? 2 : 1; const size_t new_width = str1_len+str2_len+new_start+1U; target = reinterpret_cast<char*>(calloc(new_width,1)); if (!target) return -5; target[new_width-1] = '"'; target[new_start-1] = '"'; if (str_target_wide) target[0] = 'L'; strncpy(target+new_start,str1,str1_len); strncpy(target+new_start+str1_len,str2,str2_len); assert(IsLegalCString(target,new_width)); return 1; }; // working buffer const size_t str2_un_len = LengthOfUnescapedCString(src2,src2_len); const size_t buf_len = str1_un_len+str2_un_len; union_pair<char*,my_UNICODE*> buf; if (str_target_wide) { buf.second = zaimoni::_new_buffer<my_UNICODE>(buf_len); if (!buf.second) return -5; UnescapeCWideString(buf.second,str1,str1_len); UnescapeCWideString(buf.second+str1_un_len,str2,str2_len); //! \todo C vs C++ const size_t target_len = LengthOfEscapedCString(buf.second,buf_len); target = zaimoni::_new_buffer<char>(target_len); if (!target) return free(buf.second),-5; EscapeCString(target,buf.second,buf_len); free(buf.second); assert(IsLegalCString(target,target_len)); return 1; } else{ buf.first = zaimoni::_new_buffer<char>(buf_len); if (!buf.first) return -5; UnescapeCString(buf.first,str1,str1_len); UnescapeCString(buf.first+str1_un_len,str2,str2_len); const size_t target_len = LengthOfEscapedCString(buf.first,buf_len); target = zaimoni::_new_buffer<char>(target_len); if (!target) return free(buf.first),-5; EscapeCString(target,buf.first,buf_len); free(buf.first); assert(IsLegalCString(target,target_len)); return 1; } } static uintmax_t EvalCharacterLiteral(const char* src, size_t src_len) { assert(src); assert(3<=src_len); assert(IsLegalCCharacterLiteral(src,src_len)); const bool is_wide = 'L'== *src; if (is_wide) { ++src; --src_len; }; ++src; src_len -= 2; const unsigned int target_char_bit = (is_wide ? target_machine->C_bit(target_machine->UNICODE_wchar_t()) : target_machine->C_char_bit()); assert(sizeof(uintmax_t)*CHAR_BIT >= target_char_bit); const uintmax_t safe_limit = (UINTMAX_MAX>>target_char_bit); uintmax_t tmp = 0; size_t i = 0; do { tmp <<= target_char_bit; const size_t step = EscapedCharLength_C(src+i,src_len-i); tmp += _eval_character(src+i,step); i += step; } while(src_len > i && safe_limit>=tmp); return tmp; } bool CCharLiteralIsFalse(const char* x,size_t x_len) { assert(x); assert(0<x_len); assert(IsLegalCCharacterLiteral(x,x_len)); const uintmax_t result = EvalCharacterLiteral(x,x_len); if (0==result) return true; if (bool_options[boolopt::char_is_unsigned]) return false; switch(target_machine->C_signed_int_representation()) { default: return false; case virtual_machine::ones_complement: { unsigned_var_int tmp(0,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); if (VM_MAX_BIT_PLATFORM>target_machine->C_char_bit()) tmp.set(target_machine->C_char_bit()); tmp -= 1; return tmp==result; } case virtual_machine::sign_and_magnitude: { unsigned_var_int tmp(0,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); tmp.set(target_machine->C_char_bit()-1); return tmp==result; } }; } // not sure if we need this bit, but it matches the standards // PM expression is C++ only #define PARSE_PRIMARY_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-1)) #define PARSE_STRICT_POSTFIX_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-2)) #define PARSE_STRICT_UNARY_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-3)) #define PARSE_STRICT_CAST_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-4)) #define PARSE_STRICT_PM_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-5)) #define PARSE_STRICT_MULT_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-6)) #define PARSE_STRICT_ADD_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-7)) #define PARSE_STRICT_SHIFT_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-8)) #define PARSE_STRICT_RELATIONAL_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-9)) #define PARSE_STRICT_EQUALITY_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-10)) #define PARSE_STRICT_BITAND_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-11)) #define PARSE_STRICT_BITXOR_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-12)) #define PARSE_STRICT_BITOR_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-13)) #define PARSE_STRICT_LOGICAND_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-14)) #define PARSE_STRICT_LOGICOR_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-15)) #define PARSE_STRICT_CONDITIONAL_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-16)) #define PARSE_STRICT_ASSIGNMENT_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-17)) #define PARSE_STRICT_COMMA_EXPRESSION ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-18)) /* strict type categories of parsing */ #define PARSE_PRIMARY_TYPE ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-19)) #define PARSE_UNION_TYPE ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-20)) #define PARSE_CLASS_STRUCT_TYPE ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-21)) #define PARSE_ENUM_TYPE ((lex_flags)(1)<<(sizeof(lex_flags)*CHAR_BIT-22)) // check for collision with lowest three bits BOOST_STATIC_ASSERT(sizeof(lex_flags)*CHAR_BIT-parse_tree::PREDEFINED_STRICT_UB>=22); /* nonstrict expression types */ #define PARSE_POSTFIX_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION) #define PARSE_UNARY_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION) #define PARSE_CAST_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION) #define PARSE_PM_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION) #define PARSE_MULT_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION) #define PARSE_ADD_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION) #define PARSE_SHIFT_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION) #define PARSE_RELATIONAL_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION) #define PARSE_EQUALITY_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION) #define PARSE_BITAND_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION) #define PARSE_BITXOR_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION) #define PARSE_BITOR_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION | PARSE_STRICT_BITOR_EXPRESSION) #define PARSE_LOGICAND_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION | PARSE_STRICT_BITOR_EXPRESSION | PARSE_STRICT_LOGICAND_EXPRESSION) #define PARSE_LOGICOR_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION | PARSE_STRICT_BITOR_EXPRESSION | PARSE_STRICT_LOGICAND_EXPRESSION | PARSE_STRICT_LOGICOR_EXPRESSION) #define PARSE_CONDITIONAL_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION | PARSE_STRICT_BITOR_EXPRESSION | PARSE_STRICT_LOGICAND_EXPRESSION | PARSE_STRICT_LOGICOR_EXPRESSION | PARSE_STRICT_CONDITIONAL_EXPRESSION) #define PARSE_ASSIGNMENT_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION | PARSE_STRICT_BITOR_EXPRESSION | PARSE_STRICT_LOGICAND_EXPRESSION | PARSE_STRICT_LOGICOR_EXPRESSION | PARSE_STRICT_CONDITIONAL_EXPRESSION | PARSE_STRICT_ASSIGNMENT_EXPRESSION) #define PARSE_EXPRESSION (PARSE_PRIMARY_EXPRESSION | PARSE_STRICT_POSTFIX_EXPRESSION | PARSE_STRICT_UNARY_EXPRESSION | PARSE_STRICT_CAST_EXPRESSION | PARSE_STRICT_PM_EXPRESSION | PARSE_STRICT_MULT_EXPRESSION | PARSE_STRICT_ADD_EXPRESSION | PARSE_STRICT_SHIFT_EXPRESSION | PARSE_STRICT_RELATIONAL_EXPRESSION | PARSE_STRICT_EQUALITY_EXPRESSION | PARSE_STRICT_BITAND_EXPRESSION | PARSE_STRICT_BITXOR_EXPRESSION | PARSE_STRICT_BITOR_EXPRESSION | PARSE_STRICT_LOGICAND_EXPRESSION | PARSE_STRICT_LOGICOR_EXPRESSION | PARSE_STRICT_CONDITIONAL_EXPRESSION | PARSE_STRICT_ASSIGNMENT_EXPRESSION | PARSE_STRICT_COMMA_EXPRESSION) /* nonstrict type categories */ #define PARSE_TYPE (PARSE_PRIMARY_TYPE | PARSE_UNION_TYPE | PARSE_CLASS_STRUCT_TYPE | PARSE_ENUM_TYPE) /* already-parsed */ #define PARSE_OBVIOUS (PARSE_EXPRESSION | PARSE_TYPE | parse_tree::INVALID) #define PARSE_PAREN_PRIMARY_PASSTHROUGH (parse_tree::CONSTANT_EXPRESSION) /* XXX this may belong with parse_tree XXX */ static void simple_error(parse_tree& src, const char* const err_str) { assert(err_str && *err_str); if (parse_tree::INVALID & src.flags) return; src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(src); INFORM(err_str); zcc_errors.inc_error(); } /* deal with following type catalog atomic: bool “bool” (_Bool for C) char16_t “char16_t” (C++0x, don't worry about this yet) char32_t “char32_t” (C++0x, don't worry about this yet) wchar_t “wchar_t” (C++ only) void “void” participates in composite: char “char” unsigned char “unsigned char” signed char “signed char” unsigned “unsigned int” unsigned int “unsigned int” signed “int” signed int “int” int “int” unsigned short int “unsigned short int” unsigned short “unsigned short int” unsigned long int “unsigned long int” unsigned long “unsigned long int” unsigned long long int “unsigned long long int” unsigned long long “unsigned long long int” signed long int “long int” signed long “long int” signed long long int “long long int” signed long long “long long int” long long int “long long int” long long “long long int” long int “long int” long “long int” signed short int “short int” signed short “short int” short int “short int” short “short int” float “float” double “double” long double “long double” float _Complex "float" double _Complex "double" long double _Complex "long double" in any case, use up a flag to track "positively typename" status */ void set_C_canonical_type_representation(parse_tree& src,size_t i,size_t target_type) { // range-restrict assert(C_TYPE::VOID<=target_type && C_TYPE::LDOUBLE__COMPLEX>=target_type); assert(C_TYPE::NOT_VOID!=target_type); // not-void isn't a real type assert(C_TYPE::BOOL!=target_type); // this breaks in C++ assert(C_TYPE::INTEGERLIKE!=target_type); // integerlike isn't a real type #define C_ATOMIC_TYPE_IDENTIFIER_BITFLAG ((1ULL<<C_TYPE::VOID) \ | (1ULL<<C_TYPE::BOOL) \ | (1ULL<<C_TYPE::CHAR) \ | (1ULL<<C_TYPE::SHRT) \ | (1ULL<<C_TYPE::INT) \ | (1ULL<<C_TYPE::UINT) \ | (1ULL<<C_TYPE::LONG) \ | (1ULL<<C_TYPE::FLOAT) \ | (1ULL<<C_TYPE::DOUBLE)) parse_tree& tmp = src.c_array<0>()[i]; tmp.type_code.set_type(target_type); //! \todo should use something informative in place of 0; identifier not fine tmp.grab_index_token_from_str_literal<0>(C_atomic_types[target_type-1].first,C_ATOMIC_TYPE_IDENTIFIER_BITFLAG & (1ULL<<target_type) ? C_TESTFLAG_IDENTIFIER : 0); tmp.flags |= PARSE_PRIMARY_TYPE; #undef C_ATOMIC_TYPE_IDENTIFIER_BITFLAG } zaimoni::Loki::CheckReturnRequireRange<0,2,int>::value_type optional_keyword_choice(parse_tree& src,size_t i,kleene_star_core<size_t (*)(const char*)>& invariant_decl_scanner,size_t idx1,size_t idx2) { size_t offset[2]; int tmp = 0; assert(!invariant_decl_scanner.empty()); assert(src.size<0>()>i); assert(src.size<0>()-i>=invariant_decl_scanner.size()); assert(invariant_decl_scanner.strict_ub()>idx1); assert(invariant_decl_scanner.strict_ub()>idx2); if ((idx1==invariant_decl_scanner[0])<invariant_decl_scanner.count(idx1)) { ++tmp; offset[0] = invariant_decl_scanner.scan_nofail(idx1,1); } if ((idx2==invariant_decl_scanner[0])<invariant_decl_scanner.count(idx2)) { tmp+=2; offset[1] = invariant_decl_scanner.scan_nofail(idx2,1); } // if ambiguous, use the one whose completion is sooner if (3==tmp) tmp -= offset[0]<offset[1] ? 2 : 1; if (0<tmp) { src.DeleteIdx<0>(i+ ++offset[tmp-1]); invariant_decl_scanner.DeleteIdx(offset[tmp-1]); } return tmp; } template<size_t ub> typename zaimoni::Loki::CheckReturnRequireRange<0,ub,size_t>::value_type optional_keyword_limit(parse_tree& src,size_t i,kleene_star_core<size_t (*)(const char*)>& invariant_decl_scanner,size_t idx1) { size_t tmp = 0; assert(!invariant_decl_scanner.empty()); assert(src.size<0>()>i); assert(src.size<0>()-i>=invariant_decl_scanner.size()); assert(invariant_decl_scanner.strict_ub()>idx1); while(ub>tmp && (idx1==invariant_decl_scanner[0])<invariant_decl_scanner.count(idx1)) { size_t tmp2 = invariant_decl_scanner.scan_nofail(idx1,1); src.DeleteIdx<0>(i+ ++tmp2); invariant_decl_scanner.DeleteIdx(tmp2); ++tmp; } return tmp; } bool optional_keyword(parse_tree& src,size_t i,kleene_star_core<size_t (*)(const char*)>& invariant_decl_scanner,size_t idx1) { assert(!invariant_decl_scanner.empty()); assert(src.size<0>()>i); assert(src.size<0>()-i>=invariant_decl_scanner.size()); assert(invariant_decl_scanner.strict_ub()>idx1); if ((idx1==invariant_decl_scanner[0])<invariant_decl_scanner.count(idx1)) { size_t tmp = invariant_decl_scanner.scan_nofail(idx1,1); src.DeleteIdx<0>(i+ ++tmp); invariant_decl_scanner.DeleteIdx(tmp); return true; } return false; } static void C99_notice_primary_type_atomic(parse_tree& src) { if (src.is_atomic()) { if (token_is_string<5>(src.index_tokens[0].token,"_Bool")) { src.type_code.set_type(C_TYPE::BOOL); src.flags |= PARSE_PRIMARY_TYPE; return; }; if (token_is_string<4>(src.index_tokens[0].token,"void")) { src.type_code.set_type(C_TYPE::VOID); src.flags |= PARSE_PRIMARY_TYPE; return; } } } static void C99_notice_primary_type(parse_tree& src) { assert(src.is_raw_list()); std::for_each(src.begin<0>(),src.end<0>(),C99_notice_primary_type_atomic); size_t i = 0; kleene_star<STATIC_SIZE(C99_decl_specifier_list),size_t (*)(const char*)> invariant_decl_scanner(C99_invariant_decl_specifier); do { if (src.data<0>()[i].is_atomic() && invariant_decl_scanner(src.data<0>()[i].index_tokens[0].token.first)) { bool have_warned_about_register = false; bool have_warned_about_static = false; bool have_warned_about_extern = false; bool have_warned_about_thread_local = false; bool have_warned_about_auto = false; bool have_warned_about_typedef = false; bool have_warned_about_const = false; bool have_warned_about_volatile = false; bool have_warned_about_restrict = false; size_t offset = 0; while(src.size<0>()>i+ ++offset && invariant_decl_scanner(src.data<0>()[i+offset].index_tokens[0].token.first)) { // C1X 6.7.1p2: at most one storage-class specifier, except _Thread_Local may stack with static or extern if (1<invariant_decl_scanner.count(C99_CPP_REGISTER_IDX)) { //! \bug need test case if (!have_warned_about_register) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated register storage class and continuing (C99 6.7.1p2)"); zcc_errors.inc_error(); have_warned_about_register = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_STATIC_IDX)) { //! \test decl.C99/Error_dup_static.h if (!have_warned_about_static) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated static storage class and continuing (C99 6.7.1p2)"); zcc_errors.inc_error(); have_warned_about_static = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_EXTERN_IDX)) { //! \test decl.C99/Error_dup_extern.h if (!have_warned_about_extern) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated extern storage class and continuing (C99 6.7.1p2)"); zcc_errors.inc_error(); have_warned_about_extern = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C1X_CPP0X_THREAD_LOCAL_IDX)) { //! \bug need test case if (!have_warned_about_thread_local) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated _Thread_Local storage class and continuing (C1X 6.7.1p2)"); zcc_errors.inc_error(); have_warned_about_thread_local = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_AUTO_IDX)) { //! \bug need test case if (!have_warned_about_auto) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated auto storage class and continuing (C99 6.7.1p2)"); zcc_errors.inc_error(); have_warned_about_auto = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_TYPEDEF_IDX)) { //! \test decl.C99/Error_dup_typedef.h if (!have_warned_about_typedef) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated typedef storage class and continuing (C99 6.7.1p2)"); zcc_errors.inc_error(); have_warned_about_typedef = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } // C1X 6.7.3p3: duplicate type-qualifiers should be cleaned (warn unless -Wno-OAOO or -Wno-DRY) else if (1<invariant_decl_scanner.count(C99_CPP_CONST_IDX)) { //! \test decl.C99/Warn_dup_const.h if (!have_warned_about_const) { message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("removing redundant const type qualifier (C99 6.7.3p4)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); have_warned_about_const = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_VOLATILE_IDX)) { //! \test decl.C99/Warn_dup_volatile.h if (!have_warned_about_volatile) { message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("removing redundant volatile type qualifier (C99 6.7.3p4)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); have_warned_about_volatile = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_RESTRICT_IDX)) { //! \bug need test case if (!have_warned_about_restrict) { message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("removing redundant restrict type qualifier (C99 6.7.3p4)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); have_warned_about_restrict = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset--); } }; // handle allowed sequences of type-qualifiers (do need second pass later) bool have_warned_about_Complex = false; do { switch(invariant_decl_scanner[0]) { case C99_CPP_CHAR_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(1==C_TYPE::SCHAR-C_TYPE::CHAR); BOOST_STATIC_ASSERT(2==C_TYPE::UCHAR-C_TYPE::CHAR); set_C_canonical_type_representation(src,i,C_TYPE::CHAR+optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX)); break; case C99_CPP_SHORT_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; // short and signed short are the same type BOOST_STATIC_ASSERT(1==C_TYPE::USHRT-C_TYPE::SHRT); set_C_canonical_type_representation(src,i,C_TYPE::SHRT+(2==optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX))); // short int is the same as short optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_INT_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; { int tmp = optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX); // XXX have to account for short switch(optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SHORT_IDX,C99_CPP_LONG_IDX)) { case 0: BOOST_STATIC_ASSERT(1==C_TYPE::UINT-C_TYPE::INT); set_C_canonical_type_representation(src,i,C_TYPE::INT+(2==tmp)); break; case 1: BOOST_STATIC_ASSERT(1==C_TYPE::USHRT-C_TYPE::SHRT); set_C_canonical_type_representation(src,i,C_TYPE::SHRT+(2==tmp)); break; default: BOOST_STATIC_ASSERT(3==C_TYPE::ULLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(2==C_TYPE::LLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(1==C_TYPE::ULONG-C_TYPE::LONG); set_C_canonical_type_representation(src,i,C_TYPE::LONG+(2==tmp)+2*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); // break; } } break; case C99_CPP_LONG_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_DOUBLE_IDX)) { BOOST_STATIC_ASSERT(3==C_TYPE::LDOUBLE__COMPLEX-C_TYPE::LDOUBLE); set_C_canonical_type_representation(src,i,C_TYPE::LDOUBLE+3*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_COMPLEX_IDX)); break; } BOOST_STATIC_ASSERT(3==C_TYPE::ULLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(2==C_TYPE::LLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(1==C_TYPE::ULONG-C_TYPE::LONG); set_C_canonical_type_representation(src,i,C_TYPE::LONG+(2==optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX))+2*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); // long int is the same as long optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_FLOAT_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(3==C_TYPE::FLOAT__COMPLEX-C_TYPE::FLOAT); set_C_canonical_type_representation(src,i,C_TYPE::FLOAT+3*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_COMPLEX_IDX)); break; case C99_CPP_DOUBLE_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(1==C_TYPE::LDOUBLE-C_TYPE::DOUBLE); BOOST_STATIC_ASSERT(3==C_TYPE::DOUBLE__COMPLEX-C_TYPE::DOUBLE); BOOST_STATIC_ASSERT(4==C_TYPE::LDOUBLE__COMPLEX-C_TYPE::DOUBLE); set_C_canonical_type_representation(src,i,C_TYPE::DOUBLE+optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)+3*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_COMPLEX_IDX)); break; case C99_CPP_SIGNED_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_CHAR_IDX)) { set_C_canonical_type_representation(src,i,C_TYPE::SCHAR); break; } if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_SHORT_IDX)) set_C_canonical_type_representation(src,i,C_TYPE::SHRT); else{ BOOST_STATIC_ASSERT(2==C_TYPE::LONG-C_TYPE::INT); BOOST_STATIC_ASSERT(4==C_TYPE::LLONG-C_TYPE::INT); set_C_canonical_type_representation(src,i,C_TYPE::INT+2*optional_keyword_limit<2>(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); } // signed int is the same as signed optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_UNSIGNED_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_CHAR_IDX)) { set_C_canonical_type_representation(src,i,C_TYPE::UCHAR); break; } if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_SHORT_IDX)) set_C_canonical_type_representation(src,i,C_TYPE::USHRT); else{ BOOST_STATIC_ASSERT(2==C_TYPE::ULONG-C_TYPE::UINT); BOOST_STATIC_ASSERT(4==C_TYPE::ULLONG-C_TYPE::UINT); set_C_canonical_type_representation(src,i,C_TYPE::UINT+2*optional_keyword_limit<2>(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); } // unsigned int is the same as unsigned optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_COMPLEX_IDX: switch(optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_FLOAT_IDX,C99_CPP_DOUBLE_IDX)) { case 0: if (!have_warned_about_Complex) { message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("type-specifier-sequence has _Complex without either float or double (C99 6.7.3p4)"); zcc_errors.inc_error(); have_warned_about_Complex = true; } // remove the unusable token src.DeleteIdx<0>(i--); break; case 1: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; set_C_canonical_type_representation(src,i,C_TYPE::FLOAT__COMPLEX); break; case 2: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(1==C_TYPE::LDOUBLE__COMPLEX-C_TYPE::DOUBLE__COMPLEX); set_C_canonical_type_representation(src,i,C_TYPE::DOUBLE__COMPLEX+optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); // break; } // break; } invariant_decl_scanner.DeleteIdx(0); ++i; } while(!invariant_decl_scanner.empty()); // defer handling: _Thread_Local, typedef, other storage class issues } } while(src.size<0>()> ++i); } static void CPP_notice_primary_type_atomic(parse_tree& src) { if (src.is_atomic()) { if (token_is_string<4>(src.index_tokens[0].token,"bool")) { src.type_code.set_type(C_TYPE::BOOL); src.flags |= PARSE_PRIMARY_TYPE; return; }; if (token_is_string<7>(src.index_tokens[0].token,"wchar_t")) { src.type_code.set_type(C_TYPE::WCHAR_T); src.flags |= PARSE_PRIMARY_TYPE; return; } if (token_is_string<4>(src.index_tokens[0].token,"void")) { src.type_code.set_type(C_TYPE::VOID); src.flags |= PARSE_PRIMARY_TYPE; return; } } } static void CPP_notice_primary_type(parse_tree& src) { assert(src.is_raw_list()); std::for_each(src.begin<0>(),src.end<0>(),CPP_notice_primary_type_atomic); size_t i = 0; kleene_star<STATIC_SIZE(CPP0X_decl_specifier_list),size_t (*)(const char*)> invariant_decl_scanner(CPP0X_invariant_decl_specifier); do { if (src.data<0>()[i].is_atomic() && invariant_decl_scanner(src.data<0>()[i].index_tokens[0].token.first)) { bool have_warned_about_register = false; bool have_warned_about_static = false; bool have_warned_about_extern = false; bool have_warned_about_thread_local = false; bool have_warned_about_mutable = false; bool have_warned_about_typedef = false; bool have_warned_about_const = false; bool have_warned_about_volatile = false; bool using_linkage = false; size_t offset = 0; // C++0X 7.5: intercept linkage specifications here, warn if discarding (must accept "C" and "C++") if (C99_CPP_EXTERN_IDX==invariant_decl_scanner[0] && 1<src.size<0>()-i && (C_TESTFLAG_STRING_LITERAL & src.data<0>()[i+1].flags)) { //! \todo should accept escape codes here as well if (strcmp(src.data<0>()[i+1].index_tokens[0].token.first,"\"C\"") && strcmp(src.data<0>()[i+1].index_tokens[0].token.first,"\"C++\"")) { //! \bug need test case message_header(src.data<0>()[i+1].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("discarding unrecognized linkage (only C, C++ required: C++0X 7.5p2)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); src.DeleteIdx<0>(i+1); } else using_linkage = true; } while(src.size<0>()>i+ ++offset+using_linkage && invariant_decl_scanner(src.data<0>()[i+offset+using_linkage].index_tokens[0].token.first)) { // C++0X 7.1.1p1: at most one storage-class specifier, except thread_local may stack with static or extern if (1<invariant_decl_scanner.count(C99_CPP_REGISTER_IDX)) { //! \bug need test case if (!have_warned_about_register) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated register storage class and continuing (C++0X 7.1.1p1)"); zcc_errors.inc_error(); have_warned_about_register = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } if (1<invariant_decl_scanner.count(C99_CPP_STATIC_IDX)) { //! \test decl.C99/Error_dup_static.hpp if (!have_warned_about_static) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated static storage class and continuing (C++0X 7.1.1p1)"); zcc_errors.inc_error(); have_warned_about_static = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_EXTERN_IDX)) { //! \test decl.C99/Error_dup_extern.hpp if (!have_warned_about_extern) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated extern storage class and continuing (C++0X 7.1.1p1)"); zcc_errors.inc_error(); have_warned_about_extern = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C1X_CPP0X_THREAD_LOCAL_IDX)) { //! \bug need test case if (!have_warned_about_thread_local) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated thread_local storage class and continuing (C++0X 7.1.1p1)"); zcc_errors.inc_error(); have_warned_about_thread_local = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(CPP_MUTABLE_IDX)) { //! \bug need test case if (!have_warned_about_mutable) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated mutable storage class and continuing (C++0X 7.1.1p1)"); zcc_errors.inc_error(); have_warned_about_mutable = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_TYPEDEF_IDX)) { //! \test decl.C99/Error_dup_typedef.h if (!have_warned_about_typedef) { //! \todo --do-what-i-mean should warn message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("removing prohibited duplicated typedef specifier and continuing (C++0X 7.1.3p1)"); zcc_errors.inc_error(); have_warned_about_typedef = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } // C++0X 7.1.6.1: duplicate cv-qualifiers should be cleaned (warn unless -Wno-OAOO or -Wno-DRY) else if (1<invariant_decl_scanner.count(C99_CPP_CONST_IDX)) { //! \test decl.C99/Warn_dup_const.hpp if (!have_warned_about_const) { message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("removing redundant const cv-qualifier (C++0X 7.1.6.1p1)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); have_warned_about_const = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } else if (1<invariant_decl_scanner.count(C99_CPP_VOLATILE_IDX)) { //! \test decl.C99/Warn_dup_volatile.hpp if (!have_warned_about_volatile) { message_header(src.data<0>()[i+offset+using_linkage].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); have_warned_about_volatile = true; } src.DeleteIdx<0>(i+offset+using_linkage); invariant_decl_scanner.DeleteIdx(offset--); } }; // handle allowed sequences of type-qualifiers (do need second pass later) bool have_warned_about_Complex = false; do { switch(invariant_decl_scanner[0]) { case C99_CPP_CHAR_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(1==C_TYPE::SCHAR-C_TYPE::CHAR); BOOST_STATIC_ASSERT(2==C_TYPE::UCHAR-C_TYPE::CHAR); set_C_canonical_type_representation(src,i,C_TYPE::CHAR+optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX)); break; case C99_CPP_SHORT_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; // short and signed short are the same type BOOST_STATIC_ASSERT(1==C_TYPE::USHRT-C_TYPE::SHRT); set_C_canonical_type_representation(src,i,C_TYPE::SHRT+(2==optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX))); // short int is the same as short optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_INT_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; { int tmp = optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX); // XXX have to account for short switch(optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SHORT_IDX,C99_CPP_LONG_IDX)) { case 0: BOOST_STATIC_ASSERT(1==C_TYPE::UINT-C_TYPE::INT); set_C_canonical_type_representation(src,i,C_TYPE::INT+(2==tmp)); break; case 1: BOOST_STATIC_ASSERT(1==C_TYPE::USHRT-C_TYPE::SHRT); set_C_canonical_type_representation(src,i,C_TYPE::SHRT+(2==tmp)); break; default: BOOST_STATIC_ASSERT(3==C_TYPE::ULLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(2==C_TYPE::LLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(1==C_TYPE::ULONG-C_TYPE::LONG); set_C_canonical_type_representation(src,i,C_TYPE::LONG+(2==tmp)+2*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); // break; } } break; case C99_CPP_LONG_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_DOUBLE_IDX)) { BOOST_STATIC_ASSERT(3==C_TYPE::LDOUBLE__COMPLEX-C_TYPE::LDOUBLE); set_C_canonical_type_representation(src,i,C_TYPE::LDOUBLE+3*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_COMPLEX_IDX)); break; } BOOST_STATIC_ASSERT(3==C_TYPE::ULLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(2==C_TYPE::LLONG-C_TYPE::LONG); BOOST_STATIC_ASSERT(1==C_TYPE::ULONG-C_TYPE::LONG); set_C_canonical_type_representation(src,i,C_TYPE::LONG+(2==optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_SIGNED_IDX,C99_CPP_UNSIGNED_IDX))+2*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); // long int is the same as long optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_FLOAT_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(3==C_TYPE::FLOAT__COMPLEX-C_TYPE::FLOAT); set_C_canonical_type_representation(src,i,C_TYPE::FLOAT+3*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_COMPLEX_IDX)); break; case C99_CPP_DOUBLE_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(1==C_TYPE::LDOUBLE-C_TYPE::DOUBLE); BOOST_STATIC_ASSERT(3==C_TYPE::DOUBLE__COMPLEX-C_TYPE::DOUBLE); BOOST_STATIC_ASSERT(4==C_TYPE::LDOUBLE__COMPLEX-C_TYPE::DOUBLE); set_C_canonical_type_representation(src,i,C_TYPE::DOUBLE+optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)+3*optional_keyword(src,i,invariant_decl_scanner,C99_CPP_COMPLEX_IDX)); break; case C99_CPP_SIGNED_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_CHAR_IDX)) { set_C_canonical_type_representation(src,i,C_TYPE::SCHAR); break; } if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_SHORT_IDX)) set_C_canonical_type_representation(src,i,C_TYPE::SHRT); else{ BOOST_STATIC_ASSERT(2==C_TYPE::LONG-C_TYPE::INT); BOOST_STATIC_ASSERT(4==C_TYPE::LLONG-C_TYPE::INT); set_C_canonical_type_representation(src,i,C_TYPE::INT+2*optional_keyword_limit<2>(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); } // signed int is the same as signed optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_UNSIGNED_IDX: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_CHAR_IDX)) { set_C_canonical_type_representation(src,i,C_TYPE::UCHAR); break; } if (optional_keyword(src,i,invariant_decl_scanner,C99_CPP_SHORT_IDX)) set_C_canonical_type_representation(src,i,C_TYPE::USHRT); else{ BOOST_STATIC_ASSERT(2==C_TYPE::ULONG-C_TYPE::UINT); BOOST_STATIC_ASSERT(4==C_TYPE::ULLONG-C_TYPE::UINT); set_C_canonical_type_representation(src,i,C_TYPE::UINT+2*optional_keyword_limit<2>(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); } // unsigned int is the same as unsigned optional_keyword(src,i,invariant_decl_scanner,C99_CPP_INT_IDX); break; case C99_CPP_COMPLEX_IDX: switch(optional_keyword_choice(src,i,invariant_decl_scanner,C99_CPP_FLOAT_IDX,C99_CPP_DOUBLE_IDX)) { case 0: if (!have_warned_about_Complex) { message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("type-specifier-sequence has _Complex without either float or double (C99 6.7.3p4)"); zcc_errors.inc_error(); have_warned_about_Complex = true; } // remove the unusable token src.DeleteIdx<0>(i--); break; case 1: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; set_C_canonical_type_representation(src,i,C_TYPE::FLOAT__COMPLEX); break; case 2: src.c_array<0>()[i].flags |= PARSE_PRIMARY_TYPE; BOOST_STATIC_ASSERT(1==C_TYPE::LDOUBLE__COMPLEX-C_TYPE::DOUBLE__COMPLEX); set_C_canonical_type_representation(src,i,C_TYPE::DOUBLE__COMPLEX+optional_keyword(src,i,invariant_decl_scanner,C99_CPP_LONG_IDX)); // break; } // break; } invariant_decl_scanner.DeleteIdx(0); ++i; } while(!invariant_decl_scanner.empty()); // defer handling thread_local, typedef restrictions } } while(src.size<0>()> ++i); } //! \todo generalize -- function pointer parameter target, functor target static size_t _count_identifiers(const parse_tree& src) { size_t count_id = 0; if (src.index_tokens[0].token.first && C_TESTFLAG_IDENTIFIER==src.index_tokens[0].flags) ++count_id; if (src.index_tokens[1].token.first && C_TESTFLAG_IDENTIFIER==src.index_tokens[1].flags) ++count_id; size_t i = src.size<0>(); while(0<i) count_id += _count_identifiers(src.data<0>()[--i]); i = src.size<1>(); while(0<i) count_id += _count_identifiers(src.data<1>()[--i]); i = src.size<2>(); while(0<i) count_id += _count_identifiers(src.data<2>()[--i]); return count_id; } static bool is_naked_parentheses_pair(const parse_tree& src) { return robust_token_is_char<'('>(src.index_tokens[0].token) && robust_token_is_char<')'>(src.index_tokens[1].token) #ifndef NDEBUG && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename #endif && src.empty<1>() && src.empty<2>(); } static bool is_naked_brace_pair(const parse_tree& src) { return robust_token_is_char<'{'>(src.index_tokens[0].token) && robust_token_is_char<'}'>(src.index_tokens[1].token) #ifndef NDEBUG && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename #endif && src.empty<1>() && src.empty<2>(); } static bool is_naked_bracket_pair(const parse_tree& src) { return robust_token_is_char<'['>(src.index_tokens[0].token) && robust_token_is_char<']'>(src.index_tokens[1].token) #ifndef NDEBUG && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename #endif && src.empty<1>() && src.empty<2>(); } static bool is_nonempty_naked_pair(const parse_tree& src) { return !src.empty<0>() && (is_naked_parentheses_pair(src) || is_naked_brace_pair(src) || is_naked_bracket_pair(src)); } #ifndef NDEBUG static bool is_array_deref_strict(const parse_tree& src) { return robust_token_is_char<'['>(src.index_tokens[0].token) && robust_token_is_char<']'>(src.index_tokens[1].token) && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename && 1==src.size<0>() && (PARSE_EXPRESSION & src.data<0>()->flags) // content of [ ] && 1==src.size<1>() && (PARSE_POSTFIX_EXPRESSION & src.data<1>()->flags) // prefix arg of [ ] && src.empty<2>(); } #endif static bool is_array_deref(const parse_tree& src) { return robust_token_is_char<'['>(src.index_tokens[0].token) && robust_token_is_char<']'>(src.index_tokens[1].token) #ifndef NDEBUG && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename #endif && 1==src.size<0>() && (PARSE_EXPRESSION & src.data<0>()->flags) // content of [ ] && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) // prefix arg of [ ] && src.empty<2>(); } #define C99_UNARY_SUBTYPE_PLUS 1 #define C99_UNARY_SUBTYPE_NEG 2 #define C99_UNARY_SUBTYPE_DEREF 3 #define C99_UNARY_SUBTYPE_ADDRESSOF 4 #define C99_UNARY_SUBTYPE_NOT 5 #define C99_UNARY_SUBTYPE_COMPL 6 #define C99_UNARY_SUBTYPE_SIZEOF 7 // extensions #define ZCC_UNARY_SUBTYPE_LINKAGE 8 template<char c> static bool is_C99_unary_operator_expression(const parse_tree& src) { return robust_token_is_char<c>(src.index_tokens[0].token) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<2>() && (PARSE_CAST_EXPRESSION & src.data<2>()->flags); } static bool is_CPP_logical_NOT_expression(const parse_tree& src) { return (robust_token_is_char<'!'>(src.index_tokens[0].token) || robust_token_is_string<3>(src.index_tokens[0].token,"not")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<2>() && (PARSE_CAST_EXPRESSION & src.data<2>()->flags); } static bool is_CPP_bitwise_complement_expression(const parse_tree& src) { return (robust_token_is_char<'~'>(src.index_tokens[0].token) || robust_token_is_string<5>(src.index_tokens[0].token,"compl")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<2>() && (PARSE_CAST_EXPRESSION & src.data<2>()->flags); } static bool is_CPP0X_typeid_expression(const parse_tree& src) { return (robust_token_is_string<6>(src.index_tokens[0].token,"typeid")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && ((PARSE_EXPRESSION | PARSE_TYPE) & src.data<2>()->flags) && src.type_code.is_type<C_TYPE::TYPEINFO>() && (src.type_code.qualifier<0>() & (type_spec::lvalue | type_spec::_const))==(type_spec::lvalue | type_spec::_const); } #ifndef NDEBUG static bool is_C99_CPP_sizeof_expression(const parse_tree& src) { return (robust_token_is_string<6>(src.index_tokens[0].token,"sizeof")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && ((PARSE_EXPRESSION | PARSE_TYPE) & src.data<2>()->flags); // && 1==src.size<2>() && ((PARSE_UNARY_EXPRESSION | PARSE_TYPE) & src.data<2>()->flags); } static bool is_ZCC_linkage_expression(const parse_tree& src) { return (robust_token_is_string<13>(src.index_tokens[0].token,"__zcc_linkage")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>(); // && 1==src.size<2>() && ((PARSE_EXPRESSION | PARSE_TYPE) & src.data<2>()->flags); // && 1==src.size<2>() && ((PARSE_UNARY_EXPRESSION | PARSE_TYPE) & src.data<2>()->flags); } #endif #define C99_MULT_SUBTYPE_DIV 1 #define C99_MULT_SUBTYPE_MOD 2 #define C99_MULT_SUBTYPE_MULT 3 BOOST_STATIC_ASSERT(C99_UNARY_SUBTYPE_DEREF==C99_MULT_SUBTYPE_MULT); #ifndef NDEBUG static bool is_C99_mult_operator_expression(const parse_tree& src) { return (robust_token_is_char<'/'>(src.index_tokens[0].token) || robust_token_is_char<'%'>(src.index_tokens[0].token) || robust_token_is_char<'*'>(src.index_tokens[0].token)) && src.index_tokens[0].src_filename && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_MULT_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_PM_EXPRESSION & src.data<2>()->flags); } #endif template<char c> static bool is_C99_mult_operator_expression(const parse_tree& src) { return robust_token_is_char<c>(src.index_tokens[0].token) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_MULT_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_PM_EXPRESSION & src.data<2>()->flags); } #define C99_ADD_SUBTYPE_PLUS 1 #define C99_ADD_SUBTYPE_MINUS 2 BOOST_STATIC_ASSERT(C99_UNARY_SUBTYPE_PLUS==C99_ADD_SUBTYPE_PLUS); BOOST_STATIC_ASSERT(C99_UNARY_SUBTYPE_NEG==C99_ADD_SUBTYPE_MINUS); #ifndef NDEBUG static bool is_C99_add_operator_expression(const parse_tree& src) { return (robust_token_is_char<'+'>(src.index_tokens[0].token) || robust_token_is_char<'-'>(src.index_tokens[0].token)) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_ADD_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_MULT_EXPRESSION & src.data<2>()->flags); } #endif template<char c> static bool is_C99_add_operator_expression(const parse_tree& src) { return robust_token_is_char<c>(src.index_tokens[0].token) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_ADD_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_MULT_EXPRESSION & src.data<2>()->flags); } #define C99_SHIFT_SUBTYPE_LEFT 1 #define C99_SHIFT_SUBTYPE_RIGHT 2 static bool is_C99_shift_expression(const parse_tree& src) { return (robust_token_is_string<2>(src.index_tokens[0].token,"<<") || robust_token_is_string<2>(src.index_tokens[0].token,">>")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_SHIFT_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_ADD_EXPRESSION & src.data<2>()->flags); } #define C99_RELATION_SUBTYPE_LT 1 #define C99_RELATION_SUBTYPE_GT 2 #define C99_RELATION_SUBTYPE_LTE 3 #define C99_RELATION_SUBTYPE_GTE 4 static bool is_C99_relation_expression(const parse_tree& src) { return (robust_token_is_char<'<'>(src.index_tokens[0].token) || robust_token_is_char<'>'>(src.index_tokens[0].token) || robust_token_is_string<2>(src.index_tokens[0].token,"<=") || robust_token_is_string<2>(src.index_tokens[0].token,">=")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_RELATIONAL_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_SHIFT_EXPRESSION & src.data<2>()->flags); } #define C99_EQUALITY_SUBTYPE_EQ 1 #define C99_EQUALITY_SUBTYPE_NEQ 2 static bool is_C99_equality_expression(const parse_tree& src) { return (robust_token_is_string<2>(src.index_tokens[0].token,"==") || robust_token_is_string<2>(src.index_tokens[0].token,"!=")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_EQUALITY_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_RELATIONAL_EXPRESSION & src.data<2>()->flags); } static bool is_CPP_equality_expression(const parse_tree& src) { return (robust_token_is_string<2>(src.index_tokens[0].token,"==") || robust_token_is_string<2>(src.index_tokens[0].token,"!=") || robust_token_is_string<6>(src.index_tokens[0].token,"not_eq")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); // && 1==src.size<1>() && (PARSE_EQUALITY_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_RELATIONAL_EXPRESSION & src.data<2>()->flags); } static bool is_C99_bitwise_AND_expression(const parse_tree& src) { return ( robust_token_is_char<'&'>(src.index_tokens[0].token) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_BITAND_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_EQUALITY_EXPRESSION & src.data<2>()->flags)); } static bool is_CPP_bitwise_AND_expression(const parse_tree& src) { return ( (robust_token_is_char<'&'>(src.index_tokens[0].token) || robust_token_is_string<6>(src.index_tokens[0].token,"bitand")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_BITAND_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_EQUALITY_EXPRESSION & src.data<2>()->flags)); } static bool is_C99_bitwise_XOR_expression(const parse_tree& src) { return ( robust_token_is_char<'^'>(src.index_tokens[0].token) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_BITXOR_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_BITAND_EXPRESSION & src.data<2>()->flags)); } static bool is_CPP_bitwise_XOR_expression(const parse_tree& src) { return ( (robust_token_is_char<'^'>(src.index_tokens[0].token) || robust_token_is_string<3>(src.index_tokens[0].token,"xor")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_BITXOR_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_BITAND_EXPRESSION & src.data<2>()->flags)); } static bool is_C99_bitwise_OR_expression(const parse_tree& src) { return ( robust_token_is_char<'|'>(src.index_tokens[0].token) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_BITOR_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_BITXOR_EXPRESSION & src.data<2>()->flags)); } static bool is_CPP_bitwise_OR_expression(const parse_tree& src) { return ( (robust_token_is_char<'|'>(src.index_tokens[0].token) || robust_token_is_string<5>(src.index_tokens[0].token,"bitor")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_BITOR_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_BITXOR_EXPRESSION & src.data<2>()->flags)); } static bool is_C99_logical_AND_expression(const parse_tree& src) { return ( robust_token_is_string<2>(src.index_tokens[0].token,"&&") #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_LOGICAND_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_BITOR_EXPRESSION & src.data<2>()->flags)); } static bool is_CPP_logical_AND_expression(const parse_tree& src) { return ( (robust_token_is_string<2>(src.index_tokens[0].token,"&&") || robust_token_is_string<3>(src.index_tokens[0].token,"and")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_LOGICAND_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_BITOR_EXPRESSION & src.data<2>()->flags)); } static bool is_C99_logical_OR_expression(const parse_tree& src) { return ( robust_token_is_string<2>(src.index_tokens[0].token,"||") #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_LOGICOR_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_LOGICAND_EXPRESSION & src.data<2>()->flags)); } static bool is_CPP_logical_OR_expression(const parse_tree& src) { return ( (robust_token_is_string<2>(src.index_tokens[0].token,"||") || robust_token_is_string<2>(src.index_tokens[0].token,"or")) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<1>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags)); // && 1==src.size<1>() && (PARSE_LOGICOR_EXPRESSION & src.data<1>()->flags) // && 1==src.size<2>() && (PARSE_LOGICAND_EXPRESSION & src.data<2>()->flags)); } #ifndef NDEBUG static bool is_C99_conditional_operator_expression_strict(const parse_tree& src) { return robust_token_is_char<'?'>(src.index_tokens[0].token) && robust_token_is_char<':'>(src.index_tokens[1].token) && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename && 1==src.size<0>() && (PARSE_EXPRESSION & src.data<2>()->flags) && 1==src.size<1>() && (PARSE_LOGICOR_EXPRESSION & src.data<2>()->flags) && 1==src.size<2>() && (PARSE_CONDITIONAL_EXPRESSION & src.data<2>()->flags); } #endif static bool is_C99_conditional_operator_expression(const parse_tree& src) { return robust_token_is_char<'?'>(src.index_tokens[0].token) && robust_token_is_char<':'>(src.index_tokens[1].token) #ifndef NDEBUG && src.index_tokens[0].src_filename && src.index_tokens[1].src_filename #endif && 1==src.size<0>() && (PARSE_EXPRESSION & src.data<2>()->flags) && 1==src.size<1>() && (PARSE_EXPRESSION & src.data<2>()->flags) && 1==src.size<2>() && (PARSE_EXPRESSION & src.data<2>()->flags); } static bool is_C99_anonymous_specifier(const parse_tree& src,const char* const spec_name) { if ( robust_token_is_string(src.index_tokens[0].token,spec_name) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && !src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && is_naked_brace_pair(*src.data<2>())) return true; return false; } static bool is_C99_named_specifier(const parse_tree& src,const char* const spec_name) { if ( robust_token_is_string(src.index_tokens[0].token,spec_name) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && src.empty<2>()) return true; return false; } static bool is_C99_named_specifier_definition(const parse_tree& src,const char* const spec_name) { if ( robust_token_is_string(src.index_tokens[0].token,spec_name) #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && is_naked_brace_pair(*src.data<2>())) return true; return false; } static bool is_C99_named_specifier_definitionlike(const parse_tree& src) { if ( NULL!=src.index_tokens[0].token.first #ifndef NDEBUG && src.index_tokens[0].src_filename #endif && src.index_tokens[1].token.first && src.empty<0>() && src.empty<1>() && 1==src.size<2>() && is_naked_brace_pair(*src.data<2>())) return true; return false; } static bool C99_looks_like_identifier(const parse_tree& x) { if (!x.is_atomic()) return false; if (PARSE_TYPE & x.flags) return false; if (C99_echo_reserved_keyword(x.index_tokens[0].token.first,x.index_tokens[0].token.second)) return false; return C_TESTFLAG_IDENTIFIER & x.index_tokens[0].flags; } static bool CPP_looks_like_identifier(const parse_tree& x) { if (!x.is_atomic()) return false; if (PARSE_TYPE & x.flags) return false; if (CPP_echo_reserved_keyword(x.index_tokens[0].token.first,x.index_tokens[0].token.second)) return false; return C_TESTFLAG_IDENTIFIER & x.index_tokens[0].flags; } //! \throw std::bad_alloc() static void make_target_postfix_arg(parse_tree& src,size_t& offset,const size_t i,const size_t j) { parse_tree* tmp = (0==offset ? _new_buffer_nonNULL_throws<parse_tree>(1) : _new_buffer<parse_tree>(1)); if (!tmp) { // need that slack space now src.DeleteNSlotsAt<0>(offset,src.size<0>()-offset); offset = 0; tmp = _new_buffer_nonNULL_throws<parse_tree>(1); } src.c_array<0>()[j].OverwriteInto(*tmp); src.c_array<0>()[i].fast_set_arg<2>(tmp); } //! \throw std::bad_alloc() static void C99_notice_struct_union_enum(parse_tree& src) { assert(!src.empty<0>()); size_t i = 0; size_t offset = 0; while(i+offset<src.size<0>()) { const char* const tmp2 = robust_token_is_string<4>(src.data<0>()[i],"enum") ? "enum" : robust_token_is_string<6>(src.data<0>()[i],"struct") ? "struct" : robust_token_is_string<5>(src.data<0>()[i],"union") ? "union" : 0; if (tmp2) { if (1>=src.size<0>()-(i+offset)) { // unterminated declaration //! \test zcc/decl.C99/Error_enum_truncate1.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(tmp2); INC_INFORM(" specifier cut off by end of scope ("); INFORM(strcmp(tmp2,"enum") ? "C99 6.7.2.1p1)" : "C99 6.7.2.2p1)"); zcc_errors.inc_error(); // remove from parse src.DestroyNAtAndRotateTo<0>(1,i,src.size<0>()-offset); offset += 1; continue; }; if (is_naked_brace_pair(src.data<0>()[i+1])) { // anonymous: postfix arg {...} make_target_postfix_arg(src,offset,i,i+1); src.DestroyNAtAndRotateTo<0>(1,i+1,src.size<0>()-offset); offset += 1; assert(is_C99_anonymous_specifier(src.data<0>()[i],tmp2)); continue; }; if (!C99_looks_like_identifier(src.data<0>()[i+1])) { //! \test zcc/decl.C99/Error_enum_truncate2.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(tmp2); INC_INFORM(" neither specifier nor definition ("); INFORM(strcmp(tmp2,"enum") ? "C99 6.7.2.1p1)" : "C99 6.7.2.2p1)"); zcc_errors.inc_error(); // remove from parse src.DestroyNAtAndRotateTo<0>(1,i,src.size<0>()-offset); offset += 1; continue; }; if (2<src.size<0>()-(i+offset) && is_naked_brace_pair(src.data<0>()[i+2])) { make_target_postfix_arg(src,offset,i,i+2); src.c_array<0>()[i].grab_index_token_from<1,0>(src.c_array<0>()[i+1]); src.c_array<0>()[i].grab_index_token_location_from<1,0>(src.data<0>()[i+1]); src.c_array<0>()[i+1].clear(); src.DestroyNAtAndRotateTo<0>(2,i+1,src.size<0>()-offset); offset += 2; assert(is_C99_named_specifier_definition(src.data<0>()[i],tmp2)); continue; }; src.c_array<0>()[i].grab_index_token_from<1,0>(src.c_array<0>()[i+1]); src.c_array<0>()[i].grab_index_token_location_from<1,0>(src.data<0>()[i+1]); src.c_array<0>()[i+1].clear(); src.DestroyNAtAndRotateTo<0>(1,i+1,src.size<0>()-offset); offset += 1; assert(is_C99_named_specifier(src.data<0>()[i],tmp2)); continue; } ++i; }; if (0<offset) src.DeleteNSlotsAt<0>(offset,src.size<0>()-offset); std::for_each(src.begin<0>(),src.end<0>(),conditional_action<bool (*)(const parse_tree&),void (*)(parse_tree&)>(is_nonempty_naked_pair,C99_notice_struct_union_enum)); } //! \throw std::bad_alloc() static void CPP_notice_class_struct_union_enum(parse_tree& src) { assert(!src.empty<0>()); size_t i = 0; size_t offset = 0; while(i+offset<src.size<0>()) { const char* const tmp2 = robust_token_is_string<4>(src.data<0>()[i],"enum") ? "enum" : robust_token_is_string<6>(src.data<0>()[i],"struct") ? "struct" : robust_token_is_string<5>(src.data<0>()[i],"union") ? "union" : robust_token_is_string<5>(src.data<0>()[i],"class") ? "class" : 0; if (tmp2) { if (1>=src.size<0>()-(i+offset)) { // unterminated declaration //! \test zcc/decl.C99/Error_enum_truncate1.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(tmp2); INC_INFORM(" specifier cut off by end of scope ("); INFORM(strcmp(tmp2,"enum") ? "C++98 9p1)" : "C++98 7.2p1)"); zcc_errors.inc_error(); // remove from parse src.DestroyNAtAndRotateTo<0>(1,i,src.size<0>()-offset); offset += 1; continue; }; if (is_naked_brace_pair(src.data<0>()[i+1])) { // anonymous: postfix arg {...} make_target_postfix_arg(src,offset,i,i+1); src.DestroyNAtAndRotateTo<0>(1,i+1,src.size<0>()-offset); offset += 1; assert(is_C99_anonymous_specifier(src.data<0>()[i],tmp2)); continue; }; if (!CPP_looks_like_identifier(src.data<0>()[i+1])) { //! \test zcc/decl.C99/Error_enum_truncate2.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(tmp2); INC_INFORM(" neither specifier nor definition ("); INFORM(strcmp(tmp2,"enum") ? "C++98 9p1)" : "C++98 7.2p1)"); zcc_errors.inc_error(); // remove from parse src.DestroyNAtAndRotateTo<0>(1,i,src.size<0>()-offset); offset += 1; continue; }; if (2<src.size<0>()-(i+offset) && is_naked_brace_pair(src.data<0>()[i+2])) { make_target_postfix_arg(src,offset,i,i+2); src.c_array<0>()[i].grab_index_token_from<1,0>(src.c_array<0>()[i+1]); src.c_array<0>()[i].grab_index_token_location_from<1,0>(src.data<0>()[i+1]); src.c_array<0>()[i+1].clear(); src.DestroyNAtAndRotateTo<0>(2,i+1,src.size<0>()-offset); offset += 2; assert(is_C99_named_specifier_definition(src.data<0>()[i],tmp2)); continue; }; src.c_array<0>()[i].grab_index_token_from<1,0>(src.c_array<0>()[i+1]); src.c_array<0>()[i].grab_index_token_location_from<1,0>(src.data<0>()[i+1]); src.c_array<0>()[i+1].clear(); src.DestroyNAtAndRotateTo<0>(1,i+1,src.size<0>()-offset); offset += 1; assert(is_C99_named_specifier(src.data<0>()[i],tmp2)); continue; } ++i; }; if (0<offset) src.DeleteNSlotsAt<0>(offset,src.size<0>()-offset); std::for_each(src.begin<0>(),src.end<0>(),conditional_action<bool (*)(const parse_tree&),void (*)(parse_tree&)>(is_nonempty_naked_pair,CPP_notice_class_struct_union_enum)); } bool convert_to(umaxint& dest,const C_PPIntCore& src) { assert(8==src.radix || 10==src.radix || 16==src.radix); assert(src.ptr && 0<src.digit_span); const unsigned_var_int alt_radix(src.radix,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); unsigned_var_int strict_ub(0,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); const char* target = src.ptr; size_t target_len = src.digit_span; strict_ub.set_max(); strict_ub /= alt_radix; // internally zero could be generated as a decimal rather than an octal integer literal if (1<target_len) { // Duff's device switch(src.radix) { case 16: ++target; if (0== --target_len) return false; // leading 0x case 8: ++target; if (0== --target_len) return false; // leading 0 } } const char* const end = target+target_len; dest.set_bitcount(VM_MAX_BIT_PLATFORM); dest.clear(); dest += InterpretHexadecimalDigit(*target); while(++target!=end) { if (dest>strict_ub) return false; dest *= alt_radix; dest += InterpretHexadecimalDigit(*target); }; return true; } static const enum_def* is_noticed_enumerator(const parse_tree& x,const type_system& types) { const enum_def* tmp = NULL; if (x.is_atomic() && (C_TESTFLAG_IDENTIFIER & x.index_tokens[0].flags)) tmp = types.get_enum_def(x.type_code.base_type_index); return tmp; } // forward-declare to handle recursion static bool C99_intlike_literal_to_VM(umaxint& dest, const parse_tree& src SIG_CONST_TYPES); static bool _C99_intlike_literal_to_VM(umaxint& dest, const parse_tree& src SIG_CONST_TYPES) { assert(C_TYPE::INTEGERLIKE!=src.type_code.base_type_index); if ( virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps] && is_C99_add_operator_expression<'-'>(src)) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); if (old.is_signed) { const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); if (lhs.is_signed) { umaxint lhs_int; umaxint rhs_int; if ( C99_intlike_literal_to_VM(lhs_int,*src.data<1>() ARG_TYPES) && C99_intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES)) { const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); assert(old.bitcount>rhs.bitcount || rhs.is_signed); if (lhs_int.test(lhs.bitcount-1) && (!rhs.is_signed || !rhs_int.test(rhs.bitcount-1))) { // lhs -, rhs +: could land exactly on INT_MIN/LONG_MIN/LLONG_MIN target_machine->signed_additive_inverse(lhs_int,lhs.machine_type); lhs_int += rhs_int; lhs_int -= 1; if (lhs_int==target_machine->signed_max(old.machine_type)) { lhs_int += 1; dest = lhs_int; return true; // signed additive inverse on twos-complement nontrapping machines has INT_MIN/LONG_MIN/LLONG_MIN as a fixed point } } } } } } if (!src.is_atomic() || !(PARSE_PRIMARY_EXPRESSION & src.flags)) return false; if (C_TESTFLAG_CHAR_LITERAL & src.index_tokens[0].flags) { dest = EvalCharacterLiteral(src.index_tokens[0].token.first,src.index_tokens[0].token.second); dest.set_bitcount(VM_MAX_BIT_PLATFORM); return true; } // creative interpretation: enumerators as integer-like literals if (is_noticed_enumerator(src,types)) { const type_system::enumerator_info* const tmp2 = types.get_enumerator(src.index_tokens[0].token.first); assert(tmp2); dest = tmp2->second.first.third; return true; } if (!(C_TESTFLAG_INTEGER & src.index_tokens[0].flags)) return false; C_PPIntCore tmp; ZAIMONI_PASSTHROUGH_ASSERT(C_PPIntCore::is(src.index_tokens[0].token.first,src.index_tokens[0].token.second,tmp)); ZAIMONI_PASSTHROUGH_ASSERT(convert_to(dest,tmp)); return true; } static bool _CPP_intlike_literal_to_VM(umaxint& dest, const parse_tree& src) { //! \todo: similar code for handling LLONG_MIN as above. Need that only for zcc; can't test in preprocessor as the true reserved word won't make it this far. if (!src.is_atomic()) return false; // intercept true, false if (token_is_string<4>(src.index_tokens[0].token,"true")) { dest.set_bitcount(VM_MAX_BIT_PLATFORM); dest = 1; return true; } else if (token_is_string<5>(src.index_tokens[0].token,"false")) { dest.set_bitcount(VM_MAX_BIT_PLATFORM); dest.clear(); return true; }; return false; } // return value: literal to parse, whether additive inverse applies static POD_pair<const parse_tree*,bool> _find_intlike_literal(const parse_tree* src SIG_CONST_TYPES) { assert(src); POD_pair<const parse_tree*,bool> ret = {src,false}; while(converts_to_integer(ret.first->type_code ARG_TYPES)) { if (is_C99_unary_operator_expression<'-'>(*ret.first)) { ret.second = !ret.second; ret.first = ret.first->data<2>(); assert(ret.first); } else if (is_C99_unary_operator_expression<'+'>(*ret.first)) { ret.first = ret.first->data<2>(); assert(ret.first); } else break; }; return ret; } // use this typedef to cope with signature varying by build typedef bool (intlike_literal_to_VM_func)(umaxint& dest, const parse_tree& src SIG_CONST_TYPES); static bool C99_intlike_literal_to_VM(umaxint& dest, const parse_tree& src SIG_CONST_TYPES) { const POD_pair<const parse_tree*,bool> actual = _find_intlike_literal(&src ARG_TYPES); if (C_TYPE::INTEGERLIKE==actual.first->type_code.base_type_index) return false; if (!_C99_intlike_literal_to_VM(dest,*actual.first ARG_TYPES)) return false; if (actual.second) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); if (old.is_signed) target_machine->signed_additive_inverse(dest,old.machine_type); else target_machine->unsigned_additive_inverse(dest,old.machine_type); }; return true; } static bool CPP_intlike_literal_to_VM(umaxint& dest, const parse_tree& src SIG_CONST_TYPES) { const POD_pair<const parse_tree*,bool> actual = _find_intlike_literal(&src ARG_TYPES); if (!_CPP_intlike_literal_to_VM(dest,*actual.first)) { if (C_TYPE::INTEGERLIKE==actual.first->type_code.base_type_index) return false; if (!_C99_intlike_literal_to_VM(dest,*actual.first ARG_TYPES)) return false; }; if (actual.second) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); if (old.is_signed) target_machine->signed_additive_inverse(dest,old.machine_type); else target_machine->unsigned_additive_inverse(dest,old.machine_type); }; return true; } /** decides whether the given entry is a null pointer constant * \return 1 : yes, null pointer constant * \return 0 : no, not null pointer constant * \return -1 : can't decide quickly whether this is a null * pointer constant */ static int is_null_pointer_constant(const parse_tree& src,intlike_literal_to_VM_func& intlike_literal_to_VM SIG_CONST_TYPES) { if (!converts_to_integerlike(src.type_code ARG_TYPES)) return 0; umaxint tmp; if (intlike_literal_to_VM(tmp,src ARG_TYPES)) return tmp==0; return -1; } static void _label_one_literal(parse_tree& src,const type_system& types) { assert(src.is_atomic()); if ((C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_STRING_LITERAL | C_TESTFLAG_PP_NUMERAL) & src.index_tokens[0].flags) { src.flags |= (PARSE_PRIMARY_EXPRESSION | parse_tree::CONSTANT_EXPRESSION); if (C_TESTFLAG_STRING_LITERAL==src.index_tokens[0].flags) { src.type_code.set_type(C_TYPE::CHAR); src.type_code.make_C_array(LengthOfCStringLiteral(src.index_tokens[0].token.first,src.index_tokens[0].token.second)); return; } else if (C_TESTFLAG_CHAR_LITERAL==src.index_tokens[0].flags) { // C99 6.4.4.4p10: the type of a character literal is int // C++0X 2.13.4p1: the type of a single character literal is char // but the type of a multiple-character literal is int // unfortunately, we don't have the language here. Go with // C++ rules, and patch up C elsewhere src.type_code.set_type(LengthOfCCharLiteral(src.index_tokens[0].token.first,src.index_tokens[0].token.second) ? C_TYPE::CHAR : C_TYPE::INT); return; }; assert(C_TESTFLAG_PP_NUMERAL & src.index_tokens[0].flags); C_REALITY_CHECK_PP_NUMERAL_FLAGS(src.index_tokens[0].flags); if (C_TESTFLAG_INTEGER & src.index_tokens[0].flags) { src.type_code.set_type(C_TYPE::INTEGERLIKE); C_PPIntCore parse_tmp; ZAIMONI_PASSTHROUGH_ASSERT(C_PPIntCore::is(src.index_tokens[0].token.first,src.index_tokens[0].token.second,parse_tmp)); umaxint tmp; const unsigned char type_hint = parse_tmp.hinted_type; const bool no_signed = 1==type_hint%2; const bool no_unsigned = !no_signed && 10==parse_tmp.radix; if (convert_to(tmp,parse_tmp)) { // failover to IntegerLike if won't convert size_t i = 0; do switch(types.int_priority[i]) { case C_TYPE::INT: if (no_signed || C_PPIntCore::L<=type_hint) continue; if (tmp>target_machine->signed_max<virtual_machine::std_int_int>()) continue; src.type_code.base_type_index = C_TYPE::INT; return; case C_TYPE::UINT: if (no_unsigned || C_PPIntCore::L<=type_hint) continue; if (tmp>target_machine->unsigned_max<virtual_machine::std_int_int>()) continue; src.type_code.base_type_index = C_TYPE::UINT; return; case C_TYPE::LONG: if (no_signed || C_PPIntCore::LL<=type_hint) continue; if (tmp>target_machine->signed_max<virtual_machine::std_int_long>()) continue; src.type_code.base_type_index = C_TYPE::LONG; return; case C_TYPE::ULONG: if (no_unsigned || C_PPIntCore::LL<=type_hint) continue; if (tmp>target_machine->unsigned_max<virtual_machine::std_int_long>()) continue; src.type_code.base_type_index = C_TYPE::ULONG; return; case C_TYPE::LLONG: if (no_signed) continue; if (tmp>target_machine->signed_max<virtual_machine::std_int_long_long>()) continue; src.type_code.base_type_index = C_TYPE::LLONG; return; case C_TYPE::ULLONG: if (no_unsigned) continue; if (tmp>target_machine->unsigned_max<virtual_machine::std_int_long_long>()) continue; src.type_code.base_type_index = C_TYPE::ULLONG; return; } while(types.int_priority_size > ++i); }; assert(C_TYPE::INTEGERLIKE==src.type_code.base_type_index); // integer literal has no useful type to represent it //! \test if.C99/Error_control22.hpp, if.C99/Error_control22.h //! \test if.C99/Error_control23.hpp, if.C99/Error_control23.h src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(src); INC_INFORM(" cannot be represented as "); INC_INFORM(no_unsigned ? "signed long long" : "unsigned long long"); INFORM(" (C99 6.4.4.1p5/C++0x 2.13.1p3)"); zcc_errors.inc_error(); } else{ //! \todo --do-what-i-mean should check for floating-point numerals that convert exactly to integers src.type_code.set_type( (C_TESTFLAG_L & src.index_tokens[0].flags) ? C_TYPE::LDOUBLE : (C_TESTFLAG_F & src.index_tokens[0].flags) ? C_TYPE::FLOAT : C_TYPE::DOUBLE); } } } void C99_literal_is_legal(const char* const x,const size_t x_len,const lex_flags flags,const char* src_filename,size_t lineno,const type_system& types) { parse_tree tmp; tmp.clear(); tmp.index_tokens[0].token.first = x; tmp.index_tokens[0].token.second = x_len; tmp.index_tokens[0].flags = flags; tmp.index_tokens[0].src_filename = src_filename; tmp.index_tokens[0].logical_line.first = lineno; _label_one_literal(tmp,types); } // C and C++ agree that literals are constant primary expressions // note that on some huge-char platforms not all strings can be concatenated safely in C // we almost certainly have have memory problems if there are non-concatenated strings around // a psuedo-concatenated string literal has string literals for both of its indexes static void _label_literals(parse_tree& src,const type_system& types) { std::pair<size_t,size_t> str_span(SIZE_MAX,SIZE_MAX); size_t str_count = 0; size_t i = src.size<0>(); while(0<i) { if (!src.data<0>()[--i].is_atomic()) continue; _label_one_literal(src.c_array<0>()[i],types); if (C_TESTFLAG_STRING_LITERAL==src.data<0>()[i].index_tokens[0].flags) { if (SIZE_MAX==str_span.first) str_span.second = i; str_span.first = i; ++str_count; } }; while((assert(str_count<=(str_span.second-str_span.first)+1),2<=str_count) && (2<str_count || 1==str_span.second-str_span.first)) { bool want_first_slideup = false; bool want_second_slidedown = false; bool RAMfail = false; if (C_TESTFLAG_STRING_LITERAL==src.data<0>()[str_span.first+1].index_tokens[0].flags) { if (src.size<0>()<=str_span.second+2 || C_TESTFLAG_STRING_LITERAL!=src.data<0>()[str_span.first+2].index_tokens[0].flags) { // psuedo-concatenate // that this is still a constant primary expression, as we are just pretending that the string concatenation went through src.c_array<0>()[str_span.first].grab_index_token_from<1,0>(src.c_array<0>()[str_span.first+1]); src.DeleteIdx<0>(str_span.first+1); if (1>=(str_count -= 2)) break; str_span.first += 2; want_first_slideup = true; } else{ // more than two strings to psuedo-concatenate POD_pair<size_t,size_t> scan = {str_span.first,str_span.first+2}; while(src.size<0>()>scan.second+1 && C_TESTFLAG_STRING_LITERAL==src.data<0>()[scan.second+1].index_tokens[0].flags) ++scan.second; if (parse_tree::collapse_matched_pair(src,scan)) src.c_array<0>()[scan.first].flags |= (PARSE_PRIMARY_EXPRESSION | parse_tree::CONSTANT_EXPRESSION); else RAMfail = true; } } else{ want_first_slideup = true; ++str_span.first; --str_count; }; if (C_TESTFLAG_STRING_LITERAL==src.data<0>()[str_span.second-1].index_tokens[0].flags) { if (2<=str_span.second || C_TESTFLAG_STRING_LITERAL!=src.data<0>()[str_span.second-2].index_tokens[0].flags) { // psuedo-concatenate // this is still a constant primary expression, as we are just pretending that the string concatenation went through src.c_array<0>()[str_span.second-1].grab_index_token_from<1,0>(src.c_array<0>()[str_span.second]); src.DeleteIdx<0>(str_span.second); if (1>=(str_count -= 2)) break; str_span.second -= 2; want_second_slidedown = true; } else{ // more than two strings to psuedo-concatenate POD_pair<size_t,size_t> scan = {str_span.second-2,str_span.second}; while(0<scan.first && C_TESTFLAG_STRING_LITERAL==src.data<0>()[scan.first-1].index_tokens[0].flags) --scan.first; if (parse_tree::collapse_matched_pair(src,scan)) src.c_array<0>()[scan.first].flags |= (PARSE_PRIMARY_EXPRESSION | parse_tree::CONSTANT_EXPRESSION); // note: as current item was already typed properly, do not need to update else RAMfail = true; } } else{ if (1>=(--str_count)) break; want_second_slidedown = true; --str_span.second; } if (want_first_slideup) { while(C_TESTFLAG_STRING_LITERAL!=src.data<0>()[str_span.first].index_tokens[0].flags) { ++str_span.first; assert(str_span.second > str_span.first); }; RAMfail = false; } if (want_second_slidedown) { while(C_TESTFLAG_STRING_LITERAL!=src.data<0>()[str_span.second].index_tokens[0].flags) { --str_span.second; assert(str_span.first < str_span.second); }; RAMfail = false; } if (RAMfail) throw std::bad_alloc(); // couldn't do anything at all: stalled } } // returns true if and only if no errors static bool _this_vaguely_where_it_could_be_cplusplus(const parse_tree& src) { const size_t starting_errors = zcc_errors.err_count(); if (robust_token_is_string<4>(src.index_tokens[0].token,"this")) { message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("keyword this is allowed only within a non-static member function body or a constructor memory initializer (C++98 5.1p3)"); zcc_errors.inc_error(); }; size_t j = STATIC_SIZE(src._args); do { if (0== --j && src.index_tokens[0].token.first && src.index_tokens[1].token.first) { if (token_is_char<'('>(src.index_tokens[0].token) && token_is_char<')'>(src.index_tokens[1].token)) break; // need to parse to rule out constructor memory initializer if (token_is_char<'{'>(src.index_tokens[0].token) && token_is_char<'}'>(src.index_tokens[1].token)) break; // need to parse to rule out non-static member function } size_t i = src.size(j); while(0<i) { if (robust_token_is_string<4>(src.data(j)[--i].index_tokens[0].token,"this")) { message_header(src.data(j)[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("keyword this is allowed only within a non-static member function body or a constructor memory initializer (C++98 5.1p3)"); zcc_errors.inc_error(); }; } } while(0<j); return starting_errors==zcc_errors.err_count(); } // this handles: ( ), [ ], { } // the content of ( ), [ ], { } fills the zeroth argument array // C++ *sometimes* wants to match < > as well, but its approaches are...painful. Do that elsewhere // returns true if successful static bool _match_pairs(parse_tree& src) { assert(!src.empty<0>()); POD_pair<size_t,size_t> depth_parens = balanced_character_count<'(',')'>(src.data<0>(),src.size<0>()); // pre-scan POD_pair<size_t,size_t> depth_brackets = balanced_character_count<'[',']'>(src.data<0>(),src.size<0>()); // pre-scan POD_pair<size_t,size_t> depth_braces = balanced_character_count<'{','}'>(src.data<0>(),src.size<0>()); // pre-scan assert(depth_parens.first==depth_parens.second); assert(depth_brackets.first==depth_brackets.second); assert(depth_braces.first==depth_braces.second); if (0==depth_parens.first && 0==depth_brackets.first && 0==depth_braces.first) return true; autovalarray_ptr_throws<size_t> paren_stack(depth_parens.first); autovalarray_ptr_throws<size_t> bracket_stack(depth_brackets.first); autovalarray_ptr_throws<size_t> brace_stack(depth_braces.first); const size_t starting_errors = zcc_errors.err_count(); size_t paren_idx = 0; size_t bracket_idx = 0; size_t brace_idx = 0; size_t i = 0; //! \todo optimize this loop do { if (src.data<0>()[i].index_tokens[1].token.first) continue; if (token_is_char<')'>(src.data<0>()[i].index_tokens[0].token)) { assert(0<paren_idx); assert(0==bracket_idx || bracket_stack[bracket_idx-1]<paren_stack[paren_idx-1]); assert(0==brace_idx || brace_stack[brace_idx-1]<paren_stack[paren_idx-1]); const POD_pair<size_t,size_t> target = {paren_stack[--paren_idx],i}; if (!parse_tree::collapse_matched_pair(src,target)) throw std::bad_alloc(); i = paren_stack[paren_idx]; // do not suppress inner parentheses here, this only works for known expressions if (0==paren_idx && 1<src.size<0>()-i) { depth_parens = balanced_character_count<'(',')'>(src.data<0>()+i+1,src.size<0>()-(i+1)); assert(depth_parens.first==depth_parens.second); if (0==depth_parens.first && 0==depth_brackets.first && 0==depth_braces.first) return starting_errors==zcc_errors.err_count(); paren_stack.Shrink(depth_parens.first); } } else if (token_is_char<']'>(src.data<0>()[i].index_tokens[0].token)) { assert(0<bracket_idx); assert(0==paren_idx || paren_stack[paren_idx-1]<bracket_stack[bracket_idx-1]); assert(0==brace_idx || brace_stack[brace_idx-1]<bracket_stack[bracket_idx-1]); const POD_pair<size_t,size_t> target = {bracket_stack[--bracket_idx],i}; if (!parse_tree::collapse_matched_pair(src,target)) throw std::bad_alloc(); i = bracket_stack[bracket_idx]; // do not suppress inner parentheses here, this only works for known expressions if (0==bracket_idx && 1<src.size<0>()-i) { depth_brackets = balanced_character_count<'[',']'>(src.data<0>()+i+1,src.size<0>()-(i+1)); assert(depth_brackets.first==depth_brackets.second); if (0==depth_parens.first && 0==depth_brackets.first && 0==depth_braces.first) return starting_errors==zcc_errors.err_count(); bracket_stack.Shrink(depth_brackets.first); } } else if (token_is_char<'}'>(src.data<0>()[i].index_tokens[0].token)) { assert(0<brace_idx); assert(0==paren_idx || paren_stack[paren_idx-1]<brace_stack[brace_idx-1]); assert(0==bracket_idx || bracket_stack[bracket_idx-1]<brace_stack[brace_idx-1]); const POD_pair<size_t,size_t> target = {brace_stack[--brace_idx],i}; if (!parse_tree::collapse_matched_pair(src,target)) throw std::bad_alloc(); i = brace_stack[brace_idx]; if (0==brace_idx && 1<src.size<0>()-i) { depth_braces = balanced_character_count<'{','}'>(src.data<0>()+i+1,src.size<0>()-(i+1)); assert(depth_braces.first==depth_braces.second); if (0==depth_parens.first && 0==depth_brackets.first && 0==depth_braces.first) return starting_errors==zcc_errors.err_count(); brace_stack.Shrink(depth_braces.first); } } else if (token_is_char<'('>(src.data<0>()[i].index_tokens[0].token)) { assert(paren_stack.size()>paren_idx); paren_stack[paren_idx++] = i; } else if (token_is_char<'['>(src.data<0>()[i].index_tokens[0].token)) { assert(bracket_stack.size()>bracket_idx); bracket_stack[bracket_idx++] = i; } else if (token_is_char<'{'>(src.data<0>()[i].index_tokens[0].token)) { assert(brace_stack.size()>brace_idx); brace_stack[brace_idx++] = i; } // introduces sequence points; this causes errors if caught in brackets or parentheses // cannot test within preprocessor expression (trigger is intercepted earlier) else if (token_is_char<';'>(src.data<0>()[i].index_tokens[0].token)) { if (0<paren_idx || 0<bracket_idx) { const size_t nearest_break = (paren_idx<bracket_idx) ? bracket_idx : paren_idx; message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(" ; breaks intended balancing of "); INFORM(src.data<0>()[nearest_break].index_tokens[0].token.first[0]); zcc_errors.inc_error(); } }; } while(src.size<0>() > ++i); return starting_errors==zcc_errors.err_count(); } static bool C99_literal_converts_to_integer(const parse_tree& src) { if (!src.is_atomic()) return false; return ((C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_INTEGER) & src.index_tokens[0].flags); //! \todo --do-what-i-mean should try to identify floats that are really integers } static bool CPP_literal_converts_to_integer(const parse_tree& src) { if (!src.is_atomic()) return false; if (token_is_string<4>(src.index_tokens[0].token,"true") || token_is_string<5>(src.index_tokens[0].token,"false")) return true; return ((C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_INTEGER) & src.index_tokens[0].flags); //! \todo --do-what-i-mean should try to identify floats that are really integers } //! the returned parse_tree struct has no content; safe to use OvewriteInto on //! \throw std::bad_alloc() static zaimoni::Loki::CheckReturnDisallow<NULL,parse_tree*>::value_type repurpose_inner_parentheses(parse_tree& src) { if (1==src.size<0>() && is_naked_parentheses_pair(*src.data<0>())) { zaimoni::POD_autoarray_ptr<parse_tree> tmp = src.c_array<0>()->_args[0]; src.c_array<0>()->_args[0].NULLPtr(); src.c_array<0>()->destroy(); parse_tree* const tmp2 = src.c_array<0>(); src._args[0] = tmp; return tmp2; }; return _new_buffer_nonNULL_throws<parse_tree>(1); } static void cancel_inner_parentheses(parse_tree& src) { while(1==src.size<0>() && is_naked_parentheses_pair(*src.data<0>())) { zaimoni::POD_autoarray_ptr<parse_tree> tmp = src.c_array<0>()->_args[0]; src.c_array<0>()->_args[0].NULLPtr(); src.c_array<0>()->destroy(); free(src.c_array<0>()); src._args[0] = tmp; } } static void cancel_outermost_parentheses(parse_tree& src) { while(1==src.size<0>() && is_naked_parentheses_pair(src)) src.eval_to_arg<0>(0); } /*! * determines whether a context-driven primary expression is obviously one * * \param src target to inspect * * \return true iff ( ... ) expression was recognized * \throw std::bad_alloc only if 1==src.size<0>() and src.type_code.pointer_power<src.data<0>()->type_code.pointer_power */ static bool inspect_potential_paren_primary_expression(parse_tree& src) { if (!(PARSE_OBVIOUS & src.flags) && is_naked_parentheses_pair(src)) { // we're a naked parentheses pair cancel_inner_parentheses(src); const size_t content_length = src.size<0>(); if (0==content_length) { // ahem...invalid // untestable as a preprocessor expression, balanced-kill gets this first src.flags &= parse_tree::RESERVED_MASK; // just in case src.flags |= (PARSE_PRIMARY_EXPRESSION | parse_tree::CONSTANT_EXPRESSION); simple_error(src," cannot be an expression (C99 6.5.2p1/C++98 5.2p1)"); return true; }; if (1==content_length) { if (PARSE_PRIMARY_EXPRESSION & src.data<0>()->flags) { // primary expression that got parenthesized src.eval_to_arg<0>(0); return true; } else if (PARSE_EXPRESSION & src.data<0>()->flags) { // normal expression that got parenthesized value_copy(src.type_code,src.data<0>()->type_code); src.flags &= parse_tree::RESERVED_MASK; // just in case src.flags |= PARSE_PRIMARY_EXPRESSION; src.flags |= (PARSE_PAREN_PRIMARY_PASSTHROUGH & src.data<0>()->flags); return true; } else if (PARSE_TYPE & src.data<0>()->flags) { // abuse: handle parenthesized type-specifiers here value_copy(src.type_code,src.data<0>()->type_code); src.flags &= parse_tree::RESERVED_MASK; // just in case src.flags |= (PARSE_TYPE & src.data<0>()->flags); return false; // not an expression } }; } return false; } static bool suppress_naked_brackets_and_braces(parse_tree& src,const char* const err_prefix,size_t err_len) { if (!(PARSE_OBVIOUS & src.flags) && src.empty<1>() && src.empty<2>()) { // top-level [ ] dies regardless of contents // not testable with preprocessor expression (not sure whether reachable with full source code) if (robust_token_is_char<'['>(src.index_tokens[0].token)) { if (robust_token_is_char<']'>(src.index_tokens[1].token)) { src.flags &= parse_tree::RESERVED_MASK; // just in case src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(err_prefix,err_len); INFORM(" [ ... ] has no context to interpret (C99 6.5.2p1/C++98 5.2p1)"); zcc_errors.inc_error(); return true; } } // top-level { } dies regardless of contents // not testable with preprocessor expression else if (robust_token_is_char<'{'>(src.index_tokens[0].token)) { if (robust_token_is_char<'}'>(src.index_tokens[1].token)) { src.flags &= parse_tree::RESERVED_MASK; // just in case src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(err_prefix,err_len); INFORM(" { ... } has no context to interpret (C99 6.5.2p1/C++98 5.2p1)"); zcc_errors.inc_error(); return true; } } } return false; } // \throw std::bad_alloc only if src.data<0>()[i-1].type_code.pointer_power<src.data<0>()[i-1].data<0>()->type_code.pointer_power static bool terse_locate_array_deref(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(src.data<0>()[i].empty<1>()); assert(src.data<0>()[i].empty<2>()); assert(src.data<0>()[i].index_tokens[0].token.first); assert(src.data<0>()[i].index_tokens[1].token.first); if ( !token_is_char<'['>(src.data<0>()[i].index_tokens[0].token) || !token_is_char<']'>(src.data<0>()[i].index_tokens[1].token)) return false; assert(1<=i); if ( 1==src.data<0>()[i].size<0>() && (PARSE_EXPRESSION & src.data<0>()[i].data<0>()->flags)) { // array dereference operator; put preceding argument src.data<0>()[i-1] in src.data<0>()[i].data<1>()[0] inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]); if (PARSE_POSTFIX_EXPRESSION & src.data<0>()[i-1].flags) { parse_tree* const tmp = repurpose_inner_parentheses(src.c_array<0>()[i]); // RAM conservation src.c_array<0>()[i-1].OverwriteInto(*tmp); src.c_array<0>()[i].fast_set_arg<1>(tmp); src.c_array<0>()[i].core_flag_update(); src.c_array<0>()[i].flags |= PARSE_STRICT_POSTFIX_EXPRESSION; src.DeleteIdx<0>(--i); assert(is_array_deref_strict(src.data<0>()[i])); cancel_outermost_parentheses(src.c_array<0>()[i].c_array<1>()[0]); cancel_outermost_parentheses(src.c_array<0>()[i].c_array<0>()[0]); src.type_code.set_type(C_TYPE::NOT_VOID); src.c_array<0>()[i].type_code.q_vector.front() |= type_spec::lvalue; assert(is_array_deref(src.data<0>()[i])); return true; }; if (!(parse_tree::INVALID & src.flags)) { //! \test default/Error_if_control3.hpp, default/Error_if_control3.h //! \test default/Error_if_control4.hpp, default/Error_if_control4.h //! \test default/Error_if_control5.hpp, default/Error_if_control5.h //! \test default/Error_if_control6.hpp, default/Error_if_control6.h //! \test default/Error_if_control7.hpp, default/Error_if_control7.h //! \test default/Error_if_control8.hpp, default/Error_if_control8.h //! \test default/Error_if_control9.hpp, default/Error_if_control9.h //! \test default/Error_if_control10.hpp, default/Error_if_control10.h //! \test default/Error_if_control11.hpp, default/Error_if_control11.h //! \test default/Error_if_control12.hpp, default/Error_if_control12.h //! \test default/Error_if_control13.hpp, default/Error_if_control13.h //! \test default/Error_if_control14.hpp, default/Error_if_control14.h //! \test default/Error_if_control15.hpp, default/Error_if_control15.h //! \test default/Error_if_control16.hpp, default/Error_if_control16.h //! \test default/Error_if_control17.hpp, default/Error_if_control17.h //! \test default/Error_if_control18.hpp, default/Error_if_control18.h //! \test default/Error_if_control19.hpp, default/Error_if_control19.h //! \test default/Error_if_control20.hpp, default/Error_if_control20.h //! \test default/Error_if_control21.hpp, default/Error_if_control21.h //! \test default/Error_if_control22.hpp, default/Error_if_control22.h //! \test default/Error_if_control23.hpp, default/Error_if_control23.h src.flags |= parse_tree::INVALID; src.c_array<0>()[i].flags |= PARSE_STRICT_POSTFIX_EXPRESSION; src.type_code.set_type(0); message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("array dereference "); INC_INFORM(src); INC_INFORM(" has invalid postfix expression "); INC_INFORM(src.data<0>()[i-1]); INFORM(" to dereference (C99 6.5.2.1p1)"); zcc_errors.inc_error(); }; } return false; } //! \throw std::bad_alloc static void C_array_easy_syntax_check(parse_tree& src,const type_system& types) { if (parse_tree::INVALID & src.flags) return; // cannot optimize to valid const size_t effective_pointer_power_prefix = src.data<1>()->type_code.pointer_power; const size_t effective_pointer_power_infix = src.data<0>()->type_code.pointer_power; if (0<effective_pointer_power_prefix) { if (0<effective_pointer_power_infix) { // uses extension to test in preprocessor //! \test default/Error_if_control1.h simple_error(src,"array dereference of pointer by pointer (C99 6.5.2.1p1; C++98 5.2.1p1,13.3.1.2p1)"); return; } else if (converts_to_integerlike(src.data<0>()->type_code.base_type_index ARG_TYPES)) ZAIMONI_PASSTHROUGH_ASSERT(src.data<1>()->type_code.dereference(src.type_code)); else{ // not testable from preprocessor yet (need floating-point literals as extension) src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("array dereference of pointer by "); INFORM(types.name(src.data<0>()->type_code.base_type_index)); INFORM(" (C99 6.5.2.1p1; C++98 5.2.1p1,13.5.5p1)"); zcc_errors.inc_error(); return; } } else if (0<effective_pointer_power_infix) { if (converts_to_integerlike(src.data<1>()->type_code.base_type_index ARG_TYPES)) ZAIMONI_PASSTHROUGH_ASSERT(src.data<0>()->type_code.dereference(src.type_code)); else{ // autofails in C // not testable from preprocessor yet (need floating-point literals, would be extension regardless) src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("array dereference of pointer by "); INFORM(types.name(src.data<1>()->type_code.base_type_index)); INFORM(" (C99 6.5.2.1p1; C++98 5.2.1p1,13.5.5p1)"); zcc_errors.inc_error(); return; } } else{ // autofails in C; uses extension to test in preprocessor //! \test default/Error_if_control2.h src.flags |= parse_tree::INVALID; if (!(parse_tree::INVALID & src.data<0>()->flags) && !(parse_tree::INVALID & src.data<1>()->flags)) { message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("array dereference of "); INC_INFORM(types.name(src.data<1>()->type_code.base_type_index)); INC_INFORM(" by "); INFORM(types.name(src.data<0>()->type_code.base_type_index)); INFORM(" (C99 6.5.2.1p1; C++98 5.2.1p1,13.5.5p1)"); zcc_errors.inc_error(); } return; } } /*(6.5.2) postfix-expression: primary-expression postfix-expression [ expression ] postfix-expression ( argument-expression-listopt ) postfix-expression . identifier postfix-expression -> identifier postfix-expression ++ postfix-expression -- ( type-name ) { initializer-list } ( type-name ) { initializer-list , } */ static void locate_C99_postfix_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].empty<1>() || !src.data<0>()[i].empty<2>() || !src.data<0>()[i].index_tokens[0].token.first) return; if (src.data<0>()[i].index_tokens[1].token.first) { if (terse_locate_array_deref(src,i)) { C_array_easy_syntax_check(src.c_array<0>()[i],types); return; } #if 0 else if ( token_is_char<'('>(src.data<0>()[i].index_tokens[0].token) && token_is_char<')'>(src.data<0>()[i].index_tokens[1].token)) { if (1<=i) { } else if (1<src.size<0>()-i) { } } } else{ // if (NULL==src.data<0>()[i].index_tokens[1].token.first) if (token_is_char<'.'>(src.data<0>()[i].index_tokens[0].token)) { if (1<=i && 1<src.size<0>()-i) { } else{ } } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"->")) { if (1<=i && 1<src.size<0>()-i) { } else{ } } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"++")) { if (1<=i) { } } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"--")) { if (1<=i) { } } #endif } } // if #include <typeinfo> hasn't happened, context-free error stops this //! \throw std::bad_alloc static bool terse_locate_CPP0X_typeid(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_string<6>(src.data<0>()[i].index_tokens[0].token,"typeid") && 1<src.size<0>()-i && is_naked_parentheses_pair(src.data<0>()[i+1])) { inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if ((PARSE_EXPRESSION | PARSE_TYPE) & src.data<0>()[i+1].flags) { { parse_tree* const tmp = repurpose_inner_parentheses(src.c_array<0>()[i+1]); // RAM conservation src.c_array<0>()[i+1].OverwriteInto(*tmp); src.c_array<0>()[i].fast_set_arg<2>(tmp); src.c_array<0>()[i].core_flag_update(); src.c_array<0>()[i].flags |= PARSE_STRICT_POSTFIX_EXPRESSION; src.DeleteIdx<0>(i+1); cancel_outermost_parentheses(src.c_array<0>()[i].c_array<2>()[0]); } src.c_array<0>()[i].type_code.set_type(C_TYPE::TYPEINFO); src.c_array<0>()[i].type_code.qualifier<0>() |= (type_spec::lvalue | type_spec::_const); assert(is_CPP0X_typeid_expression(src.c_array<0>()[i])); return true; } } return false; } // We can't eval typeid itself at compile-time, but we *can* eval == and != of // typeid. Most other operators should error, through. //! \throw std::bad_alloc() static bool locate_CPP0X_typeid(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_CPP0X_typeid(src,i,types)) return true; return false; } /*postfixexpression: primaryexpression postfixexpression [ expression ] postfixexpression ( expressionlistopt ) simpletypespecifier ( expressionlistopt ) postfixexpression . templateopt ::opt idexpression postfixexpression -> templateopt ::opt idexpression postfixexpression . pseudodestructorname postfixexpression -> pseudodestructorname postfixexpression ++ postfixexpression -- dynamic_cast < typeid > ( expression ) static_cast < typeid > ( expression ) reinterpret_cast < typeid > ( expression ) const_cast < typeid > ( expression ) typeid ( expression ) typeid ( typeid ) */ /* returns error count */ static void locate_CPP_postfix_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].empty<1>() || !src.data<0>()[i].empty<2>()) return; if (src.data<0>()[i].index_tokens[1].token.first) { if (terse_locate_array_deref(src,i)) { //! \todo handle operator [] overloading C_array_easy_syntax_check(src.c_array<0>()[i],types); return; } #if 0 else if ( token_is_char<'('>(src.data<0>()[i].index_tokens[0].token) && token_is_char<')'>(src.data<0>()[i].index_tokens[1].token)) { if (1<=i) { } } #endif } else{ // if (NULL==src.data<0>()[i].index_tokens[1].token.first) if (locate_CPP0X_typeid(src,i,types)) return; #if 0 if (token_is_char<'.'>(src.data<0>()[i].index_tokens[0].token)) { if (1<=i && 1<src.size<0>()-i) { } else{ } } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"->")) { if (1<=i && 1<src.size<0>()-i) { } else{ } } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"++")) { if (1<=i) { } } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"--")) { if (1<=i) { } } else if (token_is_string<12>(src.data<0>()[i].index_tokens[0].token,"dynamic_cast")) { } else if (token_is_string<11>(src.data<0>()[i].index_tokens[0].token,"static_cast")) { } else if (token_is_string<16>(src.data<0>()[i].index_tokens[0].token,"reinterpret_cast")) { } else if (token_is_string<10>(src.data<0>()[i].index_tokens[0].token,"const_cast")) { } else if (token_is_string<6>(src.data<0>()[i].index_tokens[0].token,"typeid")) { } #endif } } // typedef to simplify compatibility changes typedef bool literal_converts_to_bool_func(const parse_tree& src, bool& is_true SIG_CONST_TYPES); // Closely related to if_elif_control_is_zero/CPreproc.cpp static bool _C99_literal_converts_to_bool(const parse_tree& src, bool& is_true SIG_CONST_TYPES) { assert(src.is_atomic()); // string literals always test true (decay to non-NULL pointer) if (C_TESTFLAG_STRING_LITERAL==src.index_tokens[0].flags) { is_true = true; return true; } if (C_TESTFLAG_CHAR_LITERAL==src.index_tokens[0].flags) { is_true = !CCharLiteralIsFalse(src.index_tokens[0].token.first,src.index_tokens[0].token.second); return true; }; if (is_noticed_enumerator(src,types)) { // misintepret enumerators as literals (avoid dynamic memory thrashing) const type_system::enumerator_info* const tmp2 = types.get_enumerator(src.index_tokens[0].token.first); assert(tmp2); const promote_aux dest_type(tmp2->second.first.second,types); is_true = !target_machine->is_zero(tmp2->second.first.third.data(),tmp2->second.first.third.size(),dest_type); return true; } if (!(C_TESTFLAG_PP_NUMERAL & src.index_tokens[0].flags)) return false; C_REALITY_CHECK_PP_NUMERAL_FLAGS(src.index_tokens[0].flags); if (C_TESTFLAG_FLOAT & src.index_tokens[0].flags) return false; //! \todo handle floats as well (underflow to zero is target-sensitive) // zeros go to zero, everything else canonicalizes to one is_true = !C99_integer_literal_is_zero(src.index_tokens[0].token.first,src.index_tokens[0].token.second,src.index_tokens[0].flags); return true; } static bool C99_literal_converts_to_bool(const parse_tree& src, bool& is_true SIG_CONST_TYPES) { // deal with -1 et. al. if (is_C99_unary_operator_expression<'-'>(src) && src.data<2>()->is_atomic()) return _C99_literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES); if (!src.is_atomic()) return false; return _C99_literal_converts_to_bool(src,is_true ARG_TYPES); } static bool CPP_literal_converts_to_bool(const parse_tree& src, bool& is_true SIG_CONST_TYPES) { // deal with -1 et. al. if (is_C99_unary_operator_expression<'-'>(src) && src.data<2>()->is_atomic()) return CPP_literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES); if (!src.is_atomic()) return false; if (_C99_literal_converts_to_bool(src,is_true ARG_TYPES)) return true; // deal with: this, true, false if (token_is_string<5>(src.index_tokens[0].token,"false")) { is_true = false; return true; } else if ( token_is_string<4>(src.index_tokens[0].token,"true") || token_is_string<4>(src.index_tokens[0].token,"this")) { is_true = true; return true; }; return false; } //! \throw std::bad_alloc static void assemble_unary_postfix_arguments(parse_tree& src, const size_t i, const size_t _subtype) { assert(1<src.size<0>()-i); parse_tree* const tmp = repurpose_inner_parentheses(src.c_array<0>()[i+1]); // RAM conservation src.c_array<0>()[i+1].OverwriteInto(*tmp); src.c_array<0>()[i].fast_set_arg<2>(tmp); src.c_array<0>()[i].core_flag_update(); src.c_array<0>()[i].flags |= PARSE_STRICT_UNARY_EXPRESSION; src.c_array<0>()[i].subtype = _subtype; src.DeleteIdx<0>(i+1); cancel_outermost_parentheses(src.c_array<0>()[i].c_array<2>()[0]); } // can't do much syntax-checking or immediate-evaluation here because of binary +/- // unary +/- syntax checking out out of place as it's needed by all of the unary operators //! \throw std::bad_alloc() static void VM_to_token(const umaxint& src_int,const size_t base_type_index,POD_pair<char*,lex_flags>& dest) { assert(C_TYPE::INT<=base_type_index && C_TYPE::ULLONG>=base_type_index); const char* const suffix = literal_suffix(base_type_index); char* buf = _new_buffer_nonNULL_throws<char>((VM_MAX_BIT_PLATFORM/3)+4); dest.second = literal_flags(base_type_index); dest.second |= C_TESTFLAG_DECIMAL; z_ucharint_toa(src_int,buf,10); assert(!suffix || 3>=strlen(suffix)); assert(dest.second); if (suffix) strcat(buf,suffix); // shrinking realloc should be no-fail dest.first = REALLOC(buf,ZAIMONI_LEN_WITH_NULL(strlen(buf))); } //! \throw std::bad_alloc() static void VM_to_literal(parse_tree& dest, const umaxint& src_int,const parse_tree& src,const type_system& types) { POD_pair<char*,lex_flags> new_token; VM_to_token(src_int,src.type_code.base_type_index,new_token); dest.clear(); dest.grab_index_token_from<0>(new_token.first,new_token.second); dest.grab_index_token_location_from<0,0>(src); assert((C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_STRING_LITERAL | C_TESTFLAG_PP_NUMERAL) & dest.index_tokens[0].flags); _label_one_literal(dest,types); assert(PARSE_EXPRESSION & dest.flags); } // can't do much syntax-checking or immediate-evaluation here because of binary +/- // unary +/- syntax checking out out of place as it's needed by all of the unary operators //! \throw std::bad_alloc() static void uint_to_token(uintmax_t src_int,const size_t base_type_index,POD_pair<char*,lex_flags>& dest) { assert(C_TYPE::INT<=base_type_index && C_TYPE::ULLONG>=base_type_index); const char* const suffix = literal_suffix(base_type_index); char* buf = _new_buffer_nonNULL_throws<char>((VM_MAX_BIT_PLATFORM/3)+4); dest.second = literal_flags(base_type_index); dest.second |= C_TESTFLAG_DECIMAL; z_umaxtoa(src_int,buf,10); assert(!suffix || 3>=strlen(suffix)); assert(dest.second); if (suffix) strcat(buf,suffix); // shrinking realloc should be no-fail dest.first = REALLOC(buf,ZAIMONI_LEN_WITH_NULL(strlen(buf))); } //! \throw std::bad_alloc() static void uint_to_literal(parse_tree& dest, uintmax_t src_int,const parse_tree& src,const type_system& types) { POD_pair<char*,lex_flags> new_token; uint_to_token(src_int,src.type_code.base_type_index,new_token); dest.clear(); dest.grab_index_token_from<0>(new_token.first,new_token.second); dest.grab_index_token_location_from<0,0>(src); assert((C_TESTFLAG_CHAR_LITERAL | C_TESTFLAG_STRING_LITERAL | C_TESTFLAG_PP_NUMERAL) & dest.index_tokens[0].flags); _label_one_literal(dest,types); assert(PARSE_EXPRESSION & dest.flags); } static void force_decimal_literal(parse_tree& dest,const char* src,const type_system& types) { assert(src && *src); dest.destroy(); assert(dest.index_tokens[0].src_filename && *dest.index_tokens[0].src_filename); dest.index_tokens[0].token.first = src; dest.index_tokens[0].token.second = strlen(src); dest.index_tokens[0].flags = (C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_DECIMAL); _label_one_literal(dest,types); } static parse_tree decimal_literal(const char* src,const parse_tree& loc_src,const type_system& types) { assert(src && *src); parse_tree dest; dest.clear(); dest.index_tokens[0].token.first = src; dest.index_tokens[0].token.second = strlen(src); dest.index_tokens[0].flags = (C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_DECIMAL); dest.grab_index_token_location_from<0,0>(loc_src); _label_one_literal(dest,types); return dest; } //! usually want to use value_copy rather than MoveInto before this (easier to be ACID) //! \throw std::bad_alloc only if dest.type_code.pointer_power<dest.data<2>()->type_code.pointer_power static void force_unary_positive_literal(parse_tree& dest,const parse_tree& src SIG_CONST_TYPES) { assert(0==dest.size<0>()); assert(0==dest.size<1>()); assert(1==dest.size<2>()); assert(!dest.index_tokens[1].token.first); dest.grab_index_token_from_str_literal<0>("+",C_TESTFLAG_NONATOMIC_PP_OP_PUNC); *dest.c_array<2>() = src; dest.core_flag_update(); dest.flags |= PARSE_STRICT_UNARY_EXPRESSION; dest.subtype = C99_UNARY_SUBTYPE_PLUS; if (converts_to_arithmeticlike(dest.data<2>()->type_code ARG_TYPES)) value_copy(dest.type_code,dest.data<2>()->type_code); //! \bug doesn't work for enumerators assert(dest.index_tokens[0].src_filename); assert(is_C99_unary_operator_expression<'+'>(dest)); } static void force_unary_negative_token(parse_tree& dest,parse_tree* src,const parse_tree& loc_src SIG_CONST_TYPES) { assert(src); assert(PARSE_EXPRESSION & src->flags); dest.clear(); dest.grab_index_token_from_str_literal<0>("-",C_TESTFLAG_NONATOMIC_PP_OP_PUNC); dest.grab_index_token_location_from<0,0>(loc_src); dest.fast_set_arg<2>(src); dest.core_flag_update(); dest.flags |= PARSE_STRICT_UNARY_EXPRESSION; dest.subtype = C99_UNARY_SUBTYPE_NEG; if (converts_to_arithmeticlike(dest.data<2>()->type_code ARG_TYPES)) value_copy(dest.type_code,dest.data<2>()->type_code); //! \bug doesn't work for enumerators // do not handle type here: C++ operator overloading risk assert(dest.index_tokens[0].src_filename); assert(is_C99_unary_operator_expression<'-'>(dest)); } // this one hides a slight inefficiency: negative literals take 2 dynamic memory allocations, positive literals take one // return code is true for success, false for memory failure //! \throw std::bad_alloc() static void VM_to_signed_literal(parse_tree& x,const bool is_negative, const umaxint& src_int,const parse_tree& src,const type_system& types) { if (is_negative) { parse_tree* tmp = _new_buffer_nonNULL_throws<parse_tree>(1); try { VM_to_literal(*tmp,src_int,src,types); } catch(const std::bad_alloc&) { _flush(tmp); throw; } assert(PARSE_EXPRESSION & tmp->flags); force_unary_negative_token(x,tmp,*tmp ARG_TYPES); } else VM_to_literal(x,src_int,src,types); } //! \throw std::bad_alloc() static void enumerator_to_integer_representation(parse_tree& x,const type_system& types) { parse_tree tmp3; const type_system::enumerator_info* const tmp2 = types.get_enumerator(x.index_tokens[0].token.first); assert(tmp2); const promote_aux dest_type(tmp2->second.first.second ARG_TYPES); { umaxint res_int(tmp2->second.first.third); const bool tmp_negative = dest_type.is_signed && res_int.test(dest_type.bitcount-1); if (tmp_negative) target_machine->signed_additive_inverse(res_int,dest_type.machine_type); { // pretend x is the type of the enumerator. const type_system::type_index backup = x.type_code.base_type_index; x.type_code.base_type_index = tmp2->second.first.second; try { VM_to_signed_literal(tmp3,tmp_negative,res_int,x,types); } catch(const std::bad_alloc&) { x.type_code.base_type_index = backup; throw; } } } tmp3.MoveInto(x); } static bool is_integerlike_literal(const parse_tree& x SIG_CONST_TYPES) { return converts_to_integerlike(x.type_code ARG_TYPES) && (PARSE_PRIMARY_EXPRESSION & x.flags); } //! \throw std::bad_alloc() static bool eval_unary_plus(parse_tree& src, const type_system& types) { assert(is_C99_unary_operator_expression<'+'>(src)); if (0<src.data<2>()->type_code.pointer_power) { // assume C++98 interpretation, as this is illegal in C99 //! \test cpp/default/Pass_if_control27.hpp if (!(parse_tree::INVALID & src.flags)) { assert(src.type_code==src.data<2>()->type_code); src.eval_to_arg<2>(0); return true; } return false; }; if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); if (is_C99_unary_operator_expression<'-'>(*src.data<2>())) { // enumerator went negative: handle src.eval_to_arg<2>(0); return true; } } // handle integer-like literals like a real integer literal if (is_integerlike_literal(*src.data<2>() ARG_TYPES)) { src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); return true; } return false; } //! \throw std::bad_alloc() static bool eval_unary_minus(parse_tree& src, const type_system& types,literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_C99_unary_operator_expression<'-'>(src)); bool is_true = false; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true && (1==(src.type_code.base_type_index-C_TYPE::INT)%2 || virtual_machine::twos_complement==target_machine->C_signed_int_representation() || bool_options[boolopt::int_traps])) { // -0==0 // deal with unary - not being allowed to actually return -0 on these machines later type_spec tmp; src.type_code.OverwriteInto(tmp); force_decimal_literal(src,"0",types); tmp.MoveInto(src.type_code); return true; }; if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); if (is_C99_unary_operator_expression<'-'>(*src.data<2>())) { // enumerator went negative: handle src.eval_to_arg<2>(0); return true; } value_copy(src.type_code,src.data<2>()->type_code); } if (is_integerlike_literal(*src.data<2>() ARG_TYPES) && 1==(src.type_code.base_type_index-C_TYPE::INT)%2) { // unsigned...we're fine const virtual_machine::std_int_enum machine_type = machine_type_from_type_index(src.type_code.base_type_index); umaxint res_int; intlike_literal_to_VM(res_int,*src.data<2>() ARG_TYPES); target_machine->unsigned_additive_inverse(res_int,machine_type); //! \todo flag failures to reduce as RAM-stalled POD_pair<char*,lex_flags> new_token; VM_to_token(res_int,src.type_code.base_type_index,new_token); src.c_array<2>()->grab_index_token_from<0>(new_token.first,new_token.second); src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); return true; }; if (converts_to_integerlike(src.data<2>()->type_code ARG_TYPES) && is_C99_unary_operator_expression<'-'>(*src.data<2>())) { // - - __ |-> __, trap-int machines fine as -0=0 for sign/magnitude and one's complement, and the offending literal for two's complement is an unsigned int assert(converts_to_integerlike(src.data<2>()->data<2>()->type_code ARG_TYPES)); parse_tree tmp; src.c_array<2>()->c_array<2>()->OverwriteInto(tmp); src.type_code.MoveInto(tmp.type_code); tmp.MoveInto(src); return true; } return false; } //! \throw std::bad_alloc() static void C_unary_plusminus_easy_syntax_check(parse_tree& src,const type_system& types) { assert(C99_UNARY_SUBTYPE_NEG==src.subtype || C99_UNARY_SUBTYPE_PLUS==src.subtype); assert((C99_UNARY_SUBTYPE_PLUS==src.subtype) ? is_C99_unary_operator_expression<'+'>(src) : is_C99_unary_operator_expression<'-'>(src)); // return immediately if applied to a pointer type (C++98 would type here) if (0<src.data<2>()->type_code.pointer_power) { src.type_code.set_type(0); simple_error(src,(C99_UNARY_SUBTYPE_PLUS==src.subtype) ? " applies unary + to a pointer (C99 6.5.3.3p1)" : " applies unary - to a pointer (C99 6.5.3.3p1)"); return; } // can type if an (C++0X unscoped) enumerator if (is_noticed_enumerator(*src.data<2>(),types)) { const type_system::enumerator_info* const tmp2 = types.get_enumerator(src.data<2>()->index_tokens[0].token.first); assert(tmp2); src.type_code.set_type(tmp2->second.first.first); } else // can type if result is a primitive arithmetic type if (converts_to_arithmeticlike(src.data<2>()->type_code.base_type_index ARG_TYPES)) src.type_code.set_type(default_promote_type(src.data<2>()->type_code.base_type_index ARG_TYPES)); const size_t arg_unary_subtype = (is_C99_unary_operator_expression<'-'>(*src.data<2>())) ? C99_UNARY_SUBTYPE_NEG : (is_C99_unary_operator_expression<'+'>(*src.data<2>())) ? C99_UNARY_SUBTYPE_PLUS : 0; if (!arg_unary_subtype) return; // two deep: // 2) if inner +/- is applied to a raw pointer, error out and change type to 0 // 1) if inner +/- is applied to an arithmetic literal, try to crunch it (but handle - signed carefully) if (C99_UNARY_SUBTYPE_PLUS==src.subtype) { if (C99_UNARY_SUBTYPE_PLUS==arg_unary_subtype) eval_unary_plus(*src.c_array<2>(),types); else // if (C99_UNARY_SUBTYPE_NEG==arg_unary_subtype) eval_unary_minus(*src.c_array<2>(),types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); } else{ // if (C99_UNARY_SUBTYPE_NEG==src.subtype) if (C99_UNARY_SUBTYPE_PLUS==arg_unary_subtype) eval_unary_plus(*src.c_array<2>(),types); else // if (C99_UNARY_SUBTYPE_NEG==arg_unary_subtype) eval_unary_minus(*src.c_array<2>(),types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); } } //! \throw std::bad_alloc() static void CPP_unary_plusminus_easy_syntax_check(parse_tree& src,const type_system& types) { assert(C99_UNARY_SUBTYPE_NEG==src.subtype || C99_UNARY_SUBTYPE_PLUS==src.subtype); assert((C99_UNARY_SUBTYPE_PLUS==src.subtype) ? is_C99_unary_operator_expression<'+'>(src) : is_C99_unary_operator_expression<'-'>(src)); // can type if result is a primitive arithmetic type // can type if an (C++0X unscoped) enumerator if (is_noticed_enumerator(*src.data<2>(),types)) { const type_system::enumerator_info* const tmp2 = types.get_enumerator(src.data<2>()->index_tokens[0].token.first); assert(tmp2); src.type_code.set_type(tmp2->second.first.first); } else if (converts_to_arithmeticlike(src.data<2>()->type_code ARG_TYPES)) src.type_code.set_type(default_promote_type(src.data<2>()->type_code.base_type_index ARG_TYPES)); // two deep: // 1) if inner +/- is applied to an arithmetic literal, try to crunch it (but leave - signed alone) // 2) if inner +/- is applied to a raw pointer, error out and change type to 0 if (C99_UNARY_SUBTYPE_PLUS==src.subtype) { if (0<src.data<2>()->type_code.pointer_power) // C++98 5.3.1p6: pointer type allowed for unary +, not for unary - (C99 errors) //! \test default/Pass_if_control27.hpp value_copy(src.type_code,src.data<2>()->type_code); if (is_C99_unary_operator_expression<'+'>(*src.data<2>())) eval_unary_plus(*src.c_array<2>(),types); else if (is_C99_unary_operator_expression<'-'>(*src.data<2>())) eval_unary_minus(*src.c_array<2>(),types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); } else{ // if (C99_UNARY_SUBTYPE_NEG==src.subtype) // return immediately if result is a pointer type; nested application to a pointer type dies if (0<src.data<2>()->type_code.pointer_power) { src.type_code.set_type(0); simple_error(src," applies unary - to a pointer (C++98 5.3.1p7)"); return; } const size_t arg_unary_subtype = (is_C99_unary_operator_expression<'-'>(*src.data<2>())) ? C99_UNARY_SUBTYPE_NEG : (is_C99_unary_operator_expression<'+'>(*src.data<2>())) ? C99_UNARY_SUBTYPE_PLUS : 0; if (arg_unary_subtype) { if (C99_UNARY_SUBTYPE_PLUS==arg_unary_subtype) eval_unary_plus(*src.c_array<2>(),types); else // if (C99_UNARY_SUBTYPE_NEG==arg_unary_subtype) eval_unary_minus(*src.c_array<2>(),types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); } } } // this is going to have to be forked eventually; the CPP variant has to be more // careful with the *& identity as both deference * and reference & are // overloadable operators //! \throw std::bad_alloc() static void C_deref_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_unary_operator_expression<'*'>(src)); //! \todo: handle *& identity when we have & // multi-dimensional arrays and cv-qualified pointers should be automatically handled value_copy(src.type_code,src.data<2>()->type_code); // handle lvalueness in indirection type building and/or the dereference stage if (!src.type_code.dereference()) //! \test default/Error_if_control24.hpp, default/Error_if_control24.h simple_error(src," is not dereferencing a pointer (C99 6.5.3.2p2; C++98 5.3.1p1)"); } // no eval_deref because of &* cancellation // defer syntax check to after resolution of multiply-*, so no C/C++ fork //! \throw std::bad_alloc() static bool terse_locate_C99_deref(parse_tree& src, size_t& i,const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'*'>(src.data<0>()[i].index_tokens[0].token)) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_DEREF); assert(is_C99_unary_operator_expression<'*'>(src.data<0>()[i])); return true; }; } return false; } //! \throw std::bad_alloc() static bool terse_locate_CPP_deref(parse_tree& src, size_t& i,const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'*'>(src.data<0>()[i].index_tokens[0].token)) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_DEREF); assert(is_C99_unary_operator_expression<'*'>(src.data<0>()[i])); return true; }; } return false; } //! \throw std::bad_alloc() static bool terse_locate_C_logical_NOT(parse_tree& src, size_t& i,const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'!'>(src.data<0>()[i].index_tokens[0].token)) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_NOT); assert(is_C99_unary_operator_expression<'!'>(src.data<0>()[i])); return true; }; } return false; } //! \throw std::bad_alloc() static bool terse_locate_CPP_logical_NOT(parse_tree& src, size_t& i,const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'!'>(src.data<0>()[i].index_tokens[0].token) || token_is_string<3>(src.data<0>()[i].index_tokens[0].token,"not")) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_NOT); assert(is_CPP_logical_NOT_expression(src.data<0>()[i])); return true; }; } return false; } static bool eval_logical_NOT(parse_tree& src, const type_system& types, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_logical_NOT, literal_converts_to_bool_func& literal_converts_to_bool) { assert(is_logical_NOT(src)); { // deal with literals that convert to bool here bool is_true = false; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES)) { src.destroy(); src.index_tokens[0].token.first = (is_true) ? "0" : "1"; src.index_tokens[0].token.second = 1; src.index_tokens[0].flags = (C_TESTFLAG_PP_NUMERAL | C_TESTFLAG_INTEGER | C_TESTFLAG_DECIMAL); _label_one_literal(src,types); return true; } } // logical NOT has period 2, but the first application converts the target to bool; can only cancel 3-deep in general, 2-deep against type bool expressions if (is_logical_NOT(*src.data<2>())) { if ( is_logical_NOT(*src.data<2>()->data<2>()) || src.data<2>()->type_code.is_type<C_TYPE::BOOL>()) { parse_tree tmp; src.c_array<2>()->c_array<2>()->OverwriteInto(tmp); tmp.MoveInto(src); return true; } }; return false; } static void C_logical_NOT_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_unary_operator_expression<'!'>(src)); src.type_code.set_type(C_TYPE::BOOL); // technically wrong for C, but the range is restricted to _Bool's range if (eval_logical_NOT(src,types,is_C99_unary_operator_expression<'!'>,C99_literal_converts_to_bool)) return; if (!converts_to_bool(src.data<2>()->type_code ARG_TYPES)) { // can't test this from preprocessor or static assertion simple_error(src," applies ! to a nonscalar type (C99 6.5.3.3p1)"); return; } } static void CPP_logical_NOT_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_logical_NOT_expression(src)); src.type_code.set_type(C_TYPE::BOOL); // technically wrong for C, but the range is restricted to _Bool's range if (eval_logical_NOT(src,types,is_CPP_logical_NOT_expression,CPP_literal_converts_to_bool)) return; if (!converts_to_bool(src.data<2>()->type_code ARG_TYPES)) { // can't test this from preprocessor or static assertion simple_error(src," applies ! to a type not convertible to bool (C++98 5.3.1p8)"); return; } } //! \throw std::bad_alloc() static bool locate_C99_logical_NOT(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (terse_locate_C_logical_NOT(src,i,types)) { C_logical_NOT_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } //! \throw std::bad_alloc() static bool locate_CPP_logical_NOT(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (terse_locate_CPP_logical_NOT(src,i,types)) { //! \todo handle operator overloading CPP_logical_NOT_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } static bool int_has_trapped(parse_tree& src,const umaxint& src_int) { assert(C_TYPE::INT<=src.type_code.base_type_index && C_TYPE::INTEGERLIKE>src.type_code.base_type_index); // check for trap representation for signed types const virtual_machine::std_int_enum machine_type = machine_type_from_type_index(src.type_code.base_type_index); if (bool_options[boolopt::int_traps] && 0==(src.type_code.base_type_index-C_TYPE::INT)%2 && target_machine->trap_int(src_int,machine_type)) { if (!no_runtime_errors) simple_error(src," generated a trap representation: undefined behavior (C99 6.2.6.1p5)"); return true; } return false; } //! this doesn't do anything to dest's type static void force_unary_negative_literal(parse_tree& dest,const parse_tree& src) { assert(0==dest.size<0>()); assert(0==dest.size<1>()); assert(1==dest.size<2>()); assert(!dest.index_tokens[1].token.first); dest.grab_index_token_from_str_literal<0>("-",C_TESTFLAG_NONATOMIC_PP_OP_PUNC); *dest.c_array<2>() = src; dest.core_flag_update(); dest.flags |= PARSE_STRICT_UNARY_EXPRESSION; dest.subtype = C99_UNARY_SUBTYPE_NEG; assert(dest.index_tokens[0].src_filename); assert(is_C99_unary_operator_expression<'-'>(dest)); } //! \throw std::bad_alloc() static bool terse_locate_C99_bitwise_complement(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'~'>(src.data<0>()[i].index_tokens[0].token)) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_COMPL); assert(is_C99_unary_operator_expression<'~'>(src.data<0>()[i])); return true; }; } return false; } //! \throw std::bad_alloc() static bool terse_locate_CPP_bitwise_complement(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'~'>(src.data<0>()[i].index_tokens[0].token) || token_is_string<5>(src.data<0>()[i].index_tokens[0].token,"compl")) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_COMPL); assert(is_CPP_bitwise_complement_expression(src.data<0>()[i])); return true; }; } return false; } // all three users of this want the resulting type to be the same as dest's type //! \throw std::bad_alloc() static void construct_twos_complement_int_min(parse_tree& dest, const type_system& types, const virtual_machine::std_int_enum machine_type, const parse_tree& src_loc) { zaimoni::autoval_ptr<parse_tree> tmp2; tmp2 = _new_buffer_nonNULL_throws<parse_tree>(1); // XXX we recycle this variable later zaimoni::autoval_ptr<parse_tree> tmp3; tmp3 = _new_buffer_nonNULL_throws<parse_tree>(1); // XXX we recycle this variable later { umaxint tmp_int(target_machine->signed_max(machine_type)); zaimoni::autoval_ptr<parse_tree> tmp; tmp = _new_buffer_nonNULL_throws<parse_tree>(1); // XXX we recycle this variable later VM_to_literal(*tmp,tmp_int,src_loc,types); tmp_int = 1; try { VM_to_literal(*tmp2,tmp_int,src_loc,types); } catch(const std::bad_alloc&) { tmp->destroy(); throw; } force_unary_negative_token(*tmp3,tmp.release(),src_loc ARG_TYPES); } parse_tree_class tmp4; tmp4.grab_index_token_from_str_literal<0>("-",C_TESTFLAG_NONATOMIC_PP_OP_PUNC); tmp4.grab_index_token_location_from<0,0>(src_loc); tmp4.fast_set_arg<1>(tmp3.release()); tmp4.fast_set_arg<2>(tmp2.release()); tmp4.core_flag_update(); tmp4.flags |= PARSE_STRICT_ADD_EXPRESSION; tmp4.subtype = C99_ADD_SUBTYPE_MINUS; assert(is_C99_add_operator_expression<'-'>(tmp4)); dest.type_code.MoveInto(tmp4.type_code); tmp4.MoveInto(dest); // do not handle type here: C++ operator overloading risk } //! \throw std::bad_alloc() static bool eval_bitwise_compl(parse_tree& src, const type_system& types,func_traits<bool (*)(const parse_tree&)>::function_ref_type is_bitwise_complement_expression,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_bitwise_complement_expression(src)); assert(converts_to_integerlike(src.data<2>()->type_code ARG_TYPES)); if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); value_copy(src.type_code,src.data<2>()->type_code); } umaxint res_int; if (intlike_literal_to_VM(res_int,*src.data<2>() ARG_TYPES)) { const virtual_machine::std_int_enum machine_type = machine_type_from_type_index(src.type_code.base_type_index); res_int.auto_bitwise_complement(); res_int.mask_to(target_machine->C_bit(machine_type)); if (int_has_trapped(src,res_int)) return false; const bool negative_signed_int = 0==(src.type_code.base_type_index-C_TYPE::INT)%2 && res_int.test(target_machine->C_bit(machine_type)-1); if (negative_signed_int) target_machine->signed_additive_inverse(res_int,machine_type); if ( virtual_machine::twos_complement==target_machine->C_signed_int_representation() && 0==(src.type_code.base_type_index-C_TYPE::INT)%2 && !bool_options[boolopt::int_traps] && res_int>target_machine->signed_max(machine_type)) { // trap representation; need to get it into -INT_MAX-1 form construct_twos_complement_int_min(src,types,machine_type,src); return true; } parse_tree tmp; VM_to_literal(tmp,res_int,src,types); // two's-complement non-trapping INT_MIN dies if it gets here if (negative_signed_int) // convert to parsed - literal force_unary_negative_literal(src,tmp); else{ // convert to positive literal src.type_code.MoveInto(tmp.type_code); tmp.MoveInto(src); } return true; }; if ( is_bitwise_complement_expression(*src.data<2>()) && is_bitwise_complement_expression(*src.data<2>()->data<2>())) { // ~~~__ reduces to ~__ safely parse_tree tmp; src.c_array<2>()->c_array<2>()->OverwriteInto(tmp); tmp.MoveInto(src); return true; } return false; } //! \throw std::bad_alloc() static void C_bitwise_complement_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_unary_operator_expression<'~'>(src)); const POD_pair<size_t,bool> tmp = default_promotion_is_integerlike(src.data<2>()->type_code ARG_TYPES); if (!tmp.second) { //! \test Error_if_control25.h src.type_code.set_type(0); simple_error(src," applies ~ to a nonintegral type (C99 6.5.3.3p1)"); return; } src.type_code.set_type(tmp.first); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_compl(src,types,is_C99_unary_operator_expression<'~'>,C99_intlike_literal_to_VM)) return; } //! \throw std::bad_alloc() static void CPP_bitwise_complement_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_bitwise_complement_expression(src)); const POD_pair<size_t,bool> tmp = default_promotion_is_integerlike(src.data<2>()->type_code ARG_TYPES); if (!tmp.second) { src.type_code.set_type(0); simple_error(src," applies ~ to a nonintegral type (C99 6.5.3.3p1)"); return; } src.type_code.set_type(tmp.first); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_compl(src,types,is_CPP_bitwise_complement_expression,CPP_intlike_literal_to_VM)) return; } //! \throw std::bad_alloc() static bool locate_C99_bitwise_complement(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_C99_bitwise_complement(src,i,types)) { C_bitwise_complement_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } //! \throw std::bad_alloc() static bool locate_CPP_bitwise_complement(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_CPP_bitwise_complement(src,i,types)) { //! \todo handle overloading CPP_bitwise_complement_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } //! \throw std::bad_alloc() static bool terse_locate_C99_unary_plusminus(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t unary_subtype = (token_is_char<'-'>(src.data<0>()[i].index_tokens[0].token)) ? C99_UNARY_SUBTYPE_NEG : (token_is_char<'+'>(src.data<0>()[i].index_tokens[0].token)) ? C99_UNARY_SUBTYPE_PLUS : 0; if (unary_subtype) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,unary_subtype); src.c_array<0>()[i].type_code.set_type(C_TYPE::NOT_VOID); // defer to later if ( 0==i // unless no predecessor possible // operators also work || robust_token_is_char<'~'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'!'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"++") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"--") || robust_token_is_char<'*'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'/'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'%'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'+'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'-'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"<<") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,">>") || robust_token_is_char<'<'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'>'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"<=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,">=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"==") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"!=") || robust_token_is_char<'&'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'^'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'|'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"&&") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"||") || robust_token_is_char<'?'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<':'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'='>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"*=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"/=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"%=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"+=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"-=") || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,"<<=") || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,">>=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"&=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"^=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"|=") || robust_token_is_char<','>(src.data<0>()[i-1].index_tokens[0].token)) C_unary_plusminus_easy_syntax_check(src.c_array<0>()[i],types); assert((C99_UNARY_SUBTYPE_PLUS==unary_subtype) ? is_C99_unary_operator_expression<'+'>(src.data<0>()[i]) : is_C99_unary_operator_expression<'-'>(src.data<0>()[i])); return true; }; } return false; } //! \throw std::bad_alloc() static bool terse_locate_CPP_unary_plusminus(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t unary_subtype = (token_is_char<'-'>(src.data<0>()[i].index_tokens[0].token)) ? C99_UNARY_SUBTYPE_NEG : (token_is_char<'+'>(src.data<0>()[i].index_tokens[0].token)) ? C99_UNARY_SUBTYPE_PLUS : 0; if (unary_subtype) { assert(1<src.size<0>()-i); // should be intercepted at context-free check inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if (PARSE_CAST_EXPRESSION & src.data<0>()[i+1].flags) { assemble_unary_postfix_arguments(src,i,unary_subtype); src.c_array<0>()[i].type_code.set_type(C_TYPE::NOT_VOID); // defer to later if ( 0==i // unless no predecessor possible // operators also work || robust_token_is_char<'~'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<5>(src.data<0>()[i-1].index_tokens[0].token,"compl") || robust_token_is_char<'!'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,"not") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"++") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"--") || robust_token_is_char<'*'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'/'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'%'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'+'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'-'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"<<") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,">>") || robust_token_is_char<'<'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'>'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"<=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,">=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"==") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"!=") || robust_token_is_string<6>(src.data<0>()[i-1].index_tokens[0].token,"not_eq") || robust_token_is_char<'&'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<6>(src.data<0>()[i-1].index_tokens[0].token,"bitand") || robust_token_is_char<'^'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,"xor") || robust_token_is_char<'|'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<5>(src.data<0>()[i-1].index_tokens[0].token,"bitor") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"&&") || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,"and") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"||") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"or") || robust_token_is_char<'?'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<':'>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_char<'='>(src.data<0>()[i-1].index_tokens[0].token) || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"*=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"/=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"%=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"+=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"-=") || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,"<<=") || robust_token_is_string<3>(src.data<0>()[i-1].index_tokens[0].token,">>=") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"&=") || robust_token_is_string<6>(src.data<0>()[i-1].index_tokens[0].token,"and_eq") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"^=") || robust_token_is_string<6>(src.data<0>()[i-1].index_tokens[0].token,"xor_eq") || robust_token_is_string<2>(src.data<0>()[i-1].index_tokens[0].token,"|=") || robust_token_is_string<5>(src.data<0>()[i-1].index_tokens[0].token,"or_eq") || robust_token_is_char<','>(src.data<0>()[i-1].index_tokens[0].token)) CPP_unary_plusminus_easy_syntax_check(src.c_array<0>()[i],types); assert((C99_UNARY_SUBTYPE_PLUS==unary_subtype) ? is_C99_unary_operator_expression<'+'>(src.data<0>()[i]) : is_C99_unary_operator_expression<'-'>(src.data<0>()[i])); return true; }; } return false; } //! \throw std::bad_alloc() static bool locate_C99_unary_plusminus(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return false; return terse_locate_C99_unary_plusminus(src,i,types); } //! \throw std::bad_alloc() static bool locate_CPP_unary_plusminus(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return false; return terse_locate_CPP_unary_plusminus(src,i,types); } // handle C++0X sizeof... elsewhere (context-free syntax checks should be fixed first, possibly consider sizeof... a psuedo-identifier) //! \throw std::bad_alloc static bool terse_locate_C99_CPP_sizeof(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_string<6>(src.data<0>()[i].index_tokens[0].token,"sizeof")) { assert(1<src.size<0>()-i); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if ( (PARSE_UNARY_EXPRESSION & src.data<0>()[i+1].flags) || (is_naked_parentheses_pair(src.data<0>()[i+1]) && (PARSE_TYPE & src.data<0>()[i+1].flags))) { assemble_unary_postfix_arguments(src,i,C99_UNARY_SUBTYPE_SIZEOF); src.c_array<0>()[i].type_code.set_type(unsigned_type_from_machine_type(target_machine->size_t_type())); assert(is_C99_CPP_sizeof_expression(src.c_array<0>()[i])); return true; } } return false; } static size_t _eval_sizeof_core_type(const size_t base_type_index) { //! \todo eventually handle the floating and complex types here as well // floating is just a matter of modeling // complex may also involve ABI issues (cf. Intel) switch(base_type_index) { default: return 0; case C_TYPE::CHAR: case C_TYPE::SCHAR: case C_TYPE::UCHAR: // defined to be 1: C99 6.5.3.4p3, C++98 5.3.3p1, same paragraphs in C1X and C++0X return 1; case C_TYPE::SHRT: case C_TYPE::USHRT: return target_machine->C_sizeof_short(); case C_TYPE::INT: case C_TYPE::UINT: return target_machine->C_sizeof_int(); case C_TYPE::LONG: case C_TYPE::ULONG: return target_machine->C_sizeof_long(); case C_TYPE::LLONG: case C_TYPE::ULLONG: return target_machine->C_sizeof_long_long(); } #if 0 FLOAT, DOUBLE, LDOUBLE, FLOAT__COMPLEX, DOUBLE__COMPLEX, LDOUBLE__COMPLEX, #endif } //! \throw std::bad_alloc() static bool eval_sizeof_core_type(parse_tree& src,const size_t base_type_index,const type_system& types) { //! \todo eventually handle the floating and complex types here as well //! \todo types parameter is close to redundant // floating is just a matter of modeling // complex may also involve ABI issues (cf. Intel) const size_t fundamental_size = _eval_sizeof_core_type(base_type_index); if (0<fundamental_size) { parse_tree tmp; const size_t size_t_type = unsigned_type_from_machine_type(target_machine->size_t_type()); src.type_code.set_type(size_t_type); uint_to_literal(tmp,fundamental_size,src,types); tmp.MoveInto(src); assert(size_t_type==src.type_code.base_type_index); return true; } return false; } //! \throw std::bad_alloc() static bool eval_C99_CPP_sizeof(parse_tree& src,const type_system& types, func_traits<size_t (*)(parse_tree&,const type_system&)>::function_ref_type failover_sizeof) { assert(is_C99_CPP_sizeof_expression(src)); //! \todo error if given a function type //! \todo handle function pointers distinctly from data pointers const size_t size_t_type = unsigned_type_from_machine_type(target_machine->size_t_type()); size_t i = src.data<2>()->type_code.pointer_power; if (0==i) return eval_sizeof_core_type(src,src.data<2>()->type_code.base_type_index,types); { umaxint scaling(1,target_machine->unsigned_max(target_machine->size_t_type()).size()); { umaxint tmp2(target_machine->unsigned_max(target_machine->size_t_type())); const umaxint target_size_max(tmp2); umaxint tmp; bool want_fundamental = true; do { --i; if (type_spec::_array & src.data<2>()->type_code.qualifier(i+1)) { if (0>=src.data<2>()->type_code.extent_vector[i]) // C99 variable-length array: can't sizeof it at compile time return false; tmp = src.data<2>()->type_code.extent_vector[i]; } else{ // data pointer (for now); 0==i actually could be function pointer tmp = _eval_sizeof_core_type(unsigned_type_from_machine_type(target_machine->size_t_type())); assert(0<tmp); want_fundamental = false; } if (1<tmp) { tmp2 /= scaling; if (tmp2<tmp) { simple_error(src," sizeof operator evaluation failed: object is larger than target SIZE_MAX bytes."); return false; } tmp2 = target_size_max; scaling *= tmp; } } while(0<i && want_fundamental); if (want_fundamental) { tmp = _eval_sizeof_core_type(src.data<2>()->type_code.base_type_index); if (0==tmp) tmp = failover_sizeof(src,types); if (0==tmp) return false; else if (1<tmp) { tmp2 /= scaling; if (tmp2<tmp) { simple_error(src," sizeof operator evaluation failed: object is larger than target SIZE_MAX bytes."); return false; } scaling *= tmp; } //! \todo handle struct, union, class here (or maybe as part of core type wrapper) // enum is post-processed due to differences between C, C++ } } parse_tree tmp3; src.type_code.set_type(size_t_type); VM_to_literal(tmp3,scaling,src,types); tmp3.MoveInto(src); } assert(size_t_type==src.type_code.base_type_index); return true; } static size_t _C99_failover_sizeof(parse_tree& src,const type_system& types) { if (const enum_def* const tmp = types.get_enum_def(src.data<2>()->type_code.base_type_index)) { if (0==src.data<2>()->type_code.pointer_power && is_noticed_enumerator(src,types)) return _eval_sizeof_core_type(C_TYPE::INT); // type is int per C99 6.7.2.2p3 if (!tmp->represent_as) { simple_error(src," applies sizeof to incomplete enumeration (C99 6.5.3.4p1)"); return false; } // process tmp->represent_as as a core type // C99 6.7.2.2p4 merely requires the underlying type to be able to represent all values assert(C_TYPE::CHAR<=tmp->represent_as && C_TYPE::INT>=tmp->represent_as); return _eval_sizeof_core_type(tmp->represent_as); } return 0; } //! \throw std::bad_alloc() static bool eval_C99_sizeof(parse_tree& src,const type_system& types) { assert(is_C99_CPP_sizeof_expression(src)); return eval_C99_CPP_sizeof(src,types,_C99_failover_sizeof); } static size_t _CPP_failover_sizeof(parse_tree& src,const type_system& types) { if (C_TYPE::WCHAR_T==src.data<2>()->type_code.base_type_index) return _eval_sizeof_core_type(unsigned_type_from_machine_type(target_machine->UNICODE_wchar_t())); if (const enum_def* const tmp = types.get_enum_def(src.data<2>()->type_code.base_type_index)) { if (0==src.data<2>()->type_code.pointer_power && is_noticed_enumerator(*src.data<2>(),types)) { const type_system::enumerator_info* const tmp2 = types.get_enumerator(src.data<2>()->index_tokens[0].token.first); assert(tmp2); assert(C_TYPE::INT<=tmp2->second.first.second && C_TYPE::ULLONG>=tmp2->second.first.second); return _eval_sizeof_core_type(tmp2->second.first.second); } if (!tmp->represent_as) { simple_error(src," applies sizeof to incomplete enumeration (C++98 5.3.3p1)"); return false; } // C++0X 7.2p6 merely requires the underlying type to be able to represent all values assert(C_TYPE::CHAR<=tmp->represent_as && C_TYPE::ULLONG>=tmp->represent_as); return _eval_sizeof_core_type(tmp->represent_as); } return 0; } //! \throw std::bad_alloc() static bool eval_CPP_sizeof(parse_tree& src,const type_system& types) { assert(is_C99_CPP_sizeof_expression(src)); return eval_C99_CPP_sizeof(src,types,_CPP_failover_sizeof); } //! \throw std::bad_alloc() static void C99_sizeof_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_CPP_sizeof_expression(src)); //! \todo intercept incomplete types, function types here if (eval_C99_sizeof(src,types)) return; } //! \throw std::bad_alloc() static void CPP_sizeof_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_CPP_sizeof_expression(src)); //! \todo intercept incomplete types, function types here if (eval_CPP_sizeof(src,types)) return; } //! \throw std::bad_alloc() static bool locate_C99_sizeof(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_C99_CPP_sizeof(src,i,types)) { C99_sizeof_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } //! \throw std::bad_alloc() static bool locate_CPP_sizeof(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_C99_CPP_sizeof(src,i,types)) { CPP_sizeof_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } // handle our extension __zcc_linkage //! \throw std::bad_alloc static bool terse_locate_ZCC_linkage(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_string<13>(src.data<0>()[i].index_tokens[0].token,"__zcc_linkage")) { assert(1<src.size<0>()-i); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i+1])) C_deref_easy_syntax_check(src.c_array<0>()[i+1],types); if ( src.data<0>()[i+1].is_atomic() && C_TESTFLAG_IDENTIFIER==src.data<0>()[i+1].index_tokens[0].flags) { assemble_unary_postfix_arguments(src,i,ZCC_UNARY_SUBTYPE_LINKAGE); src.c_array<0>()[i].type_code.set_type(C_TYPE::INT); //! \todo would be nice to range-limit this assert(is_ZCC_linkage_expression(src.c_array<0>()[i])); return true; } // we don't actually know how to evaluate these -- it could get messy if (is_naked_parentheses_pair(src.data<0>()[i+1])) { assemble_unary_postfix_arguments(src,i,ZCC_UNARY_SUBTYPE_LINKAGE); src.c_array<0>()[i].type_code.set_type(C_TYPE::INT); //! \todo would be nice to range-limit this assert(is_ZCC_linkage_expression(src.c_array<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc() static bool eval_C99_ZCC_linkage(parse_tree& src,const type_system& types) { assert(is_ZCC_linkage_expression(src)); if ( 1==src.size<2>() && src.data<2>()->is_atomic() && C_TESTFLAG_IDENTIFIER==src.data<2>()->index_tokens[0].flags) { const int tmp = C99_echo_reserved_keyword(src.data<2>()->index_tokens[0].token.first,src.data<2>()->index_tokens[0].token.second) ? -1 : types.C_linkage_code(src.data<2>()->index_tokens[0].token.first); const bool is_negative = 0>tmp; const umaxint tmp2(is_negative ? -tmp : tmp); parse_tree tmp3; src.type_code.set_type(C_TYPE::INT); VM_to_signed_literal(tmp3,is_negative,tmp2,src,types); tmp3.MoveInto(src); return true; } return false; } // deferring namespaces is not going to work, what about resolving identifiers as primary expressions // maybe go with a Perl-localization //! \throw std::bad_alloc() static bool eval_CPP_ZCC_linkage(parse_tree& src,const type_system& types) { assert(is_ZCC_linkage_expression(src)); if ( 1==src.size<2>() && src.data<2>()->is_atomic() && C_TESTFLAG_IDENTIFIER==src.data<2>()->index_tokens[0].flags) { const int tmp = CPP_echo_reserved_keyword(src.data<2>()->index_tokens[0].token.first,src.data<2>()->index_tokens[0].token.second) ? -1 : types.CPP_linkage_code(src.data<2>()->index_tokens[0].token.first,parse_tree::active_namespace); const bool is_negative = 0>tmp; const umaxint tmp2(is_negative ? -tmp : tmp); parse_tree tmp3; src.type_code.set_type(C_TYPE::INT); VM_to_signed_literal(tmp3,is_negative,tmp2,src,types); tmp3.MoveInto(src); return true; } return false; } //! \throw std::bad_alloc() static void C99_ZCC_linkage_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_ZCC_linkage_expression(src)); if (eval_C99_ZCC_linkage(src,types)) return; } //! \throw std::bad_alloc() static void CPP_ZCC_linkage_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_ZCC_linkage_expression(src)); if (eval_CPP_ZCC_linkage(src,types)) return; } //! \throw std::bad_alloc() static bool locate_C99_ZCC_linkage(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_ZCC_linkage(src,i,types)) { C99_ZCC_linkage_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } //! \throw std::bad_alloc() static bool locate_CPP_ZCC_linkage(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( !(PARSE_OBVIOUS & src.data<0>()[i].flags) && src.data<0>()[i].is_atomic() && terse_locate_ZCC_linkage(src,i,types)) { CPP_ZCC_linkage_easy_syntax_check(src.c_array<0>()[i],types); return true; } return false; } /* Scan for unary operators and cast expressions unary-expression: postfix-expression ++ unary-expression -- unary-expression unary-operator cast-expression sizeof unary-expression sizeof ( type-name ) unary-operator: one of & * + - ~ ! cast-expression: unary-expression ( type-name ) cast-expression Note that the binary operators *,+,- are effectively handled by first building the unary operator, then checking whether the left-hand-side qualifies for extension to binary operator */ //! \throw std::bad_alloc() static void locate_C99_unary_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_deref(src,i,types)) return; if (locate_C99_logical_NOT(src,i,types)) return; if (locate_C99_bitwise_complement(src,i,types)) return; if (locate_C99_unary_plusminus(src,i,types)) return; if (locate_C99_sizeof(src,i,types)) return; if (locate_C99_ZCC_linkage(src,i,types)) return; #if 0 if (terse_locate_unary_operator(src,i)) { C_unary_op_easy_syntax_check(src.c_array<0>()[i],types); return; } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"++")) { } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"--")) { } else if ( token_is_char<'('>(src.data<0>()[i].index_tokens[0].token) && token_is_char<')'>(src.data<0>()[i].index_tokens[1].token)) { } #endif } /* Scan for unary expressions and cast expressions unaryexpression: postfixexpression ++ castexpression -- castexpression unaryoperator castexpression sizeof unaryexpression sizeof ( typeid ) newexpression deleteexpression unaryoperator: one of * & + - ! ~ note that compl, not end up here as well. compl may be used to make psuedo-destructor interpretation illegal note that bitand does *not* end up here, so it can prevent inadvertently taking an address castexpression: unaryexpression ( typeid ) castexpression deleteexpression: ::opt delete castexpression ::opt delete [ ] castexpression newexpression: ::opt new newplacementopt newtypeid newinitializeropt ::opt new newplacementopt ( typeid) newinitializeropt newplacement: ( expressionlist ) newtypeid: typespecifierseq newdeclaratoropt newdeclarator: ptroperator newdeclaratoropt directnewdeclarator directnewdeclarator: [ expression ] directnewdeclarator [ constantexpression ] newinitializer: ( expressionlistopt ) Note that the binary operators *,+,- are effectively handled by first building the unary operator, then checking whether the left-hand-side qualifies for extension to binary operator */ //! \throw std::bad_alloc() static void locate_CPP_unary_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_deref(src,i,types)) return; if (locate_CPP_logical_NOT(src,i,types)) return; if (locate_CPP_bitwise_complement(src,i,types)) return; if (locate_CPP_unary_plusminus(src,i,types)) return; if (locate_CPP_sizeof(src,i,types)) return; if (locate_CPP_ZCC_linkage(src,i,types)) return; #if 0 if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"++")) { } else if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"--")) { } else if ( token_is_char<'('>(src.data<0>()[i].index_tokens[0].token) && token_is_char<')'>(src.data<0>()[i].index_tokens[1].token)) { } else if (token_is_string<3>(src.data<0>()[i].index_tokens[0].token,"new")) { } else if (token_is_string<6>(src.data<0>()[i].index_tokens[0].token,"delete")) { } #endif } //! \throw std::bad_alloc() static void assemble_binary_infix_arguments(parse_tree& src, size_t& i, const lex_flags _flags) { assert(1<=i && 2<=src.size<0>()-i); { parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); zaimoni::autoval_ptr<parse_tree> tmp; tmp = repurpose_inner_parentheses(tmp_c_array[0]); // RAM conservation parse_tree* const tmp2 = repurpose_inner_parentheses(tmp_c_array[2]); // RAM conservation tmp_c_array[0].OverwriteInto(*tmp); tmp_c_array[2].OverwriteInto(*tmp2); tmp_c_array[1].fast_set_arg<1>(tmp.release()); tmp_c_array[1].fast_set_arg<2>(tmp2); tmp_c_array[1].core_flag_update(); tmp_c_array[1].flags |= _flags; } src.DeleteIdx<0>(i+1); src.DeleteIdx<0>(--i); parse_tree& tmp = src.c_array<0>()[i]; cancel_outermost_parentheses(tmp.c_array<1>()[0]); cancel_outermost_parentheses(tmp.c_array<2>()[0]); } //! \throw std::bad_alloc() static void merge_binary_infix_argument(parse_tree& src, size_t& i, const lex_flags _flags) { assert(1<=i); { parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); parse_tree* const tmp = repurpose_inner_parentheses(tmp_c_array[0]); // RAM conservation tmp_c_array[0].OverwriteInto(*tmp); tmp_c_array[1].fast_set_arg<1>(tmp); tmp_c_array[1].core_flag_update(); tmp_c_array[1].flags |= _flags; } src.DeleteIdx<0>(--i); cancel_outermost_parentheses(src.c_array<0>()[i].c_array<1>()[0]); } //! \throw std::bad_alloc() static bool terse_C99_augment_mult_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i])) { if (1<=i && (PARSE_MULT_EXPRESSION & src.data<0>()[i-1].flags)) { // check for unary +/- with type NOT_VOID // if found, split out the +/- into slot i and adjust i up before proceeding if ( is_C99_unary_operator_expression<'+'>(src.data<0>()[i-1]) || is_C99_unary_operator_expression<'-'>(src.data<0>()[i-1])) { if (src.data<0>()[i-1].type_code.is_type<C_TYPE::NOT_VOID>()) { src._args[0].insertNSlotsAt(1,i); src.c_array<0>()[i].clear(); src.c_array<0>()[i-1].front<2>().MoveInto(src.c_array<0>()[i]); src.c_array<0>()[i-1].DeleteIdx<2>(0); src.c_array<0>()[i-1].type_code.base_type_index = 0; ++i; assert(PARSE_MULT_EXPRESSION & src.data<0>()[i-1].flags); assert(is_C99_unary_operator_expression<'*'>(src.data<0>()[i])); } } merge_binary_infix_argument(src,i,PARSE_STRICT_MULT_EXPRESSION); assert(is_C99_mult_operator_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_mult_operator_expression(src.data<0>()[i])); return true; }; // run syntax-checks against unary * C_deref_easy_syntax_check(src.c_array<0>()[i],types); } return false; } //! \throw std::bad_alloc() static bool terse_CPP_augment_mult_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (is_C99_unary_operator_expression<'*'>(src.data<0>()[i])) { if (1<=i && (inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]),(PARSE_MULT_EXPRESSION & src.data<0>()[i-1].flags))) { // check for unary +/- with type NOT_VOID // if found, split out the +/- into slot i and adjust i up before proceeding if ( is_C99_unary_operator_expression<'+'>(src.data<0>()[i-1]) || is_C99_unary_operator_expression<'-'>(src.data<0>()[i-1])) { if (src.data<0>()[i-1].type_code.is_type<C_TYPE::NOT_VOID>()) { src._args[0].insertNSlotsAt(1,i); src.c_array<0>()[i].clear(); src.c_array<0>()[i-1].front<2>().MoveInto(src.c_array<0>()[i]); src.c_array<0>()[i-1].DeleteIdx<2>(0); src.c_array<0>()[i-1].type_code.base_type_index = 0; ++i; assert(PARSE_MULT_EXPRESSION & src.data<0>()[i-1].flags); assert(is_C99_unary_operator_expression<'*'>(src.data<0>()[i])); } } merge_binary_infix_argument(src,i,PARSE_STRICT_MULT_EXPRESSION); assert(is_C99_mult_operator_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_mult_operator_expression(src.data<0>()[i])); return true; }; // run syntax-checks against unary * //! \todo handle operator overloading C_deref_easy_syntax_check(src.c_array<0>()[i],types); } return false; } //! \throw std::bad_alloc() static bool terse_locate_mult_expression(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t mult_subtype = (token_is_char<'/'>(src.data<0>()[i].index_tokens[0].token)) ? C99_MULT_SUBTYPE_DIV : (token_is_char<'%'>(src.data<0>()[i].index_tokens[0].token)) ? C99_MULT_SUBTYPE_MOD : (token_is_char<'*'>(src.data<0>()[i].index_tokens[0].token)) ? C99_MULT_SUBTYPE_MULT : 0; if (mult_subtype) { if (1>i || 2>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ((PARSE_MULT_EXPRESSION & tmp_c_array[0].flags) && (PARSE_PM_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_MULT_EXPRESSION); // tmp_c_array goes invalid here assert(is_C99_mult_operator_expression(src.data<0>()[i])); { parse_tree& tmp = src.c_array<0>()[i]; tmp.subtype = mult_subtype; tmp.type_code.set_type(0); // handle type inference later } assert(is_C99_mult_operator_expression(src.data<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc() static bool eval_mult_expression(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_C99_mult_operator_expression<'*'>(src)); bool is_true = false; // do this first to avoid unnecessary dynamic memory allocation if ( (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) // 0 * __ || (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true)) // __ * 0 { // construct +0 to defuse 1-0*6 parse_tree tmp = decimal_literal("0",src,types); if (C_TYPE::INTEGERLIKE==src.type_code.base_type_index) { message_header(src.index_tokens[0]); INC_INFORM("invalid "); INC_INFORM(src); INFORM(" optimized to valid 0"); tmp.type_code.set_type(C_TYPE::LLONG); // legalize } else value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; }; umaxint res_int; umaxint rhs_int; const bool lhs_converted = intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (lhs_converted && 1==res_int) { src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); return true; }; if (rhs_converted && 1==rhs_int) { src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; }; if (lhs_converted && rhs_converted) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs const bool lhs_negative = target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,old); if (old.is_signed) { // signed integer result: overflow is undefined umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); const bool tweak_ub = rhs_negative!=lhs_negative && virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps]; if (rhs_negative) target_machine->signed_additive_inverse(rhs_test,old.machine_type); if (lhs_negative) target_machine->signed_additive_inverse(lhs_test,old.machine_type); if (tweak_ub) ub += 1; if (ub<lhs_test || ub<rhs_test) { if (!no_runtime_errors) //! \todo catch this in two's-complement specific testing simple_error(src," signed * overflow, undefined behavior (C99 6.5p5, C++98 5p5)"); return false; } const bool lhs_lt_rhs = lhs_test<rhs_test; ub /= (lhs_lt_rhs) ? rhs_test : lhs_test; if (ub<(lhs_lt_rhs ? lhs_test : rhs_test)) { //! \test if.C99/Pass_conditional_op_noeval.hpp, if.C99/Pass_conditional_op_noeval.h if (!no_runtime_errors) //! \test default/Error_if_control29.hpp, default/Error_if_control29.h simple_error(src," signed * overflow, undefined behavior (C99 6.5p5, C++98 5p5)"); return false; } lhs_test *= rhs_test; if (rhs_negative!=lhs_negative) { // valid result, but not representable: do not reduce (errors out spuriously) if (tweak_ub && target_machine->signed_max(old.machine_type)<lhs_test) return false; target_machine->signed_additive_inverse(lhs_test,old.machine_type); // convert to parsed - literal parse_tree tmp; VM_to_literal(tmp,lhs_test,src,types); src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); return true; } res_int = lhs_test; } else res_int *= rhs_int; // convert to parsed + literal parse_tree tmp; VM_to_literal(tmp,res_int,src,types); value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } return false; } //! \throw std::bad_alloc() static bool eval_div_expression(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_C99_mult_operator_expression<'/'>(src)); bool is_true = false; if (converts_to_integerlike(src.type_code ARG_TYPES)) { if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { //! \test if.C99/Pass_conditional_op_noeval.hpp, if.C99/Pass_conditional_op_noeval.h if (!no_runtime_errors) //! \test default/Error_if_control30.hpp, default/Error_if_control30.h simple_error(src," division by zero, undefined behavior (C99 6.5.5p5, C++98 5.6p4)"); return false; } /*! \todo would like a simple comparison of absolute values to auto-detect zero, possibly after mainline code */ else if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) { // construct +0 to defuse 1-0/6 parse_tree tmp = decimal_literal("0",src,types); if (C_TYPE::INTEGERLIKE==src.type_code.base_type_index) { message_header(src.index_tokens[0]); INC_INFORM("invalid "); INC_INFORM(src); INFORM(" optimized to valid 0"); tmp.type_code.set_type(C_TYPE::LLONG); // legalize } else value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } //! \todo change target for formal verification; would like to inject a constraint against div-by-integer-zero here }; umaxint res_int; umaxint rhs_int; const bool lhs_converted = intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (rhs_converted && rhs_int==1) { // __/1 |-> __ src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; }; // two's complement can overflow: INT_MIN/-1 // implementation-defined whether negative results round away or to zero (standard prefers to zero, so default to that) if (lhs_converted && rhs_converted) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs const bool lhs_negative = target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,old); if (old.is_signed) { // signed integer result umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); if (rhs_negative) target_machine->signed_additive_inverse(rhs_test,old.machine_type); if (lhs_negative) target_machine->signed_additive_inverse(lhs_test,old.machine_type); if (rhs_negative!=lhs_negative && virtual_machine::twos_complement==target_machine->C_signed_int_representation()) ub += 1; if (lhs_test<rhs_test) { const bool want_zero = rhs_negative==lhs_negative || !bool_options[boolopt::int_neg_div_rounds_away_from_zero]; parse_tree tmp = decimal_literal(want_zero ? "0" : "1",src,types); src.DeleteIdx<1>(0); if (want_zero) { value_copy(tmp.type_code,src.type_code); force_unary_positive_literal(src,tmp ARG_TYPES); // +0 } else force_unary_negative_literal(src,tmp); // -1 return true; } bool round_away = false; if (rhs_negative!=lhs_negative && bool_options[boolopt::int_neg_div_rounds_away_from_zero]) { umaxint lhs_mod_test(lhs_test); lhs_mod_test %= rhs_test; round_away = 0!=lhs_mod_test; } lhs_test /= rhs_test; if (rhs_negative!=lhs_negative) { if (round_away) lhs_test += 1; target_machine->signed_additive_inverse(lhs_test,old.machine_type); // convert to parsed - literal parse_tree tmp; VM_to_literal(tmp,lhs_test,src,types); src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); return true; } if (ub<lhs_test) { //! \todo test this in two's complement code assert(virtual_machine::twos_complement==target_machine->C_signed_int_representation()); if (!no_runtime_errors) simple_error(src," signed / overflow, undefined behavior (C99 6.5p5, C++98 5p5)"); return false; } res_int = lhs_test; } else res_int /= rhs_int; // convert to parsed + literal parse_tree tmp; VM_to_literal(tmp,res_int,src,types); value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } return false; } //! \throw std::bad_alloc() static bool eval_mod_expression(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_C99_mult_operator_expression<'%'>(src)); bool is_true = false; if (converts_to_integerlike(src.type_code ARG_TYPES)) { if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { //! \test if.C99/Pass_conditional_op_noeval.hpp, if.C99/Pass_conditional_op_noeval.h if (!no_runtime_errors) //! \test default/Error_if_control31.hpp, Error_if_control31.h simple_error(src," modulo by zero, undefined behavior (C99 6.5.5p5, C++98 5.6p4)"); return false; } /*! \todo would like a simple comparison of absolute values to auto-detect zero, possibly after mainline code */ else if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) { // construct +0 to defuse 1-0%6 parse_tree tmp = decimal_literal("0",src,types); if (C_TYPE::INTEGERLIKE==src.type_code.base_type_index) { message_header(src.index_tokens[0]); INC_INFORM("invalid "); INC_INFORM(src); INFORM(" optimized to valid 0"); tmp.type_code.set_type(C_TYPE::LLONG); // legalize } else value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } //! \todo change target for formal verification; would like to inject a constraint against div-by-integer-zero here }; umaxint res_int; umaxint rhs_int; const bool lhs_converted = intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (rhs_converted && rhs_int==1) { // __%1 |-> +0 parse_tree tmp = decimal_literal("0",src,types); if (C_TYPE::INTEGERLIKE!=src.type_code.base_type_index) value_copy(tmp.type_code,src.type_code); else tmp.type_code.set_type(C_TYPE::LLONG); // legalize src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; }; if (lhs_converted && rhs_converted) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs const bool lhs_negative = target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,old); if (old.is_signed) { // signed integer result umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); if (rhs_negative) target_machine->signed_additive_inverse(rhs_test,old.machine_type); if (lhs_negative) target_machine->signed_additive_inverse(lhs_test,old.machine_type); if (rhs_negative!=lhs_negative && virtual_machine::twos_complement==target_machine->C_signed_int_representation()) ub += 1; lhs_test %= rhs_test; if (0!=lhs_test && rhs_negative!=lhs_negative) { if (!bool_options[boolopt::int_neg_div_rounds_away_from_zero]) { // convert to parsed - literal parse_tree tmp; VM_to_literal(tmp,lhs_test,src,types); src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); return true; }; rhs_test -= lhs_test; lhs_test = rhs_test; }; res_int = lhs_test; } else // unsigned integer result: C99 6.3.1.3p2 dictates modulo conversion to unsigned res_int %= rhs_int; // convert to parsed + literal parse_tree tmp; VM_to_literal(tmp,res_int,src,types); value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } return false; } BOOST_STATIC_ASSERT(1==C99_MULT_SUBTYPE_MOD-C99_MULT_SUBTYPE_DIV); BOOST_STATIC_ASSERT(1==C99_MULT_SUBTYPE_MULT-C99_MULT_SUBTYPE_MOD); //! \throw std::bad_alloc static bool _mod_expression_typecheck(parse_tree& src SIG_CONST_TYPES) { assert(C99_MULT_SUBTYPE_MOD==src.subtype && is_C99_mult_operator_expression<'%'>(src)); POD_pair<size_t,bool> lhs = default_promotion_is_integerlike(src.data<1>()->type_code ARG_TYPES); POD_pair<size_t,bool> rhs = default_promotion_is_integerlike(src.data<2>()->type_code ARG_TYPES); if (!lhs.second) { //! \test default/Error_if_control33.hpp, default/Error_if_control33.h //! \test default/Error_if_control34.hpp, default/Error_if_control34.h simple_error(src,rhs.second ? " has nonintegral LHS (C99 6.5.5p2, C++98 5.6p2)" : " has nonintegral LHS and RHS (C99 6.5.5p2, C++98 5.6p2)"); return false; } else if (!rhs.second) { //! \test default/Error_if_control32.hpp, default/Error_if_control32.h simple_error(src," has nonintegral RHS (C99 6.5.5p2, C++98 5.6p2)"); return false; }; if (is_noticed_enumerator(*src.data<1>(),types)) { enumerator_to_integer_representation(*src.c_array<1>(),types); lhs = default_promotion_is_integerlike(src.data<1>()->type_code,types); assert(lhs.second); } if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); rhs = default_promotion_is_integerlike(src.data<2>()->type_code,types); assert(rhs.second); } src.type_code.set_type(arithmetic_reconcile(lhs.first,rhs.first ARG_TYPES)); return true; } //! \throw std::bad_alloc static bool _mult_div_expression_typecheck(parse_tree& src SIG_CONST_TYPES) { assert(C99_MULT_SUBTYPE_DIV==src.subtype || C99_MULT_SUBTYPE_MULT==src.subtype); assert((C99_MULT_SUBTYPE_DIV==src.subtype) ? is_C99_mult_operator_expression<'/'>(src) : is_C99_mult_operator_expression<'*'>(src)); POD_pair<size_t,bool> lhs = default_promotion_is_arithmeticlike(src.data<1>()->type_code ARG_TYPES); POD_pair<size_t,bool> rhs = default_promotion_is_arithmeticlike(src.data<2>()->type_code ARG_TYPES); if (!lhs.second) { //! \test default/Error_if_control36.hpp, default/Error_if_control36.h //! \test default/Error_if_control37.hpp, default/Error_if_control37.h //! \test default/Error_if_control39.hpp, default/Error_if_control39.h //! \test default/Error_if_control40.hpp, default/Error_if_control40.h simple_error(src,rhs.second ? " has nonarithmetic LHS (C99 6.5.5p2, C++98 5.6p2)" : " has nonarithmetic LHS and RHS (C99 6.5.5p2, C++98 5.6p2)"); return false; } else if (!rhs.second) { //! \test default/Error_if_control35.hpp, default/Error_if_control35.h //! \test default/Error_if_control38.hpp, default/Error_if_control38.h simple_error(src," has nonarithmetic RHS (C99 6.5.5p2, C++98 5.6p2)"); return false; }; // arithmeticlike subsumes integerlike so this is fine if (is_noticed_enumerator(*src.data<1>(),types)) { enumerator_to_integer_representation(*src.c_array<1>(),types); lhs = default_promotion_is_integerlike(src.data<1>()->type_code,types); assert(lhs.second); } if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); rhs = default_promotion_is_integerlike(src.data<2>()->type_code,types); assert(rhs.second); } src.type_code.set_type(arithmetic_reconcile(lhs.first,rhs.first ARG_TYPES)); return true; } //! \throw std::bad_alloc() static void C_mult_expression_easy_syntax_check(parse_tree& src,const type_system& types) { assert(C99_MULT_SUBTYPE_DIV<=src.subtype && C99_MULT_SUBTYPE_MULT>=src.subtype); assert((C99_MULT_SUBTYPE_DIV==src.subtype) ? is_C99_mult_operator_expression<'/'>(src) : (C99_MULT_SUBTYPE_MULT==src.subtype) ? is_C99_mult_operator_expression<'*'>(src) : is_C99_mult_operator_expression<'%'>(src)); // note that 0*integerlike and so on are invalid, but do optimize to valid (but this is probably worth a separate execution path) if (C99_MULT_SUBTYPE_MOD==src.subtype) { // require integral type if (!_mod_expression_typecheck(src ARG_TYPES)) return; zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_mod_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); } else{ // require arithmetic type if (!_mult_div_expression_typecheck(src ARG_TYPES)) return; zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (C99_MULT_SUBTYPE_MULT==src.subtype) eval_mult_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); else eval_div_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); } } //! \throw std::bad_alloc() static void CPP_mult_expression_easy_syntax_check(parse_tree& src,const type_system& types) { assert(C99_MULT_SUBTYPE_DIV<=src.subtype && C99_MULT_SUBTYPE_MULT>=src.subtype); assert((C99_MULT_SUBTYPE_DIV==src.subtype) ? is_C99_mult_operator_expression<'/'>(src) : (C99_MULT_SUBTYPE_MULT==src.subtype) ? is_C99_mult_operator_expression<'*'>(src) : is_C99_mult_operator_expression<'%'>(src)); if (C99_MULT_SUBTYPE_MOD==src.subtype) { // require integral type if (!_mod_expression_typecheck(src ARG_TYPES)) return; zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_mod_expression(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); } else{ // require arithmetic type if (!_mult_div_expression_typecheck(src ARG_TYPES)) return; zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (C99_MULT_SUBTYPE_MULT==src.subtype) eval_mult_expression(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); else eval_div_expression(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); } } /* multiplicative-expression: cast-expression multiplicative-expression * cast-expression multiplicative-expression / cast-expression multiplicative-expression % cast-expression */ //! \throw std::bad_alloc() static void locate_C99_mult_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (terse_C99_augment_mult_expression(src,i,types)) { C_mult_expression_easy_syntax_check(src.c_array<0>()[i],types); // reconstitute raw +- from terse_C99_augment_mult_expression into unary +- if (0<i) { // synchronize with locate_C99_unary_plusminus if (const size_t unary_subtype = token_is_char<'-'>(src.data<0>()[i-1].index_tokens[0].token) ? C99_UNARY_SUBTYPE_NEG : token_is_char<'+'>(src.data<0>()[i-1].index_tokens[0].token) ? C99_UNARY_SUBTYPE_PLUS : 0) { assemble_unary_postfix_arguments(src,i-1,unary_subtype); // doesn't work: reference to temporary src.c_array<0>()[i-1].type_code.set_type(C_TYPE::NOT_VOID); // defer to later assert((C99_UNARY_SUBTYPE_PLUS==unary_subtype) ? is_C99_unary_operator_expression<'+'>(src.data<0>()[i-1]) : is_C99_unary_operator_expression<'-'>(src.data<0>()[i-1])); }; } return; } if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_mult_expression(src,i)) C_mult_expression_easy_syntax_check(src.c_array<0>()[i],types); } /* multexpression: pmexpression multexpression * pmexpression multexpression / pmexpression multexpression % pmexpression */ //! \throw std::bad_alloc() static void locate_CPP_mult_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (terse_CPP_augment_mult_expression(src,i,types)) { //! \todo handle operator overloading CPP_mult_expression_easy_syntax_check(src.c_array<0>()[i],types); // reconstitute raw +- from terse_CPP_augment_mult_expression into unary +- if (0<i) { // synchronize with locate_CPP_unary_plusminus if (const size_t unary_subtype = token_is_char<'-'>(src.data<0>()[i-1].index_tokens[0].token) ? C99_UNARY_SUBTYPE_NEG : token_is_char<'+'>(src.data<0>()[i-1].index_tokens[0].token) ? C99_UNARY_SUBTYPE_PLUS : 0) { assemble_unary_postfix_arguments(src,i-1,unary_subtype); src.c_array<0>()[i-1].type_code.set_type(C_TYPE::NOT_VOID); // defer to later assert((C99_UNARY_SUBTYPE_PLUS==unary_subtype) ? is_C99_unary_operator_expression<'+'>(src.data<0>()[i-1]) : is_C99_unary_operator_expression<'-'>(src.data<0>()[i-1])); }; } return; } if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_mult_expression(src,i)) //! \todo handle operator overloading CPP_mult_expression_easy_syntax_check(src.c_array<0>()[i],types); } // Law of Demeter conversion is object-size neutral [Dec. 9 2009], so don't do it static bool C_string_literal_equal_content(const parse_tree& lhs, const parse_tree& rhs,bool& is_equal) { if (C_TESTFLAG_STRING_LITERAL==lhs.index_tokens[0].flags && C_TESTFLAG_STRING_LITERAL==rhs.index_tokens[0].flags) { const size_t lhs_len = LengthOfCStringLiteral(lhs.index_tokens[0].token.first,lhs.index_tokens[0].token.second); if (LengthOfCStringLiteral(rhs.index_tokens[0].token.first,rhs.index_tokens[0].token.second)!=lhs_len) { // string literals of different length are necessarily different decayed pointers even if they overlap is_equal = false; return true; }; if (('L'==*lhs.index_tokens[0].token.first)!=('L'==*rhs.index_tokens[0].token.first)) { // wide string literals never overlap with narrow string literals with the same character values //! \todo check language standards: is it implementation-defined whether a wide-string character literal //! can overlap a narrow-string character literal with a suitable placement of NUL bytes? is_equal = false; return true; }; size_t i = 0; while(i<lhs_len-1) { char* const lhs_lit = GetCCharacterLiteralAt(lhs.index_tokens[0].token.first,lhs.index_tokens[0].token.second,i); char* const rhs_lit = GetCCharacterLiteralAt(rhs.index_tokens[0].token.first,rhs.index_tokens[0].token.second,i); const uintmax_t lhs_val = EvalCharacterLiteral(lhs_lit,strlen(lhs_lit)); const uintmax_t rhs_val = EvalCharacterLiteral(rhs_lit,strlen(rhs_lit)); free(lhs_lit); free(rhs_lit); if (lhs_val!=rhs_val) { // different at this place, so different is_equal = false; return true; } ++i; } // assume hyper-optimizing linker; the string literals overlap is_equal = true; return true; } return false; } //! \throw std::bad_alloc() static bool terse_C99_augment_add_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (is_C99_unary_operator_expression<'+'>(src.data<0>()[i]) || is_C99_unary_operator_expression<'-'>(src.data<0>()[i])) { if (1<=i && (inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]),(PARSE_ADD_EXPRESSION & src.data<0>()[i-1].flags))) { merge_binary_infix_argument(src,i,PARSE_STRICT_ADD_EXPRESSION); assert(is_C99_add_operator_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_add_operator_expression(src.data<0>()[i])); return true; }; // run syntax-checks against unary + or unary - C_unary_plusminus_easy_syntax_check(src.c_array<0>()[i],types); } return false; } //! \throw std::bad_alloc() static bool terse_CPP_augment_add_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (is_C99_unary_operator_expression<'+'>(src.data<0>()[i]) || is_C99_unary_operator_expression<'-'>(src.data<0>()[i])) { if (1<=i && (inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]),(PARSE_ADD_EXPRESSION & src.data<0>()[i-1].flags))) { merge_binary_infix_argument(src,i,PARSE_STRICT_ADD_EXPRESSION); assert(is_C99_add_operator_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_add_operator_expression(src.data<0>()[i])); return true; }; // run syntax-checks against unary + or unary - CPP_unary_plusminus_easy_syntax_check(src.c_array<0>()[i],types); } return false; } //! \throw std::bad_alloc() static bool terse_locate_add_expression(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t add_subtype = (token_is_char<'+'>(src.data<0>()[i].index_tokens[0].token)) ? C99_ADD_SUBTYPE_PLUS : (token_is_char<'-'>(src.data<0>()[i].index_tokens[0].token)) ? C99_ADD_SUBTYPE_MINUS : 0; if (add_subtype) { if (1>i || 2>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_ADD_EXPRESSION & tmp_c_array[0].flags) && (PARSE_MULT_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_ADD_EXPRESSION); // tmp_c_array goes invalid here assert(is_C99_add_operator_expression(src.data<0>()[i])); parse_tree& tmp = src.c_array<0>()[i]; tmp.subtype = add_subtype; tmp.type_code.set_type(0); // handle type inference later assert(is_C99_add_operator_expression(src.data<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc() static bool eval_add_expression(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_C99_add_operator_expression<'+'>(src)); const size_t lhs_pointer = src.data<1>()->type_code.pointer_power; const size_t rhs_pointer = src.data<2>()->type_code.pointer_power; // void pointers should have been intercepted by now assert(1!=lhs_pointer || C_TYPE::VOID!=src.data<1>()->type_code.base_type_index); assert(1!=rhs_pointer || C_TYPE::VOID!=src.data<2>()->type_code.base_type_index); switch((0<lhs_pointer)+2*(0<rhs_pointer)) { #ifndef NDEBUG default: FATAL_CODE("hardware/compiler error: invalid linear combination in eval_add_expression",3); #endif case 0: { assert(converts_to_arithmeticlike(src.data<1>()->type_code.base_type_index ARG_TYPES)); assert(converts_to_arithmeticlike(src.data<2>()->type_code.base_type_index ARG_TYPES)); bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) { // 0 + __ |-> __ src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); return true; } else if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { // __ + 0 |-> __ src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; }; umaxint res_int; umaxint rhs_int; const promote_aux old(src.type_code.base_type_index ARG_TYPES); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); const bool lhs_converted = intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); const bool lhs_negative = lhs_converted && target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = rhs_converted && target_machine->C_promote_integer(rhs_int,rhs,old); if (lhs_converted && rhs_converted) { if (old.is_signed) { // signed integer result umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); bool result_is_negative = false; if (rhs_negative) target_machine->signed_additive_inverse(rhs_test,old.machine_type); if (lhs_negative) target_machine->signed_additive_inverse(lhs_test,old.machine_type); if (rhs_negative!=lhs_negative) { // cancellation...safe switch(cmp(lhs_test,rhs_test)) { case -1: result_is_negative = rhs_negative; rhs_test -= lhs_test; lhs_test = rhs_test; break; case 0: lhs_test.clear(); break; case 1: result_is_negative = lhs_negative; lhs_test -= rhs_test; break; }; } else{ // augmentation: bounds-check result_is_negative = lhs_negative; const bool tweak_ub = result_is_negative && virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps]; if (tweak_ub) ub += 1; if (ub<lhs_test || ub<rhs_test || (ub -= lhs_test)<rhs_test) { //! \test if.C99/Pass_conditional_op_noeval.hpp, if.C99/Pass_conditional_op_noeval.h if (!no_runtime_errors) //! \test default/Error_if_control41.hpp, default/Error_if_control41.h simple_error(src," signed + overflow, undefined behavior (C99 6.5p5, C++98 5p5)"); return false; }; lhs_test += rhs_test; // if we can't render it, do not reduce if (tweak_ub && target_machine->signed_max(old.machine_type)<lhs_test) return false; } if (result_is_negative) { // convert to parsed - literal parse_tree tmp; VM_to_literal(tmp,lhs_test,src,types); src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); return true; }; res_int = lhs_test; } else res_int += rhs_int; // convert to parsed + literal parse_tree tmp; VM_to_literal(tmp,res_int,src,types); value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } break; } case 1: { assert(converts_to_integerlike(src.data<2>()->type_code.base_type_index ARG_TYPES)); bool is_true = false; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { // __ + 0 |-> __ src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; } break; } case 2: { assert(converts_to_integerlike(src.data<1>()->type_code.base_type_index ARG_TYPES)); bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) { // 0 + __ |-> __ src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); return true; } break; } #ifndef NDEBUG case 3: FATAL_CODE("invalid expression not flagged as invalid expression",3); #endif } return false; } //! \throw std::bad_alloc() static bool eval_sub_expression(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(is_C99_add_operator_expression<'-'>(src)); const size_t lhs_pointer = src.data<1>()->type_code.pointer_power; const size_t rhs_pointer = src.data<2>()->type_code.pointer_power; // void pointers should have been intercepted by now assert(1!=lhs_pointer || C_TYPE::VOID!=src.data<1>()->type_code.base_type_index); assert(1!=rhs_pointer || C_TYPE::VOID!=src.data<2>()->type_code.base_type_index); switch((0<lhs_pointer)+2*(0<rhs_pointer)) { #ifndef NDEBUG default: FATAL_CODE("hardware/compiler error: invalid linear combination in eval_sub_expression",3); #endif case 0: { assert(converts_to_arithmeticlike(src.data<1>()->type_code.base_type_index ARG_TYPES)); assert(converts_to_arithmeticlike(src.data<2>()->type_code.base_type_index ARG_TYPES)); bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) { // 0 - __ |-> - __ src.DeleteIdx<1>(0); src.core_flag_update(); src.flags |= PARSE_STRICT_UNARY_EXPRESSION; src.subtype = C99_UNARY_SUBTYPE_NEG; assert(is_C99_unary_operator_expression<'-'>(src)); return true; } else if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { // __ - 0 |-> __ src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; } umaxint res_int; umaxint rhs_int; const bool lhs_converted = intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (lhs_converted && rhs_converted) { //! \todo deal with signed integer arithmetic const promote_aux old(src.type_code.base_type_index ARG_TYPES); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs const bool lhs_negative = target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,old); if (old.is_signed) { // signed integer result umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); bool result_is_negative = false; if (rhs_negative) target_machine->signed_additive_inverse(rhs_test,old.machine_type); if (lhs_negative) target_machine->signed_additive_inverse(lhs_test,old.machine_type); if (rhs_negative==lhs_negative) { // cancellation: safe switch(cmp(lhs_test,rhs_test)) { case -1: result_is_negative = !lhs_negative; rhs_test -= lhs_test; lhs_test = rhs_test; break; case 0: lhs_test.clear(); break; case 1: result_is_negative = lhs_negative; lhs_test -= rhs_test; break; }; } else{ // augmentation: need bounds check result_is_negative = lhs_negative; const bool tweak_ub = result_is_negative && virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps]; if (tweak_ub) ub += 1; if (ub<lhs_test || ub<rhs_test || (ub -= lhs_test)<rhs_test) { //! \test if.C99/Pass_conditional_op_noeval.hpp, if.C99/Pass_conditional_op_noeval.h if (!no_runtime_errors) //! \test default/Error_if_control42.hpp, default/Error_if_control42.h simple_error(src," signed - overflow, undefined behavior (C99 6.5p5, C++98 5p5)"); return false; }; lhs_test += rhs_test; // if we can't render it, do not reduce if (tweak_ub && target_machine->signed_max(old.machine_type)<lhs_test) return false; } if (result_is_negative) { // convert to parsed - literal parse_tree tmp; VM_to_literal(tmp,lhs_test,src,types); src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); return true; }; res_int = lhs_test; } else res_int -= rhs_int; // convert to parsed + literal parse_tree tmp; VM_to_literal(tmp,res_int,src,types); value_copy(tmp.type_code,src.type_code); src.DeleteIdx<1>(0); force_unary_positive_literal(src,tmp ARG_TYPES); return true; } break; } case 1: { assert(converts_to_integerlike(src.data<2>()->type_code.base_type_index ARG_TYPES)); bool is_true = false; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { // __ - 0 |-> __ src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; } break; } #ifndef NDEBUG case 2: FATAL_CODE("invalid expression not flagged as invalid expression",3); #endif case 3: { // hyper-optimizing linker: two string literals decay to equal pointers iff they are equal under strcmp // use this to short-circuit to 0; remember to adjust the preprocessor hacks as well bool is_equal = false; if (C_string_literal_equal_content(*src.data<1>(),*src.data<2>(),is_equal) && is_equal) { //! \test default/Pass_if_zero.hpp, default/Pass_if_zero.h type_spec old_type; src.type_code.OverwriteInto(old_type); force_decimal_literal(src,"0",types); old_type.MoveInto(src.type_code); return true; } break; } } return false; } // +: either both are arithmetic, or one is raw pointer and one is integer // -: either both are arithmetic, or both are compatible raw pointer, or left is raw pointer and right is integer //! \throw std::bad_alloc() static void C_CPP_add_expression_easy_syntax_check(parse_tree& src,const type_system& types,literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert((C99_ADD_SUBTYPE_PLUS==src.subtype && is_C99_add_operator_expression<'+'>(src)) || (C99_ADD_SUBTYPE_MINUS==src.subtype && is_C99_add_operator_expression<'-'>(src))); BOOST_STATIC_ASSERT(1==C99_ADD_SUBTYPE_MINUS-C99_ADD_SUBTYPE_PLUS); const size_t lhs_pointer = src.data<1>()->type_code.pointer_power; const size_t rhs_pointer = src.data<2>()->type_code.pointer_power; // pointers to void are disallowed; not testable from preprocessor const bool exact_rhs_voidptr = 1==rhs_pointer && C_TYPE::VOID==src.data<2>()->type_code.base_type_index; if (1==lhs_pointer && C_TYPE::VOID==src.data<1>()->type_code.base_type_index) { simple_error(src,exact_rhs_voidptr ? " uses void* arguments (C99 6.5.6p2,3; C++98 5.7p1,2)" : " uses void* left-hand argument (C99 6.5.6p2,3; C++98 5.7p1,2)"); return; } else if (exact_rhs_voidptr) { simple_error(src," uses void* right-hand argument (C99 6.5.6p2,3; C++98 5.7p1,2)"); return; } switch((0<lhs_pointer)+2*(0<rhs_pointer)+4*(src.subtype-C99_ADD_SUBTYPE_PLUS)) { #ifndef NDEBUG default: FATAL_CODE("hardware/compiler error: invalid linear combination in C_add_expression_easy_syntax_check",3); #endif case 0: { // cannot test errors from preprocessor POD_pair<size_t,bool> lhs = default_promotion_is_arithmeticlike(src.data<1>()->type_code ARG_TYPES); POD_pair<size_t,bool> rhs = default_promotion_is_arithmeticlike(src.data<2>()->type_code ARG_TYPES); if (!lhs.second) { simple_error(src,rhs.second ? " has non-arithmetic non-pointer right argument (C99 6.5.6p2; C++98 5.7p1)" : " has non-arithmetic non-pointer arguments (C99 6.5.6p2; C++98 5.7p1)"); return; } else if (!rhs.second) { simple_error(src," has non-arithmetic non-pointer left argument (C99 6.5.6p2; C++98 5.7p1)"); return; } // arithmeticlike subsumes integerlike so this is fine if (is_noticed_enumerator(*src.data<1>(),types)) { enumerator_to_integer_representation(*src.c_array<1>(),types); lhs = default_promotion_is_integerlike(src.data<1>()->type_code,types); assert(lhs.second); } if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); rhs = default_promotion_is_integerlike(src.data<2>()->type_code,types); assert(rhs.second); } src.type_code.set_type(arithmetic_reconcile(lhs.first,rhs.first ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_add_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); break; } case 1: { // ptr + integer, hopefully // requires floating-point literals to test errors from preprocessor value_copy(src.type_code,src.data<1>()->type_code); if (!converts_to_integerlike(src.data<2>()->type_code.base_type_index ARG_TYPES)) { simple_error(src," adds pointer to non-integer (C99 6.5.6p2; C++98 5.7p1)"); return; } zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_add_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); break; } case 2: { // integer + ptr, hopefully // requires floating-point literals to test errors from preprocessor value_copy(src.type_code,src.data<2>()->type_code); if (!converts_to_integerlike(src.data<1>()->type_code.base_type_index ARG_TYPES)) { simple_error(src," adds pointer to non-integer (C99 6.5.6p2; C++98 5.7p1)"); return; } zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_add_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); break; } case 3: { // ptr + ptr dies //! \test default/Error_if_control43.hpp, default/Error_if_control43.h simple_error(src," adds two pointers (C99 6.5.6p2; C++98 5.7p1)"); return; } case 4: { // cannot test errors from preprocessor POD_pair<size_t,bool> lhs = default_promotion_is_arithmeticlike(src.data<1>()->type_code ARG_TYPES); POD_pair<size_t,bool> rhs = default_promotion_is_arithmeticlike(src.data<2>()->type_code ARG_TYPES); if (!lhs.second) { simple_error(src,rhs.second ? " has non-arithmetic non-pointer right argument (C99 6.5.6p3; C++98 5.7p2)" : " has non-arithmetic non-pointer arguments (C99 6.5.6p3; C++98 5.7p2)"); return; } else if (!rhs.second) { simple_error(src," has non-arithmetic non-pointer left argument (C99 6.5.6p3; C++98 5.7p2)"); return; } // arithmeticlike subsumes integerlike so this is fine if (is_noticed_enumerator(*src.data<1>(),types)) { enumerator_to_integer_representation(*src.c_array<1>(),types); lhs = default_promotion_is_integerlike(src.data<1>()->type_code,types); assert(lhs.second); } if (is_noticed_enumerator(*src.data<2>(),types)) { enumerator_to_integer_representation(*src.c_array<2>(),types); rhs = default_promotion_is_integerlike(src.data<2>()->type_code,types); assert(rhs.second); } src.type_code.set_type(arithmetic_reconcile(lhs.first,rhs.first ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_sub_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); break; } case 5: { // ptr - integer, hopefully; requires floating-point literal to test from preprocessor value_copy(src.type_code,src.data<1>()->type_code); if (!converts_to_integerlike(src.data<2>()->type_code.base_type_index ARG_TYPES)) { simple_error(src," subtracts non-integer from pointer (C99 6.5.6p3; C++98 5.7p2)"); return; } zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_sub_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); break; } case 6: { // non-ptr - ptr dies //! \test default/Error_if_control44.hpp, default/Error_if_control44.h simple_error(src," subtracts a non-pointer from a pointer (C99 6.5.6p3; C++98 5.7p2)"); return; } case 7: { // ptr - ptr should be compatible // type is ptrdiff_t const virtual_machine::std_int_enum tmp = target_machine->ptrdiff_t_type(); assert(tmp); src.type_code.set_type((virtual_machine::std_int_char==tmp ? C_TYPE::CHAR : virtual_machine::std_int_short==tmp ? C_TYPE::SHRT : virtual_machine::std_int_int==tmp ? C_TYPE::INT : virtual_machine::std_int_long==tmp ? C_TYPE::LONG : virtual_machine::std_int_long_long==tmp ? C_TYPE::LLONG : 0)); assert(0!=src.type_code.base_type_index); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); eval_sub_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); break; } } } /* additive-expression: multiplicative-expression additive-expression + multiplicative-expression additive-expression - multiplicative-expression */ static void locate_C99_add_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (terse_C99_augment_add_expression(src,i,types)) { C_CPP_add_expression_easy_syntax_check(src.c_array<0>()[i],types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); return; } if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_add_expression(src,i)) C_CPP_add_expression_easy_syntax_check(src.c_array<0>()[i],types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); } /* additive-expression: multiplicative-expression additive-expression + multiplicative-expression additive-expression - multiplicative-expression */ static void locate_CPP_add_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if (terse_CPP_augment_add_expression(src,i,types)) { //! \todo handle operator overloading C_CPP_add_expression_easy_syntax_check(src.c_array<0>()[i],types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); return; } if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_add_expression(src,i)) //! \todo handle operator overloading C_CPP_add_expression_easy_syntax_check(src.c_array<0>()[i],types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); } static bool binary_infix_failed_integer_arguments(parse_tree& src, const char* standard SIG_CONST_TYPES) { assert(NULL!=standard); if (parse_tree::INVALID & src.flags) // already invalid, don't make noise return !converts_to_integerlike(src.data<1>()->type_code ARG_TYPES) || !converts_to_integerlike(src.data<2>()->type_code ARG_TYPES); // hmm... 45-47, 48-50, 51-53, 54-56, 57-59 //! \todo need tests for float literal in place of int literal: << >> & ^ | const bool rhs_integerlike = converts_to_integerlike(src.data<2>()->type_code ARG_TYPES); if (!converts_to_integerlike(src.data<1>()->type_code ARG_TYPES)) { // tests for string literal in place of integer literal //! \test default/Error_if_control46.hpp, default/Error_if_control46.h //! \test default/Error_if_control47.hpp, default/Error_if_control47.h //! \test default/Error_if_control49.hpp, default/Error_if_control49.h //! \test default/Error_if_control50.hpp, default/Error_if_control50.h //! \test default/Error_if_control52.hpp, default/Error_if_control52.h //! \test default/Error_if_control53.hpp, default/Error_if_control53.h //! \test default/Error_if_control55.hpp, default/Error_if_control55.h //! \test default/Error_if_control56.hpp, default/Error_if_control56.h //! \test default/Error_if_control58.hpp, default/Error_if_control58.h //! \test default/Error_if_control59.hpp, default/Error_if_control59.h src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(src); INC_INFORM(rhs_integerlike ? " has nonintegral LHS " : " has nonintegral LHS and RHS "); INFORM(standard); zcc_errors.inc_error(); return true; } else if (!rhs_integerlike) { // tests for string literal in place of integer literal //! \test default/Error_if_control45.hpp, default/Error_if_control45.h //! \test default/Error_if_control48.hpp, default/Error_if_control48.h //! \test default/Error_if_control51.hpp, default/Error_if_control51.h //! \test default/Error_if_control54.hpp, default/Error_if_control54.h //! \test default/Error_if_control57.hpp, default/Error_if_control57.h src.flags |= parse_tree::INVALID; message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM(src); INC_INFORM(" has nonintegral RHS "); INFORM(standard); zcc_errors.inc_error(); return true; } return false; } static bool terse_locate_shift_expression(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t shift_subtype = (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"<<")) ? C99_SHIFT_SUBTYPE_LEFT : (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,">>")) ? C99_SHIFT_SUBTYPE_RIGHT : 0; if (shift_subtype) { if (1>i || 2>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_SHIFT_EXPRESSION & tmp_c_array[0].flags) && (PARSE_ADD_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_SHIFT_EXPRESSION); // tmp_c_array goes invalid here assert(is_C99_shift_expression(src.data<0>()[i])); parse_tree& tmp = src.c_array<0>()[i]; tmp.subtype = shift_subtype; tmp.type_code.set_type(0); // handle type inference later assert(is_C99_shift_expression(src.data<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc() static bool eval_shift(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(converts_to_integerlike(src.data<1>()->type_code ARG_TYPES)); assert(converts_to_integerlike(src.data<2>()->type_code ARG_TYPES)); assert(C99_SHIFT_SUBTYPE_LEFT<=src.subtype && C99_SHIFT_SUBTYPE_RIGHT>=src.subtype); BOOST_STATIC_ASSERT(1==C99_SHIFT_SUBTYPE_RIGHT-C99_SHIFT_SUBTYPE_LEFT); // handle: // 0 << __ |-> 0 // __ << 0 |-> __ // 0 >> __ |-> 0 // __ >> 0 |-> __ // two integer literals // error if RHS is literal "out of bounds" bool is_true = false; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true) { if (!is_true) { // __ << 0 or __ >> 0: lift // handle enumerators now if (is_noticed_enumerator(*src.data<1>(),types)) enumerator_to_integer_representation(*src.c_array<1>(),types); src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); return true; } }; umaxint rhs_int; if (intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES)) { const virtual_machine::std_int_enum machine_type = machine_type_from_type_index(src.type_code.base_type_index); const bool undefined_behavior = target_machine->C_bit(machine_type)<=rhs_int; //! \todo can't test with static test case (need to use bitcount of uintmax_t/intmax_t) if (undefined_behavior) simple_error(src," : RHS is at least as large as bits of LHS; undefined behavior (C99 6.5.7p3/C++98 5.8p1)"); if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES)) { if (!is_true) { // 0 << __ or 0 >> __: zero out (note that we can do this even if we invoked undefined behavior) type_spec tmp; src.type_code.OverwriteInto(tmp); force_decimal_literal(src,"0",types); tmp.MoveInto(src.type_code); return true; } }; if (undefined_behavior) return false; umaxint res_int; if (intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES)) { // note that incoming negative signed integers are not handled by this code path if (C99_SHIFT_SUBTYPE_LEFT==src.subtype) { //! \todo but signed integers do go undefined in C if left-shifted too much; C++ accepts #if 0 if (0==(src.type_code.base_type_index-C_TYPE::INT)%2 && target_machine->C_bit(machine_type)<=rhs_int.to_uint()+lhs_int.int_log2()+1) simple_error(src," : result does not fit in LHS type; undefined behavior (C99 6.5.7p3)"); #endif res_int <<= rhs_int.to_uint(); if (int_has_trapped(src,res_int)) return false; } else // if (C99_SHIFT_SUBTYPE_RIGHT==src.subtype) res_int >>= rhs_int.to_uint(); const virtual_machine::std_int_enum machine_type = machine_type_from_type_index(src.type_code.base_type_index); const bool negative_signed_int = 0==(src.type_code.base_type_index-C_TYPE::INT)%2 && res_int.test(target_machine->C_bit(machine_type)-1); if (negative_signed_int) target_machine->signed_additive_inverse(res_int,machine_type); parse_tree tmp; VM_to_literal(tmp,res_int,src,types); if (negative_signed_int) { // convert to parsed - literal src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); } else{ // convert to positive literal src.type_code.MoveInto(tmp.type_code); tmp.MoveInto(src); } return true; } } return false; } //! \throw std::bad_alloc() static void C_shift_expression_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_shift_expression(src)); // C99 6.5.7p2: requires being an integer type if (binary_infix_failed_integer_arguments(src,"(C99 6.5.7p2)" ARG_TYPES)) return; src.type_code.base_type_index = default_promote_type(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_shift(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) return; } //! \throw std::bad_alloc() static void CPP_shift_expression_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_shift_expression(src)); // C++98 5.8p1: requires being an integer or enumeration type if (binary_infix_failed_integer_arguments(src,"(C++98 5.8p1)" ARG_TYPES)) return; src.type_code.base_type_index = default_promote_type(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_shift(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) return; } /* shift-expression: additive-expression shift-expression << additive-expression shift-expression >> additive-expression */ //! \throw std::bad_alloc() static void locate_C99_shift_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_shift_expression(src,i)) C_shift_expression_easy_syntax_check(src.c_array<0>()[i],types); } /* shift-expression: additive-expression shift-expression << additive-expression shift-expression >> additive-expression */ //! \throw std::bad_alloc() static void locate_CPP_shift_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_shift_expression(src,i)) //! \todo handle overloading CPP_shift_expression_easy_syntax_check(src.c_array<0>()[i],types); } //! \throw std::bad_alloc static bool terse_locate_relation_expression(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t rel_subtype = (token_is_char<'<'>(src.data<0>()[i].index_tokens[0].token)) ? C99_RELATION_SUBTYPE_LT : (token_is_char<'>'>(src.data<0>()[i].index_tokens[0].token)) ? C99_RELATION_SUBTYPE_GT : (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"<=")) ? C99_RELATION_SUBTYPE_LTE : (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,">=")) ? C99_RELATION_SUBTYPE_GTE : 0; if (rel_subtype) { if (1>i || 2>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_SHIFT_EXPRESSION & tmp_c_array[0].flags) && (PARSE_ADD_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_RELATIONAL_EXPRESSION); // tmp_c_array goes invalid here assert(is_C99_relation_expression(src.data<0>()[i])); parse_tree& tmp = src.c_array<0>()[i]; tmp.subtype = rel_subtype; tmp.type_code.set_type(C_TYPE::BOOL); assert(is_C99_relation_expression(src.data<0>()[i])); return true; } } return false; } static bool eval_relation_expression(parse_tree& src, const type_system& types,intlike_literal_to_VM_func& intlike_literal_to_VM) { BOOST_STATIC_ASSERT(1==C99_RELATION_SUBTYPE_GT-C99_RELATION_SUBTYPE_LT); BOOST_STATIC_ASSERT(1==C99_RELATION_SUBTYPE_LTE-C99_RELATION_SUBTYPE_GT); BOOST_STATIC_ASSERT(1==C99_RELATION_SUBTYPE_GTE-C99_RELATION_SUBTYPE_LTE); assert(C99_RELATION_SUBTYPE_LT<=src.subtype && C99_RELATION_SUBTYPE_GTE>=src.subtype); umaxint lhs_int; umaxint rhs_int; const bool lhs_converted = intlike_literal_to_VM(lhs_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (lhs_converted && rhs_converted) { const char* result = NULL; const promote_aux targ(arithmetic_reconcile(src.data<1>()->type_code.base_type_index, src.data<2>()->type_code.base_type_index ARG_TYPES) ARG_TYPES); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(targ.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(targ.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs bool use_unsigned_compare = true; const bool lhs_negative = target_machine->C_promote_integer(lhs_int,lhs,targ); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,targ); if (rhs_negative) target_machine->signed_additive_inverse(rhs_int,targ.machine_type); if (lhs_negative) target_machine->signed_additive_inverse(lhs_int,targ.machine_type); //! \todo --do-what-i-mean redefines < > operators to handle cross-domain if (targ.is_signed && (lhs_negative || rhs_negative)) { // repair switch to handle signed numerals if (lhs_negative && rhs_negative) std::swap(lhs_int,rhs_int); else{ const bool lhs_zero = target_machine->is_zero(lhs_int.data(),lhs_int.size(),targ); const bool rhs_zero = target_machine->is_zero(rhs_int.data(),rhs_int.size(),targ); const bool op_uses_less_than = (src.subtype%2); // low-level, check with static assertions // is above correct? BOOST_STATIC_ASSERT(C99_RELATION_SUBTYPE_LT%2); BOOST_STATIC_ASSERT(C99_RELATION_SUBTYPE_LTE%2); BOOST_STATIC_ASSERT(!(C99_RELATION_SUBTYPE_GT%2)); BOOST_STATIC_ASSERT(!(C99_RELATION_SUBTYPE_GTE%2)); use_unsigned_compare = false; if (!lhs_zero) result = lhs_negative ? (op_uses_less_than ? "1" : "0") : (op_uses_less_than ? "0" : "1"); else if (!rhs_zero) result = rhs_negative ? (op_uses_less_than ? "0" : "1") : (op_uses_less_than ? "1" : "0"); else{ // is below correct? BOOST_STATIC_ASSERT(C99_RELATION_SUBTYPE_LTE<=C99_RELATION_SUBTYPE_GTE); BOOST_STATIC_ASSERT(C99_RELATION_SUBTYPE_LT<C99_RELATION_SUBTYPE_LTE); BOOST_STATIC_ASSERT(C99_RELATION_SUBTYPE_GT<C99_RELATION_SUBTYPE_LTE); result = (C99_RELATION_SUBTYPE_LTE<=src.subtype) ? "1" : "0"; // low-level, check with static assertions } } }; if (use_unsigned_compare) switch(src.subtype) { case C99_RELATION_SUBTYPE_LT: result = (lhs_int<rhs_int) ? "1" : "0"; break; case C99_RELATION_SUBTYPE_GT: result = (lhs_int>rhs_int) ? "1" : "0"; break; case C99_RELATION_SUBTYPE_LTE: result = (lhs_int<=rhs_int) ? "1" : "0"; break; case C99_RELATION_SUBTYPE_GTE: result = (lhs_int>=rhs_int) ? "1" : "0"; break; }; force_decimal_literal(src,result,types); return true; }; //! \bug: string literals can't handle GTE, LTE //! \bug: string literals handle GT, LT only with respect to zero (NULL constant)? return false; } static bool C_CPP_relation_expression_core_syntax_ok(parse_tree& src,const type_system& types) { const unsigned int ptr_case = (0<src.data<1>()->type_code.pointer_power)+2*(0<src.data<2>()->type_code.pointer_power); switch(ptr_case) { case 0: // can't test from preprocessor if (!converts_to_reallike(src.data<1>()->type_code.base_type_index ARG_TYPES) || !converts_to_reallike(src.data<2>()->type_code.base_type_index ARG_TYPES)) { simple_error(src," compares non-real type(s) (C99 6.5.8p2/C++98 5.9p2)"); return false; } break; case 1: //! \todo need floating-point literal to test first half //! \todo figure out how to test second half if (!converts_to_integer(src.data<2>()->type_code ARG_TYPES) || !(PARSE_PRIMARY_EXPRESSION & src.data<2>()->flags)) { // oops simple_error(src," compares pointer to something not an integer literal or pointer (C99 6.5.8p2/C++98 4.10p1,5.9p2)"); return false; } break; case 2: //! \todo need floating-point literal to test first half //! \todo figure out how to test second half if (!converts_to_integer(src.data<1>()->type_code ARG_TYPES) || !(PARSE_PRIMARY_EXPRESSION & src.data<1>()->flags)) { // oops simple_error(src," compares pointer to something not an integer literal or pointer (C99 6.5.8p2/C++98 4.10p1,5.9p2)"); return false; } break; } return true; } static void C_relation_expression_easy_syntax_check(parse_tree& src,const type_system& types) { if (!C_CPP_relation_expression_core_syntax_ok(src,types)) eval_relation_expression(src,types,C99_intlike_literal_to_VM); } static void CPP_relation_expression_easy_syntax_check(parse_tree& src,const type_system& types) { //! \todo handle operator overloading if (!C_CPP_relation_expression_core_syntax_ok(src,types)) eval_relation_expression(src,types,CPP_intlike_literal_to_VM); } /* relational-expression: shift-expression relational-expression < shift-expression relational-expression > shift-expression relational-expression <= shift-expression relational-expression >= shift-expression */ //! \throw std::bad_alloc static void locate_C99_relation_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_relation_expression(src,i)) C_relation_expression_easy_syntax_check(src.c_array<0>()[i],types); } /* relational-expression: shift-expression relational-expression < shift-expression relational-expression > shift-expression relational-expression <= shift-expression relational-expression >= shift-expression */ //! \throw std::bad_alloc static void locate_CPP_relation_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_relation_expression(src,i)) //! \todo handle overloading CPP_relation_expression_easy_syntax_check(src.c_array<0>()[i],types); } //! \throw std::bad_alloc static bool terse_locate_C99_equality_expression(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t eq_subtype = (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"==")) ? C99_EQUALITY_SUBTYPE_EQ : (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"!=")) ? C99_EQUALITY_SUBTYPE_NEQ : 0; if (eq_subtype) { if (1>i || 2>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_EQUALITY_EXPRESSION & tmp_c_array[0].flags) && (PARSE_RELATIONAL_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_EQUALITY_EXPRESSION); // tmp_c_array becomes invalid here assert(is_C99_equality_expression(src.data<0>()[i])); parse_tree& tmp = src.c_array<0>()[i]; tmp.subtype = eq_subtype; tmp.type_code.set_type(C_TYPE::BOOL); assert(is_C99_equality_expression(src.data<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc static bool terse_locate_CPP_equality_expression(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); const size_t eq_subtype = (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"==")) ? C99_EQUALITY_SUBTYPE_EQ : ( token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"!=") || token_is_string<6>(src.data<0>()[i].index_tokens[0].token,"not_eq")) ? C99_EQUALITY_SUBTYPE_NEQ : 0; if (eq_subtype) { if (1>i || 2>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_EQUALITY_EXPRESSION & tmp_c_array[0].flags) && (PARSE_RELATIONAL_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_EQUALITY_EXPRESSION); // tmp_c_array becomes invalid here assert(is_CPP_equality_expression(src.data<0>()[i])); parse_tree& tmp = src.c_array<0>()[i]; tmp.subtype = eq_subtype; tmp.type_code.set_type(C_TYPE::BOOL); assert(is_CPP_equality_expression(src.data<0>()[i])); return true; } } return false; } static bool typeid_equal_content(const parse_tree& lhs, const parse_tree& rhs,bool& is_equal) { if ( is_CPP0X_typeid_expression(lhs) && is_CPP0X_typeid_expression(rhs) && C_TYPE::NOT_VOID!=lhs.data<2>()->type_code.base_type_index && C_TYPE::NOT_VOID!=rhs.data<2>()->type_code.base_type_index) { is_equal = lhs.data<2>()->type_code.typeid_equal(rhs.data<2>()->type_code); return true; } return false; } static bool eval_equality_expression(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { BOOST_STATIC_ASSERT(1==C99_EQUALITY_SUBTYPE_NEQ-C99_EQUALITY_SUBTYPE_EQ); assert(C99_EQUALITY_SUBTYPE_EQ<=src.subtype && C99_EQUALITY_SUBTYPE_NEQ>=src.subtype); umaxint lhs_int; umaxint rhs_int; const unsigned int integer_literal_case = converts_to_integer(src.data<1>()->type_code ARG_TYPES) + 2*converts_to_integer(src.data<2>()->type_code ARG_TYPES); const bool is_equal_op = src.subtype==C99_EQUALITY_SUBTYPE_EQ; bool is_true = false; switch(integer_literal_case) { case 0: { // string literal == string literal (assume hyper-optimizing linker, this should be true iff the string literals are equal as static arrays of char) //! \test default/Pass_if_nonzero.hpp, default/Pass_if_nonzero.h, //! \test default/Pass_if_zero.hpp, default/Pass_if_zero.h, bool is_equal = false; if ( C_string_literal_equal_content(*src.data<1>(),*src.data<2>(),is_equal) || typeid_equal_content(*src.data<1>(),*src.data<2>(),is_equal) ) { force_decimal_literal(src,is_equal_op==is_equal ? "1" : "0",types); return true; }; break; } case 1: { if (0<src.data<2>()->type_code.pointer_power && literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES)) { if (!is_true) { if (src.data<2>()->type_code.decays_to_nonnull_pointer()) { // string literal != NULL, etc. //! \test default/Pass_if_nonzero.hpp, default/Pass_if_nonzero.h, //! \test default/Pass_if_zero.hpp, default/Pass_if_zero.h, force_decimal_literal(src,is_equal_op ? "0" : "1",types); return true; } } else if (!(parse_tree::INVALID & src.flags)) //! \test default/Error_if_control60.hpp, default/Error_if_control60.h //! \test default/Error_if_control61.hpp, default/Error_if_control61.h simple_error(src," compares pointer to integer that is not a null pointer constant (C99 6.5.9p5/C++98 4.10p1,5.10p1)"); return false; } break; } case 2: { if (0<src.data<1>()->type_code.pointer_power && literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES)) { if (!is_true) { if (src.data<1>()->type_code.decays_to_nonnull_pointer()) { // string literal != NULL //! \test default/Pass_if_nonzero.hpp, default/Pass_if_nonzero.h, //! \test default/Pass_if_zero.hpp, default/Pass_if_zero.h, force_decimal_literal(src,is_equal_op ? "0" : "1",types); return true; } } else if (!(parse_tree::INVALID & src.flags)) //! \test default/Error_if_control62.hpp, default/Error_if_control62.h //! \test default/Error_if_control63.hpp, default/Error_if_control63.h simple_error(src," compares pointer to integer that is not a null pointer constant (C99 6.5.9p5/C++98 4.10p1,5.10p1)"); return false; } break; } case 3: { // integer literal == integer literal const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); const promote_aux old(arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES) ARG_TYPES); assert(old.bitcount>=lhs.bitcount); assert(old.bitcount>=rhs.bitcount); const bool lhs_converted = intlike_literal_to_VM(lhs_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); // general case here in case we try to do with converted/not converted mixed cases // if (lhs_converted) target_machine->C_promote_integer(lhs_int,lhs,old); // if (rhs_converted) target_machine->C_promote_integer(rhs_int,rhs,old); if (lhs_converted && rhs_converted) { target_machine->C_promote_integer(lhs_int,lhs,old); target_machine->C_promote_integer(rhs_int,rhs,old); force_decimal_literal(src,(lhs_int==rhs_int)==is_equal_op ? "1" : "0",types); return true; }; // break; } }; return false; } static bool C_CPP_equality_expression_syntax_ok_core(parse_tree& src,const type_system& types) { // admit legality of: // numeric == numeric // string literal == string literal // string literal == integer literal zero // deny legality of : string literal == integer/float // more to come later const unsigned int ptr_case = (0<src.data<1>()->type_code.pointer_power)+2*(0<src.data<2>()->type_code.pointer_power); switch(ptr_case) { case 0: // can't test from preprocessor if (C_TYPE::VOID>=src.data<1>()->type_code.base_type_index || C_TYPE::VOID>=src.data<2>()->type_code.base_type_index) { simple_error(src," can't use a void or indeterminately typed argument"); return false; } break; case 1: // need floating-point literal to test from preprocessor if (!converts_to_integer(src.data<2>()->type_code ARG_TYPES) || !(PARSE_PRIMARY_EXPRESSION & src.data<2>()->flags)) { // oops simple_error(src," compares pointer to something not an integer literal or pointer (C99 6.5.9p5/C++98 4.10p1,5.10p1)"); return false; } break; case 2: // need floating-point literal to test from preprocessor if (!converts_to_integer(src.data<1>()->type_code ARG_TYPES) || !(PARSE_PRIMARY_EXPRESSION & src.data<1>()->flags)) { // oops simple_error(src," compares pointer to something not an integer literal or pointer (C99 6.5.9p5/C++98 4.10p1,5.10p1)"); return false; } break; } return true; } static void C_equality_expression_easy_syntax_check(parse_tree& src,const type_system& types) { if (!C_CPP_equality_expression_syntax_ok_core(src,types)) return; eval_equality_expression(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM); } static void CPP_equality_expression_easy_syntax_check(parse_tree& src,const type_system& types) { //! \todo check for operator overloading if (!C_CPP_equality_expression_syntax_ok_core(src,types)) return; eval_equality_expression(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM); } /* equality-expression: relational-expression equality-expression == relational-expression equality-expression != relational-expression */ //! \throw std::bad_alloc static void locate_C99_equality_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_equality_expression(src,i)) C_equality_expression_easy_syntax_check(src.c_array<0>()[i],types); } /* equality-expression: relational-expression equality-expression == relational-expression equality-expression != relational-expression */ //! \throw std::bad_alloc static void locate_CPP_equality_expression(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_equality_expression(src,i)) //! \todo handle operator overloading CPP_equality_expression_easy_syntax_check(src.c_array<0>()[i],types); } //! \throw std::bad_alloc static bool terse_locate_C99_bitwise_AND(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); //! \todo deal with unary & parses parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); if (token_is_char<'&'>(tmp_c_array[1].index_tokens[0].token)) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_BITAND_EXPRESSION & tmp_c_array[0].flags) && (PARSE_EQUALITY_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_BITAND_EXPRESSION); // tmp_c_array becomes invalid here assert(is_C99_bitwise_AND_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_bitwise_AND_expression(src.data<0>()[i])); return true; } } return false; } static bool terse_locate_CPP_bitwise_AND(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'&'>(src.data<0>()[i].index_tokens[0].token) || token_is_string<6>(src.data<0>()[i].index_tokens[0].token,"bitand")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if ( (PARSE_BITAND_EXPRESSION & src.data<0>()[i-1].flags) && (PARSE_EQUALITY_EXPRESSION & src.data<0>()[i+1].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_BITAND_EXPRESSION); assert(is_CPP_bitwise_AND_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_CPP_bitwise_AND_expression(src.data<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc static bool eval_bitwise_AND(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(converts_to_integerlike(src.data<1>()->type_code ARG_TYPES)); assert(converts_to_integerlike(src.data<2>()->type_code ARG_TYPES)); // handle following: // __ & 0 |-> 0 // 0 & __ |-> 0 // int-literal | int-literal |-> int-literal *if* both fit // unary - gives us problems (result is target-specific, could generate a trap representation) bool is_true = false; if ( (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES) && !is_true) // 0 & __ || (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES) && !is_true)) // __ & 0 { if (C_TYPE::INTEGERLIKE==src.type_code.base_type_index) { message_header(src.index_tokens[0]); INC_INFORM("invalid "); INC_INFORM(src); INFORM(" optimized to valid 0"); force_decimal_literal(src,"0",types); src.type_code.set_type(C_TYPE::LLONG); // legalize } else{ type_spec tmp; src.type_code.OverwriteInto(tmp); force_decimal_literal(src,"0",types); tmp.MoveInto(src.type_code); } return true; }; umaxint lhs_int; umaxint rhs_int; if (intlike_literal_to_VM(lhs_int,*src.data<1>() ARG_TYPES) && intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES)) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); umaxint res_int(lhs_int); res_int &= rhs_int; // check for trap representation for signed types if (int_has_trapped(src,res_int)) return false; if (res_int==lhs_int) { // lhs & rhs = lhs; conserve type // handle enumerators now if (is_noticed_enumerator(*src.data<1>(),types)) enumerator_to_integer_representation(*src.c_array<1>(),types); src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); } else if (res_int==rhs_int) { // lhs & rhs = rhs; conserve type // handle enumerators now if (is_noticed_enumerator(*src.data<2>(),types)) enumerator_to_integer_representation(*src.c_array<2>(),types); src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); } else{ const bool negative_signed_int = old.is_signed && res_int.test(old.bitcount-1); if (negative_signed_int) target_machine->signed_additive_inverse(res_int,old.machine_type); if ( virtual_machine::twos_complement==target_machine->C_signed_int_representation() && old.is_signed && !bool_options[boolopt::int_traps] && res_int>target_machine->signed_max(old.machine_type)) { // trap representation; need to get it into -INT_MAX-1 form construct_twos_complement_int_min(src,types,old.machine_type,src); return true; } parse_tree tmp; VM_to_signed_literal(tmp,negative_signed_int,res_int,src,types); src.type_code.MoveInto(tmp.type_code); tmp.MoveInto(src); } return true; } return false; } //! \throw std::bad_alloc static void C_bitwise_AND_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_bitwise_AND_expression(src)); // C99 6.5.10p2: requires being an integer type if (binary_infix_failed_integer_arguments(src,"(C99 6.5.10p2)" ARG_TYPES)) return; src.type_code.base_type_index = default_promote_type(arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES) ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_AND(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) return; } //! \throw std::bad_alloc static void CPP_bitwise_AND_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_bitwise_AND_expression(src)); // C++98 5.11p1: requires being an integer or enumeration type if (binary_infix_failed_integer_arguments(src,"(C++98 5.11p1)" ARG_TYPES)) return; src.type_code.base_type_index = default_promote_type(arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES) ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_AND(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) return; } /* AND-expression: equality-expression AND-expression & equality-expression */ //! \throw std::bad_alloc static void locate_C99_bitwise_AND(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_bitwise_AND(src,i)) C_bitwise_AND_easy_syntax_check(src.c_array<0>()[i],types); } /* AND-expression: equality-expression AND-expression & equality-expression */ //! \throw std::bad_alloc static void locate_CPP_bitwise_AND(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_bitwise_AND(src,i)) //! \todo handle overloading CPP_bitwise_AND_easy_syntax_check(src.c_array<0>()[i],types); } static bool terse_locate_C99_bitwise_XOR(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); if (token_is_char<'^'>(tmp_c_array[1].index_tokens[0].token)) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_BITXOR_EXPRESSION & tmp_c_array[0].flags) && (PARSE_BITAND_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_BITXOR_EXPRESSION); // tmp_c_array becomes invalid here assert(is_C99_bitwise_XOR_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_bitwise_XOR_expression(src.data<0>()[i])); return true; } } return false; } static bool terse_locate_CPP_bitwise_XOR(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'^'>(src.data<0>()[i].index_tokens[0].token) || token_is_string<3>(src.data<0>()[i].index_tokens[0].token,"xor")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if ( (PARSE_BITXOR_EXPRESSION & src.data<0>()[i-1].flags) && (PARSE_BITAND_EXPRESSION & src.data<0>()[i+1].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_BITXOR_EXPRESSION); assert(is_CPP_bitwise_XOR_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_CPP_bitwise_XOR_expression(src.data<0>()[i])); return true; } } return false; } // throws std::bad_alloc static bool eval_bitwise_XOR(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(converts_to_integerlike(src.data<1>()->type_code ARG_TYPES)); assert(converts_to_integerlike(src.data<2>()->type_code ARG_TYPES)); // handle following // x ^ x |-> 0 [later, need sensible detection of "equal" expressions first] // 0 ^ __ |-> __ // __ ^ 0 |-> __ // also handle double-literal case bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES)) { if (!is_true) { // 0 ^ __ // handle enumerators now if (is_noticed_enumerator(*src.data<2>(),types)) enumerator_to_integer_representation(*src.c_array<2>(),types); src.eval_to_arg<2>(0); //! \bug convert char literal to appropriate integer return true; } }; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES)) { if (!is_true) { // __ ^ 0 // handle enumerators now if (is_noticed_enumerator(*src.data<1>(),types)) enumerator_to_integer_representation(*src.c_array<1>(),types); src.eval_to_arg<1>(0); //! \bug convert char literal to appropriate integer return true; } }; umaxint lhs_int; umaxint rhs_int; if (intlike_literal_to_VM(lhs_int,*src.data<1>() ARG_TYPES) && intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES)) { const promote_aux old(src.type_code.base_type_index ARG_TYPES); umaxint res_int(lhs_int); res_int ^= rhs_int; // res_int.mask_to(target_machine->C_bit(machine_type)); // shouldn't need this if (int_has_trapped(src,res_int)) return false; const bool negative_signed_int = old.is_signed && res_int.test(old.bitcount-1); if (negative_signed_int) target_machine->signed_additive_inverse(res_int,old.machine_type); if ( virtual_machine::twos_complement==target_machine->C_signed_int_representation() && old.is_signed && !bool_options[boolopt::int_traps] && res_int>target_machine->signed_max(old.machine_type)) { // trap representation; need to get it into -INT_MAX-1 form construct_twos_complement_int_min(src,types,old.machine_type,src); return true; } parse_tree tmp; VM_to_signed_literal(tmp,negative_signed_int,res_int,src,types); src.type_code.MoveInto(tmp.type_code); tmp.MoveInto(src); return true; } return false; } // throws std::bad_alloc static void C_bitwise_XOR_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_bitwise_XOR_expression(src)); // C99 6.5.11p2: requires being an integer type if (binary_infix_failed_integer_arguments(src,"(C99 6.5.11p2)" ARG_TYPES)) return; src.type_code.base_type_index = default_promote_type(arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES) ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_XOR(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) return; } // throws std::bad_alloc static void CPP_bitwise_XOR_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_bitwise_XOR_expression(src)); // C++98 5.12p1: requires being an integer or enumeration type if (binary_infix_failed_integer_arguments(src,"(C++98 5.12p1)" ARG_TYPES)) return; src.type_code.base_type_index = default_promote_type(arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES) ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_XOR(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) return; } /* exclusive-OR-expression: AND-expression exclusive-OR-expression ^ AND-expression */ // throws std::bad_alloc static void locate_C99_bitwise_XOR(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_bitwise_XOR(src,i)) C_bitwise_XOR_easy_syntax_check(src.c_array<0>()[i],types); } /* exclusive-OR-expression: AND-expression exclusive-OR-expression ^ AND-expression */ // throws std::bad_alloc static void locate_CPP_bitwise_XOR(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_bitwise_XOR(src,i)) //! \todo handle operator overloading CPP_bitwise_XOR_easy_syntax_check(src.c_array<0>()[i],types); } static bool terse_locate_C99_bitwise_OR(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); if (token_is_char<'|'>(tmp_c_array[1].index_tokens[0].token)) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_BITOR_EXPRESSION & tmp_c_array[0].flags) && (PARSE_BITXOR_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_BITOR_EXPRESSION); // tmp_c_array becomes invalid here assert(is_C99_bitwise_OR_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_C99_bitwise_OR_expression(src.data<0>()[i])); return true; } } return false; } static bool terse_locate_CPP_bitwise_OR(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'|'>(src.data<0>()[i].index_tokens[0].token) || token_is_string<5>(src.data<0>()[i].index_tokens[0].token,"bitor")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if ( (PARSE_BITOR_EXPRESSION & src.data<0>()[i-1].flags) && (PARSE_BITXOR_EXPRESSION & src.data<0>()[i+1].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_BITOR_EXPRESSION); assert(is_CPP_bitwise_OR_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(0); // handle type inference later assert(is_CPP_bitwise_OR_expression(src.data<0>()[i])); return true; } } return false; } //! \throw std::bad_alloc() static bool eval_bitwise_OR(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool,intlike_literal_to_VM_func& intlike_literal_to_VM) { assert(converts_to_integerlike(src.data<1>()->type_code ARG_TYPES)); assert(converts_to_integerlike(src.data<2>()->type_code ARG_TYPES)); // handle following: // __ | 0 |-> __ // 0 | __ |-> __ // int-literal | int-literal |-> int-literal *if* both fit // unary - gives us problems (result is target-specific, could generate a trap representation) bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES)) { if (!is_true) { // 0 | __ // handle enumerators now if (is_noticed_enumerator(*src.data<2>(),types)) enumerator_to_integer_representation(*src.c_array<2>(),types); src.eval_to_arg<2>(0); //! \bug convert char literal to appropriate integer return true; } }; if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES)) { if (!is_true) { // __ | 0 // handle enumerators now if (is_noticed_enumerator(*src.data<1>(),types)) enumerator_to_integer_representation(*src.c_array<1>(),types); src.eval_to_arg<1>(0); //! \bug convert char literal to appropriate integer return true; } }; umaxint lhs_int; umaxint rhs_int; if (intlike_literal_to_VM(lhs_int,*src.data<1>() ARG_TYPES) && intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES)) { umaxint res_int(lhs_int); res_int |= rhs_int; // res_int.mask_to(target_machine->C_bit(machine_type)); // shouldn't need this if (res_int==lhs_int) { // lhs | rhs = lhs; conserve type // handle enumerators now if (is_noticed_enumerator(*src.data<1>(),types)) enumerator_to_integer_representation(*src.c_array<1>(),types); src.type_code.MoveInto(src.c_array<1>()->type_code); src.eval_to_arg<1>(0); } else if (res_int==rhs_int) { // lhs | rhs = rhs; conserve type // handle enumerators now if (is_noticed_enumerator(*src.data<1>(),types)) enumerator_to_integer_representation(*src.c_array<1>(),types); src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); } else{ if (int_has_trapped(src,res_int)) return false; const virtual_machine::std_int_enum machine_type = (virtual_machine::std_int_enum)((src.type_code.base_type_index-C_TYPE::INT)/2+virtual_machine::std_int_int); const bool negative_signed_int = 0==(src.type_code.base_type_index-C_TYPE::INT)%2 && res_int.test(target_machine->C_bit(machine_type)-1); if (negative_signed_int) target_machine->signed_additive_inverse(res_int,machine_type); parse_tree tmp; VM_to_literal(tmp,res_int,src,types); if (negative_signed_int) { // convert to parsed - literal src.DeleteIdx<1>(0); force_unary_negative_literal(src,tmp); } else{ // convert to positive literal src.type_code.MoveInto(tmp.type_code); tmp.MoveInto(src); } } return true; } return false; } //! \throw std::bad_alloc() static void C_bitwise_OR_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_bitwise_OR_expression(src)); // C99 6.5.12p2: requires being an integer type if (binary_infix_failed_integer_arguments(src,"(C99 6.5.12p2)" ARG_TYPES)) return; src.type_code.base_type_index = arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_OR(src,types,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) return; } //! \throw std::bad_alloc() static void CPP_bitwise_OR_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_bitwise_OR_expression(src)); // C++98 5.13p1: requires being an integer or enumeration type if (binary_infix_failed_integer_arguments(src,"(C++98 5.13p1)" ARG_TYPES)) return; src.type_code.base_type_index = arithmetic_reconcile(src.data<1>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES); assert(converts_to_integerlike(src.type_code.base_type_index ARG_TYPES)); zaimoni::simple_lock<unsigned int> lock(no_runtime_errors); if (eval_bitwise_OR(src,types,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) return; } /* inclusive-OR-expression: exclusive-OR-expression inclusive-OR-expression | exclusive-OR-expression */ //! \throw std::bad_alloc() static void locate_C99_bitwise_OR(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_bitwise_OR(src,i)) C_bitwise_OR_easy_syntax_check(src.c_array<0>()[i],types); } /* inclusive-OR-expression: exclusive-OR-expression inclusive-OR-expression | exclusive-OR-expression */ //! \throw std::bad_alloc() static void locate_CPP_bitwise_OR(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_bitwise_OR(src,i)) //! \todo handle overloading CPP_bitwise_OR_easy_syntax_check(src.c_array<0>()[i],types); } static bool binary_infix_failed_boolean_arguments(parse_tree& src, const char* standard SIG_CONST_TYPES) { //! \todo so the error message isn't technically right...convertible to bool in C++ is morally equivalent to scalar in C // cannot test this within preprocessor assert(standard && *standard); const bool rhs_converts_to_bool = converts_to_bool(src.data<2>()->type_code ARG_TYPES); if (!converts_to_bool(src.data<1>()->type_code ARG_TYPES)) { simple_error(src,rhs_converts_to_bool ? " has nonscalar LHS" : " has nonscalar LHS and RHS"); INFORM(standard); return true; } else if (!rhs_converts_to_bool) { simple_error(src," has nonscalar RHS"); INFORM(standard); return true; } return false; } static bool terse_locate_C99_logical_AND(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); if (token_is_string<2>(tmp_c_array[1].index_tokens[0].token,"&&")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_LOGICAND_EXPRESSION & tmp_c_array[0].flags) && (PARSE_BITOR_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_LOGICAND_EXPRESSION); // tmp_c_array becomes invalid here assert(is_C99_logical_AND_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(C_TYPE::BOOL); // technically wrong, but range is correct assert(is_C99_logical_AND_expression(src.data<0>()[i])); return true; } } return false; } static bool terse_locate_CPP_logical_AND(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"&&") || token_is_string<3>(src.data<0>()[i].index_tokens[0].token,"and")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if ( (PARSE_LOGICAND_EXPRESSION & src.data<0>()[i-1].flags) && (PARSE_BITOR_EXPRESSION & src.data<0>()[i+1].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_LOGICAND_EXPRESSION); assert(is_CPP_logical_AND_expression(src.data<0>()[i])); //! \todo handle overloading src.c_array<0>()[i].type_code.set_type(C_TYPE::BOOL); assert(is_CPP_logical_AND_expression(src.data<0>()[i])); return true; } } return false; } static bool eval_logical_AND(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool) { // deal with literals here. && short-circuit evaluates. // 1 && __ |-> 0!=__ // 0 && __ |-> 0 // __ && 1 |-> 0!=__ // __ && 0 |-> __ && 0 (__ may have side effects...), *but* does "stop the buck" so // (__ && 1) && __ |-> __ && 1 bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES)) { // one of 0 && __ or 1 && __ if (!is_true) { // 0 && __ if (src.flags & parse_tree::INVALID) { message_header(src.index_tokens[0]); INC_INFORM("invalid "); INC_INFORM(src); INFORM(" optimized to valid 0"); }; force_decimal_literal(src,"0",types); return true; } else if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES)) { // 1 && 1 or 1 && 0 force_decimal_literal(src,is_true ? "1" : "0",types); return true; } #if 0 //! \todo fixup 1 && __ when we have != and are working on C/C++ proper; anything already type bool could be reduced now else{ } #endif }; #if 0 //! \todo fixup (__ && 1) && __ when we are working on C/C++ proper #endif return false; } static void C_logical_AND_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_logical_AND_expression(src)); if (binary_infix_failed_boolean_arguments(src,"(C99 6.5.13p2)" ARG_TYPES)) return; if (eval_logical_AND(src,types,C99_literal_converts_to_bool)) return; } static void CPP_logical_AND_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_logical_AND_expression(src)); if (binary_infix_failed_boolean_arguments(src,"(C++98 5.14p1)" ARG_TYPES)) return; if (eval_logical_AND(src,types,CPP_literal_converts_to_bool)) return; } /* logical-AND-expression: inclusive-OR-expression logical-AND-expression && inclusive-OR-expression */ static void locate_C99_logical_AND(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_logical_AND(src,i)) C_logical_AND_easy_syntax_check(src.c_array<0>()[i],types); } /* logical-AND-expression: inclusive-OR-expression logical-AND-expression && inclusive-OR-expression */ static void locate_CPP_logical_AND(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_logical_AND(src,i)) //! \todo check for operator overloading CPP_logical_AND_easy_syntax_check(src.c_array<0>()[i],types); } static bool terse_locate_C99_logical_OR(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); if (token_is_string<2>(tmp_c_array[1].index_tokens[0].token,"||")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); if ( (PARSE_LOGICOR_EXPRESSION & tmp_c_array[0].flags) && (PARSE_LOGICAND_EXPRESSION & tmp_c_array[2].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_LOGICOR_EXPRESSION); // tmp_c_array becomes invalid here assert(is_C99_logical_OR_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(C_TYPE::BOOL); // technically wrong, but range is correct assert(is_C99_logical_OR_expression(src.data<0>()[i])); return true; } } return false; } static bool terse_locate_CPP_logical_OR(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"||") || token_is_string<2>(src.data<0>()[i].index_tokens[0].token,"or")) { if (1>i || 2>src.size<0>()-i) return false; inspect_potential_paren_primary_expression(src.c_array<0>()[i-1]); inspect_potential_paren_primary_expression(src.c_array<0>()[i+1]); if ( (PARSE_LOGICOR_EXPRESSION & src.data<0>()[i-1].flags) && (PARSE_LOGICAND_EXPRESSION & src.data<0>()[i+1].flags)) { assemble_binary_infix_arguments(src,i,PARSE_STRICT_LOGICOR_EXPRESSION); assert(is_CPP_logical_OR_expression(src.data<0>()[i])); src.c_array<0>()[i].type_code.set_type(C_TYPE::BOOL); assert(is_CPP_logical_OR_expression(src.data<0>()[i])); return true; } } return false; } static bool eval_logical_OR(parse_tree& src, const type_system& types, literal_converts_to_bool_func& literal_converts_to_bool) { // deal with literals here. || short-circuit evaluates. // 0 || __ |-> 0!=__ // 1 || __ |-> 1 // __ || 0 |-> 0!=__ // __ || 1 |-> __ || 1 (__ may have side effects...), *but* does "stop the buck" so // (__ || 1) || __ |-> __ || 1 bool is_true = false; if (literal_converts_to_bool(*src.data<1>(),is_true ARG_TYPES)) { // one of 0 || __ or 1 || __ if (is_true) { // 1 || __ if (src.flags & parse_tree::INVALID) { message_header(src.index_tokens[0]); INC_INFORM("invalid "); INC_INFORM(src); INFORM(" optimized to valid 1"); }; force_decimal_literal(src,"1",types); return true; } else if (literal_converts_to_bool(*src.data<2>(),is_true ARG_TYPES)) { // 0 || 1 or 0 || 0 force_decimal_literal(src,is_true ? "1" : "0",types); return true; } #if 0 //! \todo fixup 0 || __ when we have != and are working on C/C++ proper; anything already type bool could be reduced now else{ } #endif }; #if 0 //! \todo fixup (__ || 1) || __ when we are working on C/C++ proper #endif return false; } static void C_logical_OR_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_logical_OR_expression(src)); if (binary_infix_failed_boolean_arguments(src,"(C99 6.5.14p2)" ARG_TYPES)) return; if (eval_logical_OR(src,types,C99_literal_converts_to_bool)) return; } static void CPP_logical_OR_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_CPP_logical_OR_expression(src)); if (binary_infix_failed_boolean_arguments(src,"(C++98 5.15p1)" ARG_TYPES)) return; if (eval_logical_OR(src,types,CPP_literal_converts_to_bool)) return; } /* logical-OR-expression: logical-AND-expression logical-OR-expression || logical-AND-expression */ static void locate_C99_logical_OR(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_C99_logical_OR(src,i)) C_logical_OR_easy_syntax_check(src.c_array<0>()[i],types); } /* logical-OR-expression: logical-AND-expression logical-OR-expression || logical-AND-expression */ static void locate_CPP_logical_OR(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_CPP_logical_OR(src,i)) //! \todo check for operator overloading CPP_logical_OR_easy_syntax_check(src.c_array<0>()[i],types); } //! \throw std::bad_alloc static bool terse_locate_conditional_op(parse_tree& src, size_t& i) { assert(!src.empty<0>()); assert(i<src.size<0>()); assert(!(PARSE_OBVIOUS & src.data<0>()[i].flags)); assert(src.data<0>()[i].is_atomic()); if (token_is_char<'?'>(src.data<0>()[i].index_tokens[0].token)) { // ? as first might be space deficiency (check uniqueness of construction) if (1>i || 3>src.size<0>()-i) return false; parse_tree* const tmp_c_array = src.c_array<0>()+(i-1); if ( tmp_c_array[3].is_atomic() && token_is_char<':'>(tmp_c_array[3].index_tokens[0].token)) { inspect_potential_paren_primary_expression(tmp_c_array[0]); inspect_potential_paren_primary_expression(tmp_c_array[2]); inspect_potential_paren_primary_expression(tmp_c_array[4]); if ( (PARSE_LOGICOR_EXPRESSION & src.data<0>()[i-1].flags) && (PARSE_EXPRESSION & src.data<0>()[i+1].flags) && (PARSE_CONDITIONAL_EXPRESSION & src.data<0>()[i+3].flags)) { zaimoni::autoval_ptr<parse_tree> tmp; zaimoni::autoval_ptr<parse_tree> tmp2; tmp = repurpose_inner_parentheses(tmp_c_array[0]); // RAM conservation tmp2 = repurpose_inner_parentheses(tmp_c_array[2]); // RAM conservation parse_tree* const tmp3 = repurpose_inner_parentheses(tmp_c_array[4]); // RAM conservation tmp_c_array[0].OverwriteInto(*tmp); tmp_c_array[2].OverwriteInto(*tmp2); tmp_c_array[4].OverwriteInto(*tmp3); tmp_c_array[1].grab_index_token_from<1,0>(tmp_c_array[3]); tmp_c_array[1].grab_index_token_location_from<1,0>(tmp_c_array[3]); tmp_c_array[1].fast_set_arg<0>(tmp2.release()); tmp_c_array[1].fast_set_arg<1>(tmp.release()); tmp_c_array[1].fast_set_arg<2>(tmp3); tmp_c_array[1].core_flag_update(); tmp_c_array[1].flags |= PARSE_STRICT_CONDITIONAL_EXPRESSION; src.DeleteNSlotsAt<0>(3,i+1); // tmp_c_array becomes invalid here src.DeleteIdx<0>(--i); assert(is_C99_conditional_operator_expression_strict(src.data<0>()[i])); parse_tree& tmp4 = src.c_array<0>()[i]; cancel_outermost_parentheses(tmp4.front<0>()); cancel_outermost_parentheses(tmp4.front<1>()); cancel_outermost_parentheses(tmp4.front<2>()); assert(is_C99_conditional_operator_expression(src.data<0>()[i])); return true; } } } return false; } static bool eval_conditional_op(parse_tree& src, literal_converts_to_bool_func& literal_converts_to_bool SIG_CONST_TYPES) { bool is_true = false; if (literal_converts_to_bool(*src.c_array<1>(),is_true ARG_TYPES)) { const bool was_invalid = src.flags & parse_tree::INVALID; if (is_true) { // it's the infix arg src.type_code.MoveInto(src.c_array<0>()->type_code); src.eval_to_arg<0>(0); } else{ // it's the postfix arg src.type_code.MoveInto(src.c_array<2>()->type_code); src.eval_to_arg<2>(0); }; if (was_invalid && !(src.flags & parse_tree::INVALID)) { message_header(src.index_tokens[0]); INC_INFORM("invalid ? : operator optimized to valid "); INFORM(src); } return true; } return false; } //! \throws std::bad_alloc static void C_conditional_op_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_conditional_operator_expression(src)); // \todo 1) infix, postfix args have common non-void type (controls whether expression has valid type) // \todo change target for multidimensional arrays // \todo change target for const/volatile/restricted pointers // NOTE: result is always an rvalue in C (C99 6.5.15p4) switch(cmp(src.data<0>()->type_code.pointer_power,src.data<2>()->type_code.pointer_power)) { case 1: { // LHS has more guaranteed indirectability than RHS if (C_TYPE::NOT_VOID==src.data<2>()->type_code.base_type_index) { // recoverable src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(src.data<0>()->type_code.pointer_power); } else if (is_null_pointer_constant(*src.data<2>(),C99_intlike_literal_to_VM ARG_TYPES)) // (...) ? string : 0 -- do *not* error (null pointer); check true/false status //! \test default/Pass_if_zero.h, default/Pass_if_zero.hpp // actually, could be either 1 (positively is null pointer constant) or -1 (could be). We do the same thing in either case. value_copy(src.type_code,src.data<0>()->type_code); else{ src.type_code.set_type(0); // incoherent type // (...) ? string : int -- error //! \test default/Error_if_control64.h simple_error(src," has incoherent type"); } break; } case -1:{ // LHS has less guaranteed indirectability than RHS if (C_TYPE::NOT_VOID==src.data<0>()->type_code.base_type_index) { // recoverable src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(src.data<2>()->type_code.pointer_power); } else if (is_null_pointer_constant(*src.data<0>(),C99_intlike_literal_to_VM ARG_TYPES)) // (...) ? 0 : string -- do *not* error (null pointer); check true/false status //! \test default/Pass_if_zero.h, default/Pass_if_zero.hpp // actually, could be either 1 (positively is null pointer constant) or -1 (could be). We do the same thing in either case. value_copy(src.type_code,src.data<2>()->type_code); else{ src.type_code.set_type(0); // incoherent type // (...) ? int : string -- error //! \test default/Error_if_control65.h simple_error(src," has incoherent type"); } break; } case 0: { if (src.data<0>()->type_code.base_type_index==src.data<2>()->type_code.base_type_index) { src.type_code.set_type(src.data<0>()->type_code.base_type_index); src.type_code.set_pointer_power(src.data<0>()->type_code.pointer_power); } else if (0==src.data<0>()->type_code.pointer_power && (C_TYPE::VOID>=src.data<0>()->type_code.base_type_index || C_TYPE::VOID>=src.data<2>()->type_code.base_type_index)) { // can't test this from preprocessor src.type_code.set_type(0); // incoherent type simple_error(src," has incoherent type"); } //! \todo test cases at preprocessor level else if (0==src.data<0>()->type_code.pointer_power && is_innate_definite_type(src.data<0>()->type_code.base_type_index) && is_innate_definite_type(src.data<2>()->type_code.base_type_index)) // standard arithmetic conversions src.type_code.set_type(arithmetic_reconcile(src.data<0>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES)); //! \todo --do-what-i-mean can handle elementary integer types with same indirection as well else if (C_TYPE::NOT_VOID==src.data<0>()->type_code.base_type_index || C_TYPE::NOT_VOID==src.data<2>()->type_code.base_type_index) { src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(src.data<0>()->type_code.pointer_power); } else{ // can't test this from preprocessor src.type_code.set_type(0); // incoherent type simple_error(src," has incoherent type"); } break; } } // 2) prefix arg type convertible to _Bool (control whether expression is evaluatable at all) if (!converts_to_bool(src.data<1>()->type_code ARG_TYPES)) { // can't test this from preprocessor simple_error(src," has nonscalar control expression"); return; } // 3) RAM conservation: if we have a suitable literal Do It Now // \todo disable this at O0? if (eval_conditional_op(src,C99_literal_converts_to_bool ARG_TYPES)) return; } //! \throws std::bad_alloc static void CPP_conditional_op_easy_syntax_check(parse_tree& src,const type_system& types) { assert(is_C99_conditional_operator_expression(src)); // C++98/C++0x 13.3.1.2p1 mentions that overloading ? : is prohibited // \todo 1) infix, postfix args have common non-void type (controls whether expression has valid type); watch out for throw expressions // \todo change target for throw expressions // \todo change target for multidimensional arrays // \todo change target for const/volatile/restricted pointers // NOTE: result is an lvalue if both are lvalues of identical type (C++98 5.16p4) // NOTE: throw expressions play nice (they always have the type of the other half) switch(cmp(src.data<0>()->type_code.pointer_power,src.data<2>()->type_code.pointer_power)) { case 1: { // LHS has more guaranteed indirectability than RHS if (C_TYPE::NOT_VOID==src.data<2>()->type_code.base_type_index) { // recoverable src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(src.data<0>()->type_code.pointer_power); } else if (is_null_pointer_constant(*src.data<2>(),CPP_intlike_literal_to_VM ARG_TYPES)) // (...) ? string : 0 -- do *not* error (null pointer); check true/false status //! \test default/Pass_if_zero.h, default/Pass_if_zero.hpp // actually, could be either 1 (positively is null pointer constant) or -1 (could be). We do the same thing in either case. value_copy(src.type_code,src.data<0>()->type_code); else{ src.type_code.set_type(0); // incoherent type // (...) ? string : int -- error //! \test default/Error_if_control64.hpp simple_error(src," has incoherent type"); } break; } case -1:{ // LHS has less guaranteed indirectability than RHS if (C_TYPE::NOT_VOID==src.data<0>()->type_code.base_type_index) { // recoverable src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(src.data<2>()->type_code.pointer_power); } else if (is_null_pointer_constant(*src.data<0>(),CPP_intlike_literal_to_VM ARG_TYPES)) // (...) ? 0 : string -- do *not* error (null pointer); check true/false status //! \test default/Pass_if_zero.h, default/Pass_if_zero.hpp // actually, could be either 1 (positively is null pointer constant) or -1 (could be). We do the same thing in either case. value_copy(src.type_code,src.data<2>()->type_code); else{ src.type_code.set_type(0); // incoherent type // (...) ? int : string -- error //! \test default/Error_if_control65.hpp simple_error(src," has incoherent type"); } break; } case 0: { if (src.data<0>()->type_code.base_type_index==src.data<2>()->type_code.base_type_index) { src.type_code.set_type(src.data<0>()->type_code.base_type_index); src.type_code.set_pointer_power(src.data<0>()->type_code.pointer_power); } else if (0==src.data<0>()->type_code.pointer_power && (C_TYPE::VOID>=src.data<0>()->type_code.base_type_index || C_TYPE::VOID>=src.data<2>()->type_code.base_type_index)) { // can't test this from preprocessor src.type_code.set_type(0); // incoherent type simple_error(src," has incoherent type"); } else if (0==src.data<0>()->type_code.pointer_power && is_innate_definite_type(src.data<0>()->type_code.base_type_index) && is_innate_definite_type(src.data<2>()->type_code.base_type_index)) // standard arithmetic conversions src.type_code.set_type(arithmetic_reconcile(src.data<0>()->type_code.base_type_index,src.data<2>()->type_code.base_type_index ARG_TYPES)); //! \todo --do-what-i-mean can handle elementary integer types with same indirection as well else if (C_TYPE::NOT_VOID==src.data<0>()->type_code.base_type_index || C_TYPE::NOT_VOID==src.data<2>()->type_code.base_type_index) { src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(src.data<0>()->type_code.pointer_power); } else{ // can't test this from preprocessor src.type_code.set_type(0); // incoherent type simple_error(src," has incoherent type"); } break; } } // 2) prefix arg type convertible to bool (control whether expression is evaluatable at all) if (!converts_to_bool(src.data<1>()->type_code ARG_TYPES)) { // can't test this from preprocessor simple_error(src," has control expression unconvertible to bool"); return; } // 3) RAM conservation: if we have a suitable literal Do It Now // \todo disable this at O0? if (eval_conditional_op(src,CPP_literal_converts_to_bool ARG_TYPES)) return; } //! \throws std::bad_alloc static void locate_C99_conditional_op(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_conditional_op(src,i)) C_conditional_op_easy_syntax_check(src.c_array<0>()[i],types); } //! \throws std::bad_alloc static void locate_CPP_conditional_op(parse_tree& src, size_t& i, const type_system& types) { assert(!src.empty<0>()); assert(i<src.size<0>()); if ( (PARSE_OBVIOUS & src.data<0>()[i].flags) || !src.data<0>()[i].is_atomic()) return; if (terse_locate_conditional_op(src,i)) CPP_conditional_op_easy_syntax_check(src.c_array<0>()[i],types); } template<class T> static void parse_forward(parse_tree& src,const type_system& types, T parse_handler) { assert(!src.empty<0>()); if (0<src.size<0>()) { size_t i = 0; do { if (parse_tree::INVALID & src.data<0>()[i].flags) continue; parse_handler(src,i,types); } while(src.size<0>()>++i); }; } template<class T> static void parse_backward(parse_tree& src,const type_system& types, T parse_handler) { assert(!src.empty<0>()); if (0<src.size<0>()) { size_t i = src.size<0>(); do { if (parse_tree::INVALID & src.data<0>()[--i].flags) continue; parse_handler(src,i,types); } while(0<i); }; } // top-level has SIZE_MAX for parent_identifier_count //! \throws std::bad_alloc static void C99_locate_expressions(parse_tree& src,const size_t parent_identifier_count,const type_system& types) { if (PARSE_OBVIOUS & src.flags) return; size_t identifier_count = (0==parent_identifier_count) ? 0 : _count_identifiers(src); { size_t i[3] = {src.size<0>(), src.size<1>(), src.size<2>()}; size_t initial_i[3]; full_restart: memmove(initial_i,i,3*sizeof(size_t)); size_t stalled[3] = {SIZE_MAX,SIZE_MAX,SIZE_MAX}; try { while(0<i[0]) C99_locate_expressions(src.c_array<0>()[--i[0]],identifier_count,types); } catch(std::bad_alloc&) { stalled[0] = i[0]++; goto restart_1; } restart_1: try { while(0<i[1]) C99_locate_expressions(src.c_array<1>()[--i[1]],identifier_count,types); } catch(std::bad_alloc&) { stalled[1] = i[1]++; goto restart_2; } restart_2: try { while(0<i[2]) C99_locate_expressions(src.c_array<2>()[--i[2]],identifier_count,types); } catch(std::bad_alloc&) { stalled[2] = i[2]++; goto restart_3; } restart_3: if (SIZE_MAX>stalled[0] || SIZE_MAX>stalled[1] || SIZE_MAX>stalled[2]) { // had a memory management problem if (i[0]<initial_i[0] || i[1]<initial_i[1] || i[2]<initial_i[2]) // if we made some progress, restart goto full_restart; // otherwise give up throw std::bad_alloc(); } } const bool top_level = SIZE_MAX==parent_identifier_count; const bool parens_are_expressions = 0==parent_identifier_count // no identifiers from outside || (top_level && 0==identifier_count); // top-level, no identifiers if (parens_are_expressions || top_level || parent_identifier_count==identifier_count) if (inspect_potential_paren_primary_expression(src)) { if (top_level && 1==src.size<0>() && is_naked_parentheses_pair(src)) src.eval_to_arg<0>(0); return; } // top-level [ ] and { } die regardless of contents // note that top-level [ ] should be asphyxiating now if (top_level && suppress_naked_brackets_and_braces(src,"top-level",sizeof("top-level")-1)) return; if (!src.empty<0>()) { suppress_naked_brackets_and_braces(*src.c_array<0>(),"top-level",sizeof("top-level")-1); parse_forward(src,types,locate_C99_postfix_expression); parse_backward(src,types,locate_C99_unary_expression); parse_forward(src,types,locate_C99_mult_expression); parse_forward(src,types,locate_C99_add_expression); parse_forward(src,types,locate_C99_shift_expression); parse_forward(src,types,locate_C99_relation_expression); parse_forward(src,types,locate_C99_equality_expression); parse_forward(src,types,locate_C99_bitwise_AND); parse_forward(src,types,locate_C99_bitwise_XOR); parse_forward(src,types,locate_C99_bitwise_OR); parse_forward(src,types,locate_C99_logical_AND); parse_forward(src,types,locate_C99_logical_OR); parse_backward(src,types,locate_C99_conditional_op); /* assignment-expression: conditional-expression unary-expression assignment-operator assignment-expression assignment-operator: one of = *= /= %= += -= <<= >>= &= ^= |= */ #if 0 parse_backward(src,types,...); #endif /* expression: assignment-expression expression , assignment-expression */ #if 0 parse_forward(src,types,...); #endif }; } // top-level has SIZE_MAX for parent_identifier_count //! \throws std::bad_alloc static void CPP_locate_expressions(parse_tree& src,const size_t parent_identifier_count,const type_system& types) { if (PARSE_OBVIOUS & src.flags) return; const size_t identifier_count = (0==parent_identifier_count) ? 0 : _count_identifiers(src); { size_t i[3] = {src.size<0>(), src.size<1>(), src.size<2>()}; size_t initial_i[3]; full_restart: memmove(initial_i,i,3*sizeof(size_t)); size_t stalled[3] = {SIZE_MAX,SIZE_MAX,SIZE_MAX}; try { while(0<i[0]) CPP_locate_expressions(src.c_array<0>()[--i[0]],identifier_count,types); } catch(std::bad_alloc&) { stalled[0] = i[0]++; goto restart_1; } restart_1: try { while(0<i[1]) CPP_locate_expressions(src.c_array<1>()[--i[1]],identifier_count,types); } catch(std::bad_alloc&) { stalled[1] = i[1]++; goto restart_2; } restart_2: try { while(0<i[2]) CPP_locate_expressions(src.c_array<2>()[--i[2]],identifier_count,types); } catch(std::bad_alloc&) { stalled[2] = i[2]++; goto restart_3; } restart_3: if (SIZE_MAX>stalled[0] || SIZE_MAX>stalled[1] || SIZE_MAX>stalled[2]) { // had a memory management problem if (i[0]<initial_i[0] || i[1]<initial_i[1] || i[2]<initial_i[2]) // if we made some progress, restart goto full_restart; // otherwise give up throw std::bad_alloc(); } } const bool top_level = SIZE_MAX==parent_identifier_count; const bool parens_are_expressions = 0==parent_identifier_count // no identifiers from outside || (top_level && 0==identifier_count); // top-level, no identifiers // try for ( expression ) if (parens_are_expressions || top_level || parent_identifier_count==identifier_count) if (inspect_potential_paren_primary_expression(src)) { if (top_level && 1==src.size<0>() && is_naked_parentheses_pair(src)) src.eval_to_arg<0>(0); return; } // top-level [ ] and { } die regardless of contents if (top_level && suppress_naked_brackets_and_braces(src,"top-level",sizeof("top-level")-1)) return; if (!src.empty<0>()) { suppress_naked_brackets_and_braces(*src.c_array<0>(),"top-level",sizeof("top-level")-1); parse_forward(src,types,locate_CPP_postfix_expression); parse_backward(src,types,locate_CPP_unary_expression); #if 0 /* pmexpression: castexpression pmexpression .* castexpression pmexpression ->* castexpression */ parse_forward(src,types,...); #endif parse_forward(src,types,locate_CPP_mult_expression); parse_forward(src,types,locate_CPP_add_expression); parse_forward(src,types,locate_CPP_shift_expression); parse_forward(src,types,locate_CPP_relation_expression); parse_forward(src,types,locate_CPP_equality_expression); parse_forward(src,types,locate_CPP_bitwise_AND); parse_forward(src,types,locate_CPP_bitwise_XOR); parse_forward(src,types,locate_CPP_bitwise_OR); parse_forward(src,types,locate_CPP_logical_AND); parse_forward(src,types,locate_CPP_logical_OR); parse_backward(src,types,locate_CPP_conditional_op); /* assignment-expression: conditional-expression unary-expression assignment-operator assignment-expression assignment-operator: one of = *= /= %= += -= <<= >>= &= ^= |= */ #if 0 parse_backward(src,types,...); #endif /* expression: assignment-expression expression , assignment-expression */ #if 0 parse_forward(src,types,...); #endif }; } static void _label_CPP_literal(parse_tree& src) { if (src.is_atomic() && C_TESTFLAG_IDENTIFIER==src.index_tokens[0].flags) { if (token_is_string<4>(src.index_tokens[0].token,"true")) { src.flags |= (PARSE_PRIMARY_EXPRESSION | parse_tree::CONSTANT_EXPRESSION); src.type_code.set_type(C_TYPE::BOOL); } else if (token_is_string<4>(src.index_tokens[0].token,"this")) { src.flags |= PARSE_PRIMARY_EXPRESSION; src.type_code.set_type(C_TYPE::NOT_VOID); src.type_code.set_pointer_power(1); } else if (token_is_string<5>(src.index_tokens[0].token,"false")) { src.flags |= (PARSE_PRIMARY_EXPRESSION | parse_tree::CONSTANT_EXPRESSION); src.type_code.set_type(C_TYPE::BOOL); } } } //! \throw std::bad_alloc static bool C99_CondenseParseTree(parse_tree& src,const type_system& types) { assert(src.is_raw_list()); assert(1<src.size<0>()); const size_t starting_errors = zcc_errors.err_count(); _label_literals(src,types); if (!_match_pairs(src)) return false; try { C99_locate_expressions(src,SIZE_MAX,types); } catch(std::bad_alloc&) { // error count change is already false if (starting_errors<zcc_errors.err_count()) return false; throw; } if (starting_errors<zcc_errors.err_count()) return false; while(src.is_raw_list() && 1==src.size<0>()) src.eval_to_arg<0>(0); return true; } //! \throw std::bad_alloc static bool CPP_CondenseParseTree(parse_tree& src,const type_system& types) { assert(src.is_raw_list()); assert(1<src.size<0>()); const size_t starting_errors = zcc_errors.err_count(); _label_literals(src,types); std::for_each(src.begin<0>(),src.end<0>(),_label_CPP_literal); // intercepts: true, false, this if (!_match_pairs(src)) return false; // check that this is at least within a brace pair or a parentheses pair (it is actually required to be in a non-static member function, or constructor mem-initializer if (!_this_vaguely_where_it_could_be_cplusplus(src)) return false; try { CPP_locate_expressions(src,SIZE_MAX,types); } catch(std::bad_alloc&) { // error count change is already false if (starting_errors<zcc_errors.err_count()) return false; throw; } if (starting_errors<zcc_errors.err_count()) return false; while(src.is_raw_list() && 1==src.size<0>()) src.eval_to_arg<0>(0); return true; } static const POD_pair<const char*,size_t> C99_nontype_decl_specifier_list[] = { DICT_STRUCT("typedef"), DICT_STRUCT("const"), DICT_STRUCT("volatile"), DICT_STRUCT("restrict"), DICT_STRUCT("register"), DICT_STRUCT("static"), DICT_STRUCT("extern"), DICT_STRUCT("inline"), DICT_STRUCT("auto"), DICT_STRUCT("_Thread_local"), // C1X, actually }; static const POD_pair<const char*,size_t> CPP0X_nontype_decl_specifier_list[] = { DICT_STRUCT("typedef"), DICT_STRUCT("const"), DICT_STRUCT("volatile"), DICT_STRUCT("register"), DICT_STRUCT("static"), DICT_STRUCT("extern"), DICT_STRUCT("inline"), DICT_STRUCT("thread_local"), // C1X _Thread_Local DICT_STRUCT("constexpr"), DICT_STRUCT("mutable"), DICT_STRUCT("virtual"), DICT_STRUCT("explicit"), DICT_STRUCT("friend") }; static size_t C99_type_or_invariant_decl_specifier(const parse_tree& x) { if (PARSE_TYPE & x.flags) return STATIC_SIZE(C99_nontype_decl_specifier_list); if (x.is_atomic()) { const errr i = linear_find(x.index_tokens[0].token.first,C99_nontype_decl_specifier_list,STATIC_SIZE(C99_nontype_decl_specifier_list)); if (STATIC_SIZE(C99_nontype_decl_specifier_list)>i) return i; } return SIZE_MAX; } static size_t CPP0X_type_or_invariant_decl_specifier(const parse_tree& x) { if (PARSE_TYPE & x.flags) return STATIC_SIZE(CPP0X_nontype_decl_specifier_list); if (x.is_atomic()) { const errr i = linear_find(x.index_tokens[0].token.first,CPP0X_nontype_decl_specifier_list,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); if (STATIC_SIZE(CPP0X_nontype_decl_specifier_list)>i) return i; } return SIZE_MAX; } void record_qualifier(parse_tree* x, unsigned char qualify) { assert(x); assert(PARSE_TYPE & x->flags); tail_recurse: x->type_code.q_vector.back() |= qualify; if (is_naked_parentheses_pair(*x) && 1==x->size<0>() && (PARSE_TYPE & x->data<0>()->flags)) { // discard nested parentheses while(is_naked_parentheses_pair(*x->data<0>()) && 1==x->data<0>()->size<0>() && (PARSE_TYPE & x->data<0>()->data<0>()->flags)) x->c_array<0>()->eval_to_arg<0>(0); // tail-recurse x = x->c_array<0>(); goto tail_recurse; } } void record_qualifier_or_warn(parse_tree& src,unsigned char qualify,size_t type_at,size_t qual_at,bool& have_warned,const char* const warning) { assert(src.size<0>()>type_at); assert(src.size<0>()>qual_at); assert(PARSE_TYPE & src.data<0>()[type_at].flags); if (!(qualify & src.data<0>()[type_at].type_code.q_vector.back())) record_qualifier(src.c_array<0>()+type_at,qualify); else if (!have_warned) { // already qualified, have not warned yet message_header(src.data<0>()[qual_at].index_tokens[0]); INC_INFORM(WARN_STR); INFORM(warning); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); have_warned = true; } } static void _condense_const_volatile_onto_type_preparsed(parse_tree& src,size_t& i,size_t& k,kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner,const char* const warn_const,const char* const warn_volatile) { size_t offset = 0; bool have_warned_too_many_types = false; bool have_warned_about_const = false; bool have_warned_about_volatile = false; #define INVARIANT() \ assert(src.size<0>()>i); \ assert(src.size<0>()-i>=invariant_decl_scanner.size()); \ assert(invariant_decl_scanner.size()>k); \ assert(PARSE_TYPE & src.data<0>()[i+k].flags) INVARIANT(); while(k>offset) switch(invariant_decl_scanner[offset]) { case C99_CPP_CONST_IDX: //! \test decl.C99/Warn_dup_const.h //! \test decl.C99/Warn_dup_const.hpp //! \test decl.C99/Warn_dup_const2.h //! \test decl.C99/Warn_dup_const2.hpp record_qualifier_or_warn(src,type_spec::_const,i+k,i+offset,have_warned_about_const,warn_const); src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset); if (0<i) --i; else --k; if (invariant_decl_scanner.size()<=k) return; INVARIANT(); continue; case C99_CPP_VOLATILE_IDX: //! \test decl.C99/Warn_dup_volatile.h //! \test decl.C99/Warn_dup_volatile.hpp //! \test decl.C99/Warn_dup_volatile2.h //! \test decl.C99/Warn_dup_volatile2.hpp record_qualifier_or_warn(src,type_spec::_volatile,i+k,i+offset,have_warned_about_volatile,warn_volatile); src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset); if (0<i) --i; else --k; if (invariant_decl_scanner.size()<=k) return; INVARIANT(); continue; default: if (0<offset && invariant_decl_scanner.strict_ub()-1==invariant_decl_scanner[offset-1]) { if (!have_warned_too_many_types) { message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("multiple types in decl-specifier sequence, discarding extra types"); zcc_errors.inc_error(); have_warned_too_many_types = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset); if (0<i) --i; else --k; if (invariant_decl_scanner.size()<=k) return; INVARIANT(); continue; } ++offset; } offset = k+1; while(invariant_decl_scanner.size()>offset) switch(invariant_decl_scanner[offset]) { case C99_CPP_CONST_IDX: //! \test decl.C99/Warn_dup_const2.h //! \test decl.C99/Warn_dup_const2.hpp //! \test decl.C99/Warn_dup_const3.h //! \test decl.C99/Warn_dup_const3.hpp record_qualifier_or_warn(src,type_spec::_const,i+k,i+offset,have_warned_about_const,warn_const); src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset); INVARIANT(); continue; case C99_CPP_VOLATILE_IDX: //! \test decl.C99/Warn_dup_volatile2.h //! \test decl.C99/Warn_dup_volatile2.hpp //! \test decl.C99/Warn_dup_volatile3.h //! \test decl.C99/Warn_dup_volatile3.hpp record_qualifier_or_warn(src,type_spec::_volatile,i+k,i+offset,have_warned_about_volatile,warn_volatile); src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset); INVARIANT(); continue; default: if (invariant_decl_scanner.strict_ub()-1==invariant_decl_scanner[offset-1]) { if (!have_warned_too_many_types) { message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("multiple types in decl-specifier sequence, discarding extra types"); zcc_errors.inc_error(); have_warned_too_many_types = true; } src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(offset); INVARIANT(); continue; } ++offset; } #undef INVARIANT } static void _condense_const_volatile_onto_type(parse_tree& src,size_t& i,kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner,const char* const warn_const,const char* const warn_volatile) { size_t offset = 0; bool have_warned_too_many_types = false; bool have_warned_about_const = false; bool have_warned_about_volatile = false; assert(PARSE_TYPE & src.data<0>()[i].flags); while(0<i-offset && invariant_decl_scanner(src.data<0>()[i- ++offset])) switch(invariant_decl_scanner[offset-1]) { case C99_CPP_CONST_IDX: //! \test decl.C99/Warn_dup_const.h //! \test decl.C99/Warn_dup_const.hpp //! \test decl.C99/Warn_dup_const2.h //! \test decl.C99/Warn_dup_const2.hpp record_qualifier_or_warn(src,type_spec::_const,i,i-offset,have_warned_about_const,warn_const); src.DeleteIdx<0>(i-- -offset); invariant_decl_scanner.DeleteIdx(--offset); continue; case C99_CPP_VOLATILE_IDX: //! \test decl.C99/Warn_dup_volatile.h //! \test decl.C99/Warn_dup_volatile.hpp //! \test decl.C99/Warn_dup_volatile2.h //! \test decl.C99/Warn_dup_volatile2.hpp record_qualifier_or_warn(src,type_spec::_volatile,i,i-offset,have_warned_about_volatile,warn_volatile); src.DeleteIdx<0>(i-- -offset); invariant_decl_scanner.DeleteIdx(--offset); continue; default: if (invariant_decl_scanner.strict_ub()-1==invariant_decl_scanner[offset-1]) { if (!have_warned_too_many_types) { message_header(src.data<0>()[i-offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("multiple types in decl-specifier sequence, discarding extra types"); zcc_errors.inc_error(); have_warned_too_many_types = true; } src.DeleteIdx<0>(i-- -offset); invariant_decl_scanner.DeleteIdx(--offset); continue; } } invariant_decl_scanner.clear(); offset = 0; while(src.size<0>()-i>offset+1 && invariant_decl_scanner(src.data<0>()[i+ ++offset])) switch(invariant_decl_scanner[offset-1]) { case C99_CPP_CONST_IDX: //! \test decl.C99/Warn_dup_const2.h //! \test decl.C99/Warn_dup_const2.hpp //! \test decl.C99/Warn_dup_const3.h //! \test decl.C99/Warn_dup_const3.hpp record_qualifier_or_warn(src,type_spec::_const,i,i+offset,have_warned_about_const,warn_const); src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(--offset); continue; case C99_CPP_VOLATILE_IDX: //! \test decl.C99/Warn_dup_volatile2.h //! \test decl.C99/Warn_dup_volatile2.hpp //! \test decl.C99/Warn_dup_volatile3.h //! \test decl.C99/Warn_dup_volatile3.hpp record_qualifier_or_warn(src,type_spec::_volatile,i,i+offset,have_warned_about_volatile,warn_volatile); src.DeleteIdx<0>(i+offset); invariant_decl_scanner.DeleteIdx(--offset); continue; default: if (invariant_decl_scanner.strict_ub()-1==invariant_decl_scanner[offset-1]) { if (!have_warned_too_many_types) { message_header(src.data<0>()[i+offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("multiple types in decl-specifier sequence, discarding extra types"); zcc_errors.inc_error(); have_warned_too_many_types = true; } src.DeleteIdx<0>(i-- +offset); invariant_decl_scanner.DeleteIdx(--offset); continue; } } invariant_decl_scanner.clear(); } void C99_condense_const_volatile_onto_type(parse_tree& src) { assert(src.is_raw_list()); size_t i = 0; kleene_star<STATIC_SIZE(C99_nontype_decl_specifier_list)+1,size_t (*)(const parse_tree&)> invariant_decl_scanner(C99_type_or_invariant_decl_specifier); do if (PARSE_TYPE & src.data<0>()[i].flags) _condense_const_volatile_onto_type(src,i,invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); while(src.size<0>()> ++i); } void CPP0X_condense_const_volatile_onto_type(parse_tree& src) { assert(src.is_raw_list()); size_t i = 0; kleene_star<STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+1,size_t (*)(const parse_tree&)> invariant_decl_scanner(CPP0X_type_or_invariant_decl_specifier); do if (PARSE_TYPE & src.data<0>()[i].flags) _condense_const_volatile_onto_type(src,i,invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); while(src.size<0>()> ++i); } //! \todo check that the fact all literals are already legal-form is used //! \throw std::bad_alloc() static void C99_ContextFreeParse(parse_tree& src,const type_system& types) { assert(src.is_raw_list()); _label_literals(src,types); // handle core type specifiers C99_notice_primary_type(src); C99_condense_const_volatile_onto_type(src); if (!_match_pairs(src)) return; // struct/union/enum specifiers can occur in all sorts of strange places C99_notice_struct_union_enum(src); } static bool CPP_ok_for_toplevel_qualified_name(const parse_tree& x) { if (!x.is_atomic()) return false; if (PARSE_PRIMARY_TYPE & x.flags) return false; if (CPP_echo_reserved_keyword(x.index_tokens[0].token.first,x.index_tokens[0].token.second)) return false; if (C_TESTFLAG_IDENTIFIER & x.index_tokens[0].flags) return true; if (token_is_string<2>(x.index_tokens[0].token,"::")) return true; return false; } //! \throw std::bad_alloc static void CPP_notice_scope_glue(parse_tree& src) { assert(!src.empty<0>()); size_t i = 0; { size_t offset = 0; while(i+offset<src.size<0>()) { if (robust_token_is_string<2>(src.data<0>()[i],"::")) { const bool is_global = 0==i || !CPP_ok_for_toplevel_qualified_name(src.data<0>()[i-1]); size_t resize_to = src.data<0>()[i].index_tokens[0].token.second; size_t forward_span = 0; bool last_scope = true; bool have_suppressed_consecutive_scope = false; while(i+offset+forward_span+1<src.size<0>() && CPP_ok_for_toplevel_qualified_name(src.data<0>()[i+forward_span+1])) { const bool this_scope = robust_token_is_string<2>(src.data<0>()[i+forward_span+1],"::"); if (!last_scope && !this_scope) break; if (last_scope && this_scope) { if (!have_suppressed_consecutive_scope) { //! \test zcc/decl.C99/Error_consecutive_doublecolon_type.hpp simple_error(src.c_array<0>()[i]," consecutive :: operators in nested-name-specifier"); have_suppressed_consecutive_scope = true; } // remove from parse src.DestroyNAtAndRotateTo<0>(1,i+forward_span,src.size<0>()-offset); offset += 1; continue; } last_scope = this_scope; ++forward_span; resize_to += src.data<0>()[i+forward_span].index_tokens[0].token.second; }; // assemble this into something identifier-like if (!is_global) { --i; ++forward_span; resize_to += src.data<0>()[i].index_tokens[0].token.second; }; if (0<forward_span) { char* tmp = _new_buffer<char>(ZAIMONI_LEN_WITH_NULL(resize_to)); if (!tmp) { if (0==offset) throw std::bad_alloc(); src.DeleteNSlotsAt<0>(offset,src.size<0>()-offset); offset = 0; tmp = _new_buffer_nonNULL_throws<char>(ZAIMONI_LEN_WITH_NULL(resize_to)); }; strncpy(tmp,src.data<0>()[i].index_tokens[0].token.first,src.data<0>()[i].index_tokens[0].token.second); size_t j = 1; do strncat(tmp,src.data<0>()[i+j].index_tokens[0].token.first,src.data<0>()[i+j].index_tokens[0].token.second); while(forward_span>= ++j); const char* tmp2 = is_string_registered(tmp); if (!tmp2) { src.c_array<0>()[i].grab_index_token_from_str_literal<0>(tmp,C_TESTFLAG_IDENTIFIER); // well...not really, but it'll substitute for one src.c_array<0>()[i].control_index_token<0>(true); } else{ free(tmp); src.c_array<0>()[i].grab_index_token_from_str_literal<0>(tmp2,C_TESTFLAG_IDENTIFIER); // well...not really, but it'll substitute for one }; j = 1; do src.c_array<0>()[i+j].destroy(); while(forward_span>= ++j); src.DestroyNAtAndRotateTo<0>(forward_span,i+1,src.size<0>()-offset); offset += forward_span; }; if (last_scope) { // might be able to save: new, delete, operator ___, destructor name if ( i+offset+1>=src.size<0>() || ( !robust_token_is_string<3>(src.data<0>()[i+1],"new") && !robust_token_is_string<6>(src.data<0>()[i+1],"delete") && !robust_token_is_string<8>(src.data<0>()[i+1],"operator") && !robust_token_is_char<'~'>(src.data<0>()[i+1]))) // no, compl does not interoperate for destructor names //! \test zcc/decl.C99/Error_doublecolon_type.hpp simple_error(src.c_array<0>()[i]," nested-name-specifier ending in ::"); } }; ++i; }; if (0<offset) src.DeleteNSlotsAt<0>(offset,src.size<0>()-offset); } // efficiency tuning: we have to have no empty slots at top level before recursing, // to mitigate risk of dynamic memory allocation failure std::for_each(src.begin<0>(),src.end<0>(),conditional_action<bool (*)(const parse_tree&),void (*)(parse_tree&)>(is_nonempty_naked_pair,CPP_notice_scope_glue)); } static void CPP_handle_pragma_relay(parse_tree& src) { assert(src.is_raw_list()); // early return implied never to happen by assert, but don't want risk of undefined behavior in release mode if (src.empty<0>()) return; bool typeid_is_ok = false; // has to be enabled in #include <typeinfo> size_t i = 0; do { parse_tree& tmp = src.c_array<0>()[i]; if (tmp.is_atomic()) { const errr Idx = linear_find(tmp.index_tokens[0].token.first, tmp.index_tokens[0].token.second,pragma_relay_keywords,PRAGMA_RELAY_KEYWORDS_STRICT_UB); if (0<=Idx) { // react to any relay keywords that actually mean anything here if (RELAY_ZCC_ENABLE_TYPEID==Idx) typeid_is_ok = true; src.DeleteIdx<0>(i); } else if (!typeid_is_ok && token_is_string<6>(tmp.index_tokens[0].token,"typeid")) //! \test staticassert.C1X/Error_typeid_no_typeinfo.hpp simple_error(tmp," requires #include <typeinfo> first (C++0X 5.2.8p6)"); } } while(src.size<0>()> ++i); } //! \todo check that the fact all literals are already legal-form is used //! \throw std::bad_alloc static void CPP_ContextFreeParse(parse_tree& src,const type_system& types) { assert(src.is_raw_list()); CPP_handle_pragma_relay(src); _label_literals(src,types); std::for_each(src.begin<0>(),src.end<0>(),_label_CPP_literal); // intercepts: true, false, this // handle core type specifiers CPP_notice_primary_type(src); CPP0X_condense_const_volatile_onto_type(src); if (!_match_pairs(src)) return; // do context-free part of qualified-names CPP_notice_scope_glue(src); // class/struct/union/enum specifiers can occur in all sorts of strange places CPP_notice_class_struct_union_enum(src); } //! \test if.C99/Pass_zero.hpp, if.C99/Pass_zero.h bool C99_integer_literal_is_zero(const char* const x,const size_t x_len,const lex_flags flags) { assert(x && *x); assert(0<x_len); assert(C_TESTFLAG_PP_NUMERAL & flags); assert(!(C_TESTFLAG_FLOAT & flags)); C_REALITY_CHECK_PP_NUMERAL_FLAGS(flags); //! \todo need some way to signal legality for integer literals switch(C_EXTRACT_BASE_CODE(flags)) { #ifndef NDEBUG default: FATAL_CODE("unclassified integer literal",3); #endif case C_BASE_OCTAL: { // all-zeros is zero, ok with leading 0 prefix C_PPOctalInteger test_oct; ZAIMONI_PASSTHROUGH_ASSERT(C_PPOctalInteger::is(x,x_len,test_oct)); return strspn(test_oct.ptr,"0") == test_oct.digit_span; }; case C_BASE_DECIMAL: { // decimal is easy C_PPDecimalInteger test_dec; ZAIMONI_PASSTHROUGH_ASSERT(C_PPDecimalInteger::is(x,x_len,test_dec)); return 1==test_dec.digit_span && '0'==test_dec.ptr[0]; }; case C_BASE_HEXADECIMAL: { // all-zeros is zero, but ignore the leading 0x prefix C_PPHexInteger test_hex; ZAIMONI_PASSTHROUGH_ASSERT(C_PPHexInteger::is(x,x_len,test_hex)); return strspn(test_hex.ptr+2,"0")+2 == test_hex.digit_span; }; } #ifdef NDEBUG return false; #endif } static void eval_string_literal_deref(parse_tree& src,const type_system& types,const POD_pair<const char*,size_t>& str_lit,const umaxint& tmp,bool is_negative,bool index_src_is_char) { const size_t strict_ub = LengthOfCStringLiteral(str_lit.first,str_lit.second); // C99 6.2.6.2p3 -0 is not actually allowed to generate the bitpattern -0, so no trapping if (is_negative && tmp==0) is_negative = false; if (is_negative) { //! \test default/Error_if_control66.hpp, default/Error_if_control66.h //! \test default/Error_if_control67.hpp, default/Error_if_control67.h if (!(src.flags & parse_tree::INVALID)) { message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("undefined behavior: "); INC_INFORM(src); INFORM(" dereferences string literal with negative index"); if (index_src_is_char) INFORM("(does this source code want char to act like unsigned char?)"); src.flags |= parse_tree::INVALID; zcc_errors.inc_error(); } return; } else if (strict_ub <= tmp) { //! \test default/Error_if_control68.hpp, default/Error_if_control68.h //! \test default/Error_if_control69.hpp, default/Error_if_control69.h if (!(src.flags & parse_tree::INVALID)) { message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("undefined behavior: "); INC_INFORM(src); INFORM(" dereferences string literal past its end"); if (index_src_is_char && target_machine->signed_max<virtual_machine::std_int_char>()<tmp) { if (tmp.to_uint()-1==target_machine->signed_max<virtual_machine::std_int_char>()) INFORM("(does this source code want char to act like signed char, with integer representation sign-and-magnitude?)"); else if (tmp==target_machine->unsigned_max<virtual_machine::std_int_char>()) INFORM("(does this source code want char to act like signed char, with integer representation one's complement?)"); } src.flags |= parse_tree::INVALID; zcc_errors.inc_error(); } return; }; assert(tmp.representable_as_uint()); char* tmp2 = GetCCharacterLiteralAt(str_lit.first,str_lit.second,tmp.to_uint()); assert(tmp2); src.destroy(); // str_lit goes invalid here, don't use again src.grab_index_token_from<0>(tmp2,C_TESTFLAG_CHAR_LITERAL); _label_one_literal(src,types); } #define ZCC_EVALPARSETREE_PAIR_EVAL(A,B) \ { \ bool RAM_err = false; \ try { \ EvalParseTree(*src.c_array<A>(),types); \ } \ catch(std::bad_alloc&) \ { \ RAM_err = true; \ goto restart_1; \ } \ restart_1: \ /* can't recover locally if this throws std::bad_alloc */ \ EvalParseTree(*src.c_array<B>(),types); \ if (RAM_err) EvalParseTree(*src.c_array<A>(),types); \ } //! \throw std::bad_alloc static bool eval_array_deref(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type literal_converts_to_integer, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (!is_array_deref(src)) return false; // crunch __[...] // canonical definition: *((__)+(...)) ZCC_EVALPARSETREE_PAIR_EVAL(0,1); if (parse_tree::CONSTANT_EXPRESSION & src.flags) { const unsigned int str_index = (C_TESTFLAG_STRING_LITERAL==src.data<0>()->index_tokens[0].flags) ? 0 : (C_TESTFLAG_STRING_LITERAL==src.data<1>()->index_tokens[0].flags) ? 1 : UINT_MAX; if (UINT_MAX>str_index) { umaxint tmp; if (!intlike_literal_to_VM(tmp,*src.data(1-str_index) ARG_TYPES)) return false; const size_t promoted_type = default_promote_type(src.type_code.base_type_index ARG_TYPES); const virtual_machine::std_int_enum machine_type = (virtual_machine::std_int_enum)((promoted_type-C_TYPE::INT)/2+virtual_machine::std_int_int); eval_string_literal_deref(src,types,src.data(str_index)->index_tokens[0].token,tmp,tmp.test(target_machine->C_bit(machine_type)-1),C_TESTFLAG_CHAR_LITERAL==src.data(1-str_index)->index_tokens[0].flags); return true; } } return false; } //! \throw std::bad_alloc static bool eval_deref( parse_tree& src, const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree) { //! \todo handle operator overloading (fork to handle C/C++?) //! \todo catch *& cancellation if (is_C99_unary_operator_expression<'*'>(src)) { EvalParseTree(*src.c_array<2>(),types); if (C_TESTFLAG_STRING_LITERAL==src.data<2>()->index_tokens[0].flags) { //! \test default/Pass_if_zero.hpp //! \test default/Pass_if_zero.h //! \test default/Pass_if_nonzero.hpp //! \test default/Pass_if_nonzero.h eval_string_literal_deref(src,types,src.data<2>()->index_tokens[0].token,umaxint(0),false,false); return true; } } return false; } //! \throw std::bad_alloc static bool eval_logical_NOT(parse_tree& src, const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_logical_NOT_expression, literal_converts_to_bool_func& literal_converts_to_bool) { if (is_logical_NOT_expression(src)) { EvalParseTree(*src.c_array<2>(),types); if (eval_logical_NOT(src,types,is_logical_NOT_expression,literal_converts_to_bool)) return true; } return false; } //! \throw std::bad_alloc static bool eval_bitwise_compl( parse_tree& src, const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_bitwise_complement_expression, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_bitwise_complement_expression(src)) { EvalParseTree(*src.c_array<2>(),types); if (eval_bitwise_compl(src,types,is_bitwise_complement_expression,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_unary_plus(parse_tree& src, const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree) { if (is_C99_unary_operator_expression<'+'>(src)) { EvalParseTree(*src.c_array<2>(),types); if (eval_unary_plus(src,types)) return true; } return false; } //! \throw std::bad_alloc static bool eval_unary_minus(parse_tree& src, const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_unary_operator_expression<'-'>(src)) { EvalParseTree(*src.c_array<2>(),types); if (eval_unary_minus(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_mult_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_mult_operator_expression<'*'>(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_mult_expression(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_div_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_mult_operator_expression<'/'>(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_div_expression(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_mod_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_mult_operator_expression<'%'>(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_mod_expression(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_add_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_add_operator_expression<'+'>(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_add_expression(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_sub_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_add_operator_expression<'-'>(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_sub_expression(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_shift(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_shift_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_shift(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_relation_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_C99_relation_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_relation_expression(src,types,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_equality_expression(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_equality_expression, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_equality_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_equality_expression(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_bitwise_AND(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_bitwise_AND_expression, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_bitwise_AND_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_bitwise_AND(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_bitwise_XOR(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_bitwise_XOR_expression, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_bitwise_XOR_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_bitwise_XOR(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_bitwise_OR(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_bitwise_OR_expression, literal_converts_to_bool_func& literal_converts_to_bool, intlike_literal_to_VM_func& intlike_literal_to_VM) { if (is_bitwise_OR_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_bitwise_OR(src,types,literal_converts_to_bool,intlike_literal_to_VM)) return true; } return false; } //! \throw std::bad_alloc static bool eval_logical_AND(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_logical_AND_expression, literal_converts_to_bool_func& literal_converts_to_bool) { if (is_logical_AND_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_logical_AND(src,types,literal_converts_to_bool)) return true; } return false; } //! \throw std::bad_alloc static bool eval_logical_OR(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, func_traits<bool (*)(const parse_tree&)>::function_ref_type is_logical_OR_expression, literal_converts_to_bool_func& literal_converts_to_bool) { if (is_logical_OR_expression(src)) { ZCC_EVALPARSETREE_PAIR_EVAL(1,2); if (eval_logical_OR(src,types,literal_converts_to_bool)) return true; } return false; } //! \throw std::bad_alloc static bool eval_conditional_operator(parse_tree& src,const type_system& types, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree, literal_converts_to_bool_func& literal_converts_to_bool) { if (is_C99_conditional_operator_expression(src)) { // prefix operator is boolean EvalParseTree(*src.c_array<1>(),types); if (eval_conditional_op(src,literal_converts_to_bool ARG_TYPES)) return true; } return false; } #if 0 static bool cancel_addressof_deref_operators(parse_tree& src) { assert(is_C99_unary_operator_expression(src)); if ('&'==*src.index_tokens[0].token.first) { // strip off &*, and remove lvalue-ness of target if (is_C99_unary_operator_expression<'*'>(*src.data<2>()) && 0<src.data<2>()->data<2>()->type_code.pointer_power) { parse_tree tmp; src.c_array<2>()->c_array<2>()->OverwriteInto(tmp); tmp.type_code.traits &= ~type_spec::lvalue; tmp.MoveInto(src); } #if 0 if (is_array_deref(*src.data<2>())) { //! \todo convert &(___[...]) to (__+...) } #endif }; return false; } #endif //! \throw std::bad_alloc static bool C99_EvalParseTree(parse_tree& src,const type_system& types) { const size_t starting_errors = zcc_errors.err_count(); RestartEval: if (src.is_atomic() || (parse_tree::INVALID & src.flags)) return starting_errors==zcc_errors.err_count(); if (eval_array_deref(src,types,C99_EvalParseTree,C99_literal_converts_to_integer,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_conditional_operator(src,types,C99_EvalParseTree,C99_literal_converts_to_bool)) goto RestartEval; if (eval_logical_OR(src,types,C99_EvalParseTree,is_C99_logical_OR_expression,C99_literal_converts_to_bool)) goto RestartEval; if (eval_logical_AND(src,types,C99_EvalParseTree,is_C99_logical_AND_expression,C99_literal_converts_to_bool)) goto RestartEval; if (eval_deref(src,types,C99_EvalParseTree)) goto RestartEval; if (eval_logical_NOT(src,types,C99_EvalParseTree,is_C99_unary_operator_expression<'!'>,C99_literal_converts_to_bool)) goto RestartEval; if (eval_unary_plus(src,types,C99_EvalParseTree)) goto RestartEval; if (eval_unary_minus(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_mult_expression(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_div_expression(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_mod_expression(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_add_expression(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_sub_expression(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_shift(src,types,C99_EvalParseTree,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_relation_expression(src,types,C99_EvalParseTree,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_equality_expression(src,types,C99_EvalParseTree,is_C99_equality_expression,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_AND(src,types,C99_EvalParseTree,is_C99_bitwise_AND_expression,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_XOR(src,types,C99_EvalParseTree,is_C99_bitwise_XOR_expression,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_OR(src,types,C99_EvalParseTree,is_C99_bitwise_OR_expression,C99_literal_converts_to_bool,C99_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_compl(src,types,C99_EvalParseTree,is_C99_unary_operator_expression<'~'>,C99_intlike_literal_to_VM)) goto RestartEval; return starting_errors==zcc_errors.err_count(); } //! \throw std::bad_alloc static bool CPP_EvalParseTree(parse_tree& src,const type_system& types) { const size_t starting_errors = zcc_errors.err_count(); RestartEval: if (src.is_atomic() || (parse_tree::INVALID & src.flags)) return starting_errors==zcc_errors.err_count(); if (eval_array_deref(src,types,CPP_EvalParseTree,CPP_literal_converts_to_integer,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_conditional_operator(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool)) goto RestartEval; if (eval_logical_OR(src,types,CPP_EvalParseTree,is_CPP_logical_OR_expression,CPP_literal_converts_to_bool)) goto RestartEval; if (eval_logical_AND(src,types,CPP_EvalParseTree,is_CPP_logical_AND_expression,CPP_literal_converts_to_bool)) goto RestartEval; if (eval_deref(src,types,CPP_EvalParseTree)) goto RestartEval; if (eval_logical_NOT(src,types,CPP_EvalParseTree,is_CPP_logical_NOT_expression,CPP_literal_converts_to_bool)) goto RestartEval; if (eval_unary_plus(src,types,CPP_EvalParseTree)) goto RestartEval; if (eval_unary_minus(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_mult_expression(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_div_expression(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_mod_expression(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_add_expression(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_sub_expression(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_shift(src,types,CPP_EvalParseTree,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_relation_expression(src,types,CPP_EvalParseTree,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_equality_expression(src,types,CPP_EvalParseTree,is_CPP_equality_expression,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_AND(src,types,CPP_EvalParseTree,is_CPP_bitwise_AND_expression,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_XOR(src,types,CPP_EvalParseTree,is_CPP_bitwise_XOR_expression,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_OR(src,types,CPP_EvalParseTree,is_CPP_bitwise_OR_expression,CPP_literal_converts_to_bool,CPP_intlike_literal_to_VM)) goto RestartEval; if (eval_bitwise_compl(src,types,CPP_EvalParseTree,is_CPP_bitwise_complement_expression,CPP_intlike_literal_to_VM)) goto RestartEval; return starting_errors==zcc_errors.err_count(); } //! \throw std::bad_alloc void C99_PPHackTree(parse_tree& src,const type_system& types) { if (parse_tree::INVALID & src.flags) return; if ( is_C99_unary_operator_expression<'-'>(src) && (PARSE_PRIMARY_EXPRESSION & src.data<2>()->flags)) { // compact - literal to literal to get past preprocessor src.eval_to_arg<2>(0); return; }; const type_spec old_type = src.type_code; const bool non_representable_int_min = virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps]; //! \todo handle other instances of non-representable int min constant expressions if (is_C99_add_operator_expression<'-'>(src)) { bool is_equal = false; if (C_string_literal_equal_content(*src.data<1>(),*src.data<2>(),is_equal)) { assert(!is_equal); // should have intercepted equal-literal reduction earlier #ifndef NDEBUG force_decimal_literal(src,"1",types); #else force_decimal_literal(src,is_equal ? "0" : "1",types); #endif src.type_code.set_type(C_TYPE::INT); return; }; if (non_representable_int_min) { umaxint res_int; umaxint rhs_int; const bool lhs_converted = C99_intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = C99_intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (lhs_converted && rhs_converted) { //! \todo deal with signed integer arithmetic const promote_aux old(old_type.base_type_index ARG_TYPES); assert(old.is_signed); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs #ifndef NDEBUG const bool lhs_negative = target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,old); #else target_machine->C_promote_integer(res_int,lhs,old); target_machine->C_promote_integer(rhs_int,rhs,old); #endif assert(lhs_negative && !rhs_negative); umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); target_machine->signed_additive_inverse(lhs_test,old.machine_type); ub += 1; assert(ub>=lhs_test && ub>=rhs_test); ub -= lhs_test; assert(ub>=rhs_test); lhs_test += rhs_test; assert(target_machine->signed_max(old.machine_type)<lhs_test); // ok...valid but won't reduce. pick an argument and mock this up src.eval_to_arg<2>(0); return; } } } if (src.type_code.decays_to_nonnull_pointer()) { force_decimal_literal(src,"1",types); src.type_code.set_type(C_TYPE::INT); return; } } //! \throw std::bad_alloc void CPP_PPHackTree(parse_tree& src,const type_system& types) { if (parse_tree::INVALID & src.flags) return; if ( is_C99_unary_operator_expression<'-'>(src) && (PARSE_PRIMARY_EXPRESSION & src.data<2>()->flags)) { // compact - literal to literal to get past preprocessor src.eval_to_arg<2>(0); return; }; const type_spec old_type = src.type_code; const bool non_representable_int_min = virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps]; //! \todo handle other instances of non-representable int min constant expressions if (is_C99_add_operator_expression<'-'>(src)) { bool is_equal = false; if (C_string_literal_equal_content(*src.data<1>(),*src.data<2>(),is_equal)) { assert(!is_equal); // should have intercepted equal-literal reduction earlier #ifndef NDEBUG force_decimal_literal(src,"1",types); #else force_decimal_literal(src,is_equal ? "0" : "1",types); #endif src.type_code.set_type(C_TYPE::INT); return; }; if (non_representable_int_min) { umaxint res_int; umaxint rhs_int; const bool lhs_converted = CPP_intlike_literal_to_VM(res_int,*src.data<1>() ARG_TYPES); const bool rhs_converted = CPP_intlike_literal_to_VM(rhs_int,*src.data<2>() ARG_TYPES); if (lhs_converted && rhs_converted) { //! \todo deal with signed integer arithmetic const promote_aux old(old_type.base_type_index ARG_TYPES); assert(old.is_signed); const promote_aux lhs(src.data<1>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=lhs.bitcount); const promote_aux rhs(src.data<2>()->type_code.base_type_index ARG_TYPES); assert(old.bitcount>=rhs.bitcount); // handle sign-extension of lhs, rhs #ifndef NDEBUG const bool lhs_negative = target_machine->C_promote_integer(res_int,lhs,old); const bool rhs_negative = target_machine->C_promote_integer(rhs_int,rhs,old); #else target_machine->C_promote_integer(res_int,lhs,old); target_machine->C_promote_integer(rhs_int,rhs,old); #endif assert(lhs_negative && !rhs_negative); umaxint lhs_test(res_int); umaxint rhs_test(rhs_int); umaxint ub(target_machine->signed_max(old.machine_type)); target_machine->signed_additive_inverse(lhs_test,old.machine_type); ub += 1; assert(ub>=lhs_test && ub>=rhs_test); ub -= lhs_test; assert(ub>=rhs_test); lhs_test += rhs_test; assert(target_machine->signed_max(old.machine_type)<lhs_test); // ok...valid but won't reduce. pick an argument and mock this up src.eval_to_arg<2>(0); return; } } } if (src.type_code.decays_to_nonnull_pointer()) { force_decimal_literal(src,"1",types); src.type_code.set_type(C_TYPE::INT); return; } } static void conserve_tokens(parse_tree& x) { if (x.own_index_token<0>()) { if (const char* const tmp = is_substring_registered(x.index_tokens[0].token.first,x.index_tokens[0].token.second)) { assert(tmp!=x.index_tokens[0].token.first); free(const_cast<char*>(x.index_tokens[0].token.first)); x.index_tokens[0].token.first = tmp; x.control_index_token<0>(false); } } if (x.own_index_token<1>()) { if (const char* const tmp = is_substring_registered(x.index_tokens[1].token.first,x.index_tokens[1].token.second)) { assert(tmp!=x.index_tokens[1].token.first); free(const_cast<char*>(x.index_tokens[1].token.first)); x.index_tokens[1].token.first = tmp; x.control_index_token<1>(false); } } } //! \todo really should be somewhere in natural-language output void INFORM_separated_list(const char* const* x,size_t x_len, const char* const sep) { assert(sep && *sep); assert(x); if (0<x_len) { INC_INFORM(*x); while(0< --x_len) { INC_INFORM(sep); INC_INFORM(*(++x)); } }; } //! \todo should this be a type_system member? //! \throw std::bad_alloc static bool check_for_typedef(type_spec& dest,const char* const src,const type_system& types) { const zaimoni::POD_triple<type_spec,const char*,size_t>* tmp = types.get_typedef(src); if (!tmp) return false; //! \todo C++: check for access control if source ends up being a class or struct value_copy(dest,tmp->first); return true; } //! \todo should this be a type_system member? //! \throw std::bad_alloc static bool check_for_typedef(type_spec& dest,const char* const src,const char* const active_namespace,const type_system& types) { const zaimoni::POD_triple<type_spec,const char*,size_t>* tmp = types.get_typedef_CPP(src,active_namespace); if (!tmp) return false; //! \todo C++: check for access control if source ends up being a class or struct value_copy(dest,tmp->first); return true; } //! \todo does this need to be in ParseTree.hpp? static size_t flush_token(parse_tree& x, const size_t i, const size_t n, const char* const target) { assert(x.size<0>()>i); assert(x.size<0>()-i>=n); size_t offset = 0; size_t j = 0; do if (robust_token_is_string(x.data<0>()[i+j],target)) ++offset; else if (0<offset) x.c_array<0>()[i+j-offset] = x.data<0>()[i+j]; while(n> ++j); if (0<offset) { j = offset; while(0<j) x.c_array<0>()[i+n- j--].clear(); x.DeleteNSlotsAt<0>(offset,i+n-offset); } return offset; } class C99_decl_specifier_scanner { private: size_t decl_count[CHAR_BIT*sizeof(uintmax_t)]; uintmax_t flags; type_spec base_type; const type_system& types; public: C99_decl_specifier_scanner(const type_system& _types) : flags(0),types(_types) { clear(decl_count); base_type.clear(); }; // trivial destructor, copy constructor, assignment fine //! \throw std::bad_alloc bool operator()(const parse_tree& x) { BOOST_STATIC_ASSERT(CHAR_BIT*sizeof(uintmax_t)>=STATIC_SIZE(C99_decl_specifiers)); if (!base_type.base_type_index && (PARSE_TYPE & x.flags)) { value_copy(base_type,x.type_code); return true; } if (!x.is_atomic()) return false; const errr Idx = linear_find(x.index_tokens[0].token.first,x.index_tokens[0].token.second,C99_decl_specifiers,STATIC_SIZE(C99_decl_specifiers)); if (0<=Idx) { flags |= (1ULL<<Idx); ++decl_count[Idx]; return true; }; // not a decl-specifier; bail out if we already have a type if (base_type.base_type_index) return false; // handle typedefs if ( !C99_echo_reserved_keyword(x.index_tokens[0].token.first,x.index_tokens[0].token.second) && (C_TESTFLAG_IDENTIFIER & x.index_tokens[0].flags)) return check_for_typedef(base_type,x.index_tokens[0].token.first,types); return false; }; bool analyze_flags_global(parse_tree& x, size_t i, size_t& decl_count) { assert(x.size<0>()>i); assert(x.size<0>()-i>=decl_count); if ((C99_CPP0X_DECLSPEC_TYPEDEF | C99_CPP0X_DECLSPEC_REGISTER | C99_CPP0X_DECLSPEC_STATIC | C99_CPP0X_DECLSPEC_EXTERN | C99_CPP0X_DECLSPEC_THREAD_LOCAL | C99_DECLSPEC_AUTO) & flags) { // storage class specifiers const char* specs[5]; unsigned int storage_count = 0; bool thread_local_compat = false; if (C99_CPP0X_DECLSPEC_TYPEDEF & flags) specs[storage_count++] = "typedef"; if (C99_CPP0X_DECLSPEC_STATIC & flags) specs[storage_count++] = "static"; if (C99_CPP0X_DECLSPEC_EXTERN & flags) specs[storage_count++] = "extern"; if (C99_CPP0X_DECLSPEC_THREAD_LOCAL & flags) { specs[storage_count++] = "_Thread_local"; thread_local_compat = ((C99_CPP0X_DECLSPEC_STATIC | C99_CPP0X_DECLSPEC_EXTERN) & flags); } if (C99_CPP0X_DECLSPEC_REGISTER & flags) { //! \test zcc/decl.C99/Error_register_global.h //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("storage-class specifier register disallowed at translation-unit level (C99 6.9p2)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"register"); flags &= ~C99_CPP0X_DECLSPEC_REGISTER; } if (C99_DECLSPEC_AUTO & flags) { //! \test zcc/decl.C99/Error_auto_global.h //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("storage-class specifier auto disallowed at translation-unit level (C99 6.9p2)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"auto"); flags &= ~C99_DECLSPEC_AUTO; }; // inline requires a function type // typedef must have a function type to tolerate anything (but kills inline) if (1<storage_count-thread_local_compat) { //! \test zcc/decl.C99/Error_extern_static.h //! \test zcc/decl.C99/Error_extern_typedef.h //! \test zcc/decl.C99/Error_static_typedef.h //! \test zcc/decl.C99/Error_extern_static_typedef.h message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("declaration has too many storage-class specifiers: "); INFORM_separated_list(specs,storage_count,", "); INFORM(" (C99 6.7.1p2)"); zcc_errors.inc_error(); return false; }; // return true; }; return true; } void fixup_type() { base_type.qualifier<0>() |= ((C99_CPP0X_DECLSPEC_CONST | C99_CPP0X_DECLSPEC_VOLATILE) & flags); }; uintmax_t get_flags() const {return flags;}; //! \throw std::bad_alloc void value_copy_type(type_spec& dest) const {value_copy(dest,base_type);}; const enum_def* is_enumeration() const {assert(0==base_type.pointer_power); return types.get_enum_def(base_type.base_type_index);}; bool is_type() const {return base_type.base_type_index;}; }; class CPP0X_decl_specifier_scanner { private: size_t decl_count[CHAR_BIT*sizeof(uintmax_t)]; uintmax_t flags; type_spec base_type; const type_system& types; // these two might belong in a koenig_lookup object const char* const active_namespace; public: CPP0X_decl_specifier_scanner(const type_system& _types,const char* const _active_namespace) : flags(0),types(_types),active_namespace(_active_namespace) { clear(decl_count); base_type.clear(); } // trivial destructor, copy constructor, assignment fine //! \throw std::bad_alloc bool operator()(parse_tree& x,const size_t i) { BOOST_STATIC_ASSERT(CHAR_BIT*sizeof(uintmax_t)>=STATIC_SIZE(CPP0X_decl_specifiers)); assert(x.size<0>()>i); if (!base_type.base_type_index && (PARSE_TYPE & x.data<0>()[i].flags)) { value_copy(base_type,x.data<0>()[i].type_code); return true; } if (!x.data<0>()[i].is_atomic()) return false; const errr Idx = linear_find(x.data<0>()[i].index_tokens[0].token.first,x.data<0>()[i].index_tokens[0].token.second,CPP0X_decl_specifiers,STATIC_SIZE(CPP0X_decl_specifiers)); if (0<=Idx) { flags |= (1ULL<<Idx); ++decl_count[Idx]; return true; }; // not a decl-specifier; bail out if we already have a type if (base_type.base_type_index) return false; // handle typedefs // determine what fully-qualified name would be if ( !CPP_echo_reserved_keyword(x.data<0>()[i].index_tokens[0].token.first,x.data<0>()[i].index_tokens[0].token.second) && (C_TESTFLAG_IDENTIFIER & x.data<0>()[i].index_tokens[0].flags)) // shove Koenig lookup into type_system return check_for_typedef(base_type,x.data<0>()[i].index_tokens[0].token.first,active_namespace,types); return false; }; bool analyze_flags_global(parse_tree& x, size_t i, size_t& decl_count) { assert(x.size<0>()>i); assert(x.size<0>()-i>=decl_count); if ((C99_CPP0X_DECLSPEC_TYPEDEF | C99_CPP0X_DECLSPEC_REGISTER | C99_CPP0X_DECLSPEC_STATIC | C99_CPP0X_DECLSPEC_EXTERN | C99_CPP0X_DECLSPEC_THREAD_LOCAL | CPP_DECLSPEC_MUTABLE | CPP_DECLSPEC_VIRTUAL | CPP_DECLSPEC_EXPLICIT | CPP_DECLSPEC_FRIEND) & flags) { // storage class specifiers const char* specs[5]; unsigned int storage_count = 0; bool thread_local_compat = false; if (C99_CPP0X_DECLSPEC_TYPEDEF & flags) specs[storage_count++] = "typedef"; if (C99_CPP0X_DECLSPEC_STATIC & flags) specs[storage_count++] = "static"; if (C99_CPP0X_DECLSPEC_EXTERN & flags) specs[storage_count++] = "extern"; // thread_local ok at namespace scope for objects/references if (C99_CPP0X_DECLSPEC_THREAD_LOCAL & flags) { specs[storage_count++] = "thread_local"; thread_local_compat = ((C99_CPP0X_DECLSPEC_STATIC | C99_CPP0X_DECLSPEC_EXTERN) & flags); } if (C99_CPP0X_DECLSPEC_REGISTER & flags) { //! \test zcc/default/decl.C99/Error_register_global.hpp //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("storage-class specifier register allowed only to objects named in a block, or function parameters (C++98 7.1.1p2)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"register"); flags &= ~C99_CPP0X_DECLSPEC_REGISTER; } if (CPP_DECLSPEC_MUTABLE & flags) { //! \test zcc/default/decl.C99/Error_mutable_global.hpp //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("storage-class specifier mutable only allowed for non-static non-const non-reference class data members (C++0X 7.1.1p10)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"mutable"); flags &= ~CPP_DECLSPEC_MUTABLE; }; // virtual and explicit can only be used in class declarations: erase (C++0X 7.1.2p5, 7.1.2p6 if (CPP_DECLSPEC_VIRTUAL & flags) { //! \test zcc/default/decl.C99/Error_virtual_global.hpp //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("function specifier virtual allowed only for class member functions (C++98 7.1.2p5)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"virtual"); flags &= ~CPP_DECLSPEC_VIRTUAL; }; if (CPP_DECLSPEC_EXPLICIT & flags) { //! \test zcc/default/decl.C99/Error_explicit_global.hpp //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("function specifier explicit allowed only for constructors (C++98 7.1.2p6)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"explicit"); flags &= ~CPP_DECLSPEC_EXPLICIT; }; // friend is only usable within a class if (CPP_DECLSPEC_FRIEND & flags) { //! \test zcc/default/decl.C99/Error_friend_global.hpp //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("decl-specifier friend only useful within a class definition (C++98 7.1.4)"); zcc_errors.inc_error(); decl_count -= flush_token(x,i,decl_count,"friend"); flags &= ~CPP_DECLSPEC_FRIEND; }; if (1<storage_count-thread_local_compat) { //! \test zcc/decl.C99/Error_extern_static.hpp //! \test zcc/decl.C99/Error_extern_typedef.hpp //! \test zcc/decl.C99/Error_static_typedef.hpp //! \test zcc/decl.C99/Error_extern_static_typedef.hpp //! \todo should be warning for --do-what-i-mean message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("declaration has too many storage-class specifiers: "); INFORM_separated_list(specs,storage_count,", "); INFORM(" (C++0X 7.1.1p1)"); zcc_errors.inc_error(); return false; } // inline dies if not a function type // typedef must have a function type to tolerate anything (but kills inline) // return true; }; return true; }; void fixup_type() { base_type.qualifier<0>() |= ((C99_CPP0X_DECLSPEC_CONST | C99_CPP0X_DECLSPEC_VOLATILE) & flags); }; uintmax_t get_flags() const {return flags;}; //! \throw std::bad_alloc void value_copy_type(type_spec& dest) const {value_copy(dest,base_type);}; const enum_def* is_enumeration() const {assert(0==base_type.pointer_power); return types.get_enum_def(base_type.base_type_index);}; bool is_type() const {return base_type.base_type_index;}; }; static size_t C99_cv_qualifier_span(parse_tree& x, size_t i,type_spec& target_type) { unsigned int warn_queue = 0; size_t ub = 0; if (x.size<0>()>i) { do { if (robust_token_is_string<5>(x.data<0>()[i+ub],"const")) { //! \bug need test cases if (target_type.q_vector.back() & type_spec::_const) { warn_queue |= type_spec::_const; // optimize source x.DeleteIdx<0>(i+ub); continue; } target_type.q_vector.back() |= type_spec::_const; } else if (robust_token_is_string<8>(x.data<0>()[i+ub],"volatile")) { //! \bug need test cases if (target_type.q_vector.back() & type_spec::_volatile) { warn_queue |= type_spec::_volatile; // optimize source x.DeleteIdx<0>(i+ub); continue; } target_type.q_vector.back() |= type_spec::_volatile; } else if (robust_token_is_string<8>(x.data<0>()[i+ub],"restrict")) { //! \bug need test cases if (target_type.q_vector.back() & type_spec::_restrict) { warn_queue |= type_spec::_restrict; // optimize source x.DeleteIdx<0>(i+ub); continue; } target_type.q_vector.back() |= type_spec::_restrict; } else break; } while(x.size<0>()>i+ ++ub); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \todo should this be a context-free check? if (warn_queue) { //! \bug need test cases message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("duplicate type qualifiers have no effect (C99 6.7.3p4)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); } } return ub; } /* C99 6.7.5p1, C1X 6.7.6p1 pointer: * type-qualifier-listopt * type-qualifier-listopt pointer */ static size_t C99_recognize_pointerlike_declarator_section(parse_tree& x, size_t i,type_spec& target_type) { assert(x.size<0>()>i); size_t ub = 0; while(robust_token_is_char<'*'>(x.data<0>()[i+ub])) { target_type.make_C_pointer(); ++ub; ub += C99_cv_qualifier_span(x,i+ub,target_type); } return ub; } // forward-declare for recursive definition static size_t C99_init_declarator_scanner(parse_tree& x, size_t i,type_spec& target_type, parse_tree*& initdecl_identifier); /* C99 6.7.5p1, C1X 6.7.6p1 direct-declarator: identifier ( declarator ) direct-declarator [ type-qualifier-listopt assignment-expressionopt ] direct-declarator [ static type-qualifier-listopt assignment-expression ] direct-declarator [ type-qualifier-list static assignment-expression ] direct-declarator [ type-qualifier-listopt * ] direct-declarator ( parameter-type-list ) direct-declarator ( identifier-listopt ) */ static size_t C99_recognize_direct_declaratorlike_section(parse_tree& x, size_t i,type_spec& target_type, parse_tree*& initdecl_identifier) { assert(x.size<0>()>i); assert(!initdecl_identifier); size_t ub = 0; if ( x.data<0>()[i].is_atomic() && (C_TESTFLAG_IDENTIFIER & x.data<0>()[i].index_tokens[0].flags) && !(PARSE_TYPE & x.data<0>()[i].flags) // internal representation could land some types here, especially primary types && !C99_echo_reserved_keyword(x.data<0>()[i].index_tokens[0].token.first,x.data<0>()[i].index_tokens[0].token.second)) { // identifier counts ub = 1; initdecl_identifier = x.c_array<0>()+i; } else if (is_naked_parentheses_pair(x.data<0>()[i])) { const size_t content_length = x.size<0>(); if (0<content_length && content_length==C99_init_declarator_scanner(x.c_array<0>()[i],0,target_type,initdecl_identifier)) ub = 1; } if (0<ub) { while(i+ub<x.size<0>()) { if (is_naked_bracket_pair(x.data<0>()[i+ub])) { // we'll catch the array size, etc. later if (target_type.is_function()) target_type.make_C_array(0); ++ub; continue; } else if (is_naked_parentheses_pair(x.data<0>()[i+ub])) { // handle the prototype later target_type.set_function(); ++ub; continue; } break; } } return ub; } /* declarator: pointeropt direct-declarator */ static size_t C99_init_declarator_scanner(parse_tree& x, size_t i,type_spec& target_type, parse_tree*& initdecl_identifier) { assert(x.size<0>()>i); assert(!initdecl_identifier); const size_t ptr_like = C99_recognize_pointerlike_declarator_section(x,i,target_type); if (x.size<0>()-i <= ptr_like) return 0; const size_t direct_decl_like = C99_recognize_direct_declaratorlike_section(x,i+ptr_like,target_type,initdecl_identifier); if (0<direct_decl_like) return ptr_like+direct_decl_like; return 0; } // very basic syntax check; defer real parsing to later static bool is_CPP0X_attribute(const parse_tree& x) { return is_naked_bracket_pair(x) && 1==x.size<0>() && is_naked_bracket_pair(*x.data<0>()); } static bool is_CPP0X_ref_qualifier(const parse_tree& x) { return robust_token_is_char<'&'>(x) || robust_token_is_string<2>(x,"&&"); } // very basic syntax check; defer real parsing to later static size_t is_CPP0X_exception_specification_here(const parse_tree& x,size_t i) { if (x.size<0>()>i) { const bool have_parens = 1<x.size<0>()-i && is_naked_parentheses_pair(x.data<0>()[i+1]); if (robust_token_is_string<8>(x,"noexcept")) return 1+have_parens; if (have_parens && robust_token_is_string<5>(x,"throw")) return 2; } return 0; } static size_t CPP_cv_qualifier_span(parse_tree& x, size_t i,type_spec& target_type) { unsigned int warn_queue = 0; size_t ub = 0; if (x.size<0>()>i) { do { if (robust_token_is_string<5>(x.data<0>()[i+ub],"const")) { //! \bug need test cases if (target_type.q_vector.back() & type_spec::_const) { warn_queue |= type_spec::_const; // optimize source x.DeleteIdx<0>(i+ub); continue; } target_type.q_vector.back() |= type_spec::_const; } else if (robust_token_is_string<8>(x.data<0>()[i+ub],"volatile")) { //! \bug need test cases if (target_type.q_vector.back() & type_spec::_volatile) { warn_queue |= type_spec::_volatile; // optimize source x.DeleteIdx<0>(i+ub); continue; } target_type.q_vector.back() |= type_spec::_volatile; } else break; } while(x.size<0>()>i+ ++ub); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \todo should this be a context-free check? if (warn_queue) { //! \bug need test cases message_header(x.data<0>()[i].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("duplicate type qualifiers have no effect (C++0X 7.1.6.1p1)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); } } return ub; } /* C++0X 8p4 ptr-operator: * attribute-specifieropt cv-qualifier-seqopt & attribute-specifieropt && attribute-specifieropt ::opt nested-name-specifier * attribute-specifieropt cv-qualifier-seqopt*/ static size_t CPP_recognize_pointerlike_declarator_section(parse_tree& x, size_t i,type_spec& target_type) { assert(x.size<0>()>i); size_t ub = 0; // handle C-like case while(robust_token_is_char<'*'>(x.data<0>()[i+ub])) { target_type.make_C_pointer(); ++ub; //! \todo would check for attributes here ub += CPP_cv_qualifier_span(x,i+ub,target_type); } return ub; } // forward-declaration for recursive definition static size_t CPP_init_declarator_scanner(parse_tree& x, size_t i,type_spec& target_type, parse_tree*& initdecl_identifier); /* noptr-declarator: declarator-id attribute-specifieropt noptr-declarator parameters-and-qualifiers noptr-declarator [ constant-expressionopt ] attribute-specifieropt ( ptr-declarator ) */ static size_t CPP_recognize_noptr_declaratorlike_section(parse_tree& x, size_t i,type_spec& target_type, parse_tree*& initdecl_identifier) { assert(x.size<0>()>i); bool local_identifier = false; size_t ub = 0; if ( x.data<0>()[i].is_atomic() && (C_TESTFLAG_IDENTIFIER & x.data<0>()[i].index_tokens[0].flags) && !(PARSE_TYPE & x.data<0>()[i].flags) // internal representation could land some types here, especially primary types && !CPP_echo_reserved_keyword(x.data<0>()[i].index_tokens[0].token.first,x.data<0>()[i].index_tokens[0].token.second)) { // identifier counts ub = 1; initdecl_identifier = x.c_array<0>()+i; if (x.size<0>()-i>ub) ub += is_CPP0X_attribute(x.data<0>()[i+ub]); local_identifier = true; } else if (is_naked_parentheses_pair(x.data<0>()[i])) { const size_t content_length = x.size<0>(); if (0<content_length && content_length==CPP_init_declarator_scanner(x.c_array<0>()[i],0,target_type,initdecl_identifier)) ub = 1; } if (0<ub) { while(x.size<0>()-i>ub) { if (is_naked_bracket_pair(x.data<0>()[i+ub])) { // we'll catch the array size, etc. later if (!target_type.is_function()) target_type.make_C_array(0); ++ub; if (x.size<0>()-i>ub) ub += is_CPP0X_attribute(x.data<0>()[i+ub]); continue; } else if (is_naked_parentheses_pair(x.data<0>()[i+ub])) { // handle the prototype later target_type.set_function(); ++ub; if (x.size<0>()-i>ub) ub += is_CPP0X_attribute(x.data<0>()[i+ub]); if (x.size<0>()-i>ub) ub += CPP_cv_qualifier_span(x,i+ub,target_type); if (x.size<0>()-i>ub) ub += is_CPP0X_ref_qualifier(x.c_array<0>()[i+ub]); if (x.size<0>()-i>ub) ub += is_CPP0X_exception_specification_here(x,i+ub); // regenerate the initdecl_identifier if we have it if (local_identifier) initdecl_identifier = x.c_array<0>()+i; continue; } break; } } return ub; } /* declarator: ptr-declarator noptr-declarator parameters-and-qualifiers trailing-return-type ptr-declarator: noptr-declarator ptr-operator ptr-declarator */ static size_t CPP_init_declarator_scanner(parse_tree& x, size_t i,type_spec& target_type, parse_tree*& initdecl_identifier) { assert(x.size<0>()>i); const size_t ptr_like = CPP_recognize_pointerlike_declarator_section(x,i,target_type); if (x.size<0>()-i <= ptr_like) return 0; const size_t noptr_like = CPP_recognize_noptr_declaratorlike_section(x,i+ptr_like,target_type,initdecl_identifier); if (0<noptr_like) { if (0<ptr_like) return ptr_like+noptr_like; //! \todo handle rest of other case return noptr_like; } return 0; } static size_t span_to_semicolon(const parse_tree* const first,const parse_tree* const last) { assert(first); assert(last); const parse_tree* iter = first; while(iter!=last && !robust_token_is_char<';'>(*iter)) ++iter; return iter-first; } #if 0 static bool is_identifier_list(const parse_tree& src,func_traits<const char* (*)(const char* x,size_t x_len)>::function_ref_type EchoReservedKeyword) { assert(!src.empty()); size_t j = src.size<0>(); if (!(j%2)) return false; const parse_tree* const x = src.data<0>(); assert(x); do { if (!x[--j].is_atomic()) return false; if (0==j%2) { // identifier needed if ( C_TESTFLAG_IDENTIFIER!=x[j].index_tokens[0].flags // must be identifier || (PARSE_TYPE & x[j].flags) // internal representation could land some types here, especially primary types || EchoReservedKeyword(x[j].index_tokens[0].token.first,x[j].index_tokens[0].token.second)) // keywords are only lexically identifiers, they'll cause problems return false; } else{ // comma needed if (!token_is_char<','>(x[j].index_tokens[0].token)) return false; } } while(0<j); return true; } #endif static void notice_enumerator_CPP(parse_tree& x,const type_system& types,const char* const active_namespace) { if (x.is_atomic() && (C_TESTFLAG_IDENTIFIER & x.index_tokens[0].flags)) { const type_system::enumerator_info* const tmp = types.get_enumerator_CPP(x.index_tokens[0].token.first,active_namespace); if (tmp) { x.set_index_token_from_str_literal<0>(tmp->first); x.type_code.set_type(tmp->second.first.first); x.flags |= PARSE_PRIMARY_EXPRESSION; // XXX would be handy to keep the tmp around, consider as time optimization XXX } } size_t i = x.size<0>(); while(0<i) notice_enumerator_CPP(x.c_array<0>()[--i],types,active_namespace); assert(x.empty<1>()); // expand these into loops if needed assert(x.empty<2>()); } //! \throw std::bad_alloc() static void C99_CPP_handle_static_assertion(parse_tree& src,PP_auxfunc& langinfo,const size_t i,const char* const err,const char* const active_namespace) { assert(err && *err); assert(src.size<0>()>i); // find the next ';' const parse_tree* const origin = src.data<0>()+i; const size_t j = i+span_to_semicolon(origin,src.end<0>()); if (src.size<0>()<=j) { //! \test zcc/staticassert.C99/Error_scope1.h, zcc/staticassert.C99/Error_scope1.hpp //! \test zcc/staticassert.C99/Error_scope2.h, zcc/staticassert.C99/Error_scope2.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("static assertion cut off by end of scope"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i,i); return; }; if ( !is_naked_parentheses_pair(origin[1]) || 3>origin[1].size<0>() || !robust_token_is_char<','>(origin[1].data<0>()[origin[1].size<0>()-2]) || !origin[1].data<0>()[origin[1].size<0>()-1].is_atomic() || C_TESTFLAG_STRING_LITERAL!=origin[1].data<0>()[origin[1].size<0>()-1].index_tokens[0].flags) { //! \test zcc/staticassert.C99/Error_badarg1.h, zcc/staticassert.C99/Error_badarg1.hpp //! \test zcc/staticassert.C99/Error_badarg2.h, zcc/staticassert.C99/Error_badarg2.hpp //! \test zcc/staticassert.C99/Error_badarg3.h, zcc/staticassert.C99/Error_badarg3.hpp //! \test zcc/staticassert.C99/Error_badarg5.h, zcc/staticassert.C99/Error_badarg5.hpp //! \test zcc/staticassert.C99/Error_badarg6.h, zcc/staticassert.C99/Error_badarg6.hpp //! \test zcc/staticassert.C99/Error_badarg7.h, zcc/staticassert.C99/Error_badarg7.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("malformed static assertion"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; }; if (2!=j-i) { //! \test zcc/staticassert.C99/Error_badarg4.h, zcc/staticassert.C99/Error_badarg4.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("garbage between static assertion arguments and terminating ;"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; }; // actually use the static assertion correctly. parse_tree_class parsetree; { const size_t k = origin[1].size<0>()-2; if (!parsetree.resize<0>(k)) { message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); _fatal("insufficient RAM to parse static assertion"); }; zaimoni::autotransform_n<void (*)(parse_tree&,const parse_tree&)>(parsetree.c_array<0>(),origin[1].data<0>(),k,value_copy); // type all enumerators now to make life reasonable later on for the expression-parser size_t enum_scan = k; do notice_enumerator_CPP(parsetree.c_array<0>()[--enum_scan],*parse_tree::types,active_namespace); while(0<enum_scan); } // init above correctly // snip from Condense const size_t starting_errors = zcc_errors.err_count(); (langinfo.LocateExpression)(parsetree,SIZE_MAX,*parse_tree::types); if (starting_errors==zcc_errors.err_count()) { while(parsetree.is_raw_list() && 1==parsetree.size<0>()) parsetree.eval_to_arg<0>(0); // end snip from Condense // snip from CPreproc if (!parsetree.is_atomic() && !(langinfo.EvalParseTree)(parsetree,*parse_tree::types)) { parsetree.destroy(); // efficiency message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM(err); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; } (langinfo.PPHackTree)(parsetree,*parse_tree::types); // final, when above is working properly if (!parsetree.is_atomic()) { //! \bug need test cases parsetree.destroy(); // efficiency message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM(err); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; } // end snip from CPreproc // handle top-level enumerators if (is_noticed_enumerator(parsetree,*parse_tree::types)) enumerator_to_integer_representation(parsetree,*parse_tree::types); bool is_true = false; if (!(langinfo.LiteralConvertsToBool)(parsetree,is_true,*parse_tree::types)) { //! \bug need test cases parsetree.destroy(); // efficiency message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM(err); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; }; parsetree.destroy(); // efficiency //! \test zcc/staticassert.C1X/Pass_autosucceed.h, zcc/staticassert.C1X/Pass_autosucceed.hpp if (!is_true) { //! \test zcc/staticassert.C1X/Error_autofail.h, zcc/staticassert.C1X/Error_autofail.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); // hmm...really should unescape string before emitting const size_t tmp_size = LengthOfCStringLiteral(origin[1].data<0>()[origin[1].size<0>()-1].index_tokens[0].token.first,origin[1].data<0>()[origin[1].size<0>()-1].index_tokens[0].token.second); if (1U>=tmp_size || 'L'== *origin[1].data<0>()[origin[1].size<0>()-1].index_tokens[0].token.first) { //! \todo handle wide-strings later INFORM("(static assertion failure)"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; }; char* tmp = _new_buffer<char>(tmp_size); if (!tmp) { INFORM("(static assertion failure)"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; } UnescapeCString(tmp,origin[1].data<0>()[origin[1].size<0>()-1].index_tokens[0].token.first+1,origin[1].data<0>()[origin[1].size<0>()-1].index_tokens[0].token.second-2); INFORM(tmp); free(tmp); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(j-i+1,i); return; }; } src.DeleteNSlotsAt<0>(j-i+1,i); } static bool default_enumerator_init_legal(const bool allow_empty, unsigned char& current_enumerator_type, const unsigned_var_int& prior_value, const weak_token& src, const type_system& types) { if (allow_empty) { // C++ //! \todo research how to rewrite this without the goto cpp_enum_was_retyped: const promote_aux test(current_enumerator_type,types); // -Wc-c++-compat trips: C++ tolerates enumerator values that don't fit in int if (bool_options[boolopt::warn_crosslang_compatibility] && C_TYPE::INT==current_enumerator_type && prior_value==target_machine->signed_max(test.machine_type)) { //! \test compat/Warn_enum_overflow.hpp message_header(src); INC_INFORM(WARN_STR); INFORM("enumerator value not representable by int is an error in C (C99 6.7.2.2p3)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); }; if (test.is_signed) { if (prior_value==target_machine->signed_max(test.machine_type)) { ++current_enumerator_type; // smallest type that can handle this goto cpp_enum_was_retyped; } } else if (prior_value==target_machine->unsigned_max(test.machine_type)) { if (C_TYPE::INTEGERLIKE == ++current_enumerator_type) // smallest type that can handle this { // unsigned long long overflow, fact it's defined doesn't save us //! \test decl.C99/Error_enum_overflow.hpp message_header(src); INC_INFORM(ERR_STR); INFORM("default-initialization of enumerator requires uintmax_t overflow (C++0X 7.2p5)"); zcc_errors.inc_error(); return false; } goto cpp_enum_was_retyped; } } // C else if (prior_value==target_machine->signed_max<virtual_machine::std_int_int>()) { // signed integer overflow //! \test decl.C99/Error_enum_overflow.h message_header(src); INC_INFORM(ERR_STR); INFORM("default-initialization of enumerator requires signed int overflow (C99 6.7.2.2p3)"); zcc_errors.inc_error(); return false; } return true; } //! \throw std::bad_alloc static bool record_enum_values(parse_tree& src, const type_system::type_index enum_type_index, const char* const active_namespace,bool allow_empty,func_traits<const char* (*)(const char*, size_t)>::function_ref_type echo_reserved_keyword, intlike_literal_to_VM_func& intlike_literal_to_VM, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type CondenseParseTree, func_traits<bool (*)(parse_tree&,const type_system&)>::function_ref_type EvalParseTree) { assert(enum_type_index); assert(!active_namespace || *active_namespace); assert(is_naked_brace_pair(src)); // enumeration idea: // * identifer [= ...] , // terminal , is optional (and in fact should trigger a warning for -Wbackport) // empty collection of enumerators is fine for C++, rejected by C (should be error in C and -Wc-c++-compat for C++) // XXX use allow_empty to signal C vs. C++ language // values would be unsigned_var_int if (src.empty<0>()) { if (!allow_empty) { //! \test zcc/decl.C99/Error_enum_empty.h message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumeration has no enumerators (C99 6.7.2.2p1)"); zcc_errors.inc_error(); return false; } else if (bool_options[boolopt::warn_crosslang_compatibility]) { //! \test zcc/compat/Warn_enum_empty.hpp message_header(src.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("enumeration with no enumerators is an error in C90/C99/C1X"); if (bool_options[boolopt::warnings_are_errors]) { zcc_errors.inc_error(); return false; } } //! \test zcc/decl.C99/Pass_enum_empty.hpp return true; }; // determine if format generally there // stage 1: top-level comma check // * terminal comma is optional, zap it and warn if -Wbackport // * one more enumerator possible than surviving commas; use this to construct buffers size_t i = 0; while(src.size<0>()>i) { // require identifier that is neither keyword nor a primitive type // C++ will have problems with enum/struct/class/union names, verify status of both of these (could be -Wc-c++-compat issue if legal in C) // if identifier, verify next is = or , // if next is =, locate comma afterwards (do not do expression parsing yet) //! \todo: enforce One Definition Rule for C++ vs types; determine how much of the effect is in C as well if ( !src.data<0>()[i].is_atomic() || C_TESTFLAG_IDENTIFIER!=src.data<0>()[i].index_tokens[0].flags || (PARSE_TYPE & src.data<0>()[i].flags) || echo_reserved_keyword(src.data<0>()[i].index_tokens[0].token.first,src.data<0>()[i].index_tokens[0].token.second)) { //! \test zcc/decl.C99/Error_enum_brace.h, zcc/decl.C99/Error_enum_brace.hpp //! \test zcc/decl.C99/Error_enum_symbol.h, zcc/decl.C99/Error_enum_symbol.hpp //! \test zcc/decl.C99/Error_enum_type.h, zcc/decl.C99/Error_enum_type.hpp //! \test zcc/decl.C99/Error_enum_keyword.h, zcc/decl.C99/Error_enum_keyword.hpp message_header(0==i ? src.index_tokens[0] : src.data<0>()[i-i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("non-keyword identifier expected as enumerator (C99 6.4.4.3p1/C++0X 7.2p1)"); zcc_errors.inc_error(); return false; } if (1>=src.size<0>()-i) break; // fine, would default-update if (robust_token_is_char<','>(src.data<0>()[i+1])) { // would default-update i += 2; continue; }; if (!robust_token_is_char<'='>(src.data<0>()[i+1])) { //! \test zcc/decl.C99/Error_enum_no_init.h, zcc/decl.C99/Error_enum_no_init.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator neither explicitly initialized nor default-initialized (C99 6.4.4.3p1/C++0X 7.2p1)"); zcc_errors.inc_error(); return false; }; i += 2; if (src.size<0>()<=i || robust_token_is_char<','>(src.data<0>()[i])) { //! \test zcc/decl.C99/Error_enum_init_truncated.h, zcc/decl.C99/Error_enum_init_truncated.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator initializer cut off by , (C99 6.4.4.3p1/C++0X 7.2p1)"); zcc_errors.inc_error(); return false; }; while(++i < src.size<0>()) { if (robust_token_is_char<','>(src.data<0>()[i])) { ++i; break; } }; } if (robust_token_is_char<','>(src.back<0>())) { // warn for -Wbackport //! \test zcc/decl.C99/Pass_enum_trailing_comma.h, zcc/decl.C99/Pass_enum_trailing_comma.hpp //! \test zcc/backport/Warn_enum_trailing_comma.h, zcc/backport/Warn_enum_trailing_comma.hpp if (bool_options[boolopt::warn_backport]) { message_header(src.back<0>().index_tokens[0]); INC_INFORM(WARN_STR); INFORM("trailing , in enumeration definition would be an error in C90/C++98"); if (bool_options[boolopt::warnings_are_errors]) { zcc_errors.inc_error(); return false; } } src.DeleteIdx<0>(src.size<0>()-1); // clean up anyway } //! \todo actually record enumerator matchings unsigned_var_int latest_value(0,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); unsigned_var_int prior_value(0,unsigned_var_int::bytes_from_bits(VM_MAX_BIT_PLATFORM)); unsigned char current_enumerator_type = C_TYPE::INT; unsigned char base_enum_type = C_TYPE::INT; bool cpp_using_negative = false; i = 0; while(src.size<0>()>i) { // require identifier that is neither keyword nor a primitive type // C++ will have problems with enum/struct/class/union names, verify status of both of these (could be -Wc-c++-compat issue if legal in C) // if identifier, verify next is = or , // if next is =, locate comma afterwards (do not do expression parsing yet) //! \todo: enforce One Definition Rule for C++ vs types; determine how much of the effect is in C as well assert(src.data<0>()[i].is_atomic()); assert(C_TESTFLAG_IDENTIFIER==src.data<0>()[i].index_tokens[0].flags); assert(!(PARSE_TYPE & src.data<0>()[i].flags)); assert(!echo_reserved_keyword(src.data<0>()[i].index_tokens[0].token.first,src.data<0>()[i].index_tokens[0].token.second)); { char* const namespace_name = active_namespace ? type_system::namespace_concatenate(src.data<0>()[i].index_tokens[0].token.first,active_namespace,"::") : NULL; const char* const fullname = namespace_name ? namespace_name : src.data<0>()[i].index_tokens[0].token.first; if (const type_system::enumerator_info* const fatal_def = parse_tree::types->get_enumerator(fullname)) { // --do-what-i-mean could recover if the prior definition were identical // C: note on C99/C1X 6.7.2.2p3 indicates autofail no matter where it was defined (but scope matters) // C++: One Definition Rule wipes out //! \test decl.C99/Error_enum_multidef.h, decl.C99/Error_enum_multidef.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator is already defined (C99 6.7.2.2p3/C++98 3.2)"); message_header(fatal_def->second.second); INFORM("prior definition here"); zcc_errors.inc_error(); return false; }; #if 0 // next proposed function call is a bit handwavish right now... // C++0X 3.3.1p4: enumerator gets to hide class names and enum names, nothing else [in particular dies against typedefs and functions] // C1X: enumerators are not in the same tag space as enumerations, structs, or unions: no conflict possible if (parse_tree::types->enum_already_defined(active_namespace,src.data<0>()[i].index_tokens[0].token.first)) { // -Wbackport warn in C++, fail in C if (allow_empty) { // C++0X if (bool_options[boolopt::warn_crosslang_compatibility] || bool_options[boolopt::warn_backport]) { message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("enum with same name as enumerator is already defined (C99 6.7.2.2p3/C++98 3.2/C++0X 3.2)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); } } }; if (parse_tree::types->union_class_struct_already_declared(active_namespace,src.data<0>()[i].index_tokens[0].token.first)) { // -Wbackport warn in C++, fail in C if (allow_empty) { // C++0X if (bool_options[boolopt::warn_crosslang_compatibility] || bool_options[boolopt::warn_backport]) { message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(WARN_STR); INFORM("union, struct, or class with same name as enumerator is already defined (C99 6.7.2.2p3/C++98 3.2/C++0X 3.2)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); } } }; if (parse_tree::types->function_already_declared(active_namespace,src.data<0>()[i].index_tokens[0].token.first)) { // C++: One Definition Rule }; #endif if (const zaimoni::POD_triple<type_spec,const char*,size_t>* const tmp = parse_tree::types->get_typedef(fullname)) { // C++: One Definition Rule //! \test decl.C99/Error_enum_typedef.h, decl.C99/Error_enum_typedef.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("typedef is already defined, conflicts with enumerator (C99 6.7.2.2p3/C++98 3.2)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": typedef definition here"); zcc_errors.inc_error(); return false; }; if (const type_system::object_type_loc_linkage* const tmp = parse_tree::types->get_object(fullname)) { // C++: One Definition Rule //! \bug needs test cases message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("object/function is already declared/defined, conflicts with enumerator (C99 6.7.2.2p3/C++0X 3.3.10p2)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": object/function declaration/definition here"); zcc_errors.inc_error(); return false; }; free(namespace_name); } // The type and representation of an enumeration varies by language // C: values are type int; actual representation can be decided after seeing all enumeration values. // C++: if the underlying type is fixed, then the enumerator is of that type. Othewise, // each enumerator has the same type as its initializing expression, and the underlying type of // the enumeration is large enough to represent all values. // So, for the default-update cases // C: type int, hard-error if going above INT_MAX // C++: type per language specification, // * hard-error if going above ULONG_MAX // * invoke -Wc-c++-compat if not within INT_MIN..INT_MAX // in any case, do not react if the default-init isn't used value_copy(prior_value,latest_value); { bool value_is_nonnegative = true; const promote_aux test(current_enumerator_type,*parse_tree::types); if (test.is_signed && latest_value.test(test.bitcount-1)) { target_machine->signed_additive_inverse(latest_value,test.machine_type); if (0<latest_value) { latest_value -= 1; if (0<latest_value) target_machine->signed_additive_inverse(latest_value,test.machine_type); value_is_nonnegative = false; } } if (value_is_nonnegative) latest_value += 1; } if (1>=src.size<0>()-i) { // default-update // handle type errors if (!default_enumerator_init_legal(allow_empty,current_enumerator_type,prior_value,src.data<0>()[i].index_tokens[0],*parse_tree::types)) return false; uchar_blob latest_value_copy; latest_value_copy.init(0); value_copy(latest_value_copy,latest_value); if (active_namespace) parse_tree::types->set_enumerator_def_CPP(src.data<0>()[i].index_tokens[0].token.first, active_namespace,src.data<0>()[i].index_tokens[0].logical_line,src.data<0>()[i].index_tokens[0].src_filename,current_enumerator_type,latest_value_copy,enum_type_index); else parse_tree::types->set_enumerator_def(src.data<0>()[i].index_tokens[0].token.first,src.data<0>()[i].index_tokens[0].logical_line,src.data<0>()[i].index_tokens[0].src_filename,current_enumerator_type,latest_value_copy,enum_type_index); break; } // complete conversion // C: type int, hard-error if not within INT_MIN..INT_MAX // C++: type per language specification // * invoke -Wc-c++-compat if not within INT_MIN..INT_MAX if (robust_token_is_char<','>(src.data<0>()[i+1])) { // would default-update if (!default_enumerator_init_legal(allow_empty,current_enumerator_type,prior_value,src.data<0>()[i].index_tokens[0],*parse_tree::types)) return false; uchar_blob latest_value_copy; latest_value_copy.init(0); value_copy(latest_value_copy,latest_value); if (active_namespace) parse_tree::types->set_enumerator_def_CPP(src.data<0>()[i].index_tokens[0].token.first, active_namespace,src.data<0>()[i].index_tokens[0].logical_line,src.data<0>()[i].index_tokens[0].src_filename,current_enumerator_type,latest_value_copy,enum_type_index); else parse_tree::types->set_enumerator_def(src.data<0>()[i].index_tokens[0].token.first,src.data<0>()[i].index_tokens[0].logical_line,src.data<0>()[i].index_tokens[0].src_filename,current_enumerator_type,latest_value_copy,enum_type_index); i += 2; continue; }; assert(robust_token_is_char<'='>(src.data<0>()[i+1])); i += 2; const size_t origin = i; assert(src.size<0>()>i && !robust_token_is_char<','>(src.data<0>()[i])); bool comma_overextended = false; while(++i < src.size<0>()) { if (robust_token_is_char<','>(src.data<0>()[i])) { ++i; comma_overextended = true; break; } }; { // see if it's a compile-time constant parse_tree_class tmp(src,origin,i-comma_overextended,0); if (tmp.is_raw_list() && !CondenseParseTree(tmp,*parse_tree::types)) return false; if (!EvalParseTree(tmp,*parse_tree::types)) return false; if (!intlike_literal_to_VM(latest_value,tmp,*parse_tree::types)) { //! \bug need test case message_header(src.data<0>()[origin-2].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator can only be explicitly initialized by a compile-time constant (C99 6.7.2.2p3/C++98 7.2p1)"); zcc_errors.inc_error(); return false; } // range checks if (allow_empty) { // C++ current_enumerator_type = tmp.type_code.base_type_index; const promote_aux test(current_enumerator_type,*parse_tree::types); if (test.is_signed && latest_value.test(test.bitcount-1)) { // negative unsigned_var_int abs_latest_value(latest_value); target_machine->signed_additive_inverse(abs_latest_value,test.machine_type); if (virtual_machine::twos_complement==target_machine->C_signed_int_representation() && !bool_options[boolopt::int_traps]) abs_latest_value-=1; cpp_using_negative = true; // sign filter switch(base_enum_type) { case C_TYPE::INT: case C_TYPE::LONG: case C_TYPE::LLONG: break; // these three are already signed, no representation change incurred case C_TYPE::UINT: if (target_machine->C_sizeof_int()<target_machine->C_sizeof_long()) { base_enum_type = C_TYPE::LONG; break; } case C_TYPE::ULONG: if (target_machine->C_sizeof_long()<target_machine->C_sizeof_long_long()) { base_enum_type = C_TYPE::LLONG; break; } default: //! \test decl.C99/Error_enum_nobase.hpp message_header(src.data<0>()[origin-2].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumeration requires both negative values and values above INTMAX_MAX, underlying type doesn't exist (C++0X 7.2p6)"); zcc_errors.inc_error(); return false; } // value filter switch(base_enum_type) { case C_TYPE::INT: if (target_machine->signed_max<virtual_machine::std_int_int>()>=abs_latest_value) break; base_enum_type = C_TYPE::LONG; case C_TYPE::LONG: if (target_machine->signed_max<virtual_machine::std_int_long>()>=abs_latest_value) break; base_enum_type = C_TYPE::LLONG; case C_TYPE::LLONG: if (target_machine->signed_max<virtual_machine::std_int_long_long>()>=abs_latest_value) break; default: //! \bug needs test case message_header(src.data<0>()[origin-2].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumeration requires value below INTMAX_MIN, underlying type doesn't exist (C++0X 7.2p6)"); zcc_errors.inc_error(); return false; } } else{ // positive if (cpp_using_negative) { switch(base_enum_type) { case C_TYPE::INT: if (target_machine->signed_max<virtual_machine::std_int_int>()>=latest_value) break; base_enum_type = C_TYPE::LONG; case C_TYPE::LONG: if (target_machine->signed_max<virtual_machine::std_int_long>()>=latest_value) break; base_enum_type = C_TYPE::LLONG; case C_TYPE::LLONG: if (target_machine->signed_max<virtual_machine::std_int_long_long>()>=latest_value) break; default: //! \test decl.C99/Error_enum_nobase2.hpp message_header(src.data<0>()[origin-2].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumeration requires both negative values and values above INTMAX_MAX, underlying type doesn't exist (C++0X 7.2p6)"); zcc_errors.inc_error(); return false; } } else{ switch(base_enum_type) { case C_TYPE::INT: if (target_machine->signed_max<virtual_machine::std_int_int>()>=latest_value) break; base_enum_type = C_TYPE::UINT; case C_TYPE::UINT: if (target_machine->unsigned_max<virtual_machine::std_int_int>()>=latest_value) break; base_enum_type = C_TYPE::LONG; case C_TYPE::LONG: if (target_machine->signed_max<virtual_machine::std_int_long>()>=latest_value) break; base_enum_type = C_TYPE::ULONG; case C_TYPE::ULONG: if (target_machine->unsigned_max<virtual_machine::std_int_long>()>=latest_value) break; base_enum_type = C_TYPE::LLONG; case C_TYPE::LLONG: if (target_machine->signed_max<virtual_machine::std_int_long_long>()>=latest_value) break; base_enum_type = C_TYPE::ULLONG; case C_TYPE::ULLONG: if (target_machine->unsigned_max<virtual_machine::std_int_long_long>()>=latest_value) break; default: //! \test decl.C99\Error_enum_overflow.hpp message_header(src.data<0>()[origin-2].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumeration requires values above UINTMAX_MAX, underlying type doesn't exist (C++0X 7.2p6)"); zcc_errors.inc_error(); return false; } } } } else{ // C const promote_aux test(tmp.type_code.base_type_index,*parse_tree::types); const promote_aux dest_type(C_TYPE::INT,*parse_tree::types); const bool is_negative = test.is_signed && latest_value.test(test.bitcount-1); if (is_negative) target_machine->signed_additive_inverse(latest_value,test.machine_type); bool out_of_range = latest_value>target_machine->signed_max<virtual_machine::std_int_int>(); if (out_of_range && is_negative && virtual_machine::twos_complement==target_machine->C_signed_int_representation()) { // handle two's complement INT_MIN latest_value -= 1; if (latest_value<=target_machine->signed_max<virtual_machine::std_int_int>()) out_of_range = false; latest_value += 1; } if (out_of_range) { //! \test decl.C99/Error_enum_overflow2.h message_header(src.data<0>()[origin-2].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("initializer of enumerator not representable as signed int (C99 6.7.2.2p3)"); zcc_errors.inc_error(); if (bool_options[boolopt::warn_crosslang_compatibility]) INFORM("(this may be valid C++, if the value is representable as either uintmax_t or intmax_t)"); return false; } if (is_negative) target_machine->signed_additive_inverse(latest_value,dest_type.machine_type); tmp.type_code.base_type_index = C_TYPE::INT; } #if 0 if (origin+1<i-comma_overextended) { // net token reduction, do source code optimization? } #endif } { // actually register the enumerator uchar_blob latest_value_copy; latest_value_copy.init(0); value_copy(latest_value_copy,latest_value); if (active_namespace) parse_tree::types->set_enumerator_def_CPP(src.data<0>()[origin-2].index_tokens[0].token.first, active_namespace,src.data<0>()[origin-2].index_tokens[0].logical_line,src.data<0>()[origin-2].index_tokens[0].src_filename,current_enumerator_type,latest_value_copy,enum_type_index); else parse_tree::types->set_enumerator_def(src.data<0>()[origin-2].index_tokens[0].token.first,src.data<0>()[origin-2].index_tokens[0].logical_line,src.data<0>()[origin-2].index_tokens[0].src_filename,current_enumerator_type,latest_value_copy,enum_type_index); } } // now ok to crunch underlying type/machine representation parse_tree::types->set_enum_underlying_type(enum_type_index,allow_empty ? base_enum_type : C_TYPE::INT); return true; } static void C99_flush_const_volatile_without_object(parse_tree& src) { //! \todo even if we use -Wno-OAOO/-Wno-DRY, -Wc-c++-compat should advise that const/volatile qualification of a forward-declaration is an error in C++ if ((type_spec::_const | type_spec::_volatile) & src.type_code.q_vector.back()) { message_header(src.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("useless const/volatile qualification of a forward-declaration (C99 6.7.3p3)"); if (bool_options[boolopt::warn_crosslang_compatibility]) INFORM("(error in C++: C++0X 7.1.6.1p1)"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); // XXX may not behave well on trapping-int hosts XXX src.type_code.q_vector.back() &= ~(type_spec::_const | type_spec::_volatile); }; } // ahem...morally should be macros; defensive coding #ifdef UNION_NAME #error internal enumerator UNION_NAME defined #undef UNION_NAME #endif #ifdef UNION_NAMED_DEF #error internal enumerator UNION_NAMED_DEF defined #undef UNION_NAMED_DEF #endif #ifdef UNION_ANON_DEF #error internal enumerator UNION_ANON_DEF defined #undef UNION_ANON_DEF #endif #ifdef STRUCT_NAME #error internal enumerator STRUCT_NAME defined #undef STRUCT_NAME #endif #ifdef STRUCT_NAMED_DEF #error internal enumerator STRUCT_NAMED_DEF defined #undef STRUCT_NAMED_DEF #endif #ifdef STRUCT_ANON_DEF #error internal enumerator STRUCT_ANON_DEF defined #undef STRUCT_ANON_DEF #endif #ifdef ENUM_NAME #error internal enumerator ENUM_NAME defined #undef ENUM_NAME #endif #ifdef ENUM_NAMED_DEF #error internal enumerator ENUM_NAMED_DEF defined #undef ENUM_NAMED_DEF #endif #ifdef ENUM_ANON_DEF #error internal enumerator ENUM_ANON_DEF defined #undef ENUM_ANON_DEF #endif #ifdef CLASS_NAME #error internal enumerator CLASS_NAME defined #undef CLASS_NAME #endif #ifdef CLASS_NAMED_DEF #error internal enumerator CLASS_NAMED_DEF defined #undef CLASS_NAMED_DEF #endif #ifdef CLASS_ANON_DEF #error internal enumerator CLASS_ANON_DEF defined #undef CLASS_ANON_DEF #endif enum C99_CPP_tag { UNION_NAME = 1, UNION_NAMED_DEF, UNION_ANON_DEF, STRUCT_NAME, STRUCT_NAMED_DEF, STRUCT_ANON_DEF, ENUM_NAME, ENUM_NAMED_DEF, ENUM_ANON_DEF, CLASS_NAME, CLASS_NAMED_DEF, CLASS_ANON_DEF }; #ifdef ZCC_CORE_NOTICE_TAG #error internal macro ZCC_CORE_NOTICE_TAG defined #undef ZCC_CORE_NOTICE_TAG #endif #define ZCC_CORE_NOTICE_TAG(src) \ if (is_C99_named_specifier(src,"union")) return UNION_NAME; \ else if (is_C99_named_specifier_definition(src,"union")) return UNION_NAMED_DEF; \ else if (is_C99_anonymous_specifier(src,"union")) return UNION_ANON_DEF; \ else if (is_C99_named_specifier(src,"struct")) return STRUCT_NAME; \ else if (is_C99_named_specifier_definition(src,"struct")) return STRUCT_NAMED_DEF; \ else if (is_C99_anonymous_specifier(src,"struct")) return STRUCT_ANON_DEF; \ else if (is_C99_named_specifier(src,"enum")) return ENUM_NAME; \ else if (is_C99_named_specifier_definition(src,"enum")) return ENUM_NAMED_DEF; \ else if (is_C99_anonymous_specifier(src,"enum")) return ENUM_ANON_DEF static int notice_C99_tag(const parse_tree& src) { ZCC_CORE_NOTICE_TAG(src); return 0; } static int notice_CPP_tag(const parse_tree& src) { ZCC_CORE_NOTICE_TAG(src); else if (is_C99_named_specifier(src,"class")) return CLASS_NAME; else if (is_C99_named_specifier_definition(src,"class")) return CLASS_NAMED_DEF; else if (is_C99_anonymous_specifier(src,"class")) return CLASS_ANON_DEF; return 0; } #undef ZCC_CORE_NOTICE_TAG static size_t C99_type_or_invariant_decl_specifier_or_tag(const parse_tree& x) { if (PARSE_TYPE & x.flags) return STATIC_SIZE(C99_nontype_decl_specifier_list); if (x.is_atomic()) { const errr i = linear_find(x.index_tokens[0].token.first,C99_nontype_decl_specifier_list,STATIC_SIZE(C99_nontype_decl_specifier_list)); if (STATIC_SIZE(C99_nontype_decl_specifier_list)>i) return i; } int tmp = notice_C99_tag(x); if (tmp) return STATIC_SIZE(C99_nontype_decl_specifier_list)+tmp; return SIZE_MAX; } static size_t CPP0X_type_or_invariant_decl_specifier_or_tag(const parse_tree& x) { if (PARSE_TYPE & x.flags) return STATIC_SIZE(CPP0X_nontype_decl_specifier_list); if (x.is_atomic()) { const errr i = linear_find(x.index_tokens[0].token.first,CPP0X_nontype_decl_specifier_list,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); if (STATIC_SIZE(CPP0X_nontype_decl_specifier_list)>i) return i; } int tmp = notice_CPP_tag(x); if (tmp) return STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+tmp; return SIZE_MAX; } static void _forward_declare_C_union_preparsed(parse_tree& src, size_t& i, size_t& k, kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner) { parse_tree& tmp = src.c_array<0>()[i+k]; #ifdef NDEBUG tmp.type_code.set_type(parse_tree::types->register_structdecl(tmp.index_tokens[1].token.first,union_struct_decl::decl_union,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename)); #else const type_system::type_index tmp2 = parse_tree::types->register_structdecl(tmp.index_tokens[1].token.first,union_struct_decl::decl_union,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename); assert(tmp2); assert(parse_tree::types->get_id_union(tmp.index_tokens[1].token.first)); assert(parse_tree::types->get_id_union(tmp.index_tokens[1].token.first)==tmp2); assert(parse_tree::types->get_structdecl(tmp2)); tmp.type_code.set_type(tmp2); #endif tmp.flags |= PARSE_UNION_TYPE; invariant_decl_scanner.reclassify(k,STATIC_SIZE(C99_nontype_decl_specifier_list)); _condense_const_volatile_onto_type_preparsed(src,i,k,invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); } static void _forward_declare_C_struct_preparsed(parse_tree& src, size_t& i, size_t& k, kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner) { parse_tree& tmp = src.c_array<0>()[i+k]; #ifdef NDEBUG tmp.type_code.set_type(parse_tree::types->register_structdecl(tmp.index_tokens[1].token.first,union_struct_decl::decl_struct,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename)); #else const type_system::type_index tmp2 = parse_tree::types->register_structdecl(tmp.index_tokens[1].token.first,union_struct_decl::decl_struct,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename); assert(tmp2); assert(parse_tree::types->get_id_struct_class(tmp.index_tokens[1].token.first)); assert(parse_tree::types->get_id_struct_class(tmp.index_tokens[1].token.first)==tmp2); assert(parse_tree::types->get_structdecl(tmp2)); tmp.type_code.set_type(tmp2); #endif tmp.flags |= PARSE_CLASS_STRUCT_TYPE; invariant_decl_scanner.reclassify(k,STATIC_SIZE(C99_nontype_decl_specifier_list)); _condense_const_volatile_onto_type_preparsed(src,i,k,invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); } static void enumeration_already_defined(const type_system::type_index x) { const enum_def* const tmp = parse_tree::types->get_enum_def(x); assert(tmp); message_header(*tmp); INFORM("prior definition here"); } static void change_definition_to_different_specifier(parse_tree& x, const char* const text) { assert(text && *text); x.set_index_token_from_str_literal<0>(text); x.DeleteIdx<2>(0); assert(is_C99_named_specifier(x,text)); } // will need: "function-type vector" // return: 1 typespec record (for now, other languages may have more demanding requirements) // incoming: n typespec records, flag for trailing ... // will need: typedef map: identifier |-> typespec record //! \todo check that the fact all literals are already legal-form is used //! \throw std::bad_alloc static void C99_ContextParse(parse_tree& src) { //! \todo type-vectorize as part of the lexical-forward loop. Need to handle in type_spec, which is required to be POD to allow C memory management: // * indirection depth n (already have this in practice) // * const, volatile at each level of indirection 0..n // * extent at each level of indirection 1..n (0 := raw-ptr, positive := array that can be bounds-checked for undefined behavior // * top-level reference (check standards to see if reference-in-middle is illegal, never seen it in real source) // * C99: restrict qualifier at each level of indirection 1..n (this is *not* in C++0x as of April 8 2009!) // * storage-qualifiers extern, static, register, auto // * fake type-qualifier typedef // Exploit uintptr_t to mitigate dynamic memory management. // * union of uintptr_t,unsigned char[sizeof(uintptr_t)] is probably best way to handle the qualifier-vector // * extent-vector will be painful: properly should be a CPUInfo-controlled type. Can get away with uintmax_t for now. (size_t won't work because we're // a cross-compiler; target size_t could be larger than host size_t. size_t does work for string literals since we have to represent those on the host.) // note that typedefs and struct/union declarations/definitions create new types; if this happens we are no longer context-free (so second pass with context-based parsing) // ask GCC: struct/class/union/enum collides with each other (both C and C++), does not collide with namespace // think we can handle this as "disallow conflicting definitions" size_t i = 0; restart_master_loop: while(i<src.size<0>()) { conserve_tokens(src.c_array<0>()[i]); // C static assertion scanner if (robust_token_is_string<14>(src.data<0>()[i],"_Static_assert")) { // _Static_assert ( constant-expression , string-literal ) ; C99_CPP_handle_static_assertion(src,*CLexer->pp_support,i,"control expression for static assertion must evaluate to a single integer constant (C1X 6.7.9p3)",NULL); continue; }; // XXX C allows mixing definitions and declaring variables at the same time, but this is a bit unusual // pre-scan for declaration-like items { kleene_star<STATIC_SIZE(C99_nontype_decl_specifier_list)+1+9,size_t (*)(const parse_tree&)> pre_invariant_decl_scanner(C99_type_or_invariant_decl_specifier_or_tag); { // wouldn't work for unnamed function parameters const size_t strict_ub = src.size<0>()-i; const parse_tree* const origin = src.data<0>()+i; while(pre_invariant_decl_scanner(origin[pre_invariant_decl_scanner.size()])) // if we ran out of tokens, bad if (strict_ub <= pre_invariant_decl_scanner.size()) { // unterminated declaration, top-level //! \test zcc/decl.C99/Error_extern_scope.h //! \test zcc/decl.C99/Error_static_scope.h //! \test zcc/decl.C99/Error_typedef_scope.h //! \test zcc/decl.C99/Error_register_scope.h //! \test zcc/decl.C99/Error_auto_scope.h message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration cut off by end of scope (C99 6.7p1)"); zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(strict_ub,i); return; }; } if (!pre_invariant_decl_scanner.empty()) { const bool semicolon_terminated_decl = robust_token_is_char<';'>(src.data<0>()[i+pre_invariant_decl_scanner.size()]); //! \todo naked identifier beyond could be an already-existing typedef which would trigger a rescan //! \todo ; means decl terminates w/o identifier //! \todo if there are unparsed tags, scan for them and parse { // check for too many types now size_t typecount = pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_ANON_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_ANON_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_ANON_DEF); if (1<typecount) { message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration trying to attribute more than one type"); zcc_errors.inc_error(); // flush the extra types by how annoying they are to the parser // names and already-parsed types go first size_t k = pre_invariant_decl_scanner.size(); assert(0<k); do switch(pre_invariant_decl_scanner[--k]) { case STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAME: case STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAME: case STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME: case STATIC_SIZE(C99_nontype_decl_specifier_list): src.DeleteIdx<0>(i+k); pre_invariant_decl_scanner.DeleteIdx(k); --typecount; } while(0<k && 1<typecount); if (1<typecount) { // cascading errors: cauterize now INFORM("must discard definition to reduce declaration to one type: stopping to prevent spurious errors"); return; } } //! \bug check for pre-existing typedefs if no types if (0>=typecount || 0<pre_invariant_decl_scanner.count(STATIC_SIZE(C99_nontype_decl_specifier_list))) goto reparse; } size_t k = 0; do switch(pre_invariant_decl_scanner[k]-STATIC_SIZE(C99_nontype_decl_specifier_list)) { case UNION_NAME: { const type_system::type_index tmp = parse_tree::types->get_id_union(src.data<0>()[i+k].index_tokens[1].token.first); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_UNION_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); } // C1X 6.7.2.3p2 states that conflicting enum or struct must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_struct_class(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_struct_as_union.h //! \test zcc/decl.C99/Error_struct_as_union3.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as struct (C99 6.7.2.3p2)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("struct"); assert(is_C99_named_specifier(tmp2,"struct")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_enum_as_union.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C99 6.7.2.3p2)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("enum"); assert(is_C99_named_specifier(tmp2,"enum")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_union_forward_def.h else _forward_declare_C_union_preparsed(src,i,k,pre_invariant_decl_scanner); } parse_tree& tmp2 = src.c_array<0>()[i+k]; if (semicolon_terminated_decl) { // check for forward-declaration here (C99 6.7.2.3) //! \test decl.C99/Warn_union_forward_def_const.h //! \test decl.C99/Warn_union_forward_def_const2.h //! \test decl.C99/Warn_union_forward_def_const3.h //! \test decl.C99/Warn_union_forward_def_const4.h //! \test decl.C99/Warn_union_forward_def_volatile.h //! \test decl.C99/Warn_union_forward_def_volatile2.h //! \test decl.C99/Warn_union_forward_def_volatile3.h //! \test decl.C99/Warn_union_forward_def_volatile4.h //! \test decl.C99/Warn_union_forward_def_const_volatile.h //! \test decl.C99/Warn_union_forward_def_const_volatile2.h //! \test decl.C99/Warn_union_forward_def_const_volatile3.h //! \test decl.C99/Warn_union_forward_def_const_volatile4.h //! \test decl.C99/Warn_union_forward_def_const_volatile5.h //! \test decl.C99/Warn_union_forward_def_const_volatile6.h //! \test decl.C99/Warn_union_forward_def_const_volatile7.h //! \test decl.C99/Warn_union_forward_def_const_volatile8.h //! \test decl.C99/Warn_union_forward_def_const_volatile9.h //! \test decl.C99/Warn_union_forward_def_const_volatile10.h //! \test decl.C99/Warn_union_forward_def_const_volatile11.h //! \test decl.C99/Warn_union_forward_def_const_volatile12.h C99_flush_const_volatile_without_object(tmp2); if (tmp) { // but if already (forward-)declared then this is a no-op // think this is common enough to not warrant OAOO/DRY treatment //! \test zcc/decl.C99/Pass_union_forward_def.h // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); assert(0<parse_tree::types->use_count(tmp)); goto restart_master_loop; } // forward-declare //! \test zcc/decl.C99/Pass_union_forward_def.h } else if (!tmp) { // used without at least forward-declaring //! \bug needs test cases message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("used without at least forward-declaring"); zcc_errors.inc_error(); } goto reparse; } // break; case UNION_NAMED_DEF: { // can only define once const type_system::type_index tmp = parse_tree::types->get_id_union(src.data<0>()[i+k].index_tokens[1].token.first); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); if (const C_union_struct_def* const fatal_def = parse_tree::types->get_C_structdef(tmp)) { //! \test zcc/decl.C99/Error_union_multidef.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'union "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C99 6.7.2.3p1)"); message_header(fatal_def->_decl); INFORM("prior definition here"); zcc_errors.inc_error(); // reduce to named-specifier tmp2.DeleteIdx<2>(0); assert(is_C99_named_specifier(tmp2,"union")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAME); continue; } tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_UNION_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); } // C1X 6.7.2.3p2 states that conflicting enum or struct must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_struct_class(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_struct_as_union2.h //! \test zcc/decl.C99/Error_struct_as_union4.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as struct (C99 6.7.2.3p2)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"struct"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_enum_as_union.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C99 6.7.2.3p2)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"enum"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_union_forward_def.h else _forward_declare_C_union_preparsed(src,i,k,pre_invariant_decl_scanner); } // parse the union and upgrade it to a full definition parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index vr_tmp = tmp2.type_code.base_type_index; const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(vr_tmp); assert(tmp3); C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(vr_tmp,tmp4); assert(parse_tree::types->get_id_union(tmp2.index_tokens[1].token.first)==vr_tmp); assert(parse_tree::types->get_C_structdef(vr_tmp)); if (semicolon_terminated_decl) { // no objects declared, trigger the const/volatile warnings //! \test decl.C99/Warn_union_def_const.h //! \test decl.C99/Warn_union_def_const2.h //! \test decl.C99/Warn_union_def_volatile.h //! \test decl.C99/Warn_union_def_volatile2.h //! \test decl.C99/Warn_union_def_const_volatile.h //! \test decl.C99/Warn_union_def_const_volatile2.h //! \test decl.C99/Warn_union_def_const_volatile3.h //! \test decl.C99/Warn_union_def_const_volatile4.h //! \test decl.C99/Warn_union_def_const_volatile5.h //! \test decl.C99/Warn_union_def_const_volatile6.h C99_flush_const_volatile_without_object(tmp2); // accept definition //! \test zcc/decl.C99/Pass_union_forward_def.h }; goto reparse; } // break; case UNION_ANON_DEF: { // anonymous types cannot be matched // tentatively forward-declare immediately const type_system::type_index tmp = parse_tree::types->register_structdecl("<unknown>",union_struct_decl::decl_union,src.data<0>()[i+k].index_tokens[0].logical_line,src.data<0>()[i+k].index_tokens[0].src_filename); assert(tmp); assert(parse_tree::types->get_structdecl(tmp)); { parse_tree& tmp2 = src.c_array<0>()[i+k]; tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_UNION_TYPE; } _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); // parse the union and upgrade it to a full definition const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(tmp); assert(tmp3); parse_tree& tmp2 = src.c_array<0>()[i+k]; C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(tmp,tmp4); assert(parse_tree::types->get_C_structdef(tmp)); if (semicolon_terminated_decl) { // unreferenceable declaration without static/extern/typedef...warn and optimize away //! \test decl.C99/Warn_union_anon_def_const.h //! \test decl.C99/Warn_union_anon_def_const2.h //! \test decl.C99/Warn_union_anon_def_volatile.h //! \test decl.C99/Warn_union_anon_def_volatile2.h //! \test decl.C99/Warn_union_anon_def_const_volatile.h //! \test decl.C99/Warn_union_anon_def_const_volatile2.h //! \test decl.C99/Warn_union_anon_def_const_volatile3.h //! \test decl.C99/Warn_union_anon_def_const_volatile4.h //! \test decl.C99/Warn_union_anon_def_const_volatile5.h //! \test decl.C99/Warn_union_anon_def_const_volatile6.h C99_flush_const_volatile_without_object(tmp2); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \test zcc/decl.C99/Warn_inaccessible_union.h message_header(tmp2.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("unreferenceable anonymous union declaration"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); goto restart_master_loop; } goto reparse; } // break; case STRUCT_NAME: { const type_system::type_index tmp = parse_tree::types->get_id_struct_class(src.data<0>()[i+k].index_tokens[1].token.first); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); } // C1X 6.7.2.3p2 states that conflicting enum or struct must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_union_as_struct.h //! \test zcc/decl.C99/Error_union_as_struct3.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C99 6.7.2.3p2)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("union"); assert(is_C99_named_specifier(tmp2,"union")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_enum_as_struct.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C99 6.7.2.3p2)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("enum"); assert(is_C99_named_specifier(tmp2,"enum")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_struct_forward_def.h else _forward_declare_C_struct_preparsed(src,i,k,pre_invariant_decl_scanner); } parse_tree& tmp2 = src.c_array<0>()[i+k]; if (semicolon_terminated_decl) { // check for forward-declaration here (C99 6.7.2.3) //! \test decl.C99/Warn_struct_forward_def_const.h //! \test decl.C99/Warn_struct_forward_def_const2.h //! \test decl.C99/Warn_struct_forward_def_const3.h //! \test decl.C99/Warn_struct_forward_def_const4.h //! \test decl.C99/Warn_struct_forward_def_volatile.h //! \test decl.C99/Warn_struct_forward_def_volatile2.h //! \test decl.C99/Warn_struct_forward_def_volatile3.h //! \test decl.C99/Warn_struct_forward_def_volatile4.h //! \test decl.C99/Warn_struct_forward_def_const_volatile.h //! \test decl.C99/Warn_struct_forward_def_const_volatile2.h //! \test decl.C99/Warn_struct_forward_def_const_volatile3.h //! \test decl.C99/Warn_struct_forward_def_const_volatile4.h //! \test decl.C99/Warn_struct_forward_def_const_volatile5.h //! \test decl.C99/Warn_struct_forward_def_const_volatile6.h //! \test decl.C99/Warn_struct_forward_def_const_volatile7.h //! \test decl.C99/Warn_struct_forward_def_const_volatile8.h //! \test decl.C99/Warn_struct_forward_def_const_volatile9.h //! \test decl.C99/Warn_struct_forward_def_const_volatile10.h //! \test decl.C99/Warn_struct_forward_def_const_volatile11.h //! \test decl.C99/Warn_struct_forward_def_const_volatile12.h C99_flush_const_volatile_without_object(tmp2); if (tmp) { // but if already (forward-)declared then this is a no-op // think this is common enough to not warrant OAOO/DRY treatment //! \test zcc/decl.C99/Pass_struct_forward_def.h // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); assert(0<parse_tree::types->use_count(tmp)); goto restart_master_loop; } // forward-declare //! \test zcc/decl.C99/Pass_struct_forward_def.h } else if (!tmp) { // used without at least forward-declaring //! \bug needs test cases message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("used without at least forward-declaring"); zcc_errors.inc_error(); } goto reparse; } // break; case STRUCT_NAMED_DEF: { // can only define once const type_system::type_index tmp = parse_tree::types->get_id_struct_class(src.data<0>()[i+k].index_tokens[1].token.first); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); if (const C_union_struct_def* const fatal_def = parse_tree::types->get_C_structdef(tmp)) { //! \test zcc/decl.C99/Error_struct_multidef.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C99 6.7.2.3p1)"); message_header(fatal_def->_decl); INFORM("prior definition here"); zcc_errors.inc_error(); // reduce to named-specifier tmp2.DeleteIdx<2>(0); assert(is_C99_named_specifier(tmp2,"struct")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAME); continue; } tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); } // C1X 6.7.2.3p2 states that conflicting enum or struct must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_union_as_struct2.h //! \test zcc/decl.C99/Error_union_as_struct4.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C99 6.7.2.3p2)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"union"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_enum_as_struct2.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C99 6.7.2.3p2)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"enum"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_struct_forward_def.h else _forward_declare_C_struct_preparsed(src,i,k,pre_invariant_decl_scanner); } // parse the union and upgrade it to a full definition parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index vr_tmp = tmp2.type_code.base_type_index; const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(vr_tmp); assert(tmp3); C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(vr_tmp,tmp4); assert(parse_tree::types->get_id_struct_class(tmp2.index_tokens[1].token.first)==vr_tmp); assert(parse_tree::types->get_C_structdef(vr_tmp)); if (semicolon_terminated_decl) { // no objects declared, trigger the const/volatile warnings //! \test decl.C99/Warn_struct_def_const.h //! \test decl.C99/Warn_struct_def_const2.h //! \test decl.C99/Warn_struct_def_volatile.h //! \test decl.C99/Warn_struct_def_volatile2.h //! \test decl.C99/Warn_struct_def_const_volatile.h //! \test decl.C99/Warn_struct_def_const_volatile2.h //! \test decl.C99/Warn_struct_def_const_volatile3.h //! \test decl.C99/Warn_struct_def_const_volatile4.h //! \test decl.C99/Warn_struct_def_const_volatile5.h //! \test decl.C99/Warn_struct_def_const_volatile6.h C99_flush_const_volatile_without_object(tmp2); // accept definition //! \test zcc/decl.C99/Pass_union_forward_def.h }; goto reparse; } // break; case STRUCT_ANON_DEF: { // anonymous types cannot be matched // tentatively forward-declare immediately const type_system::type_index tmp = parse_tree::types->register_structdecl("<unknown>",union_struct_decl::decl_struct,src.data<0>()[i+k].index_tokens[0].logical_line,src.data<0>()[i+k].index_tokens[0].src_filename); assert(tmp); assert(parse_tree::types->get_structdecl(tmp)); { parse_tree& tmp2 = src.c_array<0>()[i+k]; tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; } _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const type qualifier (C99 6.7.3p4)","removing redundant volatile type qualifier (C99 6.7.3p4)"); // parse the union and upgrade it to a full definition const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(tmp); assert(tmp3); parse_tree& tmp2 = src.c_array<0>()[i+k]; C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(tmp,tmp4); assert(parse_tree::types->get_C_structdef(tmp)); if (semicolon_terminated_decl) { // unreferenceable declaration without static/extern/typedef...warn and optimize away //! \test decl.C99/Warn_struct_anon_def_const.h //! \test decl.C99/Warn_struct_anon_def_const2.h //! \test decl.C99/Warn_struct_anon_def_volatile.h //! \test decl.C99/Warn_struct_anon_def_volatile2.h //! \test decl.C99/Warn_struct_anon_def_const_volatile.h //! \test decl.C99/Warn_struct_anon_def_const_volatile2.h //! \test decl.C99/Warn_struct_anon_def_const_volatile3.h //! \test decl.C99/Warn_struct_anon_def_const_volatile4.h //! \test decl.C99/Warn_struct_anon_def_const_volatile5.h //! \test decl.C99/Warn_struct_anon_def_const_volatile6.h C99_flush_const_volatile_without_object(tmp2); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \test zcc/decl.C99/Warn_inaccessible_struct.h message_header(tmp2.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("unreferenceable anonymous struct declaration"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); goto restart_master_loop; } goto reparse; } // break; //! \bug the enums aren't handling const/volatile qualification case ENUM_NAME: { // C99 6.7.2.3: allowed only after name is defined // XXX C: enums are int, but the optimizers will want to know parse_tree& tmp2 = src.c_array<0>()[i+k]; if (type_system::type_index tmp = parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)) { tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_ENUM_TYPE; } else{ //! \test zcc/decl.C99/Error_enum_undef.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'enum "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' must refer to completely defined enum (C99 6.7.2.3p2)"); zcc_errors.inc_error(); tmp2.type_code.set_type(C_TYPE::INT); // C: enums are int (although we'd like to extend this a bit) tmp2.flags |= (parse_tree::INVALID | PARSE_PRIMARY_TYPE); }; goto reparse; } // break; case ENUM_NAMED_DEF: { // can only define once parse_tree& tmp2 = src.c_array<0>()[i+k]; if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_enum_multidef.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'enum "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C99 6.7.2.3p1)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.DeleteIdx<2>(0); assert(is_C99_named_specifier(tmp2,"enum")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+ENUM_NAME); continue; } // C1X 6.7.2.3p2 states that conflicting union or struct must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_union_as_enum.h //! \test zcc/decl.C99/Error_union_as_enum2.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C99 6.7.2.3p2)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"union"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_struct_class(tmp2.index_tokens[1].token.first)) { //! \test zcc/decl.C99/Error_struct_as_enum.h //! \test zcc/decl.C99/Error_struct_as_enum2.h message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as struct (C99 6.7.2.3p2)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"struct"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(C99_nontype_decl_specifier_list)+STRUCT_NAME); continue; } // enum-specifier doesn't have a specific declaration mode //! \test zcc/decl.C99/Pass_enum_def.h const type_system::type_index tmp3 = parse_tree::types->register_enum_def(tmp2.index_tokens[1].token.first,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); assert(parse_tree::types->get_id_enum(tmp2.index_tokens[1].token.first)==tmp3); tmp2.type_code.set_type(tmp3); // C: enums are int (although we'd like to extend this a bit) tmp2.flags |= PARSE_ENUM_TYPE; if (!record_enum_values(*tmp2.c_array<2>(),tmp3,NULL,false,C99_echo_reserved_keyword,C99_intlike_literal_to_VM,C99_CondenseParseTree,C99_EvalParseTree)) { INFORM("enumeration not fully parsed: stopping to prevent spurious errors"); return; } goto reparse; } // break; case ENUM_ANON_DEF: { // enum-specifier doesn't have a specific declaration mode //! \test zcc/decl.C99/Pass_anonymous_enum_def.h parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index tmp = parse_tree::types->register_enum_def("<unknown>",tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); tmp2.type_code.set_type(tmp); // C: enums are int (although we'd like to extend this a bit) tmp2.flags |= PARSE_ENUM_TYPE; if (!record_enum_values(*tmp2.c_array<2>(),tmp,NULL,false,C99_echo_reserved_keyword,C99_intlike_literal_to_VM,C99_CondenseParseTree,C99_EvalParseTree)) { INFORM("enumeration not fully parsed: stopping to prevent spurious errors"); return; } goto reparse; } } while(pre_invariant_decl_scanner.size()> ++k); }; } // check naked declarations first reparse: // general declaration scanner // we intercept typedefs as part of general variable declaration detection (weird storage qualifier) // intercept declarations as follows // * storage-class specifiers // ** C: extern static auto register // ** C: taking address of a register-qualified var is an error; not so for C++ (just downgrades register to auto implicitly) // * typedef (pretty much a fake storage-class specifier) // * function specifiers // ** C: inline // * cv-qualification // ** C: const volatile restrict (but pointer type required for restrict) // * atomic types have already been parsed, we need to catch the others { C99_decl_specifier_scanner declFind(*parse_tree::types); size_t decl_count = src.get_span<0>(i,declFind); if (decl_count) { const bool coherent_storage_specifiers = declFind.analyze_flags_global(src,i,decl_count); assert(src.size<0>()-i>decl_count); // unterminated declaration handled above if (robust_token_is_char<';'>(src.data<0>()[i+decl_count])) { // C99 7p2 error: must declare something if ( declFind.is_enumeration() // but a raw enumeration is fine || (1==decl_count && declFind.is_type())) // as is a forward-declare { i += decl_count+1; continue; } //! \test zcc/decl.C99/Error_extern_semicolon.h //! \test zcc/decl.C99/Error_static_semicolon.h //! \test zcc/decl.C99/Error_typedef_semicolon.h //! \test zcc/decl.C99/Error_register_semicolon.h //! \test zcc/decl.C99/Error_auto_semicolon.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration must declare something (C99 6.7p2)"); zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(decl_count+1,i); continue; }; declFind.fixup_type(); // apply const, volatile // at this point we don't have a recovery path for things like extern static int x; // this will have already errored, so stop if (!coherent_storage_specifiers) { message_header(src.data<0>()[i].index_tokens[0]); INFORM("cannot resolve linkage for incoherent storage specifiers: stopping to prevent spurious errors"); return; } size_t decl_offset = 0; bool have_we_parsed_yet = false; do { type_spec bootstrap; bootstrap.clear(); declFind.value_copy_type(bootstrap); parse_tree* initdecl_identifier = NULL; size_t initdecl_span = C99_init_declarator_scanner(src,i+decl_count+decl_offset,bootstrap,initdecl_identifier); assert(0<initdecl_span || !initdecl_identifier); if (0==initdecl_span) { // no declarator where expected //! \todo test suite/Jan. 22 2011 does not exercise. Is this dead code? message_header(src.data<0>()[i+decl_count+decl_offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declarator missing (C99 6.7p1)"); zcc_errors.inc_error(); // find the next semicolon const size_t remove_these = span_to_semicolon(src.data<0>()+i+decl_count+decl_offset,src.end<0>()); if (have_we_parsed_yet) src.DeleteNSlotsAt<0>(remove_these,i+decl_count+decl_offset); else src.DeleteNSlotsAt<0>(remove_these+decl_count+decl_offset+(src.size<0>()>i+remove_these+decl_count+decl_offset),i); break; }; if (!initdecl_identifier) { // didn't find identifier when needed message_header(src.data<0>()[i+decl_count+decl_offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declarator has no identifier to declare (C99 6.7p1)"); zcc_errors.inc_error(); // find the next semicolon, unless we have () immediately in which case we have nothing to look for const bool unwind_to_compound_statement = is_naked_parentheses_pair(src.data<0>()[i+decl_count+decl_offset]); if (unwind_to_compound_statement) { assert(!have_we_parsed_yet); src.DeleteNSlotsAt<0>(decl_count+decl_offset+initdecl_span,i); } else{ //! \todo test suite/Jan. 22 2011 does not exercise. Is this dead code? const size_t remove_these = span_to_semicolon(src.data<0>()+i+decl_count+decl_offset,src.end<0>()); if (have_we_parsed_yet) src.DeleteNSlotsAt<0>(remove_these,i+decl_count+decl_offset); else src.DeleteNSlotsAt<0>(remove_these+decl_count+decl_offset+(src.size<0>()>i+remove_these+decl_count+decl_offset),i); } break; }; //! \todo analyze decl_specifiers for errors (now have full target type) // something is being declared; storage specifiers reasonable have_we_parsed_yet = true; if (C99_CPP0X_DECLSPEC_TYPEDEF & declFind.get_flags()) { // typedef register_token<0>(*initdecl_identifier); // verify that there is no prior definition if (const type_system::object_type_loc_linkage* const tmp = parse_tree::types->get_object(initdecl_identifier->index_tokens[0].token.first)) { //! \bug needs test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("object/function is already declared/defined, conflicts with typedef (C1X 6.2.3p1)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": object/function declaration/definition here"); zcc_errors.inc_error(); return; }; if (const zaimoni::POD_triple<type_spec,const char*,size_t>* const tmp = parse_tree::types->get_typedef(initdecl_identifier->index_tokens[0].token.first)) { if (bootstrap==tmp->first) { // warn if there is a prior, consistent definition //! \test zcc/decl.C99/Warn_redeclare_typedef.h //! \todo control this warning with an option --no-OAOO or --no-DRY message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(WARN_STR); INC_INFORM("redeclaring typedef "); INFORM(initdecl_identifier->index_tokens[0].token.first); INC_INFORM(tmp->second); INC_INFORM(':'); INC_INFORM(tmp->third); INFORM(": prior typedef"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); } else{ // error if there is a prior, inconsistent definition //! \test zcc/decl.C99/Error_redeclare_typedef.h message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("redeclaring typedef "); INFORM(initdecl_identifier->index_tokens[0].token.first); INC_INFORM(tmp->second); INC_INFORM(':'); INC_INFORM(tmp->third); INFORM(": prior typedef"); zcc_errors.inc_error(); } // do not re-register if there is a prior definition } else{ // prepare to register this with types object if (const type_system::enumerator_info* const tmp2 = parse_tree::types->get_enumerator(initdecl_identifier->index_tokens[0].token.first)) { //! \test zcc/decl.C99/Error_typedef_enum.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator is already defined, conflicts with typedef (C99 6.7.2.2p3)"); INC_INFORM(tmp2->second.second.first); INC_INFORM(":"); INC_INFORM(tmp2->second.second.second.first); INFORM(": enumerator definition here"); zcc_errors.inc_error(); return; } parse_tree::types->set_typedef(initdecl_identifier->index_tokens[0].token.first,initdecl_identifier->index_tokens[0].src_filename,initdecl_identifier->index_tokens[0].logical_line.first,bootstrap); } } // for routing purposes, we care about: extern, static, _Thread_local // function definitions also care about inline // review when declarations of functions/objects can make no-linkage declarations (struct, union, enumeration, enumerator, typedef) // but all of struct, union, enumeration will be disambiguated syntactically (affects linkage calculation but not here) // so just need to handle enumerator and typedef else{ //! \todo C1X 6.2.3p1: both enumerators and typedef will block object/function declaration register_token<0>(*initdecl_identifier); if (const zaimoni::POD_triple<type_spec,const char*,size_t>* const tmp = parse_tree::types->get_typedef(initdecl_identifier->index_tokens[0].token.first)) { // typedef: fail //! \bug need test cases message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("typedef is already defined, conflicts with object/function (C1X 6.2.3p1)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": typedef definition here"); zcc_errors.inc_error(); return; } else if (const type_system::enumerator_info* const tmp2 = parse_tree::types->get_enumerator(initdecl_identifier->index_tokens[0].token.first)) { // enumerator: fail //! \bug need test cases message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator is already defined, conflicts with object/function (C99 6.7.2.2p3)"); INC_INFORM(tmp2->second.second.first); INC_INFORM(":"); INC_INFORM(tmp2->second.second.second.first); INFORM(": enumerator definition here"); zcc_errors.inc_error(); return; }; // all declarations must agree regarding _Thread_local (C1X 6.7.1p3), which does not apply to functions (C1X 6.9.1p4...only extern, static work for functions) const type_system::object_type_loc_linkage* const tmp = parse_tree::types->get_object(initdecl_identifier->index_tokens[0].token.first); if (tmp && tmp->first!=bootstrap) { // check pre-existing type; want compatible types, in particular // multiple translation units is not an issue here: C1X 6.2.7 // * enumerations cause implementation-defined weirdness: C1X 6.7.2.2p4 // * qualifiers: C1X 6.7.3p10 // * functions: C1X 6.7.6.2p15 // reject incompatible prior type as undefined behavior message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("already defined with some other type (this error needs to implement proper incompatible type rejection) (C99 6.2.7 and related)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": prior declaration here"); zcc_errors.inc_error(); return; }; //! \todo deal with _Thread_local at this point if (C99_CPP0X_DECLSPEC_STATIC & declFind.get_flags()) { // explicit static. // pre-existing extern declaration will invoke undefined behavior [C1X 6.2.2p7], so error out then if (tmp) { if (type_system::linkage_static!=tmp->fourth) { //! \bug need test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("already defined with some linkage other than static at global scope: undefined behavior (C1X 6.2.2p7)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": prior declaration here"); zcc_errors.inc_error(); return; } //! \bug need test case // if we were already static, redeclaration so ignore } else{ // new declaration // this will have to be modified to pass in _Thread_local as well parse_tree::types->set_object(initdecl_identifier->index_tokens[0].token.first, initdecl_identifier->index_tokens[0].src_filename, initdecl_identifier->index_tokens[0].logical_line.first, bootstrap, type_system::linkage_static); } } else if (C99_CPP0X_DECLSPEC_EXTERN & declFind.get_flags()) { // explicit extern. // no effect on pre-existing declaration, other than to convert no-linkage to extern (if this can indeed be tripped) // we need a cross-lang warning if there is a pre-existing static declaration, as this will error in C++ explicit_extern: if (tmp) { if (bool_options[boolopt::warn_crosslang_compatibility] && type_system::linkage_extern_C!=tmp->fourth) { //! \bug need test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(WARN_STR); INFORM("already defined with some linkage other than extern at global scope: no effect in C, C++ would error"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": prior declaration here"); if (bool_options[boolopt::warnings_are_errors]) { //! \bug need test case zcc_errors.inc_error(); return; } } //! \bug need test case // redeclaration so ignore } else{ // new declaration // this will have to be modified to pass in _Thread_local as well parse_tree::types->set_object(initdecl_identifier->index_tokens[0].token.first, initdecl_identifier->index_tokens[0].src_filename, initdecl_identifier->index_tokens[0].logical_line.first, bootstrap, type_system::linkage_extern_C); } } else{ // something else: C99 defaults to extern no matter what for global functions and objects. // we need a cross-lang warning for const objects as C++ will default to static then if (bool_options[boolopt::warn_crosslang_compatibility] && bootstrap.CPP_global_linkage_is_static()) { //! \bug need test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(WARN_STR); INFORM("global const objects have default linkage extern in C, static in C++"); if (bool_options[boolopt::warnings_are_errors]) { //! \bug need test case zcc_errors.inc_error(); return; } } goto explicit_extern; // handle as extern }; }; decl_offset += initdecl_span; if (src.size<0>()-(i+decl_count)<=decl_offset) { // unterminated declaration: error //! \test zcc/decl.C99/Error_scope.h message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration cut off by end of scope (C99 6.7p1)"); zcc_errors.inc_error(); return; }; //! \todo function declarations can be self-terminating // ;: done if (robust_token_is_char<';'>(src.data<0>()[i+decl_count+decl_offset])) { src.c_array<0>()[i+decl_count+decl_offset].flags |= parse_tree::GOOD_LINE_BREAK; ++decl_offset; break; }; // ,: iterate // anything else: error if (!robust_token_is_char<','>(src.data<0>()[i+decl_count+decl_offset])) { //! \test decl.C99/Error_enum_runon_def.h message_header(src.data<0>()[i+decl_count+decl_offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration disoriented by missing , (C99 6.7p1)"); zcc_errors.inc_error(); // remove everything starting here through next semicolon src.DeleteNSlotsAt<0>(span_to_semicolon(src.data<0>()+i+decl_count+decl_offset,src.end<0>()),i+decl_count+decl_offset); src.c_array<0>()[i+decl_count+decl_offset].flags |= parse_tree::GOOD_LINE_BREAK; ++decl_offset; break; } ++decl_offset; } while(src.size<0>()>(i+decl_count+decl_offset)); i += decl_count+decl_offset; continue; } } ++i; } } // relies on _fatal_code being noreturn to avoid risk of undefined return value static const char* text_from_keyword(const union_struct_decl& x) { switch(x.keyword()) { default: _fatal_code("invalid state",3); case union_struct_decl::decl_union: return "union"; case union_struct_decl::decl_struct: return "struct"; case union_struct_decl::decl_class: return "class"; } } // this needs to line up with the return type for type_spec::qualifier static void display_qualifier_text(unsigned char x) { if (type_spec::_restrict & x) INC_INFORM("restrict "); if (type_spec::_const & x) INC_INFORM("const "); if (type_spec::_volatile & x) INC_INFORM("volatile "); } // language-specific printing overrides static void render_type(const type_spec& src,const type_system& types, const char* const name) { // function types will need a different naming scheme const char* const type_name = types.name(src.base_type_index); // each ptr to array transition needs a parentheses pair to group properly size_t i = src.pointer_power; size_t start_ptr_scan = src.pointer_power; while(0<i) { if (type_spec::_array & src.qualifier(i--)) continue; if (0<i && (type_spec::_array & src.qualifier(i)) && !(type_spec::_array & src.qualifier(i+1))) { while(--start_ptr_scan>i) { if (type_spec::_array & src.qualifier(start_ptr_scan+1)) continue; INC_INFORM('*'); display_qualifier_text(src.qualifier(start_ptr_scan+1)); }; INC_INFORM("("); } } display_qualifier_text(src.qualifier<0>()); if (types.get_enum_def(src.base_type_index)) INC_INFORM("enum "); else if (const union_struct_decl* tmp = types.get_structdecl(src.base_type_index)) { INC_INFORM(text_from_keyword(*tmp)); INC_INFORM(' '); } INC_INFORM(type_name ? type_name : "<unresolved type>"); while(0<start_ptr_scan--) { if (type_spec::_array & src.qualifier(start_ptr_scan+1)) continue; INC_INFORM('*'); display_qualifier_text(src.qualifier(start_ptr_scan+1)); } if (name && *name) INC_INFORM(name); i = 0; while(i<src.pointer_power) { if (!(type_spec::_array & src.qualifier(++i))) { if (type_spec::_array & src.qualifier(i-1)) INC_INFORM(")"); continue; } INC_INFORM("["); if (src.extent_vector[i-1]) INC_INFORM(src.extent_vector[i-1]); INC_INFORM("]"); } } bool C99_hook_INC_INFORM(const parse_tree& src) { if (PARSE_TYPE & src.flags) { assert(parse_tree::types); render_type(src.type_code,*parse_tree::types,NULL); if (is_C99_named_specifier_definitionlike(src)) INC_INFORM(*src.data<2>()); return true; } return false; } static bool is_CPP_namespace(const parse_tree& src) { return robust_token_is_string<9>(src.index_tokens[0].token,"namespace") && src.index_tokens[1].token.first && 1==src.size<2>() #ifndef NDEBUG && C_TESTFLAG_IDENTIFIER==src.index_tokens[1].flags #endif && robust_token_is_char<'{'>(src.data<2>()[0].index_tokens[0].token) && robust_token_is_char<'}'>(src.data<2>()[0].index_tokens[1].token); } bool CPP_hook_INC_INFORM(const parse_tree& src) { if (PARSE_TYPE & src.flags) { assert(parse_tree::types); render_type(src.type_code,*parse_tree::types,NULL); if (is_C99_named_specifier_definitionlike(src)) INC_INFORM(*src.data<2>()); return true; } if (is_CPP_namespace(src) && robust_token_is_string<9>(src.index_tokens[1].token,"<unknown>")) { // make anonymous namespaces look like authentic source code // first index token INC_INFORM(src.index_tokens[0]); INC_INFORM(' '); // postfix data INC_INFORM(*src.data<2>()); if (src.flags & parse_tree::GOOD_LINE_BREAK) INC_INFORM('\n'); return true; }; return false; } static void CPP0X_flush_const_volatile_without_object(parse_tree& src) { if ((type_spec::_const | type_spec::_volatile) & src.type_code.q_vector.back()) { message_header(src.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("const/volatile qualification must apply to an object (C++0X 7.1.6.1p1)"); zcc_errors.inc_error(); // XXX may not behave well on trapping-int hosts XXX src.type_code.q_vector.back() &= ~(type_spec::_const | type_spec::_volatile); } } static void _forward_declare_CPP_union_preparsed(parse_tree& src, const char* const active_namespace, size_t& i, size_t& k, kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner) { parse_tree& tmp = src.c_array<0>()[i+k]; #ifdef NDEBUG tmp.type_code.set_type(parse_tree::types->register_structdecl_CPP(tmp.index_tokens[1].token.first,active_namespace,union_struct_decl::decl_union,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename)); #else const type_system::type_index tmp2 = parse_tree::types->register_structdecl_CPP(tmp.index_tokens[1].token.first,active_namespace,union_struct_decl::decl_union,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename); assert(tmp2); assert(parse_tree::types->get_id_union_CPP(tmp.index_tokens[1].token.first,active_namespace)); assert(parse_tree::types->get_id_union_CPP(tmp.index_tokens[1].token.first,active_namespace)==tmp2); assert(parse_tree::types->get_structdecl(tmp2)); tmp.type_code.set_type(tmp2); #endif tmp.flags |= PARSE_UNION_TYPE; invariant_decl_scanner.reclassify(k,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); _condense_const_volatile_onto_type_preparsed(src,i,k,invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } static void _forward_declare_CPP_struct_preparsed(parse_tree& src, const char* const active_namespace, size_t& i, size_t& k, kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner) { parse_tree& tmp = src.c_array<0>()[i+k]; #ifdef NDEBUG tmp.type_code.set_type(parse_tree::types->register_structdecl_CPP(tmp.index_tokens[1].token.first,active_namespace,union_struct_decl::decl_struct,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename)); #else const type_system::type_index tmp2 = parse_tree::types->register_structdecl_CPP(tmp.index_tokens[1].token.first,active_namespace,union_struct_decl::decl_struct,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename); assert(tmp2); assert(parse_tree::types->get_id_struct_class_CPP(tmp.index_tokens[1].token.first,active_namespace)); assert(parse_tree::types->get_id_struct_class_CPP(tmp.index_tokens[1].token.first,active_namespace)==tmp2); assert(parse_tree::types->get_structdecl(tmp2)); tmp.type_code.set_type(tmp2); #endif tmp.flags |= PARSE_CLASS_STRUCT_TYPE; invariant_decl_scanner.reclassify(k,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); _condense_const_volatile_onto_type_preparsed(src,i,k,invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } static void _forward_declare_CPP_class_preparsed(parse_tree& src, const char* const active_namespace, size_t& i, size_t& k, kleene_star_core<size_t (*)(const parse_tree&)>& invariant_decl_scanner) { parse_tree& tmp = src.c_array<0>()[i+k]; #ifdef NDEBUG tmp.type_code.set_type(parse_tree::types->register_structdecl_CPP(tmp.index_tokens[1].token.first,active_namespace,union_struct_decl::decl_class,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename)); #else const type_system::type_index tmp2 = parse_tree::types->register_structdecl_CPP(tmp.index_tokens[1].token.first,active_namespace,union_struct_decl::decl_class,tmp.index_tokens[1].logical_line,tmp.index_tokens[1].src_filename); assert(tmp2); assert(parse_tree::types->get_id_struct_class_CPP(tmp.index_tokens[1].token.first,active_namespace)); assert(parse_tree::types->get_id_struct_class_CPP(tmp.index_tokens[1].token.first,active_namespace)==tmp2); assert(parse_tree::types->get_structdecl(tmp2)); tmp.type_code.set_type(tmp2); #endif tmp.flags |= PARSE_CLASS_STRUCT_TYPE; invariant_decl_scanner.reclassify(k,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); _condense_const_volatile_onto_type_preparsed(src,i,k,invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // handle namespaces or else //! \todo check that the fact all literals are already legal-form is used //! \throw std::bad_alloc static void CPP_ParseNamespace(parse_tree& src,const char* const active_namespace) { //! \todo type-vectorize as part of the lexical-forward loop. Need to handle // * indirection depth n (already have this in practice) // * const, volatile at each level of indirection 0..n // * extent at each level of indirection 1..n (0 := raw-ptr, positive := array that can be bounds-checked for undefined behavior // * top-level reference (check standards to see if reference-in-middle is illegal, never seen it in real source) // * storage-qualifiers extern, static, register, mutable, thread_local // * fake type-qualifier typedef // note that typedefs and struct/union declarations/definitions create new types // C++: note that class declarations/definitions create new types // note that we need a sense of "current namespace" in C++ // ask GCC: struct/class/union/enum collides with each other (both C and C++), does not collide with namespace // think we can handle this as "disallow conflicting definitions" // should be able to disable this warning (it's about bloat) if (src.empty<0>()) { //! \test zcc/namespace.CPP/Warn_emptybody1.hpp //! \test zcc/namespace.CPP/Warn_emptybody2.hpp //! \todo -Wno-bloat turns off message_header(src.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("namespace contains no declarations"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); return; } zaimoni::Perl::localize<const char*>(parse_tree::active_namespace,active_namespace); size_t i = 0; restart_master_loop: while(i<src.size<0>()) { conserve_tokens(src.c_array<0>()[i]); // C++ static assertion scanner if (robust_token_is_string<13>(src.data<0>()[i],"static_assert")) { // static_assert ( constant-expression , string-literal ) ; C99_CPP_handle_static_assertion(src,*CPlusPlusLexer->pp_support,i,"control expression for static assertion must be a constant convertible to bool (C++0X 7p4)",active_namespace); continue; }; // XXX C++ allows mixing definitions and declaring variables at the same time, but this is a bit unusual // check naked declarations first; handle namespaces later { kleene_star<STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+1+12,size_t (*)(const parse_tree&)> pre_invariant_decl_scanner(CPP0X_type_or_invariant_decl_specifier_or_tag); { // wouldn't work for unnamed function parameters const size_t strict_ub = src.size<0>()-i; const parse_tree* const origin = src.data<0>()+i; rescan: while(pre_invariant_decl_scanner(origin[pre_invariant_decl_scanner.size()])) // if we ran out of tokens, bad if (strict_ub <= pre_invariant_decl_scanner.size()) { // unterminated declaration, top-level //! \test zcc/decl.C99/Error_extern_scope.hpp //! \test zcc/decl.C99/Error_static_scope.hpp //! \test zcc/decl.C99/Error_typedef_scope.hpp //! \test zcc/decl.C99/Error_register_scope.hpp //! \test zcc/decl.C99/Error_mutable_scope.hpp //! \test zcc/decl.C99/Error_virtual_scope.hpp //! \test zcc/decl.C99/Error_friend_scope.hpp //! \test zcc/decl.C99/Error_explicit_scope.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration cut off by end of scope (C++98 7p1)"); zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(strict_ub,i); return; }; // more generally, we should recover any type-id; haven't checked how much we can do here // this doesn't generalize fully to C // do not have namespace available in CPP0X_type_or_invariant_decl_specifier_or_tag so can't punt there (unsure if this is worth a global) // identifier might be type name: recover if (0==pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list))) { parse_tree& tmp2 = src.c_array<0>()[i+pre_invariant_decl_scanner.size()]; if (tmp2.is_atomic() && (tmp2.index_tokens[0].flags & C_TESTFLAG_IDENTIFIER)) { { type_system::type_index tmp = parse_tree::types->get_id_enum_CPP(tmp2.index_tokens[0].token.first,active_namespace); if (tmp) { // is an enum tmp2.grab_index_token_from<1,0>(tmp2); tmp2.set_index_token_from_str_literal<0>("enum"); assert(is_C99_named_specifier(tmp2,"enum")); goto rescan; } else if ((tmp = parse_tree::types->get_id_union_CPP(tmp2.index_tokens[0].token.first,active_namespace))) { // is a union tmp2.grab_index_token_from<1,0>(tmp2); tmp2.set_index_token_from_str_literal<0>("union"); assert(is_C99_named_specifier(tmp2,"union")); goto rescan; } else if ((tmp = parse_tree::types->get_id_struct_class_CPP(tmp2.index_tokens[0].token.first,active_namespace))) { // is a struct/class const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(tmp); assert(tmp3); const char* const text = text_from_keyword(*tmp3); tmp2.grab_index_token_from<1,0>(tmp2); tmp2.set_index_token_from_str_literal<0>(text); assert(is_C99_named_specifier(tmp2,text)); goto rescan; }; } #if 0 { const zaimoni::POD_triple<type_spec,const char*,size_t>* const tmp = parse_tree::types->get_typedef_CPP(pre_invariant_decl_scanner.size()].index_tokens[0],active_namespace); if (tmp) { } } #endif } } } if (!pre_invariant_decl_scanner.empty()) { const bool semicolon_terminated_decl = robust_token_is_char<';'>(src.data<0>()[i+pre_invariant_decl_scanner.size()]); //! \todo naked identifier beyond could be an already-existing typedef which would trigger a rescan //! \todo ; means decl terminates w/o identifier //! \todo if there are unparsed tags, scan for them and parse { // check for too many types now size_t typecount = pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_ANON_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_ANON_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_ANON_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAMED_DEF); typecount += pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_ANON_DEF); if (1<typecount) { message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration trying to attribute more than one type (C++98 7.1.5p2; C++0X 7.1.6p2)"); zcc_errors.inc_error(); // flush the extra types by how annoying they are to the parser // names and already-parsed types go first size_t k = pre_invariant_decl_scanner.size(); assert(0<k); do switch(pre_invariant_decl_scanner[--k]) { case STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME: case STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME: case STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME: case STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME: case STATIC_SIZE(CPP0X_nontype_decl_specifier_list): src.DeleteIdx<0>(i+k); pre_invariant_decl_scanner.DeleteIdx(k); --typecount; } while(0<k && 1<typecount); if (1<typecount) { // cascading errors: cauterize now INFORM("must discard definition to reduce declaration to one type: stopping to prevent spurious errors"); return; } } //! \bug check for pre-existing typedefs if no types if (0>=typecount || 0<pre_invariant_decl_scanner.count(STATIC_SIZE(CPP0X_nontype_decl_specifier_list))) goto reparse; } size_t k = 0; do switch(pre_invariant_decl_scanner[k]-STATIC_SIZE(CPP0X_nontype_decl_specifier_list)) { case UNION_NAME: { const type_system::type_index tmp = parse_tree::types->get_id_union_CPP(src.data<0>()[i+k].index_tokens[1].token.first,active_namespace); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_UNION_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_struct_class_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_struct_as_union.hpp //! \test zcc/decl.C99/Error_struct_as_union3.hpp //! \test zcc/decl.C99/Error_class_as_union.hpp //! \test zcc/decl.C99/Error_class_as_union3.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INC_INFORM(" declared as "); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); const char* const text = text_from_keyword(*tmp3); INC_INFORM(text); INFORM(" (C++98 One Definition Rule)"); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>(text); assert(is_C99_named_specifier(tmp2,text)); pre_invariant_decl_scanner.reclassify(k--,strcmp("class",text) ? STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME : STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_as_union.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C++98 One Definition Rule)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("enum"); assert(is_C99_named_specifier(tmp2,"enum")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_union_forward_def.hpp else _forward_declare_CPP_union_preparsed(src,active_namespace,i,k,pre_invariant_decl_scanner); } parse_tree& tmp2 = src.c_array<0>()[i+k]; if (semicolon_terminated_decl) { // check for forward-declaration here //! \test decl.C99/Error_union_forward_def_const.hpp //! \test decl.C99/Error_union_forward_def_const2.hpp //! \test decl.C99/Error_union_forward_def_const3.hpp //! \test decl.C99/Error_union_forward_def_const4.hpp //! \test decl.C99/Error_union_forward_def_volatile.hpp //! \test decl.C99/Error_union_forward_def_volatile2.hpp //! \test decl.C99/Error_union_forward_def_volatile3.hpp //! \test decl.C99/Error_union_forward_def_volatile4.hpp //! \test decl.C99/Error_union_forward_def_const_volatile.hpp //! \test decl.C99/Error_union_forward_def_const_volatile2.hpp //! \test decl.C99/Error_union_forward_def_const_volatile3.hpp //! \test decl.C99/Error_union_forward_def_const_volatile4.hpp //! \test decl.C99/Error_union_forward_def_const_volatile5.hpp //! \test decl.C99/Error_union_forward_def_const_volatile6.hpp //! \test decl.C99/Error_union_forward_def_const_volatile7.hpp //! \test decl.C99/Error_union_forward_def_const_volatile8.hpp //! \test decl.C99/Error_union_forward_def_const_volatile9.hpp //! \test decl.C99/Error_union_forward_def_const_volatile10.hpp //! \test decl.C99/Error_union_forward_def_const_volatile11.hpp //! \test decl.C99/Error_union_forward_def_const_volatile12.hpp CPP0X_flush_const_volatile_without_object(tmp2); if (tmp) { // but if already (forward-)declared then this is a no-op // think this is common enough to not warrant OAOO/DRY treatment //! \test zcc/decl.C99/Pass_union_forward_def.hpp // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); assert(0<parse_tree::types->use_count(tmp)); goto restart_master_loop; }; //! \test zcc/decl.C99/Pass_union_forward_def.hpp } else if (!tmp) { // used without at least forward-declaring //! \bug needs test cases message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("used without at least forward-declaring"); zcc_errors.inc_error(); } goto reparse; } // break; case UNION_NAMED_DEF: { // can only define once const type_system::type_index tmp = parse_tree::types->get_id_union_CPP_exact(src.data<0>()[i+k].index_tokens[1].token.first,active_namespace); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { if (const C_union_struct_def* const fatal_def = parse_tree::types->get_C_structdef(tmp)) { //! \test zcc/decl.C99/Error_union_multidef.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'union "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C++98 3.2p1)"); message_header(fatal_def->_decl); INFORM("prior definition here"); zcc_errors.inc_error(); // reduce to named-specifier tmp2.DeleteIdx<2>(0); assert(is_C99_named_specifier(tmp2,"union")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); continue; } tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_UNION_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_struct_class_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_struct_as_union2.hpp //! \test zcc/decl.C99/Error_struct_as_union4.hpp //! \test zcc/decl.C99/Error_class_as_union2.hpp //! \test zcc/decl.C99/Error_class_as_union4.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INC_INFORM(" declared as "); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); const char* const text = text_from_keyword(*tmp3); INC_INFORM(text); INFORM(" (C++98 One Definition Rule)"); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,text); pre_invariant_decl_scanner.reclassify(k--,strcmp("class",text) ? STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME : STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_as_union.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C++98 One Definition Rule)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"enum"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_union_forward_def.hpp else _forward_declare_CPP_union_preparsed(src,active_namespace,i,k,pre_invariant_decl_scanner); } // parse the union and upgrade it to a full definition parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index vr_tmp = tmp2.type_code.base_type_index; const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(vr_tmp); assert(tmp3); C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(vr_tmp,tmp4); assert(parse_tree::types->get_id_union_CPP(tmp2.index_tokens[1].token.first,active_namespace)==vr_tmp); assert(parse_tree::types->get_C_structdef(vr_tmp)); if (semicolon_terminated_decl) { // check for forward-declaration here //! \test decl.C99/Error_union_def_const.hpp //! \test decl.C99/Error_union_def_const2.hpp //! \test decl.C99/Error_union_def_volatile.hpp //! \test decl.C99/Error_union_def_volatile2.hpp //! \test decl.C99/Error_union_def_const_volatile.hpp //! \test decl.C99/Error_union_def_const_volatile2.hpp //! \test decl.C99/Error_union_def_const_volatile3.hpp //! \test decl.C99/Error_union_def_const_volatile4.hpp //! \test decl.C99/Error_union_def_const_volatile5.hpp //! \test decl.C99/Error_union_def_const_volatile6.hpp CPP0X_flush_const_volatile_without_object(tmp2); // accept definition //! \test zcc/decl.C99/Pass_union_forward_def.hpp } goto reparse; } // break; case UNION_ANON_DEF: { // anonymous types cannot be matched // tentatively forward-declare immediately const type_system::type_index tmp = parse_tree::types->register_structdecl_CPP("<unknown>",active_namespace,union_struct_decl::decl_union,src.data<0>()[i+k].index_tokens[0].logical_line,src.data<0>()[i+k].index_tokens[0].src_filename); assert(tmp); //! \test zcc/decl.C99/Pass_union_forward_def.hpp assert(parse_tree::types->get_structdecl(tmp)); { parse_tree& tmp2 = src.c_array<0>()[i+k]; tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_UNION_TYPE; } _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); // parse the union and upgrade it to a full definition const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(tmp); assert(tmp3); parse_tree& tmp2 = src.c_array<0>()[i+k]; C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(tmp,tmp4); assert(parse_tree::types->get_C_structdef(tmp)); if (semicolon_terminated_decl) { // unreferenceable declaration without static/extern/typedef...warn and optimize away //! \test decl.C99/Error_union_anon_def_const.hpp //! \test decl.C99/Error_union_anon_def_const2.hpp //! \test decl.C99/Error_union_anon_def_volatile.hpp //! \test decl.C99/Error_union_anon_def_volatile2.hpp //! \test decl.C99/Error_union_anon_def_const_volatile.hpp //! \test decl.C99/Error_union_anon_def_const_volatile2.hpp //! \test decl.C99/Error_union_anon_def_const_volatile3.hpp //! \test decl.C99/Error_union_anon_def_const_volatile4.hpp //! \test decl.C99/Error_union_anon_def_const_volatile5.hpp //! \test decl.C99/Error_union_anon_def_const_volatile6.hpp CPP0X_flush_const_volatile_without_object(tmp2); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \test zcc/decl.C99/Warn_inaccessible_union.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("unreferenceable anonymous union declaration"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); goto restart_master_loop; } goto reparse; } // break; case STRUCT_NAME: { const type_system::type_index tmp = parse_tree::types->get_id_struct_class_CPP(src.data<0>()[i+k].index_tokens[1].token.first,active_namespace); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_union_as_struct.hpp //! \test zcc/decl.C99/Error_union_as_struct3.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C++98 One Definition Rule)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("union"); assert(is_C99_named_specifier(tmp2,"union")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_as_struct.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C++98 One Definition Rule)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("enum"); assert(is_C99_named_specifier(tmp2,"enum")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_struct_forward_def.hpp else _forward_declare_CPP_struct_preparsed(src,active_namespace,i,k,pre_invariant_decl_scanner); } parse_tree& tmp2 = src.c_array<0>()[i+k]; if (semicolon_terminated_decl) { // check for forward-declaration here //! \test decl.C99/Error_struct_forward_def_const.hpp //! \test decl.C99/Error_struct_forward_def_const2.hpp //! \test decl.C99/Error_struct_forward_def_const3.hpp //! \test decl.C99/Error_struct_forward_def_const4.hpp //! \test decl.C99/Error_struct_forward_def_volatile.hpp //! \test decl.C99/Error_struct_forward_def_volatile2.hpp //! \test decl.C99/Error_struct_forward_def_volatile3.hpp //! \test decl.C99/Error_struct_forward_def_volatile4.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile2.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile3.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile4.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile5.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile6.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile7.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile8.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile9.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile10.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile11.hpp //! \test decl.C99/Error_struct_forward_def_const_volatile12.hpp CPP0X_flush_const_volatile_without_object(tmp2); if (tmp) { // but if already (forward-)declared then this is a no-op // think this is common enough to not warrant OAOO/DRY treatment //! \test zcc/decl.C99/Pass_struct_forward_def.hpp // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); assert(0<parse_tree::types->use_count(tmp)); goto restart_master_loop; } // forward-declare //! \test zcc/decl.C99/Pass_struct_forward_def.hpp } else if (!tmp) { // used without at least forward-declaring //! \bug needs test cases message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("used without at least forward-declaring"); zcc_errors.inc_error(); } goto reparse; } // break; case STRUCT_NAMED_DEF: { // can only define once const type_system::type_index tmp = parse_tree::types->get_id_struct_class_CPP_exact(src.data<0>()[i+k].index_tokens[1].token.first,active_namespace); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { if (const C_union_struct_def* const fatal_def = parse_tree::types->get_C_structdef(tmp)) { //! \test zcc/decl.C99/Error_struct_multidef.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C++98 3.2p1)"); message_header(fatal_def->_decl); const char* const text = text_from_keyword(fatal_def->_decl); INFORM(strcmp("class",text) ? "prior definition here" : "prior definition as class here"); zcc_errors.inc_error(); // reduce to named-specifier change_definition_to_different_specifier(tmp2,text); pre_invariant_decl_scanner.reclassify(k--,strcmp("class",text) ? STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME : STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME); continue; } tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_union_as_struct2.hpp //! \test zcc/decl.C99/Error_union_as_struct4.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C++98 One Definition Rule)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"union"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_as_struct2.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C++98 One Definition Rule)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"enum"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_struct_forward_def.hpp else _forward_declare_CPP_struct_preparsed(src,active_namespace,i,k,pre_invariant_decl_scanner); } // parse the union and upgrade it to a full definition parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index vr_tmp = tmp2.type_code.base_type_index; const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(vr_tmp); assert(tmp3); C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(vr_tmp,tmp4); assert(parse_tree::types->get_id_struct_class_CPP(tmp2.index_tokens[1].token.first,active_namespace)==vr_tmp); assert(parse_tree::types->get_C_structdef(vr_tmp)); if (semicolon_terminated_decl) { // check for forward-declaration here //! \test decl.C99/Error_struct_def_const.hpp //! \test decl.C99/Error_struct_def_const2.hpp //! \test decl.C99/Error_struct_def_volatile.hpp //! \test decl.C99/Error_struct_def_volatile2.hpp //! \test decl.C99/Error_struct_def_const_volatile.hpp //! \test decl.C99/Error_struct_def_const_volatile2.hpp //! \test decl.C99/Error_struct_def_const_volatile3.hpp //! \test decl.C99/Error_struct_def_const_volatile4.hpp //! \test decl.C99/Error_struct_def_const_volatile5.hpp //! \test decl.C99/Error_struct_def_const_volatile6.hpp CPP0X_flush_const_volatile_without_object(tmp2); // accept definition //! \test zcc/decl.C99/Pass_struct_forward_def.hpp } goto reparse; } // break; case STRUCT_ANON_DEF: { // anonymous types cannot be matched // tentatively forward-declare immediately const type_system::type_index tmp = parse_tree::types->register_structdecl_CPP("<unknown>",active_namespace,union_struct_decl::decl_struct,src.data<0>()[i+k].index_tokens[0].logical_line,src.data<0>()[i+k].index_tokens[0].src_filename); assert(tmp); assert(parse_tree::types->get_structdecl(tmp)); { parse_tree& tmp2 = src.c_array<0>()[i+k]; tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; } _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); // parse the union and upgrade it to a full definition const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(tmp); assert(tmp3); parse_tree& tmp2 = src.c_array<0>()[i+k]; C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(tmp,tmp4); assert(parse_tree::types->get_C_structdef(tmp)); if (semicolon_terminated_decl) { // unreferenceable declaration without static/extern/typedef...warn and optimize away //! \test decl.C99/Error_struct_anon_def_const.hpp //! \test decl.C99/Error_struct_anon_def_const2.hpp //! \test decl.C99/Error_struct_anon_def_volatile.hpp //! \test decl.C99/Error_struct_anon_def_volatile2.hpp //! \test decl.C99/Error_struct_anon_def_const_volatile.hpp //! \test decl.C99/Error_struct_anon_def_const_volatile2.hpp //! \test decl.C99/Error_struct_anon_def_const_volatile3.hpp //! \test decl.C99/Error_struct_anon_def_const_volatile4.hpp //! \test decl.C99/Error_struct_anon_def_const_volatile5.hpp //! \test decl.C99/Error_struct_anon_def_const_volatile6.hpp CPP0X_flush_const_volatile_without_object(tmp2); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \test zcc/decl.C99/Warn_inaccessible_struct.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("unreferenceable anonymous struct declaration"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); goto restart_master_loop; } goto reparse; } // break; case CLASS_NAME: { const type_system::type_index tmp = parse_tree::types->get_id_struct_class_CPP(src.data<0>()[i+k].index_tokens[1].token.first,active_namespace); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { assert(0<parse_tree::types->use_count(tmp)); tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_union_as_class.hpp //! \test zcc/decl.C99/Error_union_as_class3.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("class "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C++98 One Definition Rule)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("union"); assert(is_C99_named_specifier(tmp2,"union")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_as_class.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("class "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C++98 One Definition Rule)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.set_index_token_from_str_literal<0>("enum"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_class_forward_def.hpp else _forward_declare_CPP_class_preparsed(src,active_namespace,i,k,pre_invariant_decl_scanner); } parse_tree& tmp2 = src.c_array<0>()[i+k]; if (semicolon_terminated_decl) { // check for forward-declaration here //! \test decl.C99/Error_class_forward_def_const.hpp //! \test decl.C99/Error_class_forward_def_const2.hpp //! \test decl.C99/Error_class_forward_def_const3.hpp //! \test decl.C99/Error_class_forward_def_const4.hpp //! \test decl.C99/Error_class_forward_def_volatile.hpp //! \test decl.C99/Error_class_forward_def_volatile2.hpp //! \test decl.C99/Error_class_forward_def_volatile3.hpp //! \test decl.C99/Error_class_forward_def_volatile4.hpp //! \test decl.C99/Error_class_forward_def_const_volatile.hpp //! \test decl.C99/Error_class_forward_def_const_volatile2.hpp //! \test decl.C99/Error_class_forward_def_const_volatile3.hpp //! \test decl.C99/Error_class_forward_def_const_volatile4.hpp //! \test decl.C99/Error_class_forward_def_const_volatile5.hpp //! \test decl.C99/Error_class_forward_def_const_volatile6.hpp //! \test decl.C99/Error_class_forward_def_const_volatile7.hpp //! \test decl.C99/Error_class_forward_def_const_volatile8.hpp //! \test decl.C99/Error_class_forward_def_const_volatile9.hpp //! \test decl.C99/Error_class_forward_def_const_volatile10.hpp //! \test decl.C99/Error_class_forward_def_const_volatile11.hpp //! \test decl.C99/Error_class_forward_def_const_volatile12.hpp CPP0X_flush_const_volatile_without_object(tmp2); if (tmp) { // but if already (forward-)declared then this is a no-op // think this is common enough to not warrant OAOO/DRY treatment //! \test zcc/decl.C99/Pass_class_forward_def.hpp // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); assert(0<parse_tree::types->use_count(tmp)); goto restart_master_loop; } // forward-declare //! \test zcc/decl.C99/Pass_class_forward_def.hpp } else if (!tmp) { // used without at least forward-declaring //! \bug needs test cases message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INFORM("used without at least forward-declaring"); zcc_errors.inc_error(); } goto reparse; } // break; case CLASS_NAMED_DEF: { // can only define once const type_system::type_index tmp = parse_tree::types->get_id_struct_class_CPP_exact(src.data<0>()[i+k].index_tokens[1].token.first,active_namespace); { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (tmp) { if (const C_union_struct_def* const fatal_def = parse_tree::types->get_C_structdef(tmp)) { //! \test zcc/decl.C99/Error_class_multidef.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'class "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C++98 3.2p1)"); message_header(fatal_def->_decl); const char* const text = text_from_keyword(fatal_def->_decl); INFORM(strcmp("class",text) ? "prior definition as struct here" : "prior definition here"); zcc_errors.inc_error(); // reduce to named-specifier change_definition_to_different_specifier(tmp2,text); pre_invariant_decl_scanner.reclassify(k--,strcmp("class",text) ? STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME : STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME); continue; } tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_union_as_class2.hpp //! \test zcc/decl.C99/Error_union_as_class4.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("class "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C++98 One Definition Rule)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"union"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_as_class2.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("class "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as enumeration (C++98 One Definition Rule)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"enum"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // tentatively forward-declare immediately //! \test zcc/decl.C99/Pass_class_forward_def.hpp else _forward_declare_CPP_class_preparsed(src,active_namespace,i,k,pre_invariant_decl_scanner); } // parse the union and upgrade it to a full definition parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index vr_tmp = tmp2.type_code.base_type_index; const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(vr_tmp); assert(tmp3); C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(vr_tmp,tmp4); assert(parse_tree::types->get_id_struct_class_CPP(tmp2.index_tokens[1].token.first,active_namespace)==vr_tmp); assert(parse_tree::types->get_C_structdef(vr_tmp)); if (semicolon_terminated_decl) { // check for forward-declaration here //! \test decl.C99/Error_class_def_const.hpp //! \test decl.C99/Error_class_def_const2.hpp //! \test decl.C99/Error_class_def_volatile.hpp //! \test decl.C99/Error_class_def_volatile2.hpp //! \test decl.C99/Error_class_def_const_volatile.hpp //! \test decl.C99/Error_class_def_const_volatile2.hpp //! \test decl.C99/Error_class_def_const_volatile3.hpp //! \test decl.C99/Error_class_def_const_volatile4.hpp //! \test decl.C99/Error_class_def_const_volatile5.hpp //! \test decl.C99/Error_class_def_const_volatile6.hpp CPP0X_flush_const_volatile_without_object(tmp2); // accept definition //! \test zcc/decl.C99/Pass_class_forward_def.hpp } goto reparse; } // break; case CLASS_ANON_DEF: { // anonymous types cannot be matched // tentatively forward-declare immediately const type_system::type_index tmp = parse_tree::types->register_structdecl_CPP("<unknown>",active_namespace,union_struct_decl::decl_class,src.data<0>()[i+k].index_tokens[0].logical_line,src.data<0>()[i+k].index_tokens[0].src_filename); assert(tmp); assert(parse_tree::types->get_structdecl(tmp)); { parse_tree& tmp2 = src.c_array<0>()[i+k]; tmp2.type_code.set_type(tmp); tmp2.flags |= PARSE_CLASS_STRUCT_TYPE; } pre_invariant_decl_scanner.reclassify(k,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)); _condense_const_volatile_onto_type_preparsed(src,i,k,pre_invariant_decl_scanner,"removing redundant const cv-qualifier (C++0X 7.1.6.1p1)","removing redundant volatile cv-qualifier (C++0X 7.1.6.1p1)"); // parse the union and upgrade it to a full definition const union_struct_decl* tmp3 = parse_tree::types->get_structdecl(tmp); assert(tmp3); parse_tree& tmp2 = src.c_array<0>()[i+k]; C_union_struct_def* tmp4 = new C_union_struct_def(*tmp3,tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); //! \todo record field structure, etc. parse_tree::types->upgrade_decl_to_def(tmp,tmp4); assert(parse_tree::types->get_C_structdef(tmp)); if (semicolon_terminated_decl) { // unreferenceable declaration without static/extern/typedef...warn and optimize away //! \test decl.C99/Error_class_anon_def_const.hpp //! \test decl.C99/Error_class_anon_def_const2.hpp //! \test decl.C99/Error_class_anon_def_volatile.hpp //! \test decl.C99/Error_class_anon_def_volatile2.hpp //! \test decl.C99/Error_class_anon_def_const_volatile.hpp //! \test decl.C99/Error_class_anon_def_const_volatile2.hpp //! \test decl.C99/Error_class_anon_def_const_volatile3.hpp //! \test decl.C99/Error_class_anon_def_const_volatile4.hpp //! \test decl.C99/Error_class_anon_def_const_volatile5.hpp //! \test decl.C99/Error_class_anon_def_const_volatile6.hpp CPP0X_flush_const_volatile_without_object(tmp2); //! \todo do not warn for -Wno-OOAO/-Wno-DRY //! \test zcc/decl.C99/Warn_inaccessible_class.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(WARN_STR); INFORM("unreferenceable anonymous class declaration"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(1+pre_invariant_decl_scanner.size(),i); goto restart_master_loop; } i += pre_invariant_decl_scanner.size(); goto restart_master_loop; } // break; //! \bug the enums aren't handling const/volatile qualification //! \bug the enums aren't noticing semicolon termination case ENUM_NAME: { parse_tree& tmp2 = src.c_array<0>()[i+k]; if (const type_system::type_index tmp = parse_tree::types->get_id_enum_CPP(tmp2.index_tokens[1].token.first,active_namespace)) { tmp2.type_code.set_type(tmp); // C++: enums are own type tmp2.flags |= PARSE_ENUM_TYPE; } else{ // this belongs elsewhere //! \test zcc/decl.C99/Error_enum_undef.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'enum "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' must refer to completely defined enum (C++98/C++0X 3.1p2, C++98 7.1.5.3p2-4/C++0X 7.1.6.3p2)"); zcc_errors.inc_error(); tmp2.type_code.set_type(C_TYPE::INT); // fail over to int, like C tmp2.flags |= (parse_tree::INVALID | PARSE_PRIMARY_TYPE); }; goto reparse; } // break; case ENUM_NAMED_DEF: { // can only define once parse_tree& tmp2 = src.c_array<0>()[i+k]; if (const type_system::type_index fatal_def = parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_enum_multidef.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'enum "); INC_INFORM(tmp2.index_tokens[1]); INFORM("' already defined (C++98 3.2p1)"); enumeration_already_defined(fatal_def); zcc_errors.inc_error(); tmp2.DeleteIdx<2>(0); assert(is_C99_named_specifier(tmp2,"enum")); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+ENUM_NAME); continue; } // One Definition Rule states that conflicting enum, struct, or class must error else if (const type_system::type_index fatal_def = parse_tree::types->get_id_union_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_union_as_enum.hpp //! \test zcc/decl.C99/Error_union_as_enum2.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("struct "); INC_INFORM(tmp2.index_tokens[1]); INFORM(" declared as union (C++98 One Definition Rule)"); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,"union"); pre_invariant_decl_scanner.reclassify(k--,STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+UNION_NAME); continue; } else if (const type_system::type_index fatal_def = parse_tree::types->get_id_struct_class_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)) { //! \test zcc/decl.C99/Error_struct_as_enum.hpp //! \test zcc/decl.C99/Error_struct_as_enum2.hpp //! \test zcc/decl.C99/Error_class_as_enum.hpp //! \test zcc/decl.C99/Error_class_as_enum2.hpp message_header(tmp2.index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("union "); INC_INFORM(tmp2.index_tokens[1]); INC_INFORM(" declared as "); const union_struct_decl* const tmp3 = parse_tree::types->get_structdecl(fatal_def); assert(tmp3); const char* const text = text_from_keyword(*tmp3); INC_INFORM(text); INFORM(" (C++98 One Definition Rule)"); message_header(*tmp3); INFORM("prior definition here"); zcc_errors.inc_error(); change_definition_to_different_specifier(tmp2,text); pre_invariant_decl_scanner.reclassify(k--,strcmp("class",text) ? STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+STRUCT_NAME : STATIC_SIZE(CPP0X_nontype_decl_specifier_list)+CLASS_NAME); continue; } //! \test zcc/decl.C99/Pass_enum_def.hpp // enum-specifier doesn't have a specific declaration mode const type_system::type_index tmp3 = parse_tree::types->register_enum_def_CPP(tmp2.index_tokens[1].token.first,active_namespace,tmp2.index_tokens[1].logical_line,tmp2.index_tokens[1].src_filename); assert(parse_tree::types->get_id_enum_CPP_exact(tmp2.index_tokens[1].token.first,active_namespace)==tmp3); tmp2.type_code.set_type(tmp3); // C++: enums are own type tmp2.flags |= PARSE_ENUM_TYPE; if (!record_enum_values(*tmp2.c_array<2>(),tmp3,active_namespace,true,CPP_echo_reserved_keyword,CPP_intlike_literal_to_VM,CPP_CondenseParseTree,CPP_EvalParseTree)) { INFORM("enumeration not fully parsed: stopping to prevent spurious errors"); return; } goto reparse; } // break; case ENUM_ANON_DEF: { // enum-specifier doesn't have a specific declaration mode //! \test zcc/decl.C99/Pass_anonymous_enum_def.hpp parse_tree& tmp2 = src.c_array<0>()[i+k]; const type_system::type_index tmp = parse_tree::types->register_enum_def_CPP("<unknown>",active_namespace,tmp2.index_tokens[0].logical_line,tmp2.index_tokens[0].src_filename); tmp2.type_code.set_type(tmp); // C++: enums are own type tmp2.flags |= PARSE_ENUM_TYPE; if (!record_enum_values(*tmp2.c_array<2>(),tmp,active_namespace,true,CPP_echo_reserved_keyword,CPP_intlike_literal_to_VM,CPP_CondenseParseTree,CPP_EvalParseTree)) { INFORM("enumeration not fully parsed: stopping to prevent spurious errors"); return; } goto reparse; } } while(pre_invariant_decl_scanner.size()> ++k); }; } reparse: // namespace scanner // need some scheme to handle unnamed namespaces (probably alphabetical counter after something illegal so unmatchable) // C++0X has inline namespaces; ignore these for now (well, maybe not: consuming the inline will prevent problems) // C++0X has more complicated using namespace directives: ignore these for now // basic namespace; C++98 and C++0X agree on what this is if (robust_token_is_string<9>(src.data<0>()[i],"namespace")) { // fail if: end of token stream // fail if: next token is a type // accept if: next token is {} (unnamed namespace) // accept if: next token is an identifier, and the token after that is {} (typical namespace) // fail otherwise if (1>=src.size<0>()-i) { //! \test zcc/namespace.CPP/Error_premature1.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("namespace declaration cut off by end of scope"); zcc_errors.inc_error(); src.DeleteIdx<0>(i); break; }; if ( robust_token_is_char<'{'>(src.data<0>()[i+1].index_tokens[0].token) && robust_token_is_char<'}'>(src.data<0>()[i+1].index_tokens[1].token)) { //! handle unnamed namespace //! \test zcc/namespace.CPP/Warn_emptybody2.hpp // regardless of official linkage, entities in anonymous namespaces aren't very accessible outside of the current translation unit; // any reasonable linker thinks they have static linkage src.c_array<0>()[i].resize<2>(1); src.c_array<0>()[i+1].OverwriteInto(src.c_array<0>()[i].c_array<2>()[0]); src.DeleteIdx<0>(i+1); // anonymous namespace names are technically illegal // GCC uses <unknown> and handles uniqueness at link time src.c_array<0>()[i].grab_index_token_from_str_literal<1>("<unknown>",C_TESTFLAG_IDENTIFIER); // pretend it's an identifier src.c_array<0>()[i].grab_index_token_location_from<1,0>(src.data<0>()[i].data<2>()[0]); // inject it at where the namespace body starts src.c_array<0>()[i].flags |= parse_tree::GOOD_LINE_BREAK; assert(is_CPP_namespace(src.data<0>()[i])); if (active_namespace) { //! \todo exception-unsafe; fix char* const new_active_namespace = type_system::namespace_concatenate("<unknown>",active_namespace,"::"); CPP_ParseNamespace(src.c_array<0>()[i].c_array<2>()[0],new_active_namespace); free(new_active_namespace); } else CPP_ParseNamespace(src.c_array<0>()[i].c_array<2>()[0],"<unknown>"); ++i; continue; } { parse_tree* const origin = src.c_array<0>()+i; const bool namespace_has_body = ( 3<=src.size<0>()-i && robust_token_is_char<'{'>(origin[2].index_tokens[0].token) && robust_token_is_char<'}'>(origin[2].index_tokens[1].token)); // next token must be an atomic identifier // already-parsed primary types are no good, neither are reserved keywords if ( !origin[1].is_atomic() || !(C_TESTFLAG_IDENTIFIER & origin[1].index_tokens[0].flags) || (PARSE_TYPE & origin[1].flags) || CPP_echo_reserved_keyword(origin[1].index_tokens[0].token.first,origin[1].index_tokens[0].token.second)) { //! \test zcc/namespace.CPP/Error_badname1.hpp //! \test zcc/namespace.CPP/Error_badname2.hpp //! \test zcc/namespace.CPP/Error_badname3.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("named namespace declaration must use non-reserved identifier (C++98 7.3.1p1, 7.3.2p1)"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(2+namespace_has_body,i); continue; }; if (!namespace_has_body) { //! \test zcc/namespace.CPP/Error_premature2.hpp message_header(origin->index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("'namespace "); INC_INFORM(origin[1]); INFORM("' definition needs a body (C++98 7.3.1p1)"); zcc_errors.inc_error(); src.DeleteNSlotsAt<0>(2,i); continue; }; //! \test zcc/namespace.CPP/Warn_emptybody1.hpp // process namespace // namespace name: postfix arg 1 // namespace definition body: postfix arg 2 // the namespace name is likely to be reused: atomic string target register_token<0>(origin[1]); origin->resize<2>(1); origin->grab_index_token_from<1,0>(origin[1]); origin->grab_index_token_location_from<1,0>(origin[1]); // inject it at where the namespace body starts origin[2].OverwriteInto(origin->c_array<2>()[0]); } src.DeleteNSlotsAt<0>(2,i+1); src.c_array<0>()[i].flags |= parse_tree::GOOD_LINE_BREAK; assert(is_CPP_namespace(src.data<0>()[i])); // handle named namespace if (NULL==active_namespace) { // global //! \todo expand namespace aliases CPP_ParseNamespace(src.c_array<0>()[i].c_array<2>()[0],src.c_array<0>()[i].index_tokens[1].token.first); } else{ // nested //! \todo expand namespace aliases char* const new_active_namespace = type_system::namespace_concatenate(src.c_array<0>()[i].index_tokens[1].token.first,active_namespace,"::"); CPP_ParseNamespace(src.c_array<0>()[i].c_array<2>()[0],new_active_namespace); free(new_active_namespace); } ++i; continue; }; // C++0X also has inline namespaces; all anonymous namespaces are already inline // general declaration scanner (have to catch C++0X inline namespaces first when those come up) // ideally would cope with both C++98 and C++0X // we intercept typedefs as part of general variable declaration detection (weird storage qualifier) // intercept declarations as follows // * storage-class specifiers // ** C++98: auto register static extern mutable [class-data only] // ** C++0x: register static thread_local extern mutable [class-data only] // ** C: taking address of a register-qualified var is an error; not so for C++ (just downgrades register to auto implicitly) // * typedef (pretty much a fake storage-class specifier) // * C++0X: constexpr // * function specifiers // ** C++: inline virtual [nonstatic class-member-function only] explicit [constructors only] // * C++: friend (inside class declaration only) // * cv-qualification // ** C++: const volatile // * atomic types have already been parsed, we need to catch the others // * C++0x: auto is a possible type! { CPP0X_decl_specifier_scanner declFind(*parse_tree::types,active_namespace); size_t decl_count = src.destructive_get_span<0>(i,declFind); if (decl_count) { const bool coherent_storage_specifiers = declFind.analyze_flags_global(src,i,decl_count); assert(src.size<0>()-i>decl_count); /* unterminated declarations already handled */ if (robust_token_is_char<';'>(src.data<0>()[i+decl_count])) { // must declare something if ( declFind.is_enumeration() // but a raw enumeration is fine || (1==decl_count && declFind.is_type())) // as is a forward-declare { i += decl_count+1; continue; } //! \test zcc/decl.C99/Error_extern_semicolon.hpp //! \test zcc/decl.C99/Error_static_semicolon.hpp //! \test zcc/decl.C99/Error_typedef_semicolon.hpp //! \test zcc/decl.C99/Error_register_semicolon.hpp //! \test zcc/decl.C99/Error_mutable_semicolon.hpp //! \test zcc/decl.C99/Error_virtual_semicolon.hpp //! \test zcc/decl.C99/Error_friend_semicolon.hpp //! \test zcc/decl.C99/Error_explicit_semicolon.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration must declare something (C++98 7p4)"); zcc_errors.inc_error(); // remove from parse src.DeleteNSlotsAt<0>(decl_count+1,i); continue; }; declFind.fixup_type(); // apply const, volatile // at this point we don't have a recovery path for things like extern static int x; // this will have already errored, so stop if (!coherent_storage_specifiers) { message_header(src.data<0>()[i].index_tokens[0]); INFORM("cannot resolve linkage for incoherent storage specifiers: stopping to prevent spurious errors"); return; } size_t decl_offset = 0; bool have_we_parsed_yet = false; do { type_spec bootstrap; bootstrap.clear(); declFind.value_copy_type(bootstrap); parse_tree* initdecl_identifier = NULL; size_t initdecl_span = CPP_init_declarator_scanner(src,i+decl_count+decl_offset,bootstrap,initdecl_identifier); assert(0<initdecl_span || !initdecl_identifier); if (0==initdecl_span) { // no declarator where expected //! \todo test suite/Jan. 22 2011 does not exercise. Is this dead code? message_header(src.data<0>()[i+decl_count+decl_offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declarator missing (C++98 7p1)"); zcc_errors.inc_error(); // find the next semicolon const size_t remove_these = span_to_semicolon(src.data<0>()+i+decl_count+decl_offset,src.end<0>()); if (have_we_parsed_yet) src.DeleteNSlotsAt<0>(remove_these,i+decl_count+decl_offset); else src.DeleteNSlotsAt<0>(remove_these+decl_count+decl_offset+(src.size<0>()>i+remove_these+decl_count+decl_offset),i); break; }; if (!initdecl_identifier) { // didn't find identifier when needed message_header(src.data<0>()[i+decl_count+decl_offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declarator has no name to declare (C++98 7p1)"); zcc_errors.inc_error(); // find the next semicolon, unless we have () immediately in which case we have nothing to look for const bool unwind_to_compound_statement = is_naked_parentheses_pair(src.data<0>()[i+decl_count+decl_offset]); if (unwind_to_compound_statement) { assert(!have_we_parsed_yet); src.DeleteNSlotsAt<0>(decl_count+decl_offset+initdecl_span,i); } else{ //! \todo test suite/Jan. 22 2011 does not exercise. Is this dead code? const size_t remove_these = span_to_semicolon(src.data<0>()+i+decl_count+decl_offset,src.end<0>()); if (have_we_parsed_yet) src.DeleteNSlotsAt<0>(remove_these,i+decl_count+decl_offset); else src.DeleteNSlotsAt<0>(remove_these+decl_count+decl_offset+(src.size<0>()>i+remove_these+decl_count+decl_offset),i); } break; }; //! \todo analyze decl_specifiers for errors (now have full target type) // something is being declared have_we_parsed_yet = true; if (C99_CPP0X_DECLSPEC_TYPEDEF & declFind.get_flags()) { // typedef register_token<0>(*initdecl_identifier); char* namespace_name = active_namespace ? type_system::namespace_concatenate(initdecl_identifier->index_tokens[0].token.first,active_namespace,"::") : NULL; const char* fullname = namespace_name ? namespace_name : initdecl_identifier->index_tokens[0].token.first; // We could run an is_string_registered check to try to conserve RAM, but in this case conserving RAM // doesn't actually reduce maximum RAM loading before the types.set_typedef_CPP call. if (const type_system::object_type_loc_linkage* const tmp = parse_tree::types->get_object(fullname)) { //! \bug needs test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("object/function is already declared/defined, conflicts with typedef (C++0X 3.3.10p2)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": object/function declaration/definition here"); zcc_errors.inc_error(); return; }; // verify that there is no prior definition // we're fine redeclaring at a different level, so do not use full C++ typedef lookup if (const zaimoni::POD_triple<type_spec,const char*,size_t>* const tmp = parse_tree::types->get_typedef(fullname)) { if (bootstrap==tmp->first) { // warn if there is a prior, consistent definition //! \test zcc/decl.C99/Warn_redeclare_typedef.hpp //! \todo control this warning with an option --no-OAOO or --no-DRY message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(WARN_STR); INC_INFORM("redeclaring typedef "); INFORM(fullname); INC_INFORM(tmp->second); INC_INFORM(':'); INC_INFORM(tmp->third); INFORM(": prior typedef"); if (bool_options[boolopt::warnings_are_errors]) zcc_errors.inc_error(); } else{ // error if there is a prior, inconsistent definition //! \test zcc/decl.C99/Error_redeclare_typedef.hpp message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INC_INFORM("redeclaring typedef "); INFORM(fullname); INC_INFORM(tmp->second); INC_INFORM(':'); INC_INFORM(tmp->third); INFORM(": prior typedef"); zcc_errors.inc_error(); } // do not re-register if there is a prior definition free(namespace_name); } else{ // register this with types object if (const type_system::enumerator_info* const tmp2 = parse_tree::types->get_enumerator(fullname)) { //! \test zcc/decl.C99/Error_typedef_enum.hpp //! \test zcc/decl.C99/Error_typedef_enum2.hpp free(namespace_name); message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator is already defined, conflicts with typedef (C++98 3.2)"); INC_INFORM(tmp2->second.second.first); INC_INFORM(":"); INC_INFORM(tmp2->second.second.second.first); INFORM(": enumerator definition here"); zcc_errors.inc_error(); return; } free(namespace_name); parse_tree::types->set_typedef_CPP(initdecl_identifier->index_tokens[0].token.first,active_namespace,initdecl_identifier->index_tokens[0].src_filename,initdecl_identifier->index_tokens[0].logical_line.first,bootstrap); } } // for routing purposes, we care about: extern, static, thread_local // function definitions also care about inline // we must reject redeclarations that are not equivalent type (only exception is presence/absence of major array bound) else{ register_token<0>(*initdecl_identifier); char* namespace_name = active_namespace ? type_system::namespace_concatenate(initdecl_identifier->index_tokens[0].token.first,active_namespace,"::") : NULL; const char* fullname = namespace_name ? namespace_name : initdecl_identifier->index_tokens[0].token.first; // objects/functions may hide class names and enumeration names (so these need not be checked, much like C): C++0X 3.3.10/[basic.scope.hiding]p2 // enumerators and typedefs will block object/function declaration: combine ODR and above if (const zaimoni::POD_triple<type_spec,const char*,size_t>* const tmp = parse_tree::types->get_typedef(fullname)) { // typedef: fail free(namespace_name); message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("typedef is already defined, conflicts with object/function (C++0X 3.3.10p2)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": object/function declaration/definition here"); zcc_errors.inc_error(); return; } else if (const type_system::enumerator_info* const tmp2 = parse_tree::types->get_enumerator(fullname)) { // enumerator: fail free(namespace_name); message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("enumerator is already defined, conflicts with object/function (C++98 3.2)"); INC_INFORM(tmp2->second.second.first); INC_INFORM(":"); INC_INFORM(tmp2->second.second.second.first); INFORM(": enumerator definition here"); zcc_errors.inc_error(); return; }; // so...type_system needs to handle following when registering an object/function as well // linkage: static/internal, extern/external // external linkage class: C, C++ // it is an error to have more than one object definition // it is an error to have more than one function type (including parameter list) for a given identifier with C linkage // all declarations must agree regarding thread_local (C++0X 7.1.1p1), which cannot apply to functions (C++0X 7.1.1p4; only extern and static work) // obviously C cannot name most things with C++ linkage const type_system::object_type_loc_linkage* const tmp = parse_tree::types->get_object(fullname); //! \todo react to overloaded function issues here free(namespace_name); if (tmp && tmp->first!=bootstrap) { // check pre-existing type message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("already defined with some other type (this error needs to implement proper incompatible type rejection)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": prior declaration here"); zcc_errors.inc_error(); return; }; //! \todo deal with thread_local here //! \todo deal with extern "C", etc. (should be passing current default language for linkage in, should be reading linkage overrides for declFind) if (C99_CPP0X_DECLSPEC_STATIC & declFind.get_flags()) { // explicit static. // pre-existing extern declaration is an error: C++0X 7.1.1p8 explicit_static: if (tmp) { if (type_system::linkage_static!=tmp->fourth) { //! \bug need test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("already defined with some linkage other than static at global scope (C++0X 7.1.1p8)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": prior declaration here"); zcc_errors.inc_error(); return; } //! \bug need test case // if we were already static, redeclaration so ignore } else{ // new declaration // this will have to be modified to pass in _Thread_local as well parse_tree::types->set_object_CPP(initdecl_identifier->index_tokens[0].token.first, active_namespace, initdecl_identifier->index_tokens[0].src_filename, initdecl_identifier->index_tokens[0].logical_line.first, bootstrap, type_system::linkage_static); } } else if (C99_CPP0X_DECLSPEC_EXTERN & declFind.get_flags()) { // explicit extern. // pre-existing static declaration is an error: C++0X 7.1.1p8 explicit_extern: if (tmp) { if (type_system::linkage_extern_CPP!=tmp->fourth) { //! \bug need test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(ERR_STR); INFORM("already defined with some linkage other than extern at global scope (C++0X 7.1.1p8)"); INC_INFORM(tmp->second); INC_INFORM(":"); INC_INFORM(tmp->third); INFORM(": prior declaration here"); zcc_errors.inc_error(); return; } //! \bug need test case // if we were already extern, redeclaration so ignore } else{ // new declaration // this will have to be modified to pass in _Thread_local as well parse_tree::types->set_object_CPP(initdecl_identifier->index_tokens[0].token.first, active_namespace, initdecl_identifier->index_tokens[0].src_filename, initdecl_identifier->index_tokens[0].logical_line.first, bootstrap, type_system::linkage_extern_CPP); } } else{ // something else: C++ defaults to extern no matter what for global functions and objects. // const objects default to static. All others default to enclosing namespace. // we need a cross-lang warning for global const objects as C will default to extern then // redeclaration will go with whatever was there previously bool default_static = bootstrap.CPP_global_linkage_is_static(); if (default_static) { if (bool_options[boolopt::warn_crosslang_compatibility]) { //! \bug need test case message_header(initdecl_identifier->index_tokens[0]); INC_INFORM(WARN_STR); INFORM("global const objects have default linkage extern in C, static in C++"); if (bool_options[boolopt::warnings_are_errors]) { //! \bug need test case zcc_errors.inc_error(); return; } } goto explicit_static; // handle as static }; goto explicit_extern; // handle as extern } }; decl_offset += initdecl_span; if (src.size<0>()-(i+decl_count)<=decl_offset) { // unterminated declaration: error //! \test zcc/decl.C99/Error_scope.hpp message_header(src.data<0>()[i].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration cut off by end of scope (C++98 7p1)"); zcc_errors.inc_error(); return; }; //! \todo function declarations can be self-terminating // ;: done if (robust_token_is_char<';'>(src.data<0>()[i+decl_count+decl_offset])) { src.c_array<0>()[i+decl_count+decl_offset].flags |= parse_tree::GOOD_LINE_BREAK; ++decl_offset; break; }; // ,: iterate // anything else: error if (!robust_token_is_char<','>(src.data<0>()[i+decl_count+decl_offset])) { //! \test decl.C99/Error_enum_runon_def.hpp message_header(src.data<0>()[i+decl_count+decl_offset].index_tokens[0]); INC_INFORM(ERR_STR); INFORM("declaration disoriented by missing , (C++98 7p1)"); zcc_errors.inc_error(); // remove everything starting here through next semicolon src.DeleteNSlotsAt<0>(span_to_semicolon(src.data<0>()+i+decl_count+decl_offset,src.end<0>()),i+decl_count+decl_offset); src.c_array<0>()[i+decl_count+decl_offset].flags |= parse_tree::GOOD_LINE_BREAK; ++decl_offset; break; } ++decl_offset; } while(src.size<0>()>(i+decl_count+decl_offset)); i += decl_count+decl_offset; continue; } } ++i; } } //! \throw std::bad_alloc static void CPP_ContextParse(parse_tree& src) { CPP_ParseNamespace(src,NULL); } PP_auxfunc C99_aux = { LengthOfCSystemHeader, CPurePreprocessingOperatorPunctuationCode, CPurePreprocessingOperatorPunctuationFlags, C_like_BalancingCheck, C99_ControlExpressionContextFreeErrorCount, C99_CondenseParseTree, C99_EvalParseTree, C99_PPHackTree, ConcatenateCStringLiterals, C99_bad_syntax_tokenized, C99_echo_reserved_keyword, C99_echo_reserved_symbol, C99_ContextFreeParse, C99_ContextParse, C99_locate_expressions, C99_literal_converts_to_bool }; PP_auxfunc CPlusPlus_aux = { LengthOfCPPSystemHeader, CPPPurePreprocessingOperatorPunctuationCode, CPPPurePreprocessingOperatorPunctuationFlags, C_like_BalancingCheck, CPP_ControlExpressionContextFreeErrorCount, CPP_CondenseParseTree, CPP_EvalParseTree, CPP_PPHackTree, ConcatenateCStringLiterals, CPP_bad_syntax_tokenized, CPP_echo_reserved_keyword, CPP_echo_reserved_symbol, CPP_ContextFreeParse, CPP_ContextParse, CPP_locate_expressions, CPP_literal_converts_to_bool }; #if 0 // this is causing crashes post-exit static void clear_lexer_defs(void) { delete CLexer; delete CPlusPlusLexer; } #endif void InitializeCLexerDefs(const virtual_machine::CPUInfo& target) { // main code target_machine = &target; CLexer = new LangConf( "//", // C99, should be NULL for C90, C94 "/*", "*/", &C_IsLegalSourceChar, &IsCIdentifierChar, NULL, NULL, LengthOfEscapedCString, EscapeCString, LengthOfUnescapedCString, UnescapeCString, "'\"", C_WHITESPACE, // prepare LangConf change to test for all-but-first WS character C_ATOMIC_CHAR, valid_keyword+C_KEYWORD_NONSTRICT_LB,C_KEYWORD_STRICT_UB-C_KEYWORD_NONSTRICT_LB, &C99_aux, 0,2, '\\','\\',true,true); CPlusPlusLexer = new LangConf( "//", "/*", "*/", &C_IsLegalSourceChar, &IsCIdentifierChar, NULL, NULL, LengthOfEscapedCString, // think we're fine for C++98 EscapeCString, LengthOfUnescapedCString, UnescapeCString, "'\"", C_WHITESPACE, // prepare LangConf change to test for all-but-first WS character C_ATOMIC_CHAR, valid_keyword+CPP_KEYWORD_NONSTRICT_LB,CPP_KEYWORD_STRICT_UB-CPP_KEYWORD_NONSTRICT_LB, &CPlusPlus_aux, 0,2, '\\','\\',true,true); CLexer->InstallGlobalFilter(&TrimMandatoryTerminalNewline); CLexer->InstallGlobalFilter(&TerminalLineContinue); CLexer->InstallGlobalFilter(&EnforceCTrigraphs); CLexer->InstallGlobalFilter(&FlattenUNICODE); CLexer->InstallTokenizer(&LengthOfCCharLiteral,CPP_FLAG_CHAR_LITERAL); CLexer->InstallTokenizer(&LengthOfCStringLiteral,CPP_FLAG_STRING_LITERAL); CLexer->InstallTokenizer(&LengthOfCPurePreprocessingOperatorPunctuation,CPP_FLAG_PP_OP_PUNC); CLexer->InstallTokenizer(&LengthOfCIdentifier,CPP_FLAG_IDENTIFIER); CLexer->InstallTokenizer(&LengthOfCPreprocessingNumber,CPP_FLAG_PP_NUMERAL); CPlusPlusLexer->InstallGlobalFilter(&TrimMandatoryTerminalNewline); CPlusPlusLexer->InstallGlobalFilter(&TerminalLineContinue); CPlusPlusLexer->InstallGlobalFilter(&EnforceCTrigraphs); CPlusPlusLexer->InstallGlobalFilter(&FlattenUNICODE); CPlusPlusLexer->InstallTokenizer(&LengthOfCCharLiteral,CPP_FLAG_CHAR_LITERAL); CPlusPlusLexer->InstallTokenizer(&LengthOfCStringLiteral,CPP_FLAG_STRING_LITERAL); CPlusPlusLexer->InstallTokenizer(&LengthOfCPPPurePreprocessingOperatorPunctuation,CPP_FLAG_PP_OP_PUNC); CPlusPlusLexer->InstallTokenizer(&LengthOfCIdentifier,CPP_FLAG_IDENTIFIER); CPlusPlusLexer->InstallTokenizer(&LengthOfCPreprocessingNumber,CPP_FLAG_PP_NUMERAL); #if 0 if (atexit(clear_lexer_defs)) FATAL("atexit handler not installed"); #endif // integrity checks on the data definitions // do the constants match the function calls assert(C_TYPE::NOT_VOID==linear_find("$not-void",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::INTEGERLIKE==linear_find("$integer-like",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::VOID==linear_find("void",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::CHAR==linear_find("char",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::SCHAR==linear_find("signed char",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::UCHAR==linear_find("unsigned char",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::SHRT==linear_find("short",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::USHRT==linear_find("unsigned short",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::INT==linear_find("int",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::UINT==linear_find("unsigned",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::LONG==linear_find("long",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::ULONG==linear_find("unsigned long",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::LLONG==linear_find("long long",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::ULLONG==linear_find("unsigned long long",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::FLOAT==linear_find("float",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::DOUBLE==linear_find("double",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::LDOUBLE==linear_find("long double",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::BOOL==linear_find("_Bool",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::FLOAT__COMPLEX==linear_find("float _Complex",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::DOUBLE__COMPLEX==linear_find("double _Complex",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::LDOUBLE__COMPLEX==linear_find("long double _Complex",C_atomic_types,C_TYPE_MAX)+1); assert(C_TYPE::NOT_VOID==linear_find("$not-void",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::INTEGERLIKE==linear_find("$integer-like",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::VOID==linear_find("void",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::CHAR==linear_find("char",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::SCHAR==linear_find("signed char",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::UCHAR==linear_find("unsigned char",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::SHRT==linear_find("short",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::USHRT==linear_find("unsigned short",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::INT==linear_find("int",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::UINT==linear_find("unsigned",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::LONG==linear_find("long",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::ULONG==linear_find("unsigned long",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::LLONG==linear_find("long long",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::ULLONG==linear_find("unsigned long long",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::FLOAT==linear_find("float",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::DOUBLE==linear_find("double",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::LDOUBLE==linear_find("long double",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::BOOL==linear_find("bool",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::FLOAT__COMPLEX==linear_find("float _Complex",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::DOUBLE__COMPLEX==linear_find("double _Complex",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::LDOUBLE__COMPLEX==linear_find("long double _Complex",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C_TYPE::WCHAR_T==linear_find("wchar_t",CPP_atomic_types,CPP_TYPE_MAX)+1); assert(C99_CPP_TYPEDEF_IDX==linear_find("typedef",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_TYPEDEF_IDX==linear_find("typedef",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_CONST_IDX==linear_find("const",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_CONST_IDX==linear_find("const",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_CONST_IDX==linear_find("const",C99_nontype_decl_specifier_list,STATIC_SIZE(C99_nontype_decl_specifier_list))); assert(C99_CPP_CONST_IDX==linear_find("const",CPP0X_nontype_decl_specifier_list,STATIC_SIZE(CPP0X_nontype_decl_specifier_list))); assert(C99_CPP_VOLATILE_IDX==linear_find("volatile",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_VOLATILE_IDX==linear_find("volatile",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_VOLATILE_IDX==linear_find("volatile",C99_nontype_decl_specifier_list,STATIC_SIZE(C99_nontype_decl_specifier_list))); assert(C99_CPP_VOLATILE_IDX==linear_find("volatile",CPP0X_nontype_decl_specifier_list,STATIC_SIZE(CPP0X_nontype_decl_specifier_list))); assert(C99_RESTRICT_IDX==linear_find("restrict",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_REGISTER_IDX==linear_find("register",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_REGISTER_IDX==linear_find("register",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_STATIC_IDX==linear_find("static",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_STATIC_IDX==linear_find("static",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_EXTERN_IDX==linear_find("extern",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_EXTERN_IDX==linear_find("extern",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_AUTO_IDX==linear_find("auto",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_AUTO_IDX==linear_find("auto",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_CHAR_IDX==linear_find("char",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_CHAR_IDX==linear_find("char",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_SHORT_IDX==linear_find("short",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_SHORT_IDX==linear_find("short",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_INT_IDX==linear_find("int",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_INT_IDX==linear_find("int",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_LONG_IDX==linear_find("long",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_LONG_IDX==linear_find("long",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_FLOAT_IDX==linear_find("float",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_FLOAT_IDX==linear_find("float",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_DOUBLE_IDX==linear_find("double",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_DOUBLE_IDX==linear_find("double",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_SIGNED_IDX==linear_find("signed",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_SIGNED_IDX==linear_find("signed",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_UNSIGNED_IDX==linear_find("unsigned",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_UNSIGNED_IDX==linear_find("unsigned",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_COMPLEX_IDX==linear_find("_Complex",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_COMPLEX_IDX==linear_find("_Complex",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C99_CPP_COMPLEX_IDX==linear_find("_Complex",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C99_CPP_COMPLEX_IDX==linear_find("_Complex",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(C1X_CPP0X_THREAD_LOCAL_IDX==linear_find("_Thread_local",C99_decl_specifier_list,STATIC_SIZE(C99_decl_specifier_list))); assert(C1X_CPP0X_THREAD_LOCAL_IDX==linear_find("thread_local",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); assert(CPP_MUTABLE_IDX==linear_find("mutable",CPP0X_decl_specifier_list,STATIC_SIZE(CPP0X_decl_specifier_list))); /* does bool converts_to_integerlike(size_t base_type_index) work */ BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::NOT_VOID && C_TYPE::NOT_VOID<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::VOID && C_TYPE::VOID<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::BOOL && C_TYPE::BOOL<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::CHAR && C_TYPE::CHAR<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::SCHAR && C_TYPE::SCHAR<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::UCHAR && C_TYPE::UCHAR<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::SHRT && C_TYPE::SHRT<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::USHRT && C_TYPE::USHRT<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::INT && C_TYPE::INT<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::UINT && C_TYPE::UINT<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::LONG && C_TYPE::LONG<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::ULONG && C_TYPE::ULONG<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::LLONG && C_TYPE::LLONG<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::ULLONG && C_TYPE::ULLONG<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(C_TYPE::BOOL<=C_TYPE::INTEGERLIKE && C_TYPE::INTEGERLIKE<=C_TYPE::INTEGERLIKE); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::FLOAT && C_TYPE::FLOAT<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::DOUBLE && C_TYPE::DOUBLE<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::LDOUBLE && C_TYPE::LDOUBLE<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::FLOAT__COMPLEX && C_TYPE::FLOAT__COMPLEX<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::DOUBLE__COMPLEX && C_TYPE::DOUBLE__COMPLEX<=C_TYPE::INTEGERLIKE)); BOOST_STATIC_ASSERT(!(C_TYPE::BOOL<=C_TYPE::LDOUBLE__COMPLEX && C_TYPE::LDOUBLE__COMPLEX<=C_TYPE::INTEGERLIKE)); }
[ "zaimoni@b4372a03-5d62-0410-814a-8f46757a0b64" ]
[ [ [ 1, 16226 ] ] ]
ac5f045bae5ed01d5e916ba83d7bb6028da744b9
563e71cceb33a518f53326838a595c0f23d9b8f3
/v2/POC/POC/VBO.cpp
8e9a405a0abf7ba2888c084ebdffe444a68796f9
[]
no_license
fabio-miranda/procedural
3d937037d63dd16cd6d9e68fe17efde0688b5a0a
e2f4b9d34baa1315e258613fb0ea66d1235a63f0
refs/heads/master
2021-05-28T18:13:57.833985
2009-10-07T21:09:13
2009-10-07T21:09:13
39,636,279
1
1
null
null
null
null
UTF-8
C++
false
false
2,069
cpp
#include "VBO.h" VBO::VBO(){ //m_vertexSize = vertexSize; //m_indexSize = indexSize; //m_oldVertexSize = m_vertexSize; //m_oldIndexSize = m_indexSize; //m_vertexArray = new Vertex[m_vertexSize]; //m_indexArray = new GLuint[m_indexSize]; // Generate And Bind The Vertex Buffer glGenBuffersARB( 1, &m_vboVertices ); // Get A Valid Name glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_vboVertices ); // Bind The Buffer // Generate And Bind The Indix Buffer glGenBuffersARB(1, &m_vboIndices); // Get A Valid Name glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_vboIndices); // Bind The Buffer VBO::FillBuffer(); } /* void VBO::IncreaseVertexSize(int add){ m_vertexSize+=add; } void VBO::IncreaseIndexSize(int add){ m_indexSize+=add; } int VBO::GetVertexSize(){ return m_vertexSize; } */ int VBO::GetIndexSize(){ return m_listIndex.size(); } void VBO::DeleteBuffer(){ //Delete the buffers glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_vboVertices ); glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_listVertex.size()*sizeof(Vertex), NULL, GL_DYNAMIC_DRAW_ARB); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_vboIndices ); glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_listIndex.size()*sizeof(GLuint), NULL, GL_DYNAMIC_DRAW_ARB); } void VBO::FillBuffer(){ //Replace the buffers glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_vboVertices ); glBufferDataARB(GL_ARRAY_BUFFER_ARB, ((int)m_listVertex.size())*sizeof(Vertex), &m_listVertex, GL_DYNAMIC_DRAW_ARB); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_vboIndices ); glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ((int)m_listIndex.size())*sizeof(GLuint), &m_listIndex, GL_DYNAMIC_DRAW_ARB); //m_oldVertexSize = m_vertexSize; //m_oldIndexSize = m_indexSize; } void VBO::Render(){ glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer( 3, GL_FLOAT, 0, 0); glPolygonMode(GL_FRONT, GL_LINE); glDrawElements( GL_QUADS, m_listIndex.size(), GL_UNSIGNED_INT, 0); glDisableClientState(GL_VERTEX_ARRAY); }
[ "fabiom@01b71de8-32d4-11de-96ab-f16d9912eac9" ]
[ [ [ 1, 83 ] ] ]
f33e97e589f80f962d37841dc7ddb46da84443d2
975d45994f670a7f284b0dc88d3a0ebe44458a82
/servidor/WarBugsServer/WarBugsServer/Includes/CVendedor.cpp
b34a1115d99c1b8b16acd0d20608cb14536bb3b8
[]
no_license
phabh/warbugs
2b616be17a54fbf46c78b576f17e702f6ddda1e6
bf1def2f8b7d4267fb7af42df104e9cdbe0378f8
refs/heads/master
2020-12-25T08:51:02.308060
2010-11-15T00:37:38
2010-11-15T00:37:38
60,636,297
0
0
null
null
null
null
ISO-8859-2
C++
false
false
8,850
cpp
/* * Classe CVendedor * * Autor: Eder Figueiredo * * Objetivo: Descrever cada personagem vendedor * */ #ifndef _CVENDEDOR_CPP_ #define _CVENDEDOR_CPP_ #include "CVendedor.h" #ifndef _CCENARIO_H_ #include "CCenario.h" #ifndef _CCENARIO_H_ class CCenario; #endif #endif #ifndef _MARKET_ #define _MARKET_ SMarket *mercado; #endif CVendedor::CVendedor() { initCPersonagem(); setID(-1); coordenada = new Ponto(); dinheiro = 0; habilidadesPrimarias = new CHabilidades(); bonusPrimario = new CBonusPrimario(); inventario = new CBolsa(); habilidadesSecundarias = new CHabilidadesSecundarias(); bonusSecundario = new CBonusSecundario(); status = new CBuffList(); setState(E_PARADO); setMoney(0); setBolsa(new CBolsa()); setStats(new CHabilidadesSecundarias()); setBonus(new CBonusSecundario()); setBaseStats(new CHabilidades()); setBaseBonus(new CBonusPrimario()); setBuffs(new CBuffList()); } CVendedor::CVendedor(EstadoPersonagem estado, int dinheiro, CBolsa *inventario, Ponto *ancora) { setID(-1); _ancora = ancora; setState(estado); setMoney(dinheiro); setBolsa(inventario); setPosition(ancora); setStats(new CHabilidadesSecundarias()); setBonus(new CBonusSecundario()); setBaseStats(new CHabilidades()); setBaseBonus(new CBonusPrimario()); setBuffs(new CBuffList()); } void CVendedor::init() { mercado->init(); } //Métodos da economia void CVendedor::plusDemand(int typeItem) { if(typeItem < MAXITEMTYPES) { mercado->_itemDemanda[typeItem] = mercado->_itemDemanda[typeItem] + 1; if(mercado->_itemDemanda[typeItem] > mercado->_maxDemanda) { mercado->_maxDemanda = mercado->_itemDemanda[typeItem]; } } else { //ERRO: Out of bounds } } void CVendedor::plusOffer(int typeItem) { if(typeItem < MAXITEMTYPES) { mercado->_itemOferta[typeItem] = mercado->_itemOferta[typeItem] + 1; if(mercado->_itemOferta[typeItem] > mercado->_maxOferta) { mercado->_maxOferta = mercado->_itemOferta[typeItem]; } } else { //ERRO: Out of bounds } } int CVendedor::normalizeDemand(int typeItem) { if(typeItem < MAXITEMTYPES) { return((mercado->_itemDemanda[typeItem] + (0-mercado->_minDemanda))/((0-mercado->_minDemanda)+mercado->_maxDemanda)); } else { return(0); //ERRO: Out of bounds } } int CVendedor::normalizeOffer(int typeItem) { if(typeItem < MAXITEMTYPES) { return((mercado->_itemOferta[typeItem] + (0-mercado->_minOferta))/((0-mercado->_minOferta)+mercado->_maxOferta)); } else { return(0); //ERRO: Out of bounds } } int CVendedor::stockValue(CItem *item) { return(mercado->_precoBase[(int)item->getType()]+(mercado->_precoBase[(int)item->getType()]+((item->getDurability()-mercado->_MEDIANADURABILIDADE)/100))+(mercado->_precoBase[(int)item->getType()]+((normalizeDemand((int)item->getType())-mercado->_MEDIANADEMANDA)/100))+((normalizeOffer((int)item->getType())-mercado->_MEDIANAOFERTA)/100)); } void CVendedor::setLeftToGoal() { _restanteMeta = 0; for(int i = 0; i < inventario->size(); i = i + 1) { _restanteMeta = _restanteMeta + stockValue(inventario->getElementAt(i)); } _restanteMeta = _restanteMeta + getMoney(); _porcentagem = _meta/_restanteMeta; } int CVendedor::getSellingPrice(CItem *item) { return(stockValue(item)*_porcentagem); } int CVendedor::getBuyPrice(CItem *item) { return(stockValue(item)*_porcentagem/2); } int CVendedor::getFinalPriceSell(CItem *item, CPersonagemJogador *jogador) { return(getSellingPrice(item)-(getSellingPrice(item)*(jogador->getLoyalty()->getLoyaltyTo(this->getRace())/1000)*(mercado->_DESCONTOLEALDADE/100))-(getSellingPrice(item)*(_tempoSemVender/10)*(mercado->_DESCONTOTEMPO/100))); } int CVendedor::getFinalPriceBuy(CItem *item, CPersonagemJogador *jogador) { return(getBuyPrice(item)-(getBuyPrice(item)*(jogador->getLoyalty()->getLoyaltyTo(this->getRace())/1000)*(mercado->_DESCONTOLEALDADE/100))-(getBuyPrice(item)*(_tempoSemVender/10)*(mercado->_DESCONTOTEMPO/100))); } //Outros métodos void CVendedor::takeDecision() { int tempLinha = 0, tempColuna = 0; Ponto *tempPos = new Ponto(); if(this->getDistanceToPoint(_ancora) >= 100) { destino = _ancora; } else { tempPos->x = this->getPosition()->x; tempPos->z = this->getPosition()->z; this->getScene()->getQuadLinhaColuna(tempPos, tempLinha, tempColuna); switch((clock()%8)) { case 0: if((tempLinha > 0)&&(tempColuna < (MAPMAXCOL-1))) { tempPos = this->getScene()->getQuadCenter(tempLinha-1, tempColuna+1); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 1: if(tempColuna < (MAPMAXCOL-1)) { tempPos = this->getScene()->getQuadCenter(tempLinha, tempColuna+1); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 2: if((tempLinha < (MAPMAXCOL-1))&&(tempColuna < (MAPMAXCOL-1))) { tempPos = this->getScene()->getQuadCenter(tempLinha+1, tempColuna+1); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 3: if(tempLinha > 0) { tempPos = this->getScene()->getQuadCenter(tempLinha-1, tempColuna); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 4: if(tempLinha < (MAPMAXCOL-1)) { tempPos = this->getScene()->getQuadCenter(tempLinha+1, tempColuna); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 5: if((tempLinha > 0)&&(tempColuna > 0)) { tempPos = this->getScene()->getQuadCenter(tempLinha-1, tempColuna-1); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 6: if(tempColuna > 0) { tempPos = this->getScene()->getQuadCenter(tempLinha, tempColuna-1); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; case 7: if((tempLinha < (MAPMAXCOL-1))&&(tempColuna > 0)) { tempPos = this->getScene()->getQuadCenter(tempLinha+1, tempColuna-1); if(this->getScene()->matrizDeCaminhamento[tempLinha][tempColuna] == PASSAVEL) { destino = this->getScene()->getQuadCenter(tempPos); } else { destino = this->getPosition(); } } break; } } } void CVendedor::speak() { destino->x = this->getPosition()->x; destino->z = this->getPosition()->z; } void CVendedor::buy(CPersonagemJogador *vendedor, CItem *item) { int preco = getFinalPriceBuy(item, vendedor); if((vendedor->haveItem(item)) && (getMoney() >= preco)) { vendedor->getBolsa()->removeItem(item->getID()); vendedor->addMoney(preco); this->addMoney((-1)*preco); getBolsa()->addItem(item); plusOffer(item->getType()); } } void CVendedor::sell(CPersonagemJogador *comprador, CItem *item) { int preco = getFinalPriceSell(item, comprador); if((getBolsa()->haveItem(item->getID())) && (comprador->getMoney() >= preco)) { getBolsa()->removeItem(item->getID()); comprador->addMoney((-1)*preco); this->addMoney(preco); comprador->getBolsa()->addItem(item); plusDemand(item->getType()); } } int CVendedor::getDEF() { return(this->getStats()->getDefense()); } bool CVendedor::tryAttack() { return(true); } void CVendedor::attack() { } void CVendedor::takeDamage(int damage, CPersonagem *atkr) { this->getStats()->addPV((-1)*damage); divisorxp->addAttacker(atkr, damage); } void CVendedor::die() { } void CVendedor::useItem(CItem *item) { } void CVendedor::update() { status->executeBuffs(this, this->status); if((destino->x != this->getPosition()->x)||(destino->z != this->getPosition()->z)) { this->move(); } else { this->takeDecision(); } } #endif
[ [ [ 1, 343 ] ] ]
9d5e890a6930ff0e38b4b830889208f08af93c41
778b3a71ae1533a346084cc02d13743821af9479
/game_framework/src/game_framework.cxx
9f482a4b1fd4ba64aceffccf82dbc0a83684bc4e
[]
no_license
texnician/game_engine
c2ead57d764a619a4dc7d007c840dfe3a1246240
f94de90ddcee083f3aa7b3b260ce62b91bcfdaa1
refs/heads/master
2016-09-01T19:53:30.968957
2011-09-01T06:40:10
2011-09-01T06:40:10
2,306,271
0
0
null
null
null
null
UTF-8
C++
false
false
357,021
cxx
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 2.0.5 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #define SWIG_PYTHON_NO_BUILD_NONE #define SWIG_PYTHON_DIRECTOR_NO_VTABLE #define SWIGPYTHON_BUILTIN #ifdef __cplusplus /* SwigValueWrapper is described in swig.swg */ template<typename T> class SwigValueWrapper { struct SwigMovePointer { T *ptr; SwigMovePointer(T *p) : ptr(p) { } ~SwigMovePointer() { delete ptr; } SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); SwigValueWrapper(const SwigValueWrapper<T>& rhs); public: SwigValueWrapper() : pointer(0) { } SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; } }; template <typename T> T SwigValueInit() { return T(); } #endif /* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) # define SWIGTEMPLATEDISAMBIGUATOR template # elif defined(__HP_aCC) /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ # define SWIGTEMPLATEDISAMBIGUATOR template # else # define SWIGTEMPLATEDISAMBIGUATOR # endif #endif /* inline attribute */ #ifndef SWIGINLINE # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline # else # define SWIGINLINE # endif #endif /* attribute recognised by some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ # endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else # define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif /* internal SWIG method */ #ifndef SWIGINTERN # define SWIGINTERN static SWIGUNUSED #endif /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif /* exporting methods */ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif #endif #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif /* calling conventions for Windows */ #ifndef SWIGSTDCALL # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL # endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif /* Python.h has to appear first */ #include <Python.h> /* ----------------------------------------------------------------------------- * swigrun.swg * * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE # define SWIG_QUOTE_STRING(x) #x # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else # define SWIG_TYPE_TABLE_NAME #endif /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ #ifndef SWIGRUNTIME # define SWIGRUNTIME SWIGINTERN #endif #ifndef SWIGRUNTIMEINLINE # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif /* Generic buffer size */ #ifndef SWIG_BUFFER_SIZE # define SWIG_BUFFER_SIZE 1024 #endif /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 /* Flags/methods for returning states. The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code } else { //fail code } Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { // success code } else { // fail code } which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); if (SWIG_IsOK(res)) { // success code if (SWIG_IsNewObj(res) { ... delete *ptr; } else { ... } } else { // fail code } I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if (<obj is ok>) { if (<need new object>) { *ptr = <ptr to new allocated object>; return SWIG_NEWOBJ; } else { *ptr = <ptr to old object>; return SWIG_OLDOBJ; } } else { return SWIG_BADOBJ; } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this int food(double) int fooi(int); and you call food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) /* The NewMask denotes the object was created (using new/malloc) */ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) /* The TmpMask is for in/out typemaps that use temporal objects */ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) /* Simple returning values */ #define SWIG_BADOBJ (SWIG_ERROR) #define SWIG_OLDOBJ (SWIG_OK) #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) /* Check, add and del mask methods */ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank # define SWIG_TypeRank unsigned long # endif # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ # define SWIG_MAXCASTRANK (2) # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif #include <string.h> #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ struct swig_cast_info *cast; /* linked list of types that can cast into this type */ void *clientdata; /* language specific type data */ int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { swig_type_info *type; /* pointer to type that is equivalent to this type */ swig_converter_func converter; /* function to cast the void pointers */ struct swig_cast_info *next; /* pointer to next cast in linked list */ struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ size_t size; /* Number of types in this module */ struct swig_module_info *next; /* Pointer to next element in circularly linked list */ swig_type_info **type_initial; /* Array of initially generated type structures */ swig_cast_info **cast_initial; /* Array of initially generated casting structures */ void *clientdata; /* Language specific module data */ } swig_module_info; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class<int>" == "Class<int >", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (int)((l1 - f1) - (l2 - f2)); } /* Check type equivalence in a name list like <name1>|<name2>|... Return 0 if not equal, 1 if equal */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; } /* Check type equivalence in a name list like <name1>|<name2>|... Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int SWIG_TypeCompare(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; } /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(iter->type->name, c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (iter->type == from) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (!type) return NULL; if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Set the clientdata field for a type */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { register size_t l = 0; register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { r = i - 1; } else { break; } } else if (compare > 0) { l = i + 1; } } else { break; /* should never happen */ } } while (l <= r); } iter = iter->next; } while (iter != end); return 0; } /* Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { return ret; } else { /* STEP 2: If the type hasn't been found, do a complete search of the str field (the human readable name) */ swig_module_info *iter = start; do { register size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; } iter = iter->next; } while (iter != end); } /* neither found a match */ return 0; } /* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } /* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { *ptr = (void *) 0; return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { char *r = buff; size_t lname = (name ? strlen(name) : 0); if ((2*sz + 2 + lname) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); if (lname) { strncpy(r,name,lname+1); } else { *r = 0; } return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { memset(ptr,0,sz); return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus } #endif /* Errors in SWIG */ #define SWIG_UnknownError -1 #define SWIG_IOError -2 #define SWIG_RuntimeError -3 #define SWIG_IndexError -4 #define SWIG_TypeError -5 #define SWIG_DivisionByZero -6 #define SWIG_OverflowError -7 #define SWIG_SyntaxError -8 #define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 #define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 /* Compatibility macros for Python 3 */ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) #define PyString_AsString(str) PyBytes_AsString(str) #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif #ifndef Py_TYPE # define Py_TYPE(op) ((op)->ob_type) #endif /* SWIG APIs for compatibility of both Python 2 & 3 */ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat #else # define SWIG_Python_str_FromFormat PyString_FromFormat #endif /* Warning: This function will allocate a new string in Python 3, * so please call SWIG_Python_str_DelForPy3(x) to free the space. */ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 char *cstr; char *newstr; Py_ssize_t len; str = PyUnicode_AsUTF8String(str); PyBytes_AsStringAndSize(str, &cstr, &len); newstr = (char *) malloc(len+1); memcpy(newstr, cstr, len+1); Py_XDECREF(str); return newstr; #else return PyString_AsString(str); #endif } #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #else # define SWIG_Python_str_DelForPy3(x) #endif SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromString(c); #else return PyString_FromString(c); #endif } /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif #endif /* A crude PyString_FromFormat implementation for old Pythons */ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE # define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * PyString_FromFormat(const char *fmt, ...) { va_list ap; char buf[SWIG_PYBUFFER_SIZE * 2]; int res; va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 # define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # ifndef PyExc_StopIteration # define PyExc_StopIteration PyExc_RuntimeError # endif # ifndef PyObject_GenericGetAttr # define PyObject_GenericGetAttr 0 # endif #endif /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented # define Py_NotImplemented PyExc_RuntimeError # endif #endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} # endif #endif /* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 # ifndef PySequence_Size # define PySequence_Size PySequence_Length # endif #endif /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static PyObject *PyBool_FromLong(long ok) { PyObject *result = ok ? Py_True : Py_False; Py_INCREF(result); return result; } #endif /* Py_ssize_t for old Pythons */ /* This code is as recommended by: */ /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX # define PY_SSIZE_T_MIN INT_MIN typedef inquiry lenfunc; typedef intargfunc ssizeargfunc; typedef intintargfunc ssizessizeargfunc; typedef intobjargproc ssizeobjargproc; typedef intintobjargproc ssizessizeobjargproc; typedef getreadbufferproc readbufferproc; typedef getwritebufferproc writebufferproc; typedef getsegcountproc segcountproc; typedef getcharbufferproc charbufferproc; static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) { long result = 0; PyObject *i = PyNumber_Int(x); if (i) { result = PyInt_AsLong(i); Py_DECREF(i); } return result; } #endif #if PY_VERSION_HEX < 0x02040000 #define Py_VISIT(op) \ do { \ if (op) { \ int vret = visit((op), arg); \ if (vret) \ return vret; \ } \ } while (0) #endif #if PY_VERSION_HEX < 0x02030000 typedef struct { PyTypeObject type; PyNumberMethods as_number; PyMappingMethods as_mapping; PySequenceMethods as_sequence; PyBufferProcs as_buffer; PyObject *name, *slots; } PyHeapTypeObject; #endif #if PY_VERSION_HEX < 0x02030000 typedef destructor freefunc; #endif #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ (PY_MAJOR_VERSION > 3)) # define SWIGPY_USE_CAPSULE # define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #endif #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) #endif /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { PyObject* type = 0; switch(code) { case SWIG_MemoryError: type = PyExc_MemoryError; break; case SWIG_IOError: type = PyExc_IOError; break; case SWIG_RuntimeError: type = PyExc_RuntimeError; break; case SWIG_IndexError: type = PyExc_IndexError; break; case SWIG_TypeError: type = PyExc_TypeError; break; case SWIG_DivisionByZero: type = PyExc_ZeroDivisionError; break; case SWIG_OverflowError: type = PyExc_OverflowError; break; case SWIG_SyntaxError: type = PyExc_SyntaxError; break; case SWIG_ValueError: type = PyExc_ValueError; break; case SWIG_SystemError: type = PyExc_SystemError; break; case SWIG_AttributeError: type = PyExc_AttributeError; break; default: type = PyExc_RuntimeError; } return type; } SWIGRUNTIME void SWIG_Python_AddErrorMsg(const char* mesg) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS # endif #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ # define SWIG_PYTHON_USE_GIL # endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { bool status; PyGILState_STATE state; public: void end() { if (status) { PyGILState_Release(state); status = false;} } SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} ~SWIG_Python_Thread_Block() { end(); } }; class SWIG_Python_Thread_Allow { bool status; PyThreadState *save; public: void end() { if (status) { PyEval_RestoreThread(save); status = false; }} SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} ~SWIG_Python_Thread_Allow() { end(); } }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() # else /* C code */ # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) # endif # else /* Old thread way, not implemented, user must provide it */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # define SWIG_PYTHON_INITIALIZE_THREADS # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) # define SWIG_PYTHON_THREAD_END_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # endif # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) # define SWIG_PYTHON_THREAD_END_ALLOW # endif # endif #else /* No thread support */ # define SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # define SWIG_PYTHON_THREAD_END_BLOCK # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # define SWIG_PYTHON_THREAD_END_ALLOW #endif /* ----------------------------------------------------------------------------- * Python API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ #if PY_VERSION_HEX >= 0x03000000 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { return PyInstanceMethod_New(func); } #else SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) { return NULL; } #endif #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) #ifdef SWIGPYTHON_BUILTIN #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) #else #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #endif #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(errtype, obj); Py_DECREF(obj); SWIG_PYTHON_THREAD_END_BLOCK; } SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(errtype, (char *) msg); SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) /* Set a constant value */ #if defined(SWIGPYTHON_BUILTIN) SWIGINTERN void SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { PyObject *s = PyString_InternFromString(key); PyList_Append(seq, s); Py_DECREF(s); } SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { PyDict_SetItemString(d, (char *)name, obj); Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); } #else SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { PyDict_SetItemString(d, (char *)name, obj); Py_DECREF(obj); } #endif /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyList_Check(result)) { PyObject *o2 = result; result = PyList_New(1); PyList_SetItem(result, 0, o2); } PyList_Append(result,obj); Py_DECREF(obj); } return result; #else PyObject* o2; PyObject* o3; if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyTuple_Check(result)) { o2 = result; result = PyTuple_New(1); PyTuple_SET_ITEM(result, 0, o2); } o3 = PyTuple_New(1); PyTuple_SET_ITEM(o3, 0, obj); o2 = result; result = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return result; #endif } /* Unpack the argument tuple */ SWIGINTERN int SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", name, (min == max ? "" : "at least "), (int)min); return 0; } } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { register int i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; } return 2; } PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { register int i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* Helper for static pointer initialization for both C and C++ code, for example static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); */ #ifdef __cplusplus #define SWIG_STATIC_POINTER(var) var #else #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var #endif /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Flags for new pointer objects */ #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) #ifdef __cplusplus extern "C" { #endif /* How to access Py_None */ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # ifndef SWIG_PYTHON_NO_BUILD_NONE # ifndef SWIG_PYTHON_BUILD_NONE # define SWIG_PYTHON_BUILD_NONE # endif # endif #endif #ifdef SWIG_PYTHON_BUILD_NONE # ifdef Py_None # undef Py_None # define Py_None SWIG_Py_None() # endif SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; } /* SwigPyClientData */ typedef struct { PyObject *klass; PyObject *newraw; PyObject *newargs; PyObject *destroy; int delargs; int implicitconv; PyTypeObject *pytype; } SwigPyClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } SWIGRUNTIME SwigPyClientData * SwigPyClientData_New(PyObject* obj) { if (!obj) { return 0; } else { SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; data->newargs = obj; Py_INCREF(obj); } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; #else data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); PyTuple_SetItem(data->newargs, 0, obj); } else { data->newargs = obj; } Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); #ifdef METH_O data->delargs = !(flags & (METH_O)); #else data->delargs = 0; #endif } else { data->delargs = 0; } data->implicitconv = 0; data->pytype = 0; return data; } } SWIGRUNTIME void SwigPyClientData_Del(SwigPyClientData *data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } /* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; #ifdef SWIGPYTHON_BUILTIN PyObject *dict; #endif } SwigPyObject; SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * SwigPyObject_format(const char* fmt, SwigPyObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 res = PyUnicode_Format(ofmt,args); #else res = PyString_Format(ofmt,args); #endif Py_DECREF(ofmt); } Py_DECREF(args); } } return res; } SWIGRUNTIME PyObject * SwigPyObject_oct(SwigPyObject *v) { return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * SwigPyObject_hex(SwigPyObject *v) { return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) #else SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, (void *)v); if (v->next) { # ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); # else PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); # endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); Py_DecRef(nrep); repr = joined; # else PyString_ConcatAndDel(&repr,nrep); # endif } return repr; } SWIGRUNTIME int SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *str; #ifdef METH_NOARGS PyObject *repr = SwigPyObject_repr(v); #else PyObject *repr = SwigPyObject_repr(v, NULL); #endif if (repr) { str = SWIG_Python_str_AsChar(repr); fputs(str, fp); SWIG_Python_str_DelForPy3(str); Py_DECREF(repr); return 0; } else { return 1; } } SWIGRUNTIME PyObject * SwigPyObject_str(SwigPyObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? SWIG_Python_str_FromChar(result) : 0; } SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } /* Added for Python 3.x, would it also be useful for Python 2.x? */ SWIGRUNTIME PyObject* SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { PyObject* res; if( op != Py_EQ && op != Py_NE ) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); return res; } SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; assert(cd); assert(cd->pytype); return cd->pytype; } #else SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); return type; } #endif SWIGRUNTIMEINLINE int SwigPyObject_Check(PyObject *op) { #ifdef SWIGPYTHON_BUILTIN PyTypeObject *target_tp = SwigPyObject_type(); if (PyType_IsSubtype(op->ob_type, target_tp)) return 1; return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); #else return (Py_TYPE(op) == SwigPyObject_type()) || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); #endif } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void SwigPyObject_dealloc(PyObject *v) { SwigPyObject *sobj = (SwigPyObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) else { const char *name = SWIG_TypePrettyName(ty); printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } #endif } Py_XDECREF(next); PyObject_DEL(v); } SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif if (!SwigPyObject_Check(next)) { return NULL; } sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* #ifdef METH_NOARGS SwigPyObject_next(PyObject* v) #else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_disown(PyObject *v) #else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_acquire(PyObject *v) #else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) #else if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) #endif { return NULL; } else { SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v); } else { SwigPyObject_disown(v); } #else if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v,args); } else { SwigPyObject_disown(v,args); } #endif } return obj; } } #ifdef METH_O static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * SwigPyObject_getattr(SwigPyObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } #endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; static PyNumberMethods SwigPyObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ /* nb_divide removed in Python 3 */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ #endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ (unaryfunc)0, /*nb_negative*/ (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif (unaryfunc)SwigPyObject_long, /*nb_int*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_long, /*nb_long*/ #else 0, /*nb_reserved*/ #endif (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ (printfunc)SwigPyObject_print, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif (reprfunc)SwigPyObject_repr, /* tp_repr */ &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyObject_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpyobject_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; #endif } return &swigpyobject_type; } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; sobj->own = own; sobj->next = 0; } return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- * Implements a simple Swig Packed type, and use it instead of string * ----------------------------------------------------------------------------- */ typedef struct { PyObject_HEAD void *pack; swig_type_info *ty; size_t size; } SwigPyPacked; SWIGRUNTIME int SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("<Swig Packed ", fp); if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { fputs("at ", fp); fputs(result, fp); } fputs(v->ty->name,fp); fputs(">", fp); return 0; } SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); } else { return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); } } SWIGRUNTIME PyObject * SwigPyPacked_str(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { return SWIG_Python_str_FromChar(v->ty->name); } } SWIGRUNTIME int SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); return type; } SWIGRUNTIMEINLINE int SwigPyPacked_Check(PyObject *op) { return ((op)->ob_type == SwigPyPacked_TypeOnce()) || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); } SWIGRUNTIME void SwigPyPacked_dealloc(PyObject *v) { if (SwigPyPacked_Check(v)) { SwigPyPacked *sobj = (SwigPyPacked *) v; free(sobj->pack); } PyObject_DEL(v); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; static PyTypeObject swigpypacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 0, /* tp_reserved in 3.0.1 */ #else (cmpfunc)SwigPyPacked_compare, /* tp_compare */ #endif (reprfunc)SwigPyPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigpacked_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpypacked_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; #endif } return &swigpypacked_type; } SWIGRUNTIME PyObject * SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { memcpy(pack, ptr, size); sobj->pack = pack; sobj->ty = ty; sobj->size = size; } else { PyObject_DEL((PyObject *) sobj); sobj = 0; } } return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { if (SwigPyPacked_Check(obj)) { SwigPyPacked *sobj = (SwigPyPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { return SWIG_Python_str_FromChar("this"); } static PyObject *swig_this = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { if (swig_this == NULL) swig_this = _SWIG_This(); return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ /* TODO: I don't know how to implement the fast getset in Python 3 right now */ #if PY_VERSION_HEX>=0x03000000 #define SWIG_PYTHON_SLOW_GETSET_THIS #endif SWIGRUNTIME SwigPyObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { PyObject *obj; if (SwigPyObject_Check(pyobj)) return (SwigPyObject *) pyobj; #ifdef SWIGPYTHON_BUILTIN (void)obj; # ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { pyobj = PyWeakref_GET_OBJECT(pyobj); if (pyobj && SwigPyObject_Check(pyobj)) return (SwigPyObject*) pyobj; } # endif return NULL; #else obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { PyObject **dictptr = _PyObject_GetDictPtr(pyobj); if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } } } #else obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } #endif if (obj && !SwigPyObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' SwigPyObject from it */ return SWIG_Python_GetSwigThis(obj); } return (SwigPyObject *)obj; #endif } /* Acquire a pointer value */ SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; return oldown; } } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; if (!obj) return SWIG_ERROR; if (obj == Py_None) { if (ptr) *ptr = 0; return SWIG_OK; } res = SWIG_ERROR; sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { swig_type_info *to = sobj->ty; if (to == ty) { /* no type cast needed */ if (ptr) *ptr = vptr; break; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { sobj = (SwigPyObject *)sobj->next; } else { if (ptr) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } break; } } } else { if (ptr) *ptr = vptr; break; } } if (sobj) { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } res = SWIG_OK; } else { if (flags & SWIG_POINTER_IMPLICIT_CONV) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { PyObject *impconv; data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ impconv = SWIG_Python_CallFunctor(klass, obj); data->implicitconv = 0; if (PyErr_Occurred()) { PyErr_Clear(); impconv = 0; } if (impconv) { SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); if (SWIG_IsOK(res)) { if (ptr) { *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { res = SWIG_AddCast(res); } } } Py_DECREF(impconv); } } } } } return res; } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { if (!PyCFunction_Check(obj)) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; if (!desc) return SWIG_ERROR; if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return SWIG_ERROR; } } else { *ptr = vptr; } return SWIG_OK; } } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Create a new pointer object * ----------------------------------------------------------------------------- */ /* Create a new instance object, without calling __init__, and set the 'this' attribute. */ SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { inst = PyObject_Call(newraw, data->newargs, NULL); if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { PyObject *dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; PyDict_SetItem(dict, SWIG_This(), swig_this); } } #else PyObject *key = SWIG_This(); PyObject_SetAttr(inst, key, swig_this); #endif } } else { #if PY_VERSION_HEX >= 0x03000000 inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; #else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); #endif } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) PyObject *inst; PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; } inst->in_class = (PyClassObject *)data->newargs; Py_INCREF(inst->in_class); inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { Py_DECREF(inst); return NULL; } #ifdef Py_TPFLAGS_HAVE_WEAKREFS inst->in_weakreflist = NULL; #endif #ifdef Py_TPFLAGS_GC PyObject_GC_Init(inst); #endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif #endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; } PyDict_SetItem(dict, SWIG_This(), swig_this); return; } #endif dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } return SWIG_Py_Void(); } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { SwigPyClientData *clientdata; PyObject * robj; int own; if (!ptr) return SWIG_Py_Void(); clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; if (clientdata && clientdata->pytype) { SwigPyObject *newobj; if (flags & SWIG_BUILTIN_TP_INIT) { newobj = (SwigPyObject*) self; if (newobj->ptr) { PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); while (newobj->next) newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; #ifdef SWIGPYTHON_BUILTIN newobj->dict = 0; #endif return (PyObject*) newobj; } return SWIG_Py_Void(); } assert(!(flags & SWIG_BUILTIN_TP_INIT)); robj = SwigPyObject_New(ptr, type, own); if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); if (inst) { Py_DECREF(robj); robj = inst; } } return robj; } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else # ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif } return (swig_module_info *) type_pointer; } #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ SWIGINTERN int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) return SWIG_ERROR; Py_DECREF(o); return SWIG_OK; } #endif SWIGRUNTIME void #ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) #else SWIG_Python_DestroyModule(void *vptr) #endif { #ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); #else swig_module_info *swig_module = (swig_module_info *) vptr; #endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); swig_this = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif #ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #else PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #endif } /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { #ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); #else descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); #endif } else { swig_module_info *swig_module = SWIG_Python_GetModule(); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { #ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); #else obj = PyCObject_FromVoidPtr(descriptor, NULL); #endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } } Py_DECREF(key); return descriptor; } /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; } else { return 0; } } SWIGRUNTIME int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } SWIGRUNTIMEINLINE const char * SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : (char*)""; } SWIGRUNTIME void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) if (obj && SwigPyObject_Check(obj)) { const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", type, otype); return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_XDECREF(str); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); #if SWIG_POINTER_EXCEPTION if (flags) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } #endif } return result; } SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; PyObject *descr; PyObject *encoded_name; descrsetfunc f; int res; #ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) #else if (!PyString_Check(name)) #endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; } else { Py_INCREF(name); } if (!tp->tp_dict) { if (PyType_Ready(tp) < 0) goto done; } res = -1; descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) f = descr->ob_type->tp_descr_set; if (!f) { if (PyString_Check(name)) { encoded_name = name; Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); } else { res = f(descr, obj, value); } done: Py_DECREF(name); return res; } #ifdef __cplusplus } #endif #define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ return wrapper(a, NULL); \ } #define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ SWIGINTERN void \ wrapper##_closure(PyObject *a) { \ SwigPyObject *sobj; \ sobj = (SwigPyObject *)a; \ if (sobj->own) { \ PyObject *o = wrapper(a, NULL); \ Py_XDECREF(o); \ } \ } #define SWIGPY_INQUIRY_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a) { \ PyObject *pyresult; \ int result; \ pyresult = wrapper(a, NULL); \ result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \ Py_XDECREF(pyresult); \ return result; \ } #define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ Py_XINCREF(b); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(b); \ Py_XINCREF(c); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_LENFUNC_CLOSURE(wrapper) \ SWIGINTERN Py_ssize_t \ wrapper##_closure(PyObject *a) { \ PyObject *resultobj; \ Py_ssize_t result; \ resultobj = wrapper(a, NULL); \ result = PyNumber_AsSsize_t(resultobj, NULL); \ Py_DECREF(resultobj); \ return result; \ } #define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(d ? 3 : 2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \ if (d) { \ PyTuple_SET_ITEM(tuple, 2, d); \ Py_INCREF(d); \ } \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_DECREF(tuple); \ Py_XDECREF(resultobj); \ return result; \ } #define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *arg, *result; \ arg = _PyLong_FromSsize_t(b); \ result = wrapper(a, arg); \ Py_DECREF(arg); \ return result; \ } #define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(c); \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_XDECREF(resultobj); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(c ? 2 : 1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ Py_XINCREF(b); \ if (c) { \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(c); \ } \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_XDECREF(resultobj); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_REPRFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ return wrapper(a, NULL); \ } #define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ SWIGINTERN long \ wrapper##_closure(PyObject *a) { \ PyObject *pyresult; \ long result; \ pyresult = wrapper(a, NULL); \ if (!pyresult || !PyLong_Check(pyresult)) \ return -1; \ result = PyLong_AsLong(pyresult); \ Py_DECREF(pyresult); \ return result; \ } #define SWIGPY_ITERNEXT_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ PyObject *result; \ result = wrapper(a, NULL); \ if (result && result == Py_None) { \ Py_DECREF(result); \ result = NULL; \ } \ return result; \ } #ifdef __cplusplus extern "C" { #endif SWIGINTERN int SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) { PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name); return -1; } SWIGINTERN void SwigPyBuiltin_BadDealloc(PyObject *pyobj) { SwigPyObject *sobj; sobj = (SwigPyObject *)pyobj; if (sobj->own) { PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name); } } typedef struct { PyCFunction get; PyCFunction set; } SwigPyGetSet; SWIGINTERN PyObject * SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) { SwigPyGetSet *getset; PyObject *tuple, *result; if (!closure) return SWIG_Py_Void(); getset = (SwigPyGetSet *)closure; if (!getset->get) return SWIG_Py_Void(); tuple = PyTuple_New(0); assert(tuple); result = (*getset->get)(obj, tuple); Py_DECREF(tuple); return result; } SWIGINTERN PyObject * SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) { SwigPyGetSet *getset; PyObject *result; if (!closure) return SWIG_Py_Void(); getset = (SwigPyGetSet *)closure; if (!getset->get) return SWIG_Py_Void(); result = (*getset->get)(obj, NULL); return result; } SWIGINTERN int SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { SwigPyGetSet *getset; PyObject *tuple, *result; if (!closure) { PyErr_Format(PyExc_TypeError, "Missing getset closure"); return -1; } getset = (SwigPyGetSet *)closure; if (!getset->set) { PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); return -1; } tuple = PyTuple_New(1); assert(tuple); PyTuple_SET_ITEM(tuple, 0, val); Py_XINCREF(val); result = (*getset->set)(obj, tuple); Py_DECREF(tuple); Py_XDECREF(result); return result ? 0 : -1; } SWIGINTERN int SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) { SwigPyGetSet *getset; PyObject *result; if (!closure) { PyErr_Format(PyExc_TypeError, "Missing getset closure"); return -1; } getset = (SwigPyGetSet *)closure; if (!getset->set) { PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); return -1; } result = (*getset->set)(obj, val); Py_XDECREF(result); return result ? 0 : -1; } SWIGINTERN void SwigPyStaticVar_dealloc(PyDescrObject *descr) { _PyObject_GC_UNTRACK(descr); Py_XDECREF(PyDescr_TYPE(descr)); Py_XDECREF(PyDescr_NAME(descr)); PyObject_GC_Del(descr); } SWIGINTERN PyObject * SwigPyStaticVar_repr(PyGetSetDescrObject *descr) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromFormat("<class attribute '%S' of type '%s'>", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif } SWIGINTERN int SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) { PyDescrObject *descr; descr = (PyDescrObject *)self; Py_VISIT((PyObject*) PyDescr_TYPE(descr)); return 0; } SWIGINTERN PyObject * SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) { if (descr->d_getset->get != NULL) return descr->d_getset->get(obj, descr->d_getset->closure); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif return NULL; } SWIGINTERN int SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) { if (descr->d_getset->set != NULL) return descr->d_getset->set(obj, value, descr->d_getset->closure); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif return -1; } SWIGINTERN int SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) { PyObject *attribute; descrsetfunc local_set; attribute = _PyType_Lookup(type, name); if (attribute != NULL) { /* Implement descriptor functionality, if any */ local_set = attribute->ob_type->tp_descr_set; if (local_set != NULL) return local_set(attribute, (PyObject *)type, value); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name); #else PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name)); #endif } else { #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name); #else PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name)); #endif } return -1; } SWIGINTERN PyTypeObject* SwigPyStaticVar_Type(void) { static PyTypeObject staticvar_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else PyObject_HEAD_INIT(&PyType_Type) 0, #endif "swig_static_var_getset_descriptor", sizeof(PyGetSetDescrObject), 0, (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)SwigPyStaticVar_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ 0, /* tp_doc */ SwigPyStaticVar_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */ (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; staticvar_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 staticvar_type.ob_type = &PyType_Type; #else if (PyType_Ready(&staticvar_type) < 0) return NULL; #endif } return &staticvar_type; } SWIGINTERN PyGetSetDescrObject * SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { PyGetSetDescrObject *descr; descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0); assert(descr); Py_XINCREF(type); PyDescr_TYPE(descr) = type; PyDescr_NAME(descr) = PyString_InternFromString(getset->name); descr->d_getset = getset; if (PyDescr_NAME(descr) == NULL) { Py_DECREF(descr); descr = NULL; } return descr; } SWIGINTERN void SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { int base_count = 0; PyTypeObject **b; PyObject *tuple; int i; if (!bases[0]) { bases[0] = SwigPyObject_type(); bases[1] = NULL; } type->tp_base = bases[0]; Py_INCREF((PyObject *)bases[0]); for (b = bases; *b != NULL; ++b) ++base_count; tuple = PyTuple_New(base_count); for (i = 0; i < base_count; ++i) { PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); Py_INCREF((PyObject *)bases[i]); } type->tp_bases = tuple; } SWIGINTERN PyObject * SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { PyObject *result; result = (PyObject *)SWIG_Python_GetSwigThis(self); Py_XINCREF(result); return result; } SWIGINTERN void SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) { #if PY_VERSION_HEX >= 0x03000000 type->ob_base.ob_base.ob_type = metatype; #else type->ob_type = metatype; #endif } #ifdef __cplusplus } #endif #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_ACC_INFO swig_types[0] #define SWIGTYPE_p_HandlableObject swig_types[1] #define SWIGTYPE_p_ObjectHandlerT_HandlableObject_t swig_types[2] #define SWIGTYPE_p_ObjectPtrTable swig_types[3] #define SWIGTYPE_p_Opt swig_types[4] #define SWIGTYPE_p_PKG_TEST_ACK swig_types[5] #define SWIGTYPE_p_PKG_TEST_REQ swig_types[6] #define SWIGTYPE_p_Protocol swig_types[7] #define SWIGTYPE_p_ROLE_INFO swig_types[8] #define SWIGTYPE_p_SwigPyObject swig_types[9] #define SWIGTYPE_p___int64 swig_types[10] #define SWIGTYPE_p_char swig_types[11] #define SWIGTYPE_p_float swig_types[12] #define SWIGTYPE_p_int swig_types[13] #define SWIGTYPE_p_long swig_types[14] #define SWIGTYPE_p_p_char swig_types[15] #define SWIGTYPE_p_p_unsigned_long swig_types[16] #define SWIGTYPE_p_short swig_types[17] #define SWIGTYPE_p_signed___int64 swig_types[18] #define SWIGTYPE_p_signed_char swig_types[19] #define SWIGTYPE_p_size_t swig_types[20] #define SWIGTYPE_p_unsigned___int64 swig_types[21] #define SWIGTYPE_p_unsigned_char swig_types[22] #define SWIGTYPE_p_unsigned_int swig_types[23] #define SWIGTYPE_p_unsigned_long swig_types[24] #define SWIGTYPE_p_unsigned_short swig_types[25] static swig_type_info *swig_types[27]; static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) /* -------- TYPES TABLE (END) -------- */ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) # error "This python version requires swig to be run with the '-classic' option" # endif #endif #if (PY_VERSION_HEX <= 0x02020000) # error "This python version requires swig to be run with the '-nomodern' option" #endif #if (PY_VERSION_HEX <= 0x02020000) # error "This python version requires swig to be run with the '-nomodernargs' option" #endif #ifndef METH_O # error "This python version requires swig to be run with the '-nofastunpack' option" #endif #ifdef SWIG_TypeQuery # undef SWIG_TypeQuery #endif #define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- @(target):= _gf.so ------------------------------------------------*/ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_init PyInit__gf #else # define SWIG_init init_gf #endif #define SWIG_name "_gf" #define SWIGVERSION 0x020005 #define SWIG_VERSION SWIGVERSION #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) #include <stdexcept> namespace swig { class SwigPtr_PyObject { protected: PyObject *_obj; public: SwigPtr_PyObject() :_obj(0) { } SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) { Py_XINCREF(_obj); } SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { Py_XINCREF(_obj); } } SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) { Py_XINCREF(item._obj); Py_XDECREF(_obj); _obj = item._obj; return *this; } ~SwigPtr_PyObject() { Py_XDECREF(_obj); } operator PyObject *() const { return _obj; } PyObject *operator->() const { return _obj; } }; } namespace swig { struct SwigVar_PyObject : SwigPtr_PyObject { SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } SwigVar_PyObject & operator = (PyObject* obj) { Py_XDECREF(_obj); _obj = obj; return *this; } }; } #include "object_ptr_table.h" #include "object_handler.h" #include "protocol.h" #define SWIG_From_long PyInt_FromLong SWIGINTERNINLINE PyObject* SWIG_From_unsigned_SS_long (unsigned long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value)); } SWIGINTERNINLINE PyObject * SWIG_From_unsigned_SS_int (unsigned int value) { return SWIG_From_unsigned_SS_long (value); } SWIGINTERN int SWIG_AsVal_double (PyObject *obj, double *val) { int res = SWIG_TypeError; if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; double d = PyFloat_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = d; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { PyErr_Clear(); } } } #endif return res; } #include <float.h> #include <math.h> SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { double fx = floor(x); double cx = ceil(x); double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { double summ, reps, diff; if (rd < x) { diff = x - rd; } else if (rd > x) { diff = rd - x; } else { return 1; } summ = rd + x; reps = diff/summ; if (reps < 8*DBL_EPSILON) { *d = rd; return 1; } } } return 0; } SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERNINLINE int SWIG_AsVal_size_t (PyObject * obj, size_t *val) { unsigned long v; int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v); return res; } SWIGINTERNINLINE PyObject* SWIG_From_bool (bool value) { return PyBool_FromLong(value ? 1 : 0); } SWIGINTERNINLINE PyObject * SWIG_From_size_t (size_t value) { return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value)); } SWIGINTERNINLINE PyObject * SWIG_From_int (int value) { return SWIG_From_long (value); } SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_char"); init = 1; } return info; } SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { #if PY_VERSION_HEX>=0x03000000 if (PyUnicode_Check(obj)) #else if (PyString_Check(obj)) #endif { char *cstr; Py_ssize_t len; #if PY_VERSION_HEX>=0x03000000 if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); PyBytes_AsStringAndSize(obj, &cstr, &len); if(alloc) *alloc = SWIG_NEWOBJ; #else PyString_AsStringAndSize(obj, &cstr, &len); #endif if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner string representation. To warranty that, if you define SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string buffer is always returned. The default behavior is just to return the pointer value, so, be careful. */ #if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) #else if (*alloc == SWIG_NEWOBJ) #endif { *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { #if PY_VERSION_HEX>=0x03000000 assert(0); /* Should never reach here in Python 3 */ #endif *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; #if PY_VERSION_HEX>=0x03000000 Py_XDECREF(obj); #endif return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } SWIGINTERN int SWIG_AsCharArray(PyObject * obj, char *val, size_t size) { char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); if (SWIG_IsOK(res)) { if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize; if (csize <= size) { if (val) { if (csize) memcpy(val, cptr, csize*sizeof(char)); if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char)); } if (alloc == SWIG_NEWOBJ) { delete[] cptr; res = SWIG_DelNewMask(res); } return res; } if (alloc == SWIG_NEWOBJ) delete[] cptr; } return SWIG_TypeError; } #include <limits.h> #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) # define LLONG_MAX __LONG_LONG_MAX__ # define LLONG_MIN (-LLONG_MAX - 1LL) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) # endif #endif SWIGINTERN int SWIG_AsVal_long (PyObject *obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERN int SWIG_AsVal_char (PyObject * obj, char *val) { int res = SWIG_AsCharArray(obj, val, 1); if (!SWIG_IsOK(res)) { long v; res = SWIG_AddCast(SWIG_AsVal_long (obj, &v)); if (SWIG_IsOK(res)) { if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { if (val) *val = static_cast< char >(v); } else { res = SWIG_OverflowError; } } } return res; } SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); #else return PyString_FromStringAndSize(carray, static_cast< int >(size)); #endif } } else { return SWIG_Py_Void(); } } SWIGINTERNINLINE PyObject * SWIG_From_char (char c) { return SWIG_FromCharPtrAndSize(&c,1); } SWIGINTERN int SWIG_AsVal_int (PyObject * obj, int *val) { long v; int res = SWIG_AsVal_long (obj, &v); if (SWIG_IsOK(res)) { if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< int >(v); } } return res; } SWIGINTERN int SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) { unsigned long v; int res = SWIG_AsVal_unsigned_SS_long (obj, &v); if (SWIG_IsOK(res)) { if ((v > USHRT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< unsigned short >(v); } } return res; } SWIGINTERNINLINE PyObject * SWIG_From_unsigned_SS_short (unsigned short value) { return SWIG_From_unsigned_SS_long (value); } SWIGINTERN int SWIG_AsVal_short (PyObject * obj, short *val) { long v; int res = SWIG_AsVal_long (obj, &v); if (SWIG_IsOK(res)) { if ((v < SHRT_MIN || v > SHRT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< short >(v); } } return res; } SWIGINTERNINLINE PyObject * SWIG_From_short (short value) { return SWIG_From_long (value); } typedef struct SWIGCDATA { char *data; size_t len; } SWIGCDATA; extern "C" { static SWIGCDATA cdata_void(void *ptr, size_t nelements) { SWIGCDATA d; d.data = (char *) ptr; d.len = nelements; return d; } } static Opt *new_Opt_Array(size_t nelements) { return (new Opt[nelements]); } static void delete_Opt_Array(Opt *ary) { delete[] ary; } static Opt Opt_Array_getitem(Opt *ary, size_t index) { return ary[index]; } static void Opt_Array_setitem(Opt *ary, size_t index, Opt value) { ary[index] = value; } /* Opt */ size_t sizeof_Opt() { return sizeof(Opt); } PyObject* Opt_ArrayFromBuffer(Opt *outArrayBuf, int outArrayItemNumber, const char *inMemBuf, int inMemBufSize) { if (outArrayItemNumber * sizeof(Opt) >= inMemBufSize) { memcpy(outArrayBuf, inMemBuf, inMemBufSize); return PyInt_FromLong(inMemBufSize); } else { return Py_None; } } PyObject* Opt_ArrayToBuffer(char *outMemBuf, int outMemBufSize, Opt *inArrayBuf, int inArrayItemNumber) { size_t in_array_size = sizeof(Opt) * inArrayItemNumber; if (outMemBufSize >= in_array_size) { memcpy(outMemBuf, inArrayBuf, in_array_size); return PyInt_FromLong(in_array_size); } else { return Py_None; } } static unsigned char *new_unsigned_char_Array(size_t nelements) { return (new unsigned char[nelements]); } static void delete_unsigned_char_Array(unsigned char *ary) { delete[] ary; } static unsigned char unsigned_char_Array_getitem(unsigned char *ary, size_t index) { return ary[index]; } static void unsigned_char_Array_setitem(unsigned char *ary, size_t index, unsigned char value) { ary[index] = value; } SWIGINTERNINLINE PyObject * SWIG_From_unsigned_SS_char (unsigned char value) { return SWIG_From_unsigned_SS_long (value); } SWIGINTERN int SWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val) { unsigned long v; int res = SWIG_AsVal_unsigned_SS_long (obj, &v); if (SWIG_IsOK(res)) { if ((v > UCHAR_MAX)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< unsigned char >(v); } } return res; } /* unsigned char */ size_t sizeof_unsigned_char() { return sizeof(unsigned char); } PyObject* unsigned_char_ArrayFromBuffer(unsigned char *outArrayBuf, int outArrayItemNumber, const char *inMemBuf, int inMemBufSize) { if (outArrayItemNumber * sizeof(unsigned char) >= inMemBufSize) { memcpy(outArrayBuf, inMemBuf, inMemBufSize); return PyInt_FromLong(inMemBufSize); } else { return Py_None; } } PyObject* unsigned_char_ArrayToBuffer(char *outMemBuf, int outMemBufSize, unsigned char *inArrayBuf, int inArrayItemNumber) { size_t in_array_size = sizeof(unsigned char) * inArrayItemNumber; if (outMemBufSize >= in_array_size) { memcpy(outMemBuf, inArrayBuf, in_array_size); return PyInt_FromLong(in_array_size); } else { return Py_None; } } static ROLE_INFO *new_ROLE_INFO_Array(size_t nelements) { return (new ROLE_INFO[nelements]); } static void delete_ROLE_INFO_Array(ROLE_INFO *ary) { delete[] ary; } static ROLE_INFO ROLE_INFO_Array_getitem(ROLE_INFO *ary, size_t index) { return ary[index]; } static void ROLE_INFO_Array_setitem(ROLE_INFO *ary, size_t index, ROLE_INFO value) { ary[index] = value; } /* ROLE_INFO */ size_t sizeof_ROLE_INFO() { return sizeof(ROLE_INFO); } PyObject* ROLE_INFO_ArrayFromBuffer(ROLE_INFO *outArrayBuf, int outArrayItemNumber, const char *inMemBuf, int inMemBufSize) { if (outArrayItemNumber * sizeof(ROLE_INFO) >= inMemBufSize) { memcpy(outArrayBuf, inMemBuf, inMemBufSize); return PyInt_FromLong(inMemBufSize); } else { return Py_None; } } PyObject* ROLE_INFO_ArrayToBuffer(char *outMemBuf, int outMemBufSize, ROLE_INFO *inArrayBuf, int inArrayItemNumber) { size_t in_array_size = sizeof(ROLE_INFO) * inArrayItemNumber; if (outMemBufSize >= in_array_size) { memcpy(outMemBuf, inArrayBuf, in_array_size); return PyInt_FromLong(in_array_size); } else { return Py_None; } } static ACC_INFO *new_ACC_INFO_Array(size_t nelements) { return (new ACC_INFO[nelements]); } static void delete_ACC_INFO_Array(ACC_INFO *ary) { delete[] ary; } static ACC_INFO ACC_INFO_Array_getitem(ACC_INFO *ary, size_t index) { return ary[index]; } static void ACC_INFO_Array_setitem(ACC_INFO *ary, size_t index, ACC_INFO value) { ary[index] = value; } /* ACC_INFO */ size_t sizeof_ACC_INFO() { return sizeof(ACC_INFO); } PyObject* ACC_INFO_ArrayFromBuffer(ACC_INFO *outArrayBuf, int outArrayItemNumber, const char *inMemBuf, int inMemBufSize) { if (outArrayItemNumber * sizeof(ACC_INFO) >= inMemBufSize) { memcpy(outArrayBuf, inMemBuf, inMemBufSize); return PyInt_FromLong(inMemBufSize); } else { return Py_None; } } PyObject* ACC_INFO_ArrayToBuffer(char *outMemBuf, int outMemBufSize, ACC_INFO *inArrayBuf, int inArrayItemNumber) { size_t in_array_size = sizeof(ACC_INFO) * inArrayItemNumber; if (outMemBufSize >= in_array_size) { memcpy(outMemBuf, inArrayBuf, in_array_size); return PyInt_FromLong(in_array_size); } else { return Py_None; } } #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_GetUniqObjectId(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectId result; if (!SWIG_Python_UnpackTuple(args,"GetUniqObjectId",0,0,0)) SWIG_fail; result = (ObjectId)GetUniqObjectId(); resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result)); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_HandlableObject(PyObject *self, PyObject *args) { PyObject *resultobj = 0; HandlableObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_HandlableObject",0,0,0)) SWIG_fail; result = (HandlableObject *)new HandlableObject(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_HandlableObject, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_delete_HandlableObject(PyObject *self, PyObject *args) { PyObject *resultobj = 0; HandlableObject *arg1 = (HandlableObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_HandlableObject",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_HandlableObject, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_HandlableObject" "', argument " "1"" of type '" "HandlableObject *""'"); } arg1 = reinterpret_cast< HandlableObject * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_Init(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; bool result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_Init" "', argument " "1"" of type '" "ObjectPtrTable *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ObjectPtrTable_Init" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); result = (bool)(arg1)->Init(arg2); resultobj = SWIG_From_bool(static_cast< bool >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_Release(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; bool result; if (!SWIG_Python_UnpackTuple(args,"ObjectPtrTable_Release",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_Release" "', argument " "1"" of type '" "ObjectPtrTable *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); result = (bool)(arg1)->Release(); resultobj = SWIG_From_bool(static_cast< bool >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_Capacity(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"ObjectPtrTable_Capacity",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_Capacity" "', argument " "1"" of type '" "ObjectPtrTable const *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); result = ((ObjectPtrTable const *)arg1)->Capacity(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_Size(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"ObjectPtrTable_Size",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_Size" "', argument " "1"" of type '" "ObjectPtrTable const *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); result = ((ObjectPtrTable const *)arg1)->Size(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_FreeSize(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"ObjectPtrTable_FreeSize",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_FreeSize" "', argument " "1"" of type '" "ObjectPtrTable const *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); result = ((ObjectPtrTable const *)arg1)->FreeSize(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_Find(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; ObjectSlotIdx arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; HandlableObject *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_Find" "', argument " "1"" of type '" "ObjectPtrTable const *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ObjectPtrTable_Find" "', argument " "2"" of type '" "ObjectSlotIdx""'"); } arg2 = static_cast< ObjectSlotIdx >(val2); result = (HandlableObject *)((ObjectPtrTable const *)arg1)->Find(arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_HandlableObject, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_GetSlotIndex(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; HandlableObject *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; ObjectSlotIdx result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_GetSlotIndex" "', argument " "1"" of type '" "ObjectPtrTable *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_HandlableObject, 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ObjectPtrTable_GetSlotIndex" "', argument " "2"" of type '" "HandlableObject &""'"); } if (!argp2) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ObjectPtrTable_GetSlotIndex" "', argument " "2"" of type '" "HandlableObject &""'"); } arg2 = reinterpret_cast< HandlableObject * >(argp2); result = (arg1)->GetSlotIndex(*arg2); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_FreeSlotIndex(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *arg1 = (ObjectPtrTable *) 0 ; HandlableObject *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; size_t result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ObjectPtrTable_FreeSlotIndex" "', argument " "1"" of type '" "ObjectPtrTable *""'"); } arg1 = reinterpret_cast< ObjectPtrTable * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_HandlableObject, 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ObjectPtrTable_FreeSlotIndex" "', argument " "2"" of type '" "HandlableObject &""'"); } if (!argp2) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ObjectPtrTable_FreeSlotIndex" "', argument " "2"" of type '" "HandlableObject &""'"); } arg2 = reinterpret_cast< HandlableObject * >(argp2); result = (arg1)->FreeSlotIndex(*arg2); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ObjectPtrTable_Instance(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectPtrTable *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ObjectPtrTable_Instance",0,0,0)) SWIG_fail; result = (ObjectPtrTable *)ObjectPtrTable::Instance(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ObjectPtrTable, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_a_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; char arg2 ; void *argp1 = 0 ; int res1 = 0 ; char val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_a_set" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); ecode2 = SWIG_AsVal_char(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Opt_a_set" "', argument " "2"" of type '" "char""'"); } arg2 = static_cast< char >(val2); if (arg1) (arg1)->a = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_a_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char result; if (!SWIG_Python_UnpackTuple(args,"Opt_a_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_a_get" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); result = (char) ((arg1)->a); resultobj = SWIG_From_char(static_cast< char >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_b_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; char arg2 ; void *argp1 = 0 ; int res1 = 0 ; char val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_b_set" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); ecode2 = SWIG_AsVal_char(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Opt_b_set" "', argument " "2"" of type '" "char""'"); } arg2 = static_cast< char >(val2); if (arg1) (arg1)->b = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_b_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char result; if (!SWIG_Python_UnpackTuple(args,"Opt_b_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_b_get" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); result = (char) ((arg1)->b); resultobj = SWIG_From_char(static_cast< char >(result)); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_Opt(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_Opt",0,0,0)) SWIG_fail; result = (Opt *)new Opt(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Opt, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_delete_Opt(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_Opt",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Opt, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Opt" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_id_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_id_set" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ACC_INFO_id_set" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); if (arg1) (arg1)->id = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_id_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_id_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_id_get" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); result = (int) ((arg1)->id); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_username_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; char *arg2 ; void *argp1 = 0 ; int res1 = 0 ; char temp2[10] ; int res2 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_username_set" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); res2 = SWIG_AsCharArray(swig_obj[0], temp2, 10); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ACC_INFO_username_set" "', argument " "2"" of type '" "char [10]""'"); } arg2 = reinterpret_cast< char * >(temp2); if (arg2) memcpy(arg1->username,arg2,10*sizeof(char)); else memset(arg1->username,0,10*sizeof(char)); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_username_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_username_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_username_get" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); result = (char *)(char *) ((arg1)->username); { size_t size = 10; while (size && (result[size - 1] == '\0')) --size; resultobj = SWIG_FromCharPtrAndSize(result, size); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_password_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; char *arg2 ; void *argp1 = 0 ; int res1 = 0 ; char temp2[64] ; int res2 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_password_set" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); res2 = SWIG_AsCharArray(swig_obj[0], temp2, 64); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ACC_INFO_password_set" "', argument " "2"" of type '" "char [64]""'"); } arg2 = reinterpret_cast< char * >(temp2); if (arg2) memcpy(arg1->password,arg2,64*sizeof(char)); else memset(arg1->password,0,64*sizeof(char)); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_password_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_password_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_password_get" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); result = (char *)(char *) ((arg1)->password); { size_t size = 64; while (size && (result[size - 1] == '\0')) --size; resultobj = SWIG_FromCharPtrAndSize(result, size); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_opt_num_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_opt_num_set" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ACC_INFO_opt_num_set" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); if (arg1) (arg1)->opt_num = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_opt_num_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_opt_num_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_opt_num_get" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); result = (int) ((arg1)->opt_num); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_opt_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; Opt *arg2 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_opt_set" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ACC_INFO_opt_set" "', argument " "2"" of type '" "Opt [512]""'"); } arg2 = reinterpret_cast< Opt * >(argp2); { if (arg2) { size_t ii = 0; for (; ii < (size_t)512; ++ii) arg1->opt[ii] = arg2[ii]; } else { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""opt""' of type '""Opt [512]""'"); } } resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_opt_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Opt *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_opt_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_opt_get" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); result = (Opt *)(Opt *) ((arg1)->opt); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Opt, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_ACC_INFO(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_ACC_INFO",0,0,0)) SWIG_fail; result = (ACC_INFO *)new ACC_INFO(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ACC_INFO, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_delete_ACC_INFO(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_ACC_INFO",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ACC_INFO, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ACC_INFO" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_name_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; char *arg2 ; void *argp1 = 0 ; int res1 = 0 ; char temp2[128] ; int res2 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_name_set" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); res2 = SWIG_AsCharArray(swig_obj[0], temp2, 128); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PKG_TEST_REQ_name_set" "', argument " "2"" of type '" "char [128]""'"); } arg2 = reinterpret_cast< char * >(temp2); if (arg2) memcpy(arg1->name,arg2,128*sizeof(char)); else memset(arg1->name,0,128*sizeof(char)); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_name_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_REQ_name_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_name_get" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); result = (char *)(char *) ((arg1)->name); { size_t size = 128; while (size && (result[size - 1] == '\0')) --size; resultobj = SWIG_FromCharPtrAndSize(result, size); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_type_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_type_set" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PKG_TEST_REQ_type_set" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); if (arg1) (arg1)->type = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_type_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_REQ_type_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_type_get" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); result = (int) ((arg1)->type); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_info_num_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_info_num_set" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PKG_TEST_REQ_info_num_set" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); if (arg1) (arg1)->info_num = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_info_num_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_REQ_info_num_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_info_num_get" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); result = (int) ((arg1)->info_num); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_uarray_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; unsigned char *arg2 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_uarray_set" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PKG_TEST_REQ_uarray_set" "', argument " "2"" of type '" "unsigned char [512]""'"); } arg2 = reinterpret_cast< unsigned char * >(argp2); { if (arg2) { size_t ii = 0; for (; ii < (size_t)512; ++ii) arg1->uarray[ii] = arg2[ii]; } else { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""uarray""' of type '""unsigned char [512]""'"); } } resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_uarray_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; unsigned char *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_REQ_uarray_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_uarray_get" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); result = (unsigned char *)(unsigned char *) ((arg1)->uarray); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_acc_info_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; ACC_INFO *arg2 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_acc_info_set" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PKG_TEST_REQ_acc_info_set" "', argument " "2"" of type '" "ACC_INFO [10]""'"); } arg2 = reinterpret_cast< ACC_INFO * >(argp2); { if (arg2) { size_t ii = 0; for (; ii < (size_t)10; ++ii) arg1->acc_info[ii] = arg2[ii]; } else { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""acc_info""' of type '""ACC_INFO [10]""'"); } } resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_REQ_acc_info_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; ACC_INFO *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_REQ_acc_info_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_REQ_acc_info_get" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); result = (ACC_INFO *)(ACC_INFO *) ((arg1)->acc_info); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ACC_INFO, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_PKG_TEST_REQ(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_PKG_TEST_REQ",0,0,0)) SWIG_fail; result = (PKG_TEST_REQ *)new PKG_TEST_REQ(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PKG_TEST_REQ, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_delete_PKG_TEST_REQ(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_REQ *arg1 = (PKG_TEST_REQ *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_PKG_TEST_REQ",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_REQ, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PKG_TEST_REQ" "', argument " "1"" of type '" "PKG_TEST_REQ *""'"); } arg1 = reinterpret_cast< PKG_TEST_REQ * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_title_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; char *arg2 ; void *argp1 = 0 ; int res1 = 0 ; char temp2[128] ; int res2 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_title_set" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); res2 = SWIG_AsCharArray(swig_obj[0], temp2, 128); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ROLE_INFO_title_set" "', argument " "2"" of type '" "char [128]""'"); } arg2 = reinterpret_cast< char * >(temp2); if (arg2) memcpy(arg1->title,arg2,128*sizeof(char)); else memset(arg1->title,0,128*sizeof(char)); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_title_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ROLE_INFO_title_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_title_get" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); result = (char *)(char *) ((arg1)->title); { size_t size = 128; while (size && (result[size - 1] == '\0')) --size; resultobj = SWIG_FromCharPtrAndSize(result, size); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_level_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; unsigned short arg2 ; void *argp1 = 0 ; int res1 = 0 ; unsigned short val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_level_set" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ROLE_INFO_level_set" "', argument " "2"" of type '" "unsigned short""'"); } arg2 = static_cast< unsigned short >(val2); if (arg1) (arg1)->level = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_level_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; unsigned short result; if (!SWIG_Python_UnpackTuple(args,"ROLE_INFO_level_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_level_get" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); result = (unsigned short) ((arg1)->level); resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_ROLE_INFO(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_ROLE_INFO",0,0,0)) SWIG_fail; result = (ROLE_INFO *)new ROLE_INFO(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ROLE_INFO, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_delete_ROLE_INFO(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_ROLE_INFO",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ROLE_INFO, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ROLE_INFO" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_ACK_err_code_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_ACK_err_code_set" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PKG_TEST_ACK_err_code_set" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); if (arg1) (arg1)->err_code = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_ACK_err_code_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_ACK_err_code_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_ACK_err_code_get" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); result = (int) ((arg1)->err_code); resultobj = SWIG_From_int(static_cast< int >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_ACK_num_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; short arg2 ; void *argp1 = 0 ; int res1 = 0 ; short val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_ACK_num_set" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); ecode2 = SWIG_AsVal_short(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PKG_TEST_ACK_num_set" "', argument " "2"" of type '" "short""'"); } arg2 = static_cast< short >(val2); if (arg1) (arg1)->num = arg2; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_ACK_num_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; short result; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_ACK_num_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_ACK_num_get" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); result = (short) ((arg1)->num); resultobj = SWIG_From_short(static_cast< short >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_ACK_info_list_set(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; ROLE_INFO *arg2 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_ACK_info_list_set" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PKG_TEST_ACK_info_list_set" "', argument " "2"" of type '" "ROLE_INFO [10]""'"); } arg2 = reinterpret_cast< ROLE_INFO * >(argp2); { if (arg2) { size_t ii = 0; for (; ii < (size_t)10; ++ii) arg1->info_list[ii] = arg2[ii]; } else { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""info_list""' of type '""ROLE_INFO [10]""'"); } } resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_PKG_TEST_ACK_info_list_get(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; ROLE_INFO *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"PKG_TEST_ACK_info_list_get",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PKG_TEST_ACK_info_list_get" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); result = (ROLE_INFO *)(ROLE_INFO *) ((arg1)->info_list); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ROLE_INFO, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_PKG_TEST_ACK(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_PKG_TEST_ACK",0,0,0)) SWIG_fail; result = (PKG_TEST_ACK *)new PKG_TEST_ACK(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PKG_TEST_ACK, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_delete_PKG_TEST_ACK(PyObject *self, PyObject *args) { PyObject *resultobj = 0; PKG_TEST_ACK *arg1 = (PKG_TEST_ACK *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_PKG_TEST_ACK",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_PKG_TEST_ACK, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PKG_TEST_ACK" "', argument " "1"" of type '" "PKG_TEST_ACK *""'"); } arg1 = reinterpret_cast< PKG_TEST_ACK * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_Protocol(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_Protocol",0,0,0)) SWIG_fail; result = (Protocol *)new Protocol(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Protocol, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN PyObject *_wrap_Protocol_Init(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *arg1 = (Protocol *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; bool result; if (!SWIG_Python_UnpackTuple(args,"Protocol_Init",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Protocol, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Protocol_Init" "', argument " "1"" of type '" "Protocol *""'"); } arg1 = reinterpret_cast< Protocol * >(argp1); result = (bool)(arg1)->Init(); resultobj = SWIG_From_bool(static_cast< bool >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Protocol_Encode(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *arg1 = (Protocol *) 0 ; int arg2 ; void *arg3 = (void *) 0 ; char *arg4 = (char *) 0 ; size_t arg5 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; int res4 ; Py_ssize_t size4 = 0 ; void *buf4 = 0 ; size_t val5 ; int ecode5 = 0 ; PyObject *swig_obj[5] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"Protocol_Encode",4,4,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Protocol, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Protocol_Encode" "', argument " "1"" of type '" "Protocol *""'"); } arg1 = reinterpret_cast< Protocol * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Protocol_Encode" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg3), 0, 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Protocol_Encode" "', argument " "3"" of type '" "void *""'"); } { res4 = PyObject_AsWriteBuffer(swig_obj[2], &buf4, &size4); if (res4<0) { PyErr_Clear(); SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Protocol_Encode" "', argument " "4"" of type '" "(char *out_buf, SIZE)""'"); } arg4 = (char *) buf4; } ecode5 = SWIG_AsVal_size_t(swig_obj[3], &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Protocol_Encode" "', argument " "5"" of type '" "size_t""'"); } arg5 = static_cast< size_t >(val5); result = (arg1)->Encode(arg2,arg3,arg4,arg5); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Protocol_Decode(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *arg1 = (Protocol *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; size_t arg4 ; void *arg5 = (void *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; Py_ssize_t size3 = 0 ; void const *buf3 = 0 ; size_t val4 ; int ecode4 = 0 ; int res5 ; PyObject *swig_obj[5] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"Protocol_Decode",4,4,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Protocol, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Protocol_Decode" "', argument " "1"" of type '" "Protocol *""'"); } arg1 = reinterpret_cast< Protocol * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Protocol_Decode" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); { res3 = PyObject_AsReadBuffer(swig_obj[1], &buf3, &size3); if (res3<0) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Protocol_Decode" "', argument " "3"" of type '" "(char *in_buf, SIZE)""'"); } arg3 = (char *) buf3; } ecode4 = SWIG_AsVal_size_t(swig_obj[2], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Protocol_Decode" "', argument " "4"" of type '" "size_t""'"); } arg4 = static_cast< size_t >(val4); res5 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg5), 0, 0); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Protocol_Decode" "', argument " "5"" of type '" "void *""'"); } result = (arg1)->Decode(arg2,arg3,arg4,arg5); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_Protocol(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *arg1 = (Protocol *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_Protocol",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Protocol, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Protocol" "', argument " "1"" of type '" "Protocol *""'"); } arg1 = reinterpret_cast< Protocol * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ProtocolEncode(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *arg1 = 0 ; int arg2 ; void *arg3 = (void *) 0 ; char *arg4 = (char *) 0 ; size_t arg5 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; int res4 ; Py_ssize_t size4 = 0 ; void *buf4 = 0 ; size_t val5 ; int ecode5 = 0 ; PyObject *swig_obj[5] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"ProtocolEncode",5,5,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_Protocol, 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ProtocolEncode" "', argument " "1"" of type '" "Protocol &""'"); } if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ProtocolEncode" "', argument " "1"" of type '" "Protocol &""'"); } arg1 = reinterpret_cast< Protocol * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ProtocolEncode" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ProtocolEncode" "', argument " "3"" of type '" "void *""'"); } { res4 = PyObject_AsWriteBuffer(swig_obj[3], &buf4, &size4); if (res4<0) { PyErr_Clear(); SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ProtocolEncode" "', argument " "4"" of type '" "(char *out_buf, SIZE)""'"); } arg4 = (char *) buf4; } ecode5 = SWIG_AsVal_size_t(swig_obj[4], &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "ProtocolEncode" "', argument " "5"" of type '" "size_t""'"); } arg5 = static_cast< size_t >(val5); result = ProtocolEncode(*arg1,arg2,arg3,arg4,arg5); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ProtocolDecode(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Protocol *arg1 = 0 ; int arg2 ; char *arg3 = (char *) 0 ; size_t arg4 ; void *arg5 = (void *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; Py_ssize_t size3 = 0 ; void const *buf3 = 0 ; size_t val4 ; int ecode4 = 0 ; int res5 ; PyObject *swig_obj[5] ; size_t result; if (!SWIG_Python_UnpackTuple(args,"ProtocolDecode",5,5,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_Protocol, 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ProtocolDecode" "', argument " "1"" of type '" "Protocol &""'"); } if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ProtocolDecode" "', argument " "1"" of type '" "Protocol &""'"); } arg1 = reinterpret_cast< Protocol * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ProtocolDecode" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); { res3 = PyObject_AsReadBuffer(swig_obj[2], &buf3, &size3); if (res3<0) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ProtocolDecode" "', argument " "3"" of type '" "(char *in_buf, SIZE)""'"); } arg3 = (char *) buf3; } ecode4 = SWIG_AsVal_size_t(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ProtocolDecode" "', argument " "4"" of type '" "size_t""'"); } arg4 = static_cast< size_t >(val4); res5 = SWIG_ConvertPtr(swig_obj[4],SWIG_as_voidptrptr(&arg5), 0, 0); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "ProtocolDecode" "', argument " "5"" of type '" "void *""'"); } result = ProtocolDecode(*arg1,arg2,arg3,arg4,arg5); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN int _wrap_new_GameObjectHandler__SWIG_0(PyObject *self, int nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { PyObject *resultobj = 0; ObjectHandler< HandlableObject > *result = 0 ; if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; result = (ObjectHandler< HandlableObject > *)new ObjectHandler< HandlableObject >(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN int _wrap_new_GameObjectHandler__SWIG_1(PyObject *self, int nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; HandlableObject *arg1 = 0 ; void *argp1 = 0 ; int res1 = 0 ; ObjectHandler< HandlableObject > *result = 0 ; if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_HandlableObject, 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_GameObjectHandler" "', argument " "1"" of type '" "HandlableObject &""'"); } if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_GameObjectHandler" "', argument " "1"" of type '" "HandlableObject &""'"); } arg1 = reinterpret_cast< HandlableObject * >(argp1); result = (ObjectHandler< HandlableObject > *)new ObjectHandler< HandlableObject >(*arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN int _wrap_new_GameObjectHandler__SWIG_2(PyObject *self, int nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; ObjectHandler< HandlableObject > *arg1 = 0 ; void *argp1 = 0 ; int res1 = 0 ; ObjectHandler< HandlableObject > *result = 0 ; if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, 0 | 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_GameObjectHandler" "', argument " "1"" of type '" "ObjectHandler< HandlableObject > const &""'"); } if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_GameObjectHandler" "', argument " "1"" of type '" "ObjectHandler< HandlableObject > const &""'"); } arg1 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp1); result = (ObjectHandler< HandlableObject > *)new ObjectHandler< HandlableObject >((ObjectHandler< HandlableObject > const &)*arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, SWIG_BUILTIN_INIT | 0 ); return resultobj == Py_None ? 1 : 0; fail: return -1; } SWIGINTERN int _wrap_new_GameObjectHandler(PyObject *self, PyObject *args) { int argc; PyObject *argv[2]; if (!(argc = SWIG_Python_UnpackTuple(args,"new_GameObjectHandler",0,1,argv))) SWIG_fail; --argc; if (argc == 0) { return _wrap_new_GameObjectHandler__SWIG_0(self, argc, argv); } if (argc == 1) { int _v = 0; { void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_HandlableObject, 0); _v = SWIG_CheckState(res); } if (!_v) goto check_2; return _wrap_new_GameObjectHandler__SWIG_1(self, argc, argv); } check_2: if (argc == 1) { return _wrap_new_GameObjectHandler__SWIG_2(self, argc, argv); } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_GameObjectHandler'.\n" " Possible C/C++ prototypes are:\n" " ObjectHandler< HandlableObject >::ObjectHandler()\n" " ObjectHandler< HandlableObject >::ObjectHandler(HandlableObject &)\n" " ObjectHandler< HandlableObject >::ObjectHandler(ObjectHandler< HandlableObject > const &)\n"); return -1; } SWIGINTERN PyObject *_wrap_GameObjectHandler_ToObject(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectHandler< HandlableObject > *arg1 = (ObjectHandler< HandlableObject > *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; HandlableObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"GameObjectHandler_ToObject",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GameObjectHandler_ToObject" "', argument " "1"" of type '" "ObjectHandler< HandlableObject > const *""'"); } arg1 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp1); result = (HandlableObject *)((ObjectHandler< HandlableObject > const *)arg1)->ToObject(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_HandlableObject, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GameObjectHandler___eq__(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectHandler< HandlableObject > *arg1 = (ObjectHandler< HandlableObject > *) 0 ; ObjectHandler< HandlableObject > *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; bool result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GameObjectHandler___eq__" "', argument " "1"" of type '" "ObjectHandler< HandlableObject > const *""'"); } arg1 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, 0 | 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GameObjectHandler___eq__" "', argument " "2"" of type '" "ObjectHandler< HandlableObject > const &""'"); } if (!argp2) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GameObjectHandler___eq__" "', argument " "2"" of type '" "ObjectHandler< HandlableObject > const &""'"); } arg2 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp2); result = (bool)((ObjectHandler< HandlableObject > const *)arg1)->operator ==((ObjectHandler< HandlableObject > const &)*arg2); resultobj = SWIG_From_bool(static_cast< bool >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_GameObjectHandler___ne__(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectHandler< HandlableObject > *arg1 = (ObjectHandler< HandlableObject > *) 0 ; ObjectHandler< HandlableObject > *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; bool result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GameObjectHandler___ne__" "', argument " "1"" of type '" "ObjectHandler< HandlableObject > const *""'"); } arg1 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, 0 | 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GameObjectHandler___ne__" "', argument " "2"" of type '" "ObjectHandler< HandlableObject > const &""'"); } if (!argp2) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GameObjectHandler___ne__" "', argument " "2"" of type '" "ObjectHandler< HandlableObject > const &""'"); } arg2 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp2); result = (bool)((ObjectHandler< HandlableObject > const *)arg1)->operator !=((ObjectHandler< HandlableObject > const &)*arg2); resultobj = SWIG_From_bool(static_cast< bool >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_GameObjectHandler(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ObjectHandler< HandlableObject > *arg1 = (ObjectHandler< HandlableObject > *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!SWIG_Python_UnpackTuple(args,"delete_GameObjectHandler",0,0,0)) SWIG_fail; res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ObjectHandlerT_HandlableObject_t, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_GameObjectHandler" "', argument " "1"" of type '" "ObjectHandler< HandlableObject > *""'"); } arg1 = reinterpret_cast< ObjectHandler< HandlableObject > * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_cdata(PyObject *self, PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; size_t arg2 = (size_t) 1 ; int res1 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; SWIGCDATA result; if (!SWIG_Python_UnpackTuple(args,"cdata",1,2,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cdata" "', argument " "1"" of type '" "void *""'"); } if (swig_obj[1]) { ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cdata" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); } result = cdata_void(arg1,arg2); resultobj = SWIG_FromCharPtrAndSize((&result)->data,(&result)->len); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_memmove(PyObject *self, PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; void *arg2 = (void *) 0 ; size_t arg3 ; int res1 ; int res2 ; char *buf2 = 0 ; size_t size2 = 0 ; int alloc2 = 0 ; PyObject *swig_obj[2] ; if (!SWIG_Python_UnpackTuple(args,"memmove",2,2,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "memmove" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, &size2, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "memmove" "', argument " "2"" of type '" "void const *""'"); } arg2 = reinterpret_cast< void * >(buf2); arg3 = static_cast< size_t >(size2); memmove(arg1,(void const *)arg2,arg3); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_Opt_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject *swig_obj[1] ; Opt *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Opt_Array" "', argument " "1"" of type '" "size_t""'"); } arg1 = static_cast< size_t >(val1); result = (Opt *)new_Opt_Array(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Opt, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_Opt_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Opt_Array" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); delete_Opt_Array(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_Array_getitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; Opt result; if (!SWIG_Python_UnpackTuple(args,"Opt_Array_getitem",2,2,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_Array_getitem" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Opt_Array_getitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); result = Opt_Array_getitem(arg1,arg2); resultobj = SWIG_NewPointerObj((new Opt(static_cast< const Opt& >(result))), SWIGTYPE_p_Opt, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_Array_setitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; size_t arg2 ; Opt arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; void *argp3 ; int res3 = 0 ; PyObject *swig_obj[3] ; if (!SWIG_Python_UnpackTuple(args,"Opt_Array_setitem",3,3,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_Array_setitem" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Opt_Array_setitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); { res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_Opt, 0 | 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Opt_Array_setitem" "', argument " "3"" of type '" "Opt""'"); } if (!argp3) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Opt_Array_setitem" "', argument " "3"" of type '" "Opt""'"); } else { Opt * temp = reinterpret_cast< Opt * >(argp3); arg3 = *temp; if (SWIG_IsNewObj(res3)) delete temp; } } Opt_Array_setitem(arg1,arg2,arg3); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_sizeof_Opt(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t result; if (!SWIG_Python_UnpackTuple(args,"sizeof_Opt",0,0,0)) SWIG_fail; result = sizeof_Opt(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_ArrayFromBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Opt *arg1 = (Opt *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; int arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; Py_ssize_t size3 = 0 ; void const *buf3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"Opt_ArrayFromBuffer",4,4,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_ArrayFromBuffer" "', argument " "1"" of type '" "Opt *""'"); } arg1 = reinterpret_cast< Opt * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Opt_ArrayFromBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); { res3 = PyObject_AsReadBuffer(swig_obj[2], &buf3, &size3); if (res3<0) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Opt_ArrayFromBuffer" "', argument " "3"" of type '" "(const char *inMemBuf, SIZE)""'"); } arg3 = (char *) buf3; } ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Opt_ArrayFromBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)Opt_ArrayFromBuffer(arg1,arg2,(char const *)arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_Opt_ArrayToBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; int arg2 ; Opt *arg3 = (Opt *) 0 ; int arg4 ; int res1 ; Py_ssize_t size1 = 0 ; void *buf1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"Opt_ArrayToBuffer",4,4,swig_obj)) SWIG_fail; { res1 = PyObject_AsWriteBuffer(swig_obj[0], &buf1, &size1); if (res1<0) { PyErr_Clear(); SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Opt_ArrayToBuffer" "', argument " "1"" of type '" "(char *outMemBuf, SIZE)""'"); } arg1 = (char *) buf1; } ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Opt_ArrayToBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_Opt, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Opt_ArrayToBuffer" "', argument " "3"" of type '" "Opt *""'"); } arg3 = reinterpret_cast< Opt * >(argp3); ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Opt_ArrayToBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)Opt_ArrayToBuffer(arg1,arg2,arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_unsigned_char_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject *swig_obj[1] ; unsigned char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_unsigned_char_Array" "', argument " "1"" of type '" "size_t""'"); } arg1 = static_cast< size_t >(val1); result = (unsigned char *)new_unsigned_char_Array(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_unsigned_char_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; unsigned char *arg1 = (unsigned char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_unsigned_char_Array" "', argument " "1"" of type '" "unsigned char *""'"); } arg1 = reinterpret_cast< unsigned char * >(argp1); delete_unsigned_char_Array(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_unsigned_char_Array_getitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; unsigned char *arg1 = (unsigned char *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; unsigned char result; if (!SWIG_Python_UnpackTuple(args,"unsigned_char_Array_getitem",2,2,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "unsigned_char_Array_getitem" "', argument " "1"" of type '" "unsigned char *""'"); } arg1 = reinterpret_cast< unsigned char * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "unsigned_char_Array_getitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); result = (unsigned char)unsigned_char_Array_getitem(arg1,arg2); resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_unsigned_char_Array_setitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; unsigned char *arg1 = (unsigned char *) 0 ; size_t arg2 ; unsigned char arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; unsigned char val3 ; int ecode3 = 0 ; PyObject *swig_obj[3] ; if (!SWIG_Python_UnpackTuple(args,"unsigned_char_Array_setitem",3,3,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "unsigned_char_Array_setitem" "', argument " "1"" of type '" "unsigned char *""'"); } arg1 = reinterpret_cast< unsigned char * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "unsigned_char_Array_setitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); ecode3 = SWIG_AsVal_unsigned_SS_char(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "unsigned_char_Array_setitem" "', argument " "3"" of type '" "unsigned char""'"); } arg3 = static_cast< unsigned char >(val3); unsigned_char_Array_setitem(arg1,arg2,arg3); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_sizeof_unsigned_char(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t result; if (!SWIG_Python_UnpackTuple(args,"sizeof_unsigned_char",0,0,0)) SWIG_fail; result = sizeof_unsigned_char(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_unsigned_char_ArrayFromBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; unsigned char *arg1 = (unsigned char *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; int arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; Py_ssize_t size3 = 0 ; void const *buf3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"unsigned_char_ArrayFromBuffer",4,4,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "unsigned_char_ArrayFromBuffer" "', argument " "1"" of type '" "unsigned char *""'"); } arg1 = reinterpret_cast< unsigned char * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "unsigned_char_ArrayFromBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); { res3 = PyObject_AsReadBuffer(swig_obj[2], &buf3, &size3); if (res3<0) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "unsigned_char_ArrayFromBuffer" "', argument " "3"" of type '" "(const char *inMemBuf, SIZE)""'"); } arg3 = (char *) buf3; } ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "unsigned_char_ArrayFromBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)unsigned_char_ArrayFromBuffer(arg1,arg2,(char const *)arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_unsigned_char_ArrayToBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; int arg2 ; unsigned char *arg3 = (unsigned char *) 0 ; int arg4 ; int res1 ; Py_ssize_t size1 = 0 ; void *buf1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"unsigned_char_ArrayToBuffer",4,4,swig_obj)) SWIG_fail; { res1 = PyObject_AsWriteBuffer(swig_obj[0], &buf1, &size1); if (res1<0) { PyErr_Clear(); SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "unsigned_char_ArrayToBuffer" "', argument " "1"" of type '" "(char *outMemBuf, SIZE)""'"); } arg1 = (char *) buf1; } ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "unsigned_char_ArrayToBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "unsigned_char_ArrayToBuffer" "', argument " "3"" of type '" "unsigned char *""'"); } arg3 = reinterpret_cast< unsigned char * >(argp3); ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "unsigned_char_ArrayToBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)unsigned_char_ArrayToBuffer(arg1,arg2,arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_ROLE_INFO_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject *swig_obj[1] ; ROLE_INFO *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_ROLE_INFO_Array" "', argument " "1"" of type '" "size_t""'"); } arg1 = static_cast< size_t >(val1); result = (ROLE_INFO *)new_ROLE_INFO_Array(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ROLE_INFO, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_ROLE_INFO_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ROLE_INFO_Array" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); delete_ROLE_INFO_Array(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_Array_getitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; ROLE_INFO result; if (!SWIG_Python_UnpackTuple(args,"ROLE_INFO_Array_getitem",2,2,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_Array_getitem" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ROLE_INFO_Array_getitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); result = ROLE_INFO_Array_getitem(arg1,arg2); resultobj = SWIG_NewPointerObj((new ROLE_INFO(static_cast< const ROLE_INFO& >(result))), SWIGTYPE_p_ROLE_INFO, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_Array_setitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; size_t arg2 ; ROLE_INFO arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; void *argp3 ; int res3 = 0 ; PyObject *swig_obj[3] ; if (!SWIG_Python_UnpackTuple(args,"ROLE_INFO_Array_setitem",3,3,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_Array_setitem" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ROLE_INFO_Array_setitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); { res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_ROLE_INFO, 0 | 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ROLE_INFO_Array_setitem" "', argument " "3"" of type '" "ROLE_INFO""'"); } if (!argp3) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ROLE_INFO_Array_setitem" "', argument " "3"" of type '" "ROLE_INFO""'"); } else { ROLE_INFO * temp = reinterpret_cast< ROLE_INFO * >(argp3); arg3 = *temp; if (SWIG_IsNewObj(res3)) delete temp; } } ROLE_INFO_Array_setitem(arg1,arg2,arg3); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_sizeof_ROLE_INFO(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t result; if (!SWIG_Python_UnpackTuple(args,"sizeof_ROLE_INFO",0,0,0)) SWIG_fail; result = sizeof_ROLE_INFO(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_ArrayFromBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ROLE_INFO *arg1 = (ROLE_INFO *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; int arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; Py_ssize_t size3 = 0 ; void const *buf3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ROLE_INFO_ArrayFromBuffer",4,4,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_ArrayFromBuffer" "', argument " "1"" of type '" "ROLE_INFO *""'"); } arg1 = reinterpret_cast< ROLE_INFO * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ROLE_INFO_ArrayFromBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); { res3 = PyObject_AsReadBuffer(swig_obj[2], &buf3, &size3); if (res3<0) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ROLE_INFO_ArrayFromBuffer" "', argument " "3"" of type '" "(const char *inMemBuf, SIZE)""'"); } arg3 = (char *) buf3; } ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ROLE_INFO_ArrayFromBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)ROLE_INFO_ArrayFromBuffer(arg1,arg2,(char const *)arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ROLE_INFO_ArrayToBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; int arg2 ; ROLE_INFO *arg3 = (ROLE_INFO *) 0 ; int arg4 ; int res1 ; Py_ssize_t size1 = 0 ; void *buf1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ROLE_INFO_ArrayToBuffer",4,4,swig_obj)) SWIG_fail; { res1 = PyObject_AsWriteBuffer(swig_obj[0], &buf1, &size1); if (res1<0) { PyErr_Clear(); SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ROLE_INFO_ArrayToBuffer" "', argument " "1"" of type '" "(char *outMemBuf, SIZE)""'"); } arg1 = (char *) buf1; } ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ROLE_INFO_ArrayToBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ROLE_INFO, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ROLE_INFO_ArrayToBuffer" "', argument " "3"" of type '" "ROLE_INFO *""'"); } arg3 = reinterpret_cast< ROLE_INFO * >(argp3); ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ROLE_INFO_ArrayToBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)ROLE_INFO_ArrayToBuffer(arg1,arg2,arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_new_ACC_INFO_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject *swig_obj[1] ; ACC_INFO *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_ACC_INFO_Array" "', argument " "1"" of type '" "size_t""'"); } arg1 = static_cast< size_t >(val1); result = (ACC_INFO *)new_ACC_INFO_Array(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ACC_INFO, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_delete_ACC_INFO_Array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ACC_INFO_Array" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); delete_ACC_INFO_Array(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_Array_getitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject *swig_obj[2] ; ACC_INFO result; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_Array_getitem",2,2,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_Array_getitem" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ACC_INFO_Array_getitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); result = ACC_INFO_Array_getitem(arg1,arg2); resultobj = SWIG_NewPointerObj((new ACC_INFO(static_cast< const ACC_INFO& >(result))), SWIGTYPE_p_ACC_INFO, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_Array_setitem(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; size_t arg2 ; ACC_INFO arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; void *argp3 ; int res3 = 0 ; PyObject *swig_obj[3] ; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_Array_setitem",3,3,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_Array_setitem" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ACC_INFO_Array_setitem" "', argument " "2"" of type '" "size_t""'"); } arg2 = static_cast< size_t >(val2); { res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_ACC_INFO, 0 | 0); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ACC_INFO_Array_setitem" "', argument " "3"" of type '" "ACC_INFO""'"); } if (!argp3) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ACC_INFO_Array_setitem" "', argument " "3"" of type '" "ACC_INFO""'"); } else { ACC_INFO * temp = reinterpret_cast< ACC_INFO * >(argp3); arg3 = *temp; if (SWIG_IsNewObj(res3)) delete temp; } } ACC_INFO_Array_setitem(arg1,arg2,arg3); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_sizeof_ACC_INFO(PyObject *self, PyObject *args) { PyObject *resultobj = 0; size_t result; if (!SWIG_Python_UnpackTuple(args,"sizeof_ACC_INFO",0,0,0)) SWIG_fail; result = sizeof_ACC_INFO(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_ArrayFromBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; ACC_INFO *arg1 = (ACC_INFO *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; int arg4 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; Py_ssize_t size3 = 0 ; void const *buf3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_ArrayFromBuffer",4,4,swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_ArrayFromBuffer" "', argument " "1"" of type '" "ACC_INFO *""'"); } arg1 = reinterpret_cast< ACC_INFO * >(argp1); ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ACC_INFO_ArrayFromBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); { res3 = PyObject_AsReadBuffer(swig_obj[2], &buf3, &size3); if (res3<0) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ACC_INFO_ArrayFromBuffer" "', argument " "3"" of type '" "(const char *inMemBuf, SIZE)""'"); } arg3 = (char *) buf3; } ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ACC_INFO_ArrayFromBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)ACC_INFO_ArrayFromBuffer(arg1,arg2,(char const *)arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ACC_INFO_ArrayToBuffer(PyObject *self, PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; int arg2 ; ACC_INFO *arg3 = (ACC_INFO *) 0 ; int arg4 ; int res1 ; Py_ssize_t size1 = 0 ; void *buf1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject *swig_obj[4] ; PyObject *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"ACC_INFO_ArrayToBuffer",4,4,swig_obj)) SWIG_fail; { res1 = PyObject_AsWriteBuffer(swig_obj[0], &buf1, &size1); if (res1<0) { PyErr_Clear(); SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ACC_INFO_ArrayToBuffer" "', argument " "1"" of type '" "(char *outMemBuf, SIZE)""'"); } arg1 = (char *) buf1; } ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ACC_INFO_ArrayToBuffer" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ACC_INFO, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ACC_INFO_ArrayToBuffer" "', argument " "3"" of type '" "ACC_INFO *""'"); } arg3 = reinterpret_cast< ACC_INFO * >(argp3); ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ACC_INFO_ArrayToBuffer" "', argument " "4"" of type '" "int""'"); } arg4 = static_cast< int >(val4); result = (PyObject *)ACC_INFO_ArrayToBuffer(arg1,arg2,arg3,arg4); resultobj = result; return resultobj; fail: return NULL; } static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, { (char *)"GetUniqObjectId", (PyCFunction)_wrap_GetUniqObjectId, METH_NOARGS, NULL}, { (char *)"ObjectPtrTable_Instance", (PyCFunction)_wrap_ObjectPtrTable_Instance, METH_NOARGS, NULL}, { (char *)"ProtocolEncode", _wrap_ProtocolEncode, METH_VARARGS, NULL}, { (char *)"ProtocolDecode", _wrap_ProtocolDecode, METH_VARARGS, NULL}, { (char *)"cdata", _wrap_cdata, METH_VARARGS, NULL}, { (char *)"memmove", _wrap_memmove, METH_VARARGS, NULL}, { (char *)"new_Opt_Array", (PyCFunction)_wrap_new_Opt_Array, METH_O, NULL}, { (char *)"delete_Opt_Array", (PyCFunction)_wrap_delete_Opt_Array, METH_O, NULL}, { (char *)"Opt_Array_getitem", _wrap_Opt_Array_getitem, METH_VARARGS, NULL}, { (char *)"Opt_Array_setitem", _wrap_Opt_Array_setitem, METH_VARARGS, NULL}, { (char *)"sizeof_Opt", (PyCFunction)_wrap_sizeof_Opt, METH_NOARGS, NULL}, { (char *)"Opt_ArrayFromBuffer", _wrap_Opt_ArrayFromBuffer, METH_VARARGS, NULL}, { (char *)"Opt_ArrayToBuffer", _wrap_Opt_ArrayToBuffer, METH_VARARGS, NULL}, { (char *)"new_unsigned_char_Array", (PyCFunction)_wrap_new_unsigned_char_Array, METH_O, NULL}, { (char *)"delete_unsigned_char_Array", (PyCFunction)_wrap_delete_unsigned_char_Array, METH_O, NULL}, { (char *)"unsigned_char_Array_getitem", _wrap_unsigned_char_Array_getitem, METH_VARARGS, NULL}, { (char *)"unsigned_char_Array_setitem", _wrap_unsigned_char_Array_setitem, METH_VARARGS, NULL}, { (char *)"sizeof_unsigned_char", (PyCFunction)_wrap_sizeof_unsigned_char, METH_NOARGS, NULL}, { (char *)"unsigned_char_ArrayFromBuffer", _wrap_unsigned_char_ArrayFromBuffer, METH_VARARGS, NULL}, { (char *)"unsigned_char_ArrayToBuffer", _wrap_unsigned_char_ArrayToBuffer, METH_VARARGS, NULL}, { (char *)"new_ROLE_INFO_Array", (PyCFunction)_wrap_new_ROLE_INFO_Array, METH_O, NULL}, { (char *)"delete_ROLE_INFO_Array", (PyCFunction)_wrap_delete_ROLE_INFO_Array, METH_O, NULL}, { (char *)"ROLE_INFO_Array_getitem", _wrap_ROLE_INFO_Array_getitem, METH_VARARGS, NULL}, { (char *)"ROLE_INFO_Array_setitem", _wrap_ROLE_INFO_Array_setitem, METH_VARARGS, NULL}, { (char *)"sizeof_ROLE_INFO", (PyCFunction)_wrap_sizeof_ROLE_INFO, METH_NOARGS, NULL}, { (char *)"ROLE_INFO_ArrayFromBuffer", _wrap_ROLE_INFO_ArrayFromBuffer, METH_VARARGS, NULL}, { (char *)"ROLE_INFO_ArrayToBuffer", _wrap_ROLE_INFO_ArrayToBuffer, METH_VARARGS, NULL}, { (char *)"new_ACC_INFO_Array", (PyCFunction)_wrap_new_ACC_INFO_Array, METH_O, NULL}, { (char *)"delete_ACC_INFO_Array", (PyCFunction)_wrap_delete_ACC_INFO_Array, METH_O, NULL}, { (char *)"ACC_INFO_Array_getitem", _wrap_ACC_INFO_Array_getitem, METH_VARARGS, NULL}, { (char *)"ACC_INFO_Array_setitem", _wrap_ACC_INFO_Array_setitem, METH_VARARGS, NULL}, { (char *)"sizeof_ACC_INFO", (PyCFunction)_wrap_sizeof_ACC_INFO, METH_NOARGS, NULL}, { (char *)"ACC_INFO_ArrayFromBuffer", _wrap_ACC_INFO_ArrayFromBuffer, METH_VARARGS, NULL}, { (char *)"ACC_INFO_ArrayToBuffer", _wrap_ACC_INFO_ArrayToBuffer, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_HandlableObject) SWIGINTERN PyGetSetDef SwigPyBuiltin__HandlableObject_getset[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__HandlableObject_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__HandlableObject_methods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__HandlableObject_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "HandlableObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_HandlableObject_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__HandlableObject_type.as_number, /* tp_as_number */ &SwigPyBuiltin__HandlableObject_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__HandlableObject_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__HandlableObject_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::HandlableObject", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__HandlableObject_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__HandlableObject_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__HandlableObject_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_HandlableObject, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__HandlableObject_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__HandlableObject_type}; SWIGINTERN PyGetSetDef SwigPyBuiltin__ObjectPtrTable_getset[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__ObjectPtrTable_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__ObjectPtrTable_methods[] = { { "Init", (PyCFunction) _wrap_ObjectPtrTable_Init, METH_O, (char*) "" }, { "Release", (PyCFunction) _wrap_ObjectPtrTable_Release, METH_NOARGS, (char*) "" }, { "Capacity", (PyCFunction) _wrap_ObjectPtrTable_Capacity, METH_NOARGS, (char*) "" }, { "Size", (PyCFunction) _wrap_ObjectPtrTable_Size, METH_NOARGS, (char*) "" }, { "FreeSize", (PyCFunction) _wrap_ObjectPtrTable_FreeSize, METH_NOARGS, (char*) "" }, { "Find", (PyCFunction) _wrap_ObjectPtrTable_Find, METH_O, (char*) "" }, { "GetSlotIndex", (PyCFunction) _wrap_ObjectPtrTable_GetSlotIndex, METH_O, (char*) "" }, { "FreeSlotIndex", (PyCFunction) _wrap_ObjectPtrTable_FreeSlotIndex, METH_O, (char*) "" }, { "Instance", (PyCFunction) _wrap_ObjectPtrTable_Instance, METH_STATIC|METH_NOARGS, "" }, { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__ObjectPtrTable_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "ObjectPtrTable", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) SwigPyBuiltin_BadDealloc, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__ObjectPtrTable_type.as_number, /* tp_as_number */ &SwigPyBuiltin__ObjectPtrTable_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__ObjectPtrTable_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__ObjectPtrTable_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::ObjectPtrTable", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__ObjectPtrTable_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__ObjectPtrTable_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__ObjectPtrTable_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) SwigPyBuiltin_BadInit, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__ObjectPtrTable_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__ObjectPtrTable_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_Opt) static SwigPyGetSet Opt_b_getset = { _wrap_Opt_b_get, _wrap_Opt_b_set }; static SwigPyGetSet Opt_a_getset = { _wrap_Opt_a_get, _wrap_Opt_a_set }; SWIGINTERN PyGetSetDef SwigPyBuiltin__Opt_getset[] = { { (char*) "b", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"Opt.b", (void*) &Opt_b_getset } , { (char*) "a", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"Opt.a", (void*) &Opt_a_getset } , {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__Opt_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__Opt_methods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__Opt_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "Opt", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_Opt_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__Opt_type.as_number, /* tp_as_number */ &SwigPyBuiltin__Opt_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__Opt_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__Opt_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::Opt", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__Opt_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__Opt_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__Opt_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_Opt, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__Opt_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__Opt_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_ACC_INFO) static SwigPyGetSet ACC_INFO_id_getset = { _wrap_ACC_INFO_id_get, _wrap_ACC_INFO_id_set }; static SwigPyGetSet ACC_INFO_password_getset = { _wrap_ACC_INFO_password_get, _wrap_ACC_INFO_password_set }; static SwigPyGetSet ACC_INFO_opt_num_getset = { _wrap_ACC_INFO_opt_num_get, _wrap_ACC_INFO_opt_num_set }; static SwigPyGetSet ACC_INFO_opt_getset = { _wrap_ACC_INFO_opt_get, _wrap_ACC_INFO_opt_set }; static SwigPyGetSet ACC_INFO_username_getset = { _wrap_ACC_INFO_username_get, _wrap_ACC_INFO_username_set }; SWIGINTERN PyGetSetDef SwigPyBuiltin__ACC_INFO_getset[] = { { (char*) "id", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ACC_INFO.id", (void*) &ACC_INFO_id_getset } , { (char*) "password", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ACC_INFO.password", (void*) &ACC_INFO_password_getset } , { (char*) "opt_num", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ACC_INFO.opt_num", (void*) &ACC_INFO_opt_num_getset } , { (char*) "opt", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ACC_INFO.opt", (void*) &ACC_INFO_opt_getset } , { (char*) "username", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ACC_INFO.username", (void*) &ACC_INFO_username_getset } , {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__ACC_INFO_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__ACC_INFO_methods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__ACC_INFO_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "ACC_INFO", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_ACC_INFO_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__ACC_INFO_type.as_number, /* tp_as_number */ &SwigPyBuiltin__ACC_INFO_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__ACC_INFO_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__ACC_INFO_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::ACC_INFO", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__ACC_INFO_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__ACC_INFO_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__ACC_INFO_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_ACC_INFO, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__ACC_INFO_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__ACC_INFO_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_PKG_TEST_REQ) static SwigPyGetSet PKG_TEST_REQ_name_getset = { _wrap_PKG_TEST_REQ_name_get, _wrap_PKG_TEST_REQ_name_set }; static SwigPyGetSet PKG_TEST_REQ_uarray_getset = { _wrap_PKG_TEST_REQ_uarray_get, _wrap_PKG_TEST_REQ_uarray_set }; static SwigPyGetSet PKG_TEST_REQ_type_getset = { _wrap_PKG_TEST_REQ_type_get, _wrap_PKG_TEST_REQ_type_set }; static SwigPyGetSet PKG_TEST_REQ_info_num_getset = { _wrap_PKG_TEST_REQ_info_num_get, _wrap_PKG_TEST_REQ_info_num_set }; static SwigPyGetSet PKG_TEST_REQ_acc_info_getset = { _wrap_PKG_TEST_REQ_acc_info_get, _wrap_PKG_TEST_REQ_acc_info_set }; SWIGINTERN PyGetSetDef SwigPyBuiltin__PKG_TEST_REQ_getset[] = { { (char*) "name", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_REQ.name", (void*) &PKG_TEST_REQ_name_getset } , { (char*) "uarray", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_REQ.uarray", (void*) &PKG_TEST_REQ_uarray_getset } , { (char*) "type", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_REQ.type", (void*) &PKG_TEST_REQ_type_getset } , { (char*) "info_num", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_REQ.info_num", (void*) &PKG_TEST_REQ_info_num_getset } , { (char*) "acc_info", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_REQ.acc_info", (void*) &PKG_TEST_REQ_acc_info_getset } , {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__PKG_TEST_REQ_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__PKG_TEST_REQ_methods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__PKG_TEST_REQ_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "PKG_TEST_REQ", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_PKG_TEST_REQ_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__PKG_TEST_REQ_type.as_number, /* tp_as_number */ &SwigPyBuiltin__PKG_TEST_REQ_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__PKG_TEST_REQ_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__PKG_TEST_REQ_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::PKG_TEST_REQ", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__PKG_TEST_REQ_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__PKG_TEST_REQ_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__PKG_TEST_REQ_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_PKG_TEST_REQ, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__PKG_TEST_REQ_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__PKG_TEST_REQ_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_ROLE_INFO) static SwigPyGetSet ROLE_INFO_level_getset = { _wrap_ROLE_INFO_level_get, _wrap_ROLE_INFO_level_set }; static SwigPyGetSet ROLE_INFO_title_getset = { _wrap_ROLE_INFO_title_get, _wrap_ROLE_INFO_title_set }; SWIGINTERN PyGetSetDef SwigPyBuiltin__ROLE_INFO_getset[] = { { (char*) "level", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ROLE_INFO.level", (void*) &ROLE_INFO_level_getset } , { (char*) "title", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"ROLE_INFO.title", (void*) &ROLE_INFO_title_getset } , {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__ROLE_INFO_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__ROLE_INFO_methods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__ROLE_INFO_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "ROLE_INFO", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_ROLE_INFO_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__ROLE_INFO_type.as_number, /* tp_as_number */ &SwigPyBuiltin__ROLE_INFO_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__ROLE_INFO_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__ROLE_INFO_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::ROLE_INFO", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__ROLE_INFO_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__ROLE_INFO_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__ROLE_INFO_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_ROLE_INFO, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__ROLE_INFO_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__ROLE_INFO_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_PKG_TEST_ACK) static SwigPyGetSet PKG_TEST_ACK_err_code_getset = { _wrap_PKG_TEST_ACK_err_code_get, _wrap_PKG_TEST_ACK_err_code_set }; static SwigPyGetSet PKG_TEST_ACK_info_list_getset = { _wrap_PKG_TEST_ACK_info_list_get, _wrap_PKG_TEST_ACK_info_list_set }; static SwigPyGetSet PKG_TEST_ACK_num_getset = { _wrap_PKG_TEST_ACK_num_get, _wrap_PKG_TEST_ACK_num_set }; SWIGINTERN PyGetSetDef SwigPyBuiltin__PKG_TEST_ACK_getset[] = { { (char*) "err_code", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_ACK.err_code", (void*) &PKG_TEST_ACK_err_code_getset } , { (char*) "info_list", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_ACK.info_list", (void*) &PKG_TEST_ACK_info_list_getset } , { (char*) "num", (getter) SwigPyBuiltin_FunpackGetterClosure, (setter) SwigPyBuiltin_FunpackSetterClosure, (char*)"PKG_TEST_ACK.num", (void*) &PKG_TEST_ACK_num_getset } , {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__PKG_TEST_ACK_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__PKG_TEST_ACK_methods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__PKG_TEST_ACK_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "PKG_TEST_ACK", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_PKG_TEST_ACK_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__PKG_TEST_ACK_type.as_number, /* tp_as_number */ &SwigPyBuiltin__PKG_TEST_ACK_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__PKG_TEST_ACK_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__PKG_TEST_ACK_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::PKG_TEST_ACK", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__PKG_TEST_ACK_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__PKG_TEST_ACK_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__PKG_TEST_ACK_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_PKG_TEST_ACK, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__PKG_TEST_ACK_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__PKG_TEST_ACK_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_Protocol) SWIGINTERN PyGetSetDef SwigPyBuiltin__Protocol_getset[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__Protocol_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__Protocol_methods[] = { { "Init", (PyCFunction) _wrap_Protocol_Init, METH_NOARGS, (char*) "" }, { "Encode", (PyCFunction) _wrap_Protocol_Encode, METH_VARARGS, (char*) "" }, { "Decode", (PyCFunction) _wrap_Protocol_Decode, METH_VARARGS, (char*) "" }, { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__Protocol_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "Protocol", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_Protocol_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__Protocol_type.as_number, /* tp_as_number */ &SwigPyBuiltin__Protocol_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__Protocol_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__Protocol_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::Protocol", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__Protocol_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__Protocol_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__Protocol_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_Protocol, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__Protocol_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__Protocol_type}; SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_GameObjectHandler) SWIGINTERN PyGetSetDef SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_getset[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; SWIGINTERN PyObject * SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_richcompare(PyObject *self, PyObject *other, int op) { PyObject *result = NULL; switch (op) { case Py_EQ : result = _wrap_GameObjectHandler___eq__(self, other); break; case Py_NE : result = _wrap_GameObjectHandler___ne__(self, other); break; default : break; } if (!result) { if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); } else { result = Py_NotImplemented; Py_INCREF(result); } } return result; } SWIGINTERN PyMethodDef SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_methods[] = { { "ToObject", (PyCFunction) _wrap_GameObjectHandler_ToObject, METH_NOARGS, (char*) "" }, { "__eq__", (PyCFunction) _wrap_GameObjectHandler___eq__, METH_O, (char*) "" }, { "__ne__", (PyCFunction) _wrap_GameObjectHandler___ne__, METH_O, (char*) "" }, { NULL, NULL, 0, NULL } /* Sentinel */ }; static PyHeapTypeObject SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type = { #if !defined(STACKLESS) { #endif #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "GameObjectHandler", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) _wrap_delete_GameObjectHandler_closure, /* tp_dealloc */ (printfunc) 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_compare */ #else (cmpfunc) 0, /* tp_compare */ #endif (reprfunc) 0, /* tp_repr */ &SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type.as_number, /* tp_as_number */ &SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type.as_sequence, /* tp_as_sequence */ &SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type.as_mapping, /* tp_as_mapping */ (hashfunc) 0, /* tp_hash */ (ternaryfunc) 0, /* tp_call */ (reprfunc) 0, /* tp_str */ (getattrofunc) 0, /* tp_getattro */ (setattrofunc) 0, /* tp_setattro */ &SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type.as_buffer, /* tp_as_buffer */ #if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ #else Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ #endif "::ObjectHandler< HandlableObject >", /* tp_doc */ (traverseproc) 0, /* tp_traverse */ (inquiry) 0, /* tp_clear */ (richcmpfunc) SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_richcompare, /* feature:python:tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc) 0, /* tp_iter */ (iternextfunc) 0, /* tp_iternext */ SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_methods, /* tp_methods */ 0, /* tp_members */ SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc) 0, /* tp_descr_get */ (descrsetfunc) 0, /* tp_descr_set */ (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */ (initproc) _wrap_new_GameObjectHandler, /* tp_init */ (allocfunc) 0, /* tp_alloc */ (newfunc) 0, /* tp_new */ (freefunc) 0, /* tp_free */ (inquiry) 0, /* tp_is_gc */ (PyObject*) 0, /* tp_bases */ (PyObject*) 0, /* tp_mro */ (PyObject*) 0, /* tp_cache */ (PyObject*) 0, /* tp_subclasses */ (PyObject*) 0, /* tp_weaklist */ (destructor) 0, /* tp_del */ #if PY_VERSION_HEX >= 0x02060000 (int) 0, /* tp_version_tag */ #endif #if !defined(STACKLESS) } #endif { (binaryfunc) 0, /* nb_add */ (binaryfunc) 0, /* nb_subtract */ (binaryfunc) 0, /* nb_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_divide */ #endif (binaryfunc) 0, /* nb_remainder */ (binaryfunc) 0, /* nb_divmod */ (ternaryfunc) 0, /* nb_power */ (unaryfunc) 0, /* nb_negative */ (unaryfunc) 0, /* nb_positive */ (unaryfunc) 0, /* nb_absolute */ (inquiry) 0, /* nb_nonzero */ (unaryfunc) 0, /* nb_invert */ (binaryfunc) 0, /* nb_lshift */ (binaryfunc) 0, /* nb_rshift */ (binaryfunc) 0, /* nb_and */ (binaryfunc) 0, /* nb_xor */ (binaryfunc) 0, /* nb_or */ #if PY_VERSION_HEX < 0x03000000 (coercion) 0, /* nb_coerce */ #endif (unaryfunc) 0, /* nb_int */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* nb_reserved */ #else (unaryfunc) 0, /* nb_long */ #endif (unaryfunc) 0, /* nb_float */ #if PY_VERSION_HEX < 0x03000000 (unaryfunc) 0, /* nb_oct */ (unaryfunc) 0, /* nb_hex */ #endif (binaryfunc) 0, /* nb_inplace_add */ (binaryfunc) 0, /* nb_inplace_subtract */ (binaryfunc) 0, /* nb_inplace_multiply */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc) 0, /* nb_inplace_divide */ #endif (binaryfunc) 0, /* nb_inplace_remainder */ (ternaryfunc) 0, /* nb_inplace_power */ (binaryfunc) 0, /* nb_inplace_lshift */ (binaryfunc) 0, /* nb_inplace_rshift */ (binaryfunc) 0, /* nb_inplace_and */ (binaryfunc) 0, /* nb_inplace_xor */ (binaryfunc) 0, /* nb_inplace_or */ (binaryfunc) 0, /* nb_floor_divide */ (binaryfunc) 0, /* nb_true_divide */ (binaryfunc) 0, /* nb_inplace_floor_divide */ (binaryfunc) 0, /* nb_inplace_true_divide */ #if PY_VERSION_HEX >= 0x02050000 (unaryfunc) 0, /* nb_index */ #endif }, { (lenfunc) 0, /* mp_length */ (binaryfunc) 0, /* mp_subscript */ (objobjargproc) 0, /* mp_ass_subscript */ }, { (lenfunc) 0, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) 0, /* sq_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_slice */ #else (ssizessizeargfunc) 0, /* sq_slice */ #endif (ssizeobjargproc) 0, /* sq_ass_item */ #if PY_VERSION_HEX >= 0x03000000 (void*) 0, /* was_sq_ass_slice */ #else (ssizessizeobjargproc) 0, /* sq_ass_slice */ #endif (objobjproc) 0, /* sq_contains */ (binaryfunc) 0, /* sq_inplace_concat */ (ssizeargfunc) 0, /* sq_inplace_repeat */ }, { #if PY_VERSION_HEX < 0x03000000 (readbufferproc) 0, /* bf_getreadbuffer */ (writebufferproc) 0, /* bf_getwritebuffer */ (segcountproc) 0, /* bf_getsegcount */ (charbufferproc) 0, /* bf_getcharbuffer */ #endif #if PY_VERSION_HEX >= 0x02060000 (getbufferproc) 0, /* bf_getbuffer */ (releasebufferproc) 0, /* bf_releasebuffer */ #endif }, (PyObject*) 0, /* ht_name */ (PyObject*) 0, /* ht_slots */ }; SWIGINTERN SwigPyClientData SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type}; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_ACC_INFO = {"_p_ACC_INFO", "ACC_INFO *", 0, 0, (void*)&SwigPyBuiltin__ACC_INFO_clientdata, 0}; static swig_type_info _swigt__p_HandlableObject = {"_p_HandlableObject", "HandlableObject *", 0, 0, (void*)&SwigPyBuiltin__HandlableObject_clientdata, 0}; static swig_type_info _swigt__p_ObjectHandlerT_HandlableObject_t = {"_p_ObjectHandlerT_HandlableObject_t", "ObjectHandler< HandlableObject > *", 0, 0, (void*)&SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_clientdata, 0}; static swig_type_info _swigt__p_ObjectPtrTable = {"_p_ObjectPtrTable", "ObjectPtrTable *", 0, 0, (void*)&SwigPyBuiltin__ObjectPtrTable_clientdata, 0}; static swig_type_info _swigt__p_Opt = {"_p_Opt", "Opt *", 0, 0, (void*)&SwigPyBuiltin__Opt_clientdata, 0}; static swig_type_info _swigt__p_PKG_TEST_ACK = {"_p_PKG_TEST_ACK", "PKG_TEST_ACK *", 0, 0, (void*)&SwigPyBuiltin__PKG_TEST_ACK_clientdata, 0}; static swig_type_info _swigt__p_PKG_TEST_REQ = {"_p_PKG_TEST_REQ", "PKG_TEST_REQ *", 0, 0, (void*)&SwigPyBuiltin__PKG_TEST_REQ_clientdata, 0}; static swig_type_info _swigt__p_Protocol = {"_p_Protocol", "Protocol *", 0, 0, (void*)&SwigPyBuiltin__Protocol_clientdata, 0}; static swig_type_info _swigt__p_ROLE_INFO = {"_p_ROLE_INFO", "ROLE_INFO *", 0, 0, (void*)&SwigPyBuiltin__ROLE_INFO_clientdata, 0}; static swig_type_info _swigt__p_SwigPyObject = {"_p_SwigPyObject", "SwigPyObject *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p___int64 = {"_p___int64", "__int64 *|LONGLONG *|LONG64 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "CHAR *|TCHAR *|char *|CCHAR *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_float = {"_p_float", "FLOAT *|float *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_int = {"_p_int", "BOOL *|INT32 *|int *|INT *|INT_PTR *|LONG32 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_long = {"_p_long", "SHANDLE_PTR *|LONG_PTR *|LONG *|HRESULT *|long *|SSIZE_T *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_char = {"_p_p_char", "PTCH *|PCTSTR *|LPCTSTR *|LPTCH *|PUTSTR *|LPUTSTR *|PCUTSTR *|LPCUTSTR *|char **|PTSTR *|LPTSTR *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_unsigned_long = {"_p_p_unsigned_long", "unsigned long **|PLCID *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_short = {"_p_short", "HALF_PTR *|short *|SHORT *|INT16 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_signed___int64 = {"_p_signed___int64", "INT64 *|signed __int64 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|INT8 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_size_t = {"_p_size_t", "size_t *|ObjectSlotIdx *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned___int64 = {"_p_unsigned___int64", "UINT64 *|DWORD64 *|unsigned __int64 *|DWORDLONG *|ULONGLONG *|ULONG64 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "FCHAR *|unsigned char *|UCHAR *|BYTE *|TBYTE *|UINT8 *|BOOLEAN *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "UINT32 *|DWORD32 *|UINT *|unsigned int *|UINT_PTR *|ObjectId *|ULONG32 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "HANDLE_PTR *|DWORD *|ULONG_PTR *|DWORD_PTR *|FLONG *|unsigned long *|ULONG *|SIZE_T *|LCID *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "WORD *|UHALF_PTR *|unsigned short *|USHORT *|FSHORT *|LANGID *|UINT16 *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_ACC_INFO, &_swigt__p_HandlableObject, &_swigt__p_ObjectHandlerT_HandlableObject_t, &_swigt__p_ObjectPtrTable, &_swigt__p_Opt, &_swigt__p_PKG_TEST_ACK, &_swigt__p_PKG_TEST_REQ, &_swigt__p_Protocol, &_swigt__p_ROLE_INFO, &_swigt__p_SwigPyObject, &_swigt__p___int64, &_swigt__p_char, &_swigt__p_float, &_swigt__p_int, &_swigt__p_long, &_swigt__p_p_char, &_swigt__p_p_unsigned_long, &_swigt__p_short, &_swigt__p_signed___int64, &_swigt__p_signed_char, &_swigt__p_size_t, &_swigt__p_unsigned___int64, &_swigt__p_unsigned_char, &_swigt__p_unsigned_int, &_swigt__p_unsigned_long, &_swigt__p_unsigned_short, }; static swig_cast_info _swigc__p_ACC_INFO[] = { {&_swigt__p_ACC_INFO, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_HandlableObject[] = { {&_swigt__p_HandlableObject, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ObjectHandlerT_HandlableObject_t[] = { {&_swigt__p_ObjectHandlerT_HandlableObject_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ObjectPtrTable[] = { {&_swigt__p_ObjectPtrTable, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Opt[] = { {&_swigt__p_Opt, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_PKG_TEST_ACK[] = { {&_swigt__p_PKG_TEST_ACK, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_PKG_TEST_REQ[] = { {&_swigt__p_PKG_TEST_REQ, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Protocol[] = { {&_swigt__p_Protocol, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ROLE_INFO[] = { {&_swigt__p_ROLE_INFO, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_SwigPyObject[] = { {&_swigt__p_SwigPyObject, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p___int64[] = { {&_swigt__p___int64, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_unsigned_long[] = { {&_swigt__p_p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_signed___int64[] = { {&_swigt__p_signed___int64, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_size_t[] = { {&_swigt__p_size_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned___int64[] = { {&_swigt__p_unsigned___int64, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_long[] = { {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_ACC_INFO, _swigc__p_HandlableObject, _swigc__p_ObjectHandlerT_HandlableObject_t, _swigc__p_ObjectPtrTable, _swigc__p_Opt, _swigc__p_PKG_TEST_ACK, _swigc__p_PKG_TEST_REQ, _swigc__p_Protocol, _swigc__p_ROLE_INFO, _swigc__p_SwigPyObject, _swigc__p___int64, _swigc__p_char, _swigc__p_float, _swigc__p_int, _swigc__p_long, _swigc__p_p_char, _swigc__p_p_unsigned_long, _swigc__p_short, _swigc__p_signed___int64, _swigc__p_signed_char, _swigc__p_size_t, _swigc__p_unsigned___int64, _swigc__p_unsigned_char, _swigc__p_unsigned_int, _swigc__p_unsigned_long, _swigc__p_unsigned_short, }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif static PyTypeObject *builtin_bases[2]; /* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back * to swig_type_info structures, we need some lookup code at initialization. * The idea is that swig generates all the structures that are needed. * The runtime then collects these partially filled structures. * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * * The generated swig_type_info structures are assigned staticly to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a * two-dimensional array. Each row corresponds to a type (there are the same * number of rows as there are in the swig_type_initial array). Each entry in * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* c-mode */ #endif #endif #if 0 #define SWIGRUNTIME_DEBUG #endif SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; int found, init; clientdata = clientdata; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; init = 1; } else { init = 0; } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); if (!module_head) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ found=0; iter=module_head; do { if (iter==&swig_module) { found=1; break; } iter=iter->next; } while (iter!= module_head); /* if the is found in the list, then all is done and we may leave */ if (found) return; /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } /* When multiple interpeters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ if (init == 0) return; /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ if (swig_module.next != &swig_module) { type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); } if (type) { /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found type %s\n", type->name); #endif if (swig_module.type_initial[i]->clientdata) { type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif } } else { type = swig_module.type_initial[i]; } /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif if (swig_module.next != &swig_module) { ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif } if (ret) { if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif cast->type = ret; ret = 0; } else { /* Check for casting already in the list */ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif if (!ocast) ret = 0; } } if (!ret) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif if (type->cast) { type->cast->prev = cast; cast->next = type->cast; } type->cast = cast; } cast++; } /* Set entry in modules->types array equal to the type */ swig_module.types[i] = type; } swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG printf("**** SWIG_InitializeModule: Cast List ******\n"); for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; ++j; } printf("---- Total casts: %d\n",j); } printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ SWIGRUNTIME void SWIG_PropagateClientData(void) { size_t i; swig_cast_info *equiv; static int init_run = 0; if (init_run) return; init_run = 1; for (i = 0; i < swig_module.size; i++) { if (swig_module.types[i]->clientdata) { equiv = swig_module.types[i]->cast; while (equiv) { if (!equiv->converter) { if (equiv->type && !equiv->type->clientdata) SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } equiv = equiv->next; } } } } #ifdef __cplusplus #if 0 { /* c-mode */ #endif } #endif #ifdef __cplusplus extern "C" { #endif /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_InternFromString("<Swig global variables>"); #else return PyString_FromString("<Swig global variables>"); #endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { #if PY_VERSION_HEX >= 0x03000000 PyObject *str = PyUnicode_InternFromString("("); PyObject *tail; PyObject *joined; swig_globalvar *var; for (var = v->vars; var; var=var->next) { tail = PyUnicode_FromString(var->name); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; if (var->next) { tail = PyUnicode_InternFromString(", "); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; } } tail = PyUnicode_InternFromString(")"); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; #else PyObject *str = PyString_FromString("("); swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); #endif return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; } SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { PyObject *res = NULL; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->get_attr)(); break; } var = var->next; } if (res == NULL && !PyErr_Occurred()) { PyErr_SetString(PyExc_NameError,"Unknown C global variable"); } return res; } SWIGINTERN int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { int res = 1; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->set_attr)(p); break; } var = var->next; } if (res == 1 && !PyErr_Occurred()) { PyErr_SetString(PyExc_NameError,"Unknown C global variable"); } return res; } SWIGINTERN PyTypeObject* swig_varlink_type(void) { static char varlink__doc__[] = "Swig var link object"; static PyTypeObject varlink_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ (printfunc) swig_varlink_print, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc) swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ varlink__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; varlink_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 varlink_type.ob_type = &PyType_Type; #else if (PyType_Ready(&varlink_type) < 0) return NULL; #endif } return &varlink_type; } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); if (result) { result->vars = 0; } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { switch(constants[i].type) { case SWIG_PY_POINTER: obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d, constants[i].name, obj); Py_DECREF(obj); } } } /* -----------------------------------------------------------------------------*/ /* Fix SwigMethods to carry the callback ptrs when needed */ /* -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; if (ptr) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" #endif SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 PyObject* #else void #endif SWIG_init(void) { PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { # if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, # else { PyObject_HEAD_INIT(NULL) NULL, /* m_init */ 0, /* m_index */ NULL, /* m_copy */ }, # endif (char *) SWIG_name, NULL, -1, SwigMethods, NULL, NULL, NULL, NULL }; #endif #if defined(SWIGPYTHON_BUILTIN) static SwigPyClientData SwigPyObject_clientdata = { 0, 0, 0, 0, 0, 0, 0 }; static PyGetSetDef this_getset_def = { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { (PyCFunction) SwigPyObject_own, (PyCFunction) SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure }; PyObject *metatype_args; PyTypeObject *builtin_pytype; int builtin_base_count; swig_type_info *builtin_basetype; PyObject *tuple; PyGetSetDescrObject *static_getset; PyTypeObject *metatype; SwigPyClientData *cd; PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; int i; (void)builtin_pytype; (void)builtin_base_count; (void)builtin_basetype; (void)tuple; (void)static_getset; /* metatype is used to implement static member variables. */ metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); assert(metatype_args); metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); assert(metatype); Py_DECREF(metatype_args); metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; assert(PyType_Ready(metatype) >= 0); #endif /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); SWIG_InitializeModule(0); #ifdef SWIGPYTHON_BUILTIN SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; if (!cd) { SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); # if PY_VERSION_HEX >= 0x03000000 return NULL; # else return; # endif } /* All objects have a 'this' attribute */ this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); (void)this_descr; /* All objects have a 'thisown' attribute */ thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); (void)thisown_descr; public_interface = PyList_New(0); public_symbol = 0; (void)public_symbol; PyDict_SetItemString(md, "__all__", public_interface); Py_DECREF(public_interface); for (i = 0; SwigMethods[i].ml_name != NULL; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); for (i = 0; swig_const_table[i].name != 0; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); #endif SWIG_InstallConstants(d,swig_const_table); /* type '::HandlableObject' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__HandlableObject_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'HandlableObject'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "HandlableObject", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "HandlableObject"); d = md; /* type '::ObjectPtrTable' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__ObjectPtrTable_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'ObjectPtrTable'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "ObjectPtrTable", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "ObjectPtrTable"); d = md; SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "TEST_REQ",SWIG_From_int(static_cast< int >(0))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "TEST_ACK",SWIG_From_int(static_cast< int >(1))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_MSG",SWIG_From_int(static_cast< int >(512))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_NAME_LEN",SWIG_From_int(static_cast< int >(128))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_REQ_DATA_LEN",SWIG_From_int(static_cast< int >(512))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_TITILE_LEN",SWIG_From_int(static_cast< int >(128))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_INFO_NUM",SWIG_From_int(static_cast< int >(10))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_ACC_NAME_LEN",SWIG_From_int(static_cast< int >(10))); SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "MAX_PASSWORD_LEN",SWIG_From_int(static_cast< int >(64))); /* type '::Opt' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__Opt_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'Opt'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "Opt", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "Opt"); d = md; /* type '::ACC_INFO' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__ACC_INFO_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'ACC_INFO'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "ACC_INFO", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "ACC_INFO"); d = md; /* type '::PKG_TEST_REQ' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__PKG_TEST_REQ_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'PKG_TEST_REQ'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "PKG_TEST_REQ", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "PKG_TEST_REQ"); d = md; /* type '::ROLE_INFO' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__ROLE_INFO_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'ROLE_INFO'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "ROLE_INFO", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "ROLE_INFO"); d = md; /* type '::PKG_TEST_ACK' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__PKG_TEST_ACK_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'PKG_TEST_ACK'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "PKG_TEST_ACK", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "PKG_TEST_ACK"); d = md; /* type '::Protocol' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__Protocol_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'Protocol'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "Protocol", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "Protocol"); d = md; /* type '::ObjectHandler< HandlableObject >' */ builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__ObjectHandlerT_HandlableObject_t_type; builtin_pytype->tp_dict = d = PyDict_New(); SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); builtin_pytype->tp_new = PyType_GenericNew; builtin_base_count = 0; builtin_bases[builtin_base_count] = NULL; SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); PyDict_SetItemString(d, "this", this_descr); PyDict_SetItemString(d, "thisown", thisown_descr); if (PyType_Ready(builtin_pytype) < 0) { PyErr_SetString(PyExc_TypeError, "Could not create type 'GameObjectHandler'."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } Py_INCREF(builtin_pytype); PyModule_AddObject(m, "GameObjectHandler", (PyObject*) builtin_pytype); SwigPyBuiltin_AddPublicSymbol(public_interface, "GameObjectHandler"); d = md; #if PY_VERSION_HEX >= 0x03000000 return m; #else return; #endif }
[ [ [ 1, 9973 ] ] ]
3713121f503240f990ece2d3204d3d069c727469
c2abb873c8b352d0ec47757031e4a18b9190556e
/src/MyGUIEngine/include/MyGUI_MessageFactory.h
df689e3ce45699b515066a1e424e91f6382a10a8
[]
no_license
twktheainur/vortex-ee
70b89ec097cd1c74cde2b75f556448965d0d345d
8b8aef42396cbb4c9ce063dd1ab2f44d95e994c6
refs/heads/master
2021-01-10T02:26:21.913972
2009-01-30T12:53:21
2009-01-30T12:53:21
44,046,528
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
1,961
h
/*! @file @author Albert Semenov @date 01/2008 @module */ #ifndef __MYGUI_MESSAGE_FACTORY_H__ #define __MYGUI_MESSAGE_FACTORY_H__ #include "MyGUI_Prerequest.h" #include "MyGUI_WidgetFactoryInterface.h" #include "MyGUI_WidgetDefines.h" namespace MyGUI { namespace factory { class _MyGUIExport MessageFactory : public WidgetFactoryInterface { public: MessageFactory(); ~MessageFactory(); // реализация интерфейса фабрики const Ogre::String& getType(); WidgetPtr createWidget(const Ogre::String& _skin, const IntCoord& _coord, Align _align, CroppedRectanglePtr _parent, WidgetCreator * _creator, const Ogre::String& _name); static Ogre::UTFString _getButtonName(size_t _index); inline static const std::string & _getDefaultSkin() {return mDefaultSkin;} private: void initialise(); void shutdown(); // методы для парсинга void Message_Caption(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); void Message_Message(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); void Message_Modal(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); void Message_Button(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); void Message_AddButton(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); void Message_SmoothShow(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); void Message_Fade(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value); size_t parseButton(const std::string & _info); private: static std::vector<Ogre::UTFString> mVectorButtonName; static std::map<std::string, size_t> mMapButtonType; static std::string mDefaultSkin; }; } // namespace factory } // namespace MyGUI #endif // __MYGUI_MESSAGE_FACTORY_H__
[ "twk.theainur@37e2baaa-b253-11dd-9381-bf584fb1fa83" ]
[ [ [ 1, 57 ] ] ]
be7f828f9673950b03252a358e445f1d5fdcac90
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestgrids/src/bctestgridscontainer.cpp
9af6db0eff7ffac2384251e561dcabe142b4be08
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
3,496
cpp
/* * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: container * */ #include "bctestgridscontainer.h" // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- // C++ default Constructor // --------------------------------------------------------------------------- // CBCTestGridsContainer::CBCTestGridsContainer() { } // --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // CBCTestGridsContainer::~CBCTestGridsContainer() { ResetControl(); } // --------------------------------------------------------------------------- // Symbian 2nd Constructor // --------------------------------------------------------------------------- // void CBCTestGridsContainer::ConstructL( const TRect& aRect ) { CreateWindowL(); SetRect( aRect ); ActivateL(); } // ---------------------------------------------------------------------------- // CBCTestGridsContainer::Draw // Fills the window's rectangle. // ---------------------------------------------------------------------------- // void CBCTestGridsContainer::Draw( const TRect& aRect ) const { CWindowGc& gc = SystemGc(); gc.SetPenStyle( CGraphicsContext::ENullPen ); gc.SetBrushColor( KRgbGray ); gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); gc.DrawRect( aRect ); } // --------------------------------------------------------------------------- // CBCTestGridsContainer::CountComponentControls // --------------------------------------------------------------------------- // TInt CBCTestGridsContainer::CountComponentControls() const { if ( iControl ) { return 1; } else { return 0; } } // --------------------------------------------------------------------------- // CBCTestGridsContainer::ComponentControl // --------------------------------------------------------------------------- // CCoeControl* CBCTestGridsContainer::ComponentControl( TInt ) const { return iControl; } // --------------------------------------------------------------------------- // CBCTestGridsContainer::SetControl // --------------------------------------------------------------------------- // void CBCTestGridsContainer::SetControlL( CCoeControl* aControl ) { iControl = aControl; if ( iControl ) { // You can change the position and size iControl->SetExtent( Rect().iTl, Rect().Size() ); iControl->ActivateL(); DrawNow(); } } // --------------------------------------------------------------------------- // CBCTestGridsContainer::ResetControl // --------------------------------------------------------------------------- // void CBCTestGridsContainer::ResetControl() { delete iControl; iControl = NULL; }
[ "none@none" ]
[ [ [ 1, 116 ] ] ]
97728256b9fbcc1a33b839e14a9f33a5e5c9f9e8
69b7796d276703936b8ae0fe82cb931d704ed432
/api/src/send.cpp
b6ce236bfa1818df2f2cc0b5187a7c1399930973
[]
no_license
owensgroup/dcgn
6038bfa1815baea6e89c97c957c6f3a4e6e7545d
d5cadbeacb4223775e8ccc87dbae346724bee214
refs/heads/master
2021-05-29T14:45:48.439038
2011-03-21T22:55:41
2011-03-21T22:55:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
212
cpp
#include <dcgn/dcgn.h> #include <dcgn/CPUWorker.h> namespace dcgn { void send(const Target dst, const void * const buffer, const int numBytes) { CPUWorker::send(dst, buffer, numBytes); } }
[ "[email protected]@0566f383-6757-26d6-4a9c-121651c89c67" ]
[ [ [ 1, 11 ] ] ]
1d7b858d114e93f7db348577983fe5e65a9e59de
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Raptor/SingletonInitiallize.cpp
0953dcfbb8e75840527240a17d7024a7c521a54c
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
556
cpp
/**@file SingletonInitiallize.cpp * @brief Dharani 컴포넌트에서 사용되는 싱글톤들을 NULL로 초기화한다. * @author siva */ #include "stdafx.h" //Dharani #include "DharaniFacade.h" #include "DharaniServerManager.h" #include "DharaniClientManager.h" #include "DharaniExternSD.h" CDharaniFacade *CDharaniFacade::m_instance = NULL; CDharaniServerManager *CDharaniServerManager::m_instance = NULL; CDharaniClientManager *CDharaniClientManager::m_instance = NULL; CDharaniExternSD *CDharaniExternSD::m_instance = NULL;
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 16 ] ] ]
cf51f727b3af21d6e62362a1873babfebdaf39ff
59ce53af7ad5a1f9b12a69aadbfc7abc4c4bfc02
/publish/skinctrlex/skintreelistctrl.h
fddffa5899d7a6b836a3b80229d0d5555bb64423
[]
no_license
fingomajom/skinengine
444a89955046a6f2c7be49012ff501dc465f019e
6bb26a46a7edac88b613ea9a124abeb8a1694868
refs/heads/master
2021-01-10T11:30:51.541442
2008-07-30T07:13:11
2008-07-30T07:13:11
47,892,418
0
0
null
null
null
null
GB18030
C++
false
false
45,440
h
/******************************************************************** * CreatedOn: 2008-5-20 10:11 * FileName: skintreelistctrl.h * CreatedBy: ichenglin <[email protected]> * CreatedBy: lidengwang <[email protected]> * $LastChangedDate$ * $LastChangedRevision$ * $LastChangedBy$ * $HeadURL: $ * Purpose: *********************************************************************/ #pragma once namespace KSGUI{ #include <ksguicommon/drawer/StandardDrawer.h> #include <map> #include <atlframe.h> ////////////////////////////////////////////////////////////////////////// #define WM_SUBITEMCLICKED (WM_USER + 0x221) template<class T> class KTreeItem; class KTreeItemData; typedef KTreeItem<KTreeItemData>* HTREELISTITEM; class ITreeListItemData { public: virtual LPCTSTR GetItemText ( HTREELISTITEM hItem, int nsubindex ) = 0; virtual int GetImageIndex( HTREELISTITEM hItem, BOOL bSelected = FALSE ) = 0; virtual HICON GetIcon ( HTREELISTITEM hItem, BOOL bSelected = FALSE ) = 0; virtual HBITMAP GetBitmap ( HTREELISTITEM hItem, BOOL bSelected = FALSE ) = 0; virtual BOOL Filter ( HTREELISTITEM hItem, LPCTSTR pszField ) = 0; virtual BOOL OnClicked ( HTREELISTITEM hItem, int nsubIndex) = 0; }; class KTreeListItemDataBase: public ITreeListItemData { public: virtual ~KTreeListItemDataBase() {} virtual LPCTSTR GetItemText ( HTREELISTITEM hItem, int nsubindex ) { return TEXT(""); } virtual int GetImageIndex( HTREELISTITEM hItem, BOOL bSelected = FALSE ) { return -1; } virtual HICON GetIcon ( HTREELISTITEM hItem, BOOL bSelected = FALSE ) { return NULL; } virtual HBITMAP GetBitmap ( HTREELISTITEM hItem, BOOL bSelected = FALSE ) { return NULL; } virtual BOOL Filter ( HTREELISTITEM hItem, LPCTSTR pszField ) { return TRUE; } virtual BOOL OnClicked ( HTREELISTITEM hItem, int nsubIndex) { return TRUE; } }; ////////////////////////////////////////////////////////////////////////// // 树结点包含以下数据: // 1. m_data 用于存放数据 // 2. m_pParent 指向该结点的父结点, 如果该结点为根结点, m_pParent为空 // 3. m_pFirstChild 指向该结点的第一个子结点, 如果没有子结点, m_pFirstChild为空 // 4. m_pNextSibling 指向该结点的下一个兄弟结点, 如果后面没有兄弟, m_pNextSibling为空 // // 树 函数简介: // 1. Clear 清空树, 删除所有结点 // 2. InsertItem 在指定的父结点的所有子结点末尾 插入一个结点 // 3. DeleteItem 删除指定结点 以及该节点的所有子结点 // 4. GetParent 获取指定结点的父结点, 根结点的父结点为NULL // 5. GetNextSibling 获取指定结点的下一个兄弟结点 // 6. GetFirstChild 获取指定结点的第一个子结点 // 7. HasChildren 查看指定结点是否有子结点 // 8. Size 获取当前结点总数 // // template<class T> class KTree { public: KTree() { m_nItemCount = 0; } ~KTree() { Clear(); } KTreeItem<T>* GetRootItem() const { return const_cast<KTreeItem<T>*>(&m_root); } void Clear() { DeleteItem( &m_root ); assert( m_nItemCount == 0 ); } KTreeItem<T>* InsertItem( const T& data, KTreeItem<T>* pParent ) { if( pParent == NULL ) { return InsertItem(data, &m_root); } KTreeItem<T>* pItem = new KTreeItem<T>; if( pItem == NULL ) { return NULL; } m_nItemCount++; pItem->m_data = data; pItem->m_pParent = pParent; if (true) { KTreeItem<T>* pIter = pParent->m_pFirstChild; if( pIter == NULL ) { pParent->m_pFirstChild = pItem; } else { while( pIter->m_pNextSibling != NULL ) { pIter = pIter->m_pNextSibling; } pIter->m_pNextSibling = pItem; } } return pItem; } void DeleteItem( KTreeItem<T>* pItem ) { assert( pItem != NULL ); DeleteChildren( pItem ); if( pItem != &m_root ) { KTreeItem<T>* pParent = GetParent( pItem ); KTreeItem<T>* pIter = pParent->m_pFirstChild; if( pIter == pItem ) { pParent->m_pFirstChild = pIter->m_pNextSibling; } else { while( pIter->m_pNextSibling != pItem ) { pIter = pIter->m_pNextSibling; assert( pIter != NULL ); } pIter->m_pNextSibling = pItem->m_pNextSibling; } } else { m_root.m_pFirstChild = NULL; m_root.m_pNextSibling = NULL; m_root.m_pParent = NULL; } if (pItem != &m_root) { delete pItem; m_nItemCount--; } } KTreeItem<T>* GetParent( const KTreeItem<T>* pItem ) const { assert( pItem != NULL ); return pItem->m_pParent; } KTreeItem<T>* GetNextSibling( const KTreeItem<T>* pItem ) const { assert( pItem != NULL ); return pItem->m_pNextSibling; } KTreeItem<T>* GetFirstChild( const KTreeItem<T>* pItem ) const { assert( pItem != NULL ); return pItem->m_pFirstChild; } bool HasChildren( const KTreeItem<T>* pItem ) const { return ( pItem->m_pFirstChild != NULL ); } int Size() const { return m_nItemCount; } private: void DeleteChildren( KTreeItem<T>* pItem ) { KTreeItem<T>* pNext = NULL; KTreeItem<T>* pIter = NULL; for( pIter = pItem->m_pFirstChild; pIter != NULL; pIter = pNext ) { pNext = pIter->m_pNextSibling; DeleteChildren( pIter ); delete pIter; pIter = NULL; m_nItemCount--; } } private: KTreeItem<T> m_root; int m_nItemCount; }; ////////////////////////////////////////////////////////////////////////// // // 树结点 // ////////////////////////////////////////////////////////////////////////// template<class T> class KTreeItem { friend class KTree<T>; public: KTreeItem() { m_pParent = NULL; m_pFirstChild = NULL; m_pNextSibling = NULL; } ~KTreeItem() { } const T& GetData() const { return m_data; } T& GetData() { return m_data; } void SetData( const T& data ) { m_data = data; } T m_data; KTreeItem<T>* m_pParent; KTreeItem<T>* m_pFirstChild; KTreeItem<T>* m_pNextSibling; }; class KTreeItemData { public: KTreeItemData() : m_piItemData(NULL), m_bVisual(TRUE), m_bExpand(FALSE), m_bChecked(FALSE), m_dwData(0) { } ~KTreeItemData() { } LPCTSTR GetItemText ( HTREELISTITEM hItem, int nsubindex ) { if (m_piItemData == NULL) return _T(""); return m_piItemData->GetItemText(hItem, nsubindex); } int GetImageIndex( HTREELISTITEM hItem, BOOL bSelected = FALSE ) { if (m_piItemData == NULL) return -1; return m_piItemData->GetImageIndex(hItem, bSelected); } HICON GetIcon( HTREELISTITEM hItem, BOOL bSelected = FALSE ) { if (m_piItemData == NULL) return NULL; return m_piItemData->GetIcon(hItem, bSelected); } HBITMAP GetBitmap( HTREELISTITEM hItem, BOOL bSelected = FALSE ) { if (m_piItemData == NULL) return NULL; return m_piItemData->GetBitmap(hItem, bSelected); } void Filter( HTREELISTITEM hItem , LPCTSTR pszField) { if (m_piItemData == NULL) { m_bVisual = TRUE; } else m_bVisual = m_piItemData->Filter(hItem, pszField); } BOOL OnClicked( HTREELISTITEM hItem, int nsubIndex) { if (m_piItemData != NULL) return m_piItemData->OnClicked(hItem, nsubIndex); return FALSE; } public: ITreeListItemData* m_piItemData; BOOL m_bVisual; BOOL m_bExpand; BOOL m_bChecked; DWORD m_dwData; }; class KExpandableTree : public KTree<KTreeItemData> { public: KExpandableTree() { } virtual ~KExpandableTree() { } BOOL KExpandableTree::IsItemExpanded( const HTREELISTITEM pItem ) const { ATLASSERT( pItem != NULL ); return pItem->GetData().m_bExpand; } BOOL KExpandableTree::IsItemVisible( const HTREELISTITEM pItem ) const { ATLASSERT( pItem != NULL ); HTREELISTITEM pParent = pItem; BOOL bVisible = TRUE; if ( !pItem->GetData().m_bVisual ) return FALSE; do { pParent = GetParent( pParent ); if( pParent == NULL ) { break; } bVisible = IsItemExpanded( pParent ) && pParent->GetData().m_bVisual; } while( bVisible ); return bVisible; } BOOL KExpandableTree::ExpandItem( HTREELISTITEM pItem, BOOL bExpand ) { assert( pItem != NULL ); HTREELISTITEM pParent = GetParent( pItem ); if( pParent != NULL && !IsItemExpanded( pParent ) ) { return FALSE; } if( !HasChildren( pItem ) ) { return FALSE; } pItem->GetData().m_bExpand = bExpand; return TRUE; } void KExpandableTree::ExpandTo( HTREELISTITEM pItem ) { pItem = GetParent( pItem ); while( pItem != NULL && !IsItemExpanded( pItem ) ) { pItem->GetData().m_bExpand = TRUE; pItem = GetParent( pItem ); } } int KExpandableTree::GetVisibleItemCount() const { int nVisibleItemCount = 0; HTREELISTITEM pItem = GetRootItem(); if (pItem != NULL) pItem = GetNextVisibleItem( pItem ); while( pItem != NULL ) { nVisibleItemCount++; pItem = GetNextVisibleItem( pItem ); } return nVisibleItemCount; } HTREELISTITEM KExpandableTree::GetNextVisibleItem( const HTREELISTITEM pItem ) const { if( pItem == NULL ) { return GetRootItem() != NULL ? GetNextVisibleItem(GetRootItem()) : NULL; } if( IsItemExpanded( pItem ) && HasChildren( pItem ) && pItem->GetData().m_bVisual ) { return (GetFirstChild( pItem )->GetData().m_bVisual) ? GetFirstChild( pItem ) : GetNextVisibleItem(GetFirstChild( pItem )); } else { HTREELISTITEM pNextItem = GetNextSibling( pItem ); HTREELISTITEM pParent = pItem; while( true ) { while (pNextItem != NULL) { if (pNextItem->GetData().m_bVisual) return pNextItem; pNextItem = GetNextSibling( pNextItem ); } pParent = GetParent( pParent ); if( pParent == NULL || pParent == GetRootItem() ) { break; } pNextItem = GetNextSibling( pParent ); } return pNextItem; } } HTREELISTITEM KExpandableTree::GetVisibleItem( int nIndex ) const { ATLASSERT( nIndex >= 0 ); HTREELISTITEM pItem = GetRootItem(); if (pItem != NULL) pItem = GetNextVisibleItem( pItem ); for( int i = 0; i < nIndex; i++ ) { pItem = GetNextVisibleItem( pItem ); if( pItem == NULL ) { break; } } return pItem; } int KExpandableTree::GetVisibleItemIndex( const HTREELISTITEM pItem ) const { int nIndex = 0; HTREELISTITEM pTargetItem = GetRootItem(); pTargetItem = GetNextVisibleItem( pTargetItem ); while( pTargetItem != NULL ) { if( pTargetItem == pItem ) { break; } pTargetItem = GetNextVisibleItem( pTargetItem ); nIndex++; } return ( pTargetItem == NULL ) ? -1 : nIndex; } int KExpandableTree::GetItemLayer( HTREELISTITEM pItem ) const { int nLayer = -1; HTREELISTITEM pParent = pItem; while( pParent != NULL ) { pParent = GetParent( pParent ); nLayer++; } return nLayer; } private: }; class CSkinTreeListCtrl : public KSGUI::SkinWindowImpl<CSkinTreeListCtrl, KSGUI::CSkinListViewCtrl>, public WTL::COwnerDraw<CSkinTreeListCtrl>, public WTL::CDoubleBufferImpl<CSkinTreeListCtrl> { private: typedef KSGUI::SkinWindowImpl<CSkinTreeListCtrl, KSGUI::CSkinListViewCtrl> theBaseClass; public: //------------------------------------------------------------------------------------------ // 构造 析构 //------------------------------------------------------------------------------------------ CSkinTreeListCtrl(void) { m_bTreeView = TRUE; m_nTreeIndent = 19; m_crSelectedItem = ::GetSysColor( COLOR_HIGHLIGHT ); m_tree.GetRootItem()->GetData().m_bExpand = TRUE; m_sizeImage.cx = 16; m_sizeImage.cy = 16; } ~CSkinTreeListCtrl(void) { } BOOL SubclassWindow( HWND hWnd ) { BOOL bRet = theBaseClass::SubclassWindow( hWnd ); if( bRet ) { _Init(); } return bRet; } BOOL SetTreeViewStyle(BOOL bTreeView = TRUE) { BOOL bResult = m_bTreeView; m_bTreeView = bTreeView; return bResult; } //------------------------------------------------------------------------------------------ // 操作 //------------------------------------------------------------------------------------------ /** * @brief 插入结点 * @param [in] lpszItem, 结点名称 * @param [in] nImage, 结点图标 * @param [in] nSelectedImage, 选择时的图标 * @param [in] pParent, 父结点, 如果父结点为NULL, 则插入根结点 * @return 指向该结点的指针, 可以当成标示该结点的句柄 * @remark */ HTREELISTITEM InsertItem( LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREELISTITEM pParent = NULL ) { ATLASSERT(FALSE); return NULL; } /** * @brief 插入结点 * @param [in] lpszItem, 结点名称 * @param [in] pParent, 父结点, 如果父结点为NULL, 则插入根结点 * @return 指向该结点的指针, 可以当成标示该结点的句柄 * @remark */ HTREELISTITEM InsertItem( ITreeListItemData* piData, HTREELISTITEM pParent = NULL ) { KTreeItemData data; data.m_bExpand = FALSE; data.m_piItemData = piData; HTREELISTITEM pItem = m_tree.InsertItem( data, pParent ); if( ( pItem != NULL ) && m_tree.IsItemVisible( pItem ) ) { _Refresh( pItem, pItem ); } return pItem; } /** * @brief 删除结点( 包含该结点的所有子结点 ) * @param [in] pItem, 该节点的地址( 由InsertItem返回 ) * @remark */ void DeleteItem( HTREELISTITEM pItem ) { ATLASSERT( pItem != NULL ); int nDeletedItem = m_tree.GetVisibleItemIndex( pItem ); m_tree.DeleteItem( pItem ); pItem = NULL; if( nDeletedItem != -1 ) { _Refresh( nDeletedItem - 1, -1 ); } } /** * @brief 删除结点( 包含该结点的所有子结点 ) * @param [in] nItem, 目前(展开可见的)第nItem个结点 * @remark */ void DeleteItem( int nItem ) { ATLASSERT( nItem >= 0 ); HTREELISTITEM pItem = m_tree.GetVisibleItem( nItem ); DeleteItem( pItem ); } void SetItemVisual( HTREELISTITEM pItem, BOOL bVisual = TRUE ) { ATLASSERT( pItem != NULL ); int nItemIndex = m_tree.GetVisibleItemIndex( pItem ); pItem->GetData().m_bVisual = bVisual; if( nItemIndex != -1 ) { _Refresh( nItemIndex - 1, -1 ); } } HTREELISTITEM GetVisibleItem( int nIndex ) const { return m_tree.GetVisibleItem(nIndex); } int GetVisibleItemCount() const { return m_tree.GetVisibleItemCount(); } int GetVisibleItemIndex( const HTREELISTITEM pItem ) const { return m_tree.GetVisibleItemIndex(pItem); } void SetFilter( LPCTSTR pszFilter , HTREELISTITEM pItem = NULL) { int nSelIndex = GetSelectedIndex(); if ( nSelIndex >= 0 ) { SetItemState(nSelIndex, 0, LVIS_SELECTED | LVIS_FOCUSED); } _SetFilter(pszFilter, pItem); Refresh(); } void _SetFilter( LPCTSTR pszFilter , HTREELISTITEM pItem ) { HTREELISTITEM hNextItem = m_tree.GetFirstChild( m_tree.GetRootItem() ); while (hNextItem != NULL) { hNextItem->GetData().Filter(hNextItem, pszFilter); hNextItem = m_tree.GetNextSibling( hNextItem ); } //if (pItem == NULL) //{ // _SetFilter(pszFilter, m_tree.GetRootItem()); // return; //} //pItem->GetData().Filter(pItem, pszFilter); //HTREELISTITEM hNextItem = m_tree.GetFirstChild( pItem ); //while (hNextItem != NULL) //{ // _SetFilter( pszFilter, hNextItem ); // hNextItem = m_tree.GetNextSibling( hNextItem ); //} } /** * @brief 展开结点 * @param [in] pItem, 待展开的节点的地址( 由InsertItem返回 ) * @param [in] bExpand, TRUE表示展开 FALSE表示收拢 * @remark */ void Expand( HTREELISTITEM pItem, BOOL bExpand ) { ATLASSERT( pItem != NULL ); if( m_tree.ExpandItem( pItem, bExpand ) ) { _Refresh( pItem ); } } /** * @brief 展开pItem路径上所有结点, 使pItem可见 * @param [in] pItem, 待展开的节点的地址( 由InsertItem返回 ) * @remark pItem本身并不展开 */ void ExpandTo( HTREELISTITEM pItem ) { m_tree.ExpandTo( pItem ); _Refresh( 0, -1 ); } /** * @brief 为各子结点设置显示的文字 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [in] nSubItem, 结点的第几列 * @param [in] lpszText, 文字 * @remark */ //BOOL SetItemText( HTREELISTITEM pItem, int nSubItem, LPCTSTR lpszText ); /** * @brief 获取结点的显示文字 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [in] nSubItem, 结点的第几列 * @param [out] strText, 返回文字 * @remark */ //BOOL GetItemText( HTREELISTITEM pItem, int nSubItem, ATL::CString& strText ); /** * @brief 设置结点图片 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [in] nImage, 和该树列表相关的Imagelist中的图片Index, -1为没有图片 * @param [in] nSelectedImage, 结点被选中时的图片 * @remark */ //void SetItemImage( HTREELISTITEM pItem, int nImage, int nSelectedImage, BOOL bRedraw = TRUE ); /** * @brief 获取结点图片 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [out] nImage, 和该树列表相关的Imagelist中的图片Index, -1为没有图片 * @param [out] nSelectedImage, 结点被选中时的图片 * @remark */ //void GetItemImage( HTREELISTITEM pItem, int& nImage, int& nSelectedImage ); /** * @brief 设置某列是否使用checkbox * @param [in] nColumn, 列, 0-based index * @param [in] bCheckable, TRUE表示该列使用checkbox, FALSE表示不使用(默认不使用) * @remark */ void SetColumnCheckable( int nColumn, BOOL bCheckable ) { HDITEM hdItem = {0}; hdItem.mask = HDI_LPARAM; CHeaderCtrl header = GetHeader(); header.GetItem( nColumn, &hdItem ); hdItem.lParam = bCheckable; header.SetItem( nColumn, &hdItem ); } /** * @brief 检查某列是否使用了checkbox * @param [in] nColumn, 列, 0-based index * @return 如果该列使用了CheckBox返回TRUE, 否则返回FALSE * @remark */ BOOL IsColumnCheckable( int nColumn ) const { HDITEM hdItem = {0}; hdItem.mask = HDI_LPARAM; CHeaderCtrl header = GetHeader(); header.GetItem( nColumn, &hdItem ); return (BOOL)hdItem.lParam; } /** * @brief 获取子结点的Check状态 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [in] nSubItem, 子结点 * @return 返回该子结点是否check * @remark */ BOOL GetSubItemCheckStatus( HTREELISTITEM pItem, int nSubItem ) const { if (pItem == NULL) return FALSE; return pItem->GetData().m_bChecked; } /** * @brief 设置子结点的Check状态 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [in] nSubItem, 子结点 * @param [in] bCheckStatus, check状态 * @return 成功返回TURE, 失败(该列没有使用checkbox)返回FALSE * @remark */ BOOL SetSubItemCheckStatus( HTREELISTITEM pItem, int nSubItem, BOOL bCheckStatus ) { if( IsColumnCheckable( nSubItem ) ) { pItem->GetData().m_bChecked = bCheckStatus; int nItem = m_tree.GetVisibleItemIndex( pItem ); if( nItem != -1 ) { RedrawItems( nItem, nItem ); } return TRUE; } else { return FALSE; } } /** * @brief 在指定的结点上设置一个32位的关联数据 * @param [in] pItem, 结点( 由InsertItem返回 ) * @param [in] dwData, 关联数据 * @remark */ void SetItemData( HTREELISTITEM pItem, DWORD dwData ) { pItem->GetData().m_dwData = dwData; } /** * @brief 获取指定的结点上的关联数据 * @param [in] pItem, 结点( 由InsertItem返回 ) * @return 关联数据 * @remark */ DWORD GetItemData( HTREELISTITEM pItem ) const { return pItem->GetData().m_dwData; } /** * @brief 删除所有结点 * @remark */ BOOL DeleteAllItems() { BOOL bRet = TRUE; m_tree.Clear(); _Refresh( 0 ); return bRet; } /** * @brief 刷新所有结点 * @remark */ void Refresh() { _Refresh( 0, -1 ); } /** * @brief 获取当前所选择的结点 * @remark */ HTREELISTITEM GetSelectedItem() const { int nCurSel = GetSelectedIndex(); if( nCurSel >= 0 ) { return m_tree.GetVisibleItem( nCurSel ); } else { return NULL; } } enum ENUM_HIT_SPEC{ eNormal = 0, eFlagBtn, eCheckBox, eImage }; struct FBHITTESTINFO { HTREELISTITEM pItem; int nItem; int nSubItem; ENUM_HIT_SPEC eHitSpec; }; /** * @brief 点击测试, 测试某点 在树-列表的哪个位置 * @param [in] pt, 待测试的点 * @param [out] pHitTestInfo, 位置信息 * @remark */ void HitTest( const POINT& pt, FBHITTESTINFO* pInfo ) { memset( pInfo, 0, sizeof( FBHITTESTINFO ) ); LVHITTESTINFO lvhti; lvhti.pt = pt; SubItemHitTest( &lvhti ); //------------------------------------- // 常规信息 pInfo->nItem = lvhti.iItem; pInfo->nSubItem = lvhti.iSubItem; if( lvhti.iItem < 0 ) { return; } pInfo->pItem = m_tree.GetVisibleItem( pInfo->nItem ); //------------------------------------- // 特殊信息 CRect rcUnit; GetSubItemRect( lvhti.iItem, lvhti.iSubItem, LVIR_BOUNDS, &rcUnit ); int xOffset = rcUnit.left; // 测试是否在 树的展开收缩标记上 if( m_bTreeView && lvhti.iSubItem == 0 ) { int nLayer = m_tree.GetItemLayer( pInfo->pItem ); nLayer--; xOffset += nLayer * m_nTreeIndent; if( pt.x > xOffset && pt.x < xOffset + m_nTreeIndent && m_tree.HasChildren( pInfo->pItem ) ) { pInfo->eHitSpec = eFlagBtn; return; } xOffset += m_nTreeIndent; } // 测试是否在 check box上 if( IsColumnCheckable( lvhti.iSubItem ) ) { if( pt.x > xOffset && pt.x < xOffset + m_nTreeIndent ) { pInfo->eHitSpec = eCheckBox; return; } xOffset += m_nTreeIndent; } // 测试是否在 图标上 if( lvhti.iSubItem == 0 ) { if( pt.x > xOffset && pt.x < xOffset + m_nTreeIndent ) { pInfo->eHitSpec = eImage; return; } } return; } /** * @brief 设置图像列表 * @param [in] hImageList, 图像列表 * @remark */ CImageList SetImageList( HIMAGELIST hImageList , int nImageWidth = -1, int nImageHeight = -1) { if( hImageList == NULL ) { return NULL; } if ( nImageWidth < 0 ) { IMAGEINFO info = {0}; ImageList_GetImageInfo( hImageList, 0, &info ); CRect rcImage = info.rcImage; m_sizeImage.cx = rcImage.Width(); m_sizeImage.cy = rcImage.Height(); } else { m_sizeImage.cx = nImageWidth; m_sizeImage.cy = nImageHeight; } m_nTreeIndent = max( m_nTreeIndent, m_sizeImage.cx ); return theBaseClass::SetImageList( hImageList, LVSIL_SMALL ); } /** * @brief 设置结点被选中后的颜色 * @param [in] crSelectedItem, 颜色 * @remark */ void SetSelectedItemColor( COLORREF crSelectedItem ) { m_crSelectedItem = crSelectedItem; } //------------------------------------------------------------------------------------------ // 消息处理 //------------------------------------------------------------------------------------------ BEGIN_MSG_MAP( CSkinRichEditCtrl ) MESSAGE_HANDLER( WM_CREATE, OnCreate ) MESSAGE_HANDLER( WM_LBUTTONDOWN, OnLButtonDown ) MESSAGE_HANDLER( WM_LBUTTONDBLCLK, OnLButtonDblClk ) CHAIN_MSG_MAP_ALT( WTL::COwnerDraw<CSkinTreeListCtrl>, 1 ) CHAIN_MSG_MAP( WTL::CDoubleBufferImpl<CSkinTreeListCtrl> ) DEFAULT_REFLECTION_HANDLER() END_MSG_MAP() LRESULT OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { _Init(); return 0; } virtual LRESULT OnLButtonDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { if (::GetFocus() != m_hWnd) SetFocus(); int xPos = GET_X_LPARAM( lParam ); int yPos = GET_Y_LPARAM( lParam ); FBHITTESTINFO fbHitInfo; HitTest( CPoint( xPos, yPos ), &fbHitInfo ); if( fbHitInfo.nItem < 0 || fbHitInfo.pItem == NULL) { return 0; } if( fbHitInfo.eHitSpec == eCheckBox ) { BOOL bLastCheckStatus = GetSubItemCheckStatus( fbHitInfo.pItem, fbHitInfo.nSubItem ); OnClickedCheckbox( fbHitInfo.pItem, fbHitInfo.nItem, fbHitInfo.nSubItem, bLastCheckStatus ); } else if( fbHitInfo.eHitSpec == eFlagBtn ) { OnClickedFlagBtn( fbHitInfo.pItem, fbHitInfo.nItem, m_tree.IsItemExpanded( fbHitInfo.pItem ) ); } else if( fbHitInfo.eHitSpec == eImage ) { OnClickedImage( fbHitInfo.pItem, fbHitInfo.nItem ); } else { OnClickedItem( fbHitInfo.pItem, fbHitInfo.nItem , fbHitInfo.nSubItem); } Invalidate(FALSE); return 0; } LRESULT OnLButtonDblClk( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { if (::GetFocus() != m_hWnd) SetFocus(); int xPos = GET_X_LPARAM( lParam ); int yPos = GET_Y_LPARAM( lParam ); FBHITTESTINFO fbHitInfo; HitTest( CPoint( xPos, yPos ), &fbHitInfo ); if( fbHitInfo.nItem < 0 ) { return 0; } if( fbHitInfo.eHitSpec == eCheckBox ) { BOOL bLastCheckStatus = GetSubItemCheckStatus( fbHitInfo.pItem, fbHitInfo.nSubItem ); OnClickedCheckbox( fbHitInfo.pItem, fbHitInfo.nItem, fbHitInfo.nSubItem, bLastCheckStatus ); } else if( fbHitInfo.eHitSpec == eImage ) { OnClickedImage( fbHitInfo.pItem, fbHitInfo.nItem ); } else { OnClickedFlagBtn( fbHitInfo.pItem, fbHitInfo.nItem, m_tree.IsItemExpanded( fbHitInfo.pItem ) ); } Invalidate(FALSE); DefWindowProc(); return 0; } void DoPaint( CDCHandle dcPaint ) { DefWindowProc( WM_ERASEBKGND, (WPARAM)dcPaint.m_hDC, 0 ); DefWindowProc( WM_PAINT, (WPARAM)dcPaint.m_hDC, 0 ); //::DefWindowProc(GetHeader(), WM_ERASEBKGND, (WPARAM)dcPaint.m_hDC, 0 ); //::DefWindowProc(GetHeader(), WM_PAINT, (WPARAM)dcPaint.m_hDC, 0); GetHeader().Invalidate(FALSE); } virtual void DrawItem( LPDRAWITEMSTRUCT lpdis ) { CDCHandle dc = lpdis->hDC; CRect rcItem = lpdis->rcItem; int nIndex = lpdis->itemID; HTREELISTITEM pItem = m_tree.GetVisibleItem( nIndex ); int nLayer = m_tree.GetItemLayer( pItem ); int nColumnCount = GetHeader().GetItemCount(); BOOL bDisabled = !IsWindowEnabled(); if( nIndex == -1 ) { return; } nLayer--; for( int nCol = 0; nCol < nColumnCount; nCol++ ) { CRect rcTreeUnit; GetSubItemRect( nIndex, nCol, LVIR_BOUNDS, &rcTreeUnit ); //------------------------------------- // 刷背景 { int nSavedDC = dc.SaveDC(); CBrush brushBkground; CPen penBkground; if( bDisabled ) { COLORREF crBkground = ::GetSysColor( COLOR_BTNFACE ); brushBkground.CreateSolidBrush( crBkground ); penBkground.CreatePen( PS_SOLID, 1, crBkground ); dc.SelectBrush( brushBkground ); dc.SelectPen( penBkground ); } else if( lpdis->itemState & ODS_SELECTED ) { COLORREF crBkground = m_crSelectedItem; brushBkground.CreateSolidBrush( crBkground ); penBkground.CreatePen( PS_SOLID, 1, crBkground ); dc.SelectBrush( brushBkground ); dc.SelectPen( penBkground ); } else { dc.SelectStockPen( WHITE_PEN ); dc.SelectStockBrush( WHITE_BRUSH ); } dc.Rectangle( &rcTreeUnit ); dc.RestoreDC( nSavedDC ); } //------------------------------------- // 画线 if( m_bTreeView && nCol == 0 && m_tree.Size() > 1 ) { int nSavedDC = dc.SaveDC(); CPoint ptStart; CPoint ptEnd; const int xFlagBtnCenter = rcTreeUnit.left + m_nTreeIndent * nLayer + m_nTreeIndent / 2; { ptStart.x = xFlagBtnCenter; ptStart.y = rcTreeUnit.top + rcTreeUnit.Height() / 2; ptEnd.x = ptStart.x + m_nTreeIndent; ptEnd.y = ptStart.y; DrawTreeline( dc, ptStart, ptEnd ); } if( nIndex != 0 ) { ptStart.x = xFlagBtnCenter; ptStart.y = rcTreeUnit.top; ptEnd.x = ptStart.x; ptEnd.y = ptStart.y + ( ( m_tree.GetNextSibling( pItem ) != NULL ) ? rcTreeUnit.Height() : rcTreeUnit.Height() / 2 ); DrawTreeline( dc, ptStart, ptEnd ); } { HTREELISTITEM pParentItem = m_tree.GetParent( pItem ); int xLinePos = xFlagBtnCenter; while( pParentItem != NULL ) { xLinePos -= m_nTreeIndent; if( m_tree.GetNextSibling( pParentItem ) != NULL ) { ptStart.x = xLinePos; ptStart.y = rcTreeUnit.top; ptEnd.x = ptStart.x; ptEnd.y = ptStart.y + rcTreeUnit.Height(); DrawTreeline( dc, ptStart, ptEnd ); } pParentItem = m_tree.GetParent( pParentItem ); } } dc.RestoreDC( nSavedDC ); } //------------------------------------- // 画树展开标记 // 标记宽度 = CTRL_WIDTH_TREEFLAG if( m_bTreeView && nCol == 0 ) { rcTreeUnit.left += nLayer * m_nTreeIndent; int x = ( m_nTreeIndent - TREE_FLAG_WIDTH ) / 2; int y = ( rcTreeUnit.Height() - TREE_FLAG_WIDTH ) / 2; int nStatus = m_tree.HasChildren( pItem ) ? ( m_tree.IsItemExpanded( pItem ) ? TFS_EXPANDED : TFS_RETRACTILE ) : TFS_NOCHILD; DrawTreeExpandFlag( dc, rcTreeUnit.left + x, rcTreeUnit.top + y, nStatus ); rcTreeUnit.left += m_nTreeIndent; } //------------------------------------- // 画Checkbox // checkbox宽度 = CTRL_WIDTH_CHECKBOX if( IsColumnCheckable( nCol) ) { BOOL bChecked = GetSubItemCheckStatus( pItem, nCol ); int nStatus = 0; nStatus = bDisabled ? CBS_DISABLED : CBS_NORMAL; nStatus |= ( bChecked ? CBS_CHECKED : 0 ); int x = ( m_nTreeIndent - CHECKBOX_WIDTH ) / 2; int y = ( rcTreeUnit.Height() - CHECKBOX_WIDTH ) / 2; DrawCheckBox( dc, rcTreeUnit.left + x, rcTreeUnit.top + y, nStatus ); rcTreeUnit.left += m_nTreeIndent; } //------------------------------------- // 画图标 if( nCol == 0 ) { HICON hIcon = NULL; HBITMAP hBmp = NULL; if ( (hIcon = pItem->GetData().GetIcon(pItem, ( lpdis->itemState & ODS_SELECTED ) )) != NULL ) { int x = rcTreeUnit.left + ( m_nTreeIndent - m_sizeImage.cx ) / 2; int y = rcTreeUnit.top + ( rcTreeUnit.Height() - m_sizeImage.cy ) / 2; ::DrawIconEx( dc, x, y, hIcon, 16, 16, 0, NULL, DI_NORMAL); rcTreeUnit.left += 22; } else if ( (hBmp = pItem->GetData().GetBitmap(pItem, ( lpdis->itemState & ODS_SELECTED ) )) != NULL ) { int x = rcTreeUnit.left + ( m_nTreeIndent - m_sizeImage.cx ) / 2; int y = rcTreeUnit.top + ( rcTreeUnit.Height() - m_sizeImage.cy ) / 2; CDC dcMem; dcMem.CreateCompatibleDC(dc); HBITMAP hOldBmp = dcMem.SelectBitmap( hBmp ); dc.BitBlt( x, y, 16, 16, dcMem, 0, 0, SRCCOPY ); dcMem.SelectBitmap( hOldBmp ); rcTreeUnit.left += 22; } else { CImageList imagelist = GetImageList( LVSIL_SMALL ); if( !imagelist.IsNull() ) { int nImage = ( lpdis->itemState & ODS_SELECTED ) ? pItem->GetData().GetImageIndex(pItem, TRUE) : pItem->GetData().GetImageIndex(pItem, FALSE); if( nImage >= 0 && m_sizeImage.cy <= rcTreeUnit.Height() && m_sizeImage.cx <= rcTreeUnit.Width() ) { int x = rcTreeUnit.left + ( m_nTreeIndent - m_sizeImage.cx ) / 2; int y = rcTreeUnit.top + ( rcTreeUnit.Height() - m_sizeImage.cy ) / 2; imagelist.Draw( dc, nImage, CPoint( x, y ), ILD_TRANSPARENT ); rcTreeUnit.left += m_nTreeIndent + 6; } } } } //------------------------------------- // 显示文字 // 宽度 = 剩余所有宽度 { dc.SetTextColor( (lpdis->itemState & ODS_SELECTED) ? GetSysColor(COLOR_HIGHLIGHTTEXT) : GetSysColor(COLOR_WINDOWTEXT)); ATL::CString strText = pItem->GetData().GetItemText( pItem, nCol ); dc.DrawText( strText, strText.GetLength(), rcTreeUnit, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_WORD_ELLIPSIS ); } } } void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) { } void DeleteItem( LPDELETEITEMSTRUCT lpDeleteItemStruct ) { ATLASSERT( FALSE ); } protected: virtual void OnClickedCheckbox( HTREELISTITEM pItem, int nItem, int nSubItem, BOOL bLastCheckStatus ) { SetSubItemCheckStatus( pItem, nSubItem, !bLastCheckStatus ); CheckSubBox(pItem, nSubItem, !bLastCheckStatus); } virtual void OnClickedFlagBtn( HTREELISTITEM pItem, int nItem, BOOL bLastFlagStatus ) { Expand( pItem, !bLastFlagStatus ); } virtual void OnClickedImage( HTREELISTITEM pItem, int nItem ) { SelectItem( nItem ); } virtual void OnClickedItem( HTREELISTITEM pItem, int nItem , int nSubItem) { SelectItem( nItem ); if ( pItem != NULL ) pItem->GetData().OnClicked(pItem, nSubItem); SendMessage( GetParent(), WM_SUBITEMCLICKED, (WPARAM)pItem, (LPARAM)nItem ); } //------------------------------------------------------------------------------------------ // 辅助功能 //------------------------------------------------------------------------------------------ void _Init() { const DWORD dwStyle = LVS_OWNERDRAWFIXED | LVS_OWNERDATA | LVS_REPORT | LVS_SINGLESEL; ModifyStyle( 0, dwStyle, 0 ); } void _Refresh( HTREELISTITEM pFirstItem = NULL, HTREELISTITEM pLastItem = NULL ) { int nFirstItem = ( pFirstItem == NULL ) ? 0 : m_tree.GetVisibleItemIndex( pFirstItem ); int nLastItem = ( pLastItem == NULL ) ? -1 : m_tree.GetVisibleItemIndex( pLastItem ); if( nFirstItem != -1 ) { _Refresh( nFirstItem, nLastItem ); } } void _Refresh( int nFirstItem = 0, int nLastItem = -1 ) { if( IsWindow() ) { int nItemCount = m_tree.GetVisibleItemCount(); if( nItemCount == 0 ) { SetItemCount( 0 ); } else { SetItemCountEx( nItemCount, LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL ); if( nLastItem == -1 ) { nLastItem = nItemCount - 1; } //ATLASSERT( nFirstItem <= nLastItem ); RedrawItems( nFirstItem, nLastItem ); } } } void CheckSubBox(HTREELISTITEM pItem, int nSubItem, BOOL bLastCheckStatus) { HTREELISTITEM subItem = m_tree.GetFirstChild(pItem); if (subItem != NULL) { CheckSubBox(subItem, nSubItem, bLastCheckStatus); SetSubItemCheckStatus(subItem, nSubItem, bLastCheckStatus); subItem = m_tree.GetNextSibling(subItem); while (subItem) { CheckSubBox(subItem, nSubItem, bLastCheckStatus); SetSubItemCheckStatus(subItem, nSubItem, bLastCheckStatus); subItem = m_tree.GetNextSibling(subItem); } } } protected: KExpandableTree m_tree; CSize m_sizeImage; int m_nTreeIndent; COLORREF m_crSelectedItem; BOOL m_bTreeView; //------------------------------------------------------------------------------------------ // 辅助绘图函数 //------------------------------------------------------------------------------------------ protected: /** * @brief 画树的连接线( 直线 虚线 ) * @param [in] hdc, 目标dc * @param [in] ptStart, 起点 * @param [in] ptEnd, 终点 * @remark */ template<class T> void Swap( T* pT1, T* pT2 ) { T temp = *pT1; *pT1 = *pT2; *pT2 = temp; } void DrawTreeline( HDC hdc, POINT ptStart, POINT ptEnd ) { CDCHandle dc( hdc ); COLORREF crDot = ::GetSysColor( COLOR_BTNSHADOW ); const int nStep = 2; // 控制所有点都在y为偶数的坐标上 (0 - based) if( ptStart.y & 1 ) // 奇数 { ptStart.y++; ptEnd.y++; } if( ptEnd.y - ptStart.y == 0 ) // 水平线 { if( ptEnd.x < ptStart.x ) { Swap( &ptStart, &ptEnd ); } while( ptEnd.x > ptStart.x ) { dc.SetPixel( ptStart.x, ptStart.y, crDot ); ptStart.x += nStep; } } else if( ptEnd.x - ptStart.x == 0 ) // 垂直线 { if( ptEnd.y < ptStart.y ) { Swap( &ptStart, &ptEnd ); } while( ptEnd.y > ptStart.y ) { dc.SetPixel( ptStart.x, ptStart.y, crDot ); ptStart.y += nStep; } } else { ATLASSERT( FALSE && "只画直线" ); } } }; }; // namespace KSGUI
[ [ [ 1, 1660 ] ] ]
ee3e1a644c2966cc81ebc08ea48dfe367b5aa1c5
a6d79692cbc9c2b4952d5844d3cf5ae4998ed7d4
/Other/Source/ThemeSwitcher/GetSettings.h
9d477c4e41cb658fccb1d54a121a93b875c54cf3
[]
no_license
crazy2be/litestepportable
00735f7a3d0688d6379b4d63e25697d793914457
7e0948ee5ac14dc70e4dd5ca70354642176f6470
refs/heads/master
2020-04-26T01:17:19.326333
2009-03-29T22:12:15
2009-03-29T22:12:15
173,199,242
1
0
null
null
null
null
UTF-8
C++
false
false
432
h
#include <fstream> #include <string> #include <sstream> #include "GlobalVars.h" using namespace std; /* Declare Functions */ bool GetBoolValue(string ValueToGet); int GetIntValue(string ValueToGet); string GetValue(string ValueToGet); string GetDefaultValue(string ValueToGet); void SetValue(string Setting, string Value); void SetIntValue(string Setting, int Value); void SetBoolValue(string Setting, bool Value);
[ [ [ 1, 15 ] ] ]
a95f686a76ae32d346d1cc8af474ebb69e068945
21da454a8f032d6ad63ca9460656c1e04440310e
/src/net/worldscale/pimap/wscPimapPacket.cpp
14f1204e228187026d430e52466af24a19f68119
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
2,660
cpp
#include "wscPimapPacket.h" #include "wscPimapConfig.h" WS_IMPL_ClassName_OF( wscPimapPacket ) wscPimapPacket::wscPimapPacket(void) { wspr::ws_memset( &m_head, 0, sizeof(m_head) ); for (ws_int i=(MAX_PARAM_NUMBER-1) ; i>=0 ; i--) { m_param[i].type = TYPE_NULL; m_param[i].value = 0; } m_head.version = wscPimapConfig::PIMAP_VERSION; } wscPimapPacket::~wscPimapPacket(void) { } ws_uint8 wscPimapPacket::GetVersion (void) { return m_head.version; } ws_uint8 wscPimapPacket::GetFlag (void) { return m_head.flag; } ws_uint8 wscPimapPacket::GetXOR (void) { return m_head.xor; } ws_uint8 wscPimapPacket::GetTransID (void) { return m_head.transId; } ws_uint32 wscPimapPacket::GetUserID (void) { return m_head.userId; } ws_uint32 wscPimapPacket::GetKey (void) { return m_head.key; } ws_uint16 wscPimapPacket::GetFunction (void) { return m_head.func; } ws_uint16 wscPimapPacket::GetAddLen (void) { return m_head.addlen; } void wscPimapPacket::SetVersion (ws_uint8 value) { m_head.version = value; } void wscPimapPacket::SetFlag (ws_uint8 value) { m_head.flag = value; } void wscPimapPacket::SetXOR (ws_uint8 value) { m_head.xor = value; } void wscPimapPacket::SetTransID (ws_uint8 value) { m_head.transId = value; } void wscPimapPacket::SetUserID (ws_uint32 value) { m_head.userId = value; } void wscPimapPacket::SetKey (ws_uint32 value) { m_head.key = value; } void wscPimapPacket::SetFunction (ws_uint16 value) { m_head.func = value; } void wscPimapPacket::SetAddLen (ws_uint16 value) { m_head.addlen = value; } void wscPimapPacket::PutParam(ws_uint8 id, ws_uint8 type, ws_uint32 value) { if (id < MAX_PARAM_NUMBER) { m_param[id].type = type; m_param[id].value = value; m_param[id].string.Set( WS_NULL ); } } void wscPimapPacket::PutParam(ws_uint8 id, ws_uint8 type, wsiString *str) { if (id < MAX_PARAM_NUMBER) { m_param[id].type = type; m_param[id].value = 0; m_param[id].string.Set( str ); } } ws_result wscPimapPacket::GetParam(ws_uint8 id, ws_uint8 & type, ws_uint32 & value, wsiString ** rStr) { if (id < MAX_PARAM_NUMBER) { type = m_param[id].type; value = m_param[id].value; m_param[id].string.Get( rStr ); return WS_RLT_SUCCESS ; } else { return WS_RLT_ARRAY_INDEX_OUT_OF_BOUNDS ; } }
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 152 ] ] ]
d177831afed03876a507be3466d5e8f68cb8421b
b83c990328347a0a2130716fd99788c49c29621e
/include/boost/asio/ssl/detail/openssl_stream_service.hpp
6fe5393a8482c7f0bde8ee8d2e40518d9c708c10
[]
no_license
SpliFF/mingwlibs
c6249fbb13abd74ee9c16e0a049c88b27bd357cf
12d1369c9c1c2cc342f66c51d045b95c811ff90c
refs/heads/master
2021-01-18T03:51:51.198506
2010-06-13T15:13:20
2010-06-13T15:13:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,142
hpp
// // stream_service.hpp // ~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com // Copyright (c) 2005-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_SSL_DETAIL_OPENSSL_STREAM_SERVICE_HPP #define BOOST_ASIO_SSL_DETAIL_OPENSSL_STREAM_SERVICE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <boost/asio/detail/push_options.hpp> #include <boost/asio/detail/push_options.hpp> #include <cstddef> #include <climits> #include <memory> #include <boost/config.hpp> #include <boost/noncopyable.hpp> #include <boost/function.hpp> #include <boost/bind.hpp> #include <boost/asio/detail/pop_options.hpp> #include <boost/asio/error.hpp> #include <boost/asio/io_service.hpp> #include <boost/asio/strand.hpp> #include <boost/asio/detail/service_base.hpp> #include <boost/asio/ssl/basic_context.hpp> #include <boost/asio/ssl/stream_base.hpp> #include <boost/asio/ssl/detail/openssl_operation.hpp> #include <boost/asio/ssl/detail/openssl_types.hpp> namespace boost { namespace asio { namespace ssl { namespace detail { class openssl_stream_service : public boost::asio::detail::service_base<openssl_stream_service> { private: enum { max_buffer_size = INT_MAX }; //Base handler for asyncrhonous operations template <typename Stream> class base_handler { public: typedef boost::function< void (const boost::system::error_code&, size_t)> func_t; base_handler(boost::asio::io_service& io_service) : op_(NULL) , io_service_(io_service) , work_(io_service) {} void do_func(const boost::system::error_code& error, size_t size) { func_(error, size); } void set_operation(openssl_operation<Stream>* op) { op_ = op; } void set_func(func_t func) { func_ = func; } ~base_handler() { delete op_; } private: func_t func_; openssl_operation<Stream>* op_; boost::asio::io_service& io_service_; boost::asio::io_service::work work_; }; // class base_handler // Handler for asynchronous IO (write/read) operations template<typename Stream, typename Handler> class io_handler : public base_handler<Stream> { public: io_handler(Handler handler, boost::asio::io_service& io_service) : base_handler<Stream>(io_service) , handler_(handler) { set_func(boost::bind( &io_handler<Stream, Handler>::handler_impl, this, boost::arg<1>(), boost::arg<2>() )); } private: Handler handler_; void handler_impl(const boost::system::error_code& error, size_t size) { std::auto_ptr<io_handler<Stream, Handler> > this_ptr(this); handler_(error, size); } }; // class io_handler // Handler for asyncrhonous handshake (connect, accept) functions template <typename Stream, typename Handler> class handshake_handler : public base_handler<Stream> { public: handshake_handler(Handler handler, boost::asio::io_service& io_service) : base_handler<Stream>(io_service) , handler_(handler) { set_func(boost::bind( &handshake_handler<Stream, Handler>::handler_impl, this, boost::arg<1>(), boost::arg<2>() )); } private: Handler handler_; void handler_impl(const boost::system::error_code& error, size_t) { std::auto_ptr<handshake_handler<Stream, Handler> > this_ptr(this); handler_(error); } }; // class handshake_handler // Handler for asyncrhonous shutdown template <typename Stream, typename Handler> class shutdown_handler : public base_handler<Stream> { public: shutdown_handler(Handler handler, boost::asio::io_service& io_service) : base_handler<Stream>(io_service), handler_(handler) { set_func(boost::bind( &shutdown_handler<Stream, Handler>::handler_impl, this, boost::arg<1>(), boost::arg<2>() )); } private: Handler handler_; void handler_impl(const boost::system::error_code& error, size_t) { std::auto_ptr<shutdown_handler<Stream, Handler> > this_ptr(this); handler_(error); } }; // class shutdown_handler public: // The implementation type. typedef struct impl_struct { ::SSL* ssl; ::BIO* ext_bio; net_buffer recv_buf; } * impl_type; // Construct a new stream socket service for the specified io_service. explicit openssl_stream_service(boost::asio::io_service& io_service) : boost::asio::detail::service_base<openssl_stream_service>(io_service), strand_(io_service) { } // Destroy all user-defined handler objects owned by the service. void shutdown_service() { } // Return a null stream implementation. impl_type null() const { return 0; } // Create a new stream implementation. template <typename Stream, typename Context_Service> void create(impl_type& impl, Stream& next_layer, basic_context<Context_Service>& context) { impl = new impl_struct; impl->ssl = ::SSL_new(context.impl()); ::SSL_set_mode(impl->ssl, SSL_MODE_ENABLE_PARTIAL_WRITE); ::SSL_set_mode(impl->ssl, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); ::BIO* int_bio = 0; impl->ext_bio = 0; ::BIO_new_bio_pair(&int_bio, 8192, &impl->ext_bio, 8192); ::SSL_set_bio(impl->ssl, int_bio, int_bio); } // Destroy a stream implementation. template <typename Stream> void destroy(impl_type& impl, Stream& next_layer) { if (impl != 0) { ::BIO_free(impl->ext_bio); ::SSL_free(impl->ssl); delete impl; impl = 0; } } // Perform SSL handshaking. template <typename Stream> boost::system::error_code handshake(impl_type& impl, Stream& next_layer, stream_base::handshake_type type, boost::system::error_code& ec) { try { openssl_operation<Stream> op( type == stream_base::client ? &ssl_wrap<mutex_type>::SSL_connect: &ssl_wrap<mutex_type>::SSL_accept, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio); op.start(); } catch (boost::system::system_error& e) { ec = e.code(); return ec; } ec = boost::system::error_code(); return ec; } // Start an asynchronous SSL handshake. template <typename Stream, typename Handler> void async_handshake(impl_type& impl, Stream& next_layer, stream_base::handshake_type type, Handler handler) { typedef handshake_handler<Stream, Handler> connect_handler; connect_handler* local_handler = new connect_handler(handler, get_io_service()); openssl_operation<Stream>* op = new openssl_operation<Stream> ( type == stream_base::client ? &ssl_wrap<mutex_type>::SSL_connect: &ssl_wrap<mutex_type>::SSL_accept, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio, boost::bind ( &base_handler<Stream>::do_func, local_handler, boost::arg<1>(), boost::arg<2>() ), strand_ ); local_handler->set_operation(op); strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); } // Shut down SSL on the stream. template <typename Stream> boost::system::error_code shutdown(impl_type& impl, Stream& next_layer, boost::system::error_code& ec) { try { openssl_operation<Stream> op( &ssl_wrap<mutex_type>::SSL_shutdown, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio); op.start(); } catch (boost::system::system_error& e) { ec = e.code(); return ec; } ec = boost::system::error_code(); return ec; } // Asynchronously shut down SSL on the stream. template <typename Stream, typename Handler> void async_shutdown(impl_type& impl, Stream& next_layer, Handler handler) { typedef shutdown_handler<Stream, Handler> disconnect_handler; disconnect_handler* local_handler = new disconnect_handler(handler, get_io_service()); openssl_operation<Stream>* op = new openssl_operation<Stream> ( &ssl_wrap<mutex_type>::SSL_shutdown, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio, boost::bind ( &base_handler<Stream>::do_func, local_handler, boost::arg<1>(), boost::arg<2>() ), strand_ ); local_handler->set_operation(op); strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); } // Write some data to the stream. template <typename Stream, typename Const_Buffers> std::size_t write_some(impl_type& impl, Stream& next_layer, const Const_Buffers& buffers, boost::system::error_code& ec) { size_t bytes_transferred = 0; try { std::size_t buffer_size = boost::asio::buffer_size(*buffers.begin()); if (buffer_size > max_buffer_size) buffer_size = max_buffer_size; boost::function<int (SSL*)> send_func = boost::bind(boost::type<int>(), &::SSL_write, boost::arg<1>(), boost::asio::buffer_cast<const void*>(*buffers.begin()), static_cast<int>(buffer_size)); openssl_operation<Stream> op( send_func, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio ); bytes_transferred = static_cast<size_t>(op.start()); } catch (boost::system::system_error& e) { ec = e.code(); return 0; } ec = boost::system::error_code(); return bytes_transferred; } // Start an asynchronous write. template <typename Stream, typename Const_Buffers, typename Handler> void async_write_some(impl_type& impl, Stream& next_layer, const Const_Buffers& buffers, Handler handler) { typedef io_handler<Stream, Handler> send_handler; send_handler* local_handler = new send_handler(handler, get_io_service()); std::size_t buffer_size = boost::asio::buffer_size(*buffers.begin()); if (buffer_size > max_buffer_size) buffer_size = max_buffer_size; boost::function<int (SSL*)> send_func = boost::bind(boost::type<int>(), &::SSL_write, boost::arg<1>(), boost::asio::buffer_cast<const void*>(*buffers.begin()), static_cast<int>(buffer_size)); openssl_operation<Stream>* op = new openssl_operation<Stream> ( send_func, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio, boost::bind ( &base_handler<Stream>::do_func, local_handler, boost::arg<1>(), boost::arg<2>() ), strand_ ); local_handler->set_operation(op); strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); } // Read some data from the stream. template <typename Stream, typename Mutable_Buffers> std::size_t read_some(impl_type& impl, Stream& next_layer, const Mutable_Buffers& buffers, boost::system::error_code& ec) { size_t bytes_transferred = 0; try { std::size_t buffer_size = boost::asio::buffer_size(*buffers.begin()); if (buffer_size > max_buffer_size) buffer_size = max_buffer_size; boost::function<int (SSL*)> recv_func = boost::bind(boost::type<int>(), &::SSL_read, boost::arg<1>(), boost::asio::buffer_cast<void*>(*buffers.begin()), static_cast<int>(buffer_size)); openssl_operation<Stream> op(recv_func, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio ); bytes_transferred = static_cast<size_t>(op.start()); } catch (boost::system::system_error& e) { ec = e.code(); return 0; } ec = boost::system::error_code(); return bytes_transferred; } // Start an asynchronous read. template <typename Stream, typename Mutable_Buffers, typename Handler> void async_read_some(impl_type& impl, Stream& next_layer, const Mutable_Buffers& buffers, Handler handler) { typedef io_handler<Stream, Handler> recv_handler; recv_handler* local_handler = new recv_handler(handler, get_io_service()); std::size_t buffer_size = boost::asio::buffer_size(*buffers.begin()); if (buffer_size > max_buffer_size) buffer_size = max_buffer_size; boost::function<int (SSL*)> recv_func = boost::bind(boost::type<int>(), &::SSL_read, boost::arg<1>(), boost::asio::buffer_cast<void*>(*buffers.begin()), static_cast<int>(buffer_size)); openssl_operation<Stream>* op = new openssl_operation<Stream> ( recv_func, next_layer, impl->recv_buf, impl->ssl, impl->ext_bio, boost::bind ( &base_handler<Stream>::do_func, local_handler, boost::arg<1>(), boost::arg<2>() ), strand_ ); local_handler->set_operation(op); strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); } // Peek at the incoming data on the stream. template <typename Stream, typename Mutable_Buffers> std::size_t peek(impl_type& impl, Stream& next_layer, const Mutable_Buffers& buffers, boost::system::error_code& ec) { ec = boost::system::error_code(); return 0; } // Determine the amount of data that may be read without blocking. template <typename Stream> std::size_t in_avail(impl_type& impl, Stream& next_layer, boost::system::error_code& ec) { ec = boost::system::error_code(); return 0; } private: boost::asio::io_service::strand strand_; typedef boost::asio::detail::mutex mutex_type; template<typename Mutex> struct ssl_wrap { static Mutex ssl_mutex_; static int SSL_accept(SSL *ssl) { typename Mutex::scoped_lock lock(ssl_mutex_); return ::SSL_accept(ssl); } static int SSL_connect(SSL *ssl) { typename Mutex::scoped_lock lock(ssl_mutex_); return ::SSL_connect(ssl); } static int SSL_shutdown(SSL *ssl) { typename Mutex::scoped_lock lock(ssl_mutex_); return ::SSL_shutdown(ssl); } }; }; template<typename Mutex> Mutex openssl_stream_service::ssl_wrap<Mutex>::ssl_mutex_; } // namespace detail } // namespace ssl } // namespace asio } // namespace boost #include <boost/asio/detail/pop_options.hpp> #endif // BOOST_ASIO_SSL_DETAIL_OPENSSL_STREAM_SERVICE_HPP
[ [ [ 1, 534 ] ] ]
51c0f10e092fa7b46f60b0537d0ca381ff31f330
b2c66c8de198d9915dfc63b8c60cb82e57643a6b
/WordsCheater/trunk/PositionArbitrator.h
615e82fbd12dbe767c916b652e522ab91c563ed0
[]
no_license
feleio/words-with-friends-exhaustive-cheater
88d6d401c28ef7bb82099c0cd9d77459828b89ca
bc198ee2677be02fc935fb8bb8e74b580f0540df
refs/heads/master
2021-01-02T08:54:47.975272
2011-05-10T14:51:06
2011-05-10T14:51:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
557
h
#ifndef POSITIONARBITRATOR_H #define POSITIONARBITRATOR_H #include "Position.h" #include <vector> class Board; class PositionArbitrator { public: explicit PositionArbitrator( Board* board ); virtual ~PositionArbitrator( ); void Reset( ); std::vector<Position>& GetPositionsToPlace( ); private: void AddEndsToResult( int row, int col, bool isVertical ); private: Board* m_board; std::vector<Position> m_positionsFor1stPlaced; std::vector<Position> m_positions; }; #endif
[ "[email protected]@2165158a-c2d0-8582-d542-857db5896f79" ]
[ [ [ 1, 28 ] ] ]
d5ec12b5a436d9ee08606409e2027a153c054221
465943c5ffac075cd5a617c47fd25adfe496b8b4
/INTOAIRP.CPP
e066e5f99a186fb667d25771ee574c194310bfeb
[]
no_license
paulanthonywilson/airtrafficcontrol
7467f9eb577b24b77306709d7b2bad77f1b231b7
6c579362f30ed5f81cabda27033f06e219796427
refs/heads/master
2016-08-08T00:43:32.006519
2009-04-09T21:33:22
2009-04-09T21:33:22
172,292
1
0
null
null
null
null
UTF-8
C++
false
false
1,227
cpp
/* Function definitions for InToAirport */ # include "intoairp.h" /**********************************************************************/ void InToAirport::ProcessInput (char KeyHit_i) { char Msg[5]; int AirportId; Airport *ToAirport; if (isdigit (KeyHit_i)) { AirportId = int (KeyHit_i) - '0'; Landmarks_c->Airports.Search (AirportId); if (Landmarks_c->Airports.Found()) { EchoChar (KeyHit_i); EchoChar (' '); ToAirport = Landmarks_c->Airports.FoundItem(); NewCmnd_c = new TurnTowardsCmnd (Plane_c, ToAirport); Next_c = new DelayOrCompleteInput (*this); IsCompleted_c = True; } } } /**********************************************************************/ void InToAirport::PromptMsg () { char Msg[3] = " "; EifIterator AirportIt = Landmarks_c->Airports.Iterator(); Out_c->Prompt ("Select airport number from :"); while (!AirportIt.Finished()) { Msg[0] = '0' + Landmarks_c->Airports.Item (AirportIt)->ID(); Out_c->AddToPrompt (Msg); AirportIt.Forth(); } } /**********************************************************************/ void InToAirport::Undo() { UndoNewCmnd(); CommonUndo(); }
[ [ [ 1, 50 ] ] ]
50156f03f5e32ed5f20ef3edf468ca64651d0479
d115cf7a1b374d857f6b094d4b4ccd8e9b1ac189
/pyplusplus_dev/unittests/data/global_variables_to_be_exported.hpp
65b5f5a7b11306075af5dd83364cd6d1b0c31a4b
[ "BSL-1.0" ]
permissive
gatoatigrado/pyplusplusclone
30af9065fb6ac3dcce527c79ed5151aade6a742f
a64dc9aeeb718b2f30bd6a5ff8dcd8bfb1cd2ede
refs/heads/master
2016-09-05T23:32:08.595261
2010-05-16T10:53:45
2010-05-16T10:53:45
700,369
4
2
null
null
null
null
UTF-8
C++
false
false
742
hpp
// Copyright 2004-2008 Roman Yakovenko. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef __global_variables_to_be_exported_hpp__ #define __global_variables_to_be_exported_hpp__ #include <cstdlib> namespace global_variables{ enum color{ red, green, blue }; extern const color const_var; extern color non_const_var; struct data{ int value; }; extern data garray[10]; extern double arr_of_doubles[100]; void init_garray(); extern int some_value; int get_some_value(); size_t get_some_value_address(); } extern const char someSin[3]; #endif//__global_variables_to_be_exported_hpp__
[ "roman_yakovenko@dc5859f9-2512-0410-ae5c-dd123cda1f76" ]
[ [ [ 1, 35 ] ] ]
efb94d4163c875d38e5c4a9ce60228d4617e9917
205069c97095da8f15e45cede1525f384ba6efd2
/Casino/Code/Server/ServerModule/CenterServer/GameTypeInfoDlg.cpp
80228ec9be2838d2fc3996e2d82e0c80b032f1da
[]
no_license
m0o0m/01technology
1a3a5a48a88bec57f6a2d2b5a54a3ce2508de5ea
5e04cbfa79b7e3cf6d07121273b3272f441c2a99
refs/heads/master
2021-01-17T22:12:26.467196
2010-01-05T06:39:11
2010-01-05T06:39:11
null
0
0
null
null
null
null
GB18030
C++
false
false
1,697
cpp
// GameTypeInfoDlg.cpp : 实现文件 // #include "stdafx.h" #include "resource.h" #include "GameTypeInfoDlg.h" #include ".\gametypeinfodlg.h" // CGameTypeInfoDlg 对话框 IMPLEMENT_DYNAMIC(CGameTypeInfoDlg, CDialog) CGameTypeInfoDlg::CGameTypeInfoDlg(CWnd* pParent /*=NULL*/) : CDialog(CGameTypeInfoDlg::IDD, pParent) , m_strTypeName(_T("")) , m_dwSortID(100) , m_nImageID(0) , m_strImageID(_T("")) { } CGameTypeInfoDlg::~CGameTypeInfoDlg() { } void CGameTypeInfoDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_TYPENAME, m_strTypeName); DDX_Text(pDX, IDC_SORT_ID, m_dwSortID); DDX_CBString(pDX, IDC_IMAGEID, m_strImageID); } BEGIN_MESSAGE_MAP(CGameTypeInfoDlg, CDialog) ON_BN_CLICKED(IDOK, OnBnClickedOk) END_MESSAGE_MAP() // CGameTypeInfoDlg 消息处理程序 BOOL CGameTypeInfoDlg::OnInitDialog() { CDialog::OnInitDialog(); ((CEdit*)GetDlgItem(IDC_TYPENAME))->LimitText(31); const char* strImageName[4] = { "真人视频", "对战", "电子", "博彩", }; CString str; for(int i = 0; i < sizeof(strImageName) / sizeof(strImageName[0]); i ++) { str.Format("%d", i); ((CComboBox*)GetDlgItem(IDC_IMAGEID))->AddString(strImageName[i]); } ((CComboBox*)GetDlgItem(IDC_IMAGEID))->SetCurSel(m_nImageID); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CGameTypeInfoDlg::OnBnClickedOk() { UpdateData(); if(m_strTypeName.IsEmpty()) { AfxMessageBox("名字不能为空"); return ; } m_nImageID = ((CComboBox*)GetDlgItem(IDC_IMAGEID))->GetCurSel(); OnOK(); }
[ [ [ 1, 77 ] ] ]
77a2a607a2d9e317ad2c916e64e388538b21b870
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/techdemo2/engine/ui/src/CutsceneCharacterController.cpp
36676a8446812adcd585a41b175d3628bcd3d9b0
[ "ClArtistic", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,827
cpp
/* * This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Perl Artistic 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 * Perl Artistic License for more details. * * You should have received a copy of the Perl Artistic License * along with this program; if not you can get it here * http://www.perldoc.com/perl5.6/Artistic.html. */ #include "CutsceneCharacterController.h" #include "Exception.h" #include "Actor.h" #include "CameraObject.h" #include "CommandMapper.h" #include "PhysicalThing.h" using namespace Ogre; namespace rl { CutsceneCharacterController::CutsceneCharacterController(Actor* camera) : CharacterController(camera, NULL) { mCamera->getPhysicalThing()->freeze(); Camera* ogreCam = static_cast<Camera*>(mCamera->_getMovableObject()); ogreCam->setFixedYawAxis(true); mCamera->_getSceneNode()->setFixedYawAxis(true); } CutsceneCharacterController::~CutsceneCharacterController() { mCamera->getPhysicalThing()->unfreeze(); } bool CutsceneCharacterController::injectKeyClicked(int keycode) { return startAction(mCommandMapper->getAction(keycode, CMDMAP_KEYMAP_OFF_COMBAT)); } void CutsceneCharacterController::run(Ogre::Real elapsedTime) { } void CutsceneCharacterController::toggleViewMode() { } void CutsceneCharacterController::resetCamera() { } CharacterController::ControllerType CutsceneCharacterController::getType() const { return CTRL_CUTSCENE; } }
[ "tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 65 ] ] ]
2e4835fc0b8bc438fcc7cd2112eae5103dba897b
2ff4099407bd04ffc49489f22bd62996ad0d0edd
/Project/Code/inc/Vector3.h
b016ec6294c1a8bafd9b958c161bc3da0baa81d3
[]
no_license
willemfrishert/imagebasedrendering
13687840a8e5b37a38cc91c3c5b8135f9c1881f2
1cb9ed13b820b791a0aa2c80564dc33fefdc47a2
refs/heads/master
2016-09-10T15:23:42.506289
2007-06-04T11:52:13
2007-06-04T11:52:13
32,184,690
0
1
null
null
null
null
UTF-8
C++
false
false
6,605
h
#pragma once #include <math.h> template <class T> class Vector3 { public: Vector3(void); Vector3(const T& x, const T& y, const T& z); Vector3(const Vector3& other); Vector3 & operator = ( Vector3 const & other); ~Vector3(void); Vector3 operator + ( Vector3 const & other) const; Vector3 operator - ( Vector3 const & other) const; Vector3 operator - () const; Vector3 operator * ( T const & other) const; Vector3 operator / ( Vector3 const & other) const; // Cross product Vector3 operator ^ ( const Vector3 & p ) const; // Dot product T operator * ( Vector3 const & other) const; Vector3 & operator += ( Vector3 const & other); Vector3 & operator *= ( T const & other); Vector3 & operator /= ( T const & other); Vector3 & operator -= ( Vector3 const & other); bool operator == ( Vector3 const & other) const; bool operator != ( Vector3 const & other) const; // Members Modifiers T &x(); T &y(); T &z(); // Setup by polar coords void setByPolar( T ro, T theta, T fi ); // Accesors const T &x() const; const T &y() const; const T &z() const; // Point's polar coords void Polar( T & ro, T & theta, T & fi ) const; T Norm() const; Vector3& Normalize(); static T Angle( const Vector3& p1, const Vector3& p2); // Angle between unitary vectors static T AngleN( const Vector3& p1, const Vector3& p2); // Modifiers void add( const T& x, const T& y, const T& z ); void setX(const T x); void setY(const T y); void setZ(const T z); void set(const T& x, const T& y, const T& z); protected: T iX; T iY; T iZ; }; // end class template <class T> inline Vector3<T>::Vector3(): iX(0), iY(0), iZ(0) { } template <class T> inline Vector3<T>::Vector3(const T& x, const T& y, const T& z): iX(x), iY(y), iZ(z) { } template <class T> inline Vector3<T>::Vector3(const Vector3& other) { iX = other.iX; iY = other.iY; iZ = other.iZ; } template <class T> inline Vector3<T> & Vector3<T>::operator = ( Vector3 const & other) { iX = other.iX; iY = other.iY; iZ = other.iZ; return *this; } template <class T> inline Vector3<T>::~Vector3() {} template <class T> inline Vector3<T> Vector3<T>::operator - ( Vector3 const & other) const { return Vector3( iX - other.iX, iY - other.iY, iZ - other.iZ ); } template <class T> inline Vector3<T> Vector3<T>::operator - () const { return Vector3( -iX, -iY, -iZ ); } template <class T> inline Vector3<T> Vector3<T>::operator + ( Vector3 const & other) const { return Vector3( iX + other.iX, iY + other.iY, iZ + other.iZ ); } template <class T> inline Vector3<T> Vector3<T>::operator * ( T const & other ) const { return Vector3( iX * other, iY * other, iZ * other ); } template <class T> inline Vector3<T> Vector3<T>::operator / ( Vector3 const & other) const { return Vector3( iX / other.iX, iY / other.iY, iZ / other.iZ ); } template <class T> inline Vector3<T>& Vector3<T>::operator += ( Vector3 const & other) { iX += other.iX; iY += other.iY; iZ += other.iZ; return *this; } template <class T> inline Vector3<T>& Vector3<T>::operator -= ( Vector3 const & other) { iX -= other.iX; iY -= other.iY; iZ -= other.iZ; return *this; } template <class T> inline Vector3<T>& Vector3<T>::operator *= ( T const & other) { iX *= other; iY *= other; iZ *= other; return *this; } template <class T> inline Vector3<T>& Vector3<T>::operator /= ( T const & other) { iX -= other; iY -= other; iZ -= other; return *this; } template <class T> inline bool Vector3<T>::operator == ( Vector3 const & other) const { return ( (iX == other.iX) && (iY == other.iY) && (iZ == other.iZ) ); } template <class T> inline bool Vector3<T>::operator != ( Vector3 const & other) const { return ( (iX != other.iX) && (iY != other.iY) && (iZ != other.iZ) ); } template <class T> inline const T& Vector3<T>::x() const { return iX; } template <class T> inline const T& Vector3<T>::y() const { return iY; } template <class T> inline const T& Vector3<T>::z() const { return iZ; } template <class T> inline T& Vector3<T>::x() { return iX; } template <class T> inline T& Vector3<T>::y() { return iY; } template <class T> inline T& Vector3<T>::z() { return iZ; } template <class T> inline void Vector3<T>::Polar( T & ro, T & theta, T & fi ) const { ro = Norm(); theta = (T)atan2( iY, iX ); fi = (T)acos( iZ / ro ); } template <class T> inline void Vector3<T>::setByPolar( T ro, T theta, T fi ) { iX = ro * sin(fi) * cos(theta); iY = ro * sin(theta) * sin(fi); iZ = ro * cos(fi); //ro = sqrt(x*x + y*y + z*z) //fi = atan(y / x) //theta = asin(sqrt(x*x + y*y) / r) = acos(z / r) //x = ro sin(fi) cos(theta) //y = ro sin(theta) sin(fi) //z = ro cos(fi) } template <class T> inline Vector3<T>& Vector3<T>::Normalize() { T norm = this->Norm(); if( norm > 0.0 ) { iX /= norm; iY /= norm; iZ /= norm; } return *this; } template <class T> inline Vector3<T> Vector3<T>::operator ^ ( const Vector3 & p ) const { return Vector3 ( (iY * p.iZ) - (iZ * p.iY), (iZ * p.iX) - (iX * p.iZ), (iX * p.iY) - (iY * p.iX) ); } template <class T> inline T Vector3<T>::operator * (const Vector3 & p) const { return ( (iX * p.iX) + (iY * p.iY) + (iZ * p.iZ) ); } template <class T> inline T Vector3<T>::Norm() const { return sqrt( iX * iX + iY * iY + iZ * iZ ); } template <class T> inline T Vector3<T>::Angle( const Vector3& p1, const Vector3& p2) { T w = p1.Norm() * p2.Norm(); if( w == 0 ) { return -1; } T t = ( p1 * p2 ) / w; if( t > 1) { t = 1; } else { if( t < -1 ) { t = -1; } } return (T) acos(t); } template <class T> inline T Vector3<T>::AngleN( const Vector3& p1, const Vector3& p2) { T w = p1 * p2; if( w > 1 ) { w = 1; } else { if( w < -1 ) { w =- 1; } } return (T) acos(w); } template <class T> inline void Vector3<T>::add( const T& x, const T& y, const T& z ) { iX += x; iY += y; iZ += z; } template <class T> inline void Vector3<T>::setX(const T x) { iX = x; } template <class T> inline void Vector3<T>::setY(const T y) { iY = y; } template <class T> inline void Vector3<T>::setZ(const T z) { iZ = z; } template <class T> inline void Vector3<T>::set(const T& x, const T& y, const T& z) { iX = x; iY = y; iZ = z; }
[ "jpjorge@15324175-3028-0410-9899-2d1205849c9d" ]
[ [ [ 1, 378 ] ] ]
3b6951ed5441281d5d73f97e652012c8063e3d44
1c84fe02ecde4a78fb03d3c28dce6fef38ebaeff
/StateLocustAttack.h
e5b2ecc276113451f0eabfaa6c93a848371983ad
[]
no_license
aadarshasubedi/beesiege
c29cb8c3fce910771deec5bb63bcb32e741c1897
2128b212c5c5a68e146d3f888bb5a8201c8104f7
refs/heads/master
2016-08-12T08:37:10.410041
2007-12-16T20:57:33
2007-12-16T20:57:33
36,995,410
0
0
null
null
null
null
UTF-8
C++
false
false
971
h
#ifndef STATELOCUSTATTACK_H #define STATELOCUSTATTACK_H #include "FSMState.h" class Enemy; class GameCharacter; class HealthAttribute; class StateLocustAttack: public FSMState { public: // ctor StateLocustAttack(FSMAIControl* control, int type=FSM_ENEMY_LOCUST_ATTACK); // see base class void Enter(); void Exit(); void Update(float fTime); FSMState* CheckTransitions(float fTime); // setters / getters void SetTarget(GameCharacter* target); private: // the locust's target GameCharacter* m_pTarget; // the locust's view radius float m_fViewRadius; // the locust's damage radius float m_fDamageRadius; // the locust's damage modifier float m_fDamage; // the target's health attribute HealthAttribute* m_pTargetHealth; // timer for delaying attacks float m_fAttackTimer; const float m_fcAttackTime; // damage target void DamageTarget(); }; NiSmartPointer(StateLocustAttack); #endif
[ [ [ 1, 49 ] ] ]
be2b0662d8447b62581270b369dd67356f704804
2112057af069a78e75adfd244a3f5b224fbab321
/branches/refactor/src_root/include/common/OgreTypes/OgrePrerequisites.h
af9b18beefe7bc0152fb5707f081fee447e5ab44
[]
no_license
blockspacer/ireon
120bde79e39fb107c961697985a1fe4cb309bd81
a89fa30b369a0b21661c992da2c4ec1087aac312
refs/heads/master
2023-04-15T00:22:02.905112
2010-01-07T20:31:07
2010-01-07T20:31:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,900
h
/*------------------------------------------------------------------------- This source file is a part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2005 The OGRE Team Also see acknowledgements in Readme.html This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 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 or go to http://www.gnu.org/copyleft/lesser.txt -------------------------------------------------------------------------*/ #ifndef __Prerequisites_H__ #define __Prerequisites_H__ // undefine this to not require new angular units where applicable #define OGRE_FORCE_ANGLE_TYPES // Platform-specific stuff #include "OgrePlatform.h" #if OGRE_COMPILER == OGRE_COMPILER_MSVC // Turn off warnings generated by long std templates // This warns about truncation to 255 characters in debug/browse info # pragma warning (disable : 4786) // Turn off warnings generated by long std templates // This warns about truncation to 255 characters in debug/browse info # pragma warning (disable : 4503) // disable: "conversion from 'double' to 'float', possible loss of data # pragma warning (disable : 4244) // disable: "truncation from 'double' to 'float' # pragma warning (disable : 4305) // disable: "<type> needs to have dll-interface to be used by clients' // Happens on STL member variables which are not public therefore is ok # pragma warning (disable : 4251) // disable: "non dll-interface class used as base for dll-interface class" // Happens when deriving from Singleton because bug in compiler ignores // template export # pragma warning (disable : 4275) // disable: "C++ Exception Specification ignored" // This is because MSVC 6 did not implement all the C++ exception // specifications in the ANSI C++ draft. # pragma warning( disable : 4290 ) // disable: "no suitable definition provided for explicit template // instantiation request" Occurs in VC7 for no justifiable reason on all // #includes of Singleton # pragma warning( disable: 4661) // disable: deprecation warnings when using CRT calls in VC8 // These show up on all C runtime lib code in VC8, disable since they clutter // the warnings with things we may not be able to do anything about (e.g. // generated code from nvparse etc). I doubt very much that these calls // will ever be actually removed from VC anyway, it would break too much code. # pragma warning( disable: 4996) #endif #if OGRE_COMPILER == OGRE_COMPILER_MSVC # undef _DEFINE_DEPRECATED_HASH_CLASSES # if OGRE_COMP_VER > 1300 # define _DEFINE_DEPRECATED_HASH_CLASSES 0 # else # define _DEFINE_DEPRECATED_HASH_CLASSES 1 # endif #endif /* Include all the standard header *after* all the configuration settings have been made. */ #include "OgreStdHeaders.h" // define the real number values to be used // default to use 'float' unless precompiler option set namespace Ogre { // Define ogre version #define OGRE_VERSION_MAJOR 1 #define OGRE_VERSION_MINOR 0 #define OGRE_VERSION_PATCH 5 #define OGRE_VERSION_NAME "Azathoth" #if OGRE_DOUBLE_PRECISION == 1 /** Software floating point type. @note Not valid as a pointer to GPU buffers / parameters */ typedef double Real; #else /** Software floating point type. @note Not valid as a pointer to GPU buffers / parameters */ typedef float Real; #endif // define the Char type as either char or wchar_t #if OGRE_WCHAR_T_STRINGS == 1 # define OgreChar wchar_t # define _TO_CHAR( x ) L##x #else # define OgreChar char # define _TO_CHAR( x ) x #endif #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 # define HashMap ::__gnu_cxx::hash_map #else # if OGRE_COMPILER == OGRE_COMPILER_MSVC # if OGRE_COMP_VER > 1300 && !defined(_STLP_MSVC) # define HashMap ::stdext::hash_map # else # define HashMap ::std::hash_map # endif # else # define HashMap ::std::hash_map # endif #endif /** In order to avoid finger-aches :) */ typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; /// Useful macros #define OGRE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } #define OGRE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } #if OGRE_WCHAR_T_STRINGS typedef std::wstring _StringBase; #else typedef std::string _StringBase; #endif typedef _StringBase String; // Useful threading defines #define OGRE_AUTO_MUTEX_NAME mutex #if OGRE_THREAD_SUPPORT #define OGRE_AUTO_MUTEX mutable boost::recursive_mutex OGRE_AUTO_MUTEX_NAME; #define OGRE_LOCK_AUTO_MUTEX boost::recursive_mutex::scoped_lock ogreAutoMutexLock(OGRE_AUTO_MUTEX_NAME); #define OGRE_MUTEX(name) mutable boost::recursive_mutex name; #define OGRE_LOCK_MUTEX(name) boost::recursive_mutex::scoped_lock ogrenameLock(name); // like OGRE_AUTO_MUTEX but mutex held by pointer #define OGRE_AUTO_SHARED_MUTEX mutable boost::recursive_mutex *OGRE_AUTO_MUTEX_NAME; #define OGRE_LOCK_AUTO_SHARED_MUTEX boost::recursive_mutex::scoped_lock ogreAutoMutexLock(*OGRE_AUTO_MUTEX_NAME); #define OGRE_NEW_AUTO_SHARED_MUTEX OGRE_AUTO_MUTEX_NAME = new boost::recursive_mutex(); #define OGRE_DELETE_AUTO_SHARED_MUTEX delete OGRE_AUTO_MUTEX_NAME; #define OGRE_COPY_AUTO_SHARED_MUTEX(from) OGRE_AUTO_MUTEX_NAME = from; #else #define OGRE_AUTO_MUTEX #define OGRE_LOCK_AUTO_MUTEX #define OGRE_MUTEX(name) #define OGRE_LOCK_MUTEX(name) #define OGRE_AUTO_SHARED_MUTEX #define OGRE_LOCK_AUTO_SHARED_MUTEX #define OGRE_NEW_AUTO_SHARED_MUTEX #define OGRE_DELETE_AUTO_SHARED_MUTEX #define OGRE_COPY_AUTO_SHARED_MUTEX(from) #endif class Angle; class ColourValue; class Degree; class Math; class Matrix3; class Matrix4; class Plane; class Quaternion; class Radian; class Vector2; class Vector3; class Vector4; } #endif // __OgrePrerequisites_H__
[ [ [ 1, 196 ] ] ]
eadfbbcbe523daff50333f8ac6760bba97b903df
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
6603c8783d4fa689828b791e9ad7c05294722b35
[ "BSD-2-Clause" ]
permissive
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,773
cpp
/* * Copyright (C) 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * 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 * OWNER 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. */ #include "config.h" #include "WebDevToolsAgentImpl.h" #include "DebuggerAgentImpl.h" #include "DebuggerAgentManager.h" #include "InjectedScriptHost.h" #include "InspectorBackendDispatcher.h" #include "InspectorController.h" #include "InspectorValues.h" #include "Page.h" #include "PageGroup.h" #include "PlatformString.h" #include "ResourceError.h" #include "ResourceRequest.h" #include "ResourceResponse.h" #include "ScriptDebugServer.h" #include "V8Binding.h" #include "V8Proxy.h" #include "V8Utilities.h" #include "WebDataSource.h" #include "WebDevToolsAgentClient.h" #include "WebFrameImpl.h" #include "WebRect.h" #include "WebString.h" #include "WebURL.h" #include "WebURLError.h" #include "WebURLRequest.h" #include "WebURLResponse.h" #include "WebViewClient.h" #include "WebViewImpl.h" #include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> using WebCore::DocumentLoader; using WebCore::FrameLoader; using WebCore::InjectedScriptHost; using WebCore::InspectorArray; using WebCore::InspectorBackendDispatcher; using WebCore::InspectorController; using WebCore::InspectorObject; using WebCore::InspectorValue; using WebCore::Node; using WebCore::Page; using WebCore::ResourceError; using WebCore::ResourceRequest; using WebCore::ResourceResponse; using WTF::String; using WebCore::V8DOMWrapper; using WebCore::V8Proxy; namespace WebKit { namespace { static const char kFrontendConnectedFeatureName[] = "frontend-connected"; static const char kResourceTrackingFeatureName[] = "resource-tracking"; static const char kTimelineFeatureName[] = "timeline-profiler"; static const char kApuAgentFeatureName[] = "apu-agent"; class ClientMessageLoopAdapter : public WebCore::ScriptDebugServer::ClientMessageLoop { public: static void ensureClientMessageLoopCreated(WebDevToolsAgentClient* client) { if (s_instance) return; s_instance = new ClientMessageLoopAdapter(client->createClientMessageLoop()); WebCore::ScriptDebugServer::shared().setClientMessageLoop(s_instance); } static void inspectedViewClosed(WebViewImpl* view) { if (s_instance) s_instance->m_frozenViews.remove(view); } static void didNavigate() { // Release render thread if necessary. if (s_instance && s_instance->m_running) WebCore::ScriptDebugServer::shared().continueProgram(); } private: ClientMessageLoopAdapter(PassOwnPtr<WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop> messageLoop) : m_running(false) , m_messageLoop(messageLoop) { } virtual void run(Page* page) { if (m_running) return; m_running = true; Vector<WebViewImpl*> views; // 1. Disable input events. HashSet<Page*>::const_iterator end = page->group().pages().end(); for (HashSet<Page*>::const_iterator it = page->group().pages().begin(); it != end; ++it) { WebViewImpl* view = WebViewImpl::fromPage(*it); m_frozenViews.add(view); views.append(view); view->setIgnoreInputEvents(true); } // 2. Disable active objects WebView::willEnterModalLoop(); // 3. Process messages until quitNow is called. m_messageLoop->run(); // 4. Resume active objects WebView::didExitModalLoop(); // 5. Resume input events. for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) { if (m_frozenViews.contains(*it)) { // The view was not closed during the dispatch. (*it)->setIgnoreInputEvents(false); } } // 6. All views have been resumed, clear the set. m_frozenViews.clear(); m_running = false; } virtual void quitNow() { m_messageLoop->quitNow(); } bool m_running; OwnPtr<WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLoop; typedef HashSet<WebViewImpl*> FrozenViewsSet; FrozenViewsSet m_frozenViews; static ClientMessageLoopAdapter* s_instance; }; ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = 0; } // namespace WebDevToolsAgentImpl::WebDevToolsAgentImpl( WebViewImpl* webViewImpl, WebDevToolsAgentClient* client) : m_hostId(client->hostIdentifier()) , m_client(client) , m_webViewImpl(webViewImpl) , m_apuAgentEnabled(false) , m_resourceTrackingWasEnabled(false) , m_attached(false) { DebuggerAgentManager::setExposeV8DebuggerProtocol( client->exposeV8DebuggerProtocol()); } WebDevToolsAgentImpl::~WebDevToolsAgentImpl() { DebuggerAgentManager::onWebViewClosed(m_webViewImpl); ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl); } void WebDevToolsAgentImpl::attach() { if (m_attached) return; if (!m_client->exposeV8DebuggerProtocol()) ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); m_debuggerAgentImpl.set( new DebuggerAgentImpl(m_webViewImpl, this, m_client)); WebCString debuggerScriptJs = m_client->debuggerScriptSource(); WebCore::ScriptDebugServer::shared().setDebuggerScriptSource( WTF::String(debuggerScriptJs.data(), debuggerScriptJs.length())); m_attached = true; } void WebDevToolsAgentImpl::detach() { // Prevent controller from sending messages to the frontend. InspectorController* ic = inspectorController(); ic->disconnectFrontend(); ic->hideHighlight(); ic->close(); m_debuggerAgentImpl.set(0); m_attached = false; m_apuAgentEnabled = false; } void WebDevToolsAgentImpl::frontendLoaded() { inspectorController()->connectFrontend(); // We know that by this time injected script has already been pushed to the backend. m_client->runtimePropertyChanged(kFrontendConnectedFeatureName, inspectorController()->injectedScriptHost()->injectedScriptSource()); } void WebDevToolsAgentImpl::didNavigate() { ClientMessageLoopAdapter::didNavigate(); DebuggerAgentManager::onNavigate(); } void WebDevToolsAgentImpl::didClearWindowObject(WebFrameImpl* webframe) { DebuggerAgentManager::setHostId(webframe, m_hostId); } void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message) { inspectorController()->inspectorBackendDispatcher()->dispatch(message); } void WebDevToolsAgentImpl::inspectElementAt(const WebPoint& point) { m_webViewImpl->inspectElementAt(point); } void WebDevToolsAgentImpl::setRuntimeProperty(const WebString& name, const WebString& value) { if (name == kApuAgentFeatureName) setApuAgentEnabled(value == "true"); else if (name == kTimelineFeatureName) setTimelineProfilingEnabled(value == "true"); else if (name == kResourceTrackingFeatureName) { InspectorController* ic = inspectorController(); if (value == "true") ic->enableResourceTracking(false /* not sticky */, false /* no reload */); else ic->disableResourceTracking(false /* not sticky */); } else if (name == kFrontendConnectedFeatureName && !inspectorController()->hasFrontend()) { inspectorController()->injectedScriptHost()->setInjectedScriptSource(value); frontendLoaded(); } } void WebDevToolsAgentImpl::setApuAgentEnabled(bool enabled) { m_apuAgentEnabled = enabled; InspectorController* ic = inspectorController(); if (enabled) { if (!ic->hasFrontend()) frontendLoaded(); m_resourceTrackingWasEnabled = ic->resourceTrackingEnabled(); ic->startTimelineProfiler(); if (!m_resourceTrackingWasEnabled) { // TODO(knorton): Introduce some kind of agents dependency here so that // user could turn off resource tracking while apu agent is on. ic->enableResourceTracking(false, false); } m_debuggerAgentImpl->setAutoContinueOnException(true); } else { ic->stopTimelineProfiler(); if (!m_resourceTrackingWasEnabled) ic->disableResourceTracking(false); m_resourceTrackingWasEnabled = false; } m_client->runtimePropertyChanged( kApuAgentFeatureName, enabled ? String("true") : String("false")); } WebCore::InspectorController* WebDevToolsAgentImpl::inspectorController() { if (Page* page = m_webViewImpl->page()) return page->inspectorController(); return 0; } //------- plugin resource load notifications --------------- void WebDevToolsAgentImpl::identifierForInitialRequest( unsigned long resourceId, WebFrame* frame, const WebURLRequest& request) { if (InspectorController* ic = inspectorController()) { WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame); FrameLoader* frameLoader = webFrameImpl->frame()->loader(); DocumentLoader* loader = frameLoader->activeDocumentLoader(); ic->identifierForInitialRequest(resourceId, loader, request.toResourceRequest()); } } void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, WebURLRequest& request) { if (InspectorController* ic = inspectorController()) ic->willSendRequest(resourceId, request.toMutableResourceRequest(), ResourceResponse()); } void WebDevToolsAgentImpl::didReceiveData(unsigned long resourceId, int length) { if (InspectorController* ic = inspectorController()) ic->didReceiveContentLength(resourceId, length); } void WebDevToolsAgentImpl::didReceiveResponse(unsigned long resourceId, const WebURLResponse& response) { if (InspectorController* ic = inspectorController()) ic->didReceiveResponse(resourceId, response.toResourceResponse()); } void WebDevToolsAgentImpl::didFinishLoading(unsigned long resourceId) { if (InspectorController* ic = inspectorController()) ic->didFinishLoading(resourceId); } void WebDevToolsAgentImpl::didFailLoading(unsigned long resourceId, const WebURLError& error) { ResourceError resourceError; if (InspectorController* ic = inspectorController()) ic->didFailLoading(resourceId, resourceError); } void WebDevToolsAgentImpl::inspectorDestroyed() { // Our lifetime is bound to the WebViewImpl. } void WebDevToolsAgentImpl::openInspectorFrontend(InspectorController*) { } void WebDevToolsAgentImpl::highlight(Node* node) { // InspectorController does the actuall tracking of the highlighted node // and the drawing of the highlight. Here we just make sure to invalidate // the rects of the old and new nodes. hideHighlight(); } void WebDevToolsAgentImpl::hideHighlight() { // FIXME: able to invalidate a smaller rect. // FIXME: Is it important to just invalidate the rect of the node region // given that this is not on a critical codepath? In order to do so, we'd // have to take scrolling into account. const WebSize& size = m_webViewImpl->size(); WebRect damagedRect(0, 0, size.width, size.height); if (m_webViewImpl->client()) m_webViewImpl->client()->didInvalidateRect(damagedRect); } void WebDevToolsAgentImpl::populateSetting(const String& key, String* value) { WebString string; m_webViewImpl->inspectorSetting(key, &string); *value = string; } void WebDevToolsAgentImpl::storeSetting(const String& key, const String& value) { m_webViewImpl->setInspectorSetting(key, value); } bool WebDevToolsAgentImpl::sendMessageToFrontend(const WTF::String& message) { WebDevToolsAgentImpl* devToolsAgent = static_cast<WebDevToolsAgentImpl*>(m_webViewImpl->devToolsAgent()); if (!devToolsAgent) return false; if (devToolsAgent->m_apuAgentEnabled) { m_client->sendDispatchToAPU(message); return true; } m_client->sendMessageToInspectorFrontend(message); return true; } void WebDevToolsAgentImpl::resourceTrackingWasEnabled() { m_client->runtimePropertyChanged(kResourceTrackingFeatureName, "true"); } void WebDevToolsAgentImpl::resourceTrackingWasDisabled() { m_client->runtimePropertyChanged(kResourceTrackingFeatureName, "false"); } void WebDevToolsAgentImpl::timelineProfilerWasStarted() { m_client->runtimePropertyChanged(kTimelineFeatureName, "true"); } void WebDevToolsAgentImpl::timelineProfilerWasStopped() { m_client->runtimePropertyChanged(kTimelineFeatureName, "false"); } void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString& script) { InspectorController* ic = inspectorController(); ic->evaluateForTestInFrontend(callId, script); } void WebDevToolsAgentImpl::setTimelineProfilingEnabled(bool enabled) { InspectorController* ic = inspectorController(); if (enabled) ic->startTimelineProfiler(); else ic->stopTimelineProfiler(); } void WebDevToolsAgent::executeDebuggerCommand(const WebString& command, int callerId) { DebuggerAgentManager::executeDebuggerCommand(command, callerId); } void WebDevToolsAgent::debuggerPauseScript() { DebuggerAgentManager::pauseScript(); } void WebDevToolsAgent::interruptAndDispatch(MessageDescriptor* d) { class DebuggerTask : public WebCore::ScriptDebugServer::Task { public: DebuggerTask(WebDevToolsAgent::MessageDescriptor* descriptor) : m_descriptor(descriptor) { } virtual ~DebuggerTask() { } virtual void run() { if (WebDevToolsAgent* webagent = m_descriptor->agent()) webagent->dispatchOnInspectorBackend(m_descriptor->message()); } private: OwnPtr<WebDevToolsAgent::MessageDescriptor> m_descriptor; }; WebCore::ScriptDebugServer::interruptAndRun(new DebuggerTask(d)); } bool WebDevToolsAgent::shouldInterruptForMessage(const WebString& message) { String commandName; if (!InspectorBackendDispatcher::getCommandName(message, &commandName)) return false; return commandName == InspectorBackendDispatcher::pauseCmd || commandName == InspectorBackendDispatcher::setBreakpointCmd || commandName == InspectorBackendDispatcher::removeBreakpointCmd || commandName == InspectorBackendDispatcher::activateBreakpointsCmd || commandName == InspectorBackendDispatcher::deactivateBreakpointsCmd || commandName == InspectorBackendDispatcher::startProfilingCmd || commandName == InspectorBackendDispatcher::stopProfilingCmd || commandName == InspectorBackendDispatcher::getProfileCmd; } void WebDevToolsAgent::processPendingMessages() { WebCore::ScriptDebugServer::shared().runPendingTasks(); } void WebDevToolsAgent::setMessageLoopDispatchHandler(MessageLoopDispatchHandler handler) { DebuggerAgentManager::setMessageLoopDispatchHandler(handler); } } // namespace WebKit
[ [ [ 1, 492 ] ] ]
9a490e919e5ae8bec0abe89c94abf98bcb7f70ae
d6e0f648d63055d6576de917de8d6f0f3fcb2989
/ddv/win/src/mwnd.cpp
a629c5416a1819bd9a47929b8d191bc942b181cd
[]
no_license
lgosha/ssd
9b4a0ade234dd192ef30274377787edf1244b365
0b97a39fd7edabca44c4ac19178a5c626d1efea3
refs/heads/master
2020-05-19T12:41:32.060017
2011-09-27T12:43:06
2011-09-27T12:43:06
2,428,803
0
0
null
null
null
null
UTF-8
C++
false
false
6,143
cpp
//<codepage = utf8 #include "mwnd.h" #include "udp_pvar.h" #include "udp_client.h" #include <QDebug> #include <QCoreApplication> #include <QMessageBox> UTreeWidget::UTreeWidget( QWidget *parent ) : QTreeWidget ( parent ), m_pEmpty ( new QTreeWidgetItem( this ) ), m_uiCount ( 1 ) { setColumnCount( 5 ); setSelectionMode( QAbstractItemView::NoSelection ); setHeaderLabels( QStringList() << "Number" << "Identifier" << "Timestamp" << "Status" << "Value" ); connect ( this, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ), this, SLOT( itemChanged( QTreeWidgetItem *, QTreeWidgetItem * ) ) ); } void UTreeWidget::createItem( uint uiRow ) { m_mItems[uiRow] = new QTreeWidgetItem( this ); } uint UTreeWidget::getParId( uint uiCab, uint uiDev, uint uiPar ) { return QString("%1%2%3") .arg( uiCab, 3, 10, QChar('0') ) .arg( uiDev, 3, 10, QChar('0') ) .arg( uiPar, 3, 10, QChar('0') ).toUInt(); } QString UTreeWidget::getParStrId( uint uiCab, uint uiDev, uint uiPar ) { return QString("%1%2%3") .arg( uiCab, 3, 10, QChar('0') ) .arg( uiDev, 3, 10, QChar('0') ) .arg( uiPar, 3, 10, QChar('0') ); } void UTreeWidget::find( const QString &sId ) { if ( m_mIds.contains( getParId( sId.left(3).toUInt(), sId.mid(3, 3).toUInt(), sId.right(3).toUInt() ) ) && m_mItems.contains( m_mIds[ getParId( sId.left(3).toUInt(), sId.mid(3, 3).toUInt(), sId.right(3).toUInt() ) ] ) ) { setCurrentItem( m_mItems[m_mIds[ getParId( sId.left(3).toUInt(), sId.mid(3, 3).toUInt(), sId.right(3).toUInt() ) ]]) ; } else QMessageBox::information( 0, "Error", "No such Id" ); } QColor UTreeWidget::itemBackgroundColor( QTreeWidgetItem *pItem, uint uiStatus ) { QColor color = QColor( 255, 255, 255 ); switch( uiStatus ) { case 0: pItem == currentItem() ? color = QColor( 255, 0, 0 ) : color = QColor( 255, 150, 150 ); break; case 1: pItem == currentItem() ? color = QColor( 0, 255, 0 ) : color = QColor( 150, 255, 150 ); break; case 2: pItem == currentItem() ? color = QColor( 100, 100, 100 ) : color = QColor( 200, 200, 200 ); break; } return color; } void UTreeWidget::setItemBackgroundColor( QTreeWidgetItem *pItem, uint uiStatus ) { QColor color = itemBackgroundColor( pItem, uiStatus ); for(int i=0;i<5;i++) pItem->setBackground( i, color ); } void UTreeWidget::itemChanged( QTreeWidgetItem *c, QTreeWidgetItem *p ) { if( p && p != m_pEmpty ) setItemBackgroundColor( p, p->text( 3 ).toUInt() ); if( c != m_pEmpty ) setItemBackgroundColor( c, c->text( 3 ).toUInt() ); } void UTreeWidget::hideItems() { foreach( QTreeWidgetItem *pItem, m_mItems.values() ) { setItemBackgroundColor( pItem, 3 ); pItem->setText( 2, QString::number(2) ); } } void UTreeWidget::setData( pAnswer &pa ) { pVariable pv; for(int i = 0; i < pa.getVariableCount(); i++) { pv = pa.getVariable(i); uint uiId = getParId( pv.getPtsID(), pv.getDeviceID(), pv.getN() ); if( !m_mIds.contains( uiId ) ) { m_mIds[ uiId ] = m_uiCount++; m_mStrIds[ uiId ] = getParStrId( pv.getPtsID(), pv.getDeviceID(), pv.getN() ); createItem( m_mIds[ uiId ] ); } m_mItems[m_mIds[ uiId ]]->setText( 0, QString::number(m_mIds[ uiId ] ) ); m_mItems[m_mIds[ uiId ]]->setText( 1, m_mStrIds[ uiId ] ); m_mItems[m_mIds[ uiId ]]->setText( 2, pv.getDateTime().toString("hh:mm:ss.zzz") ); m_mItems[m_mIds[ uiId ]]->setText( 3, QString::number(pv.getStatus()) ); m_mItems[m_mIds[ uiId ]]->setText( 4, pv.getValue().toStr() ); setItemBackgroundColor( m_mItems[m_mIds[ uiId ]], pv.getStatus() ); } } #include <QTabWidget> #include <QAction> CMainWnd::CMainWnd( XMLConfig *pXMLConfig ) : m_pClient( new UDPClient( this, pXMLConfig ) ) { setGeometry ( pXMLConfig->attr("view:x").toInt(), pXMLConfig->attr("view:y").toInt(), pXMLConfig->attr("view:width").toInt(), pXMLConfig->attr("view:height").toInt() ); setFixedSize(pXMLConfig->attr("view:width").toInt(), pXMLConfig->attr("view:height").toInt()); m_pTabContainer = new QTabWidget(this); m_pTabContainer->setGeometry(QRect(10, 10, pXMLConfig->attr("view:width").toInt() - 17, pXMLConfig->attr("view:height").toInt() - 20)); const DOMNode *pNode = pXMLConfig->first(XMLConfig::find(pXMLConfig->root(), "servers", "")); while(pNode) { if(pNode->getNodeType() == DOMNode::ELEMENT_NODE) createView( pXMLConfig, pNode ); pNode = pXMLConfig->next(); } } CMainWnd::~CMainWnd() { } #include <QKeyEvent> #include <QInputDialog> void CMainWnd::keyPressEvent( QKeyEvent *pEvent ) { if( pEvent->matches( QKeySequence::Find ) ) { QString str = QInputDialog::getText( this, "Find", "Input signal identifier" ); if( !str.isNull() && !str.isEmpty() ) m_mItemsByIndex[m_pTabContainer->currentIndex()]->find( str ); } } void CMainWnd::createView( XMLConfig *pXMLConfig, const DOMNode *pNode ) { QWidget *pTab; UTreeWidget *pTreeWidget = 0; pTab = new QWidget( m_pTabContainer ); pTreeWidget = new UTreeWidget( pTab ); pTreeWidget->setGeometry( QRect(5, 5, pXMLConfig->attr("view:width").toInt() - 32, pXMLConfig->attr("view:height").toInt() - 56) ); m_mTabs[pXMLConfig->attr(pNode, "id").toUInt()] = m_pTabContainer->addTab( pTab, QIcon( "../img/16x16/red.png" ), pXMLConfig->attr(pNode, "caption") ); m_mViews[pXMLConfig->attr(pNode, "id").toUInt()] = pTreeWidget; m_mItemsByIndex[ m_mTabs[pXMLConfig->attr(pNode, "id").toUInt()] ] = pTreeWidget; } void CMainWnd::setData( uint uiId, pAnswer &answer ) { if( m_mViews.contains( uiId ) ) m_mViews[uiId]->setData( answer ); } void CMainWnd::setConnectStatus( uint uiId, uint uiStatus) { if( m_mViews.contains( uiId ) && m_mTabs.contains( uiId ) ) { switch( uiStatus ) { case 0: m_pTabContainer->setTabIcon( m_mTabs[uiId], QIcon( "../img/16x16/red.png" ) ); m_mViews[uiId]->hideItems(); break; case 1: m_pTabContainer->setTabIcon( m_mTabs[uiId], QIcon( "../img/16x16/green.png" ) ); break; } } }
[ [ [ 1, 200 ] ] ]
6b3c65e60c23aeb25fabda6f6e950ea68a07241a
ba200ae9f30b89d1e32aee6a6e5ef2c991cee157
/trunk/GosuImpl/WinMain.cpp
38203cf73d9d20fc9d7f5ded59eea9a060c1d0de
[ "MIT" ]
permissive
clebertavares/gosu
1d5fd08d22825d18f2840dfe1c53c96f700b665f
e534e0454648a4ef16c7934d3b59b80ac9ec7a44
refs/heads/master
2020-04-08T15:36:38.697104
2010-02-20T16:57:25
2010-02-20T16:57:25
537,484
1
0
null
null
null
null
UTF-8
C++
false
false
1,750
cpp
#include <boost/lexical_cast.hpp> #include <windows.h> #include <exception> #include <string> #include <vector> using namespace std; // IMPR: Check for security issues. I hacked this together. vector<string> splitCmdLine() { vector<string> result; const char* cmdLine = ::GetCommandLineA(); const char* argBegin = 0; bool isQuotedArg = false; while (*cmdLine) { if (*cmdLine == '"') { if (argBegin == 0) { argBegin = cmdLine + 1; isQuotedArg = true; } else if (isQuotedArg) { result.push_back(std::string(argBegin, cmdLine)); argBegin = 0; } } else if (!isspace(*cmdLine) && argBegin == 0) { argBegin = cmdLine; isQuotedArg = false; } else if (isspace(*cmdLine) && argBegin != 0 && !isQuotedArg) { result.push_back(std::string(argBegin, cmdLine + 1)); argBegin = 0; } ++cmdLine; } if (argBegin != 0) result.push_back(argBegin); return result; } int main(int argc, char* argv[]); int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { vector<string> arguments = splitCmdLine(); vector<char*> argv(arguments.size()); for (unsigned i = 0; i < argv.size(); ++i) argv[i] = const_cast<char*>(arguments[i].c_str()); return main(argv.size(), &argv[0]); } catch (const std::exception& e) { ::MessageBoxA(0, e.what(), "Uncaught Exception", MB_OK | MB_ICONERROR); return EXIT_FAILURE; } }
[ [ [ 1, 69 ] ] ]
548635594a35ad3c1494e4ce4f9cc6f4d89fd2ec
ae239aeeb8dcf7212d432791b959ef709888f99a
/v1.0/ControlObject.h
32bb1570e6ce23bcece18abfdae5b55f27e24686
[]
no_license
arunaupul/merrimack-college-csc4910-sp2010
6a9fff2280494048997728b36a214271a2a8f8fc
a77d9fbb00538c98b7d61a61e91854e2dee1e748
refs/heads/master
2016-08-07T19:18:11.144431
2010-05-04T23:44:38
2010-05-04T23:44:38
35,337,837
0
0
null
null
null
null
UTF-8
C++
false
false
618
h
#ifndef _CONTROL_OBJECT_H_ #define _CONTROL_OBJECT_H_ #include <string> enum Controls { CO_RIGHT = 0, CO_LEFT = 1, CO_JUMP = 2, CO_CROUCH = 3, CO_PAUSE = 4, CO_USE_SPECIAL = 5, CO_MAX_CONTROL }; class ControlObject { public: ControlObject(); virtual ~ControlObject(); unsigned int GetControlKey( Controls control ); void SetControlKey( Controls control , unsigned int key ); void LoadControls( const std::wstring & fileName ); unsigned int StringToKey( const std::string * keyString ); private: unsigned int m_controlKeys[CO_MAX_CONTROL]; }; #endif /* _CONTROL_OBJECT_H_ */
[ "rfleming71@06d672e2-d70c-11de-b7b1-656321ec08b8" ]
[ [ [ 1, 28 ] ] ]
5a0f984accf94c9b315eabe064880c77327f975e
9756190964e5121271a44aba29a5649b6f95f506
/SimpleParam/Param/src/Param/QuadChart.h
87bc973b4511966dd521cc5fcfcaeed52c739ea1
[]
no_license
feengg/Parameterization
40f71bedd1adc7d2ccbbc45cc0c3bf0e1d0b1103
f8d2f26ff83d6f53ac8a6abb4c38d9b59db1d507
refs/heads/master
2020-03-23T05:18:25.675256
2011-01-21T15:19:08
2011-01-21T15:19:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
754
h
#ifndef HYWEI_QUADCHART_H_ #define HYWEI_QUADCHART_H_ #include "Parameterization.h" namespace PARAM { class QuadChart { public: QuadChart(int patch_id=-1); ~QuadChart(); public: bool InValidRangle(const ParamCoord& param_coord) const { return GreaterEqual(param_coord.s_coord, m_valid_range.first, LARGE_ZERO_EPSILON) && LessEqual(param_coord.s_coord, m_valid_range.second, LARGE_ZERO_EPSILON) && GreaterEqual(param_coord.t_coord, m_valid_range.first, LARGE_ZERO_EPSILON) && LessEqual(param_coord.t_coord, m_valid_range.second, LARGE_ZERO_EPSILON); } public: int m_patch_id; std::vector<ParamCoord> m_conner_param_coord_array; std::pair<double, double> m_valid_range; }; } #endif
[ [ [ 1, 31 ] ] ]
baf73e490ced23d7f7a7de05958faa84d9771796
e6abea92f59a1031d94bbcb3cee828da264c04cf
/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp
f3d4de1c0ac1146e39aac1ef132c3631d3176d5e
[]
no_license
bruderstein/nppifacelib_mob
5b0ad8d47a19a14a9815f6b480fd3a56fe2c5a39
a34ff8b5a64e237372b939106463989b227aa3b7
refs/heads/master
2021-01-15T18:59:12.300763
2009-08-13T19:57:24
2009-08-13T19:57:24
285,922
0
1
null
null
null
null
UTF-8
C++
false
false
7,265
cpp
/* NppPlugin.cpp * * This file is part of the Notepad++ Plugin Interface Lib. * Copyright 2009 Thell Fowler ([email protected]) * * 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; either version * 2 of the License, or (at your option) any later version. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * This is the main Notepad++ Plugin file for use with Notepad++ Plugin Interface Lib. * */ #include "NppPlugin.h" #include "NppPlugin_ChangeMarker.h" /* * The v_getfuncarray namespace alias allows for emulation of a class's 'virtual' function by * providing a 'symlink' like pointer to whichever npp_plugin namsespace extension that will * be responsible for responding to the N++ PluginsManager getfuncArray call. * * An example of this is npp_plugin::external_lexer::getfuncArray() which adds lexer funcItems * to the array and sorts them, then appends the plugin's primary funcItems in the order * the were registered. * */ namespace v_getfuncarray = npp_plugin; // This plugins namespace alias namespace p_cm = npp_plugin_changemarker; // <--- Required Plugin Interface Routines ---> BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/) { using namespace npp_plugin; switch (reasonForCall) { case DLL_PROCESS_ATTACH: // <--- Base initialization of the plugin object ---> npp_plugin::initPlugin(TEXT("Change Markers"), hModule); // <--- Base menu function items setup ---> setPluginFuncItem(TEXT("Jump: Prev Change"), p_cm::jumpChangePrev,p_cm::CMD_JUMPCHANGEPREV); setPluginFuncItem(TEXT("Jump: Next Change"), p_cm::jumpChangeNext,p_cm::CMD_JUMPCHANGENEXT); setPluginFuncItem(TEXT("Jump: Changed Line Up"), p_cm::jumpLineUp,p_cm::CMD_JUMPLINEUP); setPluginFuncItem(TEXT("Jump: Changed Line Down"), p_cm::jumpLineDown,p_cm::CMD_JUMPLINEDOWN); setPluginFuncItem(TEXT("Include Saved Changes in Jump Line Up/Down"), p_cm::jumpIncludeSaved,p_cm::CMD_JUMPINCLUDESAVED); setPluginFuncItem(TEXT(""), NULL); // A separator line. setPluginFuncItem(TEXT("Display: Line Number Margin"), p_cm::displayWithLineNumbers, p_cm::CMD_LINENUMBER , true); setPluginFuncItem(TEXT("Display: Change Mark Margin"), p_cm::displayWithChangeMarks, p_cm::CMD_CHANGEMARK, true); setPluginFuncItem(TEXT("Display: As Line Highlight"), p_cm::displayAsHighlight, p_cm::CMD_HIGHLIGHT, true); setPluginFuncItem(TEXT(""), NULL); // A separator line. setPluginFuncItem(TEXT("Disable Tracking for this Document"), p_cm::disableDoc, p_cm::CMD_DISABLEDOC, true); setPluginFuncItem(TEXT("Disable Plugin"), p_cm::disablePlugin, p_cm::CMD_DISABLEPLUGIN, true); setPluginFuncItem(TEXT("About..."), npp_plugin::About_func); #ifdef NPP_PLUGININTERFACE_CMDMAP_EXTENSION_H // <--- Initalize internal cmdId to funcItem cmdId map. ---> createCmdIdMap(); #endif break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } return TRUE; } extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *FuncsArraySize) { /* * PluginsManager stores pointers to the functions that are exposed, allowing dialog and * menu interaction. The base plugin's functions to retrieve the size and array can be * 'virtualized' by altering the namespace alias located near the top this file. * */ *FuncsArraySize = v_getfuncarray::getPluginFuncCount(); return ( v_getfuncarray::getPluginFuncArray() ); } // This function gives access to Notepad++'s notification facilities including forwarded // notifications from Scintilla. extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) { using namespace npp_plugin; switch (notifyCode->nmhdr.code) { case SCN_MODIFIED: if ( npp_plugin::isNppReady() ) { if ( ( notifyCode->modificationType & ( SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT ) ) || ( notifyCode->modificationType & ( SC_MOD_BEFOREDELETE ) ) ) { npp_plugin::hCurrViewNeedsUpdate(); p_cm::modificationHandler(notifyCode); } } break; case NPPN_READY: npp_plugin::setNppReady(); npp_plugin::hCurrViewNeedsUpdate(); npp_plugin::doctabmap::update_DocTabMap(); p_cm::wordStylesUpdatedHandler(); // Force an init of the style controller. break; case NPPN_TBMODIFICATION: p_cm::initPlugin(); break; case NPPN_WORDSTYLESUPDATED: p_cm::wordStylesUpdatedHandler(); break; case NPPN_BUFFERACTIVATED: if ( isNppReady() ) { npp_plugin::hCurrViewNeedsUpdate(); npp_plugin::doctabmap::update_DocTabMap(); p_cm::bufferActivatedHandler( notifyCode ); } break; case NPPN_FILEBEFORECLOSE: npp_plugin::hCurrViewNeedsUpdate(); p_cm::fileBeforeCloseHandler( notifyCode ); break; case NPPN_FILESAVED: npp_plugin::hCurrViewNeedsUpdate(); p_cm::fileSaveHandler(); break; default: break; } } extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam) { // Normally a plugin would use a switch case to check the Messages, but // this plugin only makes use of a single internal message... if ( Message == npp_plugin::PIFACE_MSG_NPPDATASET ) { // Confirm availability of the config file. TiXmlDocument * xmlDoc( npp_plugin::xmlconfig::get_pXmlPluginConfigDoc( true ) ); if (! xmlDoc ) { // Create a new default config file. p_cm::generateDefaultConfigXml(); } } return TRUE; } // Plugin Helper Functions void npp_plugin::About_func() { ::MessageBox(npp_plugin::hNpp(), TEXT(" Change Markers is a plugin that marks lines that have changed in a document since it was") TEXT(" since it was last loaded, and since it was last saved.\r\n\r\n") TEXT(" You can view lines with un-saved changes using the Jump menu commands.\n" ) TEXT(" Use Jump: Prev Change and Next Change to move through the changes in the order they were made.\n") TEXT(" Use Jump: Changed Line Up and Down to move to the first change found in the direction chosen.\r\n\r\n") TEXT(" Disabling change tracking for a document will clear all markers and reset the change tracker. This\n") TEXT(" can be used to clear old change marks, and keep your undo history, and not need to reload the document.\n") TEXT(" Disabling the whole plugin will stop all change processing. If you have several large documents and\n") TEXT(" will be doing bulk changes disabling the plugin will help speed up the process.\r\n\r\n") TEXT(" Hopefully you find this to be a useful tool. Enjoy!\r\n") TEXT(" Thell Fowler (almostautomated)"), TEXT("Change Markers 1.2.0"), MB_OK); }
[ "T B Fowler@2fa2a738-4fc5-9a49-b7e4-8bd4648edc6b" ]
[ [ [ 1, 195 ] ] ]
e587fed3258856ff9964d8e435549017ded06a1e
037faae47a5b22d3e283555e6b5ac2a0197faf18
/plugins/gs/gsdx9/GSdx9.cpp
b07ab5e6a1679bf8bfa8abc64db58dfca743f5c1
[]
no_license
isabella232/pcsx2-sourceforge
6e5aac8d0b476601bfc8fa83ded66c1564b8c588
dbb2c3a010081b105a8cba0c588f1e8f4e4505c6
refs/heads/master
2023-03-18T22:23:15.102593
2008-11-17T20:10:17
2008-11-17T20:10:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,357
cpp
/* * Copyright (C) 2003-2005 Gabest * http://www.gabest.org * * 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; either version 2, or (at your option) * any later version. * * 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 GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * * Special Notes: * */ #include "stdafx.h" #include "afxwin.h" #include "GSdx9.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // // Note! // // If this DLL is dynamically linked against the MFC // DLLs, any functions exported from this DLL which // call into MFC must have the AFX_MANAGE_STATE macro // added at the very beginning of the function. // // For example: // // extern "C" BOOL PASCAL EXPORT ExportedFunction() // { // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // // normal function body here // } // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that // it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. // // Please see MFC Technical Notes 33 and 58 for additional // details. // // CGSdx9App BEGIN_MESSAGE_MAP(CGSdx9App, CWinApp) END_MESSAGE_MAP() D3DDEVTYPE CGSdx9App::D3DDEVTYPE_X; // CGSdx9App construction CGSdx9App::CGSdx9App() { // TODO: add construction code here, // Place all significant initialization in InitInstance } // The one and only CGSdx9App object CGSdx9App theApp; // CGSdx9App initialization BOOL CGSdx9App::InitInstance() { __super::InitInstance(); D3DDEVTYPE_X = D3DDEVTYPE_HAL; if(GetSystemMetrics(SM_REMOTESESSION)) { D3DDEVTYPE_X = D3DDEVTYPE_REF; } return TRUE; }
[ "zerofrog@23c756db-88ba-2448-99d7-e6e4c676ec84" ]
[ [ [ 1, 93 ] ] ]
e6d61fc6c3ea8a60314e640a50e9f62b4efa7914
788d308fcb292f68c9f7eea3ae0a93e446737769
/toleinplaceframe.cpp
95030ab91d2aaeaf493f8aff2c01169db264f39c
[]
no_license
Tobbe/lsactivedesktop
60a8e6630d96926cdf1e6e84f5ac4a65f8feff1e
dbfefd89fbabb92ec986b62acf05bfddf22df57b
refs/heads/master
2021-01-22T07:13:47.766351
2011-08-15T12:55:52
2011-08-15T12:55:52
866,056
5
5
null
null
null
null
UTF-8
C++
false
false
1,449
cpp
#include "toleinplaceframe.h" HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::GetWindow(HWND *phwnd) { return E_FAIL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::ContextSensitiveHelp( BOOL fEnterMode) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::GetBorder(LPRECT lprectBorder) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::RequestBorderSpace( LPCBORDERWIDTHS pborderwidths) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::SetBorderSpace( LPCBORDERWIDTHS pborderwidths) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::SetActiveObject( IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName) { return S_OK; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject) { return S_OK; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::RemoveMenus(HMENU hmenuShared) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::SetStatusText( LPCOLESTR pszStatusText) { return S_OK; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::EnableModeless(BOOL fEnable) { return S_OK; } HRESULT STDMETHODCALLTYPE TOleInPlaceFrame::TranslateAccelerator(LPMSG lpmsg, WORD wID) { return E_NOTIMPL; }
[ [ [ 1, 69 ] ] ]
fbfe3709df2242895ae037a0f54254e57a5d5ce8
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
/OblivionOnline/cegui/CEGUIExceptions.h
ff98e46df77b77cb6028c842abe293b9b2c04567
[]
no_license
wlasser/oonline
51973b5ffec0b60407b63b010d0e4e1622cf69b6
fd37ee6985f1de082cbc9f8625d1d9307e8801a6
refs/heads/master
2021-05-28T23:39:16.792763
2010-05-12T22:35:20
2010-05-12T22:35:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
29,687
h
/*********************************************************************** filename: CEGUIExceptions.h created: 20/2/2004 author: Paul D Turner, Frederico Jeronimo (fjeronimo) purpose: Defines exceptions used within the system *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2007 Paul D Turner & The CEGUI Development Team * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #ifndef _CEGUIExceptions_h_ #define _CEGUIExceptions_h_ ////////////////////////////////////////////////////////////////////////// // INCLUDES ////////////////////////////////////////////////////////////////////////// #include "CEGUIBase.h" #include "CEGUIString.h" ////////////////////////////////////////////////////////////////////////// // CEGUI NAMESPACE ////////////////////////////////////////////////////////////////////////// // Start of CEGUI namespace section namespace CEGUI { ////////////////////////////////////////////////////////////////////////// // EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Root exception class used within the GUI system. */ class CEGUIEXPORT Exception { public: /************************************************************************/ /* PUBLIC FUNCTIONS /************************************************************************/ /*! \brief Return a reference to the String object describing the reason for the exception being thrown. \return String object containing a message describing the reason for the exception. */ const String& getMessage(void) const {return d_message;} /*! \brief Return a reference to the String object containing the exception name (i.e. class type). \return String object containing the exception name. */ const String& getName() const { return d_name; } /*! \brief Return a reference to the String object containing the name of the file where the exception occurred. \return String object containing the name of the file where the exception occurred. */ const String& getFileName(void) const {return d_filename;} /*! \brief Return the line number where the exception occurred. \Return Integer representing the line number where the exception occurred. */ const int getLine(void) const {return d_line;} protected: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Protected constructor that prevents instantiations (users should employ derived exception classes instead) and that is responsible for logging the exception. \param message String object describing the reason for the exception being thrown. \param name String object describing the exception class name (e.g. CEGUI::UnknownObjectException) \param filename String object containing the name of the file where the exception occurred. \param line Integer representing the line number where the exception occurred. */ Exception(const String& message = "", const String& name ="CEGUI::Exception", const String& filename = "", int line = 0); /*! \brief Virtual destructor. */ virtual ~Exception(void); /************************************************************************/ /* PROTECTED VARIABLES /************************************************************************/ /*! \brief Holds the reason for the exception being thrown. */ String d_message; /*! \brief Holds the name of the file where the exception occurred. */ String d_filename; /*! \brief Holds the class name of the exception (e.g. CEGUI::ObjectInUseException) */ String d_name; /*! \brief Holds the line number where the exception occurred. */ int d_line; }; ////////////////////////////////////////////////////////////////////////// // GENERIC EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when none of the other classes are applicable */ class CEGUIEXPORT GenericException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the generic exception by calling the base class. \param message String object describing the reason for the generic exception being thrown. \param filename String object containing the name of the file where the generic exception occurred. \param line Integer representing the line number where the generic exception occurred. \remarks The generic exception name is automatically passed to the base class as "CEGUI::GenericException". */ GenericException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::GenericException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the generic exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define GenericException(message) \ GenericException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // UNKNOWN OBJECT EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when a request was made using a name of an unknown object */ class CEGUIEXPORT UnknownObjectException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the unknown object exception by calling the base class. \param message String object describing the reason for the unknown object exception being thrown. \param filename String object containing the name of the file where the unknown object exception occurred. \param line Integer representing the line number where the unknown object exception occurred. \remarks The unknown object exception name is automatically passed to the base class as "CEGUI::UnknownObjectException". */ UnknownObjectException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::UnknownObjectException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the unknown object exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define UnknownObjectException(message) \ UnknownObjectException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // INVALID REQUEST EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when some impossible request was made for the current system state */ class CEGUIEXPORT InvalidRequestException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the invalid request exception by calling the base class. \param message String object describing the reason for the invalid request exception being thrown. \param filename String object containing the name of the file where the invalid request exception occurred. \param line Integer representing the line number where the invalid request exception occurred. \remarks The invalid request exception name is automatically passed to the base class as "CEGUI::InvalidRequestException". */ InvalidRequestException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::InvalidRequestException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the invalid request exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define InvalidRequestException(message) \ InvalidRequestException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // FILE IO EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when a file handling problem occurs */ class CEGUIEXPORT FileIOException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the file IO exception by calling the base class. \param message String object describing the reason for the file IO exception being thrown. \param filename String object containing the name of the file where the file IO exception occurred. \param line Integer representing the line number where the file IO exception occurred. \remarks The file IO exception name is automatically passed to the base class as "CEGUI::FileIOException". */ FileIOException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::FileIOException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the file IO exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define FileIOException(message) \ FileIOException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // RENDERER EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when an problem is detected within the Renderer or related objects */ class CEGUIEXPORT RendererException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the renderer exception by calling the base class. \param message String object describing the reason for the renderer exception being thrown. \param filename String object containing the name of the file where the renderer exception occurred. \param line Integer representing the line number where the renderer exception occurred. \remarks The renderer exception name is automatically passed to the base class as "CEGUI::RendererException". */ RendererException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::RendererException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the renderer exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define RendererException(message) \ RendererException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // ALREADY EXISTS EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when an attempt is made to use an object name that is already in use within the system */ class CEGUIEXPORT AlreadyExistsException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the already exists exception by calling the base class. \param message String object describing the reason for the already exists exception being thrown. \param filename String object containing the name of the file where the already exists exception occurred. \param line Integer representing the line number where the already exists exception occurred. \remarks The already exists exception name is automatically passed to the base class as "CEGUI::AlreadyExistsException". */ AlreadyExistsException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::AlreadyExistsException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the already exists exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define AlreadyExistsException(message) \ AlreadyExistsException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // MEMORY EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when a memory handling error is detected */ class CEGUIEXPORT MemoryException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the memory exception by calling the base class. \param message String object describing the reason for the memory exception being thrown. \param filename String object containing the name of the file where the memory exception occurred. \param line Integer representing the line number where the memory exception occurred. \remarks The memory exception name is automatically passed to the base class as "CEGUI::MemoryException". */ MemoryException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::MemoryException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the memory exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define MemoryException(message) \ MemoryException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // NULL OBJECT EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when some required object or parameter is null */ class CEGUIEXPORT NullObjectException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the null object exception by calling the base class. \param message String object describing the reason for the null object exception being thrown. \param filename String object containing the name of the file where the null object exception occurred. \param line Integer representing the line number where the null object exception occurred. \remarks The null object exception name is automatically passed to the base class as "CEGUI::NullObjectException". */ NullObjectException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::NullObjectException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the null object exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define NullObjectException(message) \ NullObjectException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // OBJECT IN USE EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when some attempt to delete, remove, or otherwise invalidate some object that is still in use occurs. */ class CEGUIEXPORT ObjectInUseException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the object in use exception by calling the base class. \param message String object describing the reason for the object in use exception being thrown. \param filename String object containing the name of the file where the object in use exception occurred. \param line Integer representing the line number where the object in use exception occurred. \remarks The object in use exception name is automatically passed to the base class as "CEGUI::ObjectInUseException". */ ObjectInUseException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::ObjectInUseException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the object in use exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define ObjectInUseException(message) \ ObjectInUseException(message, __FILE__, __LINE__) ////////////////////////////////////////////////////////////////////////// // SCRIPT EXCEPTION ////////////////////////////////////////////////////////////////////////// /*! \brief Exception class used when a scripting error occurs */ class CEGUIEXPORT ScriptException : public Exception { public: /************************************************************************/ /* CONSTRUCTORS/DESTRUCTORS /************************************************************************/ /*! \brief Constructor that is responsible for logging the script exception by calling the base class. \param message String object describing the reason for the script exception being thrown. \param filename String object containing the name of the file where the script exception occurred. \param line Integer representing the line number where the script exception occurred. \remarks The script exception name is automatically passed to the base class as "CEGUI::ScriptException". */ ScriptException(const String& message, const String& file = "unknown", int line = 0) : Exception(message, "CEGUI::ScriptException", file, line) {} }; /*! \brief This helper macro ensures the correct filename and line number where the script exception occurred are passed to the exception itself. \remarks There's a bug in Visual Studio 7.1 (see http://support.microsoft.com/kb/199057/en) and lower which leads to incorrect __LINE__ macro expansion if used inside a function and compiled with "Program Database for Edit & Continue" (/ZI) where instead of a constant expressing line number you'll get the following: (__LINE__Var+constant). The workaround consists in using compiler option "Program Database" (/Zi) instead --> Project Properties\C/C++\General\Debug Information Format\Program Database (/Zi). Visual Studio 2005 corrects the problem. Premake files were modified to contemplate this for VS2002 and VS2003. */ #define ScriptException(message) \ ScriptException(message, __FILE__, __LINE__) } // End of CEGUI namespace section #endif // end of guard _CEGUIExceptions_h_
[ "masterfreek64@2644d07b-d655-0410-af38-4bee65694944" ]
[ [ [ 1, 734 ] ] ]
d41a268e487fe323df5130f919c622991c399f14
cd3cb866cf33bdd9584d08f4d5904123c7d93da6
/files/tmfile.cpp
9db3913071e86e6c0d279fec24fc7d3a727eedbe
[]
no_license
benkopolis/conflict-resolver
d910aa0e771be2a1108203a3fd6da06ebdca5680
d4185a15e5c2ac42034931913ca97714b21a977c
refs/heads/master
2021-01-01T17:16:59.418070
2011-01-29T17:49:27
2011-01-29T17:49:27
32,231,168
0
0
null
null
null
null
UTF-8
C++
false
false
4,741
cpp
#include "tmfile.h" #include <QTextStream> #include <QRegExp> #include "records/tmrecord.h" #include "inifile.h" #include "tmsaver.h" TMFile::TMFile(QObject *parent) : GlossaryFile(parent) { } TMHeader TMFile::header() const { return this->_rheader; } /** * */ bool TMFile::saveContent(QString file) { bool r=false; TMSaver tms; r = tms.saveContent(file, this->_rheader, *this->_content, this->_all); return r; } /** * */ bool TMFile::saveReversedContent(QString file) { bool r=false; TMSaver tms; r = tms.saveReversedContent(file, this->_rheader, *this->_content, this->_all); return r; } /** * */ Error TMFile::processWithTabs(QFile & file) { QTextStream f(&file); QFile dump("duties.txt"); // TODO - wybor pliku, tak zeby dawalo rade zapisywac na win7 dump.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); QTextStream dstream(&dump); QString temp, ln1, ln2; QString text; _header.clear(); QTextStream forHeader(&_header); forHeader << f.readLine(); // przeczytany naglowek processHeader(); TMRecord* tmr=0; QDate d; QTime t; QRegExp rexp(IniFile::instance()->regex(), Qt::CaseInsensitive); bool store = true; if(IniFile::instance()->regex().startsWith("(?:") == false) { rexp.setPattern("(?:[0-9]{8,8}(~|=)[0-9]{6,6}\t*.*\t[0-9]{1,}\t.*\t.*\t.*)"); IniFile::instance()->setRegex(rexp.pattern()); } QChar tab('\t'), nl('\n'), tempChar; while(!f.atEnd()) { // czytaj linie w pliku QString line(f.readLine()); line.remove(QRegExp("\\s{12,}")); // usuwanie nadmiaru spacji if(line.contains(rexp) == false) { dstream << line << endl; ++_corrupted; continue; } QTextStream iline(&line); iline >> temp; if(this->isDateTime(temp, &d, &t) == false) { // wczytywanie daty i jezeli zla to do duties ++_corrupted; dstream << line << endl; continue; } // delete tmr; // tworzenie rekordu tmr = new TMRecord(this); tmr->setDate(d); tmr->setTime(t); iline >> temp; // czytanie nastepnego slowa po dacie (autor) if(iline.atEnd()){ ++_corrupted; dstream << line << endl; continue; } tmr->setAuthor(temp); iline >> temp; // czytanie nastepnego slowa - ilosc uzyc if(iline.atEnd()){ ++_corrupted; dstream << line << endl; continue; } tmr->setAuthorId(temp); iline >> ln1; // czytanie kodu jezyka zrodlowego if(iline.atEnd()){ ++_corrupted; dstream << line << endl; continue; } QString wz = _rheader.sourceCode().mid(1, 2); QString wr = ln1.mid(0, 2); if(QString::compare(wz, wr, Qt::CaseInsensitive) != 0) { // sprawdzenie czy jezyk zrodlowy zgadza sie z naglowkiem ++_corrupted; dstream << line << endl; continue; } tmr->setSourceCode(ln1); bool con = false; do { // czytanie tekstu zrodlowego if(tempChar != QChar()) text = text.append(" "); iline >> temp; text = text.append(temp); iline >> tempChar; if(iline.atEnd()){ ++_corrupted; dstream << line << endl; con = true; break; } } while(tempChar != tab); if(con) continue; text = correctText(text); // poprawianie tekstu zrodlowego if(validateText(text, &store) == false) { // sprawdzenie poprawnosci tekstu zrodlowego ++_corrupted; if(store == true) dstream << line << endl; text.clear(); continue; } tmr->setSource(text); text.clear(); iline >> ln2; // czytanie kodu jezyka docelowego if(iline.atEnd()){ ++_corrupted; dstream << line << endl; continue; } if(QString::compare(_rheader.targetCode().mid(1, 2), ln2.mid(0, 2), Qt::CaseInsensitive) != 0) { // sprawdzenie czy jezyk docelowy zgadza sie z naglowkiem ++_corrupted; dstream << line << endl; continue; } tmr->setTargetCode(ln2); tempChar = QChar(); do {// wczytywanie tekstu docelowego if(tempChar != QChar()) text = text.append(" "); iline >> temp; text = text.append(temp); iline >> tempChar; if(tempChar == tab){ break; } } while(tempChar != tab && iline.atEnd() == false); if(con) continue; text = correctText(text); if(validateText(text, &store) == false) { ++_corrupted; if(store == true) dstream << line << endl; text.clear(); continue; } tmr->setTarget(text); _content->insertMulti(FuzzyStrings(tmr->source()), tmr); text.clear(); ++_all; } dump.close(); return Error(); } /** * */ Error TMFile::processHeader() { return _rheader.readHeader(_header); }
[ "benkopolis@ce349ab3-abbd-076b-ff20-4646c42d6692" ]
[ [ [ 1, 187 ] ] ]
d1c3d387035df2f42ba62349571271db5172fa7f
60bc06fb1bcb40b96533bfb9c8dd930c8d05bed5
/Fuser/Fuser.cpp
935b5d9340d64d64a82c1ce4ada9a88e4677d3d8
[]
no_license
TheStarport/FLDev
b69b6c42bc10cad1a48c6ac08fc17183e5fedf6d
21ff46442f359a26c3391fd4b27b9f74fd50869c
refs/heads/master
2023-02-22T07:50:09.661915
2010-11-22T04:18:48
2010-11-22T04:18:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
428
cpp
// Fuser.cpp : main project file. #include "stdafx.h" #include "Main.h" using namespace Fuser; [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Main()); return 0; }
[ [ [ 1, 18 ] ] ]
f0c20e9987b8fb5ae76df467adc8d7741bb2ad09
6630a81baef8700f48314901e2d39141334a10b7
/1.4/Testing/Cxx/swWxGuiTesting/swWxGuiTestTempInteractiveControl.h
fa9563efa4b3c3edd933984fc4e0dce07a72dfd8
[]
no_license
jralls/wxGuiTesting
a1c0bed0b0f5f541cc600a3821def561386e461e
6b6e59e42cfe5b1ac9bca02fbc996148053c5699
refs/heads/master
2021-01-10T19:50:36.388929
2009-03-24T20:22:11
2009-03-26T18:51:24
623,722
1
0
null
null
null
null
ISO-8859-1
C++
false
false
1,883
h
/////////////////////////////////////////////////////////////////////////////// // Name: swWxGuiTesting/swWxGuiTestTempInteractiveControl.h // Author: Reinhold Füreder // Created: 2004 // Copyright: (c) 2005 Reinhold Füreder // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef SWWXGUITESTTEMPINTERACTIVECONTROL_H #define SWWXGUITESTTEMPINTERACTIVECONTROL_H #ifdef __GNUG__ #pragma interface "swWxGuiTestTempInteractiveControl.h" #endif #include "Common.h" namespace swTst { /*! \class WxGuiTestTempInteractiveControl \brief Handle events of dialog (controller in MVC concept). */ class WxGuiTestTempInteractiveControl : public wxEvtHandler { DECLARE_EVENT_TABLE() public: /*! \fn WxGuiTestTempInteractiveControl (wxDialog *dialog) \brief Constructor \param dialog dialog with button to continue unit testing */ WxGuiTestTempInteractiveControl (wxDialog *dialog); /*! \fn virtual ~WxGuiTestTempInteractiveControl () \brief Destructor */ virtual ~WxGuiTestTempInteractiveControl (); protected: /*! \fn virtual void OnOK (wxCommandEvent &event) \brief User clicked on OK button to continue testing -> finish. \param event button click event */ virtual void OnOK (wxCommandEvent &event); /*! \fn virtual void OnClose (wxCloseEvent &event) \brief Normal dialog closing callback -> finish. \param dialog close event */ virtual void OnClose (wxCloseEvent &event); /*! \fn virtual void Finish () \brief Finish temporary interactivity. */ virtual void Finish (); private: wxDialog *m_dialog; }; } // End namespace swTst #endif // SWWXGUITESTTEMPINTERACTIVECONTROL_H
[ "john@64288482-8357-404e-ad65-de92a562ee98" ]
[ [ [ 1, 73 ] ] ]
9f37c346532b9b9637fcb0461f6120451cb1eaf1
1efa9ffc73895ab3da9c03d2cb730a5d7b0d897c
/source/MapEdit/Src/frmMain.h
eb1fc61139063d1d43c488339dbc161b71fa41c7
[]
no_license
sydlawrence/CorsixTH-HTML5-Port
fc9356c8bfd0f00955877ec0da1a486e6892ba4c
95d272e0ad27758fed7d231d8ab7f79aa4b0773f
refs/heads/master
2021-01-23T00:07:18.124534
2011-09-25T20:06:11
2011-09-25T20:06:11
2,455,933
7
0
null
null
null
null
UTF-8
C++
false
false
4,390
h
/* Copyright (c) 2009 Peter "Corsix" Cawley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif // for all others, include the necessary headers (this file is usually all you // need because it includes almost all "standard" wxWidgets headers) #ifndef WX_PRECOMP #include "wx/wx.h" #endif // ---------------------------- #include "scrollable_game.h" #include <wx/ribbon/bar.h> #include <wx/ribbon/buttonbar.h> #include "block_gallery.h" class frmMain : public wxFrame { public: frmMain(); ~frmMain(); enum { ID_GALLERY_FLOOR1 = wxID_HIGHEST + 1, ID_GALLERY_FLOOR2, ID_GALLERY_WALL1, ID_GALLERY_WALL2, ID_GALLERY_PARCELS, ID_VIEW_WALLS, ID_VIEW_FLAGS, ID_VIEW_PARCELS, ID_PARCEL_PANEL }; protected: wxRibbonBar* m_pRibbon; wxRibbonPage* m_pHomePage; frmLog* m_pLogWindow; ScrollableGamePanel* m_pGamePanel; RibbonBlockGallery* m_pFloorGallery1; RibbonBlockGallery* m_pFloorGallery2; RibbonBlockGallery* m_pWallGallery1; RibbonBlockGallery* m_pWallGallery2; wxString m_sFrameCaption; wxString m_sFilename; bool m_bViewFlags; bool m_bViewParcels; bool m_bViewWalls; int m_iFloorTabBrushF; int m_iFloorTabBrushW1; int m_iFloorTabBrushW2; int m_iWallsTabBrushF; int m_iWallsTabBrushW1; int m_iWallsTabBrushW2; int m_iParcelBrush; void _applyViewWalls(); void _applyViewOverlay(); wxString _getMapsDirectory(); wxString _getMapsFilter(); void _setFilename(const wxString& sFilename); void _onFloorGallery1Select(wxRibbonGalleryEvent& evt); void _onFloorGallery2Select(wxRibbonGalleryEvent& evt); void _onWallGallery1Select(wxRibbonGalleryEvent& evt); void _onWallGallery2Select(wxRibbonGalleryEvent& evt); void _onParcelGallerySelect(wxRibbonGalleryEvent& evt); void _onNew(wxRibbonButtonBarEvent& evt); void _onOpen(wxRibbonButtonBarEvent& evt); void _onSave(wxRibbonButtonBarEvent& evt); void _onSaveMenu(wxRibbonButtonBarEvent& evt); void _onSaveMenuSave(wxCommandEvent& evt); void _onSaveMenuSaveAs(wxCommandEvent& evt); void _onResize(wxSizeEvent& evt); void _onViewWalls(wxRibbonButtonBarEvent& evt); void _onViewFlags(wxRibbonButtonBarEvent& evt); void _onViewParcels(wxRibbonButtonBarEvent& evt); void _onRibbonPageChanged(wxRibbonBarEvent& evt); void _populateParcelGallery(wxRibbonGallery* pGallery); static wxBitmap _asBitmap(THSpriteSheet* pSheet, unsigned int iSprite); static int _l_init(lua_State *L); static int _l_init_with_lua_app(lua_State *L); static int _l_set_blocks(lua_State *L); static int _l_set_block_brush(lua_State *L); static int _l_do_load(lua_State *L); void _setLuaBlockBrushFloorTab(int iBlockF, int iBlockW1, int iBlockW2); void _setLuaBlockBrushWallsTab(int iBlockF, int iBlockW1, int iBlockW2); void _setLuaBlockBrushFloorTab(); void _setLuaBlockBrushWallsTab(); void _setLuaBlockBrush(int iBlockF, int iBlockW1, int iBlockW2); void _setLuaParcelBrush(int iParcel); DECLARE_EVENT_TABLE(); };
[ [ [ 1, 119 ] ] ]
eeb55d8645a23bddd328ee1b9d9418c47497d024
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp
f4217383b370a8314929b68e751391fd29a84d45
[]
no_license
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,087
cpp
/* * Copyright (C) 2010 Apple Inc. All rights reserved. * * 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. */ #include "NetscapePluginModule.h" #include "Module.h" #include "NetscapeBrowserFuncs.h" #include <wtf/PassOwnPtr.h> namespace WebKit { static Vector<NetscapePluginModule*>& initializedNetscapePluginModules() { DEFINE_STATIC_LOCAL(Vector<NetscapePluginModule*>, initializedNetscapePluginModules, ()); return initializedNetscapePluginModules; } NetscapePluginModule::NetscapePluginModule(const String& pluginPath) : m_pluginPath(pluginPath) , m_isInitialized(false) , m_pluginCount(0) , m_shutdownProcPtr(0) , m_pluginFuncs() { } NetscapePluginModule::~NetscapePluginModule() { ASSERT(initializedNetscapePluginModules().find(this) == notFound); } void NetscapePluginModule::pluginCreated() { m_pluginCount++; } void NetscapePluginModule::pluginDestroyed() { ASSERT(m_pluginCount > 0); m_pluginCount--; if (!m_pluginCount) shutdown(); } void NetscapePluginModule::shutdown() { ASSERT(m_isInitialized); m_shutdownProcPtr(); size_t pluginModuleIndex = initializedNetscapePluginModules().find(this); ASSERT(pluginModuleIndex != notFound); initializedNetscapePluginModules().remove(pluginModuleIndex); } PassRefPtr<NetscapePluginModule> NetscapePluginModule::getOrCreate(const String& pluginPath) { // First, see if we already have a module with this plug-in path. for (size_t i = 0; i < initializedNetscapePluginModules().size(); ++i) { NetscapePluginModule* pluginModule = initializedNetscapePluginModules()[i]; if (pluginModule->m_pluginPath == pluginPath) return pluginModule; } RefPtr<NetscapePluginModule> pluginModule(adoptRef(new NetscapePluginModule(pluginPath))); // Try to load and initialize the plug-in module. if (!pluginModule->load()) return 0; return pluginModule.release(); } bool NetscapePluginModule::load() { if (!tryLoad()) { unload(); return false; } m_isInitialized = true; ASSERT(initializedNetscapePluginModules().find(this) == notFound); initializedNetscapePluginModules().append(this); return true; } bool NetscapePluginModule::tryLoad() { m_module = adoptPtr(new Module(m_pluginPath)); if (!m_module->load()) return false; NP_InitializeFuncPtr initializeFuncPtr = m_module->functionPointer<NP_InitializeFuncPtr>("NP_Initialize"); if (!initializeFuncPtr) return false; NP_GetEntryPointsFuncPtr getEntryPointsFuncPtr = m_module->functionPointer<NP_GetEntryPointsFuncPtr>("NP_GetEntryPoints"); if (!getEntryPointsFuncPtr) return false; m_shutdownProcPtr = m_module->functionPointer<NPP_ShutdownProcPtr>("NP_Shutdown"); if (!m_shutdownProcPtr) return false; m_pluginFuncs.size = sizeof(NPPluginFuncs); m_pluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; // On Mac, NP_Initialize must be called first, then NP_GetEntryPoints. On Windows, the order is // reversed. Failing to follow this order results in crashes (e.g., in Silverlight on Mac and // in Flash and QuickTime on Windows). #if PLATFORM(MAC) if (initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR || getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR) return false; #elif PLATFORM(WIN) if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR) return false; #endif return true; } void NetscapePluginModule::unload() { m_module = 0; } } // namespace WebKit
[ [ [ 1, 155 ] ] ]
cb0787e40e0d615b624bccedf523253df9757e86
6477cf9ac119fe17d2c410ff3d8da60656179e3b
/Projects/z6manager/main.cpp
288e4e2622b3f590b4761868599f8117bd926655
[]
no_license
crutchwalkfactory/motocakerteam
1cce9f850d2c84faebfc87d0adbfdd23472d9f08
0747624a575fb41db53506379692973e5998f8fe
refs/heads/master
2021-01-10T12:41:59.321840
2010-12-13T18:19:27
2010-12-13T18:19:27
46,494,539
0
0
null
null
null
null
UTF-8
C++
false
false
360
cpp
#include "z6manager.h" //#include "GUI_Define.h" #include <ZApplication.h> Z6Man* z6man; ZApplication* app; int main ( int argc, char **argv ) { app = new ZApplication ( argc, argv ); Z6Man *z6man = new Z6Man (argv[2], NULL, NULL ); int ret = app->exec(); delete z6man; z6man = NULL; delete app; app = NULL; return ret; }
[ [ [ 1, 19 ] ] ]
5f210918c8d287100e8c1b78d6142188d6bf07f4
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/Code/Flosti Engine/Graphics/Sprite.cpp
2e430f2bd8f0398dce62f6df0ff79f67a04241dd
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
3,182
cpp
#include "__PCH_Graphics.h" #include "Sprite.h" #include <d3dx9.h> #include "Graphics/RenderManager.h" #include "Graphics/Textures/Texture.h" CSprite::CSprite() : m_pTexture(NULL) , m_bImageLoaded(false) , m_Position(v2fZERO) , m_Velocity(v2fZERO) , m_uState(0) , m_uDirection(0) , m_uWidth(1) , m_uHeight(1) , m_uCurFrame(0) , m_uTotalFrames(1) , m_uAnimDir(1) , m_uAnimColumns(1) , m_uFrameStart(0) , m_uFrameTimer(0) , m_uAnimStartx(0) , m_uAnimstarty(0) , m_dFaceAngle(0) , m_dMoveAngle(0) , m_dRotation(0) , m_dScalingX(1.0f) , m_dScalingY(1.0f) , m_Color(colWHITE) , m_uMoveTimer(16) , m_uMoveStart(0) , m_bCollidable(true) , m_eCollisionMethod(COLLISION_RECT) {} CSprite::~CSprite() { //CHECKED_DELETE(m_pTexture) } void CSprite::Transform(CRenderManager* rm) { D3DXMATRIX mat; D3DXVECTOR2 scale((float)m_dScalingX,(float)m_dScalingY); D3DXVECTOR2 center((float)(m_uWidth*m_dScalingX), (float)(m_uHeight*m_dScalingY)); //D3DXVECTOR2 center(0.f,0.f); D3DXVECTOR2 trans((float)GetX(), (float)GetY()); D3DXMatrixTransformation2D(&mat,NULL,0,&scale,&center,(float)m_dRotation,&trans); rm->GetSpriteHandler()->SetTransform(&mat); } void CSprite::SetTexture (CTexture* texture) { m_pTexture = texture; assert(texture); uint32 w,h; m_pTexture->GetWidthAndHeight(w,h); m_uWidth = w; m_uHeight = h; } void CSprite::SetAbsWAndH(uint32 w, uint32 h) { m_dScalingX = (w/(double)m_uWidth); m_dScalingY = (h/(double)m_uHeight); } void CSprite::Draw(CRenderManager* rm) { int fx = (m_uCurFrame % m_uAnimColumns) * m_uWidth; int fy = (m_uCurFrame / m_uAnimColumns) * m_uHeight; RECT srcRect = {fx,fy, fx+ m_uWidth, fy+m_uHeight}; Transform(rm); D3DXCOLOR color(m_Color.GetUint32Argb()); rm->GetSpriteHandler()->Draw(m_pTexture->GetD3DXTexture(),&srcRect,NULL,NULL,color); } void CSprite::Move() { if (m_uMoveTimer > 0) { if (timeGetTime() > (DWORD)(m_uMoveStart + m_uMoveTimer)) { //reset move timer m_uMoveStart = timeGetTime(); //move sprite by velocity amount SetX(GetX() + m_Velocity.x); SetY(GetY() + m_Velocity.y); } } else { //no movement timer--update at cpu clock speed SetX(GetX() + m_Velocity.x); SetY(GetY() + m_Velocity.y); } } void CSprite::Animate() { //update frame based on animdir if (m_uFrameTimer > 0) { if (timeGetTime() > (DWORD)(m_uFrameStart + m_uFrameTimer)) { //reset animation timer m_uFrameStart = timeGetTime(); m_uCurFrame += m_uAnimDir; //keep frame within bounds if (m_uCurFrame < 0) m_uCurFrame = m_uTotalFrames-1; if (m_uCurFrame > m_uTotalFrames-1) m_uCurFrame = 0; } } else { //no animation timer--update at cpu clock speed m_uCurFrame += m_uAnimDir; if (m_uCurFrame < 0) m_uCurFrame = m_uTotalFrames-1; if (m_uCurFrame > m_uTotalFrames-1) m_uCurFrame = 0; } } //Rect Sprite::getBounds() //{ // Rect rect; // rect.left = getX(); //rect.top = getY(); //rect.right = getX() + getWidth() * getScale(); //rect.bottom = getY() + getHeight() * getScale(); // return rect; //}
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 144 ] ] ]
aab05e5709a4ac3944aa2cd8e3187820f737e6f6
0da7fec56f63012180d848b1e72bada9f6984ef3
/PocketDjVu_root/PocketDjvu/OptionsDlg.h
dd5f82c6fdefd630f49ed45a17ac7ec25c5d5fec
[]
no_license
UIKit0/pocketdjvu
a34fb2b8ac724d25fab7a0298942db1755098b25
4c0c761e6a3d3628440fb4fb0a9c54e5594807d9
refs/heads/master
2021-01-20T12:01:16.947853
2010-05-03T12:29:44
2010-05-03T12:29:44
32,293,688
0
0
null
null
null
null
UTF-8
C++
false
false
1,000
h
#pragma once #include "./BrowseSettings.h" #include "./SIPState.h" #include "./TimingDlg.h" #include "./VMDlg.h" #include "./MiscSettings.h" class COptionsDlg : public WTL::CPropertySheetImpl<COptionsDlg> { typedef WTL::CPropertySheetImpl<COptionsDlg> Base; public: COptionsDlg(); void OnSheetInitialized(); BEGIN_MSG_MAP(COptionsDlg) CHAIN_MSG_MAP(Base) END_MSG_MAP() // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnWininiChange( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ); // DATA: private: CSIPState m_sip; CBrowseSettings m_BrowsePg; CMiscSettings m_MiscPg; CVMDlg m_VMPg; CTimingDlg m_TimingPg; };
[ "Igor.Solovyov@84cd470b-3125-0410-acc3-039690e87181" ]
[ [ [ 1, 37 ] ] ]
d95ce236fcad2e99d4cb65eb2cc753f051128596
720466c088f243d6d54046e34872a91e3c911c58
/math/kernels/fd/gen_LR_Dn.cpp
13d5f0259b6ee2d5ec0b2b8a598b345a752e819a
[]
no_license
tmarkovich/mathlib
57f0d788a34e235b003bb49da4cb47bceb812026
a24353d59d38e18a44e084c5fc2accee6c1750a1
refs/heads/master
2021-01-17T18:24:02.477880
2011-03-05T23:17:58
2011-03-05T23:17:58
14,571,612
1
0
null
null
null
null
UTF-8
C++
false
false
2,454
cpp
#include <stdlib.h> #include <stdio.h> #include <iostream> #include <sstream> #include <assert.h> #include <fstream> #include <complex> #include <vector> #include <mathlib/math/matrices/matrix1.cpp> #include <arprec/mp_real.h> using namespace std; int m; int L,R; int k = 1; mp_real A_ij(int n, int i) { n -= 1; i -= L+1; if (n) return mp_real( pow((mp_real)i,n) / gamma((mp_real)(n+1)) ); else return mp_real(1.0); } int main() { stdSetup(); mp::mp_init(400); int ML = 24; int MR = 24; for (int k = 1;k<=6;k++) { int mm = k; vector<int> Lv; vector<int> Rv; vector< vector<mp_real> > Cv; for (L = 0;L<=ML;L++) for (R = 0;R<=MR;R++) if (R+L>=mm) { cout << k << " " << L << " " << R << endl; int size =L+R+1; matrix1<mp_real> A(size,size); A = A_ij; matrix1<mp_real> x(size,size); matrix1<mp_real> b(size,size); b(k+1,1) = 1.0; matrix1_LU<mp_real> lu(A); lu.solve(x,b); vector<mp_real> c; for (int i = 1;i<=size;i++) c.push_back(x(i,1)); Lv.push_back(L); Rv.push_back(R); Cv.push_back(c); } else { Lv.push_back(L); Rv.push_back(R); vector<mp_real> c; Cv.push_back(c); } ofstream out; sprintf(fname,"FD_D%d_LR.h",k); out.open(fname,ios::out); assert(out.good() && out.is_open()); int ndigits = 22; int exponent; char * digits = new char[ndigits+5]; int u,v; for (u=0;u<Cv.size();u++) { L = Lv[u]; R = Rv[u]; if (L+R>=mm) { out << "const double FD_D" << k << "_LR_" << Lv[u] << "_" << Rv[u] << "_" << "[] = {\n"; for (v=0;v<Cv[u].size();v++) { Cv[u][v].to_digits(digits, exponent, ndigits); if (exponent < 0 && exponent < -306) { out << "0";} else { if ( Cv[u][v]< 0.0 ) out << "-"; else out << "+"; out << digits[0] << "." << &(digits[1]) << "e"; if (exponent >= 0) out << "+"; out << exponent; } if (v < Cv[u].size()-1 ) out << "," << endl; else out << "}; " << endl << endl; } out << endl; } } out << "const double * FD_D" << k << "_LR_[" << ML+1 << "][" << MR+1 << "] = {\n"; for (u=0;u<Cv.size();u++) { L = Lv[u]; R = Rv[u]; if (L+R>=mm) { out << "&FD_D" << k << "_LR_" << L << "_" << R << "_[0]"; } if (L+R<mm) out << "0"; if (u<Cv.size()-1) out << ",\n"; else out << "};\n\n"; } out.close(); } }
[ "nick@nick-desktop.(none)" ]
[ [ [ 1, 157 ] ] ]
2e69e998c0f4011ecddd2304d3c37b953b60af11
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SETools/SEManagedFramework/SEManagedRendering/SEManagedLight.h
b376ad41bcce94cd6be4f9028066c885b61e8b14
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
UTF-8
C++
false
false
3,900
h
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #pragma once #include "SEINativeObject.h" #include "SEManagedVector3.h" #include "SEManagedColorRGB.h" namespace Swing{ namespace Tools{ namespace ManagedFramework{ //---------------------------------------------------------------------------- // Description: // Author:Sun Che // Date:20100115 //---------------------------------------------------------------------------- public ref class ManagedLight sealed : INativeObject { public: enum class LightType { LT_AMBIENT, LT_DIRECTIONAL, LT_POINT, LT_SPOT, LT_COUNT }; ManagedLight(LightType eType); ~ManagedLight(void); // Properties. property LightType Type { LightType get(void); void set(LightType eType); } property ManagedColorRGB^ Ambient { ManagedColorRGB^ get(void); void set(ManagedColorRGB^ thColor); } property ManagedColorRGB^ Diffuse { ManagedColorRGB^ get(void); void set(ManagedColorRGB^ thColor); } property ManagedColorRGB^ Specular { ManagedColorRGB^ get(void); void set(ManagedColorRGB^ thColor); } property float Constant { float get(void); void set(float fValue); } property float Linear { float get(void); void set(float fValue); } property float Quadratic { float get(void); void set(float fValue); } property float Intensity { float get(void); void set(float fValue); } property float Angle { float get(void); void set(float fValue); } property float CosAngle { float get(void); void set(float fValue); } property float SinAngle { float get(void); void set(float fValue); } property float Exponent { float get(void); void set(float fValue); } property ManagedVector3f^ Position { ManagedVector3f^ get(void); void set(ManagedVector3f^ thPosition); } property ManagedVector3f^ RVector { ManagedVector3f^ get(void); void set(ManagedVector3f^ thRVector); } property ManagedVector3f^ UVector { ManagedVector3f^ get(void); void set(ManagedVector3f^ thUVector); } property ManagedVector3f^ DVector { ManagedVector3f^ get(void); void set(ManagedVector3f^ thDVector); } void SetAngle(float fAngle); // Implement INativeObject interface. virtual void SetName(String^ thName); virtual String^ GetName(void); // virtual int GetNativeReferences(void); internal: [CLSCompliant(false)] ManagedLight(SELight* pLight); [CLSCompliant(false)] SELight* GetNativeLight(void); private: SELightPtr* m_pspLight; }; }}}
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 150 ] ] ]
8bbe14e49ab4efc628d8b7fdfad06f64914efb7e
59166d9d1eea9b034ac331d9c5590362ab942a8f
/XMLTree2Geom/osg/nodes/osgNodeFronds.cpp
2f75c9f6def7c2f60468ac60f463fa57c7bf5fb3
[]
no_license
seafengl/osgtraining
5915f7b3a3c78334b9029ee58e6c1cb54de5c220
fbfb29e5ae8cab6fa13900e417b6cba3a8c559df
refs/heads/master
2020-04-09T07:32:31.981473
2010-09-03T15:10:30
2010-09-03T15:10:30
40,032,354
0
3
null
null
null
null
WINDOWS-1251
C++
false
false
5,324
cpp
#include "osgNodeFronds.h" #include "xmlTree.h" #include <osg/Geometry> #include <osg/Geode> #include <osgDB/ReadFile> #include <osgDB/WriteFile> #include <osg/Image> #include <osgDB/FileUtils> #include <osg/Texture2D> #include <osg/AlphaFunc> #include <osg/CullFace> #include <osg/Node> #include <osg/Group> #include <osg/Drawable> #include <sstream> osgNodeFronds::osgNodeFronds() { } osgNodeFronds::~osgNodeFronds() { } void osgNodeFronds::LODSave() { //сохранить ветки по LOD'ам binFronds &fronds = xmlTree::Instance().GetFronds(); //количество LOD'ов веток int numLOD = fronds.m_vFronds.size(); for ( int i = 0 ; i < numLOD ; ++i ) { osg::ref_ptr< osg::Group > nodeFronds = new osg::Group; //инициировать корневой узел данными nodeFronds->addChild( InitFrondsGeode( i ).get() ); //добавить текстуру AddTexture( nodeFronds->getOrCreateStateSet() ); std::stringstream ss; ss << "fronds" << i; std::string sStl = ss.str() + ".stl"; std::string sFlt = ss.str() + ".flt"; std::string sObj = ss.str() + ".obj"; bool resStl = osgDB::writeNodeFile( *nodeFronds , sStl.c_str() ); bool resFlt = osgDB::writeNodeFile( *nodeFronds , sFlt.c_str() ); bool resObj = osgDB::writeNodeFile( *nodeFronds , sObj.c_str() ); int a = 1; } } osg::ref_ptr< osg::Geode > osgNodeFronds::InitFrondsGeode( int iLOD ) { //инициировать корневой узел данными osg::ref_ptr< osg::Geode > geode = new osg::Geode; // Create an object to store geometry in. osg::ref_ptr< osg::Geometry > geom = new osg::Geometry; // Create an array of vertices. osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array; // Create an array of normals. osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array; // Create a Vec2Array of texture coordinates for texture unit 0 // and attach it to the geom. osg::ref_ptr<osg::Vec2Array> tc = new osg::Vec2Array; //получить ссылку на данные веток binFronds &fronds = xmlTree::Instance().GetFronds(); //копируем координаты for ( int i = 0 ; i < fronds.m_vFronds[ iLOD ].m_vVertex.size() / 3 ; ++i ) { osg::Vec3 coord( fronds.m_vFronds[ iLOD ].m_vVertex[ i * 3 ] , fronds.m_vFronds[ iLOD ].m_vVertex[ i * 3 + 1 ] , fronds.m_vFronds[ iLOD ].m_vVertex[ i * 3 + 2 ] ); v->push_back( coord ); osg::Vec3 normal( fronds.m_vFronds[ iLOD ].m_vNormal[ i * 3 ] , fronds.m_vFronds[ iLOD ].m_vNormal[ i * 3 + 1 ] , fronds.m_vFronds[ iLOD ].m_vNormal[ i * 3 + 2 ] ); n->push_back( normal ); osg::Vec2 tex0( fronds.m_vFronds[ iLOD ].m_vTexCoord[ i * 2 ] , fronds.m_vFronds[ iLOD ].m_vTexCoord[ i * 2 + 1 ] ); tc->push_back( tex0 ); } geom->setVertexArray( v.get() ); geom->setNormalArray( n.get() ); geom->setNormalBinding( osg::Geometry::BIND_PER_VERTEX ); geom->setTexCoordArray( 0, tc.get() ); for ( int i = 0 ; i < fronds.m_vFronds[ iLOD ].m_vvIndex.size() ; ++i ) { geom->addPrimitiveSet( new osg::DrawElementsUShort( osg::PrimitiveSet::TRIANGLE_STRIP, fronds.m_vFronds[ iLOD ].m_vvIndex[ i ].size() , &fronds.m_vFronds[ iLOD ].m_vvIndex[ i ][ 0 ] ) ); } geode->addDrawable( geom.get() ); //настроить альфа канал SetupAlfaFunc( geode.get() , iLOD ); return geode.get(); } void osgNodeFronds::SetupAlfaFunc( osg::ref_ptr< osg::Geode > geode , int iLOD ) { //настроить альфа канал //получить ссылку на данные веток binFronds &fronds = xmlTree::Instance().GetFronds(); if ( fronds.m_vFronds[ iLOD ].m_fAlfa > 0.0f) { //настройка атрибутов состояния LOD ствола osg::StateSet* state = geode->getOrCreateStateSet(); //помечаем объект как имеющий прозрачность state->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); // Turn on alpha testing osg::AlphaFunc* af = new osg::AlphaFunc( osg::AlphaFunc::GREATER, fronds.m_vFronds[ iLOD ].m_fAlfa ); state->setAttributeAndModes( af ); } } void osgNodeFronds::AddTexture( osg::StateSet* state ) { //добавить текстуру //получить ссылку на данные веток binFronds &fronds = xmlTree::Instance().GetFronds(); // Load the texture image osg::ref_ptr<osg::Image> image0 = osgDB::readImageFile( fronds.m_sTexture.c_str() ); // Attach the image in a Texture2D object osg::ref_ptr<osg::Texture2D> tex0 = new osg::Texture2D; tex0->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR); tex0->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR); tex0->setWrap(osg::Texture::WRAP_S,osg::Texture::REPEAT); tex0->setWrap(osg::Texture::WRAP_T,osg::Texture::REPEAT); tex0->setImage( image0.get() ); // Attach the 2D texture attribute and enable GL_TEXTURE_2D, // both on texture unit 0. state->setTextureAttributeAndModes( 0, tex0.get() ); //включаем отсечение нелицевых граней osg::CullFace* cf = new osg::CullFace( osg::CullFace::BACK ); state->setAttributeAndModes( cf ); }
[ "asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b" ]
[ [ [ 1, 169 ] ] ]
263d6ec1197346ce6e2297b87ef5cb3950ccd04d
d76a67033e3abf492ff2f22d38fb80de804c4269
/src/opengl/ParticleSystem.cpp
dfe9eb1f9bb1a783440c13747d6e78ece4a9aba6
[ "Zlib" ]
permissive
truthwzl/lov8
869a6be317b7d963600f2f88edaefdf9b5996f2d
579163941593bae481212148041e0db78270c21d
refs/heads/master
2021-01-10T01:58:59.103256
2009-12-16T16:00:09
2009-12-16T16:00:09
36,340,451
0
0
null
null
null
null
UTF-8
C++
false
false
9,967
cpp
#include "ParticleSystem.h" #include <SDL_opengl.h> #include <cmath> namespace love_opengl { float calculate_variation(float inner, float outer, float var) { float low = inner - (outer/2.0f)*var; float high = inner + (outer/2.0f)*var; float r = (rand() / (float(RAND_MAX)+1)); return low*(1-r)+high*r; } ParticleSystem::ParticleSystem(pImage sprite, unsigned int buffer) : pStart(0), pLast(0), pEnd(0), active(true), emissionRate(0), emitCounter(0), lifetime(-1), life(0), particleLifeMin(0), particleLifeMax(0), direction(0), spread(0), relative(false), speedMin(0), speedMax(0), gravityMin(0), gravityMax(0), radialAccelerationMin(0), radialAccelerationMax(0), tangentialAccelerationMin(0), tangentialAccelerationMax(0), sizeStart(1), sizeEnd(1), sizeVariation(0), rotationMin(0), rotationMax(0), spinStart(0), spinEnd(0), spinVariation(0) { this->sprite = sprite; colorStart.reset(new Color(255,255,255,255)); colorEnd.reset(new Color(255,255,255,255)); setBufferSize(buffer); } ParticleSystem::~ParticleSystem() { if(pStart != 0) delete [] pStart; } void ParticleSystem::add() { if(isFull()) return; float min,max; min = particleLifeMin; max = particleLifeMax; if(min == max) pLast->life = min; else pLast->life = (rand() / (float(RAND_MAX)+1)) * (max - min) + min; pLast->lifetime = pLast->life; pLast->position[0] = position.getX(); pLast->position[1] = position.getY(); min = direction - spread/2.0f; max = direction + spread/2.0f; pLast->direction = (rand() / (float(RAND_MAX)+1)) * (max - min) + min; min = speedMin; max = speedMax; float speed = (rand() / (float(RAND_MAX)+1)) * (max - min) + min; pLast->speed = love::Vector(cos(pLast->direction), sin(pLast->direction)); pLast->speed *= speed; min = gravityMin; max = gravityMax; pLast->gravity = (rand() / (float(RAND_MAX)+1)) * (max - min) + min; min = radialAccelerationMin; max = radialAccelerationMax; pLast->radialAcceleration = (rand() / (float(RAND_MAX)+1)) * (max - min) + min; min = tangentialAccelerationMin; max = tangentialAccelerationMax; pLast->tangentialAcceleration = (rand() / (float(RAND_MAX)+1)) * (max - min) + min; pLast->sizeStart = calculate_variation(sizeStart, sizeEnd, sizeVariation); pLast->sizeEnd = calculate_variation(sizeEnd, sizeStart, sizeVariation); pLast->size = pLast->sizeStart; min = rotationMin; max = rotationMax; pLast->spinStart = calculate_variation(spinStart, spinEnd, spinVariation); pLast->spinEnd = calculate_variation(spinEnd, spinStart, spinVariation); pLast->rotation = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;; pLast->color[0] = (float)colorStart->getRed() / 255; pLast->color[1] = (float)colorStart->getGreen() / 255; pLast->color[2] = (float)colorStart->getBlue() / 255; pLast->color[3] = (float)colorStart->getAlpha() / 255; pLast++; } void ParticleSystem::remove(particle * p) { if(!isEmpty()) { *p = *(--pLast); } } void ParticleSystem::setSprite(pImage sprite) { this->sprite = sprite; } void ParticleSystem::setBufferSize(unsigned int size) { // delete previous data delete [] pStart; pLast = pStart = new particle[size]; pEnd = pStart + size; } void ParticleSystem::setEmissionRate(int rate) { emissionRate = rate; } void ParticleSystem::setLifetime(float life) { this->life = lifetime = life; } void ParticleSystem::setParticleLife(float min, float max) { particleLifeMin = min; if(max == 0) particleLifeMax = min; else particleLifeMax = max; } void ParticleSystem::setPosition(float x, float y) { position = love::Vector(x, y); } void ParticleSystem::setDirection(float direction) { this->direction = direction * LOVE_M_TORAD; } void ParticleSystem::setSpread(float spread) { this->spread = spread * LOVE_M_TORAD; } void ParticleSystem::setRelativeDirection(bool relative) { this->relative = relative; } void ParticleSystem::setSpeed(float speed) { speedMin = speedMax = speed; } void ParticleSystem::setSpeed(float min, float max) { speedMin = min; speedMax = max; } void ParticleSystem::setGravity(float gravity) { gravityMin = gravityMax = gravity; } void ParticleSystem::setGravity(float min, float max) { gravityMin = min; gravityMax = max; } void ParticleSystem::setRadialAcceleration(float acceleration) { radialAccelerationMin = radialAccelerationMax = acceleration; } void ParticleSystem::setRadialAcceleration(float min, float max) { radialAccelerationMin = min; radialAccelerationMax = max; } void ParticleSystem::setTangentialAcceleration(float acceleration) { tangentialAccelerationMin = tangentialAccelerationMax = acceleration; } void ParticleSystem::setTangentialAcceleration(float min, float max) { tangentialAccelerationMin = min; tangentialAccelerationMax = max; } void ParticleSystem::setSize(float size) { sizeStart = size; sizeEnd = size; } void ParticleSystem::setSize(float start, float end) { sizeStart = start; sizeEnd = end; } void ParticleSystem::setSize(float start, float end, float variation) { sizeStart = start; sizeEnd = end; sizeVariation = variation; } void ParticleSystem::setSizeVariation(float variation) { sizeVariation = variation; } void ParticleSystem::setRotation(float rotation) { rotationMin = rotationMax = rotation; } void ParticleSystem::setRotation(float min, float max) { rotationMin = min; rotationMax = max; } void ParticleSystem::setSpin(float spin) { spinStart = spin * LOVE_M_TORAD; spinEnd = spin * LOVE_M_TORAD; } void ParticleSystem::setSpin(float start, float end) { spinStart = start * LOVE_M_TORAD; spinEnd = end * LOVE_M_TORAD; } void ParticleSystem::setSpin(float start, float end, float variation) { spinStart = start * LOVE_M_TORAD; spinEnd = end * LOVE_M_TORAD; spinVariation = variation * LOVE_M_TORAD; } void ParticleSystem::setSpinVariation(float variation) { spinVariation = variation * LOVE_M_TORAD; } void ParticleSystem::setColor(pColor color) { colorStart = color; colorEnd = color; } void ParticleSystem::setColor(pColor start, pColor end) { colorStart = start; colorEnd = end; } float ParticleSystem::getX() const { return position.getX(); } float ParticleSystem::getY() const { return position.getY(); } float ParticleSystem::getDirection() const { return direction * LOVE_M_TODEG; } float ParticleSystem::getSpread() const { return spread * LOVE_M_TODEG; } int ParticleSystem::count() const { return (int)(pLast - pStart); } void ParticleSystem::start() { active = true; } void ParticleSystem::stop() { active = false; life = lifetime; emitCounter = 0; } void ParticleSystem::pause() { active = false; } void ParticleSystem::reset() { pLast = pStart; life = lifetime; emitCounter = 0; } bool ParticleSystem::isActive() const { return active; } bool ParticleSystem::isEmpty() const { return pStart == pLast; } bool ParticleSystem::isFull() const { return pLast == pEnd; } void ParticleSystem::draw(float x, float y) const { if(sprite == 0) return; // just in case of failure glPushMatrix(); glPushAttrib(GL_CURRENT_BIT); glTranslatef(x,y,0.0f); particle * p = pStart; while(p != pLast) { glPushMatrix(); glColor4f(p->color[0],p->color[1],p->color[2],p->color[3]); glTranslatef(p->position[0],p->position[1],0.0f); glRotatef(p->rotation * 57.29578f, 0.0f, 0.0f, 1.0f); // rad * (180 / pi) glScalef(p->size,p->size,1.0f); sprite->draw(0,0); glPopMatrix(); p++; } glPopAttrib(); glPopMatrix(); } void ParticleSystem::update(float dt) { // Traverse all particles and update. particle * p = pStart; // Make some more particles. if(active) { float rate = 1.0f / emissionRate; // the amount of time between each particle emit emitCounter += dt; while(emitCounter > rate) { add(); emitCounter -= rate; } /*int particles = (int)(emissionRate * dt); for(int i = 0; i != particles; i++) add();*/ life -= dt; if(lifetime != -1 && life < 0) stop(); } while(p != pLast) { // Decrease lifespan. p->life -= dt; if(p->life > 0) { // Temp variables. love::Vector radial, tangential, gravity(0, p->gravity); love::Vector ppos(p->position[0], p->position[1]); // Get vector from particle center to particle. radial = ppos - position; radial.normalize(); tangential = radial; // Resize radial acceleration. radial *= p->radialAcceleration; // Calculate tangential acceleration. { float a = tangential.getX(); tangential.setX(-tangential.getY()); tangential.setY(a); } // Resize tangential. tangential *= p->tangentialAcceleration; // Update position. p->speed += (radial+tangential+gravity)*dt; // Modify position. ppos += p->speed * dt; p->position[0] = ppos.getX(); p->position[1] = ppos.getY(); const float t = p->life / p->lifetime; // Change size. p->size = p->sizeEnd - ((p->sizeEnd - p->sizeStart) * t); // Rotate. p->rotation += (p->spinStart*(1-t) + p->spinEnd*t)*dt; // Update color. p->color[0] = (float)(colorEnd->getRed()*(1.0f-t) + colorStart->getRed() * t)/255.0f; p->color[1] = (float)(colorEnd->getGreen()*(1.0f-t) + colorStart->getGreen() * t)/255.0f; p->color[2] = (float)(colorEnd->getBlue()*(1.0f-t) + colorStart->getBlue() * t)/255.0f; p->color[3] = (float)(colorEnd->getAlpha()*(1.0f-t) + colorStart->getAlpha() * t)/255.0f; // Next particle. p++; } else { remove(p); if(p >= pLast) return; } // else } // while } }
[ "m4rvin2005@8b5f54a0-8722-11de-9e21-49812d2d8162" ]
[ [ [ 1, 453 ] ] ]
87b136ee386a6bae58240c9c9855351282ba0df6
ab41c2c63e554350ca5b93e41d7321ca127d8d3a
/glm/gtx/simd_vec4.hpp
daf7d4df02b5776373f9bdf088e386d8d03c09e5
[]
no_license
burner/e3rt
2dc3bac2b7face3b1606ee1430e7ecfd4523bf2e
775470cc9b912a8c1199dd1069d7e7d4fc997a52
refs/heads/master
2021-01-11T08:08:00.665300
2010-04-26T11:42:42
2010-04-26T11:42:42
337,021
3
0
null
null
null
null
UTF-8
C++
false
false
4,067
hpp
/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2009-05-07 // Updated : 2009-05-07 // Licence : This source is under MIT License // File : glm/gtx/simd_vec4.hpp /////////////////////////////////////////////////////////////////////////////////////////////////// // Dependency: // - GLM core // - intrinsic /////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef glm_gtx_simd_vec4 #define glm_gtx_simd_vec4 // Dependency: #include "../glm.hpp" #include "../core/intrinsic_common.hpp" namespace glm { namespace detail { GLM_ALIGN(4) struct fvec4SIMD { static __m128 one; union { __m128 Data; struct{float x, y, z, w;}; float array[4]; }; ////////////////////////////////////// // Implicit basic constructors fvec4SIMD(); fvec4SIMD(__m128 const & Data); fvec4SIMD(fvec4SIMD const & v); fvec4SIMD(tvec4<float> const & v); ////////////////////////////////////// // Explicit basic constructors fvec4SIMD(float const & s); fvec4SIMD(float const & x, float const & y, float const & z, float const & w); fvec4SIMD(float const v[4]); //////////////////////////////////////// //// Swizzle constructors //fvec4SIMD(ref4<float> const & r); //////////////////////////////////////// //// Convertion vector constructors fvec4SIMD(vec2 const & v, float const & s1, float const & s2); fvec4SIMD(float const & s1, vec2 const & v, float const & s2); fvec4SIMD(float const & s1, float const & s2, vec2 const & v); fvec4SIMD(vec3 const & v, float const & s); fvec4SIMD(float const & s, vec3 const & v); fvec4SIMD(vec2 const & v1, vec2 const & v2); //fvec4SIMD(ivec4SIMD const & v); ////////////////////////////////////// // Unary arithmetic operators fvec4SIMD& operator= (fvec4SIMD const & v); fvec4SIMD& operator+=(fvec4SIMD const & v); fvec4SIMD& operator-=(fvec4SIMD const & v); fvec4SIMD& operator*=(fvec4SIMD const & v); fvec4SIMD& operator/=(fvec4SIMD const & v); fvec4SIMD& operator+=(float const & s); fvec4SIMD& operator-=(float const & s); fvec4SIMD& operator*=(float const & s); fvec4SIMD& operator/=(float const & s); fvec4SIMD& operator++(); fvec4SIMD& operator--(); //////////////////////////////////////// //// Unary bit operators //fvec4SIMD& operator%= (float s); //fvec4SIMD& operator%= (fvec4SIMD const & v); //fvec4SIMD& operator&= (float s); //fvec4SIMD& operator&= (fvec4SIMD const & v); //fvec4SIMD& operator|= (float s); //fvec4SIMD& operator|= (fvec4SIMD const & v); //fvec4SIMD& operator^= (float s); //fvec4SIMD& operator^= (fvec4SIMD const & v); //fvec4SIMD& operator<<=(float s); //fvec4SIMD& operator<<=(fvec4SIMD const & v); //fvec4SIMD& operator>>=(float s); //fvec4SIMD& operator>>=(fvec4SIMD const & v); ////////////////////////////////////// // Swizzle operators //float swizzle(comp X) const; //vec2 const swizzle(comp X, comp Y) const; //vec3 const swizzle(comp X, comp Y, comp Z) const; //fvec4SIMD const swizzle(comp X, comp Y, comp Z, comp W) const; //fvec4SIMD const swizzle(int X, int Y, int Z, int W) const; //ref4<float> swizzle(comp X, comp Y, comp Z, comp W); }; }//namespace detail namespace gtx{ //! GLM_GTX_simd_vec4 extension: SIMD implementation of vec4 type. namespace simd_vec4 { typedef detail::fvec4SIMD vec4SIMD; }//namespace simd_vec4 }//namespace gtx }//namespace glm #define GLM_GTX_simd_vec4 namespace gtx::simd_vec4; #ifndef GLM_GTX_GLOBAL namespace glm {using GLM_GTX_simd_vec4;} #endif//GLM_GTX_GLOBAL #include "simd_vec4.inl" #endif//glm_gtx_simd_vec4
[ [ [ 1, 130 ] ] ]
c179e6c76dd804819822873b9d348b841bde2c8b
e09dfcc817c731587fd756f7611aacb19b17018a
/FilterLog/inc/InPlaceEdit.h
b59a7edf6e6eb6ebdc62f0f49fba9dd094f2d1a6
[]
no_license
jweitzen/analogqct
cb77f50f2682ee46325cafd738fcf1299d2710aa
535bcf32fd615815d640b06c860cfec9acb7f983
refs/heads/master
2021-01-10T09:31:14.808743
2009-06-12T16:46:03
2009-06-12T16:46:03
50,674,838
0
0
null
null
null
null
UTF-8
C++
false
false
1,516
h
#if !defined(AFX_INPLACEEDIT_H__2E647CAD_7E7D_40B4_99EA_D0048C9D55F7__INCLUDED_) #define AFX_INPLACEEDIT_H__2E647CAD_7E7D_40B4_99EA_D0048C9D55F7__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // InPlaceEdit.h : header file // ///////////////////////////////////////////////////////////////////////////// // CInPlaceEdit window class CInPlaceEdit : public CEdit { // Construction public: CInPlaceEdit(int iItem, int iSubItem, CString sInitText); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CInPlaceEdit) public: virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL // Implementation public: virtual ~CInPlaceEdit(); // Generated message map functions protected: //{{AFX_MSG(CInPlaceEdit) afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnNcDestroy(); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: int m_iItem; int m_iSubItem; CString m_sInitText; BOOL m_bESC; // To indicate whether ESC key was pressed }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_INPLACEEDIT_H__2E647CAD_7E7D_40B4_99EA_D0048C9D55F7__INCLUDED_)
[ "giulio.inbox@6d061dfa-575b-11de-9a1b-6103e4980ab8" ]
[ [ [ 1, 58 ] ] ]
8a1427e61cf03a2be2dfdc0645344b89331af600
5fb9b06a4bf002fc851502717a020362b7d9d042
/developertools/GumpEditor/GumpControlTypeDlg.h
1723e9630a9c7fbfa48d8215c88fc6b698ba2471
[]
no_license
bravesoftdz/iris-svn
8f30b28773cf55ecf8951b982370854536d78870
c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4
refs/heads/master
2021-12-05T18:32:54.525624
2006-08-21T13:10:54
2006-08-21T13:10:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
553
h
#pragma once //#include "afxwin.h" #include "entity/gumpentityfactory.h" class CGumpControlTypeDlg : public CDialog { DECLARE_DYNAMIC(CGumpControlTypeDlg) public: CGumpControlTypeDlg(CWnd* pParent = NULL); virtual ~CGumpControlTypeDlg(); enum { IDD = IDD_CTRL_TYPE_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); DECLARE_MESSAGE_MAP() public: CGumpEntityFactory::TYPE GetControlType(); CListBox m_lbControl; virtual BOOL OnInitDialog(); int m_iCtrlType; const int m_iStartCtrlType; };
[ "sience@a725d9c3-d2eb-0310-b856-fa980ef11a19" ]
[ [ [ 1, 26 ] ] ]
49ed4894c28fced39672aee9ed5857076b924ef7
d397b0d420dffcf45713596f5e3db269b0652dee
/src/Lib/PropertySystem/Visitor.hpp
204d0b364f4c76e98bacd60ab1c764b5825200d2
[]
no_license
irov/Axe
62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f
d3de329512a4251470cbc11264ed3868d9261d22
refs/heads/master
2021-01-22T20:35:54.710866
2010-09-15T14:36:43
2010-09-15T14:36:43
85,337,070
0
0
null
null
null
null
UTF-8
C++
false
false
469
hpp
# pragma once namespace AxeProperty { template<class T> class Numeric; class Visitor { public: virtual void process( class Numeric<bool> * _type ) = 0; virtual void process( class Numeric<int> * _type ) = 0; virtual void process( class Numeric<float> * _type ) = 0; virtual void process( class Numeric<double> * _type ) = 0; virtual void process( class String * _type ) = 0; virtual void process( class Array * _type ) = 0; }; }
[ "yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0" ]
[ [ [ 1, 19 ] ] ]
c7e0f738aaef9747f14a178e45a8076c2534a5c5
3eae1d8c99d08bca129aceb7c2269bd70e106ff0
/trunk/Codes/DeviceCode/Targets/OS/sh_os/DeviceCode/sh2/hwsetup.cpp
bb0466c08d6d9ae5d5dbd42a5f5d9d2c966ecad5
[]
no_license
yuaom/miniclr
9bfd263e96b0d418f6f6ba08cfe4c7e2a8854082
4d41d3d5fb0feb572f28cf71e0ba02acb9b95dc1
refs/heads/master
2023-06-07T09:10:33.703929
2010-12-27T14:41:18
2010-12-27T14:41:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,584
cpp
/***********************************************************************/ /* */ /* FILE :hwsetup.cpp */ /* DATE :Wed, Apr 08, 2009 */ /* DESCRIPTION :Hardware Setup file */ /* CPU TYPE :SH7011 */ /* */ /* This file is generated by Renesas Project Generator (Ver.4.9). */ /* */ /***********************************************************************/ #include "iodefine.h" #ifdef __cplusplus extern "C" { #endif extern void HardwareSetup(void); #ifdef __cplusplus } #endif void HardwareSetup(void) { /* SCI.SMR.BYTE = 0; SCI.SMR.BIT.CA = 1; SCI.SMR.BIT.CHR = 1; SCI.SMR.BIT.OE = 1; SCI.SMR.BIT.STOP = 1; SCI.SMR.BIT.MP = 1; SCI.SMR.BIT.CKS = 3; SCI.BRR = 0; SCI.SCR.BYTE = 0; SCI.SCR.BIT.TIE = 1; SCI.SCR.BIT.RIE = 1; SCI.SCR.BIT.TE = 1; SCI.SCR.BIT.RE = 1; SCI.SCR.BIT.MPIE = 1; SCI.SCR.BIT.TEIE = 1; SCI.SCR.BIT.CKE = 3; SCI.TDR = 0; SCI.SSR.BYTE = 0; SCI.SSR.BIT.TDRE = 1; SCI.SSR.BIT.RDRF = 1; SCI.SSR.BIT.ORER = 1; SCI.SSR.BIT.FER = 1; SCI.SSR.BIT.PER = 1; SCI.SSR.BIT.TEND = 1; SCI.SSR.BIT.MPB = 1; SCI.SSR.BIT.MPBT = 1; SCI.RDR = 0; */ }
[ [ [ 1, 55 ] ] ]
4df826255a4cc8bea83cf42b84b61a826d66e4b8
5fb9b06a4bf002fc851502717a020362b7d9d042
/developertools/GumpEditor-0.32/diagram/DialogEditorDemoDoc.h
5579c67f53a0b2d1a7cff6f7bc46693f339b908b
[]
no_license
bravesoftdz/iris-svn
8f30b28773cf55ecf8951b982370854536d78870
c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4
refs/heads/master
2021-12-05T18:32:54.525624
2006-08-21T13:10:54
2006-08-21T13:10:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,914
h
// DialogEditorDemoDoc.h : interface of the CDialogEditorDemoDoc class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_DIALOGEDITORDEMODOC_H__123376D9_1F69_4731_8BA4_50D6E0449623__INCLUDED_) #define AFX_DIALOGEDITORDEMODOC_H__123376D9_1F69_4731_8BA4_50D6E0449623__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // --- DiagramEditor --- #include "DiagramEditor\DiagramEntityContainer.h" class CDialogEditorDemoDoc : public CDocument { protected: // create from serialization only CDialogEditorDemoDoc(); DECLARE_DYNCREATE(CDialogEditorDemoDoc) // Attributes public: // --- DiagramEditor --- CDiagramEntityContainer* GetData(); // Operations public: // --- DiagramEditor --- void Export(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDialogEditorDemoDoc) public: virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar); protected: virtual BOOL SaveModified(); //}}AFX_VIRTUAL // Implementation public: virtual ~CDialogEditorDemoDoc(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CDialogEditorDemoDoc) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() // --- DiagramEditor --- protected: CDiagramEntityContainer m_objs; // The object data }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DIALOGEDITORDEMODOC_H__123376D9_1F69_4731_8BA4_50D6E0449623__INCLUDED_)
[ "sience@a725d9c3-d2eb-0310-b856-fa980ef11a19" ]
[ [ [ 1, 72 ] ] ]