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
1a9b4d6fe8ddce0acab83b96f71f4d9290f3b1f4
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestlist/src/bctestlistsettingcase.cpp
9a97ceea05c5f2197df6ed564c4244b403dbad51
[]
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
11,595
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: test case for setting list box classes * */ #include <aknlists.h> #include "bctestlistsettingcase.h" #include "bctestlistcontainer.h" #include "bctestlist.hrh" #include <bctestlist.rsg> #include <bctestlist.mbg> _LIT( KSettingCreate1, "Create CAknSettingStyleListBox" ); _LIT( KSettingCreate2, "Create CAknSettingNumberStyleListBox" ); _LIT( KSettingTest1, "CAknSettingStyleListBox::SizeChanged" ); _LIT( KSettingTest2, "CAknSettingStyleListBox::MinimumSize" ); _LIT( KSettingTest3, "CAknSettingStyleListBox::HandlePointerEventL" ); _LIT( KSettingItemDrawer, "CSettingsListBoxItemDrawer::DrawText" ); _LIT( KSettingNumberTest1, "CAknSettingNumberStyleListBox::SizeChanged" ); _LIT( KSettingNumberTest2, "CAknSettingNumberStyleListBox::MinimumSize" ); _LIT( KSettingNumberTest3, "CAknSettingNumberStyleListBox::HandlePointerEventL" ); // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- // Symbian 2nd static Constructor // --------------------------------------------------------------------------- // CBCTestListSettingCase* CBCTestListSettingCase::NewL( CBCTestListContainer* aContainer, CEikonEnv* aEikEnv ) { CBCTestListSettingCase* self = new( ELeave ) CBCTestListSettingCase( aContainer, aEikEnv ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); return self; } // --------------------------------------------------------------------------- // C++ default constructor // --------------------------------------------------------------------------- // CBCTestListSettingCase::CBCTestListSettingCase( CBCTestListContainer* aContainer, CEikonEnv* aEikEnv ) : CBCTestListBaseCase( aContainer, aEikEnv ) { } // --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // CBCTestListSettingCase::~CBCTestListSettingCase() { } // --------------------------------------------------------------------------- // Symbian 2nd Constructor // --------------------------------------------------------------------------- // void CBCTestListSettingCase::ConstructL() { BuildScriptL(); } // --------------------------------------------------------------------------- // CBCTestListSettingCase::BuildScriptL // --------------------------------------------------------------------------- // void CBCTestListSettingCase::BuildScriptL() { for ( TInt i=0; i <= EBCTestCmdOutline25 - EBCTestCmdOutline23; i++ ) { AddTestL( LeftCBA, REP( Down, 2 ), KeyOK, TEND ); AddTestL( REP( Down, i ), KeyOK, TEND ); } } // --------------------------------------------------------------------------- // CBCTestListSettingCase::RunL // --------------------------------------------------------------------------- // void CBCTestListSettingCase::RunL( TInt aCmd ) { if ( aCmd < EBCTestCmdOutline23 || aCmd > EBCTestCmdOutline25 ) { return; } iOutlineId = aCmd; ReleaseCase(); PrepareCaseL( aCmd ); TestSettingListL( aCmd ); } // --------------------------------------------------------------------------- // CBCTestListSettingCase::PrepareCaseL // --------------------------------------------------------------------------- // void CBCTestListSettingCase::PrepareCaseL( TInt aCmd ) { TInt resourceId( KBCTestListInitListResourceId ); TBool useGraphics( EFalse ); switch ( aCmd ) { case EBCTestCmdOutline23: resourceId = R_BCTESTLIST_SETTING_ADD_RM; useGraphics = ETrue; iListBox = new( ELeave ) CAknSettingStyleListBox(); AssertNotNullL( iListBox, KSettingCreate1 ); break; case EBCTestCmdOutline24: resourceId = R_BCTESTLIST_SETTING_NUMBER; useGraphics = ETrue; iListBox = new( ELeave ) CAknSettingNumberStyleListBox(); AssertNotNullL( iListBox, KSettingCreate2 ); break; default: break; } if ( iListBox ) { if ( resourceId != 0 ) { SetListBoxFromResourceL( iListBox, resourceId ); } else { SetListBoxFromInnerDescriptionL( iListBox ); } if ( useGraphics ) { SetGraphicIconL( iListBox ); } iContainer->SetControl( iListBox ); } } // --------------------------------------------------------------------------- // CBCTestListSettingCase::ReleaseCase // --------------------------------------------------------------------------- // void CBCTestListSettingCase::ReleaseCase() { iContainer->ResetControl(); iListBox = NULL; } // --------------------------------------------------------------------------- // CBCTestListSettingCase::TestSettingListL // --------------------------------------------------------------------------- // void CBCTestListSettingCase::TestSettingListL( TInt aCmd ) { if ( !iListBox && aCmd != EBCTestCmdOutline25 ) { return; } TPointerEvent event; event.iType = TPointerEvent::EButton1Down; event.iModifiers = 0; TPoint eventPos(0, 30); event.iPosition = eventPos; event.iParentPosition = eventPos; TSize size; switch ( aCmd ) { case EBCTestCmdOutline23: { CAknSettingStyleListBox* listbox = static_cast<CAknSettingStyleListBox*>( iListBox ); listbox->SizeChanged(); AssertTrueL( ETrue, KSettingTest1 ); size = listbox->MinimumSize(); AssertTrueL( ETrue, KSettingTest2 ); listbox->HandlePointerEventL( event ); AssertTrueL( ETrue, KSettingTest3 ); CSettingsListBoxItemDrawer* itemDrawer = listbox->ItemDrawer(); TRect rect( TPoint( 0, 0 ), TSize( 50, 30 ) ); itemDrawer->CSettingsListBoxItemDrawer::DrawItemText( 0, rect, ETrue, EFalse, EFalse ); AssertTrueL( ETrue, KSettingItemDrawer ); } break; case EBCTestCmdOutline24: { CAknSettingNumberStyleListBox* listbox = static_cast<CAknSettingNumberStyleListBox*>( iListBox ); listbox->SizeChanged(); AssertTrueL( ETrue, KSettingNumberTest1 ); size = listbox->MinimumSize(); AssertTrueL( ETrue, KSettingNumberTest2 ); listbox->HandlePointerEventL( event ); AssertTrueL( ETrue, KSettingNumberTest3 ); } break; case EBCTestCmdOutline25: { _LIT( KItemText, "Item1" ); TBuf<20> temp( KItemText ); CSelectableItem* item = new( ELeave ) CSelectableItem( temp, EFalse ); CleanupStack::PushL( item ); item->ConstructL(); CSelectionItemList* itemList = new( ELeave ) CSelectionItemList( 1 ); CleanupStack::PushL( itemList ); itemList->AppendL( item ); CBCTestCheckSettingPage* settingPage = new( ELeave ) CBCTestCheckSettingPage( R_BCTESTLIST_CHECKBOX_SETTING_PAGE, itemList ); CleanupStack::PushL( settingPage ); settingPage->ConstructL(); settingPage->CAknListBoxSettingPage::CheckAndSetDataValidity(); _LIT( KSettingPage1, "CAknListBoxSettingPage::CheckAndSetDataValidity" ); AssertTrueL( ETrue, KSettingPage1 ); settingPage->CAknListBoxSettingPage::SizeChanged(); _LIT( KSettingPage2, "CAknListBoxSettingPage::SizeChanged" ); AssertTrueL( ETrue, KSettingPage2 ); settingPage->CAknListBoxSettingPage::UpdateCbaL(); _LIT( KSettingPage3, "CAknListBoxSettingPage::UpdateCbaL" ); AssertTrueL( ETrue, KSettingPage3 ); settingPage->CAknListBoxSettingPage::HandleListBoxEventL( settingPage->ListBoxControl(), MEikListBoxObserver::EEventItemClicked ); _LIT( KSettingPage4, "CAknListBoxSettingPage::HandleListBoxEventL" ); AssertTrueL( ETrue, KSettingPage4 ); iContainer->ActivateGc(); settingPage->CAknListBoxSettingPage::Draw( iContainer->Rect() ); _LIT( KSettingPage5, "CAknListBoxSettingPage::Draw" ); AssertTrueL( ETrue, KSettingPage5 ); iContainer->DeactivateGc(); CleanupStack::PopAndDestroy( settingPage ); CleanupStack::PopAndDestroy( itemList ); CleanupStack::PopAndDestroy( item ); } break; default: break; } } // --------------------------------------------------------------------------- // CBCTestListSettingCase::GraphicIconL // --------------------------------------------------------------------------- // void CBCTestListSettingCase::GraphicIconL( CArrayPtr<CGulIcon>* aIcons ) { if ( aIcons ) { // Appends icon according to iOutlineId. switch ( iOutlineId ) { case EBCTestCmdOutline23: case EBCTestCmdOutline24: CreateIconAndAddToArrayL( aIcons, KBCTestListMifFileName, EMbmBctestlistQgn_indi_marked_add, EMbmBctestlistQgn_indi_marked_add_mask ); CreateIconAndAddToArrayL( aIcons, KBCTestListMbmFileName, EMbmBctestlistGolgo2, EMbmBctestlistGolgo2_mask ); break; default: break; } } } // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- // C++ constructor // --------------------------------------------------------------------------- // CBCTestCheckSettingPage::CBCTestCheckSettingPage( TInt aResourceId, CSelectionItemList* aItemArray ) : CAknCheckBoxSettingPage( aResourceId, aItemArray ) { }
[ "none@none" ]
[ [ [ 1, 315 ] ] ]
b87c306d055fedc6a4249825792949851a62e8c6
a3d70ef949478e1957e3a548d8db0fddb9efc125
/各分块设定示例/dxrender动画/Graphics.h
4a31d304d423df3b2414f81d681a741b5f5e2955
[]
no_license
SakuraSinojun/ling
fc58afea7c4dfe536cbafa93c0c6e3a7612e5281
46907e5548008d7216543bdd5b9cc058421f4eb8
refs/heads/master
2021-01-23T06:54:30.049039
2011-01-16T12:23:24
2011-01-16T12:23:24
32,323,103
0
0
null
null
null
null
GB18030
C++
false
false
18,000
h
////////////////////////////////////////////////////////////////// // // name: graphics.h // func: 一套使用D3D的3D图形引擎 // SDK 版本为 Microsoft DirectX SDK (June 2008) // date: 2011.01.01 // lib : d3d9.lib,d3dx9.lib,winmm.lib,D3dxof.lib,DXGUID.LIB // /////////////////////////////////////////////////////////////////// #ifndef GRAPHICS_H_101225 #define GRAPHICS_H_101225 #include <d3dx9.h> extern unsigned char D3DRM_XTEMPLATES[]; #define D3DRM_XTEMPLATE_BYTES 3278 #define FILE_PATH_LENGTH 100 // 释放COM对象 #define ReleaseCOM(x) if(x) { x->Release(); x = NULL; } class CPosition; class CTexture; class CFont; class CLight; class CCamera; class CAnimation; class CObject; struct AnimationSet; class CGraphics { public: CGraphics(); ~CGraphics(); IDirect3DDevice9 *GetDevice() const {return m_pDevice;} ID3DXSprite *GetSprite() const {return m_pSprite;} DWORD GetWidth() const {return m_width;} DWORD GetHeight() const {return m_height;} DWORD GetBPP() const {return m_bpp;} HWND GetWnd() const {return m_hWnd;} BOOL Init(HWND hWnd, BOOL bWindow = TRUE, DWORD width = 0, DWORD height = 0, char bpp = 32); BOOL ShutDown(); BOOL Clear(DWORD color = 0, FLOAT zBuffer = 1.0f); BOOL ClearZBuffer(float zBuffer = 1.0f); BOOL ClearDisplay(DWORD color = 0); BOOL BeginScene(); BOOL EndScene(); BOOL Display(); // SetTransform BOOL SetPerspective(FLOAT fov, FLOAT aspect, FLOAT nz, FLOAT fz); BOOL SetWorldPos(const D3DXMATRIX &worldPos); BOOL SetWorldPos(CPosition &pos); BOOL SetCamera(CCamera &camera); // SetRenderState BOOL SetAmbientLight(BYTE red, BYTE green, BYTE blue); BOOL SetShadeMode(DWORD shadeMode = D3DSHADE_FLAT); BOOL SetFillMode(DWORD fillMode = D3DFILL_WIREFRAME); BOOL SetLignt(DWORD num, const CLight &light); BOOL EnableLight(DWORD num, BOOL bEnable = TRUE); BOOL EnableLighting(BOOL bEnable = TRUE); BOOL EnableZBuffer(BOOL bEnable = TRUE); BOOL EnableAlphaBlending(BOOL Enable = TRUE, DWORD srcValue = D3DBLEND_SRCALPHA, DWORD destValue = D3DBLEND_INVSRCALPHA); protected: char _GetFormatBPP(const D3DFORMAT &format); BOOL _CheckFormat(const D3DFORMAT &format, BOOL bWindow, BOOL bHAL); protected: HWND m_hWnd; IDirect3D9 *m_pD3D; IDirect3DDevice9 *m_pDevice; D3DDISPLAYMODE m_d3ddm; ID3DXSprite *m_pSprite; BOOL m_bWindow; BOOL m_bHAL; BOOL m_bZBuffer; DWORD m_width; DWORD m_height; char m_bpp; BYTE m_ambientRed; BYTE m_ambientGreen; BYTE m_ambientBlue; }; ////////////////////////////////////////////////////////////////////////////////////// // // 各种顶点类型 // ////////////////////////////////////////////////////////////////////////////////////// struct WireVertex { WireVertex(){} WireVertex(float x, float y, float z) { _x = x; _y = y; _z = z; } float _x, _y, _z; static const DWORD FVF; }; struct ColorVertex { ColorVertex(){} ColorVertex(float x, float y, float z, D3DCOLOR c) { _x = x; _y = y; _z = z; _color = c; } float _x, _y, _z; D3DCOLOR _color; static const DWORD FVF; }; struct NormalVertex { NormalVertex(){} NormalVertex(float x, float y, float z, float nx, float ny, float nz) { _x = x; _y = y; _z = z; _nx = nx; _ny = ny; _nz = nz; } float _x, _y, _z; float _nx, _ny, _nz; static const DWORD FVF; }; struct Vertex { Vertex(){} Vertex(float x, float y, float z, float nx, float ny, float nz, D3DCOLOR color) { _x = x; _y = y; _z = z; _nx = nx; _ny = ny; _nz = nz; _color = color; } float _x, _y, _z; float _nx, _ny, _nz; D3DCOLOR _color; static const DWORD FVF; }; struct TexVertex2D { TexVertex2D(){} TexVertex2D(float x, float y, float z, float rhw, float u, float v) { _x = x; _y = y; _z = z; _rhw = rhw; _u = u; _v = v; } float _x, _y, _z; // 2-D 坐标 z置1 float _rhw; // rhw float _u, _v; // 材质坐标 static const DWORD FVF; }; struct TexVertex3D { TexVertex3D(){} TexVertex3D(float x, float y, float z, float u, float v) { _x = x; _y = y; _z = z; _u = u; _v = v; } float _x, _y, _z; // 3D 坐标 float _u, _v; // 材质坐标 static const DWORD FVF; }; class CVertex { public: CVertex(); ~CVertex(); void *GetBufferPtr() const {return m_pBuffer;} DWORD GetVertexNum() const {return m_vertexNum;} DWORD GetVertexSize() const {return m_vertexSize;} DWORD GetFVF() const {return m_FVF;} BOOL CreateBuffer(CGraphics *pGraphics, DWORD vertexNum, DWORD faceNum, DWORD vectexSize, DWORD FVF); BOOL CreateIndex(CGraphics *pGraphics, DWORD indexNum, DWORD indexSize, D3DFORMAT format); BOOL Destroy(); void *LockBuffer(DWORD startVertex = 0, DWORD vertexNum = 0); void *LockIndex(DWORD startIndex = 0, DWORD indexNum = 0); BOOL UnlockBuffer(); BOOL UnlockIndex(); BOOL SetBuffer(DWORD startVertex, DWORD vertexNum, void *vertexList); BOOL SetIndex(DWORD startIndex, DWORD indexNum, void *indexList); BOOL Render(DWORD startVertex, UINT primitiveCount = 0, D3DPRIMITIVETYPE type = D3DPT_TRIANGLELIST, CTexture *pTexture = NULL); protected: CGraphics *m_pGraphics; IDirect3DVertexBuffer9 *m_pVB; IDirect3DIndexBuffer9 *m_pIB; void *m_pBuffer; void *m_pIndex; DWORD m_vertexNum; DWORD m_indexNum; DWORD m_vertexSize; DWORD m_indexSize; DWORD m_FVF; DWORD m_faceNum; }; class CTexture { public: CTexture(); ~CTexture(); IDirect3DTexture9 *GetTexture() const {return m_pTexture;} DWORD GetWidth() const {m_d3dsd.Width;} DWORD GetHeight() const {m_d3dsd.Height;} BOOL LoadFromFile(CGraphics *pGraphics, const char *fileName, DWORD colorKey = 0, D3DFORMAT format = D3DFMT_UNKNOWN); BOOL Destroy(); BOOL Blt(long destX, long destY, long srcX = 0, long srcY = 0, long width = 0, long height = 0, FLOAT xScale = 1.0f, FLOAT yScale = 1.0f, D3DCOLOR color = 0xFFFFFFFF); BOOL Rotate(float centerX, float centerY, FLOAT angle); BOOL Scale(float centerX, float centerY, FLOAT scaleX, FLOAT scaleY); BOOL Translation(float x, float y); protected: CGraphics *m_pGraphics; IDirect3DTexture9 *m_pTexture; D3DSURFACE_DESC m_d3dsd; BOOL m_bLoaded; }; class CFont { public: CFont(); ~CFont(); BOOL Create(CGraphics *pGraphics, INT height = 24, const char *fontName = NULL, BOOL bItalic = FALSE); void Destroy(); BOOL Print(const char *text, long xPos, long yPos, long width, long height, DWORD format = DT_CENTER | DT_VCENTER, D3DCOLOR color = 0xffffffff); private: ID3DXFont *m_pFont; }; class CLight { public: CLight(); ~CLight(); const D3DLIGHT9 *GetLight() const {return &m_light;} void SetType(D3DLIGHTTYPE type) {m_light.Type = type;} void SetRange(float range) {m_light.Range = range;} void SetFalloff(float falloff) {m_light.Falloff = falloff;} void SetTheta(float theta) {m_light.Theta = theta;} void SetPhi(float phi) {m_light.Phi = phi;} void SetAttenuation0(float attenuation) {m_light.Attenuation0 = attenuation;} void SetAttenuation1(float attenuation) {m_light.Attenuation1 = attenuation;} void SetAttenuation2(float attenuation) {m_light.Attenuation2 = attenuation;} void SetAmbientColor(BYTE red, BYTE green, BYTE blue); void SetDiffuseColor(BYTE red, BYTE green, BYTE blue); void SetSpecularColor(BYTE red, BYTE green, BYTE blue); void MoveTo(float xPos, float yPos, float zPos); void Move(float xPos, float yPos, float zPos); protected: D3DLIGHT9 m_light; }; class CPosition { public: CPosition(); ~CPosition(); const D3DXMATRIX &GetMatrix() {Update(); return m_matWorld;} void MoveTo(float xPos, float yPos, float zPos); void Move(float x, float y, float z); void RotateTo(float xRot, float yRot, float zRot); void Rotate(float x, float y, float z); void ScaleTo(float xRot, float yRot, float zRot); void Scale(float x, float y, float z); void Update(); protected: FLOAT m_xPos, m_yPos, m_zPos; FLOAT m_xScale, m_yScale, m_zScale; FLOAT m_xRot, m_yRot, m_zRot; D3DXMATRIX m_matWorld; D3DXMATRIX m_matScale; D3DXMATRIX m_matRotation; D3DXMATRIX m_matTranslation; }; class CCamera { public: CCamera(); ~CCamera(); float GetXRotation() const {return m_xRot;} float GetYRotation() const {return m_yRot;} float GetZRotation() const {return m_zRot;} float GetXPosition() const {return m_xPos;} float GetYPosition() const {return m_yPos;} float GetZPosition() const {return m_zPos;} const D3DXMATRIX &GetMatrix() {Update();return m_matView;} void SetLookAt(float xEye, float yEye, float zEye, float xAt, float yAt, float zAt); void MoveTo(float xPos, float yPos, float zPos); void Move(float x, float y, float z); void RotateTo(float xRot, float yRot, float zRot); void Rotate(float x, float y, float z); void Update(); protected: float m_xPos, m_yPos, m_zPos; float m_xRot, m_yRot, m_zRot; D3DXMATRIX m_matView; D3DXMATRIX m_matTranslation; D3DXMATRIX m_matRotation; }; // 网格容器 struct Mesh { Mesh() { _pName = NULL; _pDXMesh = NULL; _pDXSkinMesh = NULL; _pSkinInfo = NULL; _pBoneMatrices = NULL; _apFrameMatrices = NULL; _materialNum = 0; _pMaterials = NULL; _apTextures = NULL; _pNext = NULL; } ~Mesh() { if(NULL != _pName) { delete [] _pName; } if(NULL != _pMaterials) { delete [] _pMaterials; } if(NULL != _apFrameMatrices) { delete [] _apFrameMatrices; } if(NULL != _pBoneMatrices) { delete [] _pBoneMatrices; } ReleaseCOM(_pDXMesh); ReleaseCOM(_pDXSkinMesh); ReleaseCOM(_pSkinInfo); if(NULL != _apTextures) { for(DWORD i=0; i<_materialNum; i++) { ReleaseCOM(_apTextures[i]); } delete [] _apTextures; } delete _pNext; // Delete next mesh in list } char *_pName; ID3DXMesh *_pDXMesh; // 原始网格 ID3DXMesh *_pDXSkinMesh; // 用于绘制的网格 ID3DXSkinInfo *_pSkinInfo; // 网格信息 D3DXMATRIX *_pBoneMatrices; // 骨骼变换矩阵,这个最终的矩阵数组 D3DXMATRIX **_apFrameMatrices; // 帧矩阵数组,它起到一个中间层的作用,当用CAnimation和CMesh单独加载时,它用于关联两者 D3DMATERIAL9 *_pMaterials; // 材质数组 DWORD _materialNum; // 材质数量 IDirect3DTexture9 **_apTextures; // 纹理指针数组 Mesh *_pNext; // 关联一个mesh,构成列表 D3DXVECTOR3 _min; // 边界框 D3DXVECTOR3 _max; float _radius; // 边界球半径 }; struct Frame { Frame() { _pName = NULL; _pMesh = NULL; _pParent = NULL; _pSibling = NULL; _pChild = NULL; D3DXMatrixIdentity(&_matCombined); D3DXMatrixIdentity(&_matTransformed); D3DXMatrixIdentity(&_matOriginal); } ~Frame() { if(NULL != _pName) { delete _pName; } if(NULL != _pMesh) { delete _pMesh; } if(NULL != _pChild) { delete _pChild; } if(NULL != _pSibling) { delete _pSibling; } // parent不用释放,都包含在孩子里了 } char *_pName; // 这个暂时只有parent拥有 Mesh *_pMesh; // 这些矩阵是FRAME的精要 D3DXMATRIX _matCombined; // 合成矩阵,每一个骨骼最终的变换矩阵 D3DXMATRIX _matTransformed; // 当前变换矩阵 D3DXMATRIX _matOriginal; // 原始矩阵 // 二叉树 Frame *_pParent; Frame *_pSibling; Frame *_pChild; }; class CMesh { public: CMesh(); ~CMesh(); Frame *GetParentFrame() const {return m_pFrames;} Mesh *GetHeadMesh() const {return m_pMeshes;} Frame *GetFrame(const char *frameName); BOOL LoadXFile(CGraphics *pGraphics, const char *pFileName, const char *pTexturePath = ".\\"); void Destroy(); BOOL Render(CPosition *pos = NULL, BOOL bTransformed = TRUE); protected: Frame *_FindFrame(Frame *pFrame, const char *pFrameName); BOOL _UpdateMeshes(); void _UpdateFrames(Frame *pFrame, const D3DXMATRIX &mat, BOOL bTransformed = FALSE); void _AddMeshToFrame(Frame *pFrame, Mesh *pMesh); void _MapFramesToBones(Frame *pFrame); void _ResetFrame(Frame *pFrame); BOOL _ParseXFile(const char *fileName, const char *pTexturePath); void _ParseXFileData(ID3DXFileData *pDataObj, Frame *pFrame, const char *texturePath); void _DrawMeshes(CPosition *pos = NULL); protected: CGraphics *m_pGraphics; Mesh *m_pMeshes; // 顶级指针,这个指针存放着frame中的全部mash,因此不负责释放资源 Frame *m_pFrames; // 各种关联的骨架 DWORD m_frameNum; DWORD m_meshNum; D3DXVECTOR3 m_min; D3DXVECTOR3 m_max; float m_radius; }; // 以下是加载DX动画集需要的结构体 struct XFileRotateKey { DWORD _time; DWORD _floats; float _w; float _x; float _y; float _z; }; struct XFileScaleKey { DWORD _time; DWORD _floats; D3DXVECTOR3 _scale; }; struct XFilePositionKey { DWORD _time; DWORD _floats; D3DXVECTOR3 _pos; }; struct XFileMatrixKey { DWORD _time; DWORD _floats; D3DXMATRIX _matrix; }; struct RotateKey { DWORD _time; D3DXQUATERNION _quaternion; }; struct PositionKey { DWORD _time; D3DXVECTOR3 _pos; D3DXVECTOR3 _posInterpolation; }; struct ScaleKey { DWORD _time; D3DXVECTOR3 _scale; D3DXVECTOR3 _scaleInterpolation; }; struct MatrixKey { DWORD _time; D3DXMATRIX _matrix; D3DXMATRIX _matInterpolation; }; struct Animation { Animation() { _pName = NULL; _pFrame = NULL; _pFrameName = NULL; _pNext = NULL; _pRotateKeys = NULL; _pPositionKeys = NULL; _pScaleKeys = NULL; _pMatrixKeys = NULL; _bLoop = FALSE; _bLinear = FALSE; _rotateKeysNum = 0; _positionKeysNum = 0; _scaleKeysNum = 0; _matrixKeyNum = 0; } ~Animation() { if(NULL != _pName) { delete [] _pName; } if(NULL != _pFrameName) { delete [] _pFrameName; } if(NULL != _pRotateKeys) { delete [] _pRotateKeys; } if(NULL != _pPositionKeys) { delete [] _pPositionKeys; } if(NULL != _pScaleKeys) { delete [] _pScaleKeys; } if(NULL != _pMatrixKeys) { delete [] _pMatrixKeys; } if(NULL != _pNext) { delete _pNext; } } char *_pName; // 动画名,一般为空。 Animation *_pNext; // 链表 char *_pFrameName; // 此动画关联的帧名,用来关联帧 Frame *_pFrame; // 关联的帧,不负责释放 RotateKey *_pRotateKeys; DWORD _rotateKeysNum; PositionKey *_pPositionKeys; DWORD _positionKeysNum; ScaleKey *_pScaleKeys; DWORD _scaleKeysNum; MatrixKey *_pMatrixKeys; DWORD _matrixKeyNum; BOOL _bLoop; // 标记是否循环 BOOL _bLinear; }; struct AnimationSet { AnimationSet() { _pName = NULL; _pNext = NULL; _pAnim = NULL; _length = 0; } ~AnimationSet() { if(NULL != _pName) { delete [] _pName; } if(NULL != _pAnim) { delete _pAnim; } if(NULL != _pNext) { delete _pNext; } } char *_pName; AnimationSet *_pNext; Animation *_pAnim; DWORD _length; }; // 动画集的集合 class CAnimation { public: CAnimation(); ~CAnimation(); BOOL LoadXFile(const char *fileName, CMesh *pMapMesh = NULL); void Destroy(); BOOL SetLoop(const char *pAnimSetName, BOOL bLoop); BOOL SetCurAnimSet(const char *pAnimSetName, DWORD startTime); BOOL UpdateCurAnim(DWORD time, BOOL bSmooth); protected: void _ParseXFileData(ID3DXFileData *pDXData, AnimationSet *pParentSet, Animation *pCurAnim); BOOL _MapToMesh(CMesh *pMesh); void _UpdateAnimationSet(AnimationSet *pAnimSet, DWORD time, BOOL bSmooth); void _UpdateAnimation(Animation *pAnim, DWORD time, BOOL bSmooth); AnimationSet *_FindAnimSet(AnimationSet *pAnimSet, const char *pAnimName); protected: AnimationSet *m_pAnimSet; DWORD m_nAnim; AnimationSet *m_pCurAnimSet; // 临时存储,不用释放 DWORD m_animStartTime; }; class CObject { public: CObject(); ~CObject(); void Destroy(); void MoveTo(float xPos, float yPos, float zPos); void Move(float x, float y, float z); void RotateTo(float xRot, float yRot, float zRot); void Rotate(float x, float y, float z); void ScaleTo(float xRot, float yRot, float zRot); void Scale(float x, float y, float z); BOOL LoadXFile(CGraphics *pGraphics, const char *pFileName, const char *pTexturePath = ".\\"); BOOL SetAnimation(const char *pAnimName, DWORD startTime); BOOL SetLoop(const char *pAnimSetName, BOOL bLoop); BOOL Render(DWORD curTime = 0, BOOL bSmooth = TRUE); protected: CAnimation *m_pAnim; CMesh *m_pMesh; CPosition m_pos; }; #endif
[ "wangdi640@f09d58f5-735d-f1c9-472e-e8791f25bd30" ]
[ [ [ 1, 824 ] ] ]
295d04c5663d837fe99a79cc66c0997e4f55e660
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/source/storage/filewriter.h
6a1b406303907636c66a096131347bfc8c4fc3c4
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
1,238
h
/*! @file @brief 非同期ファイル書き込みクラス */ #ifndef maid2_storage_filewriter_h #define maid2_storage_filewriter_h #include"../config/define.h" #include"../config/typedef.h" #include"../auxiliary/globalpointer.h" #include"string.h" #include"storage.h" namespace Maid { class FileWriter : public GlobalPointer<Storage> { public: FileWriter(); virtual ~FileWriter(); void Create( const String& filename ); void Open( const String& filename ); void OpenAdd( const String& filename ); void Write( const void* pData, size_t size ); enum POSITION { POSITION_BEGIN, //!< ファイルの先頭から POSITION_END, //!< ファイルの終端から POSITION_CURRENT, //!< 現在の位置から }; void Seek( POSITION ePos, int Size ); void Close(); void Close( bool IsSync ); bool IsEmpty() const; bool IsExecuting() const; bool IsError() const; size_t GetSize() const; size_t GetPosition() const; private: void CreateObject(); void SendMessage( const SPSTORAGEMESSAGE& pMess ); private: SPSTORAGEOBJECT m_pObject; }; } #endif
[ [ [ 1, 58 ] ] ]
9c496d14134b36ec6727d594e301a0784171798d
a48646eddd0eec81c4be179511493cbaf22965b9
/project/mysip/src/timer/timer_var.inc
ea3511cac2ce5ab6cc11e2ce39492a0559dbcd3a
[]
no_license
lengue/tsip
0449f791a5cbe9e9fdaa1b4d7f1d1e28eff2f0ec
da8606bd7d865d4b4a389ec1594248a4044bc890
refs/heads/master
2021-01-10T08:40:32.925501
2010-06-05T12:44:10
2010-06-05T12:44:10
53,989,315
0
0
null
null
null
null
GB18030
C++
false
false
342
inc
/******************************************************************************* 功能 : TIMER模块全局变量声明 创建人 : 唐春平 创建日期: 2009.07.19 修改记录: *******************************************************************************/ extern TIMER_S *g_pstTimerCB; extern COMM_QUEUE_S g_stTimerQueue;
[ [ [ 1, 8 ] ] ]
ce61c5579c2f48ed8e534a18b4bf9c1bca7f08c0
8f816734df7cb71af9c009fa53eeb80a24687e63
/Model/src/MeshCoordinate.cpp
1aaa810b7304dd7a91ea5c0433b150c70a93abb5
[]
no_license
terepe/rpgskyengine
46a3a09a1f4d07acf1a04a1bcefff2a9aabebf56
fbe0ddc86440025d9670fc39fb7ca72afa223953
refs/heads/master
2021-01-23T13:18:32.028357
2011-06-01T13:35:16
2011-06-01T13:35:16
35,915,383
0
0
null
null
null
null
UTF-8
C++
false
false
8,908
cpp
#include "MeshCoordinate.h" #include "RenderSystem.h" #include "Intersect.h" CMeshCoordinate::CMeshCoordinate() { m_CoordLines[CLT_X].vBegin = Vec3D(0.75f,0,0); m_CoordLines[CLT_X].vEnd = Vec3D(0.2f,0,0); m_CoordLines[CLT_X_Y].vBegin = Vec3D(0.3f,0,0); m_CoordLines[CLT_X_Y].vEnd = Vec3D(0.3f,0.3f,0); m_CoordLines[CLT_X_Z].vBegin = Vec3D(0.3f,0,0); m_CoordLines[CLT_X_Z].vEnd = Vec3D(0.3f,0,0.3f); m_CoordLines[CLT_Y].vBegin = Vec3D(0,0.75f,0); m_CoordLines[CLT_Y].vEnd = Vec3D(0,0.2f,0); m_CoordLines[CLT_Y_X].vBegin = Vec3D(0,0.3f,0); m_CoordLines[CLT_Y_X].vEnd = Vec3D(0.3f,0.3f,0); m_CoordLines[CLT_Y_Z].vBegin = Vec3D(0,0.3f,0); m_CoordLines[CLT_Y_Z].vEnd = Vec3D(0,0.3f,0.3f); m_CoordLines[CLT_Z].vBegin = Vec3D(0,0,0.75f); m_CoordLines[CLT_Z].vEnd = Vec3D(0,0,0.2f); m_CoordLines[CLT_Z_X].vBegin = Vec3D(0,0,0.3f); m_CoordLines[CLT_Z_X].vEnd = Vec3D(0.3f,0,0.3f); m_CoordLines[CLT_Z_Y].vBegin = Vec3D(0,0,0.3f); m_CoordLines[CLT_Z_Y].vEnd = Vec3D(0,0.3f,0.3f); } CMeshCoordinate::~CMeshCoordinate() { } void CMeshCoordinate::init() { m_setSubMesh.resize(3); const size_t CIRCLE_LINE_COUNT=6; m_setSubMesh[0].addPos(Vec3D(1,0,0)); for(size_t i=0; i<CIRCLE_LINE_COUNT; ++i) { float fRadian = PI*i*2/CIRCLE_LINE_COUNT; Vec3D v(0.75f,sinf(fRadian)*0.05f,cosf(fRadian)*0.05f); m_setSubMesh[0].addPos(v); } m_setSubMesh[1].addPos(Vec3D(0,1,0)); for (size_t i=0; i<CIRCLE_LINE_COUNT; ++i) { float fRadian = PI*i*2/CIRCLE_LINE_COUNT; Vec3D v(cosf(fRadian)*0.05f,0.75f,sinf(fRadian)*0.05f); m_setSubMesh[1].addPos(v); } m_setSubMesh[2].addPos(Vec3D(0,0,1)); for (size_t i=0; i<CIRCLE_LINE_COUNT; ++i) { float fRadian = PI*i*2/CIRCLE_LINE_COUNT; Vec3D v(sinf(fRadian)*0.05f,cosf(fRadian)*0.05f,0.75f); m_setSubMesh[2].addPos(v); } // m_setSubMesh[0].addColor(0xFFFF0000); m_setSubMesh[1].addColor(0xFF00FF00); m_setSubMesh[2].addColor(0xFF0000FF); m_setSubMesh[0].addColor(0xFF880000); m_setSubMesh[1].addColor(0xFF008800); m_setSubMesh[2].addColor(0xFF000088); // for (size_t i=0;i<3;++i) { size_t start = 0;//i*(CIRCLE_LINE_COUNT+1); for (size_t j=0;j<CIRCLE_LINE_COUNT-1;++j) { VertexIndex vertexIndex; vertexIndex.c=0; vertexIndex.p=0+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); vertexIndex.p=1+j+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); vertexIndex.p=2+j+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); } { VertexIndex vertexIndex; vertexIndex.c=0; vertexIndex.p=0+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); vertexIndex.p=CIRCLE_LINE_COUNT+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); vertexIndex.p=1+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); } for (size_t j=0;j<CIRCLE_LINE_COUNT-2;++j) { VertexIndex vertexIndex; vertexIndex.c=1; vertexIndex.p=1+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); vertexIndex.p=2+j+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); vertexIndex.p=3+j+start; m_setSubMesh[i].m_setVertexIndex.push_back(vertexIndex); } } // CLodMesh::init(); } void CMeshCoordinate::setPos(const Vec3D& vPos) { m_vPos = vPos; } void CMeshCoordinate::setScale(float fScale) { m_fScale = fScale; } bool CMeshCoordinate::intersect(const Vec3D& vRayPos , const Vec3D& vRayDir,Vec3D& vCoord)const { Vec3D vNewRayPos = vRayPos; Vec3D vNewRayDir = vRayDir; transformRay(vNewRayPos,vNewRayDir,getWorldMatrix()); float fMin,fMax; float fR = 0.05f; if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_X].vBegin,m_CoordLines[CLT_X].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(1,0,0); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_X_Y].vBegin,m_CoordLines[CLT_X_Y].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(1,1,0); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_X_Z].vBegin,m_CoordLines[CLT_X_Z].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(1,0,1); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_Y].vBegin,m_CoordLines[CLT_Y].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(0,1,0); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_Y_X].vBegin,m_CoordLines[CLT_Y_X].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(1,1,0); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_Y_Z].vBegin,m_CoordLines[CLT_Y_Z].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(0,1,1); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_Z].vBegin,m_CoordLines[CLT_Z].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(0,0,1); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_Z_X].vBegin,m_CoordLines[CLT_Z_X].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(1,0,1); return true; } if(LineCapsuleIntersector(vNewRayPos,vNewRayDir,m_CoordLines[CLT_Z_Y].vBegin,m_CoordLines[CLT_Z_Y].vEnd,fR,fMin,fMax)>0) { vCoord = Vec3D(0,1,1); return true; } Vec3D vOut; int nSubID = -1; if (CLodMesh::intersect(vNewRayPos, vNewRayDir, vOut, nSubID)) { switch(nSubID) { case 0: vCoord = Vec3D(1,0,0); break; case 1: vCoord = Vec3D(0,1,0); break; case 2: vCoord = Vec3D(0,0,1); break; default: break; } return true; } return false; } //#include "TextRender.h" #include "Graphics.h" #define COORD_X_COLOR 0xFFFF0000 #define COORD_Y_COLOR 0xFF00FF00 #define COORD_Z_COLOR 0xFF0000FF #define COORD_SELECT_COLOR 0xFFFFFF00 #define COORD_PLANE_COLOR 0x44FFFF00 void CMeshCoordinate::render(const Vec3D& vCoordShow) { if (m_setSubMesh.empty()) { init(); } CRenderSystem& R = GetRenderSystem(); CGraphics& G=GetGraphics(); R.setWorldMatrix(getWorldMatrix()); if (R.prepareMaterial("Coordinate1")) { SetMeshSource(); draw(); G.DrawLine3D(m_CoordLines[CLT_X].vBegin,m_CoordLines[CLT_X].vEnd,vCoordShow.x>0?COORD_SELECT_COLOR:COORD_X_COLOR); G.DrawLine3D(m_CoordLines[CLT_X_Y].vBegin,m_CoordLines[CLT_X_Y].vEnd,(vCoordShow.x>0&&vCoordShow.y>0)?COORD_SELECT_COLOR:COORD_X_COLOR); G.DrawLine3D(m_CoordLines[CLT_X_Z].vBegin,m_CoordLines[CLT_X_Z].vEnd,(vCoordShow.x>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_X_COLOR); G.DrawLine3D(m_CoordLines[CLT_Y].vBegin,m_CoordLines[CLT_Y].vEnd,vCoordShow.y>0?COORD_SELECT_COLOR:COORD_Y_COLOR); G.DrawLine3D(m_CoordLines[CLT_Y_X].vBegin,m_CoordLines[CLT_Y_X].vEnd,(vCoordShow.x>0&&vCoordShow.y>0)?COORD_SELECT_COLOR:COORD_Y_COLOR); G.DrawLine3D(m_CoordLines[CLT_Y_Z].vBegin,m_CoordLines[CLT_Y_Z].vEnd,(vCoordShow.y>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_Y_COLOR); G.DrawLine3D(m_CoordLines[CLT_Z].vBegin,m_CoordLines[CLT_Z].vEnd,vCoordShow.z>0?COORD_SELECT_COLOR:COORD_Z_COLOR); G.DrawLine3D(m_CoordLines[CLT_Z_X].vBegin,m_CoordLines[CLT_Z_X].vEnd,(vCoordShow.x>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_Z_COLOR); G.DrawLine3D(m_CoordLines[CLT_Z_Y].vBegin,m_CoordLines[CLT_Z_Y].vEnd,(vCoordShow.y>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_Z_COLOR); R.finishMaterial(); } if (R.prepareMaterial("Coordinate2")) { if (vCoordShow.x>0&&vCoordShow.y>0) { // G.fillQuad(Vec3D(0,0,0),m_CoordLines[CLT_X_Y].vBegin,m_CoordLines[CLT_X_Y].vEnd,m_CoordLines[CLT_Y_X].vBegin,COORD_PLANE_COLOR); } if (vCoordShow.y>0&&vCoordShow.z>0) { // G.fillQuad(Vec3D(0,0,0),m_CoordLines[CLT_Y_Z].vBegin,m_CoordLines[CLT_Y_Z].vEnd,m_CoordLines[CLT_Z_Y].vBegin,COORD_PLANE_COLOR); } if (vCoordShow.z>0&&vCoordShow.x>0) { // G.fillQuad(Vec3D(0,0,0),m_CoordLines[CLT_Z_X].vBegin,m_CoordLines[CLT_Z_X].vEnd,m_CoordLines[CLT_X_Z].vBegin,COORD_PLANE_COLOR); } R.finishMaterial(); } R.SetBlendFunc(true); R.SetTextureColorOP(0,TBOP_MODULATE); R.SetTextureAlphaOP(0,TBOP_MODULATE); //int nFontHeight = GetTextRender().GetCharHeight(); //Pos2D posScreen; //R.world2Screen(getWorldMatrix()*Vec3D(1.0f,0.0f,0.0f),posScreen); //GetTextRender().drawText(L"X",posScreen.x,posScreen.y-nFontHeight,vCoordShow.x>0?COORD_SELECT_COLOR:COORD_X_COLOR); //R.world2Screen(getWorldMatrix()*Vec3D(0.0f,1.0f,0.0f),posScreen); //GetTextRender().drawText(L"Y",posScreen.x,posScreen.y-nFontHeight,vCoordShow.y>0?COORD_SELECT_COLOR:COORD_Y_COLOR); //R.world2Screen(getWorldMatrix()*Vec3D(0.0f,0.0f,1.0f),posScreen); //GetTextRender().drawText(L"Z",posScreen.x,posScreen.y-nFontHeight,vCoordShow.z>0?COORD_SELECT_COLOR:COORD_Z_COLOR); } Matrix CMeshCoordinate::getWorldMatrix()const { Matrix mTrans,mScale; mTrans.translation(m_vPos); mScale.scale(Vec3D(m_fScale,m_fScale,m_fScale)); return mTrans*mScale; }
[ "rpgsky.com@97dd8ffa-095c-11df-8772-5d79768f539e" ]
[ [ [ 1, 272 ] ] ]
1ad0caa6a3bb2f801ee796d115b208e4c5f56bd9
40e58042e635ea2a61a6216dc3e143fd3e14709c
/chopshop11/Robot.h
492fd0d7282ee01ba70f7834eb07ddebc19b6ccc
[]
no_license
chopshop-166/frc-2011
005bb7f0d02050a19bdb2eb33af145d5d2916a4d
7ef98f84e544a17855197f491fc9f80247698dd3
refs/heads/master
2016-09-05T10:59:54.976527
2011-10-20T22:50:17
2011-10-20T22:50:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,160
h
/******************************************************************************* * Project : Framework * File Name : Robot.h * Owner : Software Group (FIRST Chopshop Team 166) * Creation Date : January 18, 2010 * File Description : Header for base class used in entire robot *******************************************************************************/ /*----------------------------------------------------------------------------*/ /* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */ /*----------------------------------------------------------------------------*/ #pragma once #include "WPILib.h" #include "BaeUtilities.h" #include "Team166Task.h" #include "MemoryLog.h" #include "SimpleLog.h" #include "Proxy.h" #include "Defines.h" // Maximum dashboard buffer size #define DASHBOARD_BUFFER_MAX (21) // Robot166 wait time #define ROBOT_WAIT_TIME (0.5) /** * This is a demo program showing the use of the RobotBase class. * The SimpleRobot class is the base of a robot application that will automatically call your * Autonomous and OperatorControl methods at the right time as controlled by the switches on * the driver station or the field controls. */ class Robot : public SimpleRobot { private: DriverStationLCD *dsHandleLCD; // Driver Station display handle FrameworkLogger *mlHead; // Memory log head int maxLogId; // Max log file id static Robot* RobotHandle; // Singleton instance reference public: Robot(void); // Constructor void Autonomous(void); // Method called by WPI when we're in autonomous mode void OperatorControl(void); // Method called by WPI when we're in operator control mode void Disabled(void); // Method called by WPI when we're disabled static Robot *getInstance(void); // Get pointer to our Robot166 instance void RegisterLogger(FrameworkLogger *ml); // Register memory logger void DumpLoggers(); // Dump all logs int DriverStationDisplay (const char*, ...); // Display text on DS DriverStation *dsHandle; // Driver Station handle };
[ [ [ 1, 1 ], [ 4, 4 ], [ 6, 49 ], [ 51, 51 ] ], [ [ 2, 3 ], [ 5, 5 ], [ 50, 50 ] ] ]
cdcb02425d45ff8ae7c482c41cc99f7407a07399
fbd2deaa66c52fc8c38baa90dd8f662aabf1f0dd
/totalFirePower/ta demo/code/MiniMap.cpp
ef8287eaddfb77069ea3d6e1b77c7dddb1350e2c
[]
no_license
arlukin/dev
ea4f62f3a2f95e1bd451fb446409ab33e5c0d6e1
b71fa9e9d8953e33f25c2ae7e5b3c8e0defd18e0
refs/heads/master
2021-01-15T11:29:03.247836
2011-02-24T23:27:03
2011-02-24T23:27:03
1,408,455
2
1
null
null
null
null
UTF-8
C++
false
false
7,691
cpp
// MiniMap.cpp: implementation of the CMiniMap class. // ////////////////////////////////////////////////////////////////////// #pragma warning(disable:4786) #include "MiniMap.h" #include "mygl.h" #include "GL\glu.h" #include "globalstuff.h" #include "infoconsole.h" #include "irenderer.h" #include "tapalette.h" #include "reghandler.h" #include "timeprofiler.h" #include "camera.h" #include "readmap.h" #include "vertexarray.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMiniMap* minimap; CMiniMap::CMiniMap() : xpos(10), ypos(g.screeny-210), height(200), width(200) { show=!!regHandler.GetInt("DrawMap",1); //(*info)<<g.shared->RadarpicX<<g.shared->RadarpicX<<"\n"; int maxSize=g.mapx; if(g.mapy>maxSize) maxSize=g.mapy; width=(150*g.mapx)/maxSize; height=(150*g.mapy)/maxSize; ypos=g.screeny-height-10; unsigned char tex[16][16][4]; for(int y=0;y<16;++y){ float dy=y-7.5; for(int x=0;x<16;++x){ float dx=x-7.5; float dist=sqrt(dx*dx+dy*dy); if(dist<6 || dist>9){ tex[y][x][0]=255; tex[y][x][1]=255; tex[y][x][2]=255; } else { tex[y][x][0]=0; tex[y][x][1]=0; tex[y][x][2]=0; } if(dist<7){ tex[y][x][3]=255; } else { tex[y][x][3]=0; } } } glGenTextures(1, &unitBlip); glBindTexture(GL_TEXTURE_2D, unitBlip); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); gluBuild2DMipmaps(GL_TEXTURE_2D,4 ,16, 16, GL_RGBA, GL_UNSIGNED_BYTE, tex); } CMiniMap::~CMiniMap() { } void CMiniMap::Draw() { for(int a=0;a<500;++a){ if(g.shared->Markers[a].IsNew){ EhaMarker m; m.time=g.frameNum; m.x=g.shared->Markers[a].x; m.y=g.shared->Markers[a].y; markers.push_back(m); g.shared->Markers[a].IsNew=false; } else { break; } } while(!markers.empty() && markers.front().time<g.frameNum-100){ markers.pop_front(); } if(!show) return; #ifdef PROFILE_TIME LARGE_INTEGER start; QueryPerformanceCounter(&start); #endif glViewport(xpos,ypos,width,height); glLoadIdentity(); // Reset The Current Modelview Matrix glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix gluOrtho2D(0,1,0,1); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glColor4f(1,1,1,1); glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glBindTexture(GL_TEXTURE_2D, readmap->bigtex); glBegin(GL_QUADS); glTexCoord2f(0,1); glVertex2f(0,0); glTexCoord2f(0,0); glVertex2f(0,1); glTexCoord2f(1,0); glVertex2f(1,1); glTexCoord2f(1,1); glVertex2f(1,0); glEnd(); float XscaleFactor2=1.0/(g.mapx*SQUARE_SIZE); float YscaleFactor2=1.0/(g.mapy*SQUARE_SIZE); std::deque<EhaMarker>::iterator mi; glColor3f(1,0,0); for(mi=markers.begin();mi!=markers.end();++mi){ float size=(mi->time-g.frameNum+100)*10; if(size<32) size=32; float x=mi->x*XscaleFactor2; float y=1-mi->y*YscaleFactor2; size*=XscaleFactor2; glBegin(GL_LINE_STRIP); glVertex2f(x+size,y+size); glVertex2f(x-size,y+size); glVertex2f(x-size,y-size); glVertex2f(x+size,y-size); glVertex2f(x+size,y+size); glEnd(); } glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, unitBlip); static unsigned char c2p[]={227,212,80,235,108,219,208,93,130,67}; float size=0.2f/sqrt(width+height); float XscaleFactor=1/(65536.0)/(g.mapx*SQUARE_SIZE); float YscaleFactor=1/(65536.0)/(g.mapy*SQUARE_SIZE); for(int p=0;p<g.shared->numPlayers;++p){ CVertexArray* va=GetVertexArray(); va->Initialize(); int maxUsed=p * g.shared->maxUnits + g.shared->players[p].maxUsedUnit; glColor3ubv(palette[c2p[g.shared->players[p].color]]); for(int u=p*g.shared->maxUnits;u<maxUsed;++u){ if(g.shared->units[u].active && g.shared->units[u].name[0]!=0 && (!(g.shared->units[u].RecentDamage&16))){ Unit* curUnit=&g.shared->units[u]; float x=(float)curUnit->pos.x*XscaleFactor; float y=1-(float)curUnit->pos.y*YscaleFactor; va->AddVertex2DT(x-size,y-size,0,0); va->AddVertex2DT(x-size,y+size,0,1); va->AddVertex2DT(x+size,y+size,1,1); va->AddVertex2DT(x+size,y-size,1,0); } } va->DrawArray2DT(GL_QUADS); } glDisable(GL_TEXTURE_2D); left.clear(); //Add restraints for camera sides GetFrustumSide(camera.rightside); GetFrustumSide(camera.leftside); GetFrustumSide(camera.bottom); GetFrustumSide(camera.top); float3 forward=camera.forward; forward.y=0; forward.Normalize(); camera.pos+=forward*g.viewRange*0.9f; GetFrustumSide(forward); camera.pos-=forward*g.viewRange*0.9f; if(left.size()==5){ float v1=left[3].base*camera.forward.x; float v2=left[4].base*camera.forward.x; if(v1>v2 || forward.dot(camera.top)<0) left[3]=left[4]; left.pop_back(); } std::vector<fline>::iterator fli,fli2; for(fli=left.begin();fli!=left.end();fli++){ for(fli2=left.begin();fli2!=left.end();fli2++){ if(fli==fli2) continue; float colz=-(fli->base-fli2->base)/(fli->dir-fli2->dir); if(fli2->left*(fli->dir-fli2->dir)>0){ if(colz>fli->minz && colz<40096) fli->minz=colz; } else { if(colz<fli->maxz && colz>-10000) fli->maxz=colz; } } } glColor4f(1,1,1,0.5); glBegin(GL_LINES); for(fli=left.begin();fli!=left.end();fli++){ if(fli->minz<fli->maxz){ DrawInMap(float3(fli->base+fli->dir*fli->minz,0,fli->minz)); DrawInMap(float3(fli->base+fli->dir*fli->maxz,0,fli->maxz)); } } glEnd(); glBegin(GL_POINTS); glColor4f(1,1,1,1/*0.0002f*(width+height)*/); for(a=0;a<g.shared->numProjectiles;++a){ Projectile* p=&g.shared->projectiles[a]; float x=(float)p->pos.x*XscaleFactor; float y=1-(float)p->pos.y*YscaleFactor; glVertex2f(x,y); } glColor4f(1,0.3f,0.3f,1/*0.0002f*(width+height)*/); for(a=0;a<g.shared->numExplosions;++a){ Explosion *e=&g.shared->explosions[a]; float x=(float)e->pos.x*XscaleFactor; float y=1-(float)e->pos.y*YscaleFactor; glVertex2f(x,y); } glColor4f(0.3f,0.3f,0.3f,1/*0.0002f*(width+height)*/); for(a=0;a<g.shared->numSmoke;++a){ SmokeParticle* s=&g.shared->smoke[a]; float x=(float)s->subs[0].pos.x*XscaleFactor; float y=1-(float)s->subs[0].pos.y*YscaleFactor; glVertex2f(x,y); } glEnd(); glViewport(0,0,g.screenx,g.screeny); #ifdef PROFILE_TIME LARGE_INTEGER stop; QueryPerformanceCounter(&stop); profiler.AddTime("Minimap",stop.QuadPart - start.QuadPart); #endif } void CMiniMap::DrawInMap(float3 &pos) { glVertex2f(pos.x/(g.mapx*SQUARE_SIZE),1-pos.z/(g.mapy*SQUARE_SIZE)); } void CMiniMap::GetFrustumSide(float3& side) { fline temp; float3 up(0,1,0); float3 b=up.cross(side); //get vector for collision between frustum and horizontal plane if(fabs(b.z)<0.0001) b.z=0.00011f; if(fabs(b.z)>0.0001){ temp.dir=b.x/b.z; //set direction to that float3 c=b.cross(side); //get vector from camera to collision line float3 colpoint; //a point on the collision line if(side.y>0) colpoint=camera.pos-c*((camera.pos.y)/c.y); else colpoint=camera.pos-c*((camera.pos.y)/c.y); temp.base=colpoint.x-colpoint.z*temp.dir; //get intersection between colpoint and z axis temp.left=-1; if(b.z>0) temp.left=1; temp.maxz=g.mapy*SQUARE_SIZE; temp.minz=0; left.push_back(temp); } }
[ [ [ 1, 288 ] ] ]
fefd9ffed057529030978d00970134cb667580b2
48670a0bb52ca0a28575201b06efaa4fd3673be3
/RFIDCounter/AssemblyInfo.cpp
389d13ef3d3f1eea59d06e419781a2f6cdfa26e1
[]
no_license
dschraitle/rfid-counter
a0352b63cec4c2466f5950f7e23b7148176e0212
a2d9d3c7b4faa61edf591c3403e1b97b0a74832a
refs/heads/master
2020-04-25T04:37:29.389747
2009-11-16T19:15:33
2009-11-16T19:15:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,356
cpp
#include "stdafx.h" using namespace System; using namespace System::Reflection; using namespace System::Runtime::CompilerServices; using namespace System::Runtime::InteropServices; using namespace System::Security::Permissions; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly:AssemblyTitleAttribute("RFIDCounter")]; [assembly:AssemblyDescriptionAttribute("")]; [assembly:AssemblyConfigurationAttribute("")]; [assembly:AssemblyCompanyAttribute("Microsoft")]; [assembly:AssemblyProductAttribute("RFIDCounter")]; [assembly:AssemblyCopyrightAttribute("Copyright (c) Microsoft 2009")]; [assembly:AssemblyTrademarkAttribute("")]; [assembly:AssemblyCultureAttribute("")]; // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the value or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly:AssemblyVersionAttribute("1.0.*")]; [assembly:ComVisible(false)]; [assembly:CLSCompliantAttribute(true)]; [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
[ [ [ 1, 40 ] ] ]
924253d73a0f6c1159c2e7278f42e69277c5f5b0
bd89d3607e32d7ebb8898f5e2d3445d524010850
/adaptationlayer/dataport/dataport_csy/inc/dpdatabuffer.inl
4983bbd656d5b6af672943fbb76ed962526c5954
[]
no_license
wannaphong/symbian-incubation-projects.fcl-modemadaptation
9b9c61ba714ca8a786db01afda8f5a066420c0db
0e6894da14b3b096cffe0182cedecc9b6dac7b8d
refs/heads/master
2021-05-30T05:09:10.980036
2010-10-19T10:16:20
2010-10-19T10:16:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,021
inl
/* * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "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: * */ // --------------------------------------------------------- // CDpDataBuffer::ReadElement // This method gets the read element. // --------------------------------------------------------- // inline CDpDataElement& CDpDataBuffer::ReadElement() { return iRE; } // --------------------------------------------------------- // CDpDataBuffer::WriteElement // This method gets the write element. // --------------------------------------------------------- // inline CDpDataElement& CDpDataBuffer::WriteElement() { return iWE; } // --------------------------------------------------------- // CDpDataBuffer::Size // This method gets the size of the buffer. // --------------------------------------------------------- // inline TInt CDpDataBuffer::Size() { return( iBufSize-iMaxReservationSize ); } // --------------------------------------------------------- // CDpDataBuffer::MaxReservationSize // This method gets the maximum reservation size (MMRS) of // the buffer. // --------------------------------------------------------- // inline TInt CDpDataBuffer::MaxReservationSize() { return iMaxReservationSize; } // --------------------------------------------------------- // CDpDataBuffer::IsReaderWaiting // This method gets the status if the reader is waiting for // more data. // --------------------------------------------------------- // inline TBool CDpDataBuffer::IsReaderWaiting() { return iIsReaderWaiting; } // End of File
[ "dalarub@localhost" ]
[ [ [ 1, 72 ] ] ]
c11bd250e0114dd24468fa5a8d560441314a477c
2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4
/OUAN/OUAN/Src/Game/GameObject/GameObjectTotem.cpp
5ad433fd7734a7b0b4f7f4e6a41d86e8cb9450eb
[]
no_license
juanjmostazo/once-upon-a-night
9651dc4dcebef80f0475e2e61865193ad61edaaa
f8d5d3a62952c45093a94c8b073cbb70f8146a53
refs/heads/master
2020-05-28T05:45:17.386664
2010-10-06T12:49:50
2010-10-06T12:49:50
38,101,059
1
1
null
null
null
null
UTF-8
C++
false
false
6,416
cpp
#include "OUAN_Precompiled.h" #include "GameObjectTotem.h" #include "GameObjectPortal.h" #include "../GameWorldManager.h" #include "../../Audio/AudioComponent/AudioComponent.h" using namespace OUAN; GameObjectTotem::GameObjectTotem(const std::string& name) :GameObject(name,GAME_OBJECT_TYPE_TOTEM) { } GameObjectTotem::~GameObjectTotem() { } void GameObjectTotem::setRenderComponentEntity(RenderComponentEntityPtr pRenderComponentEntity) { mRenderComponentEntity=pRenderComponentEntity; } void GameObjectTotem::setDreamsRender() { if (!isEnabled()) return; mRenderComponentEntity->setDreamsMaterials(); } void GameObjectTotem::setNightmaresRender() { if (!isEnabled()) return; mRenderComponentEntity->setNightmaresMaterials(); } void GameObjectTotem::setChangeWorldRender() { if (!isEnabled()) return; mRenderComponentEntity->setVisible(true); mRenderComponentEntity->setChangeWorldMaterials(); } RenderComponentEntityPtr GameObjectTotem::getRenderComponentEntity() const { return mRenderComponentEntity; } void GameObjectTotem::setRenderComponentPositional(RenderComponentPositionalPtr pRenderComponentPositional) { mRenderComponentPositional=pRenderComponentPositional; } void GameObjectTotem::setRenderComponentInitial(RenderComponentInitialPtr pRenderComponentInitial) { mRenderComponentInitial=pRenderComponentInitial; } RenderComponentPositionalPtr GameObjectTotem::getRenderComponentPositional() const { return mRenderComponentPositional; } RenderComponentInitialPtr GameObjectTotem::getRenderComponentInitial() const { return mRenderComponentInitial; } void GameObjectTotem::setPhysicsComponentSimpleBox(PhysicsComponentSimpleBoxPtr pPhysicsComponentSimpleBox) { mPhysicsComponentSimpleBox=pPhysicsComponentSimpleBox; } PhysicsComponentSimpleBoxPtr GameObjectTotem::getPhysicsComponentSimpleBox() const { return mPhysicsComponentSimpleBox; } void GameObjectTotem::changeWorldFinished(int newWorld) { if (!isEnabled()) return; switch(newWorld) { case DREAMS: setDreamsRender(); break; case NIGHTMARES: setNightmaresRender(); break; default:break; } } void GameObjectTotem::update(double elapsedSeconds) { GameObject::update(elapsedSeconds); bool reachedLevel; reachedLevel=false; if(mPhysicsComponentSimpleBox.get() && mPhysicsComponentSimpleBox->isInUse()) { if(mLevelTarget<mPhysicsComponentSimpleBox->getSceneNode()->getPosition().y) { Ogre::Vector3 newPosition=mPhysicsComponentSimpleBox->getSceneNode()->getPosition(); newPosition.y=newPosition.y-elapsedSeconds*LEVEL_MOVEMENT_SPEED; if(newPosition.y<mLevelTarget) { newPosition.y=mLevelTarget; mAudioComponent->stopSound(TOTEM_SOUND_LEVEL_DOWN); reachedLevel=true; } Ogre::Vector3 positionDifference=newPosition-mPhysicsComponentSimpleBox->getSceneNode()->getPosition(); mPhysicsComponentSimpleBox->setPosition(newPosition); GameObjectPtr obj = getGameWorldManager()->getObject(CHANGE_WORLD_ATTACHED); GameObjectPortalPtr portal= BOOST_PTR_CAST(GameObjectPortal,obj); if(portal->getPhysicsComponentSimpleBox().get() && portal->getPhysicsComponentSimpleBox()->isInUse()) { portal->getPhysicsComponentSimpleBox()->setPosition( portal->getPhysicsComponentSimpleBox()->getSceneNode()->getPosition()+positionDifference ); } if(reachedLevel && mLevel==0) { if(mPhysicsComponentSimpleBox.get() && mPhysicsComponentSimpleBox->isInUse()) { mPhysicsComponentSimpleBox->destroy(); } mRenderComponentEntity->setVisible(false); disable(); if(getName().compare("totem#0")==0) { getGameWorldManager()->addExecutedLevelEvent(TRIPOLLO_PLATFORM_PUZZLE_END); } } } } } void GameObjectTotem::levelDown() { mLevelTarget=mLevelTarget-LEVEL_DISTANCE; mAudioComponent->playSound(TOTEM_SOUND_LEVEL_DOWN); mLevel--; } void GameObjectTotem::changeWorldStarted(int newWorld) { if (!isEnabled()) return; switch(newWorld) { case DREAMS: break; case NIGHTMARES: break; default: break; } } void GameObjectTotem::changeToWorld(int newWorld, double perc) { if (!isEnabled()) return; switch(newWorld) { case DREAMS: break; case NIGHTMARES: break; default: break; } } void GameObjectTotem::reset() { GameObject::reset(); if(getName().compare("totem#0")!=0 || !(getGameWorldManager()->hasExecutedLevelEvent(TRIPOLLO_PLATFORM_PUZZLE_END))) { if(mPhysicsComponentSimpleBox.get() && !mPhysicsComponentSimpleBox->isInUse()) { mPhysicsComponentSimpleBox->create(); } mRenderComponentEntity->setVisible(true); mLevel=NUM_LEVELS; mPhysicsComponentSimpleBox->setPosition(mRenderComponentInitial->getPosition()); mLevelTarget=mPhysicsComponentSimpleBox->getSceneNode()->getPosition().y; } } AudioComponentPtr GameObjectTotem::getAudioComponent() const { return mAudioComponent; } void GameObjectTotem::setAudioComponent(AudioComponentPtr audioComponent) { mAudioComponent=audioComponent; } bool GameObjectTotem::hasPositionalComponent() const { return true; } RenderComponentPositionalPtr GameObjectTotem::getPositionalComponent() const { return getRenderComponentPositional(); } /// Set logic component void GameObjectTotem::setLogicComponent(LogicComponentPtr logicComponent) { mLogicComponent=logicComponent; } /// return logic component LogicComponentPtr GameObjectTotem::getLogicComponent() { return mLogicComponent; } void GameObjectTotem::setChangeWorldFactor(double factor) { if (!isEnabled()) return; mRenderComponentEntity->setChangeWorldFactor(factor); } bool GameObjectTotem::hasRenderComponentEntity() const { return true; } RenderComponentEntityPtr GameObjectTotem::getEntityComponent() const { return mRenderComponentEntity; } bool GameObjectTotem::hasLogicComponent() const { return true; } LogicComponentPtr GameObjectTotem::getLogicComponent() const { return mLogicComponent; } //------------------------------------------------------------------------------------------- TGameObjectTotemParameters::TGameObjectTotemParameters() : TGameObjectParameters() { } TGameObjectTotemParameters::~TGameObjectTotemParameters() { }
[ "wyern1@1610d384-d83c-11de-a027-019ae363d039", "ithiliel@1610d384-d83c-11de-a027-019ae363d039" ]
[ [ [ 1, 256 ], [ 261, 261 ], [ 265, 275 ] ], [ [ 257, 260 ], [ 262, 264 ] ] ]
90ba3c7aa97fe5cfebcd765eea0629c1d3ff7889
ae395aec108ca518a46a867842b9b83c0c39f8a2
/cs2310/ICEditor/Gui/TreeLayout.h
d45218ade6bb0bcf2ba08ad6956100aa9ec8dee3
[]
no_license
coolboy/iceditor
df8d580f32f77e7b67e2f48e84d3957b1ad8959d
ff1c626ee4f7038a7479b52f32d2585779390f46
refs/heads/master
2020-06-04T19:22:34.229941
2011-01-01T21:24:41
2011-01-01T21:24:41
32,131,682
0
0
null
null
null
null
UTF-8
C++
false
false
432
h
#pragma once typedef QMap<int, int> Relations;//id parid class TreeLayout { public: TreeLayout(QRectF rec); ~TreeLayout(void); void setTree(const Relations& rels); QPointF getPos(int id); private://treeHelper int getDepth(int id, const Relations& rels, int dep); int getParentId(int id, const Relations& rels); private: QRectF rct_; typedef QVector<QVector<int> > TreeLevels; TreeLevels tls_; };
[ "angelucci.louis@8e7f2bb0-d97f-11de-8314-133c20781edd" ]
[ [ [ 1, 22 ] ] ]
6f22842444c055e4b11ef43765f2892193b8b456
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ClientShellDLL/ClientShellShared/RagDollNode.h
00a582910c93c37b47d79e96191141207006c157
[]
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
802
h
#ifndef __RAGDOLLNODE_H__ #define __RAGDOLLNODE_H__ class CRagDoll; class CRagDollNode { public: CRagDollNode() : m_hModelNode(INVALID_MODEL_NODE), m_pRagDoll(NULL), m_fBSphereRadius(0.0f), m_fWeight(1.0f) { } ~CRagDollNode() { } //the model node that this node corresponds to HMODELNODE m_hModelNode; //the previous and current position of this node LTVector m_vPosition[2]; //the radius of the bounding sphere (0 indicates don't perform collisions) float m_fBSphereRadius; //the parent model. I know this is a cyclic dependency, but it is opaque to the rag doll node //and is intended for use inside of the node controller CRagDoll* m_pRagDoll; //this is the weight of the node float m_fWeight; private: }; #endif
[ [ [ 1, 42 ] ] ]
e48f0b49a24c0323c52c785a43bad94af1c58ae9
36bf908bb8423598bda91bd63c4bcbc02db67a9d
/WallPaper/include/WallPaperDrawSettingsModeDlg.h
0e85b2c9a01cce286247fbd26c7ccbe1e1a093cf
[]
no_license
code4bones/crawlpaper
edbae18a8b099814a1eed5453607a2d66142b496
f218be1947a9791b2438b438362bc66c0a505f99
refs/heads/master
2021-01-10T13:11:23.176481
2011-04-14T11:04:17
2011-04-14T11:04:17
44,686,513
0
1
null
null
null
null
WINDOWS-1252
C++
false
false
6,159
h
/* WallPaperDrawSettingsModeDlg.h Dialogo per la pagina relativa alle opzioni per le miniature. Luca Piergentili, 20/09/01 [email protected] WallPaper (alias crawlpaper) - the hardcore of Windows desktop http://www.crawlpaper.com/ copyright © 1998-2004 Luca Piergentili, all rights reserved crawlpaper is a registered name, all rights reserved This is a free software, released under the terms of the BSD license. Do not attempt to use it in any form which violates the license or you will be persecuted and charged for this. 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 "crawlpaper" 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. */ #ifndef _WALLPAPERDRAWSETTINGSMODEDLG_H #define _WALLPAPERDRAWSETTINGSMODEDLG_H #include "window.h" #include "CImageFactory.h" #include "CImageParams.h" #include "CToolTipCtrlEx.h" #include "WallPaperConfig.h" #define IDS_DRAWOWNERMODE_ORIGINAL_SIZE "original size" #define IDS_DRAWOWNERMODE_FIT_TO_SCREEN "fit to screen" #define IDS_DRAWOWNERMODE_STRETCH_TO_SCREEN "stretch to screen" #define IDS_DRAWOWNERMODE_STRETCH_TO_SCREEN_IF_DOES_NOT_FIT "stretch to screen if does not fit" #define IDS_DRAWOWNERMODE_STRETCH_TO_RECT "stretch to rect..." #define IDS_DRAWOWNERMODE_TILE_STRETCH "tile/stretch..." #define IDS_DRAWOWNERMODE_TILE_FIT "tile/fit..." #define IDS_DRAWOWNERMODE_OVERLAP_STRETCH "overlap/stretch..." #define IDS_DRAWOWNERMODE_OVERLAP_FIT "overlap/fit..." #define IDS_DRAWOWNERMODE_TILE_STRETCH_TEXT "tile/stretch if the picture area if less/greater than the % of screen area" #define IDS_DRAWOWNERMODE_TILE_FIT_TEXT "tile/fit if the picture area if less/greater than the % of screen area" #define IDS_DRAWOWNERMODE_OVERLAP_STRETCH_TEXT "overlap/stretch if the picture area if less/greater than the % of screen area" #define IDS_DRAWOWNERMODE_OVERLAP_FIT_TEXT "overlap/fit if the picture area if less/greater than the % of screen area" #define IDS_DRAWWINDOWSMODE_NORMAL "normal" #define IDS_DRAWWINDOWSMODE_TILE "tile" #define IDS_DRAWWINDOWSMODE_STRETCH "stretch" #define IDS_DRAWEFFECT_NONE "<none>" #define IDS_DRAWEFFECT_GRAYSCALE "grayscale" #define IDS_DRAWEFFECT_ROTATE90LEFT "rotate 90 left" #define IDS_DRAWEFFECT_ROTATE90RIGHT "rotate 90 right" #define IDS_DRAWEFFECT_ROTATE180 "rotate 180" #define IDS_DRAWEFFECT_BLUR "blur" #define IDS_DRAWEFFECT_BRIGHTNESS "brightness" #define IDS_DRAWEFFECT_CONTRAST "contrast" #define IDS_DRAWEFFECT_EDGEENHANCE "edge enhance" #define IDS_DRAWEFFECT_EMBOSS "emboss" #define IDS_DRAWEFFECT_FINDEDGE "find edge" #define IDS_DRAWEFFECT_INVERT "invert" #define IDS_DRAWEFFECT_MIRRORH "mirror (horiz.)" #define IDS_DRAWEFFECT_MIRRORV "mirror (vert.)" #define IDS_DRAWEFFECT_SHARPEN "sharpen" #define IDS_DRAWEFFECT_RANDOM "random" #define MIN_EFFECT_VALUE 0 #define MAX_EFFECT_VALUE 100 /* CWallPaperDrawSettingsModeDlg */ class CWallPaperDrawSettingsModeDlg : public CPropertyPage { DECLARE_DYNCREATE(CWallPaperDrawSettingsModeDlg) public: CWallPaperDrawSettingsModeDlg() {} ~CWallPaperDrawSettingsModeDlg() {} BOOL CreateEx (CWnd* pParent,UINT nID,CWallPaperConfig* pConfig); void DoDataExchange (CDataExchange* pDX); BOOL OnInitDialog (void); BOOL OnSetActive (void) {return(TRUE);} void OnRadioButtonOwnerMode (void); void OnRadioButtonWindowsMode (void); void OnComboOwnerMode (void); void OnKillFocusComboOwnerMode (void) {OnComboOwnerMode();} void OnSelChangeComboOwnerMode (void) {OnComboOwnerMode();} void OnComboWindowsMode (void); void OnSelChangeComboWindowsMode (void) {OnComboWindowsMode();} void OnKillFocusComboWindowsMode (void) {OnComboWindowsMode();} void OnComboEffect (void); void OnKillFocusComboEffect (void) {OnComboEffect();} void OnSelChangeComboEffect (void) {OnComboEffect();} void OnEnChangeEffect (void); void OnVScroll (UINT nSBCode,UINT nPos,CScrollBar* pScrollBar); CToolTipCtrlEx m_Tooltip; CWallPaperConfig* m_pConfig; char m_szLibraryName[_MAX_PATH+1]; CImageFactory m_ImageFactory; CImage* m_pImage; CImageParams m_ImageParams; int m_nDrawMode; int m_nOwnerMode; int m_nWindowsMode; CComboBox m_wndComboOwnerMode; CComboBox m_wndComboWindowsMode; UINT m_nAreaRatio; UINT m_nWidth; UINT m_nHeight; UINT m_nScreenWidth; UINT m_nScreenHeight; UINT m_nMinWidth; UINT m_nMinHeight; int m_nDrawEffect; int m_nDrawEffectValue; CComboBox m_wndComboEffect; DECLARE_MESSAGE_MAP() }; #endif // _WALLPAPERDRAWSETTINGSMODEDLG_H
[ [ [ 1, 148 ] ] ]
901cf49bd84659c676aa9486867c67c0c372f34f
d37a1d5e50105d82427e8bf3642ba6f3e56e06b8
/DVR/VPKServer/StdAfx.cpp
e57b9aa6860a4628ba9951633ac8e2051fab4cd5
[]
no_license
080278/dvrmd-filter
176f4406dbb437fb5e67159b6cdce8c0f48fe0ca
b9461f3bf4a07b4c16e337e9c1d5683193498227
refs/heads/master
2016-09-10T21:14:44.669128
2011-10-17T09:18:09
2011-10-17T09:18:09
32,274,136
0
0
null
null
null
null
UTF-8
C++
false
false
296
cpp
// stdafx.cpp : source file that includes just the standard includes // VPKServer.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "[email protected]@27769579-7047-b306-4d6f-d36f87483bb3" ]
[ [ [ 1, 8 ] ] ]
eacb2df4e3272ac733c0967dc67f8d4797cb030c
bfe8eca44c0fca696a0031a98037f19a9938dd26
/libjingle-0.4.0/talk/session/phone/phonesessionclient.h
db4457a42f5a9ffa25282683c00f706bbb1dd9fe
[ "BSD-3-Clause" ]
permissive
luge/foolject
a190006bc0ed693f685f3a8287ea15b1fe631744
2f4f13a221a0fa2fecab2aaaf7e2af75c160d90c
refs/heads/master
2021-01-10T07:41:06.726526
2011-01-21T10:25:22
2011-01-21T10:25:22
36,303,977
0
0
null
null
null
null
UTF-8
C++
false
false
4,581
h
/* * libjingle * Copyright 2004--2005, Google Inc. * * 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. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 _PHONESESSIONCLIENT_H_ #define _PHONESESSIONCLIENT_H_ #include "talk/session/phone/call.h" #include "talk/session/phone/channelmanager.h" #include "talk/base/sigslot.h" #include "talk/base/messagequeue.h" #include "talk/base/thread.h" #include "talk/p2p/base/sessionmanager.h" #include "talk/p2p/base/session.h" #include "talk/p2p/base/sessionclient.h" #include "talk/p2p/base/sessiondescription.h" #include <map> namespace cricket { class Call; class PhoneSessionDescription; class PhoneSessionClient: public SessionClient, public sigslot::has_slots<> { public: PhoneSessionClient(const buzz::Jid& jid, SessionManager *manager); ~PhoneSessionClient(); const buzz::Jid &jid() const { return jid_; } SessionManager* session_manager() const { return session_manager_; } ChannelManager* channel_manager() const { return channel_manager_; } Call *CreateCall(); void DestroyCall(Call *call); Call *GetFocus(); void SetFocus(Call *call); void JoinCalls(Call *call_to_join, Call *call); void SetAudioOptions(bool auto_gain_control, int wave_in_device, int wave_out_device) { if (channel_manager_) channel_manager_->SetAudioOptions(auto_gain_control, wave_in_device, wave_out_device); } sigslot::signal2<Call *, Call *> SignalFocus; sigslot::signal1<Call *> SignalCallCreate; sigslot::signal1<Call *> SignalCallDestroy; PhoneSessionDescription* CreateOfferSessionDescription(); PhoneSessionDescription* CreateAcceptSessionDescription(const SessionDescription* offer); // Returns our preference for the given codec. static int GetMediaCodecPreference(Codec codec); private: void OnSessionCreate(Session *session, bool received_initiate); void OnSessionState(Session *session, Session::State state); void OnSessionDestroy(Session *session); const SessionDescription *CreateSessionDescription(const buzz::XmlElement *element); buzz::XmlElement *TranslateSessionDescription(const SessionDescription *description); Session *CreateSession(Call *call); buzz::Jid jid_; SessionManager* session_manager_; Call *focus_call_; ChannelManager *channel_manager_; std::map<uint32, Call *> calls_; std::map<SessionID, Call *> session_map_; friend class Call; }; class PhoneSessionDescription: public SessionDescription { public: // Returns the list of codecs sorted by our preference. const std::vector<Codec>& codecs() const { return codecs_; } // Adds another codec to the list. void AddCodec(const Codec& codec) { codecs_.push_back(codec); } // Sorts the list of codecs by preference. void Sort() { std::sort(codecs_.begin(), codecs_.end(), PreferenceSort()); } private: std::vector<Codec> codecs_; struct PreferenceSort { bool operator()(Codec a, Codec b) { return a.preference > b.preference; } }; #if defined(FEATURE_ENABLE_VOICEMAIL) std::string lang_; #endif }; } #endif // _PHONESESSIONCLIENT_H_
[ "[email protected]@756bb6b0-a119-0410-8338-473b6f1ccd30" ]
[ [ [ 1, 125 ] ] ]
cf2233eddbb7ef6ea1bd588ec0f6b9165020f398
daef491056b6a9e227eef3e3b820e7ee7b0af6b6
/Tags/0.2.6/code/toolkit/graphics/gl/x11/gl_x11_rendertarget.cpp
f13a24b9bf28ba0ed4490a0417dc164ef7e81d36
[ "BSD-3-Clause" ]
permissive
BackupTheBerlios/gut-svn
de9952b8b3e62cedbcfeb7ccba0b4d267771dd95
0981d3b37ccfc1ff36cd79000f6c6be481ea4546
refs/heads/master
2021-03-12T22:40:32.685049
2006-07-07T02:18:38
2006-07-07T02:18:38
40,725,529
0
0
null
null
null
null
UTF-8
C++
false
false
2,469
cpp
/********************************************************************** * GameGut - gl_x11_rendertarget.cpp * Copyright (c) 1999-2005 Jason Perkins. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the BSD-style license that is * included with this library in the file LICENSE.txt. * * 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 * files LICENSE.txt for more details. **********************************************************************/ #include "core/core.h" #include "core/x11/errors.h" #include "../gl_graphics.h" #include <stdio.h> #include <X11/Xlib.h> #include <GL/glx.h> struct utxX11RenderTarget : utxRenderTarget { Display* display; Window window; GLXContext context; ~utxX11RenderTarget() { glXDestroyContext(display, context); } }; utRenderTarget utxCreateWindowTarget(void* window) { Display* display = XOpenDisplay(NULL); if (display == NULL) { utxLogError("XOpenDisplay"); return NULL; } /* Get some information about the target window */ Window x11window = (Window)window; XWindowAttributes xwa; XGetWindowAttributes(display, x11window, &xwa); int screen = DefaultScreen(display); /* Hardcode a pixel format for now...I'll come back to this */ int surface[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1, GLX_DOUBLEBUFFER, None }; XVisualInfo* visual = glXChooseVisual(display, screen, surface); if (visual == NULL) { utxLogError("glXChooseVisual"); return NULL; } /* Create the rendering context */ GLXContext context = glXCreateContext(display, visual, NULL, True); if (context == NULL) { utxLogError("glXCreateContext"); return NULL; } glXMakeCurrent(display, x11window, context); /* All set */ utxX11RenderTarget* target = utNEW utxX11RenderTarget; target->display = display; target->window = x11window; target->context = context; target->width = xwa.width; target->height = xwa.height; return target; } int utResizeRenderTarget(utRenderTarget target, int width, int height) { target->width = width; target->height = height; glViewport(0, 0, width, height); return true; } int utSwapRenderTarget(utRenderTarget target) { utxX11RenderTarget* x11t = (utxX11RenderTarget*)target; glXSwapBuffers(x11t->display, x11t->window); return true; }
[ "starkos@5eb1f239-c603-0410-9f17-9cbfe04d0a06" ]
[ [ [ 1, 97 ] ] ]
b3ba9ce1a8952e23ab6ea5209e3e53fab9a2a084
866209e7817b650a056f0137b575af95b2b610c1
/cleanjpg.cpp
62cb4ff7948012d673a70c2faa0362064af9cf72
[]
no_license
hubgit88/cleanjpg
8eb0070d231a149d57543a00b8be2003962c96ee
28741106bf795f3c0d83d7ace49c542c5ebc875d
refs/heads/master
2021-01-10T10:07:15.972652
2008-05-31T19:34:13
2008-05-31T19:34:13
51,642,336
0
0
null
null
null
null
UTF-8
C++
false
false
8,496
cpp
/*********************************************************************************/ /* cleanjpg - cleanjpg.cpp */ /* */ /* Programmed by Kevin Pickell, 2006 */ /* */ /* http://code.google.com/p/cleanjpg/ */ /* */ /* cleanjpg 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; version 2. */ /* */ /* cleanjpg 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. */ /* */ /* http://www.gnu.org/licenses/lgpl.txt */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with cleanjpg; if not, write to the Free Software */ /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /*********************************************************************************/ /****************************************/ /* what it does: */ /* */ /* iterates through a given directory */ /* removed all unnecessary data blocks */ /* from jpg pictures */ /* */ /****************************************/ #include <string.h> #include <stdio.h> #include <stdlib.h> #ifdef WIN32 #include <io.h> #else #include <sys/dir.h> #include <sys/stat.h> #include <sys/file.h> //#include <linux/types.h> //#include <linux/unistd.h> #endif /* settings */ bool recursive=true; char *loadfilez(const char *filename,int *filesize) { FILE *fp; char *filemem; int count,fs; if(filesize) *(filesize)=0; /* if there is any errors, then filesize=0 */ fp=fopen(filename,"rb"); if(!fp) /* error! */ { printf("Error: (OPEN) Unable to open input file '%s'\n",filename); return(0); } if (fseek (fp,0l,SEEK_END)) { printf("Error: (SEEK) Unable to open input file '%s'",filename); return (0); } fs=(int)ftell(fp); if(!fs) { printf("Error: (FTELL) Unable to get file size, or empty file '%s'",filename); } filemem=(char *)malloc(fs); /* let's allocate the ram to load the file in! */ if(!filemem) { printf("Error: (ALLOC) Unable allocate memory '%ld'",fs); fclose(fp); return(0); /* not enough ram to load the file in! */ } if (fseek (fp,0l,SEEK_SET)) { printf("Error: (SEEK) Unable to open input file '%s'",filename); free(filemem); return (0); } count = (int)fread (filemem,1,fs,fp); /* read in the file */ fclose(fp); if(fs!=count) { free(filemem); printf("Error: (COUNT MISMATCH) Unable to open input file '%s',%ld!=%ld",filename,count,fs); free(filemem); return(0); } /* everything was ok! */ if(filesize) *(filesize)=fs; return(filemem); } void dofunc(const char *filename) { unsigned char *pstart; unsigned char *pend; unsigned char *cp; int psize; FILE *out; int endblocks; int skip; pstart=(unsigned char *)loadfilez(filename,&psize); if(!pstart) return; pend=pstart+psize; /* traverse blocks */ cp=pstart; if(cp[0]==0xff && cp[1]==0xd8) /* valid header for a JPG file */ { printf("file='%s'\n",filename); out=fopen(filename,"wb"); fwrite(cp,1,2,out); cp+=2; endblocks=0; while(cp<pend && endblocks==0) { unsigned int id; int blocklen; /* get block ID and block length */ id=(cp[0]<<8)|cp[1]; blocklen=2+(((unsigned int)cp[2]<<8)+cp[3]); if(id>=0xffe0 && id<=0xfff0) skip=1; else skip=0; if(!skip) fwrite(cp,1,blocklen,out); printf(" block id=%04x - len=%d",id,blocklen); switch(id) { case 0xffe0: printf(" - APP0 Application Marker"); break; case 0xffdb: printf(" - DQT Quantization Table"); break; case 0xffc0: printf(" - SOF0 Start of frame"); break; case 0xffc4: printf(" - DHT Define Huffman Table"); break; case 0xffda: printf(" - SOS Start of scan"); endblocks=1; //no more packets break; case 0xffed: printf(" - APP14 This is the marker where Photoshop stores its information"); break; } printf("\n"); cp+=blocklen; } /* write remainder of file (image data) */ fwrite(cp,1,(pend-cp),out); printf(" imagedatasize=%d\n",pend-cp); fclose(out); } free(pstart); } void LoadDir(const char *path,bool recursive,const char *ext); int main(int argc, char **argv) { bool recursive=true; printf("cleanjpg 1.0 - remove all non essential data from jpg files!\n"); if(argc!=2) printf("usage: cleanjpg path\n"); else LoadDir(argv[1],recursive,".jpg"); return 0; } #ifdef WIN32 #define DIRCHAR "\\" #else #define DIRCHAR "/" #endif void LoadDir(const char *path,bool recursive,const char *ext) { //arbitrary max filename length char tempname[2048]; char *nameplace; char *fn; bool isdir; char dirc[]={DIRCHAR}; #ifdef WIN32 intptr_t dir_handle; struct _finddata_t dir_info; #else int dir_handle; int bufsize; char buffer[8192]; struct direct *direntry; struct stat statbuf; #if _FILE_OFFSET_BITS==64 long long zzzz; #else long zzzz; #endif #endif #ifdef WIN32 strcpy(tempname,path); if(strlen(tempname)==0) strcat(tempname,DIRCHAR); else if(tempname[strlen(tempname)-1]!=dirc[0]) strcat(tempname,DIRCHAR); nameplace=tempname+strlen(tempname); strcat(tempname,"*"); dir_handle = _findfirst(tempname, &dir_info); if(dir_handle<0) return; /* path must be unmounted or something is wrong! */ fn=dir_info.name; #else strcpy(tempname,path); if(strlen(tempname)>1) { //remove trailing '/' if(tempname[strlen(tempname)-1]==dirc[0]) tempname[strlen(tempname)-1]=0; } dir_handle=open(tempname,O_RDONLY); /* open directory for reading */ if(dir_handle==-1) return; /* cannot open dir */ direntry=(struct direct *)buffer; fn=direntry->d_name; bufsize=0; // if path doesn't end in '/' then append '/' if(tempname[strlen(tempname)-1]!=dirc[0]) strcat(tempname,DIRCHAR); nameplace=tempname+strlen(tempname); #endif do { #ifndef WIN32 if(bufsize<=20) bufsize+=getdirentries(dir_handle,buffer+bufsize,sizeof(buffer)-bufsize,&zzzz); if(bufsize<=0) break; #endif if(fn[0]!='.') { strcpy(nameplace,fn); /* put name after path/ */ isdir=false; #ifdef WIN32 if(dir_info.attrib&16) isdir=true; #else if(stat(tempname,&statbuf)!=-1) { if(S_ISDIR(statbuf.st_mode)) isdir=true; } #endif if(isdir) { if(recursive==true) LoadDir(tempname,true,ext); } else { bool addme; /* if no extension then match everything */ addme=true; if(ext) { addme=false; /* make sure extension matches */ if(strlen(fn)>strlen(ext)) { const char *eplace; /* compare the extension */ eplace=fn+strlen(fn)-strlen(ext); if(!stricmp(eplace,ext)) addme=true; } } /* call the processor on this file */ if(addme==true) dofunc(tempname); } } #ifdef WIN32 if(_findnext(dir_handle, &dir_info)==-1) break; #else bufsize-=direntry->d_reclen; memmove(buffer,buffer+direntry->d_reclen,bufsize); #endif }while(1); #ifdef WIN32 _findclose(dir_handle); #else close(dir_handle); #endif }
[ [ [ 1, 329 ] ] ]
6526ec50b1862bb3fe3362df73c5c5dc38a6c4fc
0f5780cdf99c4b4568d8550f2bdfb3a1fa71126d
/src/jsonreader.cpp
569101cae73f6a6b7fe8d63622ef16406cf74416
[]
no_license
lenoval/e
3136e04e5cbfc140368f0ec32c6e500e9773d113
52f3c09282ddbf5c53fe75c1d4395a9bc134f52d
refs/heads/master
2021-01-18T03:51:50.353760
2009-05-08T21:57:49
2009-05-08T21:57:49
196,945
3
1
null
null
null
null
UTF-8
C++
false
false
61,419
cpp
///////////////////////////////////////////////////////////////////////////// // Name: jsonreader.cpp // Purpose: the wxJSONReader class: a JSON text parser // Author: Luciano Cattani // Created: 2007/10/14 // RCS-ID: $Id: jsonreader.cpp,v 1.12 2008/03/12 10:48:19 luccat Exp $ // Copyright: (c) 2007 Luciano Cattani // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "jsonreader.cpp" #endif #include "jsonreader.h" #include <wx/sstream.h> #include <wx/debug.h> #include <wx/log.h> /*! \class wxJSONReader \brief The JSON parser The class is a JSON parser which reads a JSON formatted text and stores values in the \c wxJSONValue structure. The ctor accepts two parameters: the \e style flag, which controls how much error-tolerant should the parser be and an integer which is the maximum number of errors and warnings that have to be reported. If the document does not contain an open/close JSON character the function returns an \b empty value object; in other words, the wxJSONValue::IsEmpty() function returns TRUE. This is the case of a document that is empty or contains only whitespaces or comments. If the document contains a starting object/array character immediatly followed by a closing object/array character (i.e.: \c {} ) then the function returns an \b empty array or object JSON value (note the little distinction: \b empty value is not the same as \b empty \b array or \b empty \b object ). For an empty object or array, the wxJSONValue::IsEmpty() function returns FALSE and the wxJSONValue::Size() returns ZERO. In order to avoid confusion, you have to think about \b empty JSON values as \b invalid JSON values. \b Empty \b arrays and \b empty \b objects are valid JSON values. \par JSON text Note that the wxJSON parser just skips all characters read from the input JSON text until the start-object '{' or start-array '[' characters are encontered (see the GetStart() function). This means that the JSON input text may contain everything before the first start-object/array character except these two chars themselves unless they are included in a C/C++ comment. Comment lines that apear before the first start array/object character, are non ignored if the parser is constructed with the wxJSONREADER_STORE_COMMENT flag: they are added to the comment's array of the root JSON value. Also note that the parsing process stops when the internal DoRead() function returns. Because that function is recursive, the top-level close-object '}' or close-array ']' character cause the top-level DoRead() function to return thus stopping the parsing process regardless the EOF condition. This mean that the JSON input text may contain everything \b after the top-level close-object/array character. Here are some examples: Returns a wxJSONTYPE_EMPTY value (invalid JSON value) \code // this text does not contain an open array/object character \endcode Returns a wxJSONTYPE_OBJECT value of Size() = 0 \code { } \endcode Returns a wxJSONTYPE_ARRAY value of Size() = 0 \code [ ] \endcode Text before and after the top-level open/close characters is ignored. \code This non-JSON text does not cause the parser to report errors or warnings { } This non-JSON text does not cause the parser to report errors or warnings \endcode \par Extensions The wxJSON parser recognizes all JSON text plus some extensions that are not part of the JSON syntax but that many other JSON implementations do recognize. If the input text contains the following non-JSON text, the parser reports the situation as \e warnings and not as \e errors unless the parser object was constructed with the wxJSONREADER_STRICT flag. In the latter case the wxJSON parser is not tolerant. \li C/C++ comments: the parser recognizes C and C++ comments. Comments can optionally be stored in the value they refer to and can also be written back to the JSON text document. To know more about comment storage see \ref wxjson_comments \li case tolerance: JSON syntax states that the literals \c null, \c true and \c false must be lowercase; the wxJSON parser also recognizes mixed case literals such as, for example, \b Null or \b FaLSe. A \e warning is emitted. \li wrong or missing closing character: wxJSON parser is tolerant about the object / array closing character. When an open-array character '[' is encontered, the parser expects the corresponding close-array character ']'. If the character encontered is a close-object char '}' a warning is reported. A warning is also reported if the character is missing when the end-of-file is reached. \li multi-line strings: this feature allows a JSON string type to be splitted in two or more lines as in the standard C/C++ languages. The drawback is that this feature is error-prone and you have to use it with care. For more info about this topic read \ref json_multiline_string Note that you can control how much error-tolerant should the parser be and also you can specify how many and what extensions are recognized. See the constructor's parameters for more details. \par Unicode vs ANSI The parser can read JSON text from two very different kind of objects: \li a string object (\b wxString) \li a stream object (\b wxInputStream) When the input is from a string object, the character represented in the string is platform- and mode- dependant; in other words, characters are represented differently: in ANSI builds they depend on the charset in use and in Unicode builds they depend on the platform (UCS-2 in win32, UCS-4 in GNU/Linux). When the input is from a stream object, the only recognized encoding format is UTF-8 for both ANSI and Unicode builds. \par Example: \code wxJSONValue value; wxJSONReader reader; // open a text file that contains the UTF-8 encoded JSON text wxFFileInputStream jsonText( _T("filename.utf8"), _T("r")); // read the file int numErrors = reader.Parse( jsonText, &value ); if ( numErrors > 0 ) { ::MessageBox( _T("Error reading the input file")); } \endcode To know more about ANSI and Unicode mode read \ref wxjson_tutorial_unicode. */ // if you have the debug build of wxWidgets and wxJSON you can see // trace messages by setting the: // WXTRACE=traceReader StoreComment // environment variable static const wxChar* traceMask = _T("traceReader"); static const wxChar* storeTraceMask = _T("StoreComment"); //! Ctor /*! Construct a JSON parser object with the given parameters. JSON parser objects should always be constructed on the stack but it does not hurt to have a global JSON parser. \param flags this paramter controls how much error-tolerant should the parser be \param maxErrors the maximum number of errors (and warnings, too) that are reported by the parser. When the number of errors reaches this limit, the parser stops to read the JSON input text and no other error is reported. The \c flag parameter is the combination of ZERO or more of the following constants OR'ed toghether: \li wxJSONREADER_ALLOW_COMMENTS: C/C++ comments are recognized by the parser; a warning is reported by the parser \li wxJSONREADER_STORE_COMMENTS: C/C++ comments, if recognized, are stored in the value they refer to and can be rewritten back to the JSON text \li wxJSONREADER_CASE: the parser recognizes mixed-case literal strings \li wxJSONREADER_MISSING: the parser allows missing or wrong close-object and close-array characters \li wxJSONREADER_MULTISTRING: strings may be splitted in two or more lines \li wxJSONREADER_COMMENTS_AFTER: if STORE_COMMENTS if defined, the parser assumes that comment lines apear \b before the value they refer to unless this constant is specified. In the latter case, comments apear \b after the value they refer to. You can also use the following shortcuts to specify some predefined flag's combination: \li wxJSONREADER_STRICT: all wxJSON extensions are reported as errors, this is the same as specifying a ZERO value as \c flags. \li wxJSONREADER_TOLERANT: this is the same as ALLOW_COMMENTS | CASE | MISSING | MULTISTRING; all wxJSON extensions are turned on but comments are not stored in the value objects. \par Example: The following code fragment construct a JSON parser, turns on all wxJSON extensions and also stores C/C++ comments in the value object they refer to. The parser assumes that the comments apear before the value: \code wxJSONReader reader( wxJSONREADER_TOLERANT | wxJSONREADER_STORE_COMMENTS ); wxJSONValue root; int numErrors = reader.Parse( jsonText, &root ); \endcode */ wxJSONReader::wxJSONReader( int flags, int maxErrors ) { m_flags = flags; m_maxErrors = maxErrors; m_inType = -1; m_inObject = 0; } //! Dtor - does nothing wxJSONReader::~wxJSONReader() { } //! Parse the JSON document. /*! The two overloaded versions of the \c Parse() function read a JSON text stored in a wxString object or in a wxInputStream object. If \c val is a NULL pointer, the function does not store the values: it can be used as a JSON checker in order to check the syntax of the document. Returns the number of \b errors found in the document. If the returned value is ZERO and the parser was constructed with the \c wxJSONREADER_STRICT flag, then the parsed document is \e well-formed and it only contains valid JSON text. If the \c wxJSONREADER_TOLERANT flag was used in the parser's constructor, then a return value of ZERO does not mean that the document is \e well-formed because it may contain comments and other extensions that are not fatal for the wxJSON parser but other parsers may fail to recognize. You can use the \c GetWarningCount() function to know how many wxJSON extensions are present in the JSON input text. Note that the JSON value object \c val is not cleared by this function unless its type is of the wrong type. In other words, if \c val is of type wxJSONTYPE_ARRAY and it already contains 10 elements and the input document starts with a '[' (open-array char) then the elements read from the document are \b appended to the existing ones. On the other hand, if the text document starts with a '{' (open-object) char then this function must change the type of the \c val object to \c wxJSONTYPE_OBJECT and the old content of 10 array elements will be lost. When reading from a \b wxInputStream the JSON text must be encoded in UTF-8 format for both Unicode and ANSI builds. When reading from a \b wxString object, the input text is encoded in different formats depending on the platform and the build mode: in Unicode builds, strings are encoded in UCS-2 format on Windows and in UCS-4 format on GNU/Linux; in ANSI builds, strings contain one-byte locale dependent characters. */ int wxJSONReader:: Parse( const wxString& doc, wxJSONValue* val ) { m_inType = 0; // a string m_inObject = (void*) &doc; m_charPos = 0; m_conv = 0; int numErr = Parse( val ); return numErr; } //! \overload Parse( const wxString&, wxJSONValue* ) int wxJSONReader::Parse( wxInputStream& is, wxJSONValue* val ) { wxMBConvUTF8 conv; m_conv = &conv; m_inObject = &is; m_inType = 1; return Parse( val ); } //! The general parsing function (internal use) /*! This protected function is called by the public overloaded Parse() functions after setting up the internal data members. */ int wxJSONReader::Parse( wxJSONValue* val ) { // construct a temporary wxJSONValue that will be passed // to DoRead() if val == 0 - note that it will be deleted on exit wxJSONValue* temp = 0; m_level = 0; m_lineNo = 1; m_colNo = 1; m_peekChar = -1; m_errors.clear(); m_warnings.clear(); // check the internal data members wxASSERT( m_inObject != 0 ); wxASSERT( m_inType >= 0 ); if ( val != 0 ) { temp = val; } else { temp = new wxJSONValue(); } // set the wxJSONValue object's pointers for comment storage m_next = temp; m_next->SetLineNo( -1 ); m_lastStored = 0; m_current = 0; int ch = GetStart(); switch ( ch ) { case '{' : temp->SetType( wxJSONTYPE_OBJECT ); break; case '[' : temp->SetType( wxJSONTYPE_ARRAY ); break; default : AddError( _T("Cannot find a start object/array character" )); return m_errors.size(); break; } // returning from DoRead() could be for EOF or for // the closing array-object character // if -1 is returned, it is as an error because the lack // of close-object/array characters // note that the missing close-chars error messages are // added by the DoRead() function ch = DoRead( *temp ); if ( val == 0 ) { delete temp; } return m_errors.size(); } //! Returns the start of the document /*! This is the first function called by the Parse() function and it searches the input stream for the starting character of a JSON text and returns it. JSON text start with '{' or '['. If the two starting characters are inside a C/C++ comment, they are ignored. Returns the JSON-text start character or -1 on EOF. */ int wxJSONReader::GetStart() { int ch = 0; do { switch ( ch ) { case 0 : ch = ReadChar(); break; case '{' : return ch; break; case '[' : return ch; break; case '/' : ch = SkipComment(); StoreComment( 0 ); break; default : ch = ReadChar(); break; } } while ( ch >= 0 ); return ch; } //! Return a reference to the error message's array. const wxArrayString& wxJSONReader::GetErrors() const { return m_errors; } //! Return a reference to the warning message's array. const wxArrayString& wxJSONReader::GetWarnings() const { return m_warnings; } //! Return the size of the error message's array. int wxJSONReader::GetErrorCount() const { return m_errors.size(); } //! Return the size of the warning message's array. int wxJSONReader::GetWarningCount() const { return m_warnings.size(); } //! Read a character from the input JSON document. /*! The function returns a single character from the input JSON document as an integer so that all 2^31 unicode characters can be represented as a positive integer value. In case of errors or EOF, the function returns -1. The function also updates the \c m_lineNo and \c m_colNo data members and converts all CR+LF sequence in LF. Note that this function calls GetChar() in order to retrieve the next character in the JSON input text. */ int wxJSONReader::ReadChar() { int ch = GetChar(); // the function also converts CR in LF. only LF is returned // in the case of CR+LF // returns -1 on EOF if ( ch == -1 ) { return ch; } int nextChar; if ( ch == '\r' ) { m_colNo = 1; nextChar = PeekChar(); if ( nextChar == -1 ) { return -1; } else if ( nextChar == '\n' ) { ch = GetChar(); } } if ( ch == '\n' ) { ++m_lineNo; m_colNo = 1; } else { ++m_colNo; } return ch; } //! Return a character from the input JSON document. /*! The function is called by ReadChar() and returns a single character from the input JSON document as an integer so that all 2^31 unicode characters can be represented as a positive integer value. In case of errors or EOF, the function returns -1. Note that this function behaves differently depending on the build mode (ANSI or Unicode) and the type of the object containing the JSON document. \par wxString input If the input JSON text is stored in a \b wxString object, there is no difference between ANSI and Unicode builds: the function just returns the next character in the string and updates the \c m_charPos data member that points the next character in the string. In Unicode mode, the function returns wide characters and in ANSI builds it returns only chars. \par wxInputStream input Stream input is always encoded in UTF-8 format in both ANSI ans Unicode builds. In order to return a single character, the function calls the UTF8NumBytes() function which returns the number of bytes that have to be read from the stream in order to get one character. The bytes read are then converted to a wide character and returned. Note that wide chars are also returned in ANSI mode but they are processed differently by the parser: before storing the wide character in the JSON value, it is converted to the locale dependent character if one exists; if not, the \e unicode \e escape \e sequence is stored in the JSON value. */ int wxJSONReader::GetChar() { int ch; if ( m_peekChar >= 0 ) { ch = m_peekChar; m_peekChar = -1; return ch; } if ( m_inType == 0 ) { // input is a string wxString* s = (wxString*) m_inObject; size_t strLen = s->length(); if ( m_charPos >= (int) strLen ) { return -1; // EOF } else { ch = s->GetChar( m_charPos ); ++m_charPos; } } else { // input is a stream: it must be UTF-8 wxInputStream* is = (wxInputStream*) m_inObject; wxASSERT( is != 0 ); // must know the number fo bytes to read char buffer[10]; buffer[0] = is->GetC(); // check the EOF condition; note that in wxWidgets 2.6.x and below // some streams returns EOF after the last char was read and // we should use LastRead() to know the EOF condition // wxJSON depends on 2.8.4 and above so there should be no problem if ( is->Eof() ) { return -1; } // if ( LastRead() <= 0 ) { // return -1; // } int numBytes = UTF8NumBytes( buffer[0] ); wxASSERT( numBytes < 10 ); if ( numBytes > 1 ) { is->Read( buffer + 1, numBytes - 1); } // check that we read at least 'numBytes' bytes int lastRead = is->LastRead(); if ( lastRead < ( numBytes -1 )) { AddError( _T("Cannot read the number of needed UTF-8 encoded bytes")); ch = -1; return ch; } // we convert the UTF-8 char to a wide char; if the conversion // fails, returns -1 wchar_t dst[5]; wxASSERT( m_conv != 0 ); size_t outLength = m_conv->ToWChar( dst, 10, buffer, numBytes ); if ( outLength == wxCONV_FAILED ) { AddError( _T("Cannot convert multibyte sequence to wide character")); ch = -1; return ch; } else { wxASSERT( outLength == 2 ); // seems that a NULL char is appended ch = dst[0]; } // we are only interested in the dst[0] wide-chracter; it could be // possible that 'outLenght' is 2 because a trailing NULL wchar is // appended but it is ignored // if the character read is a NULL char, it is returned as a NULL // char thus causing the JSON reader to read the next char. } // for tracing purposes we do not print control characters char chPrint = '.'; if ( ch >= 20 ) { chPrint = ch; } ::wxLogTrace( _T("traceChar"), _T("(%s) ch=%x char=%c"), __PRETTY_FUNCTION__, ch, chPrint ); return ch; } //! Peek a character from the input JSON document /*! This function is much like GetChar() but it does not update the stream or string input position. */ int wxJSONReader::PeekChar() { int ch; if ( m_peekChar >= 0 ) { ch = m_peekChar; } else { ch = GetChar(); m_peekChar = ch; } return ch; } //! Reads the JSON text document (internal use) /*! This is a recursive function that is called by \c Parse() and by the \c DoRead() function itself when a new object / array is encontered. The function returns when a EOF condition is encontered or when the final close-object / close-array char is encontered. The function also increments the \c m_level data member when it is entered and decrements it on return. The function is the heart of the wxJSON parser class but it is also very easy to understand because JSON syntax is very easy. Returns the last close-object/array character read or -1 on EOF. */ int wxJSONReader::DoRead( wxJSONValue& parent ) { ++m_level; // the value that has to be read (can be a complex structure) // it can also be a 'name' (key) string wxJSONValue value( wxJSONTYPE_EMPTY ); m_next = &value; m_current = &parent; m_current->SetLineNo( m_lineNo ); m_lastStored = 0; // the 'key' string is stored from 'value' when a ':' is encontered wxString key; // the character read: -1=EOF, 0=to be read int ch=0; do { // we read until ch < 0 switch ( ch ) { case 0 : ch = ReadChar(); break; case ' ' : case '\t' : case '\n' : case '\r' : ch = SkipWhiteSpace(); break; case -1 : // the EOF break; case '/' : ch = SkipComment(); StoreComment( &parent ); break; case '{' : if ( parent.IsObject() ) { if ( key.empty() ) { AddError( _T("\'{\' is not allowed here (\'name\' is missing") ); } if ( !value.IsEmpty() ) { AddError( _T("\'{\' cannot follow a \'value\'") ); } } else if ( parent.IsArray() ) { if ( !value.IsEmpty() ) { AddError( _T("\'{\' cannot follow a \'value\' in JSON array") ); } } else { wxASSERT( 0 ); // always fails } // althrough there were errors, we go into the subobject value.SetType( wxJSONTYPE_OBJECT ); ch = DoRead( value ); break; case '}' : if ( !parent.IsObject() ) { AddWarning( wxJSONREADER_MISSING, _T("Trying to close an array using the \'}\' (close-object) char" )); } StoreValue( ch, key, value, parent ); m_current = &parent; m_next = 0; m_current->SetLineNo( m_lineNo ); ch = ReadChar(); return ch; break; case '[' : if ( parent.IsObject() ) { if ( key.empty() ) { AddError( _T("\'[\' is not allowed here (\'name\' is missing") ); } if ( !value.IsEmpty() ) { AddError( _T("\'[\' cannot follow a \'value\' text") ); } } else if ( parent.IsArray()) { if ( !value.IsEmpty() ) { AddError( _T("\'[\' cannot follow a \'value\'") ); } } else { wxASSERT( 0 ); // always fails } // althrough there were errors, we go into the subobject value.SetType( wxJSONTYPE_ARRAY ); ch = DoRead( value ); break; case ']' : if ( !parent.IsArray() ) { AddWarning( wxJSONREADER_MISSING, _T("Trying to close an object using the \']\' (close-array) char" )); } StoreValue( ch, key, value, parent ); m_current = &parent; m_next = 0; m_current->SetLineNo( m_lineNo ); return 0; // returning ZERO for reading the next char break; case ',' : StoreValue( ch, key, value, parent ); key.clear(); ch = ReadChar(); break; case '\"' : ch = ReadString( value ); // store the string in 'value' m_current = &value; m_next = 0; break; case ':' : // key / value separator m_current = &value; m_current->SetLineNo( m_lineNo ); m_next = 0; if ( !parent.IsObject() ) { AddError( _T( "\':\' cannot be used in array's values" )); } else if ( !value.IsString() ) { AddError( _T( "\':\' follows a value which is not of type \'string\'" )); } else if ( !key.empty() ) { AddError( _T( "\':\' not allowed where a \'name\' string was already available" )); } else { key = value.AsString(); value.SetType( wxJSONTYPE_EMPTY ); } ch = ReadChar(); break; // no special chars, is it a value? default : // errors are checked in the 'ReadValue()' function. m_current = &value; m_current->SetLineNo( m_lineNo ); m_next = 0; ch = ReadValue( ch, value ); break; } } while ( ch >= 0 ); if ( parent.IsArray() ) { AddWarning( wxJSONREADER_MISSING, _T("\']\' missing at end of file")); } else if ( parent.IsObject() ) { AddWarning( wxJSONREADER_MISSING, _T("\'}\' missing at end of file")); } else { wxASSERT( 0 ); } // we store the value, as there is a missing close-object/array char StoreValue( ch, key, value, parent ); --m_level; return ch; } //! Store a value in the parent object. /*! The function is called by \c DoRead() when a the comma or a close-object character is encontered and stores the current value read by the parser in the parent object. The function checks that \c value is not empty and that \c key is not an empty string if parent is an object. \param ch the character read: a comma or close objecty/array char \param key the \b key string: may be empty if parent ss an array \param value the current JSON value to be stored in \c parent \param parent the JSON value that holds \c value. */ void wxJSONReader::StoreValue( int ch, const wxString& key, wxJSONValue& value, wxJSONValue& parent ) { // if 'ch' == } or ] than value AND key may be empty when a open object/array // is immediatly followed by a close object/array // // if 'ch' == , (comma) value AND key (for TypeMap) cannot be empty // ::wxLogTrace( traceMask, _T("(%s) ch=%d char=%c"), __PRETTY_FUNCTION__, ch, (char) ch); ::wxLogTrace( traceMask, _T("(%s) value=%s"), __PRETTY_FUNCTION__, value.AsString().c_str()); m_current = 0; m_next = &value; m_lastStored = 0; m_next->SetLineNo( -1 ); if ( value.IsEmpty() && key.empty() ) { // OK, if the char read is a close-object or close-array if ( ch == '}' || ch == ']' ) { m_lastStored = 0; ::wxLogTrace( traceMask, _T("(%s) key and value are empty, returning"), __PRETTY_FUNCTION__); } else { AddError( _T("key or value is missing for JSON value")); } } else { // key or value are not empty if ( parent.IsObject() ) { if ( value.IsEmpty() ) { AddError( _T("cannot store the value: \'value\' is missing for JSON object type")); } else if ( key.empty() ) { AddError( _T("cannot store the value: \'key\' is missing for JSON object type")); } else { ::wxLogTrace( traceMask, _T("(%s) adding value to key:%s"), __PRETTY_FUNCTION__, key.c_str()); parent[key] = value; m_lastStored = &(parent[key]); m_lastStored->SetLineNo( m_lineNo ); } } else if ( parent.IsArray() ) { if ( value.IsEmpty() ) { AddError( _T("cannot store the item: \'value\' is missing for JSON array type")); } if ( !key.empty() ) { AddError( _T("cannot store the item: \'key\' (\'%s\') is not permitted in JSON array type"), key); } ::wxLogTrace( traceMask, _T("(%s) appending value to parent array"), __PRETTY_FUNCTION__ ); parent.Append( value ); const wxJSONInternalArray* arr = parent.AsArray(); wxASSERT( arr ); m_lastStored = &(arr->Last()); m_lastStored->SetLineNo( m_lineNo ); } else { wxASSERT( 0 ); // should never happen } } value.SetType( wxJSONTYPE_EMPTY ); value.ClearComments(); } //! Add a error message to the error's array /*! The overloaded versions of this function add an error message to the error's array stored in \c m_errors. The error message is formatted as follows: \code Error: line xxx, col xxx - <error_description> \endcode The \c msg parameter is the description of the error; line's and column's number are automatically added by the functions. The \c fmt parameter is a format string that has the same syntax as the \b printf function. Note that it is the user's responsability to provide a format string suitable with the arguments: another string or a character. */ void wxJSONReader::AddError( const wxString& msg ) { wxString err; err.Printf( _T("Error: line %d, col %d - %s"), m_lineNo, m_colNo, msg.c_str() ); ::wxLogTrace( traceMask, _T("(%s) %s"), __PRETTY_FUNCTION__, err.c_str()); if ( (int) m_errors.size() < m_maxErrors ) { m_errors.Add( err ); } else if ( (int) m_errors.size() == m_maxErrors ) { m_errors.Add( _T("Error: too many error messages - ignoring further errors")); } // else if ( m_errors > m_maxErrors ) do nothing, thus ignore the error message } //! \overload AddError( const wxString& ) void wxJSONReader::AddError( const wxString& fmt, const wxString& str ) { wxString s; s.Printf( fmt.c_str(), str.c_str() ); AddError( s ); } //! \overload AddError( const wxString& ) void wxJSONReader::AddError( const wxString& fmt, wxChar c ) { wxString s; s.Printf( fmt.c_str(), c ); AddError( s ); } //! Add a warning message to the warning's array /*! The warning description is as follows: \code Warning: line xxx, col xxx - <warning_description> \endcode Warning messages are generated by the parser when the JSON text that has been read is not well-formed but the error is not fatal and the parser recognizes the text as an extension to the JSON standard (see the parser's ctor for more info about wxJSON extensions). Note that the parser has to be constructed with a flag that indicates if each individual wxJSON extension is on. If the warning message is related to an extension that is not enabled in the parser's \c m_flag data member, this function calls AddError() and the warning message becomes an error message. The \c type parameter is one of the same constants that specify the parser's extensions. */ void wxJSONReader::AddWarning( int type, const wxString& msg ) { // if 'type' AND 'm_flags' == 1 than the extension is // ON. Otherwise it is OFF anf the function calls AddError() if ( ( type & m_flags ) == 0 ) { AddError( msg ); return; } wxString err; err.Printf( _T( "Warning: line %d, col %d - %s"), m_lineNo, m_colNo, msg.c_str() ); ::wxLogTrace( traceMask, _T("(%s) %s"), __PRETTY_FUNCTION__, err.c_str()); if ( (int) m_warnings.size() < m_maxErrors ) { m_warnings.Add( err ); } else if ( (int) m_warnings.size() == m_maxErrors ) { m_warnings.Add( _T("Error: too many warning messages - ignoring further warnings")); } // else do nothing, thus ignore the warning message } //! Skip all whitespaces. /*! The function reads characters from the input text and returns the first non-whitespace character read or -1 if EOF. Note that the function does not rely on the \b isspace function of the C library but checks the space constants: space, TAB and LF. */ int wxJSONReader::SkipWhiteSpace() { int ch; do { ch = ReadChar(); if ( ch < 0 ) { break; } } while ( ch == ' ' || ch == '\n' || ch == '\t' ); ::wxLogTrace( traceMask, _T("(%s) end whitespaces line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); return ch; } //! Skip a comment /*! The function is called by DoRead() when a '/' (slash) character is read from the input stream assuming that a C/C++ comment is starting. Returns the first character that follows the comment or -1 on EOF. The function also adds a warning message because comments are not valid JSON text. The function also stores the comment, if any, in the \c m_comment data member: it can be used by the DoRead() function if comments have to be stored in the value they refer to. */ int wxJSONReader::SkipComment() { static const wxChar* warn = _T("Comments may be tolerated in JSON text but they are not part of JSON syntax"); // if it is a comment, then a warning is added to the array // otherwise it is an error: values cannot start with a '/' int ch = ReadChar(); if ( ch < 0 ) { return -1; } ::wxLogTrace( storeTraceMask, _T("(%s) start comment line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); if ( ch == '/' ) { // C++ comment, read until end-of-line AddWarning( wxJSONREADER_ALLOW_COMMENTS, warn ); m_commentLine = m_lineNo; m_comment.append( _T("//") ); while ( ch != '\n' && ch >= 0 ) { ch = ReadChar(); m_comment.append( 1, ch ); } // now ch contains the '\n' character; } else if ( ch == '*' ) { // C-style comment AddWarning(wxJSONREADER_ALLOW_COMMENTS, warn ); m_commentLine = m_lineNo; m_comment.append( _T("/*") ); while ( ch >= 0 ) { ch = ReadChar(); m_comment.append( 1, ch ); if ( ch == '*' && PeekChar() == '/' ) { m_comment.append( 1, '/' ); break; } } // now ch contains '*' followed by '/'; we read two characters ch = ReadChar(); ch = ReadChar(); } else { // it is not a comment, return the character next the first '/' AddError( _T( "Strange '/' (did you want to insert a comment?)")); // we read until end-of-line OR end of C-style comment OR EOF // because a '/' should be a start comment while ( ch >= 0 ) { ch = ReadChar(); if ( ch == '*' && PeekChar() == '/' ) { break; } if ( ch == '\n' ) { break; } } ch = ReadChar(); } ::wxLogTrace( traceMask, _T("(%s) end comment line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); ::wxLogTrace( storeTraceMask, _T("(%s) end comment line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); ::wxLogTrace( storeTraceMask, _T("(%s) comment=%s"), __PRETTY_FUNCTION__, m_comment.c_str()); return ch; } //! Read a string value /*! The function reads a string value from input stream and it is called by the \c DoRead() function when it enconters the double quote characters. The function read all characters up to the next double quotes unless it is escaped. Also, the function recognizes the escaped characters defined in the JSON syntax. The string is also stored in the provided wxJSONValue argument provided that it is empty or it contains a string value. This is because the parser class recognizes multi-line strings like the following one: \code [ "line-1\n" "line-2\n" "line-3\n" ] \endcode Because of the lack of the value separator (,) the parser assumes that the string was split into several double-quoted strings. If the value does not contain a string then an error is reported. Splitted strings cause the parser to report a warning. */ int wxJSONReader::ReadString( wxJSONValue& val ) { long int hex; // the char read is the opening qoutes (") wxString s; int ch = ReadChar(); while ( ch > 0 && ch != '\"' ) { if ( ch == '\\' ) { // an escape sequence ch = ReadChar(); switch ( ch ) { case -1 : break; case 't' : s.append( 1, '\t' ); break; case 'n' : s.append( 1, '\n' ); break; case 'b' : s.append( 1, '\b' ); break; case 'r' : s.append( 1, '\r' ); break; case '\"' : s.append( 1, '\"' ); break; case '\\' : s.append( 1, '\\' ); break; case '/' : s.append( 1, '/' ); break; case '\f' : s.append( 1, '\f' ); break; case 'u' : ch = ReadUnicode( hex ); if ( hex < 0 ) { AddError( _T( "unicode sequence must contain 4 hex digits")); } else { // append the unicode escaped character to the string 's' AppendUnicodeSequence( s, hex ); } // many thanks to Bryan Ashby who discovered this bug continue; // break; default : AddError( _T( "Unknow escaped character \'\\%c\'"), ch ); } } else { // we have read a non-escaped character so we have to append it to // the string. note that in ANSI builds we have to convert the char // to a locale dependent charset; if the char cannot be converted, // store its unicode escape sequence #if defined( wxJSON_USE_UNICODE ) s.Append( (wxChar) ch, 1 ); #else wchar_t wchar = ch; char buffer[5]; size_t len = wxConvLibc.FromWChar( buffer, 5, &wchar, 1 ); if ( len != wxCONV_FAILED ) { s.Append( buffer[0], 1 ); } else { snprintf( buffer, 10, _T("\\u%04X" ), ch ); s.Append( buffer ); } #endif } ch = ReadChar(); // read the next char until closing quotes } ::wxLogTrace( traceMask, _T("(%s) line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); ::wxLogTrace( traceMask, _T("(%s) string read=%s"), __PRETTY_FUNCTION__, s.c_str() ); ::wxLogTrace( traceMask, _T("(%s) value=%s"), __PRETTY_FUNCTION__, val.AsString().c_str() ); // now assign the string to the JSON-value 'value' // must check that: // 'value' is empty // 'value' is a string; concatenate it but emit warning if ( val.IsEmpty() ) { ::wxLogTrace( traceMask, _T("(%s) assigning the string to value"), __PRETTY_FUNCTION__ ); val = s ; } else if ( val.IsString() ) { AddWarning( wxJSONREADER_MULTISTRING, _T("Multiline strings are not allowed by JSON syntax") ); ::wxLogTrace( traceMask, _T("(%s) concatenate the string to value"), __PRETTY_FUNCTION__ ); val.Cat( s ); } else { AddError( _T( "String value \'%s\' cannot follow another value"), s ); } // store the input text's line number when the string was stored in 'val' val.SetLineNo( m_lineNo ); // read the next char after the closing quotes and returns it if ( ch > 0 ) { ch = ReadChar(); } return ch; } //! Reads a token string /*! This function is called by the ReadValue() when the first character encontered is not a special char and it is not a string. It stores the token in the provided string argument and returns the next character read which is a whitespace or a special JSON character. A token cannot include \e unicode \e escaped \e sequences so this function does not try to interpret such sequences. */ int wxJSONReader::ReadToken( int ch, wxString& s ) { int nextCh = ch; while ( nextCh >= 0 ) { switch ( nextCh ) { case ' ' : case ',' : case ':' : case '[' : case ']' : case '{' : case '}' : case '\t' : case '\n' : case '\r' : case '\b' : ::wxLogTrace( traceMask, _T("(%s) line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); ::wxLogTrace( traceMask, _T("(%s) token read=%s"), __PRETTY_FUNCTION__, s.c_str() ); return nextCh; break; default : #if defined( wxJSON_USE_UNICODE ) s.Append( (wxChar) nextCh, 1 ); #else // In ANSI builds we have to convert the char // to a locale dependent charset; if the char cannot be converted, // store its unicode escape sequence wchar_t wchar = nextCh; char buffer[10]; size_t len = wxConvLibc.FromWChar( buffer, 10, &wchar, 1 ); if ( len != wxCONV_FAILED ) { s.Append( buffer[0], 1 ); } else { snprintf( buffer, 10, _T("\\u%04x" ), ch ); s.Append( buffer ); } #endif break; } // read the next character nextCh = ReadChar(); } ::wxLogTrace( traceMask, _T("(%s) EOF on line=%d col=%d"), __PRETTY_FUNCTION__, m_lineNo, m_colNo ); ::wxLogTrace( traceMask, _T("(%s) EOF - token read=%s"), __PRETTY_FUNCTION__, s.c_str() ); return nextCh; } //! Read a value from input stream /*! The function is called by DoRead() when it enconters a char that is not a special char nor a double-quote. It assumes that the string is a numeric value or a 'null' or a boolean value and stores it in the wxJSONValue object \c val. The function also checks that \c val is of type wxJSONTYPE_EMPTY otherwise an error is reported becasue a value cannot follow another value: maybe a (,) or (:) is missing. Returns the next character or -1 on EOF. */ int wxJSONReader::ReadValue( int ch, wxJSONValue& val ) { wxString s; int nextCh = ReadToken( ch, s ); ::wxLogTrace( traceMask, _T("(%s) value=%s"), __PRETTY_FUNCTION__, val.AsString().c_str() ); if ( !val.IsEmpty() ) { AddError( _T( "Value \'%s\' cannot follow a value: \',\' or \':\' missing?"), s ); return nextCh; } // variables used in the switch statement bool r; double d; // on 64-bits platforms, integers are stored in a wx(U)Int64 data type #if defined( wxJSON_64BIT_INT ) wxInt64 i64; wxUint64 ui64; #else unsigned long int ul; long int l; #endif // try to convert to a number if the token starts with a digit // or a sign character switch ( ch ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : // first try a signed integer, then a unsigned integer, then a double #if defined( wxJSON_64BIT_INT) r = Strtoll( s, &i64 ); ::wxLogTrace( traceMask, _T("(%s) convert to wxInt64 result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = i64; return nextCh; } #else r = s.ToLong( &l ); ::wxLogTrace( traceMask, _T("(%s) convert to int result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = (int) l; return nextCh; } #endif // try a unsigned integer #if defined( wxJSON_64BIT_INT) r = Strtoull( s, &ui64 ); ::wxLogTrace( traceMask, _T("(%s) convert to wxUint64 result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = ui64; return nextCh; } #else r = s.ToULong( &ul ); ::wxLogTrace( traceMask, _T("(%s) convert to int result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = (unsigned int) ul; return nextCh; } #endif // number is very large or it is in exponential notation, try double r = s.ToDouble( &d ); ::wxLogTrace( traceMask, _T("(%s) convert to double result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = d; return nextCh; } else { // the value is not syntactically correct AddError( _T( "Value \'%s\' is incorrect (did you forget quotes?)"), s ); return nextCh; } break; case '+' : // the plus sign forces a unsigned integer #if defined( wxJSON_64BIT_INT) r = Strtoull( s, &ui64 ); ::wxLogTrace( traceMask, _T("(%s) convert to wxUint64 result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = ui64; return nextCh; } #else r = s.ToULong( &ul ); ::wxLogTrace( traceMask, _T("(%s) convert to int result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = (unsigned int) ul; return nextCh; } #endif // number is very large or it is in exponential notation, try double r = s.ToDouble( &d ); ::wxLogTrace( traceMask, _T("(%s) convert to double result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = d; return nextCh; } else { // the value is not syntactically correct AddError( _T( "Value \'%s\' is incorrect (did you forget quotes?)"), s ); return nextCh; } break; case '-' : // try a signed integer, then a double #if defined( wxJSON_64BIT_INT) r = Strtoll( s, &i64 ); ::wxLogTrace( traceMask, _T("(%s) convert to wxInt64 result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = i64; return nextCh; } #else r = s.ToLong( &l ); ::wxLogTrace( traceMask, _T("(%s) convert to int result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = (int) l; return nextCh; } #endif // number is very large or it is in exponential notation, try double r = s.ToDouble( &d ); ::wxLogTrace( traceMask, _T("(%s) convert to double result=%d"), __PRETTY_FUNCTION__, r ); if ( r ) { // store the value val = d; return nextCh; } else { // the value is not syntactically correct AddError( _T( "Value \'%s\' is incorrect (did you forget quotes?)"), s ); return nextCh; } break; // if it is not a number than try the literals // JSON syntax states that constant must be lowercase // but this parser tolerate mixed-case literals but // reports a warning. default: if ( s == _T("null") ) { val.SetType( wxJSONTYPE_NULL ); ::wxLogTrace( traceMask, _T("(%s) value = NULL"), __PRETTY_FUNCTION__ ); return nextCh; } else if ( s.CmpNoCase( _T( "null" )) == 0 ) { ::wxLogTrace( traceMask, _T("(%s) value = NULL"), __PRETTY_FUNCTION__ ); AddWarning( wxJSONREADER_CASE, _T( "the \'null\' literal must be lowercase" )); val.SetType( wxJSONTYPE_NULL ); return nextCh; } else if ( s == _T("true") ) { ::wxLogTrace( traceMask, _T("(%s) value = TRUE"), __PRETTY_FUNCTION__ ); val = true; return nextCh; } else if ( s.CmpNoCase( _T( "true" )) == 0 ) { ::wxLogTrace( traceMask, _T("(%s) value = TRUE"), __PRETTY_FUNCTION__ ); AddWarning( wxJSONREADER_CASE, _T( "the \'true\' literal must be lowercase" )); val = true; return nextCh; } else if ( s == _T("false") ) { ::wxLogTrace( traceMask, _T("(%s) value = FALSE"), __PRETTY_FUNCTION__ ); val = false; return nextCh; } else if ( s.CmpNoCase( _T( "false" )) == 0 ) { ::wxLogTrace( traceMask, _T("(%s) value = FALSE"), __PRETTY_FUNCTION__ ); AddWarning( wxJSONREADER_CASE, _T( "the \'false\' literal must be lowercase" )); val = false; return nextCh; } else { AddError( _T( "Unrecognized literal \'%s\' (did you forget quotes?)"), s ); return nextCh; } } } //! Read a 4-hex-digit unicode character. /*! The function is called by ReadString() when the \b \\u sequence is encontered; the sequence introduces a unicode character. The function reads four chars from the input text by calling ReadChar() four times: if -1( EOF) is encontered before reading four chars, -1 is also returned and no conversion takes place. The function tries to convert the 4-hex-digit sequence in an integer which is returned in the \ hex parameter. If the string cannot be converted, the function stores -1 in \c hex and reports an error. Returns the character after the hex sequence or -1 if EOF or if the four characters cannot be converted to a hex number. */ int wxJSONReader::ReadUnicode( long int& hex ) { wxString s; int ch; for ( int i = 0; i < 4; i++ ) { ch = ReadChar(); if ( ch < 0 ) { return ch; } s.append( 1, (wxChar) ch ); } bool r = s.ToLong( &hex, 16 ); if ( !r ) { hex = -1; } ::wxLogTrace( traceMask, _T("(%s) unicode sequence=%s code=%d"), __PRETTY_FUNCTION__, s.c_str(), (int) hex ); ch = ReadChar(); return ch; } //! Store the comment string in the value it refers to. /*! The function searches a suitable value object for storing the comment line that was read by the parser and temporarly stored in \c m_comment. The function searches the three values pointed to by: \li \c m_next \li \c m_current \li \c m_lastStored and checks the comment flag (BEFORE or AFTER). Note that the comment line is only stored if the wxJSONREADER_STORE_COMMENTS flag was used when the parser object was constructed; otherwise, the function does nothing and immediatly returns. Also note that if the comment line has to be stored in a value and the function cannot find a suitable value to add the comment line to, an error is reported (note: not a warning but an error). */ void wxJSONReader::StoreComment( const wxJSONValue* parent ) { ::wxLogTrace( storeTraceMask, _T("(%s) m_comment=%s"), __PRETTY_FUNCTION__, m_comment.c_str()); ::wxLogTrace( storeTraceMask, _T("(%s) m_flags=%d m_commentLine=%d"), __PRETTY_FUNCTION__, m_flags, m_commentLine ); ::wxLogTrace( storeTraceMask, _T("(%s) m_current=%p"), __PRETTY_FUNCTION__, m_current ); ::wxLogTrace( storeTraceMask, _T("(%s) m_next=%p"), __PRETTY_FUNCTION__, m_next ); ::wxLogTrace( storeTraceMask, _T("(%s) m_lastStored=%p"), __PRETTY_FUNCTION__, m_lastStored ); // first check if the 'store comment' bit is on if ( (m_flags & wxJSONREADER_STORE_COMMENTS) == 0 ) { m_comment.clear(); return; } // check if the comment is on the same line of one of the // 'current', 'next' or 'lastStored' value if ( m_current != 0 ) { ::wxLogTrace( storeTraceMask, _T("(%s) m_current->lineNo=%d"), __PRETTY_FUNCTION__, m_current->GetLineNo() ); if ( m_current->GetLineNo() == m_commentLine ) { ::wxLogTrace( storeTraceMask, _T("(%s) comment added to \'m_current\' INLINE"), __PRETTY_FUNCTION__ ); m_current->AddComment( m_comment, wxJSONVALUE_COMMENT_INLINE ); m_comment.clear(); return; } } if ( m_next != 0 ) { ::wxLogTrace( storeTraceMask, _T("(%s) m_next->lineNo=%d"), __PRETTY_FUNCTION__, m_next->GetLineNo() ); if ( m_next->GetLineNo() == m_commentLine ) { ::wxLogTrace( storeTraceMask, _T("(%s) comment added to \'m_next\' INLINE"), __PRETTY_FUNCTION__ ); m_next->AddComment( m_comment, wxJSONVALUE_COMMENT_INLINE ); m_comment.clear(); return; } } if ( m_lastStored != 0 ) { ::wxLogTrace( storeTraceMask, _T("(%s) m_lastStored->lineNo=%d"), __PRETTY_FUNCTION__, m_lastStored->GetLineNo() ); if ( m_lastStored->GetLineNo() == m_commentLine ) { ::wxLogTrace( storeTraceMask, _T("(%s) comment added to \'m_lastStored\' INLINE"), __PRETTY_FUNCTION__ ); m_lastStored->AddComment( m_comment, wxJSONVALUE_COMMENT_INLINE ); m_comment.clear(); return; } } // if comment is BEFORE, store the comment in the 'm_next' // or 'm_current' value // if comment is AFTER, store the comment in the 'm_lastStored' // or 'm_current' value if ( m_flags & wxJSONREADER_COMMENTS_AFTER ) { // comment AFTER if ( m_current ) { if ( m_current == parent || m_current->IsEmpty()) { AddError( _T("Cannot find a value for storing the comment (flag AFTER)")); } else { ::wxLogTrace( storeTraceMask, _T("(%s) comment added to m_current (AFTER)"), __PRETTY_FUNCTION__ ); m_current->AddComment( m_comment, wxJSONVALUE_COMMENT_AFTER ); } } else if ( m_lastStored ) { ::wxLogTrace( storeTraceMask, _T("(%s) comment added to m_lastStored (AFTER)"), __PRETTY_FUNCTION__ ); m_lastStored->AddComment( m_comment, wxJSONVALUE_COMMENT_AFTER ); } else { ::wxLogTrace( storeTraceMask, _T("(%s) cannot find a value for storing the AFTER comment"), __PRETTY_FUNCTION__ ); AddError(_T("Cannot find a value for storing the comment (flag AFTER)")); } } else { // comment BEFORE can only be added to the 'next' value if ( m_next ) { ::wxLogTrace( storeTraceMask, _T("(%s) comment added to m_next (BEFORE)"), __PRETTY_FUNCTION__ ); m_next->AddComment( m_comment, wxJSONVALUE_COMMENT_BEFORE ); } else { // cannot find a value for storing the comment AddError(_T("Cannot find a value for storing the comment (flag BEFORE)")); } } m_comment.clear(); } //! Return the number of bytes that contains a unicode char in various encodings /*! This function was used by the GetChar() function in Unicode builds when the character has to be read from a stream object and returns the number of bytes that has to be read from the stream in order to convert them to a wide character. For locale dependent formats, the number of bytes is always 1, for Unicode formats it can be 2 (UCS-2) or 4 (UCS-4) or a variable number of bytes if the encoding format is UTF-8. The function is now no more used because input streams can only be encoded in UTF-8 format so it was substituted by the UTF8NumBytes() function. Calling this function always cause the program to abort for an ASSERTION failure. */ int wxJSONReader::NumBytes() { // always fails wxASSERT( 0 ); return 0; } //! Compute the number of bytes that makes a UTF-8 encoded wide character. /*! The function counts the number of '1' bit in the character \c ch and returns it. The UTF-8 encoding specifies the number of bytes needed by a wide character by coding it in the first byte. See below. Note that if the character does not contain a valid UTF-8 encoding the function returns -1. \code UCS-4 range (hex.) UTF-8 octet sequence (binary) ------------------- ----------------------------- 0000 0000-0000 007F 0xxxxxxx 0000 0080-0000 07FF 110xxxxx 10xxxxxx 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx 0001 0000-001F FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 0020 0000-03FF FFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 0400 0000-7FFF FFFF 1111110x 10xxxxxx ... 10xxxxxx \endcode */ int wxJSONReader::UTF8NumBytes( char ch ) { int num = 0; // the counter of '1' bits for ( int i = 0; i < 8; i++ ) { if ( (ch & 0x80) == 0 ) { break; } ++num; ch = ch << 1; } // note that if the char contains more than six '1' bits it is not // a valid UTF-8 encoded character if ( num > 6 ) { num = -1; } else if ( num == 0 ) { num = 1; } return num; } //! The function appends the wide character to the string value /*! This function is called by \c ReadString() when a \e unicode \e escaped \e sequence is read from the input text as for example (the greek letter alpha): \code \u03B1 \endcode In unicode mode, the function just appends the wide character code stored in \c hex to the string \c s. In ANSI mode, the function converts the wide character code to the corresponding character if it is convertible using the locale dependent character set. If the wide char cannot be converted, the function appends the \e unicode \e escape \e sequence to the string \c s. Returns ZERO if the character was not converted to a unicode escape sequence. */ int wxJSONReader::AppendUnicodeSequence( wxString& s, int hex ) { int r = 0; #ifndef wxJSON_USE_UNICODE wchar_t ch = hex; #endif #if defined( wxJSON_USE_UNICODE ) s.append( 1, (wxChar) hex ); #else char buffer[10]; size_t len = wxConvLibc.FromWChar( buffer, 10, &ch, 1 ); if ( len != wxCONV_FAILED ) { s.append( 1, buffer[0] ); } else { snprintf( buffer, 10, _T("\\u%04X"), hex ); s.append( buffer ); r = 1; } #endif return r; } #if defined( wxJSON_64BIT_INT ) // Converts a decimal string to a 64-bit signed integer /* This is an undcumented function which implements a simple variant of the 'strtoll' C-library function. I needed this implementation because the wxString::To(U)LongLong function does not work on my system: \li GNU/Linux Fedora Core 6 \li GCC version 4.1.1 \li libc.so.6 The wxWidgets library (actually I have installed version 2.8.7) relies on 'strtoll' in order to do the conversion from a string to a long long integer but, in fact, it does not work because the 'wxHAS_STRTOLL' macro is not defined on my system. Note that this implementation is not a complete substitute of the strtoll function because it only converts decimal strings (only base 10 is implemented). */ bool wxJSONReader::Strtoll( const wxString& str, wxInt64* i64 ) { wxChar sign = ' '; wxUint64 ui64; bool r = DoStrto_ll( str, &ui64, &sign ); // check overflow for signed long long switch ( sign ) { case '-' : if ( ui64 > (wxUint64) LLONG_MAX + 1 ) { r = false; } else { *i64 = (wxInt64) (ui64 * -1); } break; // case '+' : default : if ( ui64 > LLONG_MAX ) { r = false; } else { *i64 = (wxInt64) ui64; } break; } return r; } bool wxJSONReader::Strtoull( const wxString& str, wxUint64* ui64 ) { wxChar sign = ' '; bool r = DoStrto_ll( str, ui64, &sign ); if ( sign == '-' ) { r = false; } return r; } bool wxJSONReader::DoStrto_ll( const wxString& str, wxUint64* ui64, wxChar* sign ) { // the conversion is done by multiplying the individual digits // in reverse order to the corresponding power of 10 // // 10's power: 987654321.9876543210 // // LLONG_MAX: 9223372036854775807 // LLONG_MIN: -9223372036854775808 // ULLONG_MAX: 18446744073709551615 // // the function does not take into account the sign: only a // unsigned long long int is returned int maxDigits = 20; // 20 + 1 (for the sign) wxUint64 power10[] = { wxULL(1), wxULL(10), wxULL(100), wxULL(1000), wxULL(10000), wxULL(100000), wxULL(1000000), wxULL(10000000), wxULL(100000000), wxULL(1000000000), wxULL(10000000000), wxULL(100000000000), wxULL(1000000000000), wxULL(10000000000000), wxULL(100000000000000), wxULL(1000000000000000), wxULL(10000000000000000), wxULL(100000000000000000), wxULL(1000000000000000000), wxULL(10000000000000000000) }; wxUint64 temp1 = wxULL(0); // the temporary converted integer int strLen = str.length(); if ( strLen == 0 ) { // an empty string is converted to a ZERO value: the function succeeds *ui64 = wxLL(0); return true; } int index = 0; wxChar ch = str[0]; if ( ch == '+' || ch == '-' ) { *sign = ch; ++index; ++maxDigits; } if ( strLen > maxDigits ) { return false; } // check the overflow: check the string length and the individual digits // of the string; the overflow is checked for unsigned long long if ( strLen == maxDigits ) { wxString uLongMax( _T("18446744073709551615")); int j = 0; for ( int i = index; i < strLen - 1; i++ ) { ch = str[i]; if ( ch < '0' || ch > '9' ) { return false; } if ( ch > uLongMax[j] ) { return false; } if ( ch < uLongMax[j] ) { break; } ++j; } } // get the digits in the reverse order and multiply them by the // corresponding power of 10 int exponent = 0; for ( int i = strLen - 1; i >= index; i-- ) { wxChar ch = str[i]; if ( ch < '0' || ch > '9' ) { return false; } ch = ch - '0'; // compute the new temporary value temp1 += ch * power10[exponent]; ++exponent; } *ui64 = temp1; return true; } #endif // defined( wxJSON_64BIT_INT ) /* { } */
[ [ [ 1, 1948 ] ] ]
f0ab2e346df6cbcea05957f00719b8286502bd30
e537c879c7f7777d649121eee4b3f1fbff1e07c8
/modules/LogManGui/src/LogManGui.cpp
97020a4ed2d8b9c1008601fc09d658971a33a31a
[]
no_license
SymbiSoft/logman-for-symbian
1181007a28a6d798496bb7e1107d1bce366becdd
cd0de1cf1afef03df09622e3d1db6c8bddbd324b
refs/heads/master
2021-01-10T15:04:55.032082
2010-05-11T13:26:07
2010-05-11T13:26:07
48,182,126
0
0
null
null
null
null
UTF-8
C++
false
false
445
cpp
// INCLUDE FILES #include <eikstart.h> #include "LogManGui_Application.h" /** * Create application class */ LOCAL_C CApaApplication* NewApplication() { return new CLoggingServerGuiApplication; } /** * A normal Symbian OS executable provides an E32Main() function which is * called by the operating system to start the program. */ GLDEF_C TInt E32Main() { return EikStart::RunApplication( NewApplication ); }
[ "jtoivola@localhost" ]
[ [ [ 1, 21 ] ] ]
289bb7192440611e68b6e79b12348809b12da259
32a15c120bd40f93cfcac0ad95ef8370a187ec98
/sqlite3/CppSQLite3.h
ecc893eda536af1bbe79dd786d5b0bcaf64a9a05
[]
no_license
sidoh/Join-Compression
1d9e3101e1568ab80f436e292a9e5f51cac5e190
aa3df4634664506d60cbb5fe2ff9bdb06481b22a
refs/heads/master
2021-01-19T14:04:29.582154
2011-10-03T01:09:00
2011-10-03T01:09:00
2,027,194
0
0
null
null
null
null
UTF-8
C++
false
false
8,219
h
//////////////////////////////////////////////////////////////////////////////// // CppSQLite3 - A C++ wrapper around the SQLite3 embedded database library. // // Copyright (c) 2004..2007 Rob Groves. All Rights Reserved. [email protected] // // Permission to use, copy, modify, and distribute this software and its // documentation for any purpose, without fee, and without a written // agreement, is hereby granted, provided that the above copyright notice, // this paragraph and the following two paragraphs appear in all copies, // modifications, and distributions. // // IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST // PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, // EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A // PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF // ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO OBLIGATION // TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. // // V3.0 03/08/2004 -Initial Version for sqlite3 // // V3.1 16/09/2004 -Implemented getXXXXField using sqlite3 functions // -Added CppSQLiteDB3::tableExists() // // V3.2 01/07/2005 -Fixed execScalar to handle a NULL result // 12/07/2007 -Added CppSQLiteDB::IsAutoCommitOn() // -Added int64 functions to CppSQLite3Query // -Added Name based parameter binding to CppSQLite3Statement. //////////////////////////////////////////////////////////////////////////////// #ifndef _CppSQLite3_H_ #define _CppSQLite3_H_ #include "sqlite3.h" #include <stdio.h> #include <stddef.h> #define CPPSQLITE_ERROR 1000 class CppSQLite3Exception { public: CppSQLite3Exception(const int nErrCode, char* szErrMess, bool bDeleteMsg=true); CppSQLite3Exception(const CppSQLite3Exception& e); virtual ~CppSQLite3Exception(); const int errorCode() { return mnErrCode; } const char* errorMessage() { return mpszErrMess; } static const char* errorCodeAsString(int nErrCode); private: int mnErrCode; char* mpszErrMess; }; class CppSQLite3Buffer { public: CppSQLite3Buffer(); ~CppSQLite3Buffer(); const char* format(const char* szFormat, ...); operator const char*() { return mpBuf; } void clear(); private: char* mpBuf; }; class CppSQLite3Binary { public: CppSQLite3Binary(); ~CppSQLite3Binary(); void setBinary(const unsigned char* pBuf, int nLen); void setEncoded(const unsigned char* pBuf); const unsigned char* getEncoded(); const unsigned char* getBinary(); int getBinaryLength(); unsigned char* allocBuffer(int nLen); void clear(); private: unsigned char* mpBuf; int mnBinaryLen; int mnBufferLen; int mnEncodedLen; bool mbEncoded; }; class CppSQLite3Query { public: CppSQLite3Query(); CppSQLite3Query(const CppSQLite3Query& rQuery); CppSQLite3Query(sqlite3* pDB, sqlite3_stmt* pVM, bool bEof, bool bOwnVM=true); CppSQLite3Query& operator=(const CppSQLite3Query& rQuery); virtual ~CppSQLite3Query(); const int numFields() const; int fieldIndex(const char* szField); const char* fieldName(int nCol); const char* fieldDeclType(int nCol); int fieldDataType(int nCol); const char* fieldValue(int nField); const char* fieldValue(const char* szField); int getIntField(int nField, int nNullValue=0); int getIntField(const char* szField, int nNullValue=0); sqlite_int64 getInt64Field(int nField, sqlite_int64 nNullValue=0); sqlite_int64 getInt64Field(const char* szField, sqlite_int64 nNullValue=0); double getFloatField(int nField, double fNullValue=0.0); double getFloatField(const char* szField, double fNullValue=0.0); const char* getStringField(int nField, const char* szNullValue=""); const char* getStringField(const char* szField, const char* szNullValue=""); const unsigned char* getBlobField(int nField, int& nLen); const unsigned char* getBlobField(const char* szField, int& nLen); bool fieldIsNull(int nField); bool fieldIsNull(const char* szField); bool eof(); void nextRow(); void finalize(); private: const void checkVM() const; sqlite3* mpDB; sqlite3_stmt* mpVM; bool mbEof; int mnCols; bool mbOwnVM; }; class CppSQLite3Table { public: CppSQLite3Table(); CppSQLite3Table(const CppSQLite3Table& rTable); CppSQLite3Table(char** paszResults, int nRows, int nCols); virtual ~CppSQLite3Table(); CppSQLite3Table& operator=(const CppSQLite3Table& rTable); int numFields(); int numRows(); const char* fieldName(int nCol); const char* fieldValue(int nField); const char* fieldValue(const char* szField); int getIntField(int nField, int nNullValue=0); int getIntField(const char* szField, int nNullValue=0); double getFloatField(int nField, double fNullValue=0.0); double getFloatField(const char* szField, double fNullValue=0.0); const char* getStringField(int nField, const char* szNullValue=""); const char* getStringField(const char* szField, const char* szNullValue=""); bool fieldIsNull(int nField); bool fieldIsNull(const char* szField); void setRow(int nRow); void finalize(); private: void checkResults(); int mnCols; int mnRows; int mnCurrentRow; char** mpaszResults; }; class CppSQLite3Statement { public: CppSQLite3Statement(); CppSQLite3Statement(const CppSQLite3Statement& rStatement); CppSQLite3Statement(sqlite3* pDB, sqlite3_stmt* pVM); virtual ~CppSQLite3Statement(); CppSQLite3Statement& operator=(const CppSQLite3Statement& rStatement); int execDML(); CppSQLite3Query execQuery(); void bind(int nParam, const char* szValue); void bind(int nParam, const int nValue); void bind(int nParam, const double dwValue); void bind(int nParam, const unsigned char* blobValue, int nLen); void bindNull(int nParam); int bindParameterIndex(const char* szParam); void bind(const char* szParam, const char* szValue); void bind(const char* szParam, const int nValue); void bind(const char* szParam, const double dwValue); void bind(const char* szParam, const unsigned char* blobValue, int nLen); void bindNull(const char* szParam); void reset(); void finalize(); private: void checkDB(); void checkVM(); sqlite3* mpDB; sqlite3_stmt* mpVM; }; class CppSQLite3DB { public: CppSQLite3DB(); virtual ~CppSQLite3DB(); void open(const char* szFile); void close(); bool tableExists(const char* szTable); int execDML(const char* szSQL); CppSQLite3Query execQuery(const char* szSQL); int execScalar(const char* szSQL, int nNullValue=0); CppSQLite3Table getTable(const char* szSQL); CppSQLite3Statement compileStatement(const char* szSQL); sqlite_int64 lastRowId(); void interrupt() { sqlite3_interrupt(mpDB); } void setBusyTimeout(int nMillisecs); static const char* SQLiteVersion() { return SQLITE_VERSION; } static const char* SQLiteHeaderVersion() { return SQLITE_VERSION; } static const char* SQLiteLibraryVersion() { return sqlite3_libversion(); } static int SQLiteLibraryVersionNumber() { return sqlite3_libversion_number(); } bool IsAutoCommitOn(); private: CppSQLite3DB(const CppSQLite3DB& db); CppSQLite3DB& operator=(const CppSQLite3DB& db); sqlite3_stmt* compile(const char* szSQL); void checkDB(); sqlite3* mpDB; int mnBusyTimeoutMs; }; #endif
[ [ [ 1, 326 ] ] ]
f97359e6ceae5bd5420533d7f15d476515c514e0
cd3cb866cf33bdd9584d08f4d5904123c7d93da6
/filemerger.h
70cd4afba81794cb06e5db6640553f6f32bb62e4
[]
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
1,311
h
#ifndef FILEMERGER_H #define FILEMERGER_H #include <QObject> #include "files/tmfile.h" #include "files/glossaryfile.h" class FileMerger : public QObject { Q_OBJECT public: explicit FileMerger(QObject *parent = 0); virtual void findInnerConflicts(GlossaryFile* it); virtual void findConflictsInContext(GlossaryFile* it, GlossaryFile* context); inline unsigned duplicatedCount() const { return _duplicatedCount; } inline unsigned conflictsCount() const { return _conflictsCount; } inline unsigned fuzzyCount() const { return _fuzzyCount; } inline void setFuzzySearch(bool f) { _fuzzySearch = f; } inline bool fuzzySearch() const { return _fuzzySearch; } signals: void duplicatedCount(unsigned c); public slots: void initCounters(); /** * trzeba pamietac o tym, zeby oba parametry byly tego samego typu - ale moze dzialac chyba tez przy roznych typach, * tylko wtedy zrobi sie mieszany plik. */ virtual GlossaryFile* mergeFiles(GlossaryFile* one, GlossaryFile* two) const; private: void findDuplicated(const FuzzyStrings& key, GlossaryFile *it); unsigned _duplicatedCount; unsigned _conflictsCount; unsigned _fuzzyCount; bool _fuzzySearch; }; #endif // FILEMERGER_H
[ "benkopolis@ce349ab3-abbd-076b-ff20-4646c42d6692" ]
[ [ [ 1, 48 ] ] ]
9d163fa72223affd5639cddc8c1652efe25e37d5
a0155e192c9dc2029b231829e3db9ba90861f956
/Libs/mwnlm/Libraries/Runtime/(Sources)/onetimeinit.cpp
b6c08ce34dba982359093079bdaddd13269ffbcd
[]
no_license
zeha/mailfilter
d2de4aaa79bed2073cec76c93768a42068cfab17
898dd4d4cba226edec566f4b15c6bb97e79f8001
refs/heads/master
2021-01-22T02:03:31.470739
2010-08-12T23:51:35
2010-08-12T23:51:35
81,022,257
0
0
null
null
null
null
UTF-8
C++
false
false
4,952
cpp
#define NDEBUG #include <stdlib.h> #include <string.h> #include <CPlusLib.h> /* 3.3.2 One-time Construction API As described in Section 2.8, function-scope static objects have associated guard variables used to support the requirement that they be initialized exactly once, the first time the scope declaring them is entered. An implementation that does not anticipate supporting multi-threading may simply check the low-order byte of that guard variable, initializing if and only if its value is zero, and then setting it to a non-zero value. However, an implementation intending to support automatically thread-safe, one-time initialization (as opposed to requiring explicit user control for thread safety) requires more control, and should use the following API to achieve interoperability with other such implementations. if ( obj_guard.first_byte == false ) { if ( __cxa_guard_acquire (obj_guard) ) { ... initialize the object ...; ... queue object destructor with __cxa_atexit() ...; __cxa_guard_release (obj_guard); } } <Functions described below> An implementation need not include the simple inline test of the initialization flag in the guard variable around the above sequence. If it does so, the cost of this scheme, when run single-threaded with minimal versions of the above functions, will be two extra function calls, each of them accessing the guard variable, the first time the scope is entered. An implementation supporting thread-safety on multiprocessor systems must also guarantee that references to the initialized object do not occur before the load of the initialization flag. On Itanium, this can be done by using a ld1.acq operation to load the flag. The intent of specifying an 8-byte structure for the guard variable, but only describing one byte of its contents, is to allow flexibility in the implementation of the API above. On systems with good small lock support, the second word might be used for a mutex lock. On others, it might identify (as a pointer or index) a more complex lock structure to use. */ typedef enum { NOT_INITIALIZED, INITIALIZED, BEING_INITIALIZED } RTState; typedef struct RTMutex { char flag; // 0 or 1 char pad[3]; volatile unsigned long state; } RTMutex; /* extern "C" int __cxa_guard_acquire ( __int64_t *guard_object ); The guard_object argument is the guard variable (see Section 2.8) associated with the object to be initialized. If it indicates that the object has been initialized already, return false (0) immediately. Otherwise, acquire a lock associated with the guard variable (possibly part of it, but unspecified by this ABI). If the object has now been initialized, release the lock and return false (0). If not, return true (1) without releasing the lock. */ inline unsigned long atomic_cmpxchg(volatile unsigned long *addr, unsigned long cmp, unsigned long src) { register unsigned long ret; asm { optimize mov ecx, addr mov eax, cmp mov edx, src lock cmpxchg dword ptr [ecx], edx mov ret, eax } return ret; } int __cdecl __cxa_guard_acquire ( long long *guard_object ) { RTMutex *m = (RTMutex *)guard_object; // the frontend already checked, but be sure if (m->flag || m->state == INITIALIZED) return 0; // acquire a spinlock if (NOT_INITIALIZED == atomic_cmpxchg(&m->state, NOT_INITIALIZED, BEING_INITIALIZED)) { // ready to initialize return 1; } else { // else, wait for other thread to complete while (m->state == BEING_INITIALIZED) /**/; // we know someone else initialized it or aborted return 0; } } /* extern "C" void __cxa_guard_release ( __int64_t *guard_object ); The guard_object argument is the guard variable (see Section 2.8) associated with the object being initialized. Set it to indicate that initialization is complete, release the associated lock (in that order), and return. */ void __cdecl __cxa_guard_release ( long long *guard_object ) { RTMutex *m = (RTMutex *)guard_object; // initialization complete m->flag = 1; m->state = INITIALIZED; } /* extern "C" void __cxa_guard_abort ( __int64_t *guard_object ); The guard_object argument is the guard variable (see Section 2.8) associated with an object being initialized. Set it to indicate that initialization is not complete, release the associated lock (in that order), and return. This routine is intended for use when the initialization raises an exception, which requires that initialization be attempted again by the next pass through the object's scope. */ void __cdecl __cxa_guard_abort ( long long *guard_object ) { RTMutex *m = (RTMutex *)guard_object; // initialization not complete m->flag = 0; m->state = NOT_INITIALIZED; } /* Change History * ejs 020819 Added one-time construction API */
[ [ [ 1, 160 ] ] ]
628ac11e9b9b63883e02f43f7159fbfbc7f44092
a9afa168fac234c3b838dd29af4a5966a6acb328
/RateCalculator/src/Customer.h
51a40b1303c6f128d70c3fa3a7e08775bf773772
[]
no_license
unclebob/tddrefcpp
38a4170c38f612c180a8b9e5bdb2ec9f8971832e
9124a6fad27349911658606392ba5730ff0d1e15
refs/heads/master
2021-01-25T07:34:57.626817
2010-05-10T20:01:39
2010-05-10T20:01:39
659,579
8
5
null
null
null
null
UTF-8
C++
false
false
418
h
#ifndef CUSTOMER_H #define CUSTOMER_H #include <vector> struct Site; struct Customer { enum customertype { consumer, business, industrial }; enum ratetype { lifeline, interruptable, oneHourNotice, territorial, UNDEFINED }; typedef std::vector < Site * > c_site; int address; int kwh; customertype type; ratetype rate, industrialRate; c_site sites; ~Customer(); }; #endif
[ [ [ 1, 26 ] ] ]
3ec6331733ea52fb701b8c584126bf5688e45067
65da00cc6f20a83dd89098bb22f8f93c2ff7419b
/HabuInput/Library/Source/Devices/Mouse.cpp
1700d9fd7a9f3ffda2c793d641eeed49073c3cda
[]
no_license
skevy/CSC-350-Assignment-5
8b7c42257972d71e3d0cd3e9566e88a1fdcce73c
8091a56694f4b5b8de7e278b64448d4f491aaef5
refs/heads/master
2021-01-23T11:49:35.653361
2011-04-20T02:20:06
2011-04-20T02:20:06
1,638,578
0
0
null
null
null
null
UTF-8
C++
false
false
17,262
cpp
//D***************************************************************************// // Mouse Class Implementation // // Created Aug 27, 2006 // By: Jeremy M Miller // // Copyright (c) 2006 Jeremy M Miller. All rights reserved. // This source code module, and all information, data, and algorithms // associated with it, are part of BlueHabu technology (tm). // // Usage of HabuInput is subject to the appropriate license agreement. // A proprietary/commercial licenses are available. ([email protected]) // // HabuInput 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. // // HabuInput 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 HabuThreads. If not, see <http://www.gnu.org/licenses/>. //***************************************************************************// #include "Devices\Mouse.hpp" //***************************************************************************// namespace HabuTech { //*************************************************************************// // Public // Constructor. Mouse::Mouse() { //-----------------------------------------------------------------------// // Initialize all data members to 0. It might be easier and quicker to // just use memset. mlCurrentPixel_X_Position = 0L; mlCurrentPixel_Y_Position = 0L; mlPreviousPixel_X_Position = 0L; mlPreviousPixel_Y_Position = 0L; mlWidth = 0L; mlHeight = 0L; mlUpperLimit = 0L; mlLowerLimit = 0L; mlLeftLimit = 0L; mlRightLimit = 0L; //-----------------------------------------------------------------------// } // End of Mouse::Mouse() //*************************************************************************// //*************************************************************************// // Public // Destructor. Mouse::~Mouse() { } // End of Mouse::~Mouse() //*************************************************************************// //*************************************************************************// // Private // This method will center the mouse relative to the window. void Mouse::Center() { SetCursorPos(mlLeftLimit + (this->mlWidth >> 1), mlUpperLimit + (this->mlHeight >> 1)); } // End of void Mouse::Center() //*************************************************************************// //*************************************************************************// // Private // This method will should be called everytime the windows postion has changed // so that offsets for the mouse can be updated. // Parameter 1: The parameter is the current rectangle of the window. If no // rectangle is passed to this method, the mthod will make a windows // call to find the dimesions and location of the window. void Mouse::SetWindowPosition(RECT* pRectangle) { //-----------------------------------------------------------------------// // This bool will be used if this method creates a rectangle object. // If this bool is true then we need to delete the object that is created. bool bCleanUp = false; //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // If no valid rectangle was passed inot this method; we neet to create one // and get the dimensions and the location of the window. if(pRectangle == NULL) { pRectangle = new RECT; // Set this bool to true so that we know that we need to delete // the rectangle created above bCleanUp = true; GetWindowRect(mhMainWindow, pRectangle); } //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Set the width and height of the window this->mlWidth = pRectangle->right - pRectangle->left; this->mlHeight = pRectangle->bottom - pRectangle->top; //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Set the limits of the window mlUpperLimit = pRectangle->top; mlLowerLimit = pRectangle->bottom - 1; mlLeftLimit = pRectangle->left; mlRightLimit = pRectangle->right - 1; //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // If we created the rectangle we need to delete it. if(bCleanUp) delete pRectangle; //-----------------------------------------------------------------------// } // End of void Mouse::SetWindowPosition(RECT* pRectangle) //*************************************************************************// //*************************************************************************// // Public // The below method uses a pointer from a the directinput interface to // create and initialze communication with the mouse using directinput. // This method also sets the mouse to be used via windows calls so that // pixel position information can be provided by this class. This method // is required by the Device base class. // Parameter 1: An establised pointer to a directinput interface. // Parameter 2: A valid window handle to which mouse movements need to be tracked // Return Value: If the method was unable to setup directinput for the mouse // this method will return false. Otherwise it will return true. // We assume that we can always use the mouse windows calls. bool Mouse::Initialize(IDirectInput8* pDirectInput, HWND hMainWindow) { //-----------------------------------------------------------------------// // Clear the current state of the mouse memset(&mMouseState, 0L, sizeof(mMouseState)); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Store the handle to window so that we can access the windows location // in the event it is moved or resized mhMainWindow = hMainWindow; //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Create the mouse device pDirectInput->CreateDevice(GUID_SysMouse, &mpMouse, 0); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Set Data Format and the cooperation level mpMouse-> SetDataFormat(&c_dfDIMouse2); mpMouse-> SetCooperativeLevel(mhMainWindow, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Aquire Device via directinput long lResult = mpMouse->Acquire(); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Set the get the latest window postions from the OS and set the cusor to // be in the center of the that window this->SetWindowPosition(); this->Center(); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // If we successfully acquired the mouse via directinput return true // otherwise return false. if(lResult == DI_OK) return true; return false; //-----------------------------------------------------------------------// } // End of bool Mouse::Initialize(IDirectInput8* pDirectInput, HWND hMainWindow) //*************************************************************************// //*************************************************************************// // Public // The below method will uninitialize and release the mouse from directinput. // This method is required by the Device base class. // Return Value: This method will return true if the release and uninitialization // was sucessful. Otherwise it will return false. bool Mouse::Uninitialize() { //-----------------------------------------------------------------------// // If the we attained a valid pointer for the mouse via directinput... if(this->mpMouse) { //---------------------------------------------------------------------// // ... release the mouse long lResult = this->mpMouse->Unacquire(); this->mpMouse->Release(); //---------------------------------------------------------------------// //---------------------------------------------------------------------// // If we sucessfully released the mouse return true. Otherwise return false. if(lResult == DI_OK) return true; //---------------------------------------------------------------------// } //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // We can only get here if we failed to release the mouse from directinput. // In that case return false. return false; //-----------------------------------------------------------------------// } // End of bool Mouse::Uninitialize() //*************************************************************************// //*************************************************************************// // Public // The below methods get the delta for their respective basis vector that is // reported by direct input. // Return Value: The delta/change in postion the mouse moved. float Mouse::Direct_DX() const { return (float)mMouseState.lX; } float Mouse::Direct_DY() const { return (float)mMouseState.lY; } float Mouse::Direct_DZ() const { return (float)mMouseState.lZ; } bool Mouse::LeftButton() const { return (mMouseState.rgbButtons[0] & 0x80); } bool Mouse::RightButton() const { return (mMouseState.rgbButtons[2] & 0x80); } //*************************************************************************// //*************************************************************************// // Public // The below methods get the delta for their respective basis vector that is // reported by windows in units of pixels. // Return Value: The delta/change in postion the mouse moved in pixels. long Mouse::Pixel_DX_Position() const { return this->mlCurrentPixel_X_Position - this->mlPreviousPixel_X_Position; } long Mouse::Pixel_DY_Position() const { return this->mlCurrentPixel_Y_Position - this->mlPreviousPixel_Y_Position; } //*************************************************************************// //*************************************************************************// // Public // The below methods get the relative (to the current windows) position // for their respective basis vector that is reported by windows in units // of pixels. // Return Value: The relative in postion the mouse moved in pixels long Mouse::Pixel_X_Position() const { return this->mlCurrentPixel_X_Position; } long Mouse::Pixel_Y_Position() const { return this->mlCurrentPixel_Y_Position; } //*************************************************************************// //*************************************************************************// // Public // Currently this method does nothing. A better name would be SetCursorImage // TODO: Implement this method bool Mouse::SetCursor(std::string strFileName) { return false; } // End of bool Mouse::SetCursor(std::string strFileName) //*************************************************************************// //*************************************************************************// // Public // This is method is required to poll the mouse and should be called once per // program loop. This method is required by the Device base class. void Mouse::Poll() { //-----------------------------------------------------------------------// // These object wil be used to get the current rectangle of the window and // the current point postion of the mouse. RECT oRectangle; POINT oPoint; //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // This method will get the mouse data from directinput. long lResult = this->mpMouse->GetDeviceState(sizeof(mMouseState), (void**)&mMouseState); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Get the current position and size of the window. GetWindowRect(mhMainWindow, &oRectangle); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // If the window size of position had changed... if((oRectangle.top != this->mlUpperLimit) || (oRectangle.left != this->mlLeftLimit) || (oRectangle.right != this->mlRightLimit) || (oRectangle.bottom != this->mlLowerLimit)) { // ... Update the windows position this->SetWindowPosition(&oRectangle); } //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // Get the position of the cursor GetCursorPos(&oPoint); //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // If the cursor position is within the bounds of the window... if((oPoint.y <= this->mlLowerLimit) && (oPoint.y >= this->mlUpperLimit) && (oPoint.x <= this->mlRightLimit) && (oPoint.x >= this->mlLeftLimit)) { // ... update the postion of the mouse //---------------------------------------------------------------------// // First we need to store the previous postion of the cursor so that deltas can be // derived. this->mlPreviousPixel_X_Position = this->mlCurrentPixel_X_Position; this->mlPreviousPixel_Y_Position = this->mlCurrentPixel_Y_Position; //---------------------------------------------------------------------// //---------------------------------------------------------------------// // Then set the current position of the mouse this->mlCurrentPixel_X_Position = oPoint.x - this->mlLeftLimit; this->mlCurrentPixel_Y_Position = oPoint.y - this->mlUpperLimit; //---------------------------------------------------------------------// } //-----------------------------------------------------------------------// else { //---------------------------------------------------------------------// // ... otherwise just set the current position from the previous valid postion. // This will ensure the deltas are zero. this->mlCurrentPixel_X_Position = this->mlPreviousPixel_X_Position; this->mlCurrentPixel_Y_Position = this->mlPreviousPixel_Y_Position; //---------------------------------------------------------------------// } //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // If we unsuccessful reading mouse data from directinput... if(lResult != DI_OK) { // ... try to reacquire the mouse memset(&mMouseState, 0L, sizeof(mMouseState)); mpMouse->Acquire(); }//-----------------------------------------------------------------------// } // End of void Mouse::Poll() //*************************************************************************// } // End of namespace HabuTech //***************************************************************************//
[ [ [ 1, 378 ] ] ]
78fabb61c69fe48ba2bfa7d37b195155190eef6e
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp
9f31c0b2e75fa8e430076a21178d06e797d6ac2b
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
3,424
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ BEGIN_JUCE_NAMESPACE //============================================================================== ProgressBar::ProgressBar (double& progress_) : progress (progress_), displayPercentage (true), lastCallbackTime (0) { currentValue = jlimit (0.0, 1.0, progress); } ProgressBar::~ProgressBar() { } //============================================================================== void ProgressBar::setPercentageDisplay (const bool shouldDisplayPercentage) { displayPercentage = shouldDisplayPercentage; repaint(); } void ProgressBar::setTextToDisplay (const String& text) { displayPercentage = false; displayedMessage = text; } void ProgressBar::lookAndFeelChanged() { setOpaque (findColour (backgroundColourId).isOpaque()); } void ProgressBar::colourChanged() { lookAndFeelChanged(); } void ProgressBar::paint (Graphics& g) { String text; if (displayPercentage) { if (currentValue >= 0 && currentValue <= 1.0) text << roundToInt (currentValue * 100.0) << '%'; } else { text = displayedMessage; } getLookAndFeel().drawProgressBar (g, *this, getWidth(), getHeight(), currentValue, text); } void ProgressBar::visibilityChanged() { if (isVisible()) startTimer (30); else stopTimer(); } void ProgressBar::timerCallback() { double newProgress = progress; const uint32 now = Time::getMillisecondCounter(); const int timeSinceLastCallback = (int) (now - lastCallbackTime); lastCallbackTime = now; if (currentValue != newProgress || newProgress < 0 || newProgress >= 1.0 || currentMessage != displayedMessage) { if (currentValue < newProgress && newProgress >= 0 && newProgress < 1.0 && currentValue >= 0 && currentValue < 1.0) { newProgress = jmin (currentValue + 0.0008 * timeSinceLastCallback, newProgress); } currentValue = newProgress; currentMessage = displayedMessage; repaint(); } } END_JUCE_NAMESPACE
[ "ow3nskip" ]
[ [ [ 1, 117 ] ] ]
981282bdca211037c6bc510d28a8c9b0d0163bd6
c267e416aba473054330378d18bc3cd172bbad21
/MouseEnhancer/CoreAudioApi/Release/测试.cpp
38391654fcbad967f4e22250f427435d6a77e975
[]
no_license
chenwp/shuax
c3b7dea72708ee539664ac8db1d9885e87fefed7
b13bea0aae7e252650f4c8f5df1b2a716455ef80
refs/heads/master
2021-04-26T16:43:25.168306
2011-10-22T15:09:37
2011-10-22T15:09:37
45,179,472
2
0
null
null
null
null
UTF-8
C++
false
false
1,260
cpp
/* void __declspec(dllexport)SetXPVolume( const DWORD dwVolume ); BOOL __declspec(dllexport)GetXPVolume( DWORD& dwVolume ); void __declspec(dllexport)SetVolumnVista( UINT nInputStep ); BOOL __declspec(dllexport)GetVolumnVista( UINT& uVol ); */ #include <windows.h> #include <stdio.h> int main() { typedef bool(__stdcall* GetVolumnVista)(UINT&); typedef void(__stdcall* SetVolumnVista)(UINT); typedef bool(__stdcall* GetXPVolume)(UINT&); typedef void(__stdcall* SetXPVolume)(UINT); HINSTANCE hInst = ::LoadLibrary("CoreAudioApi.dll"); if (hInst) { GetVolumnVista m_GetVolumnVista; SetVolumnVista m_SetVolumnVista; GetXPVolume m_GetXPVolume; SetXPVolume m_SetXPVolume; m_GetVolumnVista = (GetVolumnVista)GetProcAddress(hInst, "?GetVolumnVista@@YA_NAAI@Z"); m_SetVolumnVista = (SetVolumnVista)GetProcAddress(hInst, "?SetVolumnVista@@YAXI@Z"); m_GetXPVolume = (GetXPVolume)GetProcAddress(hInst, "?GetXPVolume@@YA_NAAI@Z"); m_SetXPVolume = (SetXPVolume)GetProcAddress(hInst, "?SetXPVolume@@YAXI@Z"); UINT x; m_GetVolumnVista(x); printf("%d\n", x); //x++; //m_SetVolumnVista(100); //m_GetVolumnVista(x); //printf("%d\n", x); getchar(); } return 0; }
[ [ [ 1, 45 ] ] ]
29f70d98f68bebbdea5f077b8a56324c59d16c3d
dc4b6ab7b120262779e29d8b2d96109517f35551
/Dialog/HandlerDlg.h
2822b9c16396c1deb936b3685b17cf0b425c6457
[]
no_license
cnsuhao/wtlhelper9
92daef29b61f95f44a10e3277d8835c2dd620616
681df3a014fc71597e9380b0a60bd3cd23e22efe
refs/heads/master
2021-07-17T19:59:07.143192
2009-05-18T14:24:48
2009-05-18T14:24:48
108,361,858
0
1
null
null
null
null
UTF-8
C++
false
false
5,619
h
//////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2004 Sergey Solozhentsev // Author: Sergey Solozhentsev e-mail: [email protected] // Product: WTL Helper // File: HandlerDlg.h // Created: 16.11.2004 8:55 // // Using this software in commercial applications requires an author // permission. The permission will be granted to everyone excluding the cases // when someone simply tries to resell the code. // This file may be redistributed by any means PROVIDING it is not sold for // profit without the authors written consent, and providing that this notice // and the authors name is included. // This file is provided "as is" with no expressed or implied warranty. The // author accepts no liability if it causes any damage to you or your computer // whatsoever. // //////////////////////////////////////////////////////////////////////////////// // HandlerDlg.h : Declaration of the CHandlerDlg #pragma once #include "../resource.h" #include "atllttmap.h" // CHandlerDlg class CHandlerDlg : public CDialogImpl<CHandlerDlg>, public CWinDataExchange<CHandlerDlg>, public CToolTipMapImpl<CHandlerDlg> { public: CHandlerDlg() : m_Style(TRUE), m_bInline(FALSE), m_bCustom(FALSE), m_iSelectedHandler(-1) { } ~CHandlerDlg() { } CString m_DefFunc; CString m_Function; CString m_Message; BOOL m_Style; BOOL m_bInline; BOOL m_bCustom; CAtlArray<HandlerFunction> m_SupHandlers; int m_iSelectedHandler; enum { IDD = IDD_DIALOG_HANDLER }; BEGIN_MSG_MAP(CHandlerDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK) COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel) COMMAND_HANDLER(IDC_STATIC_MESSAGE, EN_CHANGE, OnStaticMessageEnChange) COMMAND_HANDLER(IDC_STATIC_MESSAGE, EN_UPDATE, OnStaticMessageEnUpdate) COMMAND_HANDLER(IDC_COMBO_FUNCTION, CBN_SELCHANGE, OnComboFunctionSelchange) COMMAND_HANDLER(IDC_COMBO_FUNCTION, CBN_EDITCHANGE, OnComboFunctionEditchange) END_MSG_MAP() BEGIN_DDX_MAP(CHandlerDlg) DDX_TEXT(IDC_COMBO_FUNCTION, m_Function) DDX_TEXT(IDC_STATIC_MESSAGE, m_Message) DDX_CHECK(IDC_CHECK_STYLE, m_Style) DDX_CHECK(IDC_CHECK_INLINE, m_bInline); END_DDX_MAP() BEGIN_TOOLTIP_MAP(CHandlerDlg) TIP_CHILDWND(IDC_CHECK_STYLE, IDS_TOOLTIP_NEW_STYLE) TIP_CHILDWND(IDC_CHECK_INLINE, IDS_TOOLTIP_INLINE) END_TOOLTIP_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 OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { m_Function = m_DefFunc; CenterWindow(GetParent()); if (m_bCustom) { GetDlgItem(IDC_STATIC_MESSAGE).SendMessage(EM_SETREADONLY, 0, 0); m_Message.Empty(); GetDlgItem(IDC_STATIC_MESSAGE).SetFocus(); } else { GetDlgItem(IDC_COMBO_FUNCTION).SetFocus(); } CComboBox ComboFunc = GetDlgItem(IDC_COMBO_FUNCTION); for (size_t i = 0; i < m_SupHandlers.GetCount(); i++) { int iPos = ComboFunc.AddString(m_SupHandlers[i].pFunc->Name); ComboFunc.SetItemData(iPos, i); } DoDataExchange(); InitToolTip(); m_ToolTip.SetMaxTipWidth(400); ComboFunc.SetEditSel(0, -1); ComboFunc.Detach(); return 0; // Let the system set the focus } LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { DoDataExchange(TRUE); EndDialog(wID); return 0; } LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { EndDialog(wID); return 0; } LRESULT OnStaticMessageEnChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { CString Message; GetDlgItem(IDC_STATIC_MESSAGE).GetWindowText(Message); if (Message == m_Message && !m_DefFunc.IsEmpty()) { GetDlgItem(IDC_COMBO_FUNCTION).SetWindowText(m_DefFunc); return 0; } CString FuncName = _T("On"); FuncName += CreateIDName(Message); GetDlgItem(IDC_COMBO_FUNCTION).SetWindowText(FuncName); return 0; } LRESULT OnStaticMessageEnUpdate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { CString Message; GetDlgItem(IDC_STATIC_MESSAGE).GetWindowText(Message); int Pos; GetDlgItem(IDC_STATIC_MESSAGE).SendMessage(EM_GETSEL, (WPARAM)&Pos, 0); Pos--; if (Pos >=0 && Message[Pos] == _T(' ')) { Message.Delete(Pos); GetDlgItem(IDC_STATIC_MESSAGE).SetWindowText(Message); GetDlgItem(IDC_STATIC_MESSAGE).SendMessage(EM_SETSEL, Pos, Pos); MessageBeep(MB_OK); } return 0; } LRESULT OnComboFunctionSelchange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { CComboBox ComboFunc = GetDlgItem(IDC_COMBO_FUNCTION); int iSelItem = ComboFunc.GetCurSel(); m_iSelectedHandler = (int)ComboFunc.GetItemData(iSelItem); ComboFunc.Detach(); GetDlgItem(IDC_CHECK_STYLE).EnableWindow(FALSE); return 0; } LRESULT OnComboFunctionEditchange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { DoDataExchange(TRUE, IDC_COMBO_FUNCTION); for (size_t i = 0; i < m_SupHandlers.GetCount(); i++) { if (m_SupHandlers[i].pFunc->Name == m_Function) { m_iSelectedHandler = (int)i; GetDlgItem(IDC_CHECK_STYLE).EnableWindow(FALSE); return 0; } } m_iSelectedHandler = -1; GetDlgItem(IDC_CHECK_STYLE).EnableWindow(TRUE); return 0; } };
[ "free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1" ]
[ [ [ 1, 186 ] ] ]
1ba417292fc81263569661aff1bc2780424fdb5f
58f7277b5f9717883abdd06caec7461890fd52df
/src/third_party/factory/usage_example/base.h
9f5a978f36d8169026b91815a22d4309ec0a5dad
[]
no_license
temporaer/embrel
8701d5dd82f16aacff164a88bb0c9be1fd9ae1e9
41029ec4fc4d572d9a54b6b32a060646a2186993
refs/heads/master
2020-12-24T16:23:28.626286
2009-05-24T13:40:19
2009-05-24T13:40:19
123,805
2
0
null
null
null
null
UTF-8
C++
false
false
597
h
// base.h // Copyright 2001, Jim Hyslop. // This file may be freely used, modified and distributed, provided that // the accompanying copyright notice remains intact. // // Declaration of the base class to be stored in the factory. #ifndef BASE_HEADER_DEFINED #define BASE_HEADER_DEFINED #include <string> // The class to be stored in the factory template. class Base { public: typedef std::string BASE_KEY_TYPE; // A virtual function to illustrate how well this system // works. virtual void doSomething(); virtual ~Base(); }; #endif // sentry
[ [ [ 1, 26 ] ] ]
a7a333ba857cfc7103cc50802343e8697e1cbb6c
9773c3304eecc308671bcfa16b5390c81ef3b23a
/MDI AIPI V.6.92 2003 ( Correct Save Fired Rules, AM =-1, g_currentLine)/AIPI/ProjectProperties.cpp
fcee2f375cea891ab47018cabe33e128ea152f01
[]
no_license
15831944/AiPI-1
2d09d6e6bd3fa104d0175cf562bb7826e1ac5ec4
9350aea6ac4c7870b43d0a9f992a1908a3c1c4a8
refs/heads/master
2021-12-02T20:34:03.136125
2011-10-27T00:07:54
2011-10-27T00:07:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
982
cpp
// ProjectProperties.cpp: implementation of the CProjectProperties class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "AIPI.h" #include "ProjectProperties.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CProjectProperties::CProjectProperties() { m_LastModified = CTime::GetCurrentTime(); } CProjectProperties::CProjectProperties( const CProjectProperties &ob) { *this = ob; } CProjectProperties &CProjectProperties::operator = (const CProjectProperties &ob) { m_Name = ob.m_Name; m_hItem = ob.m_hItem; m_File = ob.m_File; m_Path = ob.m_Path; m_LastModified = ob.m_LastModified; return *this; } CProjectProperties::~CProjectProperties() { }
[ [ [ 1, 45 ] ] ]
b25d9884eb6edba7fe5a7b7ff9d98469569de240
0045263cdb6bb6f662607ef9034252aa80768fb2
/IrrlichtW/particlescenenode.cpp
c385322a6c247dc379619f5776eb249096213f7b
[ "Zlib", "LicenseRef-scancode-unknown-license-reference" ]
permissive
paupawsan/irrlichtnetcp
4fcbf1d4b11f27164c02be1d102efbc3e5ed3af6
29f8ffe0113cc4bd7f131cb4d472d0c2ef255bfa
refs/heads/master
2021-05-27T00:02:20.923024
2010-01-24T23:13:32
2010-01-24T23:13:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,870
cpp
#include "particlescenenode.h" IParticleSystemSceneNode *GetPSSFromIntPtr(IntPtr part) { return ((IParticleSystemSceneNode*)part); } void Particle_AddAffector(IntPtr part, IntPtr affector) { GetPSSFromIntPtr(part)->addAffector((IParticleAffector*)affector); } class Affector : public IParticleAffector { public: void SetCallBack(AFFECTORCALLBACK call) { _callback = call; } void affect(u32 now, SParticle* particlearray, u32 count) { IntPtr *intptrarr = new IntPtr[count]; for(unsigned int i = 0; i < count; i++) intptrarr[i] = &particlearray[i]; _callback(now, intptrarr, count); delete[] intptrarr; } E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_NONE; } protected: AFFECTORCALLBACK _callback; }; void Particle_AddAffectorA(IntPtr part, AFFECTORCALLBACK affector) { Affector *af = new Affector(); af->SetCallBack(affector); GetPSSFromIntPtr(part)->addAffector(af); } IntPtr Particle_CreateBoxEmitter(IntPtr part,M_BOX3D box, M_VECT3DF direction, unsigned int minPPS, unsigned int maxPPS, M_SCOLOR minSC, M_SCOLOR maxSC, unsigned int minLT, unsigned int maxLT, int maxAngleDegrees) { return GetPSSFromIntPtr(part)->createBoxEmitter(MU_BOX3D(box), MU_VECT3DF(direction), minPPS, maxPPS, MU_SCOLOR(minSC), MU_SCOLOR(maxSC), minLT, maxLT, maxAngleDegrees); } IntPtr Particle_CreateFadeOutParticleAffector(IntPtr part, M_SCOLOR tgtColor, unsigned int timeNeeded) { return GetPSSFromIntPtr(part)->createFadeOutParticleAffector(MU_SCOLOR(tgtColor), timeNeeded); } IntPtr Particle_CreateGravityAffector(IntPtr part, M_VECT3DF gravity, unsigned int timeForceLost) { return GetPSSFromIntPtr(part)->createGravityAffector(MU_VECT3DF(gravity), timeForceLost); } IntPtr Particle_CreatePointEmitter(IntPtr part, M_VECT3DF dir, unsigned int minPPS, unsigned int maxPPS, M_SCOLOR minSC, M_SCOLOR maxSC, unsigned int minLT, unsigned int maxLT, int maxAngleDegrees) { return GetPSSFromIntPtr(part)->createPointEmitter(MU_VECT3DF(dir), minPPS, maxPPS, MU_SCOLOR(minSC), MU_SCOLOR(maxSC), minLT, maxLT, maxAngleDegrees); } void Particle_RemoveAllAffectors(IntPtr part) { GetPSSFromIntPtr(part)->removeAllAffectors(); } void Particle_SetEmitter(IntPtr part, IntPtr emitter) { GetPSSFromIntPtr(part)->setEmitter((IParticleEmitter*)emitter); } class Emitter : public IParticleEmitter { public: void SetCallBack(EMITTERCALLBACK call) { _callback = call; } int emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) { Particles.clear(); _callback(now, timeSinceLastCall, this); outArray = Particles.pointer(); int tor = Particles.size(); return tor; } void AddParticles(IntPtr *part, int count) { for(int i = 0; i < count; i++) Particles.push_back(*(SParticle*)part[i]); } virtual void setDirection(const irr::core::vector3df& direction) { Direction = direction; } virtual void setMinParticlesPerSecond(irr::u32 pps) { MinParticlesPerSecond = pps; } virtual void setMaxParticlesPerSecond(irr::u32 pps) { MaxParticlesPerSecond = pps; } virtual const irr::core::vector3df& getDirection() const { return Direction; } virtual irr::u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } virtual irr::u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } virtual const video::SColor& getMinStartColor() const { return MinStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual void setMaxStartColor(const video::SColor& newMaxStartColor) { MaxStartColor = newMaxStartColor; } virtual void setMinStartColor(const video::SColor& newMinStartColor) { MinStartColor = newMinStartColor; } E_PARTICLE_EMITTER_TYPE getType() const { return EPET_POINT; } protected: EMITTERCALLBACK _callback; core::array<SParticle> Particles; irr::core::vector3df Direction; irr::u32 MinParticlesPerSecond, MaxParticlesPerSecond; video::SColor MinStartColor, MaxStartColor; }; void Emitter_AddParticle(IntPtr emitter, IntPtr *part, int count) { ((Emitter*)emitter)->AddParticles(part, count); } void Particle_SetEmitterA(IntPtr part, EMITTERCALLBACK callback) { Emitter *em = new Emitter(); em->SetCallBack(callback); GetPSSFromIntPtr(part)->setEmitter(em); } void Particle_SetParticlesAreGlobal(IntPtr part, bool global) { GetPSSFromIntPtr(part)->setParticlesAreGlobal(global); } void Particle_SetParticleSize(IntPtr part, M_DIM2DF size) { GetPSSFromIntPtr(part)->setParticleSize(MU_DIM2DF(size)); } IntPtr SParticle_Create() { return new SParticle(); } void SParticle_GetPos(IntPtr particle, M_VECT3DF vect) { SParticle *part = ((SParticle*)particle); UM_VECT3DF(part->pos, vect); } void SParticle_SetPos(IntPtr particle, M_VECT3DF vect) { SParticle *part = ((SParticle*)particle); part->pos = MU_VECT3DF(vect); } void SParticle_GetVect(IntPtr particle, M_VECT3DF vect) { SParticle *part = ((SParticle*)particle); UM_VECT3DF(part->vector, vect); } void SParticle_SetVect(IntPtr particle, M_VECT3DF vect) { SParticle *part = ((SParticle*)particle); part->vector = MU_VECT3DF(vect); } void SParticle_GetStartVect(IntPtr particle, M_VECT3DF vect) { SParticle *part = ((SParticle*)particle); UM_VECT3DF(part->startVector, vect); } void SParticle_SetStartVect(IntPtr particle, M_VECT3DF vect) { SParticle *part = ((SParticle*)particle); part->startVector = MU_VECT3DF(vect); } void SParticle_GetColor(IntPtr particle, M_SCOLOR color) { SParticle *part = ((SParticle*)particle); UM_SCOLOR(part->color, color); } void SParticle_SetColor(IntPtr particle, M_SCOLOR color) { SParticle *part = ((SParticle*)particle); part->color = MU_SCOLOR(color); } void SParticle_GetStartColor(IntPtr particle, M_SCOLOR color) { SParticle *part = ((SParticle*)particle); UM_SCOLOR(part->startColor, color); } void SParticle_SetStartColor(IntPtr particle, M_SCOLOR color) { SParticle *part = ((SParticle*)particle); part->startColor = MU_SCOLOR(color); } unsigned int SParticle_GetStartTime(IntPtr particle) { SParticle *part = ((SParticle*)particle); return part->startTime; } void SParticle_SetStartTime(IntPtr particle, unsigned int time) { SParticle *part = ((SParticle*)particle); part->startTime = time; } unsigned int SParticle_GetEndTime(IntPtr particle) { SParticle *part = ((SParticle*)particle); return part->endTime; } void SParticle_SetEndTime(IntPtr particle, unsigned int time) { SParticle *part = ((SParticle*)particle); part->endTime = time; }
[ [ [ 1, 277 ] ] ]
baab7aeaf5cd204eb09fe01f3257633f2eb0337c
2ba3bfd31fa7e7d4ca9bd2657c607f57993e3316
/TrayIcon.cpp
1a5fd343ccc36cfd637555ec97910767daec175e
[]
no_license
DTTKillASmallScale/kbsizer
d5a870b2239038f44aacc11e704a998a829b891a
52323ec22fb3948e9fa7fa8c9df938990598b97d
refs/heads/master
2021-01-17T11:35:40.259654
2007-11-02T07:00:15
2007-11-02T07:00:15
38,954,920
1
0
null
2015-07-12T08:21:46
2015-07-12T08:21:46
C++
UTF-8
C++
false
false
1,151
cpp
#include "kbSizer.h" #include <shlwapi.h> TrayIcon::TrayIcon() : IsInstalled(false) { } TrayIcon::~TrayIcon() { RemoveIcon(); } void TrayIcon::Init(HWND hwnd, int uid, HICON hIcon, UINT msg, LPCTSTR tooltip) { ZeroMemory(&tnd, sizeof(NOTIFYICONDATA)); tnd.cbSize = sizeof(NOTIFYICONDATA); tnd.hWnd = hwnd; tnd.uID = uid; tnd.hIcon = hIcon; tnd.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; tnd.uVersion = NOTIFYICON_VERSION; tnd.uCallbackMessage = msg; StrCpy(tnd.szTip, tooltip); } void TrayIcon::InstallIcon() { if(!IsInstalled) { Shell_NotifyIcon(NIM_ADD, &tnd); Shell_NotifyIcon(NIM_SETVERSION, &tnd); IsInstalled = true; } } void TrayIcon::ChangeIcon(HICON hIcon) { tnd.hIcon = hIcon; if(IsInstalled) { Shell_NotifyIcon(NIM_MODIFY, &tnd); } else { InstallIcon(); } } void TrayIcon::RemoveIcon() { if(IsInstalled) { Shell_NotifyIcon(NIM_DELETE, &tnd); IsInstalled = false; } } void TrayIcon::RefreshIcon() { RemoveIcon(); InstallIcon(); }
[ "wctang@41ce1f99-ec3d-0410-8b29-7d57c04839ee" ]
[ [ [ 1, 54 ] ] ]
961b2a03b65bd500a36dc847920632c192a544b0
9277f8b966db2bc75acaf12a75f620853be4ffa4
/crbm/crbm_simple/apex_crbm_trainer.h
e4e0db5b0a7f3657790c026bffeb6e497dabb0df
[]
no_license
guochao1/apex-dbn
3e6ad9de12564fc206ed08e563ecea1976edfff5
d95a606a55ba80687e730b78bd4579f20d616eec
refs/heads/master
2021-01-22T13:42:09.752260
2010-09-29T09:13:39
2010-09-29T09:13:39
40,700,204
1
0
null
null
null
null
UTF-8
C++
false
false
5,578
h
#ifndef _APEX_CRBM_TRAINER_H_ #define _APEX_CRBM_TRAINER_H_ #include <vector> #include <cstdlib> #include <cstring> #include "apex_crbm.h" #include "../apex_crbm_model.h" #include "../../utils/apex_config.h" #include "../../utils/task/apex_tensor_update_task.h" namespace apex_rbm{ class CRBMTrainer : public apex_utils::deprecated::ITensorUpdater<apex_tensor::CTensor4D> { private: // model parameter /* parameter for new layer */ CRBMModelParam param_new_layer; CRBMTrainParam param_train; /* model of SDBN */ CDBNModel model; ICRBM *crbm; private: // name of config file char name_config[ 256 ]; // 0 = new layer, 1 = continue last layer's training int task; // whether to be silent int silent; // step of cd int cd_step; // input bound of the image int trunk_size; // input model name char name_model_in[ 256 ]; // start counter of model int start_counter; // folder name of output char name_model_out_folder[ 256 ]; private: // name for summary and detail information of validation char name_summary_log[256], name_detail_log[256]; // file for summary and detail information of validation FILE *fo_summary_log, *fo_detail_log; private: inline void reset_default(){ strcpy( name_config, "crbm.conf" ); strcpy( name_model_in, "NULL" ); strcpy( name_model_out_folder, "models" ); strcpy( name_summary_log, "summary.log.txt" ); strcpy( name_detail_log , "detail.log.txt" ); task = silent = start_counter = 0; cd_step = 1; trunk_size = 1; } public: CRBMTrainer(){ crbm = NULL; reset_default(); } virtual ~CRBMTrainer(){ if( crbm != NULL ) delete crbm; } private: inline void set_param_inner( const char *name, const char *val){ if( !strcmp( name,"task" )) task = atoi( val ); if( !strcmp( name,"silent" )) silent = atoi( val ); if( !strcmp( name,"cd_step" )) cd_step = atoi( val ); if( !strcmp( name,"start_counter" )) start_counter = atoi( val ); if( !strcmp( name,"model_in" )) strcpy( name_model_in, val ); if( !strcmp( name,"model_out_folder" )) strcpy( name_model_out_folder, val ); if( !strcmp( name,"summary_log" )) strcpy( name_summary_log, val ); if( !strcmp( name,"detail_log" )) strcpy( name_detail_log , val ); param_new_layer.set_param( name, val ); param_train.set_param( name, val ); } inline void configure(){ apex_utils::ConfigIterator cfg( name_config ); while( cfg.next() ){ set_param_inner( cfg.name(), cfg.val() ); } } inline void load_model(){ FILE *fi = apex_utils::fopen_check( name_model_in, "rb" ); // load model from file model.load_from_file( fi ); fclose( fi ); } inline void save_model(){ char name[256]; sprintf(name,"%s/%02d.%04d.model" , name_model_out_folder, (int)(model.layers.size()-1) , start_counter ++ ); FILE *fo = apex_utils::fopen_check( name, "wb" ); model.save_to_file( fo ); fclose( fo ); } public: virtual void set_param( const char *name, const char *val ){ if( !strcmp( name, "dbn_config" ) ) strcpy( name_config , val ); if( !strcmp( name, "trunk_size" ) ) trunk_size = atoi( val ); } virtual void init( void ){ this->configure(); if( strcmp( name_model_in,"NULL") != 0 ){ this->load_model(); } if( task == 0 ){ model.add_layer( param_new_layer ); } crbm = factory::create_crbm( model, param_train ); crbm->set_cd_step( cd_step ); // saved for further usage fo_summary_log = apex_utils::fopen_check( name_summary_log , "w" ); fo_detail_log = apex_utils::fopen_check( name_detail_log , "w" ); } virtual void train_update_trunk( const apex_tensor::CTensor4D &data ){ crbm->train_update_trunk( data ); } virtual void validate_trunk ( const apex_tensor::CTensor4D &data ){ CRBMModelParam &param = model.layers.back().param; CRBMModelStats stats( param.v_max, param.h_max, param.y_max, param.x_max ); crbm->validate_stats( stats, data ); stats.save_summary( fo_summary_log ); stats.save_detail ( fo_detail_log ); } /* we end a round of training */ virtual void round_end(){ crbm->clone_model( model ); this->save_model(); } // do nothing virtual void all_end(){ fclose( fo_summary_log ); fclose( fo_detail_log ); } }; }; #endif
[ "workcrow@b861ab8a-2dba-11df-8e64-fd3be38ee323" ]
[ [ [ 1, 149 ] ] ]
db89653aeebe47b64366703f7dcf25e2cec6da4f
9b078eff9020f0d0633458bc52d181ce28e5e6fd
/StdAfx.h
84ac073266277d6d976c28eac96a95b82b1c42fb
[ "BSD-3-Clause" ]
permissive
ambiesoft/cmd2memo
3167dec2a0208826143d19939ccff8992b546896
38f2ed220094c145f376eef8f217062d2578964b
refs/heads/master
2020-06-09T21:02:58.909677
2008-10-19T01:39:16
2008-10-19T01:39:16
193,505,554
0
0
null
null
null
null
UTF-8
C++
false
false
1,850
h
/*** 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. 3. Neither the name of the project 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 PROJECT 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 PROJECT 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(AFX_STDAFX_H__EE6ACF6F_81CD_45E5_8FB2_AF8DF532D1F8__INCLUDED_) #define AFX_STDAFX_H__EE6ACF6F_81CD_45E5_8FB2_AF8DF532D1F8__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <tchar.h> #include <string> #include <windows.h> //{{AFX_INSERT_LOCATION}} // #endif // !defined(AFX_STDAFX_H__EE6ACF6F_81CD_45E5_8FB2_AF8DF532D1F8__INCLUDED_)
[ "svnuser@5ada3c48-002d-0410-850d-99865cc6fd0f" ]
[ [ [ 1, 43 ] ] ]
ee63885be49c7b72fa146424a1678ad073661e27
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/QtGui/qlayout.h
fc578e81d4464aa39886de883f5bb98311acefae
[ "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
7,899
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtGui 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 QLAYOUT_H #define QLAYOUT_H #include <QtCore/qobject.h> #include <QtGui/qlayoutitem.h> #include <QtGui/qsizepolicy.h> #include <QtCore/qrect.h> #include <limits.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) class QLayout; class QSize; #ifdef QT3_SUPPORT class Q_GUI_EXPORT QLayoutIterator { public: inline QT3_SUPPORT_CONSTRUCTOR QLayoutIterator(QLayout *i) : layout(i), index(0) {} inline QLayoutIterator(const QLayoutIterator &i) : layout(i.layout), index(i.index) {} inline QLayoutIterator &operator=(const QLayoutIterator &i) { layout = i.layout; index = i.index; return *this; } inline QT3_SUPPORT QLayoutItem *operator++(); inline QT3_SUPPORT QLayoutItem *current(); inline QT3_SUPPORT QLayoutItem *takeCurrent(); inline QT3_SUPPORT void deleteCurrent(); private: // hack to avoid deprecated warning friend class QLayout; inline QLayoutIterator(QLayout *i, bool) : layout(i), index(0) {} QLayout *layout; int index; }; #endif class QLayoutPrivate; class Q_GUI_EXPORT QLayout : public QObject, public QLayoutItem { Q_OBJECT Q_DECLARE_PRIVATE(QLayout) Q_ENUMS(SizeConstraint) Q_PROPERTY(int margin READ margin WRITE setMargin) Q_PROPERTY(int spacing READ spacing WRITE setSpacing) Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint) public: enum SizeConstraint { SetDefaultConstraint, SetNoConstraint, SetMinimumSize, SetFixedSize, SetMaximumSize, SetMinAndMaxSize #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN) , Auto = SetDefaultConstraint, FreeResize = SetNoConstraint, Minimum = SetMinimumSize, Fixed = SetFixedSize #endif }; QLayout(QWidget *parent); QLayout(); ~QLayout(); int margin() const; int spacing() const; void setMargin(int); void setSpacing(int); void setContentsMargins(int left, int top, int right, int bottom); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; QRect contentsRect() const; bool setAlignment(QWidget *w, Qt::Alignment alignment); bool setAlignment(QLayout *l, Qt::Alignment alignment); #ifdef Q_NO_USING_KEYWORD inline void setAlignment(Qt::Alignment alignment) { QLayoutItem::setAlignment(alignment); } #else using QLayoutItem::setAlignment; #endif void setSizeConstraint(SizeConstraint); SizeConstraint sizeConstraint() const; #ifdef QT3_SUPPORT inline QT3_SUPPORT void setResizeMode(SizeConstraint s) {setSizeConstraint(s);} inline QT3_SUPPORT SizeConstraint resizeMode() const {return sizeConstraint();} #endif void setMenuBar(QWidget *w); QWidget *menuBar() const; QWidget *parentWidget() const; void invalidate(); QRect geometry() const; bool activate(); void update(); void addWidget(QWidget *w); virtual void addItem(QLayoutItem *) = 0; void removeWidget(QWidget *w); void removeItem(QLayoutItem *); Qt::Orientations expandingDirections() const; QSize minimumSize() const; QSize maximumSize() const; virtual void setGeometry(const QRect&); virtual QLayoutItem *itemAt(int index) const = 0; virtual QLayoutItem *takeAt(int index) = 0; virtual int indexOf(QWidget *) const; virtual int count() const = 0; bool isEmpty() const; int totalHeightForWidth(int w) const; QSize totalMinimumSize() const; QSize totalMaximumSize() const; QSize totalSizeHint() const; QLayout *layout(); void setEnabled(bool); bool isEnabled() const; #ifdef QT3_SUPPORT QT3_SUPPORT void freeze(int w=0, int h=0); QT3_SUPPORT bool isTopLevel() const; #endif static QSize closestAcceptableSize(const QWidget *w, const QSize &s); protected: void widgetEvent(QEvent *); void childEvent(QChildEvent *e); void addChildLayout(QLayout *l); void addChildWidget(QWidget *w); #ifdef QT3_SUPPORT QT3_SUPPORT void deleteAllItems(); #endif QRect alignmentRect(const QRect&) const; protected: QLayout(QLayoutPrivate &d, QLayout*, QWidget*); private: Q_DISABLE_COPY(QLayout) static void activateRecursiveHelper(QLayoutItem *item); friend class QApplicationPrivate; friend class QWidget; #ifdef QT3_SUPPORT public: QT3_SUPPORT_CONSTRUCTOR QLayout(QWidget *parent, int margin, int spacing = -1, const char *name = 0); QT3_SUPPORT_CONSTRUCTOR QLayout(QLayout *parentLayout, int spacing = -1, const char *name = 0); QT3_SUPPORT_CONSTRUCTOR QLayout(int spacing, const char *name = 0); inline QT3_SUPPORT QWidget *mainWidget() const { return parentWidget(); } inline QT3_SUPPORT void remove(QWidget *w) { removeWidget(w); } inline QT3_SUPPORT void add(QWidget *w) { addWidget(w); } QT3_SUPPORT void setAutoAdd(bool a); QT3_SUPPORT bool autoAdd() const; inline QT3_SUPPORT QLayoutIterator iterator() { return QLayoutIterator(this,true); } inline QT3_SUPPORT int defaultBorder() const { return spacing(); } #endif }; #ifdef QT3_SUPPORT inline QLayoutItem *QLayoutIterator::operator++() { return layout->itemAt(++index); } inline QLayoutItem *QLayoutIterator::current() { return layout->itemAt(index); } inline QLayoutItem *QLayoutIterator::takeCurrent() { return layout->takeAt(index); } inline void QLayoutIterator::deleteCurrent() { delete layout->takeAt(index); } #endif //### support old includes #if 1 //def QT3_SUPPORT QT_BEGIN_INCLUDE_NAMESPACE #include <QtGui/qboxlayout.h> #include <QtGui/qgridlayout.h> QT_END_INCLUDE_NAMESPACE #endif QT_END_NAMESPACE QT_END_HEADER #endif // QLAYOUT_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 242 ] ] ]
8914ecda21ce68be04f3fe02926d7dfecdaa69fb
3276915b349aec4d26b466d48d9c8022a909ec16
/c++/重定向与命令行参数传第/文件地址信息用作命令行参数.cpp
74494f0fe7c473dc20f666b17ad2bc35f01bf579
[]
no_license
flyskyosg/3dvc
c10720b1a7abf9cf4fa1a66ef9fc583d23e54b82
0279b1a7ae097b9028cc7e4aa2dcb67025f096b9
refs/heads/master
2021-01-10T11:39:45.352471
2009-07-31T13:13:50
2009-07-31T13:13:50
48,670,844
0
0
null
null
null
null
GB18030
C++
false
false
636
cpp
#include<iostream> //命令行传递文件信息 注:在命令行中输入如下内容:重定向 xxx.txt yyy.txt 这样就把xxx.txt 中的所有信息拷贝进了yyy.txt #include<fstream> using namespace std; int main(int argc,char ** argv) //输入时只需要传入字符串,第一项参数不需要传入,系统自动传入 { ifstream inf(argv[1]); //这里的下表是1和2是因为第一个字符串是程序名,而且argc的个数包含了程序名字符串 ofstream ouf(argv[2]); if(inf&&ouf) ouf<<inf.rdbuf(); //该函数从输入流缓冲区中读取字符 }
[ [ [ 1, 11 ] ] ]
2183d486125e7c3af88764d42ea7f43e3d8a2065
ed1a161411b6850d6113b640b5b8c776e7cb0f2c
/TiGLiCS/src/Manager/FontManager.h
bf4202d44499672f378fa35d00c02590ccb6bc73
[]
no_license
weimingtom/tiglics
643d19a616dcae3e474471e3dea868f6631463ba
450346a441ee6c538e39968311ab60eb9e572746
refs/heads/master
2021-01-10T01:36:31.607727
2008-08-13T03:35:45
2008-08-13T03:35:45
48,733,131
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,623
h
//フォント管理構造体。生成に必要な情報の管理 #pragma once #include "Base/Base.h" #include <vector> namespace TiGLiCS{ namespace Manager{ /** @brief フォント単体マネージャ @author my04337 @note フォントファイル管理クラス。フォントスプライトの生成を請け負う */ class CFont{ const char * FileName;//ファイル名 const char * FileType;//ファイルフォーマット public: /** @brief コンストラクタ @author my04337 @param FileName [in] フォントファイル名 @param FileType [in] ファイルフォーマット */ CFont(const char * FileName,const char * FileType){ this->FileName=FileName; this->FileType=FileType; } ~CFont(){}//デストラクタ Selene::Renderer::Object::IFontSprite2D *MakeFontSprite2D(Selene::Renderer::IRender *pRender,Sint32 MaxDrawNum){ return pRender->CreateFontSprite2DFromFile(FileName,FileType,MaxDrawNum); } Selene::Renderer::Object::IFontSprite3D *MakeFontSprite3D(Selene::Renderer::IRender *pRender,Sint32 MaxDrawNum){ return pRender->CreateFontSprite3DFromFile(FileName,FileType,MaxDrawNum); } inline const char * GetFileName(){return FileName;} inline const char * GetFileType(){return FileType;} }; //------------------------------------------------------------------------------------- /** @brief フォントマネージャ @author my04337 @note フォント全体の管理を請け負う。 */ class CFontManager{//シングルトン static CFontManager * Instance; std::vector<CFont *> FontList;//フォントリスト CFontManager(){} ~CFontManager(){} public: static CFontManager * GetInstance(){return Instance;} static void Release(){ //フォントの解放 for(Sint32 i=0;i<(Sint32)Instance->FontList.size();++i){ SAFE_DELETE(Instance->FontList[i]); } } /** @brief フォントの追加 @author my04337 @param pFont [in] フォントマネージャへのポインタ @return フォントID フォントの登録を行う。戻り値はフォントIDで、フォントの追加順に<br> 0 , 1 , 2 , ... といった値となる。 */ Sint32 AddFont(CFont * pFont){FontList.push_back(pFont);return (Sint32)FontList.size();} inline Sint32 GetCFontNum(void){ return (Sint32)FontList.size(); } inline CFont* GetCFont(Sint32 idx){ return (idx>=0 && idx<(Sint32)FontList.size()?FontList[idx]:NULL); } }; }; };
[ "my04337@d15ed888-2954-0410-b748-710a6ca92709" ]
[ [ [ 1, 77 ] ] ]
8134e2ae8ddeb482f19525fe79885465a23cee87
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/libs/STLPort-4.0/src/fstream.cpp
2ce8fe32db56e9eab29324cc7f96ce970abc419b
[ "LicenseRef-scancode-stlport-4.5" ]
permissive
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
28,649
cpp
/* * Copyright (c) 1999 * Silicon Graphics Computer Systems, Inc. * * Copyright (c) 1999 * Boris Fomitchev * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */ # include "stlport_prefix.h" #include <fstream> #ifdef __CYGWIN__ # define __int64 long long #endif #if defined (__STL_USE_UNIX_IO) // open/close/read/write # include <sys/stat.h> // For stat # include <sys/mman.h> // For mmap # include <unistd.h> # include <fcntl.h> #elif defined (__STL_USE_WIN32_IO) # define WIN32_LEAN_AND_MEAN # include <windows.h> # ifdef __BORLANDC__ # if (__BORLANDC__ > 0x530) # include <cfcntl.h> // For _O_RDONLY, etc # else # include <fcntl.h> // For _O_RDONLY, etc # endif # include <sys/stat.h> // For _fstat # else # include <io.h> // For _get_osfhandle # include <fcntl.h> // For _O_RDONLY, etc # include <sys/stat.h> // For _fstat # endif # define _TEXTBUF_SIZE 0x1000 #elif defined (__STL_USE_UNIX_EMULATION_IO) # if defined( __MSL__ ) # include <unistd.h> # else # include <io.h> # endif # include <fcntl.h> # include <sys/stat.h> #elif defined (__STL_USE_STDIO_IO) # include <cstdio> # if !(defined(__MRC__)||defined(__SC__)) //*TY 02/25/2000 - MPW does not come with <sys/stat.h> # include <sys/stat.h> # endif //*TY 02/25/2000 - # if defined( __MSL__ ) # include <unix.h> # endif #else #error "Configure i/o !" #endif // map permission masks #if defined (__STL_USE_UNIX_EMULATION_IO) || defined (__STL_USE_STDIO_IO) # ifndef S_IRUSR # define S_IRUSR _S_IREAD # define S_IWUSR _S_IWRITE # define S_IRGRP _S_IREAD # define S_IWGRP _S_IWRITE # define S_IROTH _S_IREAD # define S_IWOTH _S_IWRITE # endif # ifndef O_RDONLY # define O_RDONLY _O_RDONLY # define O_WRONLY _O_WRONLY # define O_RDWR _O_RDWR # define O_APPEND _O_APPEND # define O_CREAT _O_CREAT # define O_TRUNC _O_TRUNC # define O_TEXT _O_TEXT # define O_BINARY _O_BINARY # endif # ifdef __MSL__ # define _O_TEXT 0x0 # if !defined( O_TEXT ) # define O_TEXT _O_TEXT # endif # define _S_IFREG S_IFREG # define S_IREAD S_IRUSR # define S_IWRITE S_IWUSR # define S_IEXEC S_IXUSR # define _S_IWRITE S_IWRITE # define _S_IREAD S_IREAD # define _open open # define _lseek lseek # define _close close # define _read read # define _write write # endif #endif #ifndef O_ACCMODE # define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) #endif #include "fstream_impl.h" # ifdef __STL_LONG_LONG # define ULL(x) ((unsigned long long)x) # elif defined (_MSC_VER) || defined (__BORLANDC__) # define ULL(x) ((__int64)x) # elif defined(__MRC__) || defined(__SC__) //*TY 02/25/2000 - added support for MPW compilers # include <Math64.h> # define ULL(x) (U64SetU(x)) # else # error "there should be some long long type on the system!" # endif __SGI_BEGIN_NAMESPACE #if !defined(__MSL__) && !defined(__MRC__) && !defined(__SC__) //*TY 04/15/2000 - exclude mpw compilers also ios_base::openmode flag_to_openmode(int mode) { ios_base::openmode ret; switch(mode & O_ACCMODE) { case O_RDONLY: ret = ios_base::in; break; case O_WRONLY: ret = ios_base::out; break; case O_RDWR: ret = ios_base::in | ios_base::out; break; } if (mode & O_APPEND) ret |= ios_base::app; # ifdef __STL_USE_WIN32_IO if (mode & O_BINARY) ret |= ios_base::binary; # endif // _MSC_VER return ret; } # endif /* MSL */ // Helper functions for _Filebuf_base. bool __is_regular_file(_STL_fd fd) { #if defined (__STL_UNIX) struct stat buf; return fstat(fd, &buf) == 0 && S_ISREG(buf.st_mode); #elif defined(__MRC__) || defined(__SC__) //*TY 02/25/2000 - added support for MPW compilers #pragma unused(fd) return true; // each file is a regular file under mac os, isn't it? (we don't have fstat()) #elif defined(__STL_USE_UNIX_EMULATION_IO) || defined (__STL_USE_STDIO_IO) struct stat buf; return fstat(fd, &buf) == 0 && (buf.st_mode & _S_IFREG) != 0 ; # elif defined (__STL_USE_WIN32_IO) return (GetFileType(fd) & ~FILE_TYPE_REMOTE) == FILE_TYPE_DISK; #else (void)fd; // dwa 4/27/00 - suppress unused parameter warning return false; #endif } // Number of characters in the file. streamoff __file_size(_STL_fd fd) { streamoff ret = 0; #if defined (__STL_UNIX) struct stat buf; if(fstat(fd, &buf) == 0 && S_ISREG(buf.st_mode)) ret = buf.st_size > 0 ? buf.st_size : 0; #elif defined(__MRC__) || defined(__SC__) //*TY 02/25/2000 - added support for MPW compilers #pragma unused(fd) #elif defined(__STL_USE_UNIX_EMULATION_IO) || defined (__STL_USE_STDIO_IO) struct stat buf; if(fstat(fd, &buf) == 0 && (buf.st_mode & _S_IFREG) != 0) ret = buf.st_size > 0 ? buf.st_size : 0; # elif defined (__STL_USE_WIN32_IO) DWORD FileSizeHigh; DWORD FileSize = GetFileSize(fd, &FileSizeHigh); // may use 64-bit ret = (((__int64)FileSizeHigh) << 32) | (__int64)FileSize; # else (void)fd; // dwa 4/27/00 - suppress unused parameter warning # endif return ret; } // Visual C++ and Intel use this, but not Metrowerks #if !defined(__MSL__) && defined ( _MSC_VER ) && defined (_WIN32) // fcntl(fileno, F_GETFL) for Microsoft library // 'semi-documented' defines: #define IOINFO_L2E 5 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + \ ((i) & (IOINFO_ARRAY_ELTS - 1)) ) #define FAPPEND 0x20 // O_APPEND flag #define FTEXT 0x80 // O_TEXT flag // end of 'semi-documented' defines // fbp : empirical #define F_WRITABLE 0x04 // 'semi-documented' internal structure extern "C" { struct ioinfo { long osfhnd; // the real os HANDLE char osfile; // file handle flags char pipech; // pipe buffer # ifdef _MT // multi-threaded locking int lockinitflag; CRITICAL_SECTION lock; # endif /* _MT */ }; extern _CRTIMP ioinfo * __pioinfo[]; } // extern "C" // end of 'semi-documented' declarations ios_base::openmode _get_osfflags(int fd, HANDLE oshandle) { char dosflags = 0; dosflags = _pioinfo(fd)->osfile; // end of 'semi-documented' stuff int mode = 0; if (dosflags & FAPPEND) mode |= O_APPEND; if (dosflags & FTEXT) mode |= O_TEXT; else mode |= O_BINARY; // we have to guess # ifdef __macintosh DWORD dummy, dummy2; if (WriteFile(oshandle, &dummy2, 0, &dummy, 0)) mode |= O_RDWR; else mode |= O_RDONLY; # else // on Windows, this seems to work... if (dosflags & F_WRITABLE) mode |= O_RDWR; else mode |= O_RDONLY; # endif return flag_to_openmode(mode); } #endif // _MSC_VER __SGI_END_NAMESPACE // All version of Unix have mmap and lseek system calls. Some also have // longer versions of thos system calls to accommodate 64-bit offsets. // If we're on a Unix system, define some macros to encapsulate those // differences. #ifdef __STL_USE_UNIX_IO # ifdef __sgi /* IRIX */ # define LSEEK lseek64 # define MMAP mmap64 # else # define LSEEK lseek # define MMAP mmap # endif #ifndef MAP_FAILED /* MMAP failure return code */ # define MAP_FAILED -1 #endif #elif defined (__STL_USE_UNIX_EMULATION_IO) # define LSEEK _lseek #endif __STL_BEGIN_NAMESPACE size_t _Filebuf_base::_M_page_size = 4096; _Filebuf_base::_Filebuf_base() : _M_file_id((_STL_fd)-1), _M_openmode(0), _M_is_open(false), _M_should_close(false) { if (!_M_page_size) #if defined (__STL_UNIX) _M_page_size = sysconf(_SC_PAGESIZE); # elif defined (__STL_USE_WIN32_IO) { SYSTEM_INFO SystemInfo; GetSystemInfo(&SystemInfo); _M_page_size = SystemInfo.dwPageSize; // might be .dwAllocationGranularity } // _M_CRLF_trans_buf = 0, // _M_trans_buf_end=0, _M_view_id = 0; #endif if (_M_page_size <=0 ) _M_page_size = 4096; } // Return the size of the file. This is a wrapper for stat. // Returns zero if the size cannot be determined or is ill-defined. streamoff _Filebuf_base::_M_file_size() { return SGI::__file_size(_M_file_id); } bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode, long permission) { _STL_fd file_no; if (_M_is_open) return false; #if defined (__STL_USE_UNIX_IO) || defined (__STL_USE_UNIX_EMULATION_IO) int flags = 0; // Unix makes no distinction between text and binary files. switch(openmode & (~ios_base::ate & ~ios_base::binary)) { case ios_base::out: case ios_base::out | ios_base::trunc: flags = O_WRONLY | O_CREAT | O_TRUNC; break; case ios_base::out | ios_base::app: flags = O_WRONLY | O_CREAT | O_APPEND; break; case ios_base::in: flags = O_RDONLY; permission = 0; // Irrelevant unless we're writing. break; case ios_base::in | ios_base::out: flags = O_RDWR; break; case ios_base::in | ios_base::out | ios_base::trunc: flags = O_RDWR | O_CREAT | O_TRUNC; break; default: // The above are the only combinations of return false; // flags allowed by the C++ standard. } # if defined (__STL_USE_UNIX_EMULATION_IO) if (openmode & ios_base::binary) flags |= O_BINARY; else flags |= O_TEXT; file_no = _open(name, flags, permission); # else file_no = open(name, flags, permission); # endif /* __STL_USE_UNIX_EMULATION_IO */ if (file_no < 0) return false; _M_is_open = true; if (openmode & ios_base::ate) if (LSEEK(file_no, 0, SEEK_END) == -1) _M_is_open = false; #elif defined (__STL_USE_STDIO_IO) // use FILE-based i/o const char* flags; switch(openmode & (~ios_base::ate)) { case ios_base::out: case ios_base::out | ios_base::trunc: flags = "w"; break; case ios_base::out | ios_base::binary: case ios_base::out | ios_base::trunc | ios_base::binary: flags = "wb"; break; case ios_base::out | ios_base::app: flags = "a"; break; case ios_base::out | ios_base::app | ios_base::binary: flags = "ab"; break; case ios_base::in: flags = "r"; break; case ios_base::in | ios_base::binary: flags = "rb"; break; case ios_base::in | ios_base::out: flags = "r+"; break; case ios_base::in | ios_base::out | ios_base::binary: flags = "r+b"; break; case ios_base::in | ios_base::out | ios_base::trunc: flags = "w+"; break; case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary: flags = "w+b"; break; default: // The above are the only combinations of return false; // flags allowed by the C++ standard. } // fbp : TODO : set permissions ! (void)permission; // currently unused //*TY 02/26/2000 - added to suppress warning message _M_file = fopen(name, flags); if (_M_file) { file_no = fileno(_M_file); } else return false; // unset buffering immediately setbuf(_M_file, 0); _M_is_open = true; if (openmode & ios_base::ate) if (fseek(_M_file, 0, SEEK_END) == -1) _M_is_open = false; # elif defined (__STL_USE_WIN32_IO) DWORD dwDesiredAccess, dwShareMode, dwCreationDisposition; bool doTruncate = false; switch(openmode & (~ios_base::ate & ~ios_base::binary)) { case ios_base::out: case ios_base::out | ios_base::trunc: dwDesiredAccess = GENERIC_WRITE; dwShareMode = FILE_SHARE_READ; dwCreationDisposition = OPEN_ALWAYS; // boris : even though it is very non-intuitive, standard // requires them both to behave same. doTruncate = true; break; case ios_base::out | ios_base::app: dwDesiredAccess = GENERIC_WRITE; dwShareMode = FILE_SHARE_READ; dwCreationDisposition = OPEN_ALWAYS; break; case ios_base::in: dwDesiredAccess = GENERIC_READ; dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; dwCreationDisposition = OPEN_EXISTING; permission = 0; // Irrelevant unless we're writing. break; case ios_base::in | ios_base::out: dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; dwShareMode = FILE_SHARE_READ; dwCreationDisposition = OPEN_EXISTING; break; case ios_base::in | ios_base::out | ios_base::trunc: dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; dwShareMode = FILE_SHARE_READ; dwCreationDisposition = OPEN_ALWAYS; doTruncate = true; break; default: // The above are the only combinations of return false; // flags allowed by the C++ standard. } # ifdef _UNICODE file_no = CreateFileA( # else file_no = CreateFile( # endif name, dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, permission, 0); if ( file_no == INVALID_HANDLE_VALUE ) return false; if ((doTruncate && SetEndOfFile(file_no) == 0) || ((openmode & ios_base::ate) && SetFilePointer(file_no, 0, NULL, FILE_END) == -1)) { CloseHandle(file_no); return false; } _M_is_open = true; #else # error "Port!" #endif /* __unix */ _M_file_id = file_no; _M_should_close = _M_is_open; _M_openmode = openmode; if (_M_is_open) _M_regular_file = SGI::__is_regular_file(_M_file_id); return _M_is_open; } bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode) { // This doesn't really grant everyone in the world read/write // access. On Unix, file-creation system calls always clear // bits that are set in the umask from the permissions flag. # ifdef __STL_USE_WIN32_IO return this->_M_open(name, openmode, FILE_ATTRIBUTE_NORMAL); # elif defined(__MRC__) || defined(__SC__) //*TY 02/26/2000 - added support for MPW compilers return this->_M_open(name, openmode, 0); # else return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); # endif } // Associated the filebuf with a file descriptor pointing to an already- // open file. Mode is set to be consistent with the way that the file // was opened. bool _Filebuf_base::_M_open(int file_no, ios_base::openmode init_mode) { if (_M_is_open || file_no < 0) return false; # if defined (__STL_UNIX) (void)init_mode; // dwa 4/27/00 - suppress unused parameter warning int mode ; mode = fcntl(file_no, F_GETFL); if (mode == -1) return false; _M_openmode = SGI::flag_to_openmode(mode); # elif defined(__MRC__) || defined(__SC__) //*TY 02/26/2000 - added support for MPW compilers (void)init_mode; // dwa 4/27/00 - suppress unused parameter warning switch( _iob[file_no]._flag & (_IOREAD|_IOWRT|_IORW) ) { case _IOREAD: _M_openmode = ios_base::in; break; case _IOWRT: _M_openmode = ios_base::out; break; case _IORW: _M_openmode = ios_base::in | ios_base::out; break; default: return false; } # elif defined (__STL_USE_UNIX_EMULATION_IO) || defined (__STL_USE_STDIO_IO) (void)init_mode; // dwa 4/27/00 - suppress unused parameter warning int mode ; struct stat buf; if (fstat(file_no, &buf) != 0) return false; mode = buf.st_mode; switch(mode & (_S_IWRITE | _S_IREAD) ) { case _S_IREAD: _M_openmode = ios_base::in; break; case _S_IWRITE: _M_openmode = ios_base::out; break; case (_S_IWRITE | _S_IREAD): _M_openmode = ios_base::in | ios_base::out; break; default: return false; } # elif defined(__STL_USE_WIN32_IO) && defined (_MSC_VER) if (_M_is_open || file_no == -1) return false; HANDLE oshandle = (HANDLE)_get_osfhandle(file_no); if ((long)oshandle != -1) file_no = (int)oshandle; else return false; if (init_mode != ios_base::__default_mode) _M_openmode = init_mode; else _M_openmode = SGI::_get_osfflags(file_no, oshandle); # else (void)init_mode; // dwa 4/27/00 - suppress unused parameter warning // not available for the API return false; # endif _M_is_open = true; _M_file_id = (_STL_fd)file_no; _M_should_close = false; _M_regular_file = SGI::__is_regular_file(_M_file_id); return true; } bool _Filebuf_base::_M_close() { if (!_M_is_open) return false; bool ok; if (!_M_should_close) ok = true; else { # if defined (__STL_USE_UNIX_IO) ok = (close(_M_file_id) == 0); # elif defined (__STL_USE_UNIX_EMULATION_IO) ok = (_close(_M_file_id) == 0); # elif defined (__STL_USE_STDIO_IO) ok = (fclose(_M_file) == 0); # elif defined (__STL_USE_WIN32_IO) ok = (CloseHandle(_M_file_id) != 0); # else ok = false; # endif /* __STL_USE_UNIX_IO */ } _M_is_open = _M_should_close = false; _M_openmode = 0; return ok; } # define __STL_LF 10 # define __STL_CR 13 # define __STL_CTRLZ 26 // Read up to n characters into a buffer. Return value is number of // characters read. ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) { # if defined (__STL_USE_UNIX_IO) return read(_M_file_id, buf, n); # elif defined (__STL_USE_UNIX_EMULATION_IO) return _read(_M_file_id, buf, n); # elif defined (__STL_USE_WIN32_IO) DWORD NumberOfBytesRead; ReadFile(_M_file_id, (LPVOID)buf, (DWORD)n, &NumberOfBytesRead, 0); if ((! (_M_openmode & ios_base::binary)) && NumberOfBytesRead) { // translate CR-LFs to LFs in the buffer char * to = buf, * last = buf + NumberOfBytesRead - 1; char * from; for (from = buf; from <= last && * from != __STL_CTRLZ; ++ from ) { if (* from != __STL_CR) * to ++ = * from; else { // found CR if (from < last) { // not at buffer end if (* (from + 1) != __STL_LF) * to ++ = __STL_CR; } else { // last char is CR, peek for LF char peek = ' '; DWORD NumberOfBytesPeeked; ReadFile(_M_file_id, (LPVOID)&peek, 1, &NumberOfBytesPeeked, 0); if (NumberOfBytesPeeked) SetFilePointer(_M_file_id,(LONG)-1,0,SEEK_CUR); if (peek != __STL_LF) * to ++ = __STL_CR; } } // found CR } // for // seek back to TEXT end of file if hit CTRL-Z if (from <= last) // terminated due to CTRLZ SetFilePointer(_M_file_id,(LONG)((last+1) - from),0,SEEK_CUR); NumberOfBytesRead = to - buf; } return (ptrdiff_t)NumberOfBytesRead; # elif defined (__STL_USE_STDIO_IO) return fread(buf, 1, n, _M_file); # else # error "Port!" # endif /* __unix */ } // Write n characters from a buffer. Return value: true if we managed // to write the entire buffer, false if we didn't. bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n) { while (true) { ptrdiff_t written; # if defined (__STL_USE_UNIX_IO) written = write(_M_file_id, buf, n); # elif defined (__STL_USE_UNIX_EMULATION_IO) written = _write(_M_file_id, buf, n); # elif defined (__STL_USE_WIN32_IO) // In append mode, every write does an implicit seek to the end // of the file. if (_M_openmode & ios_base::app) _M_seek( 0, ios_base::end); if (_M_openmode & ios_base::binary) { // binary mode DWORD NumberOfBytesWritten; WriteFile(_M_file_id, (LPVOID)buf, (DWORD)n, &NumberOfBytesWritten, 0); written = (ptrdiff_t)NumberOfBytesWritten; } else { char textbuf[_TEXTBUF_SIZE + 1]; // extra 1 in case LF at end char * nextblock = buf, * ptrtextbuf = textbuf; char * endtextbuf = textbuf + _TEXTBUF_SIZE; char * endblock = buf + n; ptrdiff_t nextblocksize = (__STLPORT_STD::min)(n, _TEXTBUF_SIZE); char * nextlf; while ( (nextblocksize > 0) && (nextlf = (char *)memchr(nextblock, __STL_LF, nextblocksize)) != 0) { ptrdiff_t linelength = nextlf - nextblock; memcpy(ptrtextbuf, nextblock, linelength); ptrtextbuf += linelength; nextblock += (linelength + 1); * ptrtextbuf ++ = __STL_CR; * ptrtextbuf ++ = __STL_LF; nextblocksize = (__STLPORT_STD::min)(ptrdiff_t(endblock - nextblock), (__STLPORT_STD::max)(ptrdiff_t(0), ptrdiff_t(endtextbuf - ptrtextbuf))); } // write out what's left, > condition is here since for LF at the end , // endtextbuf may get < ptrtextbuf ... if (nextblocksize > 0) { memcpy(ptrtextbuf, nextblock, nextblocksize); ptrtextbuf += nextblocksize; nextblock += nextblocksize; } // now write out the translated buffer char * writetextbuf = textbuf; for (ptrdiff_t NumberOfBytesToWrite = ptrtextbuf - textbuf; NumberOfBytesToWrite;) { DWORD NumberOfBytesWritten; WriteFile((HANDLE)_M_file_id, (LPVOID)writetextbuf, NumberOfBytesToWrite, &NumberOfBytesWritten, 0); if (NumberOfBytesWritten == NumberOfBytesToWrite) break; if (!NumberOfBytesWritten) // write shortfall return false; writetextbuf += NumberOfBytesWritten; NumberOfBytesToWrite -= NumberOfBytesWritten; } // count non-translated characters written = (nextblock - buf); } # elif defined (__STL_USE_STDIO_IO) written = fwrite(buf, 1, n, _M_file); # else # error "Port!" # endif /* __unix */ if (n == written) return true; else if (written > 0 && written < n) { n -= written; buf += written; } else return false; } } #ifdef __STL_USE_WIN32_IO # define STL_SEEK_SET FILE_BEGIN # define STL_SEEK_CUR FILE_CURRENT # define STL_SEEK_END FILE_END #else # define STL_SEEK_SET SEEK_SET # define STL_SEEK_CUR SEEK_CUR # define STL_SEEK_END SEEK_END #endif // Wrapper for lseek or the like. streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir) { streamoff result = -1; int whence; switch(dir) { case ios_base::beg: if (offset < 0 || offset > _M_file_size()) return streamoff(-1); whence = STL_SEEK_SET; break; case ios_base::cur: whence = STL_SEEK_CUR; break; case ios_base::end: if (offset > 0 || -offset > _M_file_size()) return streamoff(-1); whence = STL_SEEK_END; break; default: return streamoff(-1); } #if defined (__STL_USE_UNIX_IO) || defined (__STL_USE_UNIX_EMULATION_IO) result = LSEEK(_M_file_id, offset, whence); #elif defined (__STL_USE_STDIO_IO) result = fseek(_M_file, offset, whence); #elif defined (__STL_USE_WIN32_IO) long hi_seek = ULL(offset) >> 32; long ret = SetFilePointer(_M_file_id, offset, &hi_seek, whence); if (ret == -1) result = ret; else { result = hi_seek; result = (ULL(result)<<32) | ret; } #else # error "Port!" #endif return result; } // Attempts to memory-map len bytes of the current file, starting // at position offset. Precondition: offset is a multiple of the // page size. Postcondition: return value is a null pointer if the // memory mapping failed. Otherwise the return value is a pointer to // the memory-mapped file and the file position is set to offset. void* _Filebuf_base::_M_mmap(streamoff offset, streamoff len) { void* base; #if defined (__STL_UNIX) base = MMAP(0, len, PROT_READ, MAP_PRIVATE, _M_file_id, offset); if (base != (void*)MAP_FAILED) { if (LSEEK(_M_file_id, offset + len, SEEK_SET) < 0) { this->_M_unmap(base, len); base = 0; } } else base =0; #elif defined (__STL_USE_WIN32_IO) _M_view_id = CreateFileMapping(_M_file_id, (PSECURITY_ATTRIBUTES)0 , PAGE_READONLY, 0 /* len >> 32 */ , 0 /* len & 0xFFFFFFFF */ , // low-order DWORD of size 0); if (_M_view_id) { # if 0 printf("view %x created from file %x, error = %d, size = %d, map_offset = %d map_len = %d\n", _M_view_id, _M_file_id, GetLastError(), (int)cur_filesize, ULL(offset) & 0xffffffff, len); # endif base = MapViewOfFile(_M_view_id, FILE_MAP_READ, ULL(offset)>>32, ULL(offset) & 0xffffffff, len); if (base) { if (_M_seek(offset+len, ios_base::beg) < 0) { this->_M_unmap(base, len); base = 0; } } } #else (void)len; //*TY 02/26/2000 - unused variables (void)offset; //*TY 02/26/2000 - base = 0; #endif return base; } void _Filebuf_base::_M_unmap(void* base, streamoff len) { // precondition : there is a valid mapping at the moment #if defined (__STL_UNIX) munmap((caddr_t)base, len); #elif defined (__STL_USE_WIN32_IO) UnmapViewOfFile(base); // destroy view handle as well CloseHandle(_M_view_id); _M_view_id = 0; #else (void)len; //*TY 02/26/2000 - unused variables (void)base; //*TY 02/26/2000 - #endif } # define MMAP_CHUNK 0x1000000UL int __STL_CALL _Underflow<char, char_traits<char> >::_M_doit (basic_filebuf<char, char_traits<char> >* __this) { if (!__this->_M_in_input_mode) { if (!__this->_M_switch_to_input_mode()) return traits_type::eof(); } else if (__this->_M_in_putback_mode) { __this->_M_exit_putback_mode(); if (__this->gptr() != __this->egptr()) { int_type __c = traits_type::to_int_type(*__this->gptr()); return __c; } } // If it's a disk file, and if the internal and external character // sequences are guaranteed to be identical, then try to use memory // mapped I/O. Otherwise, revert to ordinary read. if (__this->_M_base.__regular_file() && __this->_M_always_noconv && __this->_M_base._M_in_binary_mode()) { // If we've mmapped part of the file already, then unmap it. if (__this->_M_mmap_base) __this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len); // Determine the position where we start mapping. It has to be // a multiple of the page size. streamoff __cur = __this->_M_base._M_seek(0, ios_base::cur); streamoff __size = __this->_M_base._M_file_size(); if (__size > 0 && __cur >= 0 && __cur < __size) { streamoff __offset = (__cur / __this->_M_base.__page_size()) * __this->_M_base.__page_size(); streamoff __remainder = __cur - __offset; __this->_M_mmap_len = __size - __offset; // fbp : let us map 1 MB maximum, just be sure not to trash VM if (__this->_M_mmap_len > MMAP_CHUNK) __this->_M_mmap_len = MMAP_CHUNK; if ((__this->_M_mmap_base = __this->_M_base._M_mmap(__offset, __this->_M_mmap_len)) != 0) { __this->setg((char*) __this->_M_mmap_base, (char*) __this->_M_mmap_base + __remainder, (char*) __this->_M_mmap_base + __this->_M_mmap_len); return traits_type::to_int_type(*__this->gptr()); } } } return __this->_M_underflow_aux(); } //---------------------------------------------------------------------- // Force instantiation of filebuf and fstream classes. #if !defined(__STL_NO_FORCE_INSTANTIATE) template class basic_filebuf<char, char_traits<char> >; template class basic_ifstream<char, char_traits<char> >; template class basic_ofstream<char, char_traits<char> >; template class basic_fstream<char, char_traits<char> >; #endif __STL_END_NAMESPACE // Local Variables: // mode:C++ // End:
[ [ [ 1, 1054 ] ] ]
a755429e91db20170b7c2ee85789d06a58233d2c
93eb4ff62a5fce345e5a16bd695b8725043a4242
/com/BotPlatformSDK/MiscObjBase.cpp
4661f5efb635954478a3abf9b2ff32b19e116e84
[]
no_license
adrianchia/botplatform
b8ed1e2494a96352e55da20e0a442ba9753d7582
4b04d1bb6d06b23b6a216d7a84331c6e378260c0
refs/heads/master
2020-04-05T02:40:08.665911
2010-07-09T08:38:53
2010-07-09T08:38:53
32,486,419
0
0
null
null
null
null
UTF-8
C++
false
false
272
cpp
#include "StdAfx.h" #include "MiscObjBase.h" void CheckToken::reset() { InterlockedExchange( &m_time, 0 ); } void CheckToken::step() { InterlockedIncrement( &m_time ); } bool CheckToken::isTimeOut() const { return m_time >= TIME_OUT; }
[ "[email protected]@0ded8006-25be-11df-b172-d5673a86adf5" ]
[ [ [ 1, 19 ] ] ]
9b54db234edf3b98193eebf71e27764a7830f759
04fec4cbb69789d44717aace6c8c5490f2cdfa47
/include/Poco/DynamicAny.h
8438c43aac6508df3c6d1577dd58b04cdb4358ea
[]
no_license
aaryanapps/whiteTiger
04f39b00946376c273bcbd323414f0a0b675d49d
65ed8ffd530f20198280b8a9ea79cb22a6a47acd
refs/heads/master
2021-01-17T12:07:15.264788
2010-10-11T20:20:26
2010-10-11T20:20:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
50,066
h
// // DynamicAny.h // // $Id: //poco/svn/Foundation/include/Poco/DynamicAny.h#2 $ // // Library: Foundation // Package: Core // Module: DynamicAny // // Definition of the DynamicAny class. // // Copyright (c) 2007, Applied Informatics Software Engineering GmbH. // and Contributors. // // 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. // #ifndef Foundation_DynamicAny_INCLUDED #define Foundation_DynamicAny_INCLUDED #include "Poco/Foundation.h" #include "Poco/DynamicAnyHolder.h" #include <typeinfo> namespace Poco { class Foundation_API DynamicAny /// DynamicAny allows to store data of different types and to convert between these types transparently. /// DynamicAny puts forth the best effort to provide intuitive and reasonable conversion semantics and prevent /// unexpected data loss, particularly when performing narrowing or signedness conversions of numeric data types. /// /// Loss of signedness is not allowed for numeric values. This means that if an attempt is made to convert /// the internal value which is a negative signed integer to an unsigned integer type storage, a RangeException is thrown. /// Overflow is not allowed, so if the internal value is a larger number than the target numeric type size can accomodate, /// a RangeException is thrown. /// /// Precision loss, such as in conversion from floating-point types to integers or from double to float on platforms /// where they differ in size (provided internal actual value fits in float min/max range), is allowed. /// /// String truncation is allowed -- it is possible to convert between string and character when string length is /// greater than 1. An empty string gets converted to the char '\0', a non-empty string is truncated to the first character. /// /// Boolean conversion is performed as follows: /// /// A string value "false" (not case sensitive), "0" or "" (empty string) can be converted to a boolean value false, /// any other string not being false by the above criteria evaluates to true (e.g: "hi" -> true). /// Integer 0 values are false, everything else is true. /// Floating point values equal to the minimal FP representation on a given platform are false, everything else is true. /// /// Arithmetic operations with POD types as well as between DynamicAny's are supported, subject to following /// limitations: /// /// - for std::string and const char* values, only '+' and '+=' operations are supported /// /// - for integral and floating point numeric values, following operations are supported: /// '+', '+=', '-', '-=', '*', '*=' , '/' and '/=' /// /// - for integral values, following operations are supported: /// prefix and postfix increment (++) and decement (--) /// /// - for all other types, InvalidArgumentException is thrown upon attempt of an arithmetic operation /// /// A DynamicAny can be created from and converted to a value of any type for which a specialization of /// DynamicAnyHolderImpl is available. For supported types, see DynamicAnyHolder documentation. { public: DynamicAny(); /// Creates a DynamicAny holding an int with value 0. template <typename T> DynamicAny(const T &val): _pHolder(new DynamicAnyHolderImpl<T>(val)) /// Creates the DynamicAny from the given value. { } DynamicAny(const char* pVal); // Convenience constructor for const char* which gets mapped to a std::string internally, i.e. pVal is deep-copied. DynamicAny(const DynamicAny& other); /// Copy constructor. ~DynamicAny(); /// Destroys the DynamicAny. void swap(DynamicAny& other); /// Swaps the content of the this DynamicAny with the other DynamicAny. template <typename T> void convert(T& val) const /// Invoke this method to perform a safe conversion. /// /// Example usage: /// DynamicAny any("42"); /// int i; /// any.convert(i); /// /// Throws a RangeException if the value does not fit /// into the result variable. /// Throws a NotImplementedException if conversion is /// not available for the given type. { _pHolder->convert(val); } template <typename T> T convert() const /// Invoke this method to perform a safe conversion. /// /// Example usage: /// DynamicAny any("42"); /// int i = any.convert<int>(); /// /// Throws a RangeException if the value does not fit /// into the result variable. /// Throws a NotImplementedException if conversion is /// not available for the given type. { T result; _pHolder->convert(result); return result; } template <typename T> operator T () const /// Safe conversion operator for implicit type /// conversions. /// /// Throws a RangeException if the value does not fit /// into the result variable. /// Throws a NotImplementedException if conversion is /// not available for the given type. { T result; _pHolder->convert(result); return result; } template <typename T> const T& extract() const /// Returns a const reference to the actual value. /// /// Must be instantiated with the exact type of /// the stored value, otherwise a BadCastException /// is thrown. { if (_pHolder && _pHolder->type() == typeid(T)) { DynamicAnyHolderImpl<T>* pHolder = static_cast<DynamicAnyHolderImpl<T>*>(_pHolder); return pHolder->value(); } else throw BadCastException(); } template <typename T> DynamicAny& operator = (const T& other) /// Assignment operator for assigning POD to DynamicAny { DynamicAny tmp(other); swap(tmp); return *this; } bool operator ! () { return !convert<bool>(); } DynamicAny& operator = (const DynamicAny& other); /// Assignment operator specialization for DynamicAny template <typename T> const DynamicAny operator + (const T& other) const /// Addition operator for adding POD to DynamicAny { return convert<T>() + other; } const DynamicAny operator + (const DynamicAny& other) const; /// Addition operator specialization for DynamicAny const DynamicAny operator + (const char* other) const; /// Addition operator specialization for adding const char* to DynamicAny DynamicAny& operator ++ (); /// Pre-increment operator DynamicAny operator ++ (int); /// Post-increment operator DynamicAny& operator -- (); /// Pre-decrement operator DynamicAny operator -- (int); /// Post-decrement operator template <typename T> DynamicAny& operator += (const T& other) /// Addition asignment operator for addition/assignment of POD to DynamicAny. { return *this = convert<T>() + other; } DynamicAny& operator += (const DynamicAny& other); /// Addition asignment operator specialization for DynamicAny DynamicAny& operator += (const char* other); /// Addition asignment operator specialization for const char* template <typename T> const DynamicAny operator - (const T& other) const /// Subtraction operator for subtracting POD from DynamicAny { return convert<T>() - other; } const DynamicAny operator - (const DynamicAny& other) const; /// Subtraction operator specialization for DynamicAny template <typename T> DynamicAny& operator -= (const T& other) /// Subtraction asignment operator { return *this = convert<T>() - other; } DynamicAny& operator -= (const DynamicAny& other); /// Subtraction asignment operator specialization for DynamicAny template <typename T> const DynamicAny operator * (const T& other) const /// Multiplication operator for multiplying DynamicAny with POD { return convert<T>() * other; } const DynamicAny operator * (const DynamicAny& other) const; /// Multiplication operator specialization for DynamicAny template <typename T> DynamicAny& operator *= (const T& other) /// Multiplication asignment operator { return *this = convert<T>() * other; } DynamicAny& operator *= (const DynamicAny& other); /// Multiplication asignment operator specialization for DynamicAny template <typename T> const DynamicAny operator / (const T& other) const /// Division operator for dividing DynamicAny with POD { return convert<T>() / other; } const DynamicAny operator / (const DynamicAny& other) const; /// Division operator specialization for DynamicAny template <typename T> DynamicAny& operator /= (const T& other) /// Division asignment operator { return *this = convert<T>() / other; } DynamicAny& operator /= (const DynamicAny& other); /// Division asignment operator specialization for DynamicAny template <typename T> bool operator == (const T& other) const /// Equality operator { return convert<T>() == other; } bool operator == (const char* other) const; /// Equality operator specialization for const char* bool operator == (const DynamicAny& other) const; /// Equality operator specialization for DynamicAny template <typename T> bool operator != (const T& other) const /// Inequality operator { return convert<T>() != other; } bool operator != (const DynamicAny& other) const; /// Inequality operator specialization for DynamicAny bool operator != (const char* other) const; /// Inequality operator specialization for const char* template <typename T> bool operator < (const T& other) const /// Less than operator { return convert<T>() < other; } template <typename T> bool operator <= (const T& other) const /// Less than or equal operator { return convert<T>() <= other; } template <typename T> bool operator > (const T& other) const /// Greater than operator { return convert<T>() > other; } template <typename T> bool operator >= (const T& other) const /// Greater than or equal operator { return convert<T>() >= other; } bool isArray() const; /// Returns true if DynamicAny represents a vector bool isStruct() const; /// Returns true if DynamicAny represents a struct template <typename T> DynamicAny& operator [] (T n) /// Index operator, only use on DynamicAnys where isArray /// returns true! In all other cases a BadCastException is thrown! { DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder = dynamic_cast<DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder); if (pHolder) return pHolder->operator[](n); else throw BadCastException(); } template <typename T> const DynamicAny& operator [] (T n) const /// const Index operator, only use on DynamicAnys where isArray /// returns true! In all other cases a BadCastException is thrown! { const DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder = dynamic_cast<const DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder); if (pHolder) return pHolder->operator[](n); else throw BadCastException(); } DynamicAny& operator [] (const std::string& name); /// Index operator by name, only use on DynamicAnys where isStruct /// returns true! In all other cases a BadCastException is thrown! const DynamicAny& operator [] (const std::string& name) const; /// Index operator by name, only use on DynamicAnys where isStruct /// returns true! In all other cases a BadCastException is thrown! DynamicAny& operator [] (const char* name); /// Index operator by name, only use on DynamicAnys where isStruct /// returns true! In all other cases a BadCastException is thrown! const DynamicAny& operator [] (const char* name) const; /// Index operator by name, only use on DynamicAnys where isStruct /// returns true! In all other cases a BadCastException is thrown! const std::type_info& type() const; /// Returns the type information of the stored content. bool isInteger() const; /// Returns true if stored value is integer. bool isSigned() const; /// Returns true if stored value is signed. bool isNumeric() const; /// Returns true if stored value is numeric. /// Returns false for numeric strings (e.g. "123" is string, not number) bool isString() const; /// Returns true if stored value is std::string. static DynamicAny parse(const std::string& val); /// Parses the string which must be in JSON format static std::string toString(const DynamicAny& any); /// Converts the DynamicAny to a string in JSON format. Note that toString will return /// a different result than any.convert<std::string>()! private: static DynamicAny parse(const std::string& val, std::string::size_type& offset); /// Parses the string which must be in JSON format static DynamicAny parseObject(const std::string& val, std::string::size_type& pos); static DynamicAny parseArray(const std::string& val, std::string::size_type& pos); static std::string parseString(const std::string& val, std::string::size_type& pos); static void skipWhiteSpace(const std::string& val, std::string::size_type& pos); template <typename T> T add(const DynamicAny& other) const { return convert<T>() + other.convert<T>(); } template <typename T> T subtract(const DynamicAny& other) const { return convert<T>() - other.convert<T>(); } template <typename T> T multiply(const DynamicAny& other) const { return convert<T>() * other.convert<T>(); } template <typename T> T divide(const DynamicAny& other) const { return convert<T>() / other.convert<T>(); } DynamicAnyHolder* _pHolder; }; /// /// inlines /// /// /// DynamicAny members /// inline void DynamicAny::swap(DynamicAny& ptr) { std::swap(_pHolder, ptr._pHolder); } inline const std::type_info& DynamicAny::type() const { return _pHolder->type(); } inline DynamicAny& DynamicAny::operator [] (const char* name) { return operator [] (std::string(name)); } inline const DynamicAny& DynamicAny::operator [] (const char* name) const { return operator [] (std::string(name)); } inline const DynamicAny DynamicAny::operator + (const char* other) const { return convert<std::string>() + other; } inline DynamicAny& DynamicAny::operator += (const char*other) { return *this = convert<std::string>() + other; } inline bool DynamicAny::operator == (const DynamicAny& other) const { return convert<std::string>() == other.convert<std::string>(); } inline bool DynamicAny::operator == (const char* other) const { return convert<std::string>() == other; } inline bool DynamicAny::operator != (const DynamicAny& other) const { return convert<std::string>() != other.convert<std::string>(); } inline bool DynamicAny::operator != (const char* other) const { return convert<std::string>() != other; } inline bool DynamicAny::isArray() const { return _pHolder->isArray(); } inline bool DynamicAny::isStruct() const { return _pHolder->isStruct(); } inline bool DynamicAny::isInteger() const { return _pHolder->isInteger(); } inline bool DynamicAny::isSigned() const { return _pHolder->isSigned(); } inline bool DynamicAny::isNumeric() const { return _pHolder->isNumeric(); } inline bool DynamicAny::isString() const { return _pHolder->isString(); } /// /// DynamicAny non-member functions /// inline const DynamicAny operator + (const char* other, const DynamicAny& da) /// Addition operator for adding DynamicAny to const char* { std::string tmp = other; return tmp + da.convert<std::string>(); } inline const char operator + (const char& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to char { return other + da.convert<char>(); } inline const char operator - (const char& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from char { return other - da.convert<char>(); } inline const char operator * (const char& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with char { return other * da.convert<char>(); } inline const char operator / (const char& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with char { return other / da.convert<char>(); } inline char operator += (char& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to char { return other += da.convert<char>(); } inline char operator -= (char& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from char { return other -= da.convert<char>(); } inline char operator *= (char& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with char { return other *= da.convert<char>(); } inline char operator /= (char& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with char { return other /= da.convert<char>(); } inline const bool operator == (const char& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with char { return other == da.convert<char>(); } inline const bool operator != (const char& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with char { return other != da.convert<char>(); } inline const bool operator < (const char& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with char { return other < da.convert<char>(); } inline const bool operator <= (const char& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with char { return other <= da.convert<char>(); } inline const bool operator > (const char& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with char { return other > da.convert<char>(); } inline const bool operator >= (const char& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with char { return other >= da.convert<char>(); } inline const Poco::Int8 operator + (const Poco::Int8& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::Int8 { return other + da.convert<Poco::Int8>(); } inline const Poco::Int8 operator - (const Poco::Int8& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::Int8 { return other - da.convert<Poco::Int8>(); } inline const Poco::Int8 operator * (const Poco::Int8& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::Int8 { return other * da.convert<Poco::Int8>(); } inline const Poco::Int8 operator / (const Poco::Int8& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::Int8 { return other / da.convert<Poco::Int8>(); } inline Poco::Int8 operator += (Poco::Int8& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::Int8 { return other += da.convert<Poco::Int8>(); } inline Poco::Int8 operator -= (Poco::Int8& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::Int8 { return other -= da.convert<Poco::Int8>(); } inline Poco::Int8 operator *= (Poco::Int8& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::Int8 { return other *= da.convert<Poco::Int8>(); } inline Poco::Int8 operator /= (Poco::Int8& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::Int8 { return other /= da.convert<Poco::Int8>(); } inline const bool operator == (const Poco::Int8& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::Int8 { return other == da.convert<Poco::Int8>(); } inline const bool operator != (const Poco::Int8& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::Int8 { return other != da.convert<Poco::Int8>(); } inline const bool operator < (const Poco::Int8& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::Int8 { return other < da.convert<Poco::Int8>(); } inline const bool operator <= (const Poco::Int8& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::Int8 { return other <= da.convert<Poco::Int8>(); } inline const bool operator > (const Poco::Int8& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::Int8 { return other > da.convert<Poco::Int8>(); } inline const bool operator >= (const Poco::Int8& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::Int8 { return other >= da.convert<Poco::Int8>(); } inline const Poco::UInt8 operator + (const Poco::UInt8& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::UInt8 { return other + da.convert<Poco::UInt8>(); } inline const Poco::UInt8 operator - (const Poco::UInt8& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::UInt8 { return other - da.convert<Poco::UInt8>(); } inline const Poco::UInt8 operator * (const Poco::UInt8& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::UInt8 { return other * da.convert<Poco::UInt8>(); } inline const Poco::UInt8 operator / (const Poco::UInt8& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::UInt8 { return other / da.convert<Poco::UInt8>(); } inline Poco::UInt8 operator += (Poco::UInt8& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::UInt8 { return other += da.convert<Poco::UInt8>(); } inline Poco::UInt8 operator -= (Poco::UInt8& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::UInt8 { return other -= da.convert<Poco::UInt8>(); } inline Poco::UInt8 operator *= (Poco::UInt8& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::UInt8 { return other *= da.convert<Poco::UInt8>(); } inline Poco::UInt8 operator /= (Poco::UInt8& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::UInt8 { return other /= da.convert<Poco::UInt8>(); } inline const bool operator == (const Poco::UInt8& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::UInt8 { return other == da.convert<Poco::UInt8>(); } inline const bool operator != (const Poco::UInt8& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::UInt8 { return other != da.convert<Poco::UInt8>(); } inline const bool operator < (const Poco::UInt8& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::UInt8 { return other < da.convert<Poco::UInt8>(); } inline const bool operator <= (const Poco::UInt8& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::UInt8 { return other <= da.convert<Poco::UInt8>(); } inline const bool operator > (const Poco::UInt8& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::UInt8 { return other > da.convert<Poco::UInt8>(); } inline const bool operator >= (const Poco::UInt8& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::UInt8 { return other >= da.convert<Poco::UInt8>(); } inline const Poco::Int16 operator + (const Poco::Int16& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::Int16 { return other + da.convert<Poco::Int16>(); } inline const Poco::Int16 operator - (const Poco::Int16& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::Int16 { return other - da.convert<Poco::Int16>(); } inline const Poco::Int16 operator * (const Poco::Int16& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::Int16 { return other * da.convert<Poco::Int16>(); } inline const Poco::Int16 operator / (const Poco::Int16& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::Int16 { return other / da.convert<Poco::Int16>(); } inline Poco::Int16 operator += (Poco::Int16& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::Int16 { return other += da.convert<Poco::Int16>(); } inline Poco::Int16 operator -= (Poco::Int16& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::Int16 { return other -= da.convert<Poco::Int16>(); } inline Poco::Int16 operator *= (Poco::Int16& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::Int16 { return other *= da.convert<Poco::Int16>(); } inline Poco::Int16 operator /= (Poco::Int16& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::Int16 { return other /= da.convert<Poco::Int16>(); } inline const bool operator == (const Poco::Int16& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::Int16 { return other == da.convert<Poco::Int16>(); } inline const bool operator != (const Poco::Int16& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::Int16 { return other != da.convert<Poco::Int16>(); } inline const bool operator < (const Poco::Int16& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::Int16 { return other < da.convert<Poco::Int16>(); } inline const bool operator <= (const Poco::Int16& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::Int16 { return other <= da.convert<Poco::Int16>(); } inline const bool operator > (const Poco::Int16& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::Int16 { return other > da.convert<Poco::Int16>(); } inline const bool operator >= (const Poco::Int16& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::Int16 { return other >= da.convert<Poco::Int16>(); } inline const Poco::UInt16 operator + (const Poco::UInt16& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::UInt16 { return other + da.convert<Poco::UInt16>(); } inline const Poco::UInt16 operator - (const Poco::UInt16& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::UInt16 { return other - da.convert<Poco::UInt16>(); } inline const Poco::UInt16 operator * (const Poco::UInt16& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::UInt16 { return other * da.convert<Poco::UInt16>(); } inline const Poco::UInt16 operator / (const Poco::UInt16& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::UInt16 { return other / da.convert<Poco::UInt16>(); } inline Poco::UInt16 operator += (Poco::UInt16& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::UInt16 { return other += da.convert<Poco::UInt16>(); } inline Poco::UInt16 operator -= (Poco::UInt16& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::UInt16 { return other -= da.convert<Poco::UInt16>(); } inline Poco::UInt16 operator *= (Poco::UInt16& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::UInt16 { return other *= da.convert<Poco::UInt16>(); } inline Poco::UInt16 operator /= (Poco::UInt16& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::UInt16 { return other /= da.convert<Poco::UInt16>(); } inline const bool operator == (const Poco::UInt16& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::UInt16 { return other == da.convert<Poco::UInt16>(); } inline const bool operator != (const Poco::UInt16& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::UInt16 { return other != da.convert<Poco::UInt16>(); } inline const bool operator < (const Poco::UInt16& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::UInt16 { return other < da.convert<Poco::UInt16>(); } inline const bool operator <= (const Poco::UInt16& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::UInt16 { return other <= da.convert<Poco::UInt16>(); } inline const bool operator > (const Poco::UInt16& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::UInt16 { return other > da.convert<Poco::UInt16>(); } inline const bool operator >= (const Poco::UInt16& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::UInt16 { return other >= da.convert<Poco::UInt16>(); } inline const Poco::Int32 operator + (const Poco::Int32& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::Int32 { return other + da.convert<Poco::Int32>(); } inline const Poco::Int32 operator - (const Poco::Int32& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::Int32 { return other - da.convert<Poco::Int32>(); } inline const Poco::Int32 operator * (const Poco::Int32& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::Int32 { return other * da.convert<Poco::Int32>(); } inline const Poco::Int32 operator / (const Poco::Int32& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::Int32 { return other / da.convert<Poco::Int32>(); } inline Poco::Int32 operator += (Poco::Int32& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::Int32 { return other += da.convert<Poco::Int32>(); } inline Poco::Int32 operator -= (Poco::Int32& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::Int32 { return other -= da.convert<Poco::Int32>(); } inline Poco::Int32 operator *= (Poco::Int32& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::Int32 { return other *= da.convert<Poco::Int32>(); } inline Poco::Int32 operator /= (Poco::Int32& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::Int32 { return other /= da.convert<Poco::Int32>(); } inline const bool operator == (const Poco::Int32& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::Int32 { return other == da.convert<Poco::Int32>(); } inline const bool operator != (const Poco::Int32& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::Int32 { return other != da.convert<Poco::Int32>(); } inline const bool operator < (const Poco::Int32& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::Int32 { return other < da.convert<Poco::Int32>(); } inline const bool operator <= (const Poco::Int32& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::Int32 { return other <= da.convert<Poco::Int32>(); } inline const bool operator > (const Poco::Int32& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::Int32 { return other > da.convert<Poco::Int32>(); } inline const bool operator >= (const Poco::Int32& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::Int32 { return other >= da.convert<Poco::Int32>(); } inline const Poco::UInt32 operator + (const Poco::UInt32& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::UInt32 { return other + da.convert<Poco::UInt32>(); } inline const Poco::UInt32 operator - (const Poco::UInt32& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::UInt32 { return other - da.convert<Poco::UInt32>(); } inline const Poco::UInt32 operator * (const Poco::UInt32& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::UInt32 { return other * da.convert<Poco::UInt32>(); } inline const Poco::UInt32 operator / (const Poco::UInt32& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::UInt32 { return other / da.convert<Poco::UInt32>(); } inline Poco::UInt32 operator += (Poco::UInt32& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::UInt32 { return other += da.convert<Poco::UInt32>(); } inline Poco::UInt32 operator -= (Poco::UInt32& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::UInt32 { return other -= da.convert<Poco::UInt32>(); } inline Poco::UInt32 operator *= (Poco::UInt32& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::UInt32 { return other *= da.convert<Poco::UInt32>(); } inline Poco::UInt32 operator /= (Poco::UInt32& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::UInt32 { return other /= da.convert<Poco::UInt32>(); } inline const bool operator == (const Poco::UInt32& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::UInt32 { return other == da.convert<Poco::UInt32>(); } inline const bool operator != (const Poco::UInt32& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::UInt32 { return other != da.convert<Poco::UInt32>(); } inline const bool operator < (const Poco::UInt32& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::UInt32 { return other < da.convert<Poco::UInt32>(); } inline const bool operator <= (const Poco::UInt32& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::UInt32 { return other <= da.convert<Poco::UInt32>(); } inline const bool operator > (const Poco::UInt32& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::UInt32 { return other > da.convert<Poco::UInt32>(); } inline const bool operator >= (const Poco::UInt32& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::UInt32 { return other >= da.convert<Poco::UInt32>(); } inline const Poco::Int64 operator + (const Poco::Int64& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::Int64 { return other + da.convert<Poco::Int64>(); } inline const Poco::Int64 operator - (const Poco::Int64& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::Int64 { return other - da.convert<Poco::Int64>(); } inline const Poco::Int64 operator * (const Poco::Int64& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::Int64 { return other * da.convert<Poco::Int64>(); } inline const Poco::Int64 operator / (const Poco::Int64& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::Int64 { return other / da.convert<Poco::Int64>(); } inline Poco::Int64 operator += (Poco::Int64& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::Int64 { return other += da.convert<Poco::Int64>(); } inline Poco::Int64 operator -= (Poco::Int64& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::Int64 { return other -= da.convert<Poco::Int64>(); } inline Poco::Int64 operator *= (Poco::Int64& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::Int64 { return other *= da.convert<Poco::Int64>(); } inline Poco::Int64 operator /= (Poco::Int64& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::Int64 { return other /= da.convert<Poco::Int64>(); } inline const bool operator == (const Poco::Int64& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::Int64 { return other == da.convert<Poco::Int64>(); } inline const bool operator != (const Poco::Int64& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::Int64 { return other != da.convert<Poco::Int64>(); } inline const bool operator < (const Poco::Int64& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::Int64 { return other < da.convert<Poco::Int64>(); } inline const bool operator <= (const Poco::Int64& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::Int64 { return other <= da.convert<Poco::Int64>(); } inline const bool operator > (const Poco::Int64& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::Int64 { return other > da.convert<Poco::Int64>(); } inline const bool operator >= (const Poco::Int64& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::Int64 { return other >= da.convert<Poco::Int64>(); } inline const Poco::UInt64 operator + (const Poco::UInt64& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to Poco::UInt64 { return other + da.convert<Poco::UInt64>(); } inline const Poco::UInt64 operator - (const Poco::UInt64& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from Poco::UInt64 { return other - da.convert<Poco::UInt64>(); } inline const Poco::UInt64 operator * (const Poco::UInt64& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with Poco::UInt64 { return other * da.convert<Poco::UInt64>(); } inline const Poco::UInt64 operator / (const Poco::UInt64& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with Poco::UInt64 { return other / da.convert<Poco::UInt64>(); } inline Poco::UInt64 operator += (Poco::UInt64& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to Poco::UInt64 { return other += da.convert<Poco::UInt64>(); } inline Poco::UInt64 operator -= (Poco::UInt64& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from Poco::UInt64 { return other -= da.convert<Poco::UInt64>(); } inline Poco::UInt64 operator *= (Poco::UInt64& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with Poco::UInt64 { return other *= da.convert<Poco::UInt64>(); } inline Poco::UInt64 operator /= (Poco::UInt64& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with Poco::UInt64 { return other /= da.convert<Poco::UInt64>(); } inline const bool operator == (const Poco::UInt64& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with Poco::UInt64 { return other == da.convert<Poco::UInt64>(); } inline const bool operator != (const Poco::UInt64& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with Poco::UInt64 { return other != da.convert<Poco::UInt64>(); } inline const bool operator < (const Poco::UInt64& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with Poco::UInt64 { return other < da.convert<Poco::UInt64>(); } inline const bool operator <= (const Poco::UInt64& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with Poco::UInt64 { return other <= da.convert<Poco::UInt64>(); } inline const bool operator > (const Poco::UInt64& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with Poco::UInt64 { return other > da.convert<Poco::UInt64>(); } inline const bool operator >= (const Poco::UInt64& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with Poco::UInt64 { return other >= da.convert<Poco::UInt64>(); } inline const float operator + (const float& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to float { return other + da.convert<float>(); } inline const float operator - (const float& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from float { return other - da.convert<float>(); } inline const float operator * (const float& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with float { return other * da.convert<float>(); } inline const float operator / (const float& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with float { return other / da.convert<float>(); } inline float operator += (float& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to float { return other += da.convert<float>(); } inline float operator -= (float& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from float { return other -= da.convert<float>(); } inline float operator *= (float& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with float { return other *= da.convert<float>(); } inline float operator /= (float& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with float { return other /= da.convert<float>(); } inline const bool operator == (const float& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with float { return other == da.convert<float>(); } inline const bool operator != (const float& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with float { return other != da.convert<float>(); } inline const bool operator < (const float& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with float { return other < da.convert<float>(); } inline const bool operator <= (const float& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with float { return other <= da.convert<float>(); } inline const bool operator > (const float& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with float { return other > da.convert<float>(); } inline const bool operator >= (const float& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with float { return other >= da.convert<float>(); } inline const double operator + (const double& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to double { return other + da.convert<double>(); } inline const double operator - (const double& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from double { return other - da.convert<double>(); } inline const double operator * (const double& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with double { return other * da.convert<double>(); } inline const double operator / (const double& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with double { return other / da.convert<double>(); } inline double operator += (double& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to double { return other += da.convert<double>(); } inline double operator -= (double& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from double { return other -= da.convert<double>(); } inline double operator *= (double& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with double { return other *= da.convert<double>(); } inline double operator /= (double& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with double { return other /= da.convert<double>(); } inline const bool operator == (const double& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with double { return other == da.convert<double>(); } inline const bool operator != (const double& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with double { return other != da.convert<double>(); } inline const bool operator < (const double& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with double { return other < da.convert<double>(); } inline const bool operator <= (const double& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with double { return other <= da.convert<double>(); } inline const bool operator > (const double& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with double { return other > da.convert<double>(); } inline const bool operator >= (const double& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with double { return other >= da.convert<double>(); } inline const bool operator == (const bool& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with bool { return other == da.convert<bool>(); } inline const bool operator != (const bool& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with bool { return other != da.convert<bool>(); } inline const bool operator == (const std::string& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with std::string { return other == da.convert<std::string>(); } inline const bool operator != (const std::string& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with std::string { return other != da.convert<std::string>(); } inline const bool operator == (const char* other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with const char* { return da.convert<std::string>() == other; } inline const bool operator != (const char* other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with const char* { return da.convert<std::string>() != other; } #ifndef POCO_LONG_IS_64_BIT inline const long operator + (const long& other, const DynamicAny& da) /// Addition operator for adding DynamicAny to long { return other + da.convert<long>(); } inline const long operator - (const long& other, const DynamicAny& da) /// Subtraction operator for subtracting DynamicAny from long { return other - da.convert<long>(); } inline const long operator * (const long& other, const DynamicAny& da) /// Multiplication operator for multiplying DynamicAny with long { return other * da.convert<long>(); } inline const long operator / (const long& other, const DynamicAny& da) /// Division operator for dividing DynamicAny with long { return other / da.convert<long>(); } inline long operator += (long& other, const DynamicAny& da) /// Addition asignment operator for adding DynamicAny to long { return other += da.convert<long>(); } inline long operator -= (long& other, const DynamicAny& da) /// Subtraction asignment operator for subtracting DynamicAny from long { return other -= da.convert<long>(); } inline long operator *= (long& other, const DynamicAny& da) /// Multiplication asignment operator for multiplying DynamicAny with long { return other *= da.convert<long>(); } inline long operator /= (long& other, const DynamicAny& da) /// Division asignment operator for dividing DynamicAny with long { return other /= da.convert<long>(); } inline const bool operator == (const long& other, const DynamicAny& da) /// Equality operator for comparing DynamicAny with long { return other == da.convert<long>(); } inline const bool operator != (const long& other, const DynamicAny& da) /// Inequality operator for comparing DynamicAny with long { return other != da.convert<long>(); } inline const bool operator < (const long& other, const DynamicAny& da) /// Less than operator for comparing DynamicAny with long { return other < da.convert<long>(); } inline const bool operator <= (const long& other, const DynamicAny& da) /// Less than or equal operator for comparing DynamicAny with long { return other <= da.convert<long>(); } inline const bool operator > (const long& other, const DynamicAny& da) /// Greater than operator for comparing DynamicAny with long { return other > da.convert<long>(); } inline const bool operator >= (const long& other, const DynamicAny& da) /// Greater than or equal operator for comparing DynamicAny with long { return other >= da.convert<long>(); } #endif // POCO_LONG_IS_64_BIT } // namespace Poco #endif // Foundation_DynamicAny_INCLUDED
[ [ [ 1, 1801 ] ] ]
b145cec9f0d1c12032c046d930cf5cc0a67c3811
5e0422794380a8f3bf06d0c37ac2354f4b91fefb
/fastnetwork/session_manager.cpp
0cba5a36ef9a0f43461124654bff934c58f6643b
[]
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,687
cpp
#include "StdAfx.h" #include "session_manager.h" #include "udp_session.h" #include "tcp_session.h" using namespace boost; using namespace boost::asio; using namespace fastnetwork; shared_ptr<io_session> fastnetwork::session_manager::new_session( shared_ptr<ip::udp::socket> socket, endpoint remote ) { mutex::scoped_lock lock(mutex_); shared_ptr<io_session> session( new udp::udp_session( *this, socket, remote, 120 ) ); sessions_.insert( make_pair(remote, session) ); return session; } shared_ptr<io_session> fastnetwork::session_manager::new_session( shared_ptr<ip::tcp::socket> socket, endpoint remote ) { mutex::scoped_lock lock(mutex_); shared_ptr<io_session> session( new tcp::tcp_session( *this, socket, remote, 120 ) ); sessions_.insert( make_pair(remote, session) ); return session; } void fastnetwork::session_manager::check_session_idle() { session_map idle_sessions; find_idle_sessions(idle_sessions); for ( session_map::iterator it = idle_sessions.begin(); it != idle_sessions.end(); ++it ) { shared_ptr<io_session> session = it->second; session->get_filter_chain()->session_idle( session ); } } void fastnetwork::session_manager::close_session( shared_ptr<io_session> session ) { mutex::scoped_lock lock(mutex_); sessions_.erase( session->get_remote_endpoint() ); } void fastnetwork::session_manager::find_idle_sessions( session_map &idle_sessions ) { mutex::scoped_lock lock(mutex_); for ( session_map::iterator it = sessions_.begin(); it != sessions_.end(); ++it ) { shared_ptr<io_session> session = it->second; if ( session->is_idle() ) { idle_sessions.insert( *it ); } } }
[ "everwanna@8b0bd7a0-72c1-11de-90d8-1fdda9445408" ]
[ [ [ 1, 56 ] ] ]
05c7f2b6e0494ffbf09a418d8b72e71815d15f71
bda7b365b5952dc48827a8e8d33d11abd458c5eb
/Runnable_PS3/gcmutil.h
aa251d623f4d7ec7bbb5e03d42a3283a27d634ed
[]
no_license
MrColdbird/gameservice
3bc4dc3906d16713050612c1890aa8820d90272e
009d28334bdd8f808914086e8367b1eb9497c56a
refs/heads/master
2021-01-25T09:59:24.143855
2011-01-31T07:12:24
2011-01-31T07:12:24
35,889,912
3
3
null
null
null
null
UTF-8
C++
false
false
7,301
h
/* SCE CONFIDENTIAL * PlayStation(R)3 Programmer Tool Runtime Library 330.001 * Copyright (C) 2009 Sony Computer Entertainment Inc. * All Rights Reserved. */ #ifndef __CELL_GCMUTIL_H__ #define __CELL_GCMUTIL_H__ // libgcm #include <cell/gcm.h> #include <sysutil/sysutil_sysparam.h> #if defined(__cplusplus) // cgb #include <cell/cgb.h> // vector math #include <vectormath/cpp/vectormath_aos.h> // gcmutil definition #include "gcmutil_type.h" #include "gcmutil_enum.h" #include "gcmutil_inline.h" #include "gcmutil_class.h" #include "gcmutil_error.h" #endif // old interface #include "gcmutil_old.h" #if defined(__cplusplus) #include "padutil.h" #include "gtfloader.h" namespace CellGcmUtil{ /* memory.cpp */ bool cellGcmUtilInitLocal(void* local_base_addr, size_t local_size); bool cellGcmUtilInitMain(void* main_base_addr, size_t main_size); bool cellGcmUtilAllocateLocal(uint32_t size, uint32_t alignment, Memory_t *memory); bool cellGcmUtilAllocateMain(uint32_t size, uint32_t alignment, Memory_t *memory); bool cellGcmUtilAllocate(uint32_t size, uint32_t alignment, uint8_t location, Memory_t *memory); bool cellGcmUtilReallocate(Memory_t *memory, uint8_t location, uint32_t alignment); bool cellGcmUtilAllocateUnmappedMain(uint32_t size, uint32_t alignment, Memory_t *memory); void cellGcmUtilFree(Memory_t *memory); void cellGcmUtilFinalizeMemory(void); /* file.cpp */ bool cellGcmUtilReadFile(const char *fname, uint8_t **buffer, uint32_t *buf_size, uint32_t offset = 0, uint32_t size = 0xFFFFFFFFUL); bool cellGcmUtilWriteFile(const char *fname, uint8_t *buffer, uint32_t buf_size); uint32_t cellGcmUtilGetFileList(const char *path, const char *ext, FileList_t *filelist); void cellGcmUtilFreeFileList(FileList_t *filelist); bool cellGcmUtilIsFileExsits(const char *fname); void cellGcmUtilAddFileList(FileList_t *filelist, const char *fname); void cellGcmUtilSortFileList(FileList_t *filelist); /* display */ bool cellGcmUtilInitDisplay(uint8_t color_format, uint8_t depth_format, uint8_t buffer_number, Memory_t *buffer, CellGcmSurface *surface); bool cellGcmUtilSetDisplayBuffer(uint8_t number, CellGcmTexture *texture_array); /* tile.cpp */ int cellGcmUtilUnpackTileInfo(int index, const CellGcmTileInfo *raw_tile_info, CellGcmUtilUnpackedTileInfo *outTileInfo); /* zcull.cpp */ int cellGcmUtilUnpackZcullInfo(int index, const CellGcmZcullInfo *raw_zcull_info, CellGcmUtilUnpackedZcullInfo *outZcullInfo); /* dbgfont.cpp */ bool cellGcmUtilDbgfontInit(int32_t word_count, void* addr, uint32_t size, uint8_t location); void cellGcmUtilDbgfontEnd(void); uint32_t cellGcmUtilDbgfontGetRequireSize(int32_t word_count); void cellGcmUtilPuts(const char* str); void cellGcmUtilPrintf(const char* format, ...); void cellGcmUtilPrintfColor(uint32_t color, const char* format, ...); void cellGcmUtilSetPrintPos(float x, float y); void cellGcmUtilSetPrintSize(float size); void cellGcmUtilSetPrintColor(uint32_t color); void cellGcmUtilGetPrintPos(float *x, float *y); /* utility.cpp */ bool cellGcmUtilInit(int32_t cb_size, int32_t main_size); void cellGcmUtilEnd(); CellVideoOutResolution cellGcmUtilGetResolution(void); float cellGcmUtilGetAspectRatio(); Viewport_t cellGcmUtilGetViewport2D(uint16_t width, uint16_t height); Viewport_t cellGcmUtilGetViewportGL(uint32_t surface_height, uint32_t vpX, uint32_t vpY, uint32_t vpWidth, uint32_t vpHeight, float vpZMin, float vpZMax); Viewport_t cellGcmUtilGetViewportDX(uint32_t vpX, uint32_t vpY, uint32_t vpWidth, uint32_t vpHeight, float vpZMin, float vpZMax); bool cellGcmUtilOffsetToAddress(uint8_t location, uint32_t offset, void **address); /* shader.cpp */ bool cellGcmUtilLoadShader(const char *fname, Shader_t *shader); bool cellGcmUtilLoadShaderFromMemory(const unsigned char *buffer, uint32_t size, Shader_t *shader); void cellGcmUtilDestroyShader(Shader_t *shader); bool cellGcmUtilGetVertexUCode(const Shader_t *shader, Memory_t *ucode); bool cellGcmUtilGetFragmentUCode(const Shader_t *shader, uint8_t location, Memory_t *ucode); /* texture.cpp */ bool cellGcmUtilCreateTexture(CellGcmTexture *texture, Memory_t *image); bool cellGcmUtilCreateSimpleTexture(uint32_t width, uint32_t height, uint8_t location, CellGcmTexture *texture, Memory_t *image); bool cellGcmUtilLoadTexture(const char* fname, uint32_t location, CellGcmTexture *tex, Memory_t *image); bool cellGcmUtilLoadTextureFromMemory(const unsigned char *buffer, uint32_t size, uint32_t location, CellGcmTexture *tex, Memory_t *image); uint32_t cellGcmUtilLoadPackedTexture(const char* fname, uint32_t index, uint32_t location, CellGcmTexture *texture, Memory_t *image); void cellGcmUtilSetTextureUnit(uint32_t tex_unit, const CellGcmTexture *tex); void cellGcmUtilInvalidateTextureUnit(uint32_t tex_unit); uint32_t cellGcmUtilGetTextureRequireSize(const CellGcmTexture tex); uint8_t cellGcmUtilGetRawFormat(uint8_t texture_format); const char* cellGcmUtilGetFormatName(uint8_t texture_format); uint16_t cellGcmUtilStr2Remap(const char *str); const char* cellGcmUtilRemap2Str(uint16_t remap); bool cellGcmUtilSaveTexture(const char* fname, const CellGcmTexture *texture, Memory_t *image); CellGcmTexture cellGcmUtilSurfaceToTexture(const CellGcmSurface *surface, uint32_t index); CellGcmTexture cellGcmUtilDepthToTexture(const CellGcmSurface *surface, bool bAsColor); CellGcmSurface cellGcmUtilTextureToSurface(const CellGcmTexture *color, const CellGcmTexture *depth); bool cellGcmUtilCreateTiledTexture(uint32_t width, uint32_t height, uint8_t format, uint8_t location, uint32_t comp_mode, uint32_t number, CellGcmTexture *texture_array, Memory_t *buffer); bool cellGcmUtilCreateRenderTexture(uint32_t width, uint32_t height, uint8_t format, uint8_t location, uint32_t comp_mode, CellGcmTexture *texture, Memory_t *image); bool cellGcmUtilCreateDepthTexture(uint32_t width, uint32_t height, uint8_t format, uint8_t location, uint32_t msaa_mode, bool bZCull, bool bTile, CellGcmTexture *texture, Memory_t *image); uint8_t cellGcmUtilBindTile(CellGcmTexture *texture, uint32_t comp_mode); uint8_t cellGcmUtilBindSharedTile(CellGcmTexture *texture, uint32_t comp_mode, uint32_t size); uint32_t cellGcmUtilBindZCull(CellGcmTexture *texture); void cellGcmUtilUnbindTile(CellGcmTexture *texture); void cellGcmUtilUnbindZCull(CellGcmTexture *texture); /* camera.cpp */ void cellGcmUtilSimpleCameraInit(Vectormath::Aos::Vector3 eye, Vectormath::Aos::Vector3 at, Vectormath::Aos::Vector3 up); void cellGcmUtilSimpleCameraUpdate(void); void cellGcmUtilSimpleCameraMove(int32_t dx, int32_t dy, int32_t dz, bool bReset); Vectormath::Aos::Matrix4 cellGcmUtilSimpleCameraGetMatrix(void); void cellGcmUtilSimpleCameraGetInitParam(Vectormath::Aos::Vector3 *eye, Vectormath::Aos::Vector3 *at, Vectormath::Aos::Vector3 *up); void cellGcmUtilSimpleCameraGetStatus(Vectormath::Aos::Vector3 *eye, Vectormath::Aos::Vector3 *at, Vectormath::Aos::Vector3 *up); void cellGcmUtilSimpleCameraGetParam(Vectormath::Aos::Vector3 *trans, float *yaw, float *pitch); void cellGcmUtilSimpleCameraSetParam(Vectormath::Aos::Vector3 trans, float yaw, float pitch); } // namespace CellGcmUtil #endif #endif /* __CELL_GCMUTIL_H__ */
[ "leavesmaple@383b229b-c81f-2bc2-fa3f-61d2d0c0fe69" ]
[ [ [ 1, 144 ] ] ]
fac020c02c976f5769fa3e36a454d2634da06cbb
3d560d0b4772580943946c78e2612ac0589c7958
/examples/poly_serialization.hpp
45c1322f92b283c8f60aaa39a789b1e87caa70cd
[]
no_license
black-square/id2type-cast
b792f9d9c00afebba856494db58a4151dcfd2b33
1a313b55c1dac2ea388c943fa4bf326eaa1957c3
refs/heads/master
2020-05-30T13:03:58.304192
2011-11-01T09:46:58
2011-11-01T09:46:58
32,418,189
0
0
null
null
null
null
UTF-8
C++
false
false
6,410
hpp
#pragma once #include "./../id2type_cast/id2type_cast.hpp" #include <iosfwd> #include <limits> namespace poly_serialization { namespace detail { /////////////////////////////////////////////////////////////////////////////// template<class DerivedT> struct serializer_base { template< class T > DerivedT &operator&( T &t ) { DerivedT *const pThis = static_cast<DerivedT *>(this); pThis->process(t); return *pThis; } template< class T > DerivedT &operator&( const T &t ) { DerivedT *const pThis = static_cast<DerivedT *>(this); pThis->process(t); return *pThis; } template< class T> DerivedT &operator&( T *&t ) { DerivedT *const pThis = static_cast<DerivedT *>(this); pointer_helper( t, i2tc::detail::int2type<i2tc::detail::is_embedded_type_id<T>::value>() ); return *pThis; } private: template<class T> void pointer_helper( T *&t, i2tc::detail::int2type<false> ) { static_cast<DerivedT *>(this)->process_pointer_regular(t); } template<class T> void pointer_helper( T *&t, i2tc::detail::int2type<true> ) { static_cast<DerivedT *>(this)->process_pointer_poly(t); } }; /////////////////////////////////////////////////////////////////////////////// template<class DerivedT> struct serializer_write_base: serializer_base<DerivedT> { template< class T> void process_pointer_regular( T *&pT ) { DerivedT &archive = static_cast<DerivedT &>(*this); if( pT != 0 ) { archive & 'G'; pT->Serialize( archive ); } else { archive & 'N'; } } template< class T> void process_pointer_poly( T *&pT ) { DerivedT &archive = static_cast<DerivedT &>(*this); if( pT != 0 ) { archive & pT->i2tc_get_id(); i2tc::id2type_cast( pT, serializer_write_functor(archive) ); } else { archive & -1; } } private: struct serializer_write_functor: i2tc::function<> { DerivedT &m_archive; serializer_write_functor( DerivedT &archive ): m_archive(archive) {} template<class T> void operator()( T *t ) const { t->Serialize( m_archive ); } private: serializer_write_base &operator=( const serializer_write_functor & ); }; }; /////////////////////////////////////////////////////////////////////////////// template<class DerivedT> struct serializer_read_base: serializer_base<DerivedT> { template< class T> void process_pointer_regular( T *&pT ) { DerivedT &archive = static_cast<DerivedT &>(*this); char nullTag; archive & nullTag; if( nullTag == 'G' ) { if( pT == 0 ) pT = new T; pT->Serialize(archive); } else { delete pT; pT = 0; } } template< class T> void process_pointer_poly( T *&pT ) { DerivedT &archive = static_cast<DerivedT &>(*this); int typeTag = 0; archive & typeTag; if( typeTag >= 0 ) { i2tc::id2type_cast<typename T::i2tc_type_list>( typeTag, serialization_functor_read<T>(archive, pT) ); } else { delete pT; pT = 0; } } private: template < class DstT > struct creation_functor: i2tc::function<DstT *> { template<class RealT> static DstT *createImpl( RealT *pCur, i2tc::detail::int2type<true> ) { return pCur; } template<class RealT> static DstT *createImpl( RealT *pCur, i2tc::detail::int2type<false> ) { delete pCur; return new DstT; } template<class RealT> DstT *operator()( RealT *pCur ) const { return createImpl( pCur, i2tc::detail::int2type<i2tc::detail::is_same_type<DstT, RealT>::value>() ); } }; template< class TCurr > struct serialization_functor_read: i2tc::function<> { DerivedT &m_archive; TCurr *&m_pCur; serialization_functor_read( DerivedT &archive, TCurr *&pCur ): m_archive(archive), m_pCur(pCur) {} template<class T> void operator()( const T * ) const { T * const pNew = m_pCur != 0 ? i2tc::id2type_cast< creation_functor<T> >( m_pCur ): new T; pNew->Serialize( m_archive ); m_pCur = pNew; } private: serialization_functor_read &operator=( const serialization_functor_read & ); }; protected: ~serializer_read_base() {} }; /////////////////////////////////////////////////////////////////////////////// }//namespace detail class reader: public detail::serializer_read_base<reader> { public: reader( std::istream &is ): m_is(is) {} template< class T> void process( T &t ) { m_is >> t; } private: std::istream &m_is; reader &operator=( const reader & ); }; class writer: public detail::serializer_write_base<writer> { public: writer( std::ostream &is ): is(is) {} template< class T> void process( T &t ) { is << t << ' '; } private: std::ostream &is; writer &operator=( const writer & ); }; } //namespace PolySerialization
[ [ [ 1, 235 ] ] ]
9f7523ebac6cfd3a82745a7465a8d40968e4370a
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/qbytearray.h
a3ed18e9f3f12b381e5f029796d79f95bbcb54fc
[ "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
23,727
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtCore 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 QBYTEARRAY_H #define QBYTEARRAY_H #include <QtCore/qglobal.h> #include <QtCore/qatomic.h> #include <string.h> #include <stdarg.h> #ifdef truncate #error qbytearray.h must be included before any header file that defines truncate #endif QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Core) /***************************************************************************** Safe and portable C string functions; extensions to standard string.h *****************************************************************************/ Q_CORE_EXPORT char *qstrdup(const char *); inline uint qstrlen(const char *str) { return str ? uint(strlen(str)) : 0; } inline uint qstrnlen(const char *str, uint maxlen) { uint length = 0; if (str) { while (length < maxlen && *str++) length++; } return length; } Q_CORE_EXPORT char *qstrcpy(char *dst, const char *src); Q_CORE_EXPORT char *qstrncpy(char *dst, const char *src, uint len); Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2); Q_CORE_EXPORT int qstrcmp(const QByteArray &str1, const QByteArray &str2); Q_CORE_EXPORT int qstrcmp(const QByteArray &str1, const char *str2); static inline int qstrcmp(const char *str1, const QByteArray &str2) { return -qstrcmp(str2, str1); } inline int qstrncmp(const char *str1, const char *str2, uint len) { return (str1 && str2) ? strncmp(str1, str2, len) : (str1 ? 1 : (str2 ? -1 : 0)); } Q_CORE_EXPORT int qstricmp(const char *, const char *); Q_CORE_EXPORT int qstrnicmp(const char *, const char *, uint len); // implemented in qvsnprintf.cpp Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap); Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...); #ifdef QT3_SUPPORT inline QT3_SUPPORT void *qmemmove(void *dst, const void *src, uint len) { return memmove(dst, src, len); } inline QT3_SUPPORT uint cstrlen(const char *str) { return uint(strlen(str)); } inline QT3_SUPPORT char *cstrcpy(char *dst, const char *src) { return qstrcpy(dst,src); } inline QT3_SUPPORT int cstrcmp(const char *str1, const char *str2) { return strcmp(str1,str2); } inline QT3_SUPPORT int cstrncmp(const char *str1, const char *str2, uint len) { return strncmp(str1,str2,len); } #endif // qChecksum: Internet checksum Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len); class QByteRef; class QString; class QDataStream; template <typename T> class QList; class Q_CORE_EXPORT QByteArray { public: inline QByteArray(); QByteArray(const char *); QByteArray(const char *, int size); QByteArray(int size, char c); inline QByteArray(const QByteArray &); inline ~QByteArray(); QByteArray &operator=(const QByteArray &); QByteArray &operator=(const char *str); inline int size() const; bool isEmpty() const; void resize(int size); QByteArray &fill(char c, int size = -1); int capacity() const; void reserve(int size); void squeeze(); #ifndef QT_NO_CAST_FROM_BYTEARRAY operator const char *() const; operator const void *() const; #endif char *data(); const char *data() const; inline const char *constData() const; inline void detach(); bool isDetached() const; void clear(); #ifdef Q_COMPILER_MANGLES_RETURN_TYPE const char at(int i) const; const char operator[](int i) const; const char operator[](uint i) const; #else char at(int i) const; char operator[](int i) const; char operator[](uint i) const; #endif QByteRef operator[](int i); QByteRef operator[](uint i); int indexOf(char c, int from = 0) const; int indexOf(const char *c, int from = 0) const; int indexOf(const QByteArray &a, int from = 0) const; int lastIndexOf(char c, int from = -1) const; int lastIndexOf(const char *c, int from = -1) const; int lastIndexOf(const QByteArray &a, int from = -1) const; QBool contains(char c) const; QBool contains(const char *a) const; QBool contains(const QByteArray &a) const; int count(char c) const; int count(const char *a) const; int count(const QByteArray &a) const; QByteArray left(int len) const; QByteArray right(int len) const; QByteArray mid(int index, int len = -1) const; bool startsWith(const QByteArray &a) const; bool startsWith(char c) const; bool startsWith(const char *c) const; bool endsWith(const QByteArray &a) const; bool endsWith(char c) const; bool endsWith(const char *c) const; void truncate(int pos); void chop(int n); QByteArray toLower() const; QByteArray toUpper() const; QByteArray trimmed() const; QByteArray simplified() const; QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const; QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const; #ifdef QT3_SUPPORT inline QT3_SUPPORT QByteArray leftJustify(uint width, char aFill = ' ', bool aTruncate = false) const { return leftJustified(int(width), aFill, aTruncate); } inline QT3_SUPPORT QByteArray rightJustify(uint width, char aFill = ' ', bool aTruncate = false) const { return rightJustified(int(width), aFill, aTruncate); } #endif QByteArray &prepend(char c); QByteArray &prepend(const char *s); QByteArray &prepend(const QByteArray &a); QByteArray &append(char c); QByteArray &append(const char *s); QByteArray &append(const char *s, int len); QByteArray &append(const QByteArray &a); QByteArray &insert(int i, char c); QByteArray &insert(int i, const char *s); QByteArray &insert(int i, const QByteArray &a); QByteArray &remove(int index, int len); QByteArray &replace(int index, int len, const char *s); QByteArray &replace(int index, int len, const QByteArray &s); QByteArray &replace(char before, const char *after); QByteArray &replace(char before, const QByteArray &after); QByteArray &replace(const char *before, const char *after); QByteArray &replace(const char *before, int bsize, const char *after, int asize); QByteArray &replace(const QByteArray &before, const QByteArray &after); QByteArray &replace(const QByteArray &before, const char *after); QByteArray &replace(const char *before, const QByteArray &after); QByteArray &replace(char before, char after); QByteArray &operator+=(char c); QByteArray &operator+=(const char *s); QByteArray &operator+=(const QByteArray &a); QList<QByteArray> split(char sep) const; QByteArray repeated(int times) const; #ifndef QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARN QByteArray &append(const QString &s); QT_ASCII_CAST_WARN QByteArray &insert(int i, const QString &s); QT_ASCII_CAST_WARN QByteArray &replace(const QString &before, const char *after); QT_ASCII_CAST_WARN QByteArray &replace(char c, const QString &after); QT_ASCII_CAST_WARN QByteArray &replace(const QString &before, const QByteArray &after); QT_ASCII_CAST_WARN QByteArray &operator+=(const QString &s); QT_ASCII_CAST_WARN int indexOf(const QString &s, int from = 0) const; QT_ASCII_CAST_WARN int lastIndexOf(const QString &s, int from = -1) const; #endif #ifndef QT_NO_CAST_FROM_ASCII inline QT_ASCII_CAST_WARN bool operator==(const QString &s2) const; inline QT_ASCII_CAST_WARN bool operator!=(const QString &s2) const; inline QT_ASCII_CAST_WARN bool operator<(const QString &s2) const; inline QT_ASCII_CAST_WARN bool operator>(const QString &s2) const; inline QT_ASCII_CAST_WARN bool operator<=(const QString &s2) const; inline QT_ASCII_CAST_WARN bool operator>=(const QString &s2) const; #endif short toShort(bool *ok = 0, int base = 10) const; ushort toUShort(bool *ok = 0, int base = 10) const; int toInt(bool *ok = 0, int base = 10) const; uint toUInt(bool *ok = 0, int base = 10) const; long toLong(bool *ok = 0, int base = 10) const; ulong toULong(bool *ok = 0, int base = 10) const; qlonglong toLongLong(bool *ok = 0, int base = 10) const; qulonglong toULongLong(bool *ok = 0, int base = 10) const; float toFloat(bool *ok = 0) const; double toDouble(bool *ok = 0) const; QByteArray toBase64() const; QByteArray toHex() const; QByteArray toPercentEncoding(const QByteArray &exclude = QByteArray(), const QByteArray &include = QByteArray(), char percent = '%') const; QByteArray &setNum(short, int base = 10); QByteArray &setNum(ushort, int base = 10); QByteArray &setNum(int, int base = 10); QByteArray &setNum(uint, int base = 10); QByteArray &setNum(qlonglong, int base = 10); QByteArray &setNum(qulonglong, int base = 10); QByteArray &setNum(float, char f = 'g', int prec = 6); QByteArray &setNum(double, char f = 'g', int prec = 6); static QByteArray number(int, int base = 10); static QByteArray number(uint, int base = 10); static QByteArray number(qlonglong, int base = 10); static QByteArray number(qulonglong, int base = 10); static QByteArray number(double, char f = 'g', int prec = 6); static QByteArray fromRawData(const char *, int size); static QByteArray fromBase64(const QByteArray &base64); static QByteArray fromHex(const QByteArray &hexEncoded); static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%'); typedef char *iterator; typedef const char *const_iterator; typedef iterator Iterator; typedef const_iterator ConstIterator; iterator begin(); const_iterator begin() const; const_iterator constBegin() const; iterator end(); const_iterator end() const; const_iterator constEnd() const; // stl compatibility typedef const char & const_reference; typedef char & reference; void push_back(char c); void push_back(const char *c); void push_back(const QByteArray &a); void push_front(char c); void push_front(const char *c); void push_front(const QByteArray &a); inline int count() const { return d->size; } int length() const { return d->size; } bool isNull() const; // compatibility #ifdef QT3_SUPPORT QT3_SUPPORT_CONSTRUCTOR QByteArray(int size); inline QT3_SUPPORT QByteArray& duplicate(const QByteArray& a) { *this = a; return *this; } inline QT3_SUPPORT QByteArray& duplicate(const char *a, uint n) { *this = QByteArray(a, n); return *this; } inline QT3_SUPPORT QByteArray& setRawData(const char *a, uint n) { *this = fromRawData(a, n); return *this; } inline QT3_SUPPORT void resetRawData(const char *, uint) { clear(); } inline QT3_SUPPORT QByteArray lower() const { return toLower(); } inline QT3_SUPPORT QByteArray upper() const { return toUpper(); } inline QT3_SUPPORT QByteArray stripWhiteSpace() const { return trimmed(); } inline QT3_SUPPORT QByteArray simplifyWhiteSpace() const { return simplified(); } inline QT3_SUPPORT int find(char c, int from = 0) const { return indexOf(c, from); } inline QT3_SUPPORT int find(const char *c, int from = 0) const { return indexOf(c, from); } inline QT3_SUPPORT int find(const QByteArray &ba, int from = 0) const { return indexOf(ba, from); } inline QT3_SUPPORT int findRev(char c, int from = -1) const { return lastIndexOf(c, from); } inline QT3_SUPPORT int findRev(const char *c, int from = -1) const { return lastIndexOf(c, from); } inline QT3_SUPPORT int findRev(const QByteArray &ba, int from = -1) const { return lastIndexOf(ba, from); } #ifndef QT_NO_CAST_TO_ASCII QT3_SUPPORT int find(const QString &s, int from = 0) const; QT3_SUPPORT int findRev(const QString &s, int from = -1) const; #endif #endif private: operator QNoImplicitBoolCast() const; struct Data { QBasicAtomicInt ref; int alloc, size; // ### Qt 5.0: We need to add the missing capacity bit // (like other tool classes have), to maintain the // reserved memory on resize. char *data; char array[1]; }; static Data shared_null; static Data shared_empty; Data *d; QByteArray(Data *dd, int /*dummy*/, int /*dummy*/) : d(dd) {} void realloc(int alloc); void expand(int i); QByteArray nulTerminated() const; friend class QByteRef; friend class QString; public: typedef Data * DataPtr; inline DataPtr &data_ptr() { return d; } }; inline QByteArray::QByteArray(): d(&shared_null) { d->ref.ref(); } inline QByteArray::~QByteArray() { if (!d->ref.deref()) qFree(d); } inline int QByteArray::size() const { return d->size; } #ifdef Q_COMPILER_MANGLES_RETURN_TYPE inline const char QByteArray::at(int i) const { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } inline const char QByteArray::operator[](int i) const { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } inline const char QByteArray::operator[](uint i) const { Q_ASSERT(i < uint(size())); return d->data[i]; } #else inline char QByteArray::at(int i) const { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } inline char QByteArray::operator[](int i) const { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } inline char QByteArray::operator[](uint i) const { Q_ASSERT(i < uint(size())); return d->data[i]; } #endif inline bool QByteArray::isEmpty() const { return d->size == 0; } #ifndef QT_NO_CAST_FROM_BYTEARRAY inline QByteArray::operator const char *() const { return d->data; } inline QByteArray::operator const void *() const { return d->data; } #endif inline char *QByteArray::data() { detach(); return d->data; } inline const char *QByteArray::data() const { return d->data; } inline const char *QByteArray::constData() const { return d->data; } inline void QByteArray::detach() { if (d->ref != 1 || d->data != d->array) realloc(d->size); } inline bool QByteArray::isDetached() const { return d->ref == 1; } inline QByteArray::QByteArray(const QByteArray &a) : d(a.d) { d->ref.ref(); } #ifdef QT3_SUPPORT inline QByteArray::QByteArray(int aSize) : d(&shared_null) { d->ref.ref(); if (aSize > 0) fill('\0', aSize); } #endif inline int QByteArray::capacity() const { return d->alloc; } inline void QByteArray::reserve(int asize) { if (d->ref != 1 || asize > d->alloc) realloc(asize); } inline void QByteArray::squeeze() { if (d->size < d->alloc) realloc(d->size); } class Q_CORE_EXPORT QByteRef { QByteArray &a; int i; inline QByteRef(QByteArray &array, int idx) : a(array),i(idx) {} friend class QByteArray; public: #ifdef Q_COMPILER_MANGLES_RETURN_TYPE inline operator const char() const { return i < a.d->size ? a.d->data[i] : 0; } #else inline operator char() const { return i < a.d->size ? a.d->data[i] : 0; } #endif inline QByteRef &operator=(char c) { if (i >= a.d->size) a.expand(i); else a.detach(); a.d->data[i] = c; return *this; } inline QByteRef &operator=(const QByteRef &c) { if (i >= a.d->size) a.expand(i); else a.detach(); a.d->data[i] = c.a.d->data[c.i]; return *this; } inline bool operator==(char c) const { return a.d->data[i] == c; } inline bool operator!=(char c) const { return a.d->data[i] != c; } inline bool operator>(char c) const { return a.d->data[i] > c; } inline bool operator>=(char c) const { return a.d->data[i] >= c; } inline bool operator<(char c) const { return a.d->data[i] < c; } inline bool operator<=(char c) const { return a.d->data[i] <= c; } }; inline QByteRef QByteArray::operator[](int i) { Q_ASSERT(i >= 0); return QByteRef(*this, i); } inline QByteRef QByteArray::operator[](uint i) { return QByteRef(*this, i); } inline QByteArray::iterator QByteArray::begin() { detach(); return d->data; } inline QByteArray::const_iterator QByteArray::begin() const { return d->data; } inline QByteArray::const_iterator QByteArray::constBegin() const { return d->data; } inline QByteArray::iterator QByteArray::end() { detach(); return d->data + d->size; } inline QByteArray::const_iterator QByteArray::end() const { return d->data + d->size; } inline QByteArray::const_iterator QByteArray::constEnd() const { return d->data + d->size; } inline QByteArray &QByteArray::operator+=(char c) { return append(c); } inline QByteArray &QByteArray::operator+=(const char *s) { return append(s); } inline QByteArray &QByteArray::operator+=(const QByteArray &a) { return append(a); } inline void QByteArray::push_back(char c) { append(c); } inline void QByteArray::push_back(const char *c) { append(c); } inline void QByteArray::push_back(const QByteArray &a) { append(a); } inline void QByteArray::push_front(char c) { prepend(c); } inline void QByteArray::push_front(const char *c) { prepend(c); } inline void QByteArray::push_front(const QByteArray &a) { prepend(a); } inline QBool QByteArray::contains(const QByteArray &a) const { return QBool(indexOf(a) != -1); } inline QBool QByteArray::contains(char c) const { return QBool(indexOf(c) != -1); } inline bool operator==(const QByteArray &a1, const QByteArray &a2) { return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); } inline bool operator==(const QByteArray &a1, const char *a2) { return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); } inline bool operator==(const char *a1, const QByteArray &a2) { return a1 ? qstrcmp(a1,a2) == 0 : a2.isEmpty(); } inline bool operator!=(const QByteArray &a1, const QByteArray &a2) { return !(a1==a2); } inline bool operator!=(const QByteArray &a1, const char *a2) { return a2 ? qstrcmp(a1,a2) != 0 : !a1.isEmpty(); } inline bool operator!=(const char *a1, const QByteArray &a2) { return a1 ? qstrcmp(a1,a2) != 0 : !a2.isEmpty(); } inline bool operator<(const QByteArray &a1, const QByteArray &a2) { return qstrcmp(a1, a2) < 0; } inline bool operator<(const QByteArray &a1, const char *a2) { return qstrcmp(a1, a2) < 0; } inline bool operator<(const char *a1, const QByteArray &a2) { return qstrcmp(a1, a2) < 0; } inline bool operator<=(const QByteArray &a1, const QByteArray &a2) { return qstrcmp(a1, a2) <= 0; } inline bool operator<=(const QByteArray &a1, const char *a2) { return qstrcmp(a1, a2) <= 0; } inline bool operator<=(const char *a1, const QByteArray &a2) { return qstrcmp(a1, a2) <= 0; } inline bool operator>(const QByteArray &a1, const QByteArray &a2) { return qstrcmp(a1, a2) > 0; } inline bool operator>(const QByteArray &a1, const char *a2) { return qstrcmp(a1, a2) > 0; } inline bool operator>(const char *a1, const QByteArray &a2) { return qstrcmp(a1, a2) > 0; } inline bool operator>=(const QByteArray &a1, const QByteArray &a2) { return qstrcmp(a1, a2) >= 0; } inline bool operator>=(const QByteArray &a1, const char *a2) { return qstrcmp(a1, a2) >= 0; } inline bool operator>=(const char *a1, const QByteArray &a2) { return qstrcmp(a1, a2) >= 0; } inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2) { return QByteArray(a1) += a2; } inline const QByteArray operator+(const QByteArray &a1, const char *a2) { return QByteArray(a1) += a2; } inline const QByteArray operator+(const QByteArray &a1, char a2) { return QByteArray(a1) += a2; } inline const QByteArray operator+(const char *a1, const QByteArray &a2) { return QByteArray(a1) += a2; } inline const QByteArray operator+(char a1, const QByteArray &a2) { return QByteArray(&a1, 1) += a2; } inline QBool QByteArray::contains(const char *c) const { return QBool(indexOf(c) != -1); } inline QByteArray &QByteArray::replace(char before, const char *c) { return replace(&before, 1, c, qstrlen(c)); } inline QByteArray &QByteArray::replace(const QByteArray &before, const char *c) { return replace(before.constData(), before.size(), c, qstrlen(c)); } inline QByteArray &QByteArray::replace(const char *before, const char *after) { return replace(before, qstrlen(before), after, qstrlen(after)); } inline QByteArray &QByteArray::setNum(short n, int base) { return setNum(qlonglong(n), base); } inline QByteArray &QByteArray::setNum(ushort n, int base) { return setNum(qulonglong(n), base); } inline QByteArray &QByteArray::setNum(int n, int base) { return setNum(qlonglong(n), base); } inline QByteArray &QByteArray::setNum(uint n, int base) { return setNum(qulonglong(n), base); } inline QByteArray &QByteArray::setNum(float n, char f, int prec) { return setNum(double(n),f,prec); } #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &); Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QByteArray &); #endif #ifndef QT_NO_COMPRESS Q_CORE_EXPORT QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel = -1); Q_CORE_EXPORT QByteArray qUncompress(const uchar* data, int nbytes); inline QByteArray qCompress(const QByteArray& data, int compressionLevel = -1) { return qCompress(reinterpret_cast<const uchar *>(data.constData()), data.size(), compressionLevel); } inline QByteArray qUncompress(const QByteArray& data) { return qUncompress(reinterpret_cast<const uchar*>(data.constData()), data.size()); } #endif Q_DECLARE_TYPEINFO(QByteArray, Q_MOVABLE_TYPE); Q_DECLARE_SHARED(QByteArray) QT_END_NAMESPACE QT_END_HEADER #endif // QBYTEARRAY_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 589 ] ] ]
a4d32b9fc0b47bfa33b2fa3b0f06796ec581d8d4
2c1e5a69ca68fe185cc04c5904aa104b0ba42e32
/src/game/List.h
9c71738388de5df884e2722ddb1dfda6d0519ba4
[]
no_license
dogtwelve/newsiderpg
e3f8284a7cd9938156ef8d683dca7bcbd928c593
303566a034dca3e66cf0f29cf9eaea1d54d63e4a
refs/heads/master
2021-01-10T13:03:31.986204
2010-06-27T05:36:33
2010-06-27T05:36:33
46,550,247
0
1
null
null
null
null
UTF-8
C++
false
false
11,499
h
#ifndef __LIST_ #define __LIST_ #define SAFE_DELETE(a) {if(a){delete (a);a=NULL;}} enum SeekMode { L_PRE = 0x01, L_NEXT = 0x02, L_START = 0x04, L_LAST = 0x08 }; enum InsertMode { L_IPRE = 0x01, L_INEXT = 0x02, }; //agent list template<class T> class Stack { public: T* data; int size; int count; //-------------------------------------------------------------------------------------- Stack(int _stacksize) //-------------------------------------------------------------------------------------- { count = -1; size = _stacksize; if(0 < size) { data = (T*)MALLOC(sizeof(T)*size); } } //-------------------------------------------------------------------------------------- ~Stack() //-------------------------------------------------------------------------------------- { SAFE_DELETE(data); // while(NULL != Pop()){} } //-------------------------------------------------------------------------------------- void Push(T _data) //-------------------------------------------------------------------------------------- { if(count+1 >= size) { return; } data[++count] = _data; } //-------------------------------------------------------------------------------------- T Pop() //-------------------------------------------------------------------------------------- { if(0 > count) {return NULL;} return (data[count--]); } //-------------------------------------------------------------------------------------- int GetStackCount() //-------------------------------------------------------------------------------------- { return (count+1); } }; #define GetNodeCount(a) ((a)->count) #define GetNow(a) ((a)->now) #define SetNow(a,b) ((a)->now = (b)) #define GetData(a) ((a)->now->data) #define MoveHead(a) ((a)->now = (a)->head) #define MoveTail(a) ((a)->now = (a)->tail) #define MovePre(a) ((a)->now = (a)->now->prev) #define MoveNext(a) ((a)->now = (a)->now->next) #define InitList(a) ((a)->now = (a)->head->next) //#define GetNowNode(a) ((a)->now) //#define GetTailNode(a) ((a)->tail) //#define GetHeadNode(a) ((a)->head) #define NotEndList(a) ((a)->now != (a)->tail) //agent list template<class T> class List2 { public: typedef struct Node { struct Node* prev; struct Node* next; T data; }; Node* head; Node* tail; Node* now; Node* saveNode; int count; //-------------------------------------------------------------------------------------- List2() //-------------------------------------------------------------------------------------- { head = GL_NEW Node; tail = GL_NEW Node; now = head; head->prev = head; head->next = tail; tail->prev = head; tail->next = tail; // count = 2; } //-------------------------------------------------------------------------------------- ~List2() //-------------------------------------------------------------------------------------- { SAFE_DELETE(head); SAFE_DELETE(tail); } //-------------------------------------------------------------------------------------- void Insert_prev(T nodeData) //-------------------------------------------------------------------------------------- { if(now == head) { return; } Node* tmpNode = GL_NEW Node; tmpNode->data = nodeData; now->prev->next = tmpNode; tmpNode->prev = now->prev; now->prev = tmpNode; tmpNode->next = now; now = tmpNode; count++; } //-------------------------------------------------------------------------------------- void Insert_next(T nodeData) //-------------------------------------------------------------------------------------- { if(now == tail) { return; } Node* tmpNode = GL_NEW Node; tmpNode->data = nodeData; now->next->prev = tmpNode; tmpNode->next = now->next; now->next = tmpNode; tmpNode->prev = now; now = tmpNode; count++; } //-------------------------------------------------------------------------------------- void Delete() //-------------------------------------------------------------------------------------- { if(now == head || now == tail) { return; } Node* tmpNode = now->next; now->prev->next = now->next; now->next->prev = now->prev; SAFE_DELETE(now); now = tmpNode; count--; } //-------------------------------------------------------------------------------------- void SaveCurrentState() //-------------------------------------------------------------------------------------- { saveNode = now; } //-------------------------------------------------------------------------------------- void RestoreCurrentState() //-------------------------------------------------------------------------------------- { now = saveNode; saveNode = NULL; } }; //agent list template<class T> class List { public: typedef struct Node { struct Node* prenode; struct Node* nextnode; T* dest; }; Node* firstnode; Node* lastnode; Node* currentnode; int nodecount; int delmode; Stack<Node*> *pStackPool; //-------------------------------------------------------------------------------------- List() //-------------------------------------------------------------------------------------- { pStackPool = NULL; nodecount = 0; firstnode = NULL; lastnode = NULL; currentnode = NULL; delmode = 0; } //-------------------------------------------------------------------------------------- List(int stackpoolsize) //-------------------------------------------------------------------------------------- { nodecount = 0; firstnode = NULL; lastnode = NULL; currentnode = NULL; delmode = 0; pStackPool = GL_NEW Stack<Node*>(stackpoolsize); for(int loop = 0; loop < stackpoolsize; loop++) { pStackPool->Push( (Node*)MALLOC(sizeof(Node))); } } //-------------------------------------------------------------------------------------- ~List() //-------------------------------------------------------------------------------------- { Node* tmpNode = NULL; if(pStackPool) { while(0 < pStackPool->GetStackCount()) { tmpNode = pStackPool->Pop(); SAFE_DELETE(tmpNode); } } SAFE_DELETE(pStackPool); DeleteAll(); } //-------------------------------------------------------------------------------------- void Insert(T* nodeData) //-------------------------------------------------------------------------------------- { Insert(nodeData, L_INEXT); } //-------------------------------------------------------------------------------------- void Insert(T* nodeData, int insertopt) //-------------------------------------------------------------------------------------- { Node* tmpNode = NULL; if(pStackPool) { tmpNode = pStackPool->Pop(); } else { tmpNode = GL_NEW Node; } tmpNode->prenode = NULL; tmpNode->nextnode = NULL; tmpNode->dest = nodeData; if(0 == nodecount) { firstnode = tmpNode; lastnode = tmpNode; } else { if(L_IPRE == insertopt) { tmpNode->prenode = currentnode->prenode; if(tmpNode->prenode) {tmpNode->prenode->nextnode = tmpNode;} tmpNode->nextnode = currentnode; currentnode->prenode = tmpNode; if(firstnode == currentnode) {firstnode = tmpNode;} } else //if(L_INEXT == insertopt) { tmpNode->nextnode = currentnode->nextnode; if(tmpNode->nextnode) {tmpNode->nextnode->prenode = tmpNode;} tmpNode->prenode = currentnode; currentnode->nextnode = tmpNode; if(lastnode == currentnode) {lastnode = tmpNode;} } } currentnode = tmpNode; nodecount++; } //-------------------------------------------------------------------------------------- void Delete() //-------------------------------------------------------------------------------------- { if(NULL == currentnode) {return;} if(0 == delmode) { SAFE_DELETE(currentnode->dest); } nodecount--; if(0 == nodecount) { //SAFE_DELETE(currentnode); if(pStackPool) { currentnode->nextnode = NULL; currentnode->prenode = NULL; pStackPool->Push(currentnode); currentnode = NULL; } else {SAFE_DELETE(currentnode);} firstnode = NULL; lastnode = NULL; } else if(firstnode == currentnode) { firstnode = currentnode->nextnode; firstnode->prenode = NULL; //SAFE_DELETE(currentnode); if(pStackPool) { currentnode->nextnode = NULL; currentnode->prenode = NULL; pStackPool->Push(currentnode); currentnode = NULL; } else {SAFE_DELETE(currentnode);} currentnode = firstnode; } else if(lastnode == currentnode) { lastnode = currentnode->prenode; lastnode->nextnode = NULL; //SAFE_DELETE(currentnode); if(pStackPool) { currentnode->nextnode = NULL; currentnode->prenode = NULL; pStackPool->Push(currentnode); currentnode = NULL; } else {SAFE_DELETE(currentnode);} currentnode = lastnode; } else { Node* tmpnode = currentnode->nextnode; currentnode->prenode->nextnode = currentnode->nextnode; currentnode->nextnode->prenode = currentnode->prenode; //SAFE_DELETE(currentnode); if(pStackPool) { currentnode->nextnode = NULL; currentnode->prenode = NULL; pStackPool->Push(currentnode); currentnode = NULL; } else {SAFE_DELETE(currentnode);} currentnode = tmpnode; } } //-------------------------------------------------------------------------------------- T* CurNode() //-------------------------------------------------------------------------------------- { if(currentnode) {return (currentnode->dest);} return NULL; } //-------------------------------------------------------------------------------------- bool Move(SeekMode _type) //-------------------------------------------------------------------------------------- { switch(_type) { case L_PRE: {if(currentnode->prenode) {currentnode = currentnode->prenode; return true;} break;} case L_NEXT: {if(currentnode->nextnode) {currentnode = currentnode->nextnode; return true;} break;} case L_START: {currentnode = firstnode; return true; break;} case L_LAST: {currentnode = lastnode; return true; break;} default: {break;} } return false; } //-------------------------------------------------------------------------------------- int GetCount() //-------------------------------------------------------------------------------------- { return nodecount; } //-------------------------------------------------------------------------------------- bool IsLast() //-------------------------------------------------------------------------------------- { if(currentnode == lastnode) {return true;} return false; } //-------------------------------------------------------------------------------------- void DeleteAll() //-------------------------------------------------------------------------------------- { while(0 < nodecount) {Delete();} } }; #endif // __LIST_
[ [ [ 1, 481 ] ] ]
27a906ba2ade1e2a32c07d12340e0f4b1341c484
9a48be80edc7692df4918c0222a1640545384dbb
/Libraries/Boost1.40/libs/python/test/pickle2.cpp
f5360bbd54e2a4a79bc23591b39f9cb0f7ba20b4
[ "BSL-1.0" ]
permissive
fcrick/RepSnapper
05e4fb1157f634acad575fffa2029f7f655b7940
a5809843f37b7162f19765e852b968648b33b694
refs/heads/master
2021-01-17T21:42:29.537504
2010-06-07T05:38:05
2010-06-07T05:38:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,080
cpp
// Copyright Ralf W. Grosse-Kunstleve 2002-2004. 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) /* This example shows how to make an Extension Class "pickleable". The world class below contains member data (secret_number) that cannot be restored by any of the constructors. Therefore it is necessary to provide the __getstate__/__setstate__ pair of pickle interface methods. For simplicity, the __dict__ is not included in the result of __getstate__. This is not generally recommended, but a valid approach if it is anticipated that the object's __dict__ will always be empty. Note that safety guards are provided to catch the cases where this assumption is not true. pickle3.cpp shows how to include the object's __dict__ in the result of __getstate__. For more information refer to boost/libs/python/doc/pickle.html. */ #include <boost/python/module.hpp> #include <boost/python/def.hpp> #include <boost/python/class.hpp> #include <boost/python/tuple.hpp> #include <boost/python/extract.hpp> namespace boost_python_test { // A friendly class. class world { public: world(const std::string& _country) : secret_number(0) { this->country = _country; } std::string greet() const { return "Hello from " + country + "!"; } std::string get_country() const { return country; } void set_secret_number(int number) { secret_number = number; } int get_secret_number() const { return secret_number; } private: std::string country; int secret_number; }; struct world_pickle_suite : boost::python::pickle_suite { static boost::python::tuple getinitargs(const world& w) { using namespace boost::python; return make_tuple(w.get_country()); } static boost::python::tuple getstate(const world& w) { using namespace boost::python; return make_tuple(w.get_secret_number()); } static void setstate(world& w, boost::python::tuple state) { using namespace boost::python; if (len(state) != 1) { PyErr_SetObject(PyExc_ValueError, ("expected 1-item tuple in call to __setstate__; got %s" % state).ptr() ); throw_error_already_set(); } long number = extract<long>(state[0]); if (number != 42) w.set_secret_number(number); } }; } BOOST_PYTHON_MODULE(pickle2_ext) { using namespace boost_python_test; boost::python::class_<world>( "world", boost::python::init<const std::string&>()) .def("greet", &world::greet) .def("get_secret_number", &world::get_secret_number) .def("set_secret_number", &world::set_secret_number) .def_pickle(world_pickle_suite()) ; }
[ "metrix@Blended.(none)" ]
[ [ [ 1, 99 ] ] ]
70e5890c13b73dfd9d911742df6efbb3393474ad
31a5e7570148149f0f7d8626274c22e15454a71f
/Simcraft/Simcraft/sc_weapon.cpp
9da7c3cb5f25473870c5666121e740edcba1176a
[]
no_license
imclab/SimcraftGearOptimizer
b54575e9fc330c97070168ade5bbd46a2de0627a
b5c1f82b2bf7579389d23b769e520a6b0968fc98
refs/heads/master
2021-01-22T13:37:15.010740
2010-05-04T00:46:44
2010-05-04T00:46:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,913
cpp
// ========================================================================== // Dedmonwakeen's Raid DPS/TPS Simulator. // Send questions to [email protected] // ========================================================================== #include "simulationcraft.h" // ========================================================================== // Weapon // ========================================================================== // weapon_t::group ========================================================== int weapon_t::group() SC_CONST { switch ( type ) { case WEAPON_DAGGER: case WEAPON_SMALL: return WEAPON_SMALL; case WEAPON_SWORD: case WEAPON_MACE: case WEAPON_AXE: case WEAPON_FIST: case WEAPON_1H: return WEAPON_1H; case WEAPON_SWORD_2H: case WEAPON_MACE_2H: case WEAPON_AXE_2H: case WEAPON_STAFF: case WEAPON_POLEARM: case WEAPON_2H: return WEAPON_2H; case WEAPON_BOW: case WEAPON_CROSSBOW: case WEAPON_GUN: case WEAPON_WAND: case WEAPON_THROWN: case WEAPON_RANGED: return WEAPON_RANGED; } return WEAPON_NONE; } // weapon_t::normalized_weapon_speed ======================================== double weapon_t::normalized_weapon_speed() SC_CONST { int g = group(); if ( g == WEAPON_SMALL ) return 1.7; if ( g == WEAPON_1H ) return 2.4; if ( g == WEAPON_2H ) return 3.3; if ( g == WEAPON_RANGED ) return 2.8; assert( 0 ); return 0; } // weapon_t::proc_chance_on_swing =========================================== double weapon_t::proc_chance_on_swing( double PPM, double adjusted_swing_time ) SC_CONST { if ( adjusted_swing_time == 0 ) adjusted_swing_time = swing_time; double time_to_proc = 60.0 / PPM; double proc_chance = adjusted_swing_time / time_to_proc; return proc_chance; }
[ [ [ 1, 74 ] ] ]
5c3c0ef3a5be70ea70f379efbd43d7f4c974da4e
4f04b6f376acb98e41ac16659f9e9eee99163bc8
/sequential-v3/main.cpp
41c3163f42695ee7a4a62b92488f63ca628a1222
[]
no_license
jskvara/PAR-KGM
d4689971b88565067f1cb3369b5f7d4425646107
407874a0b0a417cff28448ddcfc622a67b96cdd0
refs/heads/master
2020-04-09T10:28:17.442416
2011-12-15T22:55:34
2011-12-15T22:55:34
2,991,233
0
0
null
null
null
null
UTF-8
C++
false
false
2,997
cpp
 #include "Graph.h" #include "Stack.h" #include <cstring> #include <fstream> #include <cstdlib> using namespace std; static Graph* solve(Graph* graph) { //pokud neni nic nacteno, vraceno NULL if(graph == NULL) return NULL; int vertexCount = graph->getVertexCount(); //pokud ma nacteny graf mene nez jeden vrchol, vraceno NULL if(vertexCount < 2) return NULL; //pokud neni vstupni graf spojity, vraceno NULL if(!graph->isContinuous()) return NULL; //pocet hran kostry int edgeLimit = vertexCount - 1; //nejlepsi reseni Graph* best = NULL; Stack s; s.push(graph); while (!s.is_empty()) { Graph* subgraph = s.pop(); //pro nalezeni lepsiho reseni musi platit, ze je kostrou vstupniho grafu a ma mensi stupen nez dosud nejlepsi reseni if (subgraph->getEdgeCount() == edgeLimit && subgraph->isSpanningTree() && ((best != NULL && best->getDegree() > subgraph->getDegree()) || best == NULL)) { //nahrazeni nejlepsiho reseni delete best; best = new Graph(*subgraph); } else { //rozvijet stavovy prostor budeme dokud podgrafy maji vetsi nebo stejny pocet hran //ktery je potreba k vytvoreni kostry a dale pokud jsou spojite if(subgraph->getEdgeCount() > edgeLimit && subgraph->isContinuous()){ for (int i = 0; i < (vertexCount - 1); i++) { for (int j = i + 1; j < vertexCount; j++) { if (subgraph->getEdge(i, j) && subgraph->getEdge(j, i)) { Graph* temp = new Graph(*subgraph); temp->setEdge(i, j, false); temp->setEdge(j, i, false); s.push(temp); } else { continue; } } } } } delete subgraph; } return best; } //main int main(int argc, char* argv[]) { if (argc != 2) { ofstream err ("output.txt"); if(err.is_open()) { err << "Path to graph file required in argument" << endl; err.close(); } //cout << "Path to graph file required in argument" << endl; exit(1); } //nacteni grafu Graph* solution = solve(Graph::loadGraph(argv[1])); ofstream output ("output.txt", ofstream::app); //vypsani vysledku if (solution != NULL) { if(output.is_open()) { output << "Min degree spanning tree's matrix: " << endl << endl; output << "Degree: " << solution->getDegree() << endl; output.close(); } solution->print(); } else { if(output.is_open()) { output << "No solution found" << endl; output.close(); } } delete solution; return 0; }
[ [ [ 1, 123 ] ] ]
941e01a5b1e40624200042d0758f7847e4d96b8d
29b6d4476806896a1734924edb734f2dd98346f3
/src/LuaBindings.inc
f8ec288ce3de8dc8c2aecc94a6e01efb585340b4
[]
no_license
ermachkov/Balance_GUI
0861bfe99608bbdc99bf4d17a531c5c15d99b203
398cc168f5eacd712539547d8fd6eb2a378c9924
refs/heads/master
2021-01-02T09:15:06.523769
2011-11-30T06:55:57
2011-11-30T06:55:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
121,849
inc
/* ** Lua binding: LuaBindings ** Generated automatically by tolua++-1.0.92 on 11/29/11 15:16:58. */ #ifndef __cplusplus #include "stdlib.h" #endif #include "string.h" #include "tolua++.h" /* Exported function */ TOLUA_API int tolua_LuaBindings_open (lua_State* tolua_S); #include "Application.h" #include "Balance.h" #include "Database.h" #include "Font.h" #include "Graphics.h" #include "Keyboard.h" #include "Mouse.h" #include "Profile.h" #include "ResourceManager.h" #include "ResourceQueue.h" #include "Sound.h" #include "Sprite.h" /* function to release collected object via destructor */ #ifdef __cplusplus static int tolua_collect_Profile (lua_State* tolua_S) { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_Sprite (lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_CFont (lua_State* tolua_S) { CFont* self = (CFont*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_Sound (lua_State* tolua_S) { Sound* self = (Sound*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } #endif /* function to register type */ static void tolua_reg_types (lua_State* tolua_S) { tolua_usertype(tolua_S,"Database"); tolua_usertype(tolua_S,"CFont"); tolua_usertype(tolua_S,"Keyboard"); tolua_usertype(tolua_S,"ResourceQueue"); tolua_usertype(tolua_S,"Application"); tolua_usertype(tolua_S,"Balance"); tolua_usertype(tolua_S,"Sprite"); tolua_usertype(tolua_S,"Graphics"); tolua_usertype(tolua_S,"ResourceManager"); tolua_usertype(tolua_S,"Mouse"); tolua_usertype(tolua_S,"Sound"); tolua_usertype(tolua_S,"Profile"); } /* method: getDataDirectory of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_getDataDirectory00 static int tolua_LuaBindings_Application_getDataDirectory00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Application",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Application* self = (const Application*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDataDirectory'", NULL); #endif { std::string tolua_ret = (std::string) self->getDataDirectory(); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getDataDirectory'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getCompanyName of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_getCompanyName00 static int tolua_LuaBindings_Application_getCompanyName00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Application",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Application* self = (const Application*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCompanyName'", NULL); #endif { std::string tolua_ret = (std::string) self->getCompanyName(); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getCompanyName'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setCompanyName of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_setCompanyName00 static int tolua_LuaBindings_Application_setCompanyName00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Application",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Application* self = (Application*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCompanyName'", NULL); #endif { self->setCompanyName(name); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setCompanyName'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getApplicationName of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_getApplicationName00 static int tolua_LuaBindings_Application_getApplicationName00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Application",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Application* self = (const Application*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getApplicationName'", NULL); #endif { std::string tolua_ret = (std::string) self->getApplicationName(); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getApplicationName'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setApplicationName of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_setApplicationName00 static int tolua_LuaBindings_Application_setApplicationName00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Application",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Application* self = (Application*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setApplicationName'", NULL); #endif { self->setApplicationName(name); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setApplicationName'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getApplicationVersion of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_getApplicationVersion00 static int tolua_LuaBindings_Application_getApplicationVersion00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Application",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Application* self = (const Application*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getApplicationVersion'", NULL); #endif { std::string tolua_ret = (std::string) self->getApplicationVersion(); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getApplicationVersion'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setApplicationVersion of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_setApplicationVersion00 static int tolua_LuaBindings_Application_setApplicationVersion00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Application",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Application* self = (Application*) tolua_tousertype(tolua_S,1,0); const std::string version = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setApplicationVersion'", NULL); #endif { self->setApplicationVersion(version); tolua_pushcppstring(tolua_S,(const char*)version); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setApplicationVersion'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: quit of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_quit00 static int tolua_LuaBindings_Application_quit00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Application",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Application* self = (Application*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'quit'", NULL); #endif { self->quit(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'quit'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class Application */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Application_getSingleton00 static int tolua_LuaBindings_Application_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Application",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Application& tolua_ret = (Application&) Application::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"Application"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isConnected of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_isConnected00 static int tolua_LuaBindings_Balance_isConnected00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Balance",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Balance* self = (const Balance*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isConnected'", NULL); #endif { bool tolua_ret = (bool) self->isConnected(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isConnected'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isProtocolValid of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_isProtocolValid00 static int tolua_LuaBindings_Balance_isProtocolValid00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Balance",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Balance* self = (const Balance*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isProtocolValid'", NULL); #endif { bool tolua_ret = (bool) self->isProtocolValid(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isProtocolValid'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setServerAddr of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_setServerAddr00 static int tolua_LuaBindings_Balance_setServerAddr00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Balance* self = (Balance*) tolua_tousertype(tolua_S,1,0); const std::string addr = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setServerAddr'", NULL); #endif { self->setServerAddr(addr); tolua_pushcppstring(tolua_S,(const char*)addr); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setServerAddr'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setOscMode of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_setOscMode00 static int tolua_LuaBindings_Balance_setOscMode00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Balance",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Balance* self = (Balance*) tolua_tousertype(tolua_S,1,0); int mode = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOscMode'", NULL); #endif { self->setOscMode(mode); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setOscMode'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_getParam00 static int tolua_LuaBindings_Balance_getParam00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const Balance* self = (const Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParam'", NULL); #endif { std::string tolua_ret = (std::string) self->getParam(name); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getParam'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getIntParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_getIntParam00 static int tolua_LuaBindings_Balance_getIntParam00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const Balance* self = (const Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIntParam'", NULL); #endif { int tolua_ret = (int) self->getIntParam(name); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getIntParam'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getFloatParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_getFloatParam00 static int tolua_LuaBindings_Balance_getFloatParam00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const Balance* self = (const Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFloatParam'", NULL); #endif { float tolua_ret = (float) self->getFloatParam(name); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getFloatParam'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_setParam00 static int tolua_LuaBindings_Balance_setParam00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Balance* self = (Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setParam'", NULL); #endif { self->setParam(name); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setParam'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_setParam01 static int tolua_LuaBindings_Balance_setParam01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_iscppstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { Balance* self = (Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string value = ((const std::string) tolua_tocppstring(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setParam'", NULL); #endif { self->setParam(name,value); tolua_pushcppstring(tolua_S,(const char*)name); tolua_pushcppstring(tolua_S,(const char*)value); } } return 2; tolua_lerror: return tolua_LuaBindings_Balance_setParam00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: setIntParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_setIntParam00 static int tolua_LuaBindings_Balance_setIntParam00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Balance* self = (Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); int value = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setIntParam'", NULL); #endif { self->setIntParam(name,value); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setIntParam'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setFloatParam of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_setFloatParam00 static int tolua_LuaBindings_Balance_setFloatParam00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Balance",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Balance* self = (Balance*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); float value = ((float) tolua_tonumber(tolua_S,3,0.0f)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFloatParam'", NULL); #endif { self->setFloatParam(name,value); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setFloatParam'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class Balance */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Balance_getSingleton00 static int tolua_LuaBindings_Balance_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Balance",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Balance& tolua_ret = (Balance&) Balance::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"Balance"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: execQuery of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_execQuery00 static int tolua_LuaBindings_Database_execQuery00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Database",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Database* self = (Database*) tolua_tousertype(tolua_S,1,0); const std::string text = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'execQuery'", NULL); #endif { self->execQuery(text); tolua_pushcppstring(tolua_S,(const char*)text); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'execQuery'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: nextRow of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_nextRow00 static int tolua_LuaBindings_Database_nextRow00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Database",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Database* self = (Database*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'nextRow'", NULL); #endif { bool tolua_ret = (bool) self->nextRow(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'nextRow'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getString of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_getString00 static int tolua_LuaBindings_Database_getString00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Database",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Database* self = (Database*) tolua_tousertype(tolua_S,1,0); const std::string column = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getString'", NULL); #endif { std::string tolua_ret = (std::string) self->getString(column); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)column); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getString'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getInt of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_getInt00 static int tolua_LuaBindings_Database_getInt00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Database",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Database* self = (Database*) tolua_tousertype(tolua_S,1,0); const std::string column = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getInt'", NULL); #endif { int tolua_ret = (int) self->getInt(column); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)column); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getInt'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getFloat of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_getFloat00 static int tolua_LuaBindings_Database_getFloat00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Database",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Database* self = (Database*) tolua_tousertype(tolua_S,1,0); const std::string column = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFloat'", NULL); #endif { double tolua_ret = (double) self->getFloat(column); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)column); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getFloat'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: closeQuery of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_closeQuery00 static int tolua_LuaBindings_Database_closeQuery00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Database",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Database* self = (Database*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'closeQuery'", NULL); #endif { self->closeQuery(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'closeQuery'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class Database */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Database_getSingleton00 static int tolua_LuaBindings_Database_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Database",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Database& tolua_ret = (Database&) Database::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"Database"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new of class CFont */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_CFont_new00 static int tolua_LuaBindings_CFont_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CFont",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); { CFont* tolua_ret = (CFont*) Mtolua_new((CFont)(name)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CFont"); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class CFont */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_CFont_new00_local static int tolua_LuaBindings_CFont_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CFont",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); { CFont* tolua_ret = (CFont*) Mtolua_new((CFont)(name)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CFont"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getTextSize of class CFont */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_CFont_getTextSize00 static int tolua_LuaBindings_CFont_getTextSize00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CFont",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnumber(tolua_S,4,1,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { CFont* self = (CFont*) tolua_tousertype(tolua_S,1,0); std::string text = ((std::string) tolua_tocppstring(tolua_S,2,0)); int width = ((int) tolua_tonumber(tolua_S,3,NULL)); int height = ((int) tolua_tonumber(tolua_S,4,NULL)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextSize'", NULL); #endif { self->getTextSize(text,&width,&height); tolua_pushnumber(tolua_S,(lua_Number)width); tolua_pushnumber(tolua_S,(lua_Number)height); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getTextSize'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: drawText of class CFont */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_CFont_drawText00 static int tolua_LuaBindings_CFont_drawText00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CFont",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_iscppstring(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,1,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnumber(tolua_S,7,1,&tolua_err) || !tolua_isnumber(tolua_S,8,1,&tolua_err) || !tolua_isnoobj(tolua_S,9,&tolua_err) ) goto tolua_lerror; else #endif { CFont* self = (CFont*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); const std::string text = ((const std::string) tolua_tocppstring(tolua_S,4,0)); float r = ((float) tolua_tonumber(tolua_S,5,1.0f)); float g = ((float) tolua_tonumber(tolua_S,6,1.0f)); float b = ((float) tolua_tonumber(tolua_S,7,1.0f)); float a = ((float) tolua_tonumber(tolua_S,8,1.0f)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'drawText'", NULL); #endif { self->drawText(x,y,text,r,g,b,a); tolua_pushcppstring(tolua_S,(const char*)text); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawText'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setScreenSize of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_setScreenSize00 static int tolua_LuaBindings_Graphics_setScreenSize00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,1,&tolua_err) || !tolua_isnumber(tolua_S,5,1,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); float width = ((float) tolua_tonumber(tolua_S,2,0)); float height = ((float) tolua_tonumber(tolua_S,3,0)); float minAspect = ((float) tolua_tonumber(tolua_S,4,0.0f)); float maxAspect = ((float) tolua_tonumber(tolua_S,5,0.0f)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setScreenSize'", NULL); #endif { self->setScreenSize(width,height,minAspect,maxAspect); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setScreenSize'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getVisibleRect of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_getVisibleRect00 static int tolua_LuaBindings_Graphics_getVisibleRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,1,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnumber(tolua_S,4,1,&tolua_err) || !tolua_isnumber(tolua_S,5,1,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { const Graphics* self = (const Graphics*) tolua_tousertype(tolua_S,1,0); float x1 = ((float) tolua_tonumber(tolua_S,2,NULL)); float y1 = ((float) tolua_tonumber(tolua_S,3,NULL)); float x2 = ((float) tolua_tonumber(tolua_S,4,NULL)); float y2 = ((float) tolua_tonumber(tolua_S,5,NULL)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVisibleRect'", NULL); #endif { self->getVisibleRect(&x1,&y1,&x2,&y2); tolua_pushnumber(tolua_S,(lua_Number)x1); tolua_pushnumber(tolua_S,(lua_Number)y1); tolua_pushnumber(tolua_S,(lua_Number)x2); tolua_pushnumber(tolua_S,(lua_Number)y2); } } return 4; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getVisibleRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: show of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_show00 static int tolua_LuaBindings_Graphics_show00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'show'", NULL); #endif { self->show(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'show'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: hide of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_hide00 static int tolua_LuaBindings_Graphics_hide00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hide'", NULL); #endif { self->hide(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'hide'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isVSync of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_isVSync00 static int tolua_LuaBindings_Graphics_isVSync00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Graphics* self = (const Graphics*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVSync'", NULL); #endif { bool tolua_ret = (bool) self->isVSync(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isVSync'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setVSync of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_setVSync00 static int tolua_LuaBindings_Graphics_setVSync00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); bool vsync = ((bool) tolua_toboolean(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVSync'", NULL); #endif { self->setVSync(vsync); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setVSync'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getFPS of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_getFPS00 static int tolua_LuaBindings_Graphics_getFPS00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Graphics* self = (const Graphics*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFPS'", NULL); #endif { float tolua_ret = (float) self->getFPS(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getFPS'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getBlendMode of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_getBlendMode00 static int tolua_LuaBindings_Graphics_getBlendMode00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Graphics* self = (const Graphics*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBlendMode'", NULL); #endif { BlendMode tolua_ret = (BlendMode) self->getBlendMode(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getBlendMode'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setBlendMode of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_setBlendMode00 static int tolua_LuaBindings_Graphics_setBlendMode00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); BlendMode blendMode = ((BlendMode) (int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBlendMode'", NULL); #endif { self->setBlendMode(blendMode); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setBlendMode'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setClipRect of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_setClipRect00 static int tolua_LuaBindings_Graphics_setClipRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); float x1 = ((float) tolua_tonumber(tolua_S,2,0)); float y1 = ((float) tolua_tonumber(tolua_S,3,0)); float x2 = ((float) tolua_tonumber(tolua_S,4,0)); float y2 = ((float) tolua_tonumber(tolua_S,5,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClipRect'", NULL); #endif { self->setClipRect(x1,y1,x2,y2); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setClipRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: resetClipRect of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_resetClipRect00 static int tolua_LuaBindings_Graphics_resetClipRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetClipRect'", NULL); #endif { self->resetClipRect(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'resetClipRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: clear of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_clear00 static int tolua_LuaBindings_Graphics_clear00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); float r = ((float) tolua_tonumber(tolua_S,2,0)); float g = ((float) tolua_tonumber(tolua_S,3,0)); float b = ((float) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clear'", NULL); #endif { self->clear(r,g,b); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'clear'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: fillRect of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_fillRect00 static int tolua_LuaBindings_Graphics_fillRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isnumber(tolua_S,8,0,&tolua_err) || !tolua_isnumber(tolua_S,9,0,&tolua_err) || !tolua_isnoobj(tolua_S,10,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); float x1 = ((float) tolua_tonumber(tolua_S,2,0)); float y1 = ((float) tolua_tonumber(tolua_S,3,0)); float x2 = ((float) tolua_tonumber(tolua_S,4,0)); float y2 = ((float) tolua_tonumber(tolua_S,5,0)); float r = ((float) tolua_tonumber(tolua_S,6,0)); float g = ((float) tolua_tonumber(tolua_S,7,0)); float b = ((float) tolua_tonumber(tolua_S,8,0)); float a = ((float) tolua_tonumber(tolua_S,9,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fillRect'", NULL); #endif { self->fillRect(x1,y1,x2,y2,r,g,b,a); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'fillRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: gradientFill of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_gradientFill00 static int tolua_LuaBindings_Graphics_gradientFill00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isnumber(tolua_S,8,0,&tolua_err) || !tolua_isnumber(tolua_S,9,0,&tolua_err) || !tolua_isnumber(tolua_S,10,0,&tolua_err) || !tolua_isnumber(tolua_S,11,0,&tolua_err) || !tolua_isnumber(tolua_S,12,0,&tolua_err) || !tolua_isnumber(tolua_S,13,0,&tolua_err) || !tolua_isnoobj(tolua_S,14,&tolua_err) ) goto tolua_lerror; else #endif { Graphics* self = (Graphics*) tolua_tousertype(tolua_S,1,0); float x1 = ((float) tolua_tonumber(tolua_S,2,0)); float y1 = ((float) tolua_tonumber(tolua_S,3,0)); float x2 = ((float) tolua_tonumber(tolua_S,4,0)); float y2 = ((float) tolua_tonumber(tolua_S,5,0)); float r1 = ((float) tolua_tonumber(tolua_S,6,0)); float g1 = ((float) tolua_tonumber(tolua_S,7,0)); float b1 = ((float) tolua_tonumber(tolua_S,8,0)); float a1 = ((float) tolua_tonumber(tolua_S,9,0)); float r2 = ((float) tolua_tonumber(tolua_S,10,0)); float g2 = ((float) tolua_tonumber(tolua_S,11,0)); float b2 = ((float) tolua_tonumber(tolua_S,12,0)); float a2 = ((float) tolua_tonumber(tolua_S,13,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'gradientFill'", NULL); #endif { self->gradientFill(x1,y1,x2,y2,r1,g1,b1,a1,r2,g2,b2,a2); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'gradientFill'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class Graphics */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Graphics_getSingleton00 static int tolua_LuaBindings_Graphics_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Graphics",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Graphics& tolua_ret = (Graphics&) Graphics::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"Graphics"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isKeyDown of class Keyboard */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Keyboard_isKeyDown00 static int tolua_LuaBindings_Keyboard_isKeyDown00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Keyboard",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const Keyboard* self = (const Keyboard*) tolua_tousertype(tolua_S,1,0); int key = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isKeyDown'", NULL); #endif { bool tolua_ret = (bool) self->isKeyDown(key); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isKeyDown'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class Keyboard */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Keyboard_getSingleton00 static int tolua_LuaBindings_Keyboard_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Keyboard",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Keyboard& tolua_ret = (Keyboard&) Keyboard::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"Keyboard"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getPosition of class Mouse */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Mouse_getPosition00 static int tolua_LuaBindings_Mouse_getPosition00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Mouse",0,&tolua_err) || !tolua_isnumber(tolua_S,2,1,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const Mouse* self = (const Mouse*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,NULL)); float y = ((float) tolua_tonumber(tolua_S,3,NULL)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'", NULL); #endif { self->getPosition(&x,&y); tolua_pushnumber(tolua_S,(lua_Number)x); tolua_pushnumber(tolua_S,(lua_Number)y); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isKeyDown of class Mouse */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Mouse_isKeyDown00 static int tolua_LuaBindings_Mouse_isKeyDown00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Mouse",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const Mouse* self = (const Mouse*) tolua_tousertype(tolua_S,1,0); int key = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isKeyDown'", NULL); #endif { bool tolua_ret = (bool) self->isKeyDown(key); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isKeyDown'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: showCursor of class Mouse */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Mouse_showCursor00 static int tolua_LuaBindings_Mouse_showCursor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Mouse",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Mouse* self = (Mouse*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'showCursor'", NULL); #endif { self->showCursor(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'showCursor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: hideCursor of class Mouse */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Mouse_hideCursor00 static int tolua_LuaBindings_Mouse_hideCursor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Mouse",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Mouse* self = (Mouse*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hideCursor'", NULL); #endif { self->hideCursor(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'hideCursor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class Mouse */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Mouse_getSingleton00 static int tolua_LuaBindings_Mouse_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Mouse",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Mouse& tolua_ret = (Mouse&) Mouse::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"Mouse"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_new00 static int tolua_LuaBindings_Profile_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); { Profile* tolua_ret = (Profile*) Mtolua_new((Profile)(name)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Profile"); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_new00_local static int tolua_LuaBindings_Profile_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); { Profile* tolua_ret = (Profile*) Mtolua_new((Profile)(name)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Profile"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: save of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_save00 static int tolua_LuaBindings_Profile_save00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'save'", NULL); #endif { bool tolua_ret = (bool) self->save(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'save'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getString of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_getString00 static int tolua_LuaBindings_Profile_getString00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getString'", NULL); #endif { std::string tolua_ret = (std::string) self->getString(name); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getString'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getString of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_getString01 static int tolua_LuaBindings_Profile_getString01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_iscppstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string defaultValue = ((const std::string) tolua_tocppstring(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getString'", NULL); #endif { std::string tolua_ret = (std::string) self->getString(name,defaultValue); tolua_pushcppstring(tolua_S,(const char*)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); tolua_pushcppstring(tolua_S,(const char*)defaultValue); } } return 3; tolua_lerror: return tolua_LuaBindings_Profile_getString00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: setString of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_setString00 static int tolua_LuaBindings_Profile_setString00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_iscppstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string value = ((const std::string) tolua_tocppstring(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setString'", NULL); #endif { self->setString(name,value); tolua_pushcppstring(tolua_S,(const char*)name); tolua_pushcppstring(tolua_S,(const char*)value); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setString'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getInt of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_getInt00 static int tolua_LuaBindings_Profile_getInt00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); int defaultValue = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getInt'", NULL); #endif { int tolua_ret = (int) self->getInt(name,defaultValue); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getInt'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setInt of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_setInt00 static int tolua_LuaBindings_Profile_setInt00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); int value = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setInt'", NULL); #endif { self->setInt(name,value); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setInt'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getBool of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_getBool00 static int tolua_LuaBindings_Profile_getBool00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isboolean(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); bool defaultValue = ((bool) tolua_toboolean(tolua_S,3,false)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBool'", NULL); #endif { bool tolua_ret = (bool) self->getBool(name,defaultValue); tolua_pushboolean(tolua_S,(bool)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getBool'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setBool of class Profile */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Profile_setBool00 static int tolua_LuaBindings_Profile_setBool00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Profile",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isboolean(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Profile* self = (Profile*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); bool value = ((bool) tolua_toboolean(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBool'", NULL); #endif { self->setBool(name,value); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setBool'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: loadResource of class ResourceManager */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceManager_loadResource00 static int tolua_LuaBindings_ResourceManager_loadResource00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceManager",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_iscppstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { ResourceManager* self = (ResourceManager*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string fileName = ((const std::string) tolua_tocppstring(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadResource'", NULL); #endif { self->loadResource(name,fileName); tolua_pushcppstring(tolua_S,(const char*)name); tolua_pushcppstring(tolua_S,(const char*)fileName); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'loadResource'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: loadAllResources of class ResourceManager */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceManager_loadAllResources00 static int tolua_LuaBindings_ResourceManager_loadAllResources00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceManager",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { ResourceManager* self = (ResourceManager*) tolua_tousertype(tolua_S,1,0); const std::string fileName = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadAllResources'", NULL); #endif { self->loadAllResources(fileName); tolua_pushcppstring(tolua_S,(const char*)fileName); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'loadAllResources'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: unloadResource of class ResourceManager */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceManager_unloadResource00 static int tolua_LuaBindings_ResourceManager_unloadResource00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceManager",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { ResourceManager* self = (ResourceManager*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadResource'", NULL); #endif { self->unloadResource(name); tolua_pushcppstring(tolua_S,(const char*)name); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unloadResource'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: unloadAllResources of class ResourceManager */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceManager_unloadAllResources00 static int tolua_LuaBindings_ResourceManager_unloadAllResources00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceManager",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { ResourceManager* self = (ResourceManager*) tolua_tousertype(tolua_S,1,0); const std::string fileName = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadAllResources'", NULL); #endif { self->unloadAllResources(fileName); tolua_pushcppstring(tolua_S,(const char*)fileName); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unloadAllResources'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class ResourceManager */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceManager_getSingleton00 static int tolua_LuaBindings_ResourceManager_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"ResourceManager",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { ResourceManager& tolua_ret = (ResourceManager&) ResourceManager::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"ResourceManager"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: addResource of class ResourceQueue */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceQueue_addResource00 static int tolua_LuaBindings_ResourceQueue_addResource00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceQueue",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_iscppstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { ResourceQueue* self = (ResourceQueue*) tolua_tousertype(tolua_S,1,0); const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string fileName = ((const std::string) tolua_tocppstring(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addResource'", NULL); #endif { self->addResource(name,fileName); tolua_pushcppstring(tolua_S,(const char*)name); tolua_pushcppstring(tolua_S,(const char*)fileName); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'addResource'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: addAllResources of class ResourceQueue */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceQueue_addAllResources00 static int tolua_LuaBindings_ResourceQueue_addAllResources00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceQueue",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { ResourceQueue* self = (ResourceQueue*) tolua_tousertype(tolua_S,1,0); const std::string fileName = ((const std::string) tolua_tocppstring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addAllResources'", NULL); #endif { self->addAllResources(fileName); tolua_pushcppstring(tolua_S,(const char*)fileName); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'addAllResources'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: startLoading of class ResourceQueue */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceQueue_startLoading00 static int tolua_LuaBindings_ResourceQueue_startLoading00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"ResourceQueue",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { ResourceQueue* self = (ResourceQueue*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'startLoading'", NULL); #endif { self->startLoading(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'startLoading'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isLoadingActive of class ResourceQueue */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceQueue_isLoadingActive00 static int tolua_LuaBindings_ResourceQueue_isLoadingActive00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const ResourceQueue",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const ResourceQueue* self = (const ResourceQueue*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isLoadingActive'", NULL); #endif { bool tolua_ret = (bool) self->isLoadingActive(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isLoadingActive'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getLoadingProgress of class ResourceQueue */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceQueue_getLoadingProgress00 static int tolua_LuaBindings_ResourceQueue_getLoadingProgress00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const ResourceQueue",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const ResourceQueue* self = (const ResourceQueue*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLoadingProgress'", NULL); #endif { float tolua_ret = (float) self->getLoadingProgress(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getLoadingProgress'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSingleton of class ResourceQueue */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_ResourceQueue_getSingleton00 static int tolua_LuaBindings_ResourceQueue_getSingleton00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"ResourceQueue",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { ResourceQueue& tolua_ret = (ResourceQueue&) ResourceQueue::getSingleton(); tolua_pushusertype(tolua_S,(void*)&tolua_ret,"ResourceQueue"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_new00 static int tolua_LuaBindings_Sound_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Sound",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); { Sound* tolua_ret = (Sound*) Mtolua_new((Sound)(name)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Sound"); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_new00_local static int tolua_LuaBindings_Sound_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Sound",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); { Sound* tolua_ret = (Sound*) Mtolua_new((Sound)(name)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Sound"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isPlaying of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_isPlaying00 static int tolua_LuaBindings_Sound_isPlaying00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sound",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Sound* self = (Sound*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPlaying'", NULL); #endif { bool tolua_ret = (bool) self->isPlaying(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isPlaying'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isPaused of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_isPaused00 static int tolua_LuaBindings_Sound_isPaused00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sound",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Sound* self = (const Sound*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPaused'", NULL); #endif { bool tolua_ret = (bool) self->isPaused(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isPaused'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: play of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_play00 static int tolua_LuaBindings_Sound_play00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sound",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Sound* self = (Sound*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'play'", NULL); #endif { self->play(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'play'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: pause of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_pause00 static int tolua_LuaBindings_Sound_pause00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sound",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Sound* self = (Sound*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'pause'", NULL); #endif { self->pause(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'pause'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: stop of class Sound */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sound_stop00 static int tolua_LuaBindings_Sound_stop00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sound",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Sound* self = (Sound*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'stop'", NULL); #endif { self->stop(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'stop'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_new00 static int tolua_LuaBindings_Sprite_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); float x = ((float) tolua_tonumber(tolua_S,3,0)); float y = ((float) tolua_tonumber(tolua_S,4,0)); { Sprite* tolua_ret = (Sprite*) Mtolua_new((Sprite)(name,x,y)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Sprite"); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_new00_local static int tolua_LuaBindings_Sprite_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_iscppstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { const std::string name = ((const std::string) tolua_tocppstring(tolua_S,2,0)); float x = ((float) tolua_tonumber(tolua_S,3,0)); float y = ((float) tolua_tonumber(tolua_S,4,0)); { Sprite* tolua_ret = (Sprite*) Mtolua_new((Sprite)(name,x,y)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Sprite"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); tolua_pushcppstring(tolua_S,(const char*)name); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* get function: x of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_x static int tolua_get_Sprite_x(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_x()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: x of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_x static int tolua_set_Sprite_x(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_x(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* get function: y of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_y static int tolua_get_Sprite_y(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_y()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: y of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_y static int tolua_set_Sprite_y(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_y(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* get function: red of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_red static int tolua_get_Sprite_red(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'red'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_red()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: red of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_red static int tolua_set_Sprite_red(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'red'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_red(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* get function: green of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_green static int tolua_get_Sprite_green(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'green'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_green()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: green of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_green static int tolua_set_Sprite_green(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'green'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_green(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* get function: blue of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_blue static int tolua_get_Sprite_blue(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'blue'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_blue()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: blue of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_blue static int tolua_set_Sprite_blue(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'blue'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_blue(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* get function: alpha of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_alpha static int tolua_get_Sprite_alpha(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'alpha'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_alpha()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: alpha of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_alpha static int tolua_set_Sprite_alpha(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'alpha'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_alpha(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* method: getNumFrames of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_getNumFrames00 static int tolua_LuaBindings_Sprite_getNumFrames00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sprite",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Sprite* self = (const Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNumFrames'", NULL); #endif { int tolua_ret = (int) self->getNumFrames(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getNumFrames'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* get function: frame of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_frame static int tolua_get_Sprite_frame(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'frame'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_frame()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: frame of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_frame static int tolua_set_Sprite_frame(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'frame'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_frame(((int) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* method: getWidth of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_getWidth00 static int tolua_LuaBindings_Sprite_getWidth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sprite",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Sprite* self = (const Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'", NULL); #endif { int tolua_ret = (int) self->getWidth(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHeight of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_getHeight00 static int tolua_LuaBindings_Sprite_getHeight00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sprite",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const Sprite* self = (const Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'", NULL); #endif { int tolua_ret = (int) self->getHeight(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHotSpot of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_getHotSpot00 static int tolua_LuaBindings_Sprite_getHotSpot00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,1,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const Sprite* self = (const Sprite*) tolua_tousertype(tolua_S,1,0); int x = ((int) tolua_tonumber(tolua_S,2,NULL)); int y = ((int) tolua_tonumber(tolua_S,3,NULL)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHotSpot'", NULL); #endif { self->getHotSpot(&x,&y); tolua_pushnumber(tolua_S,(lua_Number)x); tolua_pushnumber(tolua_S,(lua_Number)y); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getHotSpot'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setHotSpot of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_setHotSpot00 static int tolua_LuaBindings_Sprite_setHotSpot00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); int x = ((int) tolua_tonumber(tolua_S,2,0)); int y = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHotSpot'", NULL); #endif { self->setHotSpot(x,y); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setHotSpot'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* get function: angle of class Sprite */ #ifndef TOLUA_DISABLE_tolua_get_Sprite_angle static int tolua_get_Sprite_angle(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'angle'",NULL); #endif tolua_pushnumber(tolua_S,(lua_Number)self->get_angle()); return 1; } #endif //#ifndef TOLUA_DISABLE /* set function: angle of class Sprite */ #ifndef TOLUA_DISABLE_tolua_set_Sprite_angle static int tolua_set_Sprite_angle(lua_State* tolua_S) { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'angle'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif self->set_angle(((float) tolua_tonumber(tolua_S,2,0)) ) ; return 0; } #endif //#ifndef TOLUA_DISABLE /* method: getScale of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_getScale00 static int tolua_LuaBindings_Sprite_getScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,1,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const Sprite* self = (const Sprite*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,NULL)); float y = ((float) tolua_tonumber(tolua_S,3,NULL)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getScale'", NULL); #endif { self->getScale(&x,&y); tolua_pushnumber(tolua_S,(lua_Number)x); tolua_pushnumber(tolua_S,(lua_Number)y); } } return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getScale'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setScale of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_setScale00 static int tolua_LuaBindings_Sprite_setScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0.0f)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setScale'", NULL); #endif { self->setScale(x,y); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setScale'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isPointInside of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_isPointInside00 static int tolua_LuaBindings_Sprite_isPointInside00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const Sprite* self = (const Sprite*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPointInside'", NULL); #endif { bool tolua_ret = (bool) self->isPointInside(x,y); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isPointInside'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: draw of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_draw00 static int tolua_LuaBindings_Sprite_draw00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'draw'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: draw of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_draw01 static int tolua_LuaBindings_Sprite_draw01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y); } } return 0; tolua_lerror: return tolua_LuaBindings_Sprite_draw00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_draw02 static int tolua_LuaBindings_Sprite_draw02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); float x1 = ((float) tolua_tonumber(tolua_S,2,0)); float y1 = ((float) tolua_tonumber(tolua_S,3,0)); float x2 = ((float) tolua_tonumber(tolua_S,4,0)); float y2 = ((float) tolua_tonumber(tolua_S,5,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x1,y1,x2,y2); } } return 0; tolua_lerror: return tolua_LuaBindings_Sprite_draw01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class Sprite */ #ifndef TOLUA_DISABLE_tolua_LuaBindings_Sprite_draw03 static int tolua_LuaBindings_Sprite_draw03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Sprite",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isnumber(tolua_S,8,0,&tolua_err) || !tolua_isnumber(tolua_S,9,0,&tolua_err) || !tolua_isnoobj(tolua_S,10,&tolua_err) ) goto tolua_lerror; else { Sprite* self = (Sprite*) tolua_tousertype(tolua_S,1,0); float x1 = ((float) tolua_tonumber(tolua_S,2,0)); float y1 = ((float) tolua_tonumber(tolua_S,3,0)); float x2 = ((float) tolua_tonumber(tolua_S,4,0)); float y2 = ((float) tolua_tonumber(tolua_S,5,0)); float sx1 = ((float) tolua_tonumber(tolua_S,6,0)); float sy1 = ((float) tolua_tonumber(tolua_S,7,0)); float sx2 = ((float) tolua_tonumber(tolua_S,8,0)); float sy2 = ((float) tolua_tonumber(tolua_S,9,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x1,y1,x2,y2,sx1,sy1,sx2,sy2); } } return 0; tolua_lerror: return tolua_LuaBindings_Sprite_draw02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* Open function */ TOLUA_API int tolua_LuaBindings_open (lua_State* tolua_S) { tolua_open(tolua_S); tolua_reg_types(tolua_S); tolua_module(tolua_S,NULL,0); tolua_beginmodule(tolua_S,NULL); tolua_cclass(tolua_S,"Application","Application","",NULL); tolua_beginmodule(tolua_S,"Application"); tolua_function(tolua_S,"getDataDirectory",tolua_LuaBindings_Application_getDataDirectory00); tolua_function(tolua_S,"getCompanyName",tolua_LuaBindings_Application_getCompanyName00); tolua_function(tolua_S,"setCompanyName",tolua_LuaBindings_Application_setCompanyName00); tolua_function(tolua_S,"getApplicationName",tolua_LuaBindings_Application_getApplicationName00); tolua_function(tolua_S,"setApplicationName",tolua_LuaBindings_Application_setApplicationName00); tolua_function(tolua_S,"getApplicationVersion",tolua_LuaBindings_Application_getApplicationVersion00); tolua_function(tolua_S,"setApplicationVersion",tolua_LuaBindings_Application_setApplicationVersion00); tolua_function(tolua_S,"quit",tolua_LuaBindings_Application_quit00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_Application_getSingleton00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"Balance","Balance","",NULL); tolua_beginmodule(tolua_S,"Balance"); tolua_function(tolua_S,"isConnected",tolua_LuaBindings_Balance_isConnected00); tolua_function(tolua_S,"isProtocolValid",tolua_LuaBindings_Balance_isProtocolValid00); tolua_function(tolua_S,"setServerAddr",tolua_LuaBindings_Balance_setServerAddr00); tolua_function(tolua_S,"setOscMode",tolua_LuaBindings_Balance_setOscMode00); tolua_function(tolua_S,"getParam",tolua_LuaBindings_Balance_getParam00); tolua_function(tolua_S,"getIntParam",tolua_LuaBindings_Balance_getIntParam00); tolua_function(tolua_S,"getFloatParam",tolua_LuaBindings_Balance_getFloatParam00); tolua_function(tolua_S,"setParam",tolua_LuaBindings_Balance_setParam00); tolua_function(tolua_S,"setParam",tolua_LuaBindings_Balance_setParam01); tolua_function(tolua_S,"setIntParam",tolua_LuaBindings_Balance_setIntParam00); tolua_function(tolua_S,"setFloatParam",tolua_LuaBindings_Balance_setFloatParam00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_Balance_getSingleton00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"Database","Database","",NULL); tolua_beginmodule(tolua_S,"Database"); tolua_function(tolua_S,"execQuery",tolua_LuaBindings_Database_execQuery00); tolua_function(tolua_S,"nextRow",tolua_LuaBindings_Database_nextRow00); tolua_function(tolua_S,"getString",tolua_LuaBindings_Database_getString00); tolua_function(tolua_S,"getInt",tolua_LuaBindings_Database_getInt00); tolua_function(tolua_S,"getFloat",tolua_LuaBindings_Database_getFloat00); tolua_function(tolua_S,"closeQuery",tolua_LuaBindings_Database_closeQuery00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_Database_getSingleton00); tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"CFont","CFont","",tolua_collect_CFont); #else tolua_cclass(tolua_S,"CFont","CFont","",NULL); #endif tolua_beginmodule(tolua_S,"CFont"); tolua_function(tolua_S,"new",tolua_LuaBindings_CFont_new00); tolua_function(tolua_S,"new_local",tolua_LuaBindings_CFont_new00_local); tolua_function(tolua_S,".call",tolua_LuaBindings_CFont_new00_local); tolua_function(tolua_S,"getTextSize",tolua_LuaBindings_CFont_getTextSize00); tolua_function(tolua_S,"drawText",tolua_LuaBindings_CFont_drawText00); tolua_endmodule(tolua_S); tolua_constant(tolua_S,"BLEND_DISABLE",BLEND_DISABLE); tolua_constant(tolua_S,"BLEND_ALPHA",BLEND_ALPHA); tolua_constant(tolua_S,"BLEND_ADD",BLEND_ADD); tolua_constant(tolua_S,"BLEND_SUBTRACT",BLEND_SUBTRACT); tolua_constant(tolua_S,"BLEND_MULTIPLY",BLEND_MULTIPLY); tolua_cclass(tolua_S,"Graphics","Graphics","",NULL); tolua_beginmodule(tolua_S,"Graphics"); tolua_function(tolua_S,"setScreenSize",tolua_LuaBindings_Graphics_setScreenSize00); tolua_function(tolua_S,"getVisibleRect",tolua_LuaBindings_Graphics_getVisibleRect00); tolua_function(tolua_S,"show",tolua_LuaBindings_Graphics_show00); tolua_function(tolua_S,"hide",tolua_LuaBindings_Graphics_hide00); tolua_function(tolua_S,"isVSync",tolua_LuaBindings_Graphics_isVSync00); tolua_function(tolua_S,"setVSync",tolua_LuaBindings_Graphics_setVSync00); tolua_function(tolua_S,"getFPS",tolua_LuaBindings_Graphics_getFPS00); tolua_function(tolua_S,"getBlendMode",tolua_LuaBindings_Graphics_getBlendMode00); tolua_function(tolua_S,"setBlendMode",tolua_LuaBindings_Graphics_setBlendMode00); tolua_function(tolua_S,"setClipRect",tolua_LuaBindings_Graphics_setClipRect00); tolua_function(tolua_S,"resetClipRect",tolua_LuaBindings_Graphics_resetClipRect00); tolua_function(tolua_S,"clear",tolua_LuaBindings_Graphics_clear00); tolua_function(tolua_S,"fillRect",tolua_LuaBindings_Graphics_fillRect00); tolua_function(tolua_S,"gradientFill",tolua_LuaBindings_Graphics_gradientFill00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_Graphics_getSingleton00); tolua_endmodule(tolua_S); tolua_constant(tolua_S,"KEY_BACKSPACE",CL_KEY_BACKSPACE); tolua_constant(tolua_S,"KEY_TAB",CL_KEY_TAB); tolua_constant(tolua_S,"KEY_CLEAR",CL_KEY_CLEAR); tolua_constant(tolua_S,"KEY_RETURN",CL_KEY_RETURN); tolua_constant(tolua_S,"KEY_SHIFT",CL_KEY_SHIFT); tolua_constant(tolua_S,"KEY_CONTROL",CL_KEY_CONTROL); tolua_constant(tolua_S,"KEY_MENU",CL_KEY_MENU); tolua_constant(tolua_S,"KEY_PAUSE",CL_KEY_PAUSE); tolua_constant(tolua_S,"KEY_ESCAPE",CL_KEY_ESCAPE); tolua_constant(tolua_S,"KEY_SPACE",CL_KEY_SPACE); tolua_constant(tolua_S,"KEY_PRIOR",CL_KEY_PRIOR); tolua_constant(tolua_S,"KEY_NEXT",CL_KEY_NEXT); tolua_constant(tolua_S,"KEY_END",CL_KEY_END); tolua_constant(tolua_S,"KEY_HOME",CL_KEY_HOME); tolua_constant(tolua_S,"KEY_LEFT",CL_KEY_LEFT); tolua_constant(tolua_S,"KEY_UP",CL_KEY_UP); tolua_constant(tolua_S,"KEY_RIGHT",CL_KEY_RIGHT); tolua_constant(tolua_S,"KEY_DOWN",CL_KEY_DOWN); tolua_constant(tolua_S,"KEY_SELECT",CL_KEY_SELECT); tolua_constant(tolua_S,"KEY_PRINT",CL_KEY_PRINT); tolua_constant(tolua_S,"KEY_EXECUTE",CL_KEY_EXECUTE); tolua_constant(tolua_S,"KEY_INSERT",CL_KEY_INSERT); tolua_constant(tolua_S,"KEY_DELETE",CL_KEY_DELETE); tolua_constant(tolua_S,"KEY_HELP",CL_KEY_HELP); tolua_constant(tolua_S,"KEY_0",CL_KEY_0); tolua_constant(tolua_S,"KEY_1",CL_KEY_1); tolua_constant(tolua_S,"KEY_2",CL_KEY_2); tolua_constant(tolua_S,"KEY_3",CL_KEY_3); tolua_constant(tolua_S,"KEY_4",CL_KEY_4); tolua_constant(tolua_S,"KEY_5",CL_KEY_5); tolua_constant(tolua_S,"KEY_6",CL_KEY_6); tolua_constant(tolua_S,"KEY_7",CL_KEY_7); tolua_constant(tolua_S,"KEY_8",CL_KEY_8); tolua_constant(tolua_S,"KEY_9",CL_KEY_9); tolua_constant(tolua_S,"KEY_A",CL_KEY_A); tolua_constant(tolua_S,"KEY_B",CL_KEY_B); tolua_constant(tolua_S,"KEY_C",CL_KEY_C); tolua_constant(tolua_S,"KEY_D",CL_KEY_D); tolua_constant(tolua_S,"KEY_E",CL_KEY_E); tolua_constant(tolua_S,"KEY_F",CL_KEY_F); tolua_constant(tolua_S,"KEY_G",CL_KEY_G); tolua_constant(tolua_S,"KEY_H",CL_KEY_H); tolua_constant(tolua_S,"KEY_I",CL_KEY_I); tolua_constant(tolua_S,"KEY_J",CL_KEY_J); tolua_constant(tolua_S,"KEY_K",CL_KEY_K); tolua_constant(tolua_S,"KEY_L",CL_KEY_L); tolua_constant(tolua_S,"KEY_M",CL_KEY_M); tolua_constant(tolua_S,"KEY_N",CL_KEY_N); tolua_constant(tolua_S,"KEY_O",CL_KEY_O); tolua_constant(tolua_S,"KEY_P",CL_KEY_P); tolua_constant(tolua_S,"KEY_Q",CL_KEY_Q); tolua_constant(tolua_S,"KEY_R",CL_KEY_R); tolua_constant(tolua_S,"KEY_S",CL_KEY_S); tolua_constant(tolua_S,"KEY_T",CL_KEY_T); tolua_constant(tolua_S,"KEY_U",CL_KEY_U); tolua_constant(tolua_S,"KEY_V",CL_KEY_V); tolua_constant(tolua_S,"KEY_W",CL_KEY_W); tolua_constant(tolua_S,"KEY_X",CL_KEY_X); tolua_constant(tolua_S,"KEY_Y",CL_KEY_Y); tolua_constant(tolua_S,"KEY_Z",CL_KEY_Z); tolua_constant(tolua_S,"KEY_LWIN",CL_KEY_LWIN); tolua_constant(tolua_S,"KEY_RWIN",CL_KEY_RWIN); tolua_constant(tolua_S,"KEY_APPS",CL_KEY_APPS); tolua_constant(tolua_S,"KEY_NUMPAD0",CL_KEY_NUMPAD0); tolua_constant(tolua_S,"KEY_NUMPAD1",CL_KEY_NUMPAD1); tolua_constant(tolua_S,"KEY_NUMPAD2",CL_KEY_NUMPAD2); tolua_constant(tolua_S,"KEY_NUMPAD3",CL_KEY_NUMPAD3); tolua_constant(tolua_S,"KEY_NUMPAD4",CL_KEY_NUMPAD4); tolua_constant(tolua_S,"KEY_NUMPAD5",CL_KEY_NUMPAD5); tolua_constant(tolua_S,"KEY_NUMPAD6",CL_KEY_NUMPAD6); tolua_constant(tolua_S,"KEY_NUMPAD7",CL_KEY_NUMPAD7); tolua_constant(tolua_S,"KEY_NUMPAD8",CL_KEY_NUMPAD8); tolua_constant(tolua_S,"KEY_NUMPAD9",CL_KEY_NUMPAD9); tolua_constant(tolua_S,"KEY_NUMPAD_ENTER",CL_KEY_NUMPAD_ENTER); tolua_constant(tolua_S,"KEY_MULTIPLY",CL_KEY_MULTIPLY); tolua_constant(tolua_S,"KEY_ADD",CL_KEY_ADD); tolua_constant(tolua_S,"KEY_SEPARATOR",CL_KEY_SEPARATOR); tolua_constant(tolua_S,"KEY_SUBTRACT",CL_KEY_SUBTRACT); tolua_constant(tolua_S,"KEY_DECIMAL",CL_KEY_DECIMAL); tolua_constant(tolua_S,"KEY_DIVIDE",CL_KEY_DIVIDE); tolua_constant(tolua_S,"KEY_F1",CL_KEY_F1); tolua_constant(tolua_S,"KEY_F2",CL_KEY_F2); tolua_constant(tolua_S,"KEY_F3",CL_KEY_F3); tolua_constant(tolua_S,"KEY_F4",CL_KEY_F4); tolua_constant(tolua_S,"KEY_F5",CL_KEY_F5); tolua_constant(tolua_S,"KEY_F6",CL_KEY_F6); tolua_constant(tolua_S,"KEY_F7",CL_KEY_F7); tolua_constant(tolua_S,"KEY_F8",CL_KEY_F8); tolua_constant(tolua_S,"KEY_F9",CL_KEY_F9); tolua_constant(tolua_S,"KEY_F10",CL_KEY_F10); tolua_constant(tolua_S,"KEY_F11",CL_KEY_F11); tolua_constant(tolua_S,"KEY_F12",CL_KEY_F12); tolua_constant(tolua_S,"KEY_F13",CL_KEY_F13); tolua_constant(tolua_S,"KEY_F14",CL_KEY_F14); tolua_constant(tolua_S,"KEY_F15",CL_KEY_F15); tolua_constant(tolua_S,"KEY_F16",CL_KEY_F16); tolua_constant(tolua_S,"KEY_F17",CL_KEY_F17); tolua_constant(tolua_S,"KEY_F18",CL_KEY_F18); tolua_constant(tolua_S,"KEY_F19",CL_KEY_F19); tolua_constant(tolua_S,"KEY_F20",CL_KEY_F20); tolua_constant(tolua_S,"KEY_F21",CL_KEY_F21); tolua_constant(tolua_S,"KEY_F22",CL_KEY_F22); tolua_constant(tolua_S,"KEY_F23",CL_KEY_F23); tolua_constant(tolua_S,"KEY_F24",CL_KEY_F24); tolua_constant(tolua_S,"KEY_NUMLOCK",CL_KEY_NUMLOCK); tolua_constant(tolua_S,"KEY_SCROLL",CL_KEY_SCROLL); tolua_constant(tolua_S,"KEY_LSHIFT",CL_KEY_LSHIFT); tolua_constant(tolua_S,"KEY_RSHIFT",CL_KEY_RSHIFT); tolua_constant(tolua_S,"KEY_LCONTROL",CL_KEY_LCONTROL); tolua_constant(tolua_S,"KEY_RCONTROL",CL_KEY_RCONTROL); tolua_constant(tolua_S,"KEY_LMENU",CL_KEY_LMENU); tolua_constant(tolua_S,"KEY_RMENU",CL_KEY_RMENU); tolua_cclass(tolua_S,"Keyboard","Keyboard","",NULL); tolua_beginmodule(tolua_S,"Keyboard"); tolua_function(tolua_S,"isKeyDown",tolua_LuaBindings_Keyboard_isKeyDown00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_Keyboard_getSingleton00); tolua_endmodule(tolua_S); tolua_constant(tolua_S,"MOUSE_LEFT",CL_MOUSE_LEFT); tolua_constant(tolua_S,"MOUSE_RIGHT",CL_MOUSE_RIGHT); tolua_constant(tolua_S,"MOUSE_MIDDLE",CL_MOUSE_MIDDLE); tolua_constant(tolua_S,"MOUSE_WHEEL_UP",CL_MOUSE_WHEEL_UP); tolua_constant(tolua_S,"MOUSE_WHEEL_DOWN",CL_MOUSE_WHEEL_DOWN); tolua_cclass(tolua_S,"Mouse","Mouse","",NULL); tolua_beginmodule(tolua_S,"Mouse"); tolua_function(tolua_S,"getPosition",tolua_LuaBindings_Mouse_getPosition00); tolua_function(tolua_S,"isKeyDown",tolua_LuaBindings_Mouse_isKeyDown00); tolua_function(tolua_S,"showCursor",tolua_LuaBindings_Mouse_showCursor00); tolua_function(tolua_S,"hideCursor",tolua_LuaBindings_Mouse_hideCursor00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_Mouse_getSingleton00); tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"Profile","Profile","",tolua_collect_Profile); #else tolua_cclass(tolua_S,"Profile","Profile","",NULL); #endif tolua_beginmodule(tolua_S,"Profile"); tolua_function(tolua_S,"new",tolua_LuaBindings_Profile_new00); tolua_function(tolua_S,"new_local",tolua_LuaBindings_Profile_new00_local); tolua_function(tolua_S,".call",tolua_LuaBindings_Profile_new00_local); tolua_function(tolua_S,"save",tolua_LuaBindings_Profile_save00); tolua_function(tolua_S,"getString",tolua_LuaBindings_Profile_getString00); tolua_function(tolua_S,"getString",tolua_LuaBindings_Profile_getString01); tolua_function(tolua_S,"setString",tolua_LuaBindings_Profile_setString00); tolua_function(tolua_S,"getInt",tolua_LuaBindings_Profile_getInt00); tolua_function(tolua_S,"setInt",tolua_LuaBindings_Profile_setInt00); tolua_function(tolua_S,"getBool",tolua_LuaBindings_Profile_getBool00); tolua_function(tolua_S,"setBool",tolua_LuaBindings_Profile_setBool00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"ResourceManager","ResourceManager","",NULL); tolua_beginmodule(tolua_S,"ResourceManager"); tolua_function(tolua_S,"loadResource",tolua_LuaBindings_ResourceManager_loadResource00); tolua_function(tolua_S,"loadAllResources",tolua_LuaBindings_ResourceManager_loadAllResources00); tolua_function(tolua_S,"unloadResource",tolua_LuaBindings_ResourceManager_unloadResource00); tolua_function(tolua_S,"unloadAllResources",tolua_LuaBindings_ResourceManager_unloadAllResources00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_ResourceManager_getSingleton00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"ResourceQueue","ResourceQueue","",NULL); tolua_beginmodule(tolua_S,"ResourceQueue"); tolua_function(tolua_S,"addResource",tolua_LuaBindings_ResourceQueue_addResource00); tolua_function(tolua_S,"addAllResources",tolua_LuaBindings_ResourceQueue_addAllResources00); tolua_function(tolua_S,"startLoading",tolua_LuaBindings_ResourceQueue_startLoading00); tolua_function(tolua_S,"isLoadingActive",tolua_LuaBindings_ResourceQueue_isLoadingActive00); tolua_function(tolua_S,"getLoadingProgress",tolua_LuaBindings_ResourceQueue_getLoadingProgress00); tolua_function(tolua_S,"getSingleton",tolua_LuaBindings_ResourceQueue_getSingleton00); tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"Sound","Sound","",tolua_collect_Sound); #else tolua_cclass(tolua_S,"Sound","Sound","",NULL); #endif tolua_beginmodule(tolua_S,"Sound"); tolua_function(tolua_S,"new",tolua_LuaBindings_Sound_new00); tolua_function(tolua_S,"new_local",tolua_LuaBindings_Sound_new00_local); tolua_function(tolua_S,".call",tolua_LuaBindings_Sound_new00_local); tolua_function(tolua_S,"isPlaying",tolua_LuaBindings_Sound_isPlaying00); tolua_function(tolua_S,"isPaused",tolua_LuaBindings_Sound_isPaused00); tolua_function(tolua_S,"play",tolua_LuaBindings_Sound_play00); tolua_function(tolua_S,"pause",tolua_LuaBindings_Sound_pause00); tolua_function(tolua_S,"stop",tolua_LuaBindings_Sound_stop00); tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"Sprite","Sprite","",tolua_collect_Sprite); #else tolua_cclass(tolua_S,"Sprite","Sprite","",NULL); #endif tolua_beginmodule(tolua_S,"Sprite"); tolua_function(tolua_S,"new",tolua_LuaBindings_Sprite_new00); tolua_function(tolua_S,"new_local",tolua_LuaBindings_Sprite_new00_local); tolua_function(tolua_S,".call",tolua_LuaBindings_Sprite_new00_local); tolua_variable(tolua_S,"x",tolua_get_Sprite_x,tolua_set_Sprite_x); tolua_variable(tolua_S,"y",tolua_get_Sprite_y,tolua_set_Sprite_y); tolua_variable(tolua_S,"red",tolua_get_Sprite_red,tolua_set_Sprite_red); tolua_variable(tolua_S,"green",tolua_get_Sprite_green,tolua_set_Sprite_green); tolua_variable(tolua_S,"blue",tolua_get_Sprite_blue,tolua_set_Sprite_blue); tolua_variable(tolua_S,"alpha",tolua_get_Sprite_alpha,tolua_set_Sprite_alpha); tolua_function(tolua_S,"getNumFrames",tolua_LuaBindings_Sprite_getNumFrames00); tolua_variable(tolua_S,"frame",tolua_get_Sprite_frame,tolua_set_Sprite_frame); tolua_function(tolua_S,"getWidth",tolua_LuaBindings_Sprite_getWidth00); tolua_function(tolua_S,"getHeight",tolua_LuaBindings_Sprite_getHeight00); tolua_function(tolua_S,"getHotSpot",tolua_LuaBindings_Sprite_getHotSpot00); tolua_function(tolua_S,"setHotSpot",tolua_LuaBindings_Sprite_setHotSpot00); tolua_variable(tolua_S,"angle",tolua_get_Sprite_angle,tolua_set_Sprite_angle); tolua_function(tolua_S,"getScale",tolua_LuaBindings_Sprite_getScale00); tolua_function(tolua_S,"setScale",tolua_LuaBindings_Sprite_setScale00); tolua_function(tolua_S,"isPointInside",tolua_LuaBindings_Sprite_isPointInside00); tolua_function(tolua_S,"draw",tolua_LuaBindings_Sprite_draw00); tolua_function(tolua_S,"draw",tolua_LuaBindings_Sprite_draw01); tolua_function(tolua_S,"draw",tolua_LuaBindings_Sprite_draw02); tolua_function(tolua_S,"draw",tolua_LuaBindings_Sprite_draw03); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); return 1; } #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 TOLUA_API int luaopen_LuaBindings (lua_State* tolua_S) { return tolua_LuaBindings_open(tolua_S); }; #endif
[ [ [ 1, 2 ], [ 4, 17 ], [ 19, 64 ], [ 66, 68 ], [ 70, 70 ], [ 72, 75 ], [ 77, 399 ], [ 499, 769 ], [ 1000, 1229 ], [ 1292, 3594 ], [ 3598, 3606 ], [ 3617, 3637 ], [ 3640, 3872 ] ], [ [ 3, 3 ], [ 18, 18 ], [ 65, 65 ], [ 69, 69 ], [ 71, 71 ], [ 76, 76 ], [ 400, 498 ], [ 770, 999 ], [ 1230, 1291 ], [ 3595, 3597 ], [ 3607, 3616 ], [ 3638, 3639 ] ] ]
4a2473893e9f235eb74977391d4242b118c7ed2f
accd6e4daa3fc1103c86d245c784182e31681ea4
/Chess/Chess/MTD_fSearchEngine.h
9bedbbcdb7dbddd5fde50bcd987cd47230e2bb5a
[]
no_license
linfuqing/zero3d
d87ad6cf97069aea7861332a9ab8fc02b016d286
cebb12c37fe0c9047fb5b8fd3c50157638764c24
refs/heads/master
2016-09-05T19:37:56.213992
2011-08-04T01:37:36
2011-08-04T01:37:36
34,048,942
0
1
null
null
null
null
UTF-8
C++
false
false
1,522
h
#pragma once #include "alphabetaengine.h" template<typename TYPE, UINT WIDTH, UINT HEIGHT> class CMTD_fSearchEngine : public CAlphaBetaEngine<TYPE, WIDTH, HEIGHT> { public: CMTD_fSearchEngine(void) { } ~CMTD_fSearchEngine(void) { } virtual VOID SearchNextMove(BOARD<TYPE, WIDTH, HEIGHT>& Board, const SEARCHSIDE Side = NEGATIVE_SIDE) { m_pMover->m_Board.SetBoard(&Board); m_Side = Side; if(m_pMover->m_pTranspositionTable) m_pMover->m_pTranspositionTable->Initialize(m_pMover->m_Board); if(m_bHistoryHeuristic) memset( m_pHistory, 0, sizeof(m_pHistory) ); INT nGuess = m_nMaxDepth % 2 ? -m_pEveluation->m_nMAX_VALUE : m_pEveluation->m_nMAX_VALUE; if(m_bIterativeDeepening) { m_uDepth = m_uCount = 0; for(m_nMaxDepth = 1; m_nMaxDepth <= m_nSearchDepth; m_nMaxDepth++) { nGuess = MTD_f(nGuess, m_nMaxDepth); } } else { m_nMaxDepth = m_nSearchDepth; MTD_f(nGuess, m_nMaxDepth); } m_BestType = m_pMover->MakeMove(m_pBestMove); Board.SetBoard(&m_pMover->m_Board); } private: INT MTD_f(INT nGuess, UINT uDepth) { INT nUpperBound = m_pEveluation->m_nMAX_VALUE, nLowerBound = -m_pEveluation->m_nMAX_VALUE, nBeta; while(nLowerBound < nUpperBound) { nBeta = nGuess == nLowerBound ? nGuess + 1 : nGuess; nGuess = _AlphaBeta(uDepth, nBeta - 1, nBeta); if(nGuess < nBeta) nUpperBound = nGuess; else nLowerBound = nGuess; } return nGuess; } };
[ [ [ 1, 72 ] ] ]
2e79786125a83d6889c2a22aa5d45bce58efe6eb
93176e72508a8b04769ee55bece71095d814ec38
/Utilities/BGL/boost/fusion/view/transform_view/transform_view_iterator.hpp
3e87342881f58a258a5eec2d84d112029f516807
[ "BSL-1.0" ]
permissive
inglada/OTB
a0171a19be1428c0f3654c48fe5c35442934cf13
8b6d8a7df9d54c2b13189e00ba8fcb070e78e916
refs/heads/master
2021-01-19T09:23:47.919676
2011-06-29T17:29:21
2011-06-29T17:29:21
1,982,100
4
5
null
null
null
null
UTF-8
C++
false
false
3,167
hpp
/*============================================================================= Copyright (c) 2001-2006 Joel de Guzman 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) ==============================================================================*/ #if !defined(FUSION_TRANSFORM_VIEW_ITERATOR_07162005_1033) #define FUSION_TRANSFORM_VIEW_ITERATOR_07162005_1033 #include <boost/fusion/support/iterator_base.hpp> #include <boost/fusion/support/category_of.hpp> #include <boost/fusion/iterator/mpl/convert_iterator.hpp> #include <boost/fusion/adapted/mpl/mpl_iterator.hpp> #include <boost/fusion/view/transform_view/detail/deref_impl.hpp> #include <boost/fusion/view/transform_view/detail/next_impl.hpp> #include <boost/fusion/view/transform_view/detail/prior_impl.hpp> #include <boost/fusion/view/transform_view/detail/value_of_impl.hpp> #include <boost/fusion/view/transform_view/detail/advance_impl.hpp> #include <boost/fusion/view/transform_view/detail/distance_impl.hpp> #include <boost/fusion/view/transform_view/detail/equal_to_impl.hpp> namespace boost { namespace fusion { // Unary Version struct transform_view_iterator_tag; template <typename First, typename F> struct transform_view_iterator : iterator_base<transform_view_iterator<First, F> > { typedef transform_view_iterator_tag fusion_tag; typedef convert_iterator<First> converter; typedef typename converter::type first_type; typedef typename traits::category_of<first_type>::type category; typedef F transform_type; transform_view_iterator(First const& first, F const& f) : first(converter::call(first)), f(f) {} first_type first; transform_type f; private: // silence MSVC warning C4512: assignment operator could not be generated transform_view_iterator& operator= (transform_view_iterator const&); }; // Binary Version struct transform_view_iterator2_tag; template <typename First1, typename First2, typename F> struct transform_view_iterator2 : iterator_base<transform_view_iterator2<First1, First2, F> > { typedef transform_view_iterator2_tag fusion_tag; typedef convert_iterator<First1> converter1; typedef convert_iterator<First2> converter2; typedef typename converter1::type first1_type; typedef typename converter2::type first2_type; typedef typename traits::category_of<first1_type>::type category; typedef F transform_type; transform_view_iterator2(First1 const& first1, First2 const& first2, F const& f) : first1(converter1::call(first1)), first2(converter2::call(first2)), f(f) {} first1_type first1; first2_type first2; transform_type f; private: // silence MSVC warning C4512: assignment operator could not be generated transform_view_iterator2& operator= (transform_view_iterator2 const&); }; }} #endif
[ [ [ 1, 77 ] ] ]
64817b3e4d87ba901456782b84637bb8f84a0d21
fad6f9883d4ad2686c196dc532a9ecb9199500ee
/NXP-LPC/CommTest/CommTest/NewSvrDlg.h
76386b951fca943730fef3409373dea6ec109740
[]
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
528
h
#pragma once // CNewSvrDlg 对话框 class CNewSvrDlg : public CBCGPDialog { DECLARE_DYNAMIC(CNewSvrDlg) public: CNewSvrDlg(CWnd* pParent = NULL); // 标准构造函数 virtual ~CNewSvrDlg(); // 对话框数据 enum { IDD = IDD_DLG_NEW_SVR }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: virtual BOOL OnInitDialog(); UINT m_nSvrPortNum; CString m_szLocalIp; // DWORD m_dwLocalIp; protected: virtual void OnOK(); };
[ "lijin.unix@13de9a6c-71d3-11de-b374-81e7cb8b6ca2" ]
[ [ [ 1, 28 ] ] ]
8e11abcb56f25b48dbe93fa8e256a583e61e35fe
b08e948c33317a0a67487e497a9afbaf17b0fc4c
/Input/Input.h
104c2669011f34b24bd94b311b9d2f5417546d55
[]
no_license
15831944/bastionlandscape
e1acc932f6b5a452a3bd94471748b0436a96de5d
c8008384cf4e790400f9979b5818a5a3806bd1af
refs/heads/master
2023-03-16T03:28:55.813938
2010-05-21T15:00:07
2010-05-21T15:00:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,812
h
#ifndef __INPUT_H__ #define __INPUT_H__ #include "../Core/Core.h" #include "../Input/InputTypes.h" namespace ElixirEngine { //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class Input : public CoreObject { public: struct CreateInfo { CreateInfo(); HINSTANCE m_hInstance; HWND m_hWnd; bool m_bCreateDefaultKeyboard; bool m_bCreateDefaultMouse; Key m_uDefaultKeyboardKey; // if m_bCreateDefaultKeyboard is true then m_uDefaultKeyboardKey will be used as device key. Key m_uDefaultMouseKey; // if m_bCreateDefaultMouse is true then m_uDefaultMouseKey will be used as device key. DWORD m_uCooperativeLevelKeyboard; DWORD m_uCooperativeLevelMouse; }; public: Input(); virtual ~Input(); static void SetRoot(InputPtr _pInput); static InputPtr GetRoot(); virtual bool Create(const boost::any& _rConfig); virtual void Update(); virtual void Release(); DIPtr GetDirectInput(); bool RegisterDevice(const Key& _rDeviceKey, InputDevicePtr _pDevice); bool UnregisterDevice(const Key& _rDeviceKey, InputDevicePtr _pDevice); InputDevicePtr GetDevice(const Key& _rDeviceKey); bool GetDeviceInfo(const Key& _rDeviceKey, VoidPtr _pData); protected: static InputPtr s_pInput; DIPtr m_pDI; InputDevicePtrMap m_mDevices; InputDevicePtr m_pKeyboard; InputDevicePtr m_pMouse; Key m_uKeyboardKey; Key m_uMouseKey; }; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class InputDevice : public CoreObject { public: InputDevice(InputRef _rInput); virtual ~InputDevice(); virtual bool GetInfo(VoidPtr _pData) = 0; protected: InputRef m_rInput; }; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class InputDeviceKeyboard : public InputDevice { public: struct CreateInfo { InputPtr m_pInput; HWND m_hWnd; DWORD m_uCooperativeLevel; }; public: InputDeviceKeyboard(InputRef _rInput); virtual ~InputDeviceKeyboard(); virtual bool Create(const boost::any& _rConfig); virtual void Update(); virtual void Release(); virtual bool GetInfo(VoidPtr _pData); protected: DIDevicePtr m_pDevice; unsigned char m_aKeys[256]; }; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class InputDeviceMouse : public InputDevice { public: struct CreateInfo { InputPtr m_pInput; HWND m_hWnd; DWORD m_uCooperativeLevel; }; public: InputDeviceMouse(InputRef _rInput); virtual ~InputDeviceMouse(); virtual bool Create(const boost::any& _rConfig); virtual void Update(); virtual void Release(); virtual bool GetInfo(VoidPtr _pData); protected: DIDevicePtr m_pDevice; DIMouseState m_oState; }; } #endif // __INPUT_H__
[ "voodoohaust@97c0069c-804f-11de-81da-11cc53ed4329" ]
[ [ [ 1, 135 ] ] ]
f92e7d139fb38ce67db8f832fb203aa815438da8
45d9342056e62844bdef1ba1befdb078d87a0650
/step_map.cpp
15db2a76e1b21cc3685db19a04ef045f522f0fba
[]
no_license
martim00/enlighten
8881ad62ed68902badfcd84b68fef05491e483c4
fe870ba779a6caa3f9c5211c9ac89a7fdc083918
refs/heads/master
2016-09-08T02:00:03.237865
2010-05-10T17:08:21
2010-05-10T17:08:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
386
cpp
#include "step_map.h" #include <consumer.h> #include <enlighten_macros.h> namespace enlighten { Consumer consumer; Consumer::EndMarker ok; struct BuiltInSteps { STEP("it should throw", BuiltInSteps, ItShouldThrow) void ItShouldThrow() { consumer.NextStepShouldThrow(); } } builtinSteps; } //namespace enlighten
[ [ [ 1, 20 ] ] ]
50c5f34cd79a4932131293991d54c4f3e18c2a76
cd0289d3c3880341230f58250468d544d1cadc9f
/KonaNativeLib/Stdafx.cpp
4446ad54e6a731fa58b9c2eb71ba9471f8c6ef82
[]
no_license
dsavitskiy/KonaRemotingTest
1c2833ac21653854f2b3aa18b730381307105690
d18e1cbd10e593a2d535d83cf8dcf6708acca28d
refs/heads/master
2021-08-27T15:10:49.541807
2011-10-12T12:06:49
2011-10-12T12:06:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
209
cpp
// stdafx.cpp : source file that includes just the standard includes // KonaNativeLib.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
[ [ [ 1, 5 ] ] ]
76cf6934cfd0f6cbde9b81edcd7645da69a60abc
5f0b8d4a0817a46a9ae18a057a62c2442c0eb17e
/Include/layout/FlowLayout.cpp
1499bc791f68c8b33ce538ec8bedf49587c32130
[ "BSD-3-Clause" ]
permissive
gui-works/ui
3327cfef7b9bbb596f2202b81f3fc9a32d5cbe2b
023faf07ff7f11aa7d35c7849b669d18f8911cc6
refs/heads/master
2020-07-18T00:46:37.172575
2009-11-18T22:05:25
2009-11-18T22:05:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,247
cpp
/* * Copyright (c) 2003-2006, Bram Stein * 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. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 "./FlowLayout.h" #include "../Container.h" #include "../util/Rectangle.h" #include "../util/Dimension.h" #include "../util/Insets.h" namespace ui { namespace layout { FlowLayout::FlowLayout() : alignment(Component::CENTER) { setHgap(5); setVgap(5); } FlowLayout::FlowLayout(const FlowLayout& rhs) : LayoutManager(static_cast<LayoutManager>(rhs)), alignment(rhs.alignment) { } FlowLayout& FlowLayout::operator =(const FlowLayout& rhs) { FlowLayout temp(rhs); swap(temp); return *this; } void FlowLayout::swap(FlowLayout& rhs) throw() { std::swap(alignment,rhs.alignment); } FlowLayout::FlowLayout(int align) : alignment(align) { setHgap(5); setVgap(5); } FlowLayout::FlowLayout(int align, int hgap, int vgap) : alignment(align) { setHgap(hgap); setVgap(vgap); } const util::Dimension FlowLayout::preferredLayoutSize(const Container* parent) const { util::Dimension preferredSize; ComponentList::const_iterator iter; ComponentList list = parent->getChildren(); bool firstComponent = false; for(iter = list.begin(); iter != list.end(); ++iter) { if((*iter)->isVisible()) { preferredSize.height = std::max(preferredSize.height,(*iter)->getPreferredSize().height); preferredSize.width += (*iter)->getPreferredSize().width; if(firstComponent) { firstComponent = false; } else { preferredSize.width += getHgap(); } } } util::Insets parentInsets = parent->getInsets(); preferredSize.width += parentInsets.left + parentInsets.right + getHgap() + getHgap(); preferredSize.height += parentInsets.top + parentInsets.bottom + getVgap() + getVgap(); return preferredSize; /* util::Dimension dim; dim.height = 0; dim.width = 0; bool first = true; ComponentList::iterator iter; ComponentList childList = parent->getChildren(); for(iter = childList.begin(); iter != childList.end(); ++iter) { if((*iter)->isVisible()) { dim.height = std::max(dim.height,(*iter)->getPreferredSize().height); if(first) first = false; else dim.width += getHgap(); dim.width += (*iter)->getPreferredSize().width; } } dim.width += parent->getInsets().left + parent->getInsets().right + getHgap() * 2; dim.height += parent->getInsets().top + parent->getInsets().bottom + getVgap() * 2; return dim; */ } void FlowLayout::layoutContainer(const Container* parent) { /* util::Insets insets = parent->getInsets(); int maxWidth = parent->getBounds().width - (insets.left + insets.right + getHgap()*2); int numComponents = parent->getNumberOfChildren(); int x = 0; int y = insets.top + getVgap(); int rowHeight = 0, start = 0; ComponentList::iterator iter; ComponentList list = parent->getChildren(); int i = 0; for(iter = list.begin(); iter != list.end(); ++iter) { Component* comp = (*iter); if(comp->isVisible()) { comp->setSize(comp->getPreferredSize().width,comp->getPreferredSize().height); if((x == 0) || ((x + comp->getPreferredSize().width) <= maxWidth)) { if(x > 0) { x += getHgap(); } x += comp->getPreferredSize().width; rowHeight = std::max(rowHeight,comp->getPreferredSize().height); } else { moveComponents(parent,insets.left + getHgap(),y,maxWidth -x, rowHeight, start, i); x = comp->getPreferredSize().width; y += getVgap() + rowHeight; rowHeight = comp->getPreferredSize().height; start = i; } } ++i; } moveComponents(parent,insets.left + getHgap(),y,maxWidth -x, rowHeight, start, numComponents); */ util::Dimension rowDimension(0,0); util::Insets parentInsets = parent->getInsets(); util::Dimension parentDimension(parent->getBounds().width - parentInsets.left - parentInsets.right,parent->getBounds().height - parentInsets.top - parentInsets.bottom); int y = parentInsets.top; ComponentList::const_iterator iter; ComponentList list = parent->getChildren(); ComponentList row; for(iter = list.begin(); iter != list.end(); ++iter) { if((*iter)->isVisible()) { (*iter)->setSize((*iter)->getPreferredSize()); row.push_back((*iter)); rowDimension.height = std::max(rowDimension.height,(*iter)->getPreferredSize().height + getVgap()); rowDimension.width += (*iter)->getPreferredSize().width + getHgap(); if(rowDimension.width > parent->getBounds().width + (parentInsets.left + parentInsets.right)) { align(row,y,parentInsets,rowDimension,parentDimension); row.clear(); y += rowDimension.height; rowDimension.width = 0; rowDimension.height = 0; } } } align(row,y,parentInsets,rowDimension, parentDimension); } void FlowLayout::align(ComponentList &row, int rowHeight, util::Insets &parentInsets, util::Dimension &rowDimension, util::Dimension &parentDimension) { util::Point location(parentInsets.left,0); switch(alignment) { case Component::CENTER: { location.x = (getHgap() + parentDimension.width - rowDimension.width) / 2; break; } case Component::LEFT: { location.x = getHgap(); break; } case Component::RIGHT: { location.x = (parentDimension.width - rowDimension.width); break; } } ComponentList::const_iterator rowIterator; for(rowIterator = row.begin(); rowIterator != row.end(); ++rowIterator) { location.y = rowHeight + ((parentDimension.height / 2) - ((*rowIterator)->getBounds().height / 2)); (*rowIterator)->setLocation(location); location.x += (*rowIterator)->getBounds().width + getHgap(); } } /* void FlowLayout::moveComponents(Container* parent, int x, int y, int width, int height, int rowStart, int rowEnd) { switch(alignment) { case Component::CENTER: { x += width/2; break; } case Component::LEFT: { x += 0; break; } case Component::RIGHT: { x += width; break; } } for(int i = rowStart; i < rowEnd; ++i) { Component* comp = parent->getChild(i); if(comp->isVisible()) { comp->setLocation(x,y + (height - comp->getPreferredSize().height) /2); x += comp->getPreferredSize().width + getHgap(); } } } */ } }
[ "bs@bram.(none)" ]
[ [ [ 1, 289 ] ] ]
56340a5c605d833e05514193b334919bc25d31b0
1d6dcdeddc2066f451338361dc25196157b8b45c
/tp1/Visualizacion/Color.h
34ad1b0d6320e5900fa00fa3625cbf04408a3c2b
[]
no_license
nicohen/ssgg2009
1c105811837f82aaa3dd1f55987acaf8f62f16bb
467e4f475ef04d59740fa162ac10ee51f1f95f83
refs/heads/master
2020-12-24T08:16:36.476182
2009-08-15T00:43:57
2009-08-15T00:43:57
34,405,608
0
0
null
null
null
null
UTF-8
C++
false
false
928
h
#ifndef COLOR_H #define COLOR_H /** * Clase que representa un color a partir de su intensidad de los colores primaios * RGB (rojo verde azul) */ class Color { public: /** * Constructor * @param r Es el porcentaje de rojo del color. * @param r Es el porcentaje de rojo del color. * @param r Es el porcentaje de rojo del color. * @note Todos los valores estan comoprendidos entre [0.0,1.0] */ Color(float r,float g, float v); virtual ~Color(); float getRojo() { return rojo; } float getVerde() { return verde; } float getAzul() { return azul; } /** * Devuelve una copia del Color */ Color* copia(){ return new Color(this->rojo,this->verde,this->azul);} protected: private: float rojo; float verde; float azul; }; #endif // COLOR_H
[ "rodvar@6da81292-15a5-11de-a4db-e31d5fa7c4f0" ]
[ [ [ 1, 36 ] ] ]
da446c24a74af8db90da3797031aeb2f4597963f
796687b684b1604bc7d8a178d20e7071dec5b0e1
/game/include/Game.h
44a87ceb1e7200753e14b962ffba37a83acfacd0
[]
no_license
josenavas/ale-vj-qt2011
965498af5474bc65a015ab13e42878cb0451ce85
6e4e5ad486e5b2c4cfc1aa2044d35263f6acd263
refs/heads/master
2021-01-22T03:13:49.635483
2011-12-19T23:45:14
2011-12-19T23:45:14
32,129,957
1
0
null
null
null
null
UTF-8
C++
false
false
430
h
#ifndef __GAME_H #define __GAME_H #include <OgreRoot.h> #include "InputManager.h" class Game { public: Game(void); virtual ~Game(void); bool go(void); private: void loadResources(void); bool createRenderSystem(void); void initialisingResources(void); Ogre::Root* mRoot; Ogre::String mPluginsCfg; Ogre::String mResourcesCfg; Ogre::RenderWindow* mWindow; InputManager* mInputMgr; }; #endif
[ "[email protected]@55d2aa0d-96bd-598c-80cb-e06a2779e390" ]
[ [ [ 1, 27 ] ] ]
cf0aefb135add64ea45b034e39e03dd658f91b54
6253ab92ce2e85b4db9393aa630bde24655bd9b4
/operational/PathSmoother/PathSmoother/shared_ptr.h
4deea6b68f5c8f6f78a0ea9028d689c088c9e2ef
[]
no_license
Aand1/cornell-urban-challenge
94fd4df18fd4b6cc6e12d30ed8eed280826d4aed
779daae8703fe68e7c6256932883de32a309a119
refs/heads/master
2021-01-18T11:57:48.267384
2008-10-01T06:43:18
2008-10-01T06:43:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,520
h
#ifndef _SHARED_PTR_H #define _SHARED_PTR_H #include "ref_obj.h" #ifdef __cplusplus_cli #pragma managed(push,off) #endif template<class T> class shared_ptr { public: // default constructor, initialize to NULL shared_ptr(); shared_ptr(const shared_ptr<T>& copy); // constructor - initialize from T ptr shared_ptr(T* ptr); // destructor, automatically decrements the // reference count, deletes the object if // necessary ~shared_ptr(); // overloaded arrow operator, allows the user to call // methods using the contained pointer. T* operator->() const; // overloaded dereference operator, allows the user // to dereference the contained pointer. T& operator*() const; /** Overloaded equals operator, allows the user to * set the value of the SmartPtr from a raw pointer */ shared_ptr<T>& operator=(T* rhs); /** Overloaded equals operator, allows the user to * set the value of the SmartPtr from another * SmartPtr */ shared_ptr<T>& operator=(const shared_ptr<T>& rhs); /** Overloaded equality comparison operator, allows the * user to compare the value of two SmartPtrs */ template <class U1, class U2> friend bool operator==(const shared_ptr<U1>& lhs, const shared_ptr<U2>& rhs); /** Overloaded equality comparison operator, allows the * user to compare the value of a SmartPtr with a raw pointer. */ template <class U1, class U2> friend bool operator==(const shared_ptr<U1>& lhs, U2* raw_rhs); /** Overloaded equality comparison operator, allows the * user to compare the value of a raw pointer with a SmartPtr. */ template <class U1, class U2> friend bool operator==(U1* lhs, const shared_ptr<U2>& raw_rhs); /** Overloaded in-equality comparison operator, allows the * user to compare the value of two SmartPtrs */ template <class U1, class U2> friend bool operator!=(const shared_ptr<U1>& lhs, const shared_ptr<U2>& rhs); /** Overloaded in-equality comparison operator, allows the * user to compare the value of a SmartPtr with a raw pointer. */ template <class U1, class U2> friend bool operator!=(const shared_ptr<U1>& lhs, U2* raw_rhs); /** Overloaded in-equality comparison operator, allows the * user to compare the value of a SmartPtr with a raw pointer. */ template <class U1, class U2> friend bool operator!=(U1* lhs, const shared_ptr<U2>& raw_rhs); //@} /**@name friend method declarations. */ //@{ /** Returns the raw pointer contained. * Use to get the value of * the raw ptr (i.e. to pass to other * methods/functions, etc.) * Note: This method does NOT copy, * therefore, modifications using this * value modify the underlying object * contained by the SmartPtr, * NEVER delete this returned value. */ template <class U> friend U* get_raw_ptr(const shared_ptr<U>& ptr); /** Returns a const pointer */ template <class U> friend shared_ptr<const U> const_ptr(const shared_ptr<U>& ptr); /** Returns true if the SmartPtr is NOT NULL. * Use this to check if the SmartPtr is not null * This is preferred to if(GetRawPtr(sp) != NULL) */ template <class U> friend bool is_valid(const shared_ptr<U>& ptr); /** Returns true if the SmartPtr is NULL. * Use this to check if the SmartPtr IsNull. * This is preferred to if(GetRawPtr(sp) == NULL) */ template <class U> friend bool is_null(const shared_ptr<U>& ptr); //@} private: /**@name Private Data/Methods */ //@{ /** Actual raw pointer to the object. */ T* ptr_; /** Set the value of the internal raw pointer * from another raw pointer, releasing the * previously referenced object if necessary. */ shared_ptr<T>& set_from_raw_ptr(T* rhs); /** Set the value of the internal raw pointer * from a SmartPtr, releasing the previously referenced * object if necessary. */ shared_ptr<T>& set_from_shared_ptr(const shared_ptr<T>& rhs); /** Release the currently referenced object. */ void release_ptr(); //@} }; /**@name SmartPtr friend function declarations.*/ //@{ template <class U> U* get_raw_ptr(const shared_ptr<U>& ptr); template <class U> shared_ptr<const U> const_ptr(const shared_ptr<U>& ptr); template <class U> bool is_null(const shared_ptr<U>& ptr); template <class U> bool is_valid(const shared_ptr<U>& ptr); template <class U1, class U2> bool operator==(const shared_ptr<U1>& lhs, const shared_ptr<U2>& rhs); template <class U1, class U2> bool operator==(const shared_ptr<U1>& lhs, U2* raw_rhs); template <class U1, class U2> bool operator==(U1* lhs, const shared_ptr<U2>& raw_rhs); template <class U1, class U2> bool operator!=(const shared_ptr<U1>& lhs, const shared_ptr<U2>& rhs); template <class U1, class U2> bool operator!=(const shared_ptr<U1>& lhs, U2* raw_rhs); template <class U1, class U2> bool operator!=(U1* lhs, const shared_ptr<U2>& raw_rhs); //@} template <class T> shared_ptr<T>::shared_ptr() : ptr_(NULL) {} template <class T> shared_ptr<T>::shared_ptr(const shared_ptr<T>& copy) : ptr_(NULL) { set_from_shared_ptr(copy); } template <class T> shared_ptr<T>::shared_ptr(T* ptr) : ptr_(NULL) { set_from_raw_ptr(ptr); } template <class T> shared_ptr<T>::~shared_ptr() { release_ptr(); } template <class T> T* shared_ptr<T>::operator->() const { return ptr_; } template <class T> T& shared_ptr<T>::operator*() const { return *ptr_; } template <class T> shared_ptr<T>& shared_ptr<T>::operator=(T* rhs) { return set_from_raw_ptr(rhs); } template <class T> shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr<T>& rhs) { return set_from_shared_ptr(rhs); } template <class T> shared_ptr<T>& shared_ptr<T>::set_from_raw_ptr(T* rhs) { // Release any old pointer release_ptr(); if (rhs != NULL) { rhs->add_ref(); ptr_ = rhs; } return *this; } template <class T> shared_ptr<T>& shared_ptr<T>::set_from_shared_ptr(const shared_ptr<T>& rhs) { T* ptr = get_raw_ptr(rhs); set_from_raw_ptr(ptr); return (*this); } template <class T> void shared_ptr<T>::release_ptr() { if (ptr_) { if (ptr_->release_ref() == 0) { delete ptr_; } ptr_ = NULL; } } template <class U> U* get_raw_ptr(const shared_ptr<U>& ptr){ return ptr.ptr_; } template <class U> shared_ptr<const U> const_ptr(const shared_ptr<U>& ptr) { // compiler should implicitly cast return get_raw_ptr(ptr); } template <class U> bool is_valid(const shared_ptr<U>& ptr) { return !is_null(ptr); } template <class U> bool is_null(const shared_ptr<U>& ptr) { return (ptr.ptr_ == NULL); } template <class U1, class U2> bool compare_ptrs(const U1* lhs, const U2* rhs) { if (lhs == rhs) { return true; } // Even if lhs and rhs point to the same object // with different interfaces U1 and U2, we cannot guarantee that // the value of the pointers will be equivalent. We can // guarantee this if we convert to void* const void* v_lhs = static_cast<const void*>(lhs); const void* v_rhs = static_cast<const void*>(rhs); if (v_lhs == v_rhs) { return true; } // They must not be the same return false; } template <class U1, class U2> bool operator==(const shared_ptr<U1>& lhs, const shared_ptr<U2>& rhs) { U1* raw_lhs = get_raw_ptr(lhs); U2* raw_rhs = get_raw_ptr(rhs); return compare_ptrs(raw_lhs, raw_rhs); } template <class U1, class U2> bool operator==(const shared_ptr<U1>& lhs, U2* raw_rhs) { U1* raw_lhs = get_raw_ptr(lhs); return compare_ptrs(raw_lhs, raw_rhs); } template <class U1, class U2> bool operator==(U1* raw_lhs, const shared_ptr<U2>& rhs) { const U2* raw_rhs = get_raw_ptr(rhs); return compare_ptrs(raw_lhs, raw_rhs); } template <class U1, class U2> bool operator!=(const shared_ptr<U1>& lhs, const shared_ptr<U2>& rhs) { bool retValue = operator==(lhs, rhs); return !retValue; } template <class U1, class U2> bool operator!=(const shared_ptr<U1>& lhs, U2* raw_rhs) { bool retValue = operator==(lhs, raw_rhs); return !retValue; } template <class U1, class U2> bool operator!=(U1* raw_lhs, const shared_ptr<U2>& rhs) { bool retValue = operator==(raw_lhs, rhs); return !retValue; } #ifdef __cplusplus_cli #pragma managed(pop) #endif #endif
[ "anathan@5031bdca-8e6f-11dd-8a4e-8714b3728bc5" ]
[ [ [ 1, 329 ] ] ]
10ae99397d925872a89248f48b52af8b3c2adf7e
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/ForceFieldShapeFactory.h
9339e23adb140e7891874b6986a5b49d00d2142d
[]
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
763
h
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: ForceFieldShapeFactory.h Version: 0.02 --------------------------------------------------------------------------- */ #pragma once #ifndef __INC_FORCEFIELDSHAPEFACTORY_H_ #define __INC_FORCEFIELDSHAPEFACTORY_H_ #include "Prerequisities.h" namespace nGENE { /** Base ForceFieldShapeFactory class. @remarks Each ForceFieldShape class should be accompanied by its own (derived) ForceFieldShapeFactory class. */ class nGENEDLL ForceFieldShapeFactory { public: virtual ForceFieldShape* createShape()=0; }; } #endif
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 37 ] ] ]
1343c15b29351a62e0cce062d0a3d99dedde9378
f8403b6b1005f80d2db7fad9ee208887cdca6aec
/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h
d4b58d296cc51610f0b9e1dbdcf74e4f7bc5f7ba
[]
no_license
sonic59/JuceText
25544cb07e5b414f9d7109c0826a16fc1de2e0d4
5ac010ffe59c2025d25bc0f9c02fc829ada9a3d2
refs/heads/master
2021-01-15T13:18:11.670907
2011-10-29T19:03:25
2011-10-29T19:03:25
2,507,112
0
0
null
null
null
null
UTF-8
C++
false
false
110,310
h
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #ifndef __JUCE_COMPONENT_JUCEHEADER__ #define __JUCE_COMPONENT_JUCEHEADER__ #include "../mouse/juce_MouseCursor.h" #include "../mouse/juce_MouseListener.h" #include "../mouse/juce_MouseEvent.h" #include "juce_ComponentListener.h" #include "../keyboard/juce_KeyListener.h" #include "../keyboard/juce_KeyboardFocusTraverser.h" #include "juce_ModalComponentManager.h" class LookAndFeel; class MouseInputSource; class MouseInputSourceInternal; class ComponentPeer; class MarkerList; class RelativeRectangle; //============================================================================== /** The base class for all JUCE user-interface objects. */ class JUCE_API Component : public MouseListener { public: //============================================================================== /** Creates a component. To get it to actually appear, you'll also need to: - Either add it to a parent component or use the addToDesktop() method to make it a desktop window - Set its size and position to something sensible - Use setVisible() to make it visible And for it to serve any useful purpose, you'll need to write a subclass of Component or use one of the other types of component from the library. */ Component(); /** Destructor. Note that when a component is deleted, any child components it contains are NOT automatically deleted. It's your responsibilty to manage their lifespan - you may want to use helper methods like deleteAllChildren(), or less haphazard approaches like using ScopedPointers or normal object aggregation to manage them. If the component being deleted is currently the child of another one, then during deletion, it will be removed from its parent, and the parent will receive a childrenChanged() callback. Any ComponentListener objects that have registered with it will also have their ComponentListener::componentBeingDeleted() methods called. */ virtual ~Component(); //============================================================================== /** Creates a component, setting its name at the same time. @see getName, setName */ explicit Component (const String& componentName); /** Returns the name of this component. @see setName */ const String& getName() const noexcept { return componentName; } /** Sets the name of this component. When the name changes, all registered ComponentListeners will receive a ComponentListener::componentNameChanged() callback. @see getName */ virtual void setName (const String& newName); /** Returns the ID string that was set by setComponentID(). @see setComponentID, findChildWithID */ const String& getComponentID() const noexcept { return componentID; } /** Sets the component's ID string. You can retrieve the ID using getComponentID(). @see getComponentID, findChildWithID */ void setComponentID (const String& newID); //============================================================================== /** Makes the component visible or invisible. This method will show or hide the component. Note that components default to being non-visible when first created. Also note that visible components won't be seen unless all their parent components are also visible. This method will call visibilityChanged() and also componentVisibilityChanged() for any component listeners that are interested in this component. @param shouldBeVisible whether to show or hide the component @see isVisible, isShowing, visibilityChanged, ComponentListener::componentVisibilityChanged */ virtual void setVisible (bool shouldBeVisible); /** Tests whether the component is visible or not. this doesn't necessarily tell you whether this comp is actually on the screen because this depends on whether all the parent components are also visible - use isShowing() to find this out. @see isShowing, setVisible */ bool isVisible() const noexcept { return flags.visibleFlag; } /** Called when this component's visiblility changes. @see setVisible, isVisible */ virtual void visibilityChanged(); /** Tests whether this component and all its parents are visible. @returns true only if this component and all its parents are visible. @see isVisible */ bool isShowing() const; //============================================================================== /** Makes this component appear as a window on the desktop. Note that before calling this, you should make sure that the component's opacity is set correctly using setOpaque(). If the component is non-opaque, the windowing system will try to create a special transparent window for it, which will generally take a lot more CPU to operate (and might not even be possible on some platforms). If the component is inside a parent component at the time this method is called, it will be first be removed from that parent. Likewise if a component on the desktop is subsequently added to another component, it'll be removed from the desktop. @param windowStyleFlags a combination of the flags specified in the ComponentPeer::StyleFlags enum, which define the window's characteristics. @param nativeWindowToAttachTo this allows an OS object to be passed-in as the window in which the juce component should place itself. On Windows, this would be a HWND, a HIViewRef on the Mac. Not necessarily supported on all platforms, and best left as 0 unless you know what you're doing @see removeFromDesktop, isOnDesktop, userTriedToCloseWindow, getPeer, ComponentPeer::setMinimised, ComponentPeer::StyleFlags, ComponentPeer::getStyleFlags, ComponentPeer::setFullScreen */ virtual void addToDesktop (int windowStyleFlags, void* nativeWindowToAttachTo = nullptr); /** If the component is currently showing on the desktop, this will hide it. You can also use setVisible() to hide a desktop window temporarily, but removeFromDesktop() will free any system resources that are being used up. @see addToDesktop, isOnDesktop */ void removeFromDesktop(); /** Returns true if this component is currently showing on the desktop. @see addToDesktop, removeFromDesktop */ bool isOnDesktop() const noexcept; /** Returns the heavyweight window that contains this component. If this component is itself on the desktop, this will return the window object that it is using. Otherwise, it will return the window of its top-level parent component. This may return 0 if there isn't a desktop component. @see addToDesktop, isOnDesktop */ ComponentPeer* getPeer() const; /** For components on the desktop, this is called if the system wants to close the window. This is a signal that either the user or the system wants the window to close. The default implementation of this method will trigger an assertion to warn you that your component should do something about it, but you can override this to ignore the event if you want. */ virtual void userTriedToCloseWindow(); /** Called for a desktop component which has just been minimised or un-minimised. This will only be called for components on the desktop. @see getPeer, ComponentPeer::setMinimised, ComponentPeer::isMinimised */ virtual void minimisationStateChanged (bool isNowMinimised); //============================================================================== /** Brings the component to the front of its siblings. If some of the component's siblings have had their 'always-on-top' flag set, then they will still be kept in front of this one (unless of course this one is also 'always-on-top'). @param shouldAlsoGainFocus if true, this will also try to assign keyboard focus to the component (see grabKeyboardFocus() for more details) @see toBack, toBehind, setAlwaysOnTop */ void toFront (bool shouldAlsoGainFocus); /** Changes this component's z-order to be at the back of all its siblings. If the component is set to be 'always-on-top', it will only be moved to the back of the other other 'always-on-top' components. @see toFront, toBehind, setAlwaysOnTop */ void toBack(); /** Changes this component's z-order so that it's just behind another component. @see toFront, toBack */ void toBehind (Component* other); /** Sets whether the component should always be kept at the front of its siblings. @see isAlwaysOnTop */ void setAlwaysOnTop (bool shouldStayOnTop); /** Returns true if this component is set to always stay in front of its siblings. @see setAlwaysOnTop */ bool isAlwaysOnTop() const noexcept; //============================================================================== /** Returns the x coordinate of the component's left edge. This is a distance in pixels from the left edge of the component's parent. Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to its bounding box. */ inline int getX() const noexcept { return bounds.getX(); } /** Returns the y coordinate of the top of this component. This is a distance in pixels from the top edge of the component's parent. Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to its bounding box. */ inline int getY() const noexcept { return bounds.getY(); } /** Returns the component's width in pixels. */ inline int getWidth() const noexcept { return bounds.getWidth(); } /** Returns the component's height in pixels. */ inline int getHeight() const noexcept { return bounds.getHeight(); } /** Returns the x coordinate of the component's right-hand edge. This is a distance in pixels from the left edge of the component's parent. Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to its bounding box. */ int getRight() const noexcept { return bounds.getRight(); } /** Returns the component's top-left position as a Point. */ Point<int> getPosition() const noexcept { return bounds.getPosition(); } /** Returns the y coordinate of the bottom edge of this component. This is a distance in pixels from the top edge of the component's parent. Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to its bounding box. */ int getBottom() const noexcept { return bounds.getBottom(); } /** Returns this component's bounding box. The rectangle returned is relative to the top-left of the component's parent. Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to its bounding box. */ const Rectangle<int>& getBounds() const noexcept { return bounds; } /** Returns the component's bounds, relative to its own origin. This is like getBounds(), but returns the rectangle in local coordinates, In practice, it'll return a rectangle with position (0, 0), and the same size as this component. */ Rectangle<int> getLocalBounds() const noexcept; /** Returns the area of this component's parent which this component covers. The returned area is relative to the parent's coordinate space. If the component has an affine transform specified, then the resulting area will be the smallest rectangle that fully covers the component's transformed bounding box. If this component has no parent, the return value will simply be the same as getBounds(). */ Rectangle<int> getBoundsInParent() const noexcept; /** Returns the region of this component that's not obscured by other, opaque components. The RectangleList that is returned represents the area of this component which isn't covered by opaque child components. If includeSiblings is true, it will also take into account any siblings that may be overlapping the component. */ void getVisibleArea (RectangleList& result, bool includeSiblings) const; //============================================================================== /** Returns this component's x coordinate relative the the screen's top-left origin. @see getX, localPointToGlobal */ int getScreenX() const; /** Returns this component's y coordinate relative the the screen's top-left origin. @see getY, localPointToGlobal */ int getScreenY() const; /** Returns the position of this component's top-left corner relative to the screen's top-left. @see getScreenBounds */ Point<int> getScreenPosition() const; /** Returns the bounds of this component, relative to the screen's top-left. @see getScreenPosition */ Rectangle<int> getScreenBounds() const; /** Converts a point to be relative to this component's coordinate space. This takes a point relative to a different component, and returns its position relative to this component. If the sourceComponent parameter is null, the source point is assumed to be a global screen coordinate. */ Point<int> getLocalPoint (const Component* sourceComponent, const Point<int>& pointRelativeToSourceComponent) const; /** Converts a rectangle to be relative to this component's coordinate space. This takes a rectangle that is relative to a different component, and returns its position relative to this component. If the sourceComponent parameter is null, the source rectangle is assumed to be a screen coordinate. If you've used setTransform() to apply one or more transforms to components, then the source rectangle may not actually be rectanglular when converted to the target space, so in that situation this will return the smallest rectangle that fully contains the transformed area. */ Rectangle<int> getLocalArea (const Component* sourceComponent, const Rectangle<int>& areaRelativeToSourceComponent) const; /** Converts a point relative to this component's top-left into a screen coordinate. @see getLocalPoint, localAreaToGlobal */ Point<int> localPointToGlobal (const Point<int>& localPoint) const; /** Converts a rectangle from this component's coordinate space to a screen coordinate. If you've used setTransform() to apply one or more transforms to components, then the source rectangle may not actually be rectanglular when converted to the target space, so in that situation this will return the smallest rectangle that fully contains the transformed area. @see getLocalPoint, localPointToGlobal */ Rectangle<int> localAreaToGlobal (const Rectangle<int>& localArea) const; //============================================================================== /** Moves the component to a new position. Changes the component's top-left position (without changing its size). The position is relative to the top-left of the component's parent. If the component actually moves, this method will make a synchronous call to moved(). Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to whatever bounds you set for it. @see setBounds, ComponentListener::componentMovedOrResized */ void setTopLeftPosition (int x, int y); /** Moves the component to a new position. Changes the component's top-left position (without changing its size). The position is relative to the top-left of the component's parent. If the component actually moves, this method will make a synchronous call to moved(). Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to whatever bounds you set for it. @see setBounds, ComponentListener::componentMovedOrResized */ void setTopLeftPosition (const Point<int>& newTopLeftPosition); /** Moves the component to a new position. Changes the position of the component's top-right corner (keeping it the same size). The position is relative to the top-left of the component's parent. If the component actually moves, this method will make a synchronous call to moved(). Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to whatever bounds you set for it. */ void setTopRightPosition (int x, int y); /** Changes the size of the component. A synchronous call to resized() will be occur if the size actually changes. Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to whatever bounds you set for it. */ void setSize (int newWidth, int newHeight); /** Changes the component's position and size. The coordinates are relative to the top-left of the component's parent, or relative to the origin of the screen is the component is on the desktop. If this method changes the component's top-left position, it will make a synchronous call to moved(). If it changes the size, it will also make a call to resized(). Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to whatever bounds you set for it. @see setTopLeftPosition, setSize, ComponentListener::componentMovedOrResized */ void setBounds (int x, int y, int width, int height); /** Changes the component's position and size. The coordinates are relative to the top-left of the component's parent, or relative to the origin of the screen is the component is on the desktop. If this method changes the component's top-left position, it will make a synchronous call to moved(). If it changes the size, it will also make a call to resized(). Note that if you've used setTransform() to apply a transform, then the component's bounds will no longer be a direct reflection of the position at which it appears within its parent, as the transform will be applied to whatever bounds you set for it. @see setBounds */ void setBounds (const Rectangle<int>& newBounds); /** Changes the component's position and size. This is similar to the other setBounds() methods, but uses RelativeRectangle::applyToComponent() to set the position, This uses a Component::Positioner to make sure that any dynamic expressions are used in the RelativeRectangle will be automatically re-applied to the component's bounds when the source values change. See RelativeRectangle::applyToComponent() for more details. When using relative expressions, the following symbols are available: - "left", "right", "top", "bottom" refer to the position of those edges in this component, so e.g. for a component whose width is always 100, you might set the right edge to the "left + 100". - "[id].left", "[id].right", "[id].top", "[id].bottom", "[id].width", "[id].height", where [id] is the identifier of one of this component's siblings. A component's identifier is set with Component::setComponentID(). So for example if you want your component to always be 50 pixels to the right of the one called "xyz", you could set your left edge to be "xyz.right + 50". - Instead of an [id], you can use the name "parent" to refer to this component's parent. Like any other component, these values are relative to their component's parent, so "parent.right" won't be very useful for positioning a component because it refers to a position with the parent's parent.. but "parent.width" can be used for setting positions relative to the parent's size. E.g. to make a 10x10 component which remains 1 pixel away from its parent's bottom-right, you could use "right - 10, bottom - 10, parent.width - 1, parent.height - 1". - The name of one of the parent component's markers can also be used as a symbol. For markers to be used, the parent component must implement its Component::getMarkers() method, and return at least one valid MarkerList. So if you want your component's top edge to be 10 pixels below the marker called "foobar", you'd set it to "foobar + 10". See the Expression class for details about the operators that are supported, but for example if you wanted to make your component remain centred within its parent with a size of 100, 100, you could express it as: @code myComp.setBounds (RelativeBounds ("parent.width / 2 - 50, parent.height / 2 - 50, left + 100, top + 100")); @endcode ..or an alternative way to achieve the same thing: @code myComp.setBounds (RelativeBounds ("right - 100, bottom - 100, parent.width / 2 + 50, parent.height / 2 + 50")); @endcode Or if you wanted a 100x100 component whose top edge is lined up to a marker called "topMarker" and which is positioned 50 pixels to the right of another component called "otherComp", you could write: @code myComp.setBounds (RelativeBounds ("otherComp.right + 50, topMarker, left + 100, top + 100")); @endcode Be careful not to make your coordinate expressions recursive, though, or exceptions and assertions will be thrown! @see setBounds, RelativeRectangle::applyToComponent(), Expression */ void setBounds (const RelativeRectangle& newBounds); /** Sets the component's bounds with an expression. The string is parsed as a RelativeRectangle expression - see the notes for Component::setBounds (const RelativeRectangle&) for more information. This method is basically just a shortcut for writing setBounds (RelativeRectangle ("...")) */ void setBounds (const String& newBoundsExpression); /** Changes the component's position and size in terms of fractions of its parent's size. The values are factors of the parent's size, so for example setBoundsRelative (0.2f, 0.2f, 0.5f, 0.5f) would give it half the width and height of the parent, with its top-left position 20% of the way across and down the parent. @see setBounds */ void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight); /** Changes the component's position and size based on the amount of space to leave around it. This will position the component within its parent, leaving the specified number of pixels around each edge. @see setBounds */ void setBoundsInset (const BorderSize<int>& borders); /** Positions the component within a given rectangle, keeping its proportions unchanged. If onlyReduceInSize is false, the component will be resized to fill as much of the rectangle as possible without changing its aspect ratio (the component's current size is used to determine its aspect ratio, so a zero-size component won't work here). If onlyReduceInSize is true, it will only be resized if it's too big to fit inside the rectangle. It will then be positioned within the rectangle according to the justification flags specified. @see setBounds */ void setBoundsToFit (int x, int y, int width, int height, const Justification& justification, bool onlyReduceInSize); /** Changes the position of the component's centre. Leaves the component's size unchanged, but sets the position of its centre relative to its parent's top-left. @see setBounds */ void setCentrePosition (int x, int y); /** Changes the position of the component's centre. Leaves the position unchanged, but positions its centre relative to its parent's size. E.g. setCentreRelative (0.5f, 0.5f) would place it centrally in its parent. */ void setCentreRelative (float x, float y); /** Changes the component's size and centres it within its parent. After changing the size, the component will be moved so that it's centred within its parent. If the component is on the desktop (or has no parent component), then it'll be centred within the main monitor area. */ void centreWithSize (int width, int height); //============================================================================== /** Sets a transform matrix to be applied to this component. If you set a transform for a component, the component's position will be warped by it, relative to the component's parent's top-left origin. This means that the values you pass into setBounds() will no longer reflect the actual area within the parent that the component covers, as the bounds will be transformed and the component will probably end up actually appearing somewhere else within its parent. When using transforms you need to be extremely careful when converting coordinates between the coordinate spaces of different components or the screen - you should always use getLocalPoint(), getLocalArea(), etc to do this, and never just manually add a component's position to a point in order to convert it between different components (but I'm sure you would never have done that anyway...). Currently, transforms are not supported for desktop windows, so the transform will be ignored if you put a component on the desktop. To remove a component's transform, simply pass AffineTransform::identity as the parameter to this method. */ void setTransform (const AffineTransform& transform); /** Returns the transform that is currently being applied to this component. For more details about transforms, see setTransform(). @see setTransform */ AffineTransform getTransform() const; /** Returns true if a non-identity transform is being applied to this component. For more details about transforms, see setTransform(). @see setTransform */ bool isTransformed() const noexcept; //============================================================================== /** Returns a proportion of the component's width. This is a handy equivalent of (getWidth() * proportion). */ int proportionOfWidth (float proportion) const noexcept; /** Returns a proportion of the component's height. This is a handy equivalent of (getHeight() * proportion). */ int proportionOfHeight (float proportion) const noexcept; /** Returns the width of the component's parent. If the component has no parent (i.e. if it's on the desktop), this will return the width of the screen. */ int getParentWidth() const noexcept; /** Returns the height of the component's parent. If the component has no parent (i.e. if it's on the desktop), this will return the height of the screen. */ int getParentHeight() const noexcept; /** Returns the screen coordinates of the monitor that contains this component. If there's only one monitor, this will return its size - if there are multiple monitors, it will return the area of the monitor that contains the component's centre. */ Rectangle<int> getParentMonitorArea() const; //============================================================================== /** Returns the number of child components that this component contains. @see getChildComponent, getIndexOfChildComponent */ int getNumChildComponents() const noexcept; /** Returns one of this component's child components, by it index. The component with index 0 is at the back of the z-order, the one at the front will have index (getNumChildComponents() - 1). If the index is out-of-range, this will return a null pointer. @see getNumChildComponents, getIndexOfChildComponent */ Component* getChildComponent (int index) const noexcept; /** Returns the index of this component in the list of child components. A value of 0 means it is first in the list (i.e. behind all other components). Higher values are further towards the front. Returns -1 if the component passed-in is not a child of this component. @see getNumChildComponents, getChildComponent, addChildComponent, toFront, toBack, toBehind */ int getIndexOfChildComponent (const Component* child) const noexcept; /** Looks for a child component with the specified ID. @see setComponentID, getComponentID */ Component* findChildWithID (const String& componentID) const noexcept; /** Adds a child component to this one. Adding a child component does not mean that the component will own or delete the child - it's your responsibility to delete the component. Note that it's safe to delete a component without first removing it from its parent - doing so will automatically remove it and send out the appropriate notifications before the deletion completes. If the child is already a child of this component, then no action will be taken, and its z-order will be left unchanged. @param child the new component to add. If the component passed-in is already the child of another component, it'll first be removed from it current parent. @param zOrder The index in the child-list at which this component should be inserted. A value of -1 will insert it in front of the others, 0 is the back. @see removeChildComponent, addAndMakeVisible, getChild, ComponentListener::componentChildrenChanged */ void addChildComponent (Component* child, int zOrder = -1); /** Adds a child component to this one, and also makes the child visible if it isn't. Quite a useful function, this is just the same as calling setVisible (true) on the child and then addChildComponent(). See addChildComponent() for more details. */ void addAndMakeVisible (Component* child, int zOrder = -1); /** Removes one of this component's child-components. If the child passed-in isn't actually a child of this component (either because it's invalid or is the child of a different parent), then no action is taken. Note that removing a child will not delete it! But it's ok to delete a component without first removing it - doing so will automatically remove it and send out the appropriate notifications before the deletion completes. @see addChildComponent, ComponentListener::componentChildrenChanged */ void removeChildComponent (Component* childToRemove); /** Removes one of this component's child-components by index. This will return a pointer to the component that was removed, or null if the index was out-of-range. Note that removing a child will not delete it! But it's ok to delete a component without first removing it - doing so will automatically remove it and send out the appropriate notifications before the deletion completes. @see addChildComponent, ComponentListener::componentChildrenChanged */ Component* removeChildComponent (int childIndexToRemove); /** Removes all this component's children. Note that this won't delete them! To do that, use deleteAllChildren() instead. */ void removeAllChildren(); /** Removes all this component's children, and deletes them. @see removeAllChildren */ void deleteAllChildren(); /** Returns the component which this component is inside. If this is the highest-level component or hasn't yet been added to a parent, this will return null. */ Component* getParentComponent() const noexcept { return parentComponent; } /** Searches the parent components for a component of a specified class. For example findParentComponentOfClass \<MyComp\>() would return the first parent component that can be dynamically cast to a MyComp, or will return 0 if none of the parents are suitable. N.B. The dummy parameter is needed to work around a VC6 compiler bug. */ template <class TargetClass> TargetClass* findParentComponentOfClass (TargetClass* const dummyParameter = nullptr) const { (void) dummyParameter; Component* p = parentComponent; while (p != nullptr) { TargetClass* target = dynamic_cast <TargetClass*> (p); if (target != nullptr) return target; p = p->parentComponent; } return nullptr; } /** Returns the highest-level component which contains this one or its parents. This will search upwards in the parent-hierarchy from this component, until it finds the highest one that doesn't have a parent (i.e. is on the desktop or not yet added to a parent), and will return that. */ Component* getTopLevelComponent() const noexcept; /** Checks whether a component is anywhere inside this component or its children. This will recursively check through this component's children to see if the given component is anywhere inside. */ bool isParentOf (const Component* possibleChild) const noexcept; //============================================================================== /** Called to indicate that the component's parents have changed. When a component is added or removed from its parent, this method will be called on all of its children (recursively - so all children of its children will also be called as well). Subclasses can override this if they need to react to this in some way. @see getParentComponent, isShowing, ComponentListener::componentParentHierarchyChanged */ virtual void parentHierarchyChanged(); /** Subclasses can use this callback to be told when children are added or removed. @see parentHierarchyChanged */ virtual void childrenChanged(); //============================================================================== /** Tests whether a given point inside the component. Overriding this method allows you to create components which only intercept mouse-clicks within a user-defined area. This is called to find out whether a particular x, y coordinate is considered to be inside the component or not, and is used by methods such as contains() and getComponentAt() to work out which component the mouse is clicked on. Components with custom shapes will probably want to override it to perform some more complex hit-testing. The default implementation of this method returns either true or false, depending on the value that was set by calling setInterceptsMouseClicks() (true is the default return value). Note that the hit-test region is not related to the opacity with which areas of a component are painted. Applications should never call hitTest() directly - instead use the contains() method, because this will also test for occlusion by the component's parent. Note that for components on the desktop, this method will be ignored, because it's not always possible to implement this behaviour on all platforms. @param x the x coordinate to test, relative to the left hand edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's width @param y the y coordinate to test, relative to the top edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's height @returns true if the click is considered to be inside the component @see setInterceptsMouseClicks, contains */ virtual bool hitTest (int x, int y); /** Changes the default return value for the hitTest() method. Setting this to false is an easy way to make a component pass its mouse-clicks through to the components behind it. When a component is created, the default setting for this is true. @param allowClicksOnThisComponent if true, hitTest() will always return true; if false, it will return false (or true for child components if allowClicksOnChildComponents is true) @param allowClicksOnChildComponents if this is true and allowClicksOnThisComponent is false, then child components can be clicked on as normal but clicks on this component pass straight through; if this is false and allowClicksOnThisComponent is false, then neither this component nor any child components can be clicked on @see hitTest, getInterceptsMouseClicks */ void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept; /** Retrieves the current state of the mouse-click interception flags. On return, the two parameters are set to the state used in the last call to setInterceptsMouseClicks(). @see setInterceptsMouseClicks */ void getInterceptsMouseClicks (bool& allowsClicksOnThisComponent, bool& allowsClicksOnChildComponents) const noexcept; /** Returns true if a given point lies within this component or one of its children. Never override this method! Use hitTest to create custom hit regions. @param localPoint the coordinate to test, relative to this component's top-left. @returns true if the point is within the component's hit-test area, but only if that part of the component isn't clipped by its parent component. Note that this won't take into account any overlapping sibling components which might be in the way - for that, see reallyContains() @see hitTest, reallyContains, getComponentAt */ bool contains (const Point<int>& localPoint); /** Returns true if a given point lies in this component, taking any overlapping siblings into account. @param localPoint the coordinate to test, relative to this component's top-left. @param returnTrueIfWithinAChild if the point actually lies within a child of this component, this determines whether that is counted as a hit. @see contains, getComponentAt */ bool reallyContains (const Point<int>& localPoint, bool returnTrueIfWithinAChild); /** Returns the component at a certain point within this one. @param x the x coordinate to test, relative to this component's left edge. @param y the y coordinate to test, relative to this component's top edge. @returns the component that is at this position - which may be 0, this component, or one of its children. Note that overlapping siblings that might actually be in the way are not taken into account by this method - to account for these, instead call getComponentAt on the top-level parent of this component. @see hitTest, contains, reallyContains */ Component* getComponentAt (int x, int y); /** Returns the component at a certain point within this one. @param position the coordinate to test, relative to this component's top-left. @returns the component that is at this position - which may be 0, this component, or one of its children. Note that overlapping siblings that might actually be in the way are not taken into account by this method - to account for these, instead call getComponentAt on the top-level parent of this component. @see hitTest, contains, reallyContains */ Component* getComponentAt (const Point<int>& position); //============================================================================== /** Marks the whole component as needing to be redrawn. Calling this will not do any repainting immediately, but will mark the component as 'dirty'. At some point in the near future the operating system will send a paint message, which will redraw all the dirty regions of all components. There's no guarantee about how soon after calling repaint() the redraw will actually happen, and other queued events may be delivered before a redraw is done. If the setBufferedToImage() method has been used to cause this component to use a buffer, the repaint() call will invalidate the component's buffer. To redraw just a subsection of the component rather than the whole thing, use the repaint (int, int, int, int) method. @see paint */ void repaint(); /** Marks a subsection of this component as needing to be redrawn. Calling this will not do any repainting immediately, but will mark the given region of the component as 'dirty'. At some point in the near future the operating system will send a paint message, which will redraw all the dirty regions of all components. There's no guarantee about how soon after calling repaint() the redraw will actually happen, and other queued events may be delivered before a redraw is done. The region that is passed in will be clipped to keep it within the bounds of this component. @see repaint() */ void repaint (int x, int y, int width, int height); /** Marks a subsection of this component as needing to be redrawn. Calling this will not do any repainting immediately, but will mark the given region of the component as 'dirty'. At some point in the near future the operating system will send a paint message, which will redraw all the dirty regions of all components. There's no guarantee about how soon after calling repaint() the redraw will actually happen, and other queued events may be delivered before a redraw is done. The region that is passed in will be clipped to keep it within the bounds of this component. @see repaint() */ void repaint (const Rectangle<int>& area); //============================================================================== /** Makes the component use an internal buffer to optimise its redrawing. Setting this flag to true will cause the component to allocate an internal buffer into which it paints itself, so that when asked to redraw itself, it can use this buffer rather than actually calling the paint() method. The buffer is kept until the repaint() method is called directly on this component (or until it is resized), when the image is invalidated and then redrawn the next time the component is painted. Note that only the drawing that happens within the component's paint() method is drawn into the buffer, it's child components are not buffered, and nor is the paintOverChildren() method. @see repaint, paint, createComponentSnapshot */ void setBufferedToImage (bool shouldBeBuffered); /** Generates a snapshot of part of this component. This will return a new Image, the size of the rectangle specified, containing a snapshot of the specified area of the component and all its children. The image may or may not have an alpha-channel, depending on whether the image is opaque or not. If the clipImageToComponentBounds parameter is true and the area is greater than the size of the component, it'll be clipped. If clipImageToComponentBounds is false then parts of the component beyond its bounds can be drawn. @see paintEntireComponent */ Image createComponentSnapshot (const Rectangle<int>& areaToGrab, bool clipImageToComponentBounds = true); /** Draws this component and all its subcomponents onto the specified graphics context. You should very rarely have to use this method, it's simply there in case you need to draw a component with a custom graphics context for some reason, e.g. for creating a snapshot of the component. It calls paint(), paintOverChildren() and recursively calls paintEntireComponent() on its children in order to render the entire tree. The graphics context may be left in an undefined state after this method returns, so you may need to reset it if you're going to use it again. If ignoreAlphaLevel is false, then the component will be drawn with the opacity level specified by getAlpha(); if ignoreAlphaLevel is true, then this will be ignored and an alpha of 1.0 will be used. */ void paintEntireComponent (Graphics& context, bool ignoreAlphaLevel); /** This allows you to indicate that this component doesn't require its graphics context to be clipped when it is being painted. Most people will never need to use this setting, but in situations where you have a very large number of simple components being rendered, and where they are guaranteed never to do any drawing beyond their own boundaries, setting this to true will reduce the overhead involved in clipping the graphics context that gets passed to the component's paint() callback. If you enable this mode, you'll need to make sure your paint method doesn't call anything like Graphics::fillAll(), and doesn't draw beyond the component's bounds, because that'll produce artifacts. Your component also can't have any child components that may be placed beyond its bounds. */ void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept; //============================================================================== /** Adds an effect filter to alter the component's appearance. When a component has an effect filter set, then this is applied to the results of its paint() method. There are a few preset effects, such as a drop-shadow or glow, but they can be user-defined as well. The effect that is passed in will not be deleted by the component - the caller must take care of deleting it. To remove an effect from a component, pass a null pointer in as the parameter. @see ImageEffectFilter, DropShadowEffect, GlowEffect */ void setComponentEffect (ImageEffectFilter* newEffect); /** Returns the current component effect. @see setComponentEffect */ ImageEffectFilter* getComponentEffect() const noexcept { return effect; } //============================================================================== /** Finds the appropriate look-and-feel to use for this component. If the component hasn't had a look-and-feel explicitly set, this will return the parent's look-and-feel, or just the default one if there's no parent. @see setLookAndFeel, lookAndFeelChanged */ LookAndFeel& getLookAndFeel() const noexcept; /** Sets the look and feel to use for this component. This will also change the look and feel for any child components that haven't had their look set explicitly. The object passed in will not be deleted by the component, so it's the caller's responsibility to manage it. It may be used at any time until this component has been deleted. Calling this method will also invoke the sendLookAndFeelChange() method. @see getLookAndFeel, lookAndFeelChanged */ void setLookAndFeel (LookAndFeel* newLookAndFeel); /** Called to let the component react to a change in the look-and-feel setting. When the look-and-feel is changed for a component, this will be called in all its child components, recursively. It can also be triggered manually by the sendLookAndFeelChange() method, in case an application uses a LookAndFeel class that might have changed internally. @see sendLookAndFeelChange, getLookAndFeel */ virtual void lookAndFeelChanged(); /** Calls the lookAndFeelChanged() method in this component and all its children. This will recurse through the children and their children, calling lookAndFeelChanged() on them all. @see lookAndFeelChanged */ void sendLookAndFeelChange(); //============================================================================== /** Indicates whether any parts of the component might be transparent. Components that always paint all of their contents with solid colour and thus completely cover any components behind them should use this method to tell the repaint system that they are opaque. This information is used to optimise drawing, because it means that objects underneath opaque windows don't need to be painted. By default, components are considered transparent, unless this is used to make it otherwise. @see isOpaque, getVisibleArea */ void setOpaque (bool shouldBeOpaque); /** Returns true if no parts of this component are transparent. @returns the value that was set by setOpaque, (the default being false) @see setOpaque */ bool isOpaque() const noexcept; //============================================================================== /** Indicates whether the component should be brought to the front when clicked. Setting this flag to true will cause the component to be brought to the front when the mouse is clicked somewhere inside it or its child components. Note that a top-level desktop window might still be brought to the front by the operating system when it's clicked, depending on how the OS works. By default this is set to false. @see setMouseClickGrabsKeyboardFocus */ void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept; /** Indicates whether the component should be brought to the front when clicked-on. @see setBroughtToFrontOnMouseClick */ bool isBroughtToFrontOnMouseClick() const noexcept; //============================================================================== // Keyboard focus methods /** Sets a flag to indicate whether this component needs keyboard focus or not. By default components aren't actually interested in gaining the focus, but this method can be used to turn this on. See the grabKeyboardFocus() method for details about the way a component is chosen to receive the focus. @see grabKeyboardFocus, getWantsKeyboardFocus */ void setWantsKeyboardFocus (bool wantsFocus) noexcept; /** Returns true if the component is interested in getting keyboard focus. This returns the flag set by setWantsKeyboardFocus(). The default setting is false. @see setWantsKeyboardFocus */ bool getWantsKeyboardFocus() const noexcept; //============================================================================== /** Chooses whether a click on this component automatically grabs the focus. By default this is set to true, but you might want a component which can be focused, but where you don't want the user to be able to affect it directly by clicking. */ void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus); /** Returns the last value set with setMouseClickGrabsKeyboardFocus(). See setMouseClickGrabsKeyboardFocus() for more info. */ bool getMouseClickGrabsKeyboardFocus() const noexcept; //============================================================================== /** Tries to give keyboard focus to this component. When the user clicks on a component or its grabKeyboardFocus() method is called, the following procedure is used to work out which component should get it: - if the component that was clicked on actually wants focus (as indicated by calling getWantsKeyboardFocus), it gets it. - if the component itself doesn't want focus, it will try to pass it on to whichever of its children is the default component, as determined by KeyboardFocusTraverser::getDefaultComponent() - if none of its children want focus at all, it will pass it up to its parent instead, unless it's a top-level component without a parent, in which case it just takes the focus itself. @see setWantsKeyboardFocus, getWantsKeyboardFocus, hasKeyboardFocus, getCurrentlyFocusedComponent, focusGained, focusLost, keyPressed, keyStateChanged */ void grabKeyboardFocus(); /** Returns true if this component currently has the keyboard focus. @param trueIfChildIsFocused if this is true, then the method returns true if either this component or any of its children (recursively) have the focus. If false, the method only returns true if this component has the focus. @see grabKeyboardFocus, setWantsKeyboardFocus, getCurrentlyFocusedComponent, focusGained, focusLost */ bool hasKeyboardFocus (bool trueIfChildIsFocused) const; /** Returns the component that currently has the keyboard focus. @returns the focused component, or null if nothing is focused. */ static Component* JUCE_CALLTYPE getCurrentlyFocusedComponent() noexcept; //============================================================================== /** Tries to move the keyboard focus to one of this component's siblings. This will try to move focus to either the next or previous component. (This is the method that is used when shifting focus by pressing the tab key). Components for which getWantsKeyboardFocus() returns false are not looked at. @param moveToNext if true, the focus will move forwards; if false, it will move backwards @see grabKeyboardFocus, setFocusContainer, setWantsKeyboardFocus */ void moveKeyboardFocusToSibling (bool moveToNext); /** Creates a KeyboardFocusTraverser object to use to determine the logic by which focus should be passed from this component. The default implementation of this method will return a default KeyboardFocusTraverser if this component is a focus container (as determined by the setFocusContainer() method). If the component isn't a focus container, then it will recursively ask its parents for a KeyboardFocusTraverser. If you overrride this to return a custom KeyboardFocusTraverser, then this component and all its sub-components will use the new object to make their focusing decisions. The method should return a new object, which the caller is required to delete when no longer needed. */ virtual KeyboardFocusTraverser* createFocusTraverser(); /** Returns the focus order of this component, if one has been specified. By default components don't have a focus order - in that case, this will return 0. Lower numbers indicate that the component will be earlier in the focus traversal order. To change the order, call setExplicitFocusOrder(). The focus order may be used by the KeyboardFocusTraverser class as part of its algorithm for deciding the order in which components should be traversed. See the KeyboardFocusTraverser class for more details on this. @see moveKeyboardFocusToSibling, createFocusTraverser, KeyboardFocusTraverser */ int getExplicitFocusOrder() const; /** Sets the index used in determining the order in which focusable components should be traversed. A value of 0 or less is taken to mean that no explicit order is wanted, and that traversal should use other factors, like the component's position. @see getExplicitFocusOrder, moveKeyboardFocusToSibling */ void setExplicitFocusOrder (int newFocusOrderIndex); /** Indicates whether this component is a parent for components that can have their focus traversed. This flag is used by the default implementation of the createFocusTraverser() method, which uses the flag to find the first parent component (of the currently focused one) which wants to be a focus container. So using this method to set the flag to 'true' causes this component to act as the top level within which focus is passed around. @see isFocusContainer, createFocusTraverser, moveKeyboardFocusToSibling */ void setFocusContainer (bool shouldBeFocusContainer) noexcept; /** Returns true if this component has been marked as a focus container. See setFocusContainer() for more details. @see setFocusContainer, moveKeyboardFocusToSibling, createFocusTraverser */ bool isFocusContainer() const noexcept; //============================================================================== /** Returns true if the component (and all its parents) are enabled. Components are enabled by default, and can be disabled with setEnabled(). Exactly what difference this makes to the component depends on the type. E.g. buttons and sliders will choose to draw themselves differently, etc. Note that if one of this component's parents is disabled, this will always return false, even if this component itself is enabled. @see setEnabled, enablementChanged */ bool isEnabled() const noexcept; /** Enables or disables this component. Disabling a component will also cause all of its child components to become disabled. Similarly, enabling a component which is inside a disabled parent component won't make any difference until the parent is re-enabled. @see isEnabled, enablementChanged */ void setEnabled (bool shouldBeEnabled); /** Callback to indicate that this component has been enabled or disabled. This can be triggered by one of the component's parent components being enabled or disabled, as well as changes to the component itself. The default implementation of this method does nothing; your class may wish to repaint itself or something when this happens. @see setEnabled, isEnabled */ virtual void enablementChanged(); /** Changes the transparency of this component. When painted, the entire component and all its children will be rendered with this as the overall opacity level, where 0 is completely invisible, and 1.0 is fully opaque (i.e. normal). @see getAlpha */ void setAlpha (float newAlpha); /** Returns the component's current transparancy level. See setAlpha() for more details. */ float getAlpha() const; //============================================================================== /** Changes the mouse cursor shape to use when the mouse is over this component. Note that the cursor set by this method can be overridden by the getMouseCursor method. @see MouseCursor */ void setMouseCursor (const MouseCursor& cursorType); /** Returns the mouse cursor shape to use when the mouse is over this component. The default implementation will return the cursor that was set by setCursor() but can be overridden for more specialised purposes, e.g. returning different cursors depending on the mouse position. @see MouseCursor */ virtual MouseCursor getMouseCursor(); /** Forces the current mouse cursor to be updated. If you're overriding the getMouseCursor() method to control which cursor is displayed, then this will only be checked each time the user moves the mouse. So if you want to force the system to check that the cursor being displayed is up-to-date (even if the mouse is just sitting there), call this method. (If you're changing the cursor using setMouseCursor(), you don't need to bother calling this). */ void updateMouseCursor() const; //============================================================================== /** Components can override this method to draw their content. The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn. Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this. If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In Juce (and almost all modern UI frameworks), you never redraw something synchronously. You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent(). @param g the graphics context that must be used to do the drawing operations. @see repaint, paintOverChildren, Graphics */ virtual void paint (Graphics& g); /** Components can override this method to draw over the top of their children. For most drawing operations, it's better to use the normal paint() method, but if you need to overlay something on top of the children, this can be used. @see paint, Graphics */ virtual void paintOverChildren (Graphics& g); //============================================================================== /** Called when the mouse moves inside this component. If the mouse button isn't pressed and the mouse moves over a component, this will be called to let the component react to this. A component will always get a mouseEnter callback before a mouseMove. @param e details about the position and status of the mouse event @see mouseEnter, mouseExit, mouseDrag, contains */ virtual void mouseMove (const MouseEvent& e); /** Called when the mouse first enters this component. If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this. When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released. If you're writing a component that needs to repaint itself when the mouse enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() method. @param e details about the position and status of the mouse event @see mouseExit, mouseDrag, mouseMove, contains */ virtual void mouseEnter (const MouseEvent& e); /** Called when the mouse moves out of this component. This will be called when the mouse moves off the edge of this component. If the mouse button was pressed, and it was then dragged off the edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback. If you're writing a component that needs to repaint itself when the mouse enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() method. @param e details about the position and status of the mouse event @see mouseEnter, mouseDrag, mouseMove, contains */ virtual void mouseExit (const MouseEvent& e); /** Called when a mouse button is pressed while it's over this component. The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time. Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released. @param e details about the position and status of the mouse event @see mouseUp, mouseDrag, mouseDoubleClick, contains */ virtual void mouseDown (const MouseEvent& e); /** Called when the mouse is moved while a button is held down. When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds. If you want to be able to drag things off the edge of a component and have the component scroll when you get to the edges, the beginDragAutoRepeat() method might be useful. @param e details about the position and status of the mouse event @see mouseDown, mouseUp, mouseMove, contains, beginDragAutoRepeat */ virtual void mouseDrag (const MouseEvent& e); /** Called when a mouse button is released. A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released. The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released. @param e details about the position and status of the mouse event @see mouseDown, mouseDrag, mouseDoubleClick, contains */ virtual void mouseUp (const MouseEvent& e); /** Called when a mouse button has been double-clicked in this component. The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time. For altering the time limit used to detect double-clicks, see MouseEvent::setDoubleClickTimeout. @param e details about the position and status of the mouse event @see mouseDown, mouseUp, MouseEvent::setDoubleClickTimeout, MouseEvent::getDoubleClickTimeout */ virtual void mouseDoubleClick (const MouseEvent& e); /** Called when the mouse-wheel is moved. This callback is sent to the component that the mouse is over when the wheel is moved. If not overridden, the component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them. @param e details about the position and status of the mouse event @param wheelIncrementX the speed and direction of the horizontal scroll-wheel - a positive value means the wheel has been pushed to the right, negative means it was pushed to the left @param wheelIncrementY the speed and direction of the vertical scroll-wheel - a positive value means the wheel has been pushed upwards, negative means it was pushed downwards */ virtual void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); //============================================================================== /** Ensures that a non-stop stream of mouse-drag events will be sent during the current mouse-drag operation. This allows you to make sure that mouseDrag() events are sent continuously, even when the mouse isn't moving. This can be useful for things like auto-scrolling components when the mouse is near an edge. Call this method during a mouseDown() or mouseDrag() callback, specifying the minimum interval between consecutive mouse drag callbacks. The callbacks will continue until the mouse is released, and then the interval will be reset, so you need to make sure it's called every time you begin a drag event. Passing an interval of 0 or less will cancel the auto-repeat. @see mouseDrag, Desktop::beginDragAutoRepeat */ static void beginDragAutoRepeat (int millisecondsBetweenCallbacks); /** Causes automatic repaints when the mouse enters or exits this component. If turned on, then when the mouse enters/exits, or when the button is pressed/released on the component, it will trigger a repaint. This is handy for things like buttons that need to draw themselves differently when the mouse moves over them, and it avoids having to override all the different mouse callbacks and call repaint(). @see mouseEnter, mouseExit, mouseDown, mouseUp */ void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept; /** Registers a listener to be told when mouse events occur in this component. If you need to get informed about mouse events in a component but can't or don't want to override its methods, you can attach any number of listeners to the component, and these will get told about the events in addition to the component's own callbacks being called. Note that a MouseListener can also be attached to more than one component. @param newListener the listener to register @param wantsEventsForAllNestedChildComponents if true, the listener will receive callbacks for events that happen to any child component within this component, including deeply-nested child components. If false, it will only be told about events that this component handles. @see MouseListener, removeMouseListener */ void addMouseListener (MouseListener* newListener, bool wantsEventsForAllNestedChildComponents); /** Deregisters a mouse listener. @see addMouseListener, MouseListener */ void removeMouseListener (MouseListener* listenerToRemove); //============================================================================== /** Adds a listener that wants to hear about keypresses that this component receives. The listeners that are registered with a component are called by its keyPressed() or keyStateChanged() methods (assuming these haven't been overridden to do something else). If you add an object as a key listener, be careful to remove it when the object is deleted, or the component will be left with a dangling pointer. @see keyPressed, keyStateChanged, removeKeyListener */ void addKeyListener (KeyListener* newListener); /** Removes a previously-registered key listener. @see addKeyListener */ void removeKeyListener (KeyListener* listenerToRemove); /** Called when a key is pressed. When a key is pressed, the component that has the keyboard focus will have this method called. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this. If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, the key will be passed to any KeyListeners that have been registered with this component. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on. The default implementation of this method does nothing and returns false. @see keyStateChanged, getCurrentlyFocusedComponent, addKeyListener */ virtual bool keyPressed (const KeyPress& key); /** Called when a key is pressed or released. Whenever a key on the keyboard is pressed or released (including modifier keys like shift and ctrl), this method will be called on the component that currently has the keyboard focus. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this. If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, then any KeyListeners that have been registered with this component will have their keyStateChanged methods called. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on. The default implementation of this method does nothing and returns false. To find out which keys are up or down at any time, see the KeyPress::isKeyCurrentlyDown() method. @param isKeyDown true if a key has been pressed; false if it has been released @see keyPressed, KeyPress, getCurrentlyFocusedComponent, addKeyListener */ virtual bool keyStateChanged (bool isKeyDown); /** Called when a modifier key is pressed or released. Whenever the shift, control, alt or command keys are pressed or released, this method will be called on the component that currently has the keyboard focus. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this. The default implementation of this method actually calls its parent's modifierKeysChanged method, so that focused components which aren't interested in this will give their parents a chance to act on the event instead. @see keyStateChanged, ModifierKeys */ virtual void modifierKeysChanged (const ModifierKeys& modifiers); //============================================================================== /** Enumeration used by the focusChanged() and focusLost() methods. */ enum FocusChangeType { focusChangedByMouseClick, /**< Means that the user clicked the mouse to change focus. */ focusChangedByTabKey, /**< Means that the user pressed the tab key to move the focus. */ focusChangedDirectly /**< Means that the focus was changed by a call to grabKeyboardFocus(). */ }; /** Called to indicate that this component has just acquired the keyboard focus. @see focusLost, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus */ virtual void focusGained (FocusChangeType cause); /** Called to indicate that this component has just lost the keyboard focus. @see focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus */ virtual void focusLost (FocusChangeType cause); /** Called to indicate that one of this component's children has been focused or unfocused. Essentially this means that the return value of a call to hasKeyboardFocus (true) has changed. It happens when focus moves from one of this component's children (at any depth) to a component that isn't contained in this one, (or vice-versa). @see focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus */ virtual void focusOfChildComponentChanged (FocusChangeType cause); //============================================================================== /** Returns true if the mouse is currently over this component. If the mouse isn't over the component, this will return false, even if the mouse is currently being dragged - so you can use this in your mouseDrag method to find out whether it's really over the component or not. Note that when the mouse button is being held down, then the only component for which this method will return true is the one that was originally clicked on. If includeChildren is true, then this will also return true if the mouse is over any of the component's children (recursively) as well as the component itself. @see isMouseButtonDown. isMouseOverOrDragging, mouseDrag */ bool isMouseOver (bool includeChildren = false) const; /** Returns true if the mouse button is currently held down in this component. Note that this is a test to see whether the mouse is being pressed in this component, so it'll return false if called on component A when the mouse is actually being dragged in component B. @see isMouseButtonDownAnywhere, isMouseOver, isMouseOverOrDragging */ bool isMouseButtonDown() const; /** True if the mouse is over this component, or if it's being dragged in this component. This is a handy equivalent to (isMouseOver() || isMouseButtonDown()). @see isMouseOver, isMouseButtonDown, isMouseButtonDownAnywhere */ bool isMouseOverOrDragging() const; /** Returns true if a mouse button is currently down. Unlike isMouseButtonDown, this will test the current state of the buttons without regard to which component (if any) it has been pressed in. @see isMouseButtonDown, ModifierKeys */ static bool JUCE_CALLTYPE isMouseButtonDownAnywhere() noexcept; /** Returns the mouse's current position, relative to this component. The return value is relative to the component's top-left corner. */ Point<int> getMouseXYRelative() const; //============================================================================== /** Called when this component's size has been changed. A component can implement this method to do things such as laying out its child components when its width or height changes. The method is called synchronously as a result of the setBounds or setSize methods, so repeatedly changing a components size will repeatedly call its resized method (unlike things like repainting, where multiple calls to repaint are coalesced together). If the component is a top-level window on the desktop, its size could also be changed by operating-system factors beyond the application's control. @see moved, setSize */ virtual void resized(); /** Called when this component's position has been changed. This is called when the position relative to its parent changes, not when its absolute position on the screen changes (so it won't be called for all child components when a parent component is moved). The method is called synchronously as a result of the setBounds, setTopLeftPosition or any of the other repositioning methods, and like resized(), it will be called each time those methods are called. If the component is a top-level window on the desktop, its position could also be changed by operating-system factors beyond the application's control. @see resized, setBounds */ virtual void moved(); /** Called when one of this component's children is moved or resized. If the parent wants to know about changes to its immediate children (not to children of its children), this is the method to override. @see moved, resized, parentSizeChanged */ virtual void childBoundsChanged (Component* child); /** Called when this component's immediate parent has been resized. If the component is a top-level window, this indicates that the screen size has changed. @see childBoundsChanged, moved, resized */ virtual void parentSizeChanged(); /** Called when this component has been moved to the front of its siblings. The component may have been brought to the front by the toFront() method, or by the operating system if it's a top-level window. @see toFront */ virtual void broughtToFront(); /** Adds a listener to be told about changes to the component hierarchy or position. Component listeners get called when this component's size, position or children change - see the ComponentListener class for more details. @param newListener the listener to register - if this is already registered, it will be ignored. @see ComponentListener, removeComponentListener */ void addComponentListener (ComponentListener* newListener); /** Removes a component listener. @see addComponentListener */ void removeComponentListener (ComponentListener* listenerToRemove); //============================================================================== /** Dispatches a numbered message to this component. This is a quick and cheap way of allowing simple asynchronous messages to be sent to components. It's also safe, because if the component that you send the message to is a null or dangling pointer, this won't cause an error. The command ID is later delivered to the component's handleCommandMessage() method by the application's message queue. @see handleCommandMessage */ void postCommandMessage (int commandId); /** Called to handle a command that was sent by postCommandMessage(). This is called by the message thread when a command message arrives, and the component can override this method to process it in any way it needs to. @see postCommandMessage */ virtual void handleCommandMessage (int commandId); //============================================================================== /** Runs a component modally, waiting until the loop terminates. This method first makes the component visible, brings it to the front and gives it the keyboard focus. It then runs a loop, dispatching messages from the system message queue, but blocking all mouse or keyboard messages from reaching any components other than this one and its children. This loop continues until the component's exitModalState() method is called (or the component is deleted), and then this method returns, returning the value passed into exitModalState(). @see enterModalState, exitModalState, isCurrentlyModal, getCurrentlyModalComponent, isCurrentlyBlockedByAnotherModalComponent, ModalComponentManager */ #if JUCE_MODAL_LOOPS_PERMITTED int runModalLoop(); #endif /** Puts the component into a modal state. This makes the component modal, so that messages are blocked from reaching any components other than this one and its children, but unlike runModalLoop(), this method returns immediately. If takeKeyboardFocus is true, the component will use grabKeyboardFocus() to get the focus, which is usually what you'll want it to do. If not, it will leave the focus unchanged. The callback is an optional object which will receive a callback when the modal component loses its modal status, either by being hidden or when exitModalState() is called. If you pass an object in here, the system will take care of deleting it later, after making the callback If deleteWhenDismissed is true, then when it is dismissed, the component will be deleted and then the callback will be called. (This will safely handle the situation where the component is deleted before its exitModalState() method is called). @see exitModalState, runModalLoop, ModalComponentManager::attachCallback */ void enterModalState (bool takeKeyboardFocus = true, ModalComponentManager::Callback* callback = nullptr, bool deleteWhenDismissed = false); /** Ends a component's modal state. If this component is currently modal, this will turn of its modalness, and return a value to the runModalLoop() method that might have be running its modal loop. @see runModalLoop, enterModalState, isCurrentlyModal */ void exitModalState (int returnValue); /** Returns true if this component is the modal one. It's possible to have nested modal components, e.g. a pop-up dialog box that launches another pop-up, but this will only return true for the one at the top of the stack. @see getCurrentlyModalComponent */ bool isCurrentlyModal() const noexcept; /** Returns the number of components that are currently in a modal state. @see getCurrentlyModalComponent */ static int JUCE_CALLTYPE getNumCurrentlyModalComponents() noexcept; /** Returns one of the components that are currently modal. The index specifies which of the possible modal components to return. The order of the components in this list is the reverse of the order in which they became modal - so the component at index 0 is always the active component, and the others are progressively earlier ones that are themselves now blocked by later ones. @returns the modal component, or null if no components are modal (or if the index is out of range) @see getNumCurrentlyModalComponents, runModalLoop, isCurrentlyModal */ static Component* JUCE_CALLTYPE getCurrentlyModalComponent (int index = 0) noexcept; /** Checks whether there's a modal component somewhere that's stopping this one from receiving messages. If there is a modal component, its canModalEventBeSentToComponent() method will be called to see if it will still allow this component to receive events. @see runModalLoop, getCurrentlyModalComponent */ bool isCurrentlyBlockedByAnotherModalComponent() const; /** When a component is modal, this callback allows it to choose which other components can still receive events. When a modal component is active and the user clicks on a non-modal component, this method is called on the modal component, and if it returns true, the event is allowed to reach its target. If it returns false, the event is blocked and the inputAttemptWhenModal() callback is made. It called by the isCurrentlyBlockedByAnotherModalComponent() method. The default implementation just returns false in all cases. */ virtual bool canModalEventBeSentToComponent (const Component* targetComponent); /** Called when the user tries to click on a component that is blocked by another modal component. When a component is modal and the user clicks on one of the other components, the modal component will receive this callback. The default implementation of this method will play a beep, and bring the currently modal component to the front, but it can be overridden to do other tasks. @see isCurrentlyBlockedByAnotherModalComponent, canModalEventBeSentToComponent */ virtual void inputAttemptWhenModal(); //============================================================================== /** Returns the set of properties that belong to this component. Each component has a NamedValueSet object which you can use to attach arbitrary items of data to it. */ NamedValueSet& getProperties() noexcept { return properties; } /** Returns the set of properties that belong to this component. Each component has a NamedValueSet object which you can use to attach arbitrary items of data to it. */ const NamedValueSet& getProperties() const noexcept { return properties; } //============================================================================== /** Looks for a colour that has been registered with the given colour ID number. If a colour has been set for this ID number using setColour(), then it is returned. If none has been set, the method will try calling the component's LookAndFeel class's findColour() method. If none has been registered with the look-and-feel either, it will just return black. The colour IDs for various purposes are stored as enums in the components that they are relevent to - for an example, see Slider::ColourIds, Label::ColourIds, TextEditor::ColourIds, TreeView::ColourIds, etc. @see setColour, isColourSpecified, colourChanged, LookAndFeel::findColour, LookAndFeel::setColour */ const Colour findColour (int colourId, bool inheritFromParent = false) const; /** Registers a colour to be used for a particular purpose. Changing a colour will cause a synchronous callback to the colourChanged() method, which your component can override if it needs to do something when colours are altered. For more details about colour IDs, see the comments for findColour(). @see findColour, isColourSpecified, colourChanged, LookAndFeel::findColour, LookAndFeel::setColour */ void setColour (int colourId, const Colour& colour); /** If a colour has been set with setColour(), this will remove it. This allows you to make a colour revert to its default state. */ void removeColour (int colourId); /** Returns true if the specified colour ID has been explicitly set for this component using the setColour() method. */ bool isColourSpecified (int colourId) const; /** This looks for any colours that have been specified for this component, and copies them to the specified target component. */ void copyAllExplicitColoursTo (Component& target) const; /** This method is called when a colour is changed by the setColour() method. @see setColour, findColour */ virtual void colourChanged(); //============================================================================== /** Components can implement this method to provide a MarkerList. The default implementation of this method returns 0, but you can override it to return a pointer to the component's marker list. If xAxis is true, it should return the X marker list; if false, it should return the Y markers. */ virtual MarkerList* getMarkers (bool xAxis); //============================================================================== /** Returns the underlying native window handle for this component. This is platform-dependent and strictly for power-users only! */ void* getWindowHandle() const; //============================================================================== /** Holds a pointer to some type of Component, which automatically becomes null if the component is deleted. If you're using a component which may be deleted by another event that's outside of your control, use a SafePointer instead of a normal pointer to refer to it, and you can test whether it's null before using it to see if something has deleted it. The ComponentType typedef must be Component, or some subclass of Component. You may also want to use a WeakReference<Component> object for the same purpose. */ template <class ComponentType> class SafePointer { public: /** Creates a null SafePointer. */ SafePointer() noexcept {} /** Creates a SafePointer that points at the given component. */ SafePointer (ComponentType* const component) : weakRef (component) {} /** Creates a copy of another SafePointer. */ SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {} /** Copies another pointer to this one. */ SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; } /** Copies another pointer to this one. */ SafePointer& operator= (ComponentType* const newComponent) { weakRef = newComponent; return *this; } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ ComponentType* getComponent() const noexcept { return dynamic_cast <ComponentType*> (weakRef.get()); } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ operator ComponentType*() const noexcept { return getComponent(); } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ ComponentType* operator->() noexcept { return getComponent(); } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ const ComponentType* operator->() const noexcept { return getComponent(); } /** If the component is valid, this deletes it and sets this pointer to null. */ void deleteAndZero() { delete getComponent(); jassert (getComponent() == nullptr); } bool operator== (ComponentType* component) const noexcept { return weakRef == component; } bool operator!= (ComponentType* component) const noexcept { return weakRef != component; } private: WeakReference<Component> weakRef; }; //============================================================================== /** A class to keep an eye on a component and check for it being deleted. This is designed for use with the ListenerList::callChecked() methods, to allow the list iterator to stop cleanly if the component is deleted by a listener callback while the list is still being iterated. */ class JUCE_API BailOutChecker { public: /** Creates a checker that watches one component. */ BailOutChecker (Component* component); /** Returns true if either of the two components have been deleted since this object was created. */ bool shouldBailOut() const noexcept; private: const WeakReference<Component> safePointer; JUCE_DECLARE_NON_COPYABLE (BailOutChecker); }; //============================================================================== /** Base class for objects that can be used to automatically position a component according to some kind of algorithm. The component class simply holds onto a reference to a Positioner, but doesn't actually do anything with it - all the functionality must be implemented by the positioner itself (e.g. it might choose to watch some kind of value and move the component when the value changes). */ class JUCE_API Positioner { public: /** Creates a Positioner which can control the specified component. */ explicit Positioner (Component& component) noexcept; /** Destructor. */ virtual ~Positioner() {} /** Returns the component that this positioner controls. */ Component& getComponent() const noexcept { return component; } /** Attempts to set the component's position to the given rectangle. Unlike simply calling Component::setBounds(), this may involve the positioner being smart enough to adjust itself to fit the new bounds, e.g. a RelativeRectangle's positioner may try to reverse the expressions used to make them fit these new coordinates. */ virtual void applyNewBounds (const Rectangle<int>& newBounds) = 0; private: Component& component; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Positioner); }; /** Returns the Positioner object that has been set for this component. @see setPositioner() */ Positioner* getPositioner() const noexcept; /** Sets a new Positioner object for this component. If there's currently another positioner set, it will be deleted. The object that is passed in will be deleted automatically by this component when it's no longer required. Pass a null pointer to clear the current positioner. @see getPositioner() */ void setPositioner (Positioner* newPositioner); //============================================================================== #ifndef DOXYGEN // These methods are deprecated - use localPointToGlobal, getLocalPoint, getLocalPoint, etc instead. JUCE_DEPRECATED (const Point<int> relativePositionToGlobal (const Point<int>&) const); JUCE_DEPRECATED (const Point<int> globalPositionToRelative (const Point<int>&) const); JUCE_DEPRECATED (const Point<int> relativePositionToOtherComponent (const Component*, const Point<int>&) const); #endif private: //============================================================================== friend class ComponentPeer; friend class MouseInputSource; friend class MouseInputSourceInternal; #ifndef DOXYGEN static Component* currentlyFocusedComponent; //============================================================================== String componentName, componentID; Component* parentComponent; Rectangle<int> bounds; ScopedPointer <Positioner> positioner; ScopedPointer <AffineTransform> affineTransform; Array <Component*> childComponentList; LookAndFeel* lookAndFeel; MouseCursor cursor; ImageEffectFilter* effect; Image bufferedImage; class MouseListenerList; friend class MouseListenerList; friend class ScopedPointer <MouseListenerList>; ScopedPointer <MouseListenerList> mouseListeners; ScopedPointer <Array <KeyListener*> > keyListeners; ListenerList <ComponentListener> componentListeners; NamedValueSet properties; friend class WeakReference<Component>; WeakReference<Component>::Master masterReference; struct ComponentFlags { bool hasHeavyweightPeerFlag : 1; bool visibleFlag : 1; bool opaqueFlag : 1; bool ignoresMouseClicksFlag : 1; bool allowChildMouseClicksFlag : 1; bool wantsFocusFlag : 1; bool isFocusContainerFlag : 1; bool dontFocusOnMouseClickFlag : 1; bool alwaysOnTopFlag : 1; bool bufferToImageFlag : 1; bool bringToFrontOnClickFlag : 1; bool repaintOnMouseActivityFlag : 1; bool currentlyModalFlag : 1; bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; bool dontClipGraphicsFlag : 1; #if JUCE_DEBUG bool isInsidePaintCall : 1; #endif }; union { uint32 componentFlags; ComponentFlags flags; }; uint8 componentTransparency; //============================================================================== void internalMouseEnter (MouseInputSource&, const Point<int>&, const Time&); void internalMouseExit (MouseInputSource&, const Point<int>&, const Time&); void internalMouseDown (MouseInputSource&, const Point<int>&, const Time&); void internalMouseUp (MouseInputSource&, const Point<int>&, const Time&, const ModifierKeys& oldModifiers); void internalMouseDrag (MouseInputSource&, const Point<int>&, const Time&); void internalMouseMove (MouseInputSource&, const Point<int>&, const Time&); void internalMouseWheel (MouseInputSource&, const Point<int>&, const Time&, float amountX, float amountY); void internalBroughtToFront(); void internalFocusGain (const FocusChangeType, const WeakReference<Component>&); void internalFocusGain (const FocusChangeType); void internalFocusLoss (const FocusChangeType); void internalChildFocusChange (FocusChangeType, const WeakReference<Component>&); void internalModalInputAttempt(); void internalModifierKeysChanged(); void internalChildrenChanged(); void internalHierarchyChanged(); Component* removeChildComponent (int index, bool sendParentEvents, bool sendChildEvents); void moveChildInternal (int sourceIndex, int destIndex); void paintComponentAndChildren (Graphics&); void paintComponent (Graphics&); void paintWithinParentContext (Graphics&); void sendMovedResizedMessages (bool wasMoved, bool wasResized); void repaintParent(); void sendFakeMouseMove() const; void takeKeyboardFocus (const FocusChangeType); void grabFocusInternal (const FocusChangeType, bool canTryParent = true); static void giveAwayFocus (bool sendFocusLossEvent); void sendEnablementChangeMessage(); void sendVisibilityChangeMessage(); class ComponentHelpers; friend class ComponentHelpers; /* Components aren't allowed to have copy constructors, as this would mess up parent hierarchies. You might need to give your subclasses a private dummy constructor to avoid compiler warnings. */ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Component); //============================================================================== #if JUCE_CATCH_DEPRECATED_CODE_MISUSE // This is included here just to cause a compile error if your code is still handling // drag-and-drop with this method. If so, just update it to use the new FileDragAndDropTarget // class, which is easy (just make your class inherit from FileDragAndDropTarget, and // implement its methods instead of this Component method). virtual void filesDropped (const StringArray&, int, int) {} // This is included here to cause an error if you use or overload it - it has been deprecated in // favour of contains (const Point<int>&) void contains (int, int); #endif protected: //============================================================================== /** @internal */ virtual void internalRepaint (int x, int y, int w, int h); /** @internal */ virtual ComponentPeer* createNewPeer (int styleFlags, void* nativeWindowToAttachTo); #endif }; #endif // __JUCE_COMPONENT_JUCEHEADER__
[ [ [ 1, 2363 ] ] ]
f6a1fa858f57930676f3a4723e7f51bcf14645ac
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Util/xabsl/compiler/vsyabsl/stdservice_.cpp
7e66e8eb95f2242ebd028484a2966f1a869e8916
[ "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
43,377
cpp
/*************************************************************************** Copyright (c) Microsoft Corporation, All rights reserved. This code sample is provided "AS IS" without warranty of any kind, it is not recommended for use in a production environment. ***************************************************************************/ #include "common.h" #include "languagedef.h" #include "stdservice.h" #include "dllmain.h" #include <tchar.h> #define CHECK(r) ((r) == ReasonCheck) #define SELECT(r) ((r) >= ReasonMemberSelect && (r) <= ReasonMethodTip) #define METHODTIP(r) ((r) == ReasonMethodTip || (r) == ReasonQuickInfo) #define MATCHBRACES(r) ((r) == ReasonHighlightBraces || (r) == ReasonMatchBraces) #define AUTOS(r) ((r) == ReasonAutos) #define CODESPAN(r) ((r) == ReasonCodeSpan) #define DOUBLE_BYTE_BUF_SIZE 10 //--------------------------------------------------------- // //--------------------------------------------------------- int yywrap() { return 1; } void yyerror( const char* message ) { return; } global Service* g_service = NULL; /*--------------------------------------------------------- BSTR ---------------------------------------------------------*/ BSTR BstrNew( const char* s ) { static OLECHAR buffer[MaxStr+1]; if (s == NULL) return NULL; size_t convertedSize; size_t inputSize = strlen(s); if (0 != mbstowcs_s(&convertedSize, buffer, MaxStr+1, s, inputSize)) return NULL; return SysAllocString( buffer ); } BSTR BstrNewFormat( const char* s ) { if (s == NULL) return SysAllocString( L"" ); if (s[0] == 0) return SysAllocString( L"" ); return BstrNew(s); } /*--------------------------------------------------------- ColorizerState ---------------------------------------------------------*/ LexBuffer::LexBuffer( int size ) : cstate(0) { yy_buffer = yy_create_buffer( NULL, size ); prevBuffer= NULL; input = NULL; inputStart= NULL; inputLim = NULL; sink = NULL; reason = ReasonColorize; token = NULL; location.initialize(); yylloc.initialize(); yylval.initialize(); service = NULL; } LexBuffer::~LexBuffer() { yy_delete_buffer( yy_buffer ); RELEASE(sink); } //--------------------------------------------------------- // ColorizerState //--------------------------------------------------------- const Bits MaxBitsValid = sizeof(int) * 8; ColorizerState::ColorizerState() { m_bitsValid = 0; m_state = 0; } ColorizerState::ColorizerState( in State state ) { reset(state); } void ColorizerState::reset( in State state ) { m_bitsValid = MaxBitsValid; m_state = state; } State ColorizerState::getState() { return m_state; } State ColorizerState::load( in Bits bits ) { ASSERT( bits <= m_bitsValid ); State mask = (1 << bits) - 1; State result = m_state & mask; m_state >>= bits; m_bitsValid -= bits; return result; } void ColorizerState::save( in State state, in Bits bits ) { ASSERT( bits + m_bitsValid <= MaxBitsValid ); State mask = (1 << bits) - 1; ASSERT( state <= mask ); m_state <<= bits; m_state |= state; m_bitsValid += bits; }; //--------------------------------------------------------- // Location //--------------------------------------------------------- local inline void updatePosition( in char c, inout int& row, inout int& idx ) { if (c == '\n') { idx = 0; row += 1; } else //if (c != '\r') { idx += 1; } } Location::Location() { initialize(); } Location::Location( in const Location& loc1, const Location& loc2 ) { startRow = loc1.startRow; startIdx = loc1.startIdx; endRow = loc2.endRow; endIdx = loc2.endIdx; text = loc1.text; textOfs = loc1.textOfs; textLen = (loc2.textOfs - loc1.textOfs) + loc2.textLen; token = 0; } final void Location::initialize(void) { startRow = endRow = 0; startIdx = endIdx = 0; text = NULL; textLen = 0; textOfs = 0; token = 0; } final void Location::update( in int _token, in const char* _text, in int _textLen ) { textOfs += textLen; startRow = endRow; startIdx = endIdx; token = _token; text = _text; textLen = _textLen; for (int i = 0; i < textLen; i++) { updatePosition( text[i], endRow, endIdx ); }; } //--------------------------------------------------------- // IBabelService: Init/Done //--------------------------------------------------------- STDMETHODIMP StdService::Init( in LCID lcid, in long reserved ) { return S_OK; } STDMETHODIMP StdService::Done() { return S_OK; } int endsWith(const char* s1, const char* s2) { int l1 = strlen(s1); int l2 = strlen(s2); if(l2 == 0) return 1; if(l1 < l2) return 0; return strncmp(s1 + l1 - l2 , s2, l2) == 0; } //--------------------------------------------------------- // IBabelService: ParseSource //--------------------------------------------------------- STDMETHODIMP StdService::ParseSource( in BSTR source, in IParseSink* sink, in ParseReason reason, in long reserved, out IScope** scope ) { TRACE(L"StdService::ParseSource"); enterParser(); { switchBuffer( m_parserBuffer, 0, (source ? SysStringLen(source) : 0), source, sink, reason ); if (scope) *scope = NULL; char filePath[1024]; getFileName(filePath, 1024); /* FILE * pFile; pFile = fopen ("c:/log1.txt","wt"); if (pFile!=NULL) { fputs (filePath,pFile); fclose (pFile); }*/ if(endsWith(filePath, "yabsl.api")) { yyparse(); } else { IScope* scope = NULL; char temp[1024]; char apiFilename[1024]; DWORD dwBufLen = 1024; HKEY hKey; LONG lRet; RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\VisualStudio\\8.0"), 0, KEY_QUERY_VALUE, &hKey); lRet = RegQueryValueEx(hKey, TEXT("InstallDir"), NULL, NULL, (LPBYTE)temp, &dwBufLen); CharToOem((LPCTSTR)temp, (LPSTR)apiFilename); strcat_s(apiFilename, 1024 ,"yabsl.api"); //loadScope does IParseSink::GetPackage and IBabelPackage::LoadScope. loadScope( apiFilename, &scope ); if (scope != NULL && m_buffer->sink != NULL && CHECK(m_buffer->reason)) { enterSink(); { m_buffer->sink->AddExtern( 1, 0, 1, 0, scope ); } leaveSink(); scope->Release(); } } // if (yyparse() != 0) // errorMessage( SevFatal, "sorry, parsing could not recover" ); doneBuffer(); } leaveParser(); return S_OK; } //--------------------------------------------------------- // IBabelService: ColorLine //--------------------------------------------------------- STDMETHODIMP StdService::ColorLine( in BSTR line, in IColorSink* sink, inout long* state ) { TRACE(L"StdService::ColorLine"); if (!state) return E_POINTER; enterLexer(); { //if (g_service) { TRACE(L"entering colorizer while parsing"); } switchBuffer( m_lexerBuffer, *state, (line ? SysStringLen(line) : 0), line, NULL, ReasonColorize ); if (line) { int pos = 0; Token token; while ( (token = nextToken()) != 0) { if (sink) { const TokenInfo* tokenInfo = lookupTokenInfo(token); sink->Colorize( pos, pos + yyleng - 1 , tokenInfo->colorClass , tokenInfo->charClass , tokenInfo->trigger ); pos += yyleng; } } } *state = doneBuffer(); //if (g_service) { TRACE(L"leaving colorizer while parsing"); } } leaveLexer(); return S_OK; }; //--------------------------------------------------------- // NextToken //--------------------------------------------------------- bool StdService::isParserToken( in const TokenInfo& info) const { return ( info.charClass != CharWhiteSpace && info.charClass != CharLineComment && info.charClass != CharComment ); } Token StdService::parserNextToken(void) { Token token; const TokenInfo* info; enterLexer(); { do { token = nextToken(); info = lookupTokenInfo( token ); } while ( !isParserToken(*info) ); yylloc = m_buffer->location; yylval = m_buffer->location; } leaveLexer(); return token; }; Token StdService::nextToken(void) { m_buffer->token = yylex(); m_buffer->location.update( m_buffer->token, yytext, yyleng ); return m_buffer->token; }; //--------------------------------------------------------- // IBabelService: ColorCount && GetColorInfo //--------------------------------------------------------- STDMETHODIMP StdService::ColorCount( out ColorClass* count) { TRACE(L"StdService::ColorCount"); if (!count) return E_POINTER; else *count = 0; const ColorInfo* info = getColorInfo(); ColorClass counter = 0; ASSERT(info); if (info) { while (info->colorClass != ColorClassEnd) { info++; counter++; } }; *count = counter; return S_OK; }; STDMETHODIMP StdService::GetColorInfo( in ColorClass index, out BSTR* description, out BSTR* style ) { TRACE(L"StdService::GetColorInfo"); OLECHAR buffer[MaxStr+1]; const ColorInfo* info = lookupColorInfo( index ); if (info->colorClass != index) return E_INVALIDARG; HRESULT hr = S_OK; if (description) { if (info->description == NULL) { hr = E_FAIL; goto Error; } size_t convertedSize; size_t descriptionLen = strlen(info->description); if (0 != mbstowcs_s(&convertedSize, buffer, MaxStr+1, info->description, descriptionLen)) { hr = E_FAIL; goto Error; } *description = SysAllocString( buffer ); if ((*description) == NULL) { hr = E_OUTOFMEMORY; goto Error; } } if (style) { if (info->style == NULL) { hr = E_FAIL; goto Error; } size_t convertedSize; size_t styleSize = strlen(info->style); if (0 != mbstowcs_s(&convertedSize, buffer, MaxStr+1, info->style, styleSize)) { hr = E_FAIL; goto Error; } *style = SysAllocString( buffer ); if ((*style) == NULL) { hr = E_OUTOFMEMORY; goto Error; } } Error: if (FAILED(hr)) { if (description) bstrFree(*description); if (style) bstrFree(*style); } return hr; }; //--------------------------------------------------------- // Token info //--------------------------------------------------------- static TokenInfo defaultTokenInfo = { TokenEnd, ClassDefault, "<unknown>", CharDefault }; final const char* StdService::getTokenDescription( in Token token ) const { static char buffer[MaxErrorMessage]; const TokenInfo* info = lookupTokenInfo( token ); ASSERT(info); if (info && info->token == token) //found a fit description { const char* text = (m_buffer->location.text == NULL) ? "<unknown>" : m_buffer->location.text; if (info->description != NULL) { if (0!=sprintf_s(buffer, MaxErrorMessage, info->description, text )) buffer[0] = 0; } else { buffer[0] = 0; } return buffer; } else { if (token == 0) return "end-of-file"; if (token >= ' ') sprintf_s( buffer, MaxErrorMessage, "token ('%c')", token ); else sprintf_s( buffer, MaxErrorMessage, "token (0x%x)", token ); buffer[MaxErrorMessage-1] = 0; return buffer; } }; final const TokenInfo* StdService::lookupTokenInfo( Token token ) const { const TokenInfo* info = getTokenInfo(); ASSERT(info); if (info==NULL) info = &defaultTokenInfo; while (info->token != TokenEnd) //walk through info in a linear fasion { if (info->token == token) break; info++; } return info; } const TokenInfo* StdService::getTokenInfo(void) const { return &defaultTokenInfo; } //--------------------------------------------------------- // Color info //--------------------------------------------------------- local const ColorClass ColorMask = 0xFFFF; final const ColorInfo* StdService::lookupColorInfo( in ColorClass colorClass ) const { static ColorInfo defaultColorInfo = { ColorClassEnd, "Text", "" }; const ColorInfo* info = getColorInfo(); ASSERT(info); if (info == NULL) info = &defaultColorInfo; colorClass &= ColorMask; //mask off attributes (ie. ClassHumanText) while (info->colorClass != ColorClassEnd ) { if (info->colorClass == colorClass) break; info++; } ASSERT( info && info->colorClass != ColorClassEnd ); return info; } const ColorInfo* StdService::getColorInfo() const { static ColorInfo defaultColorInfoTable[] = { // { ClassText, "Text", "" }, { ClassKeyword, "Keyword", "color: blue" }, { ClassComment, "Comment", "color: darkgreen; text-kind: humantext" }, { ClassIdentifier, "Identifier", "" }, { ClassString, "String", "color: purple" }, { ClassNumber, "Number", "" }, { ColorClassEnd, "Text", "" } }; return defaultColorInfoTable; } //--------------------------------------------------------- // Error messages //--------------------------------------------------------- static char errorBuffer[MaxErrorMessage]; void StdService::fatalFlexError( in const char* message ) const { ASSERT(0); lexicalError( SevFatal, message ); } void StdService::lexicalError( in Severity sev, in const char* message ) const { if (!CHECK(m_buffer->reason)) return; if (!m_buffer->sink) return; Location location = m_buffer->location; location.update( m_buffer->token, yytext, yyleng ); errorMessage( sev, message, &location ); }; void StdService::expectError( in const char* construct, in const char* expecting, in const Location* loc ) const { if (!CHECK(m_buffer->reason)) return; sprintf_s( errorBuffer, MaxErrorMessage, "Syntax error in %s; expecting \"%s\"", construct, expecting ); errorBuffer[MaxErrorMessage-1] = 0; errorMessage( SevError, errorBuffer, loc ); } void StdService::syntaxError( in const char* construct, in const Location* loc ) const { if (!CHECK(m_buffer->reason)) return; const char* description = getTokenDescription( (yychar < 0 ? m_buffer->token : yychar ) ); sprintf_s( errorBuffer, MaxErrorMessage, "Syntax error in %s (unexpected %s)", construct, description ); errorBuffer[MaxErrorMessage-1] = 0; errorMessage( SevError, errorBuffer, loc ); } void StdService::errorMessage( in Severity sev, in const char* message, in const Location* loc ) const { if (!CHECK(m_buffer->reason)) return; if (!m_buffer->sink) return; if (loc == NULL) loc = &yylloc; BSTR bstrMessage = BstrNew( message ); if (bstrMessage) { enterSink(); { m_buffer->sink->ErrorMessage( loc->startRow, loc->endRow, loc->startIdx, loc->endIdx, sev, bstrMessage ); SysFreeString(bstrMessage); } leaveSink(); } } //--------------------------------------------------------- // IBabelService::GetMethodFormat //--------------------------------------------------------- STDMETHODIMP StdService::GetMethodFormat(out BSTR* parStart, out BSTR* parSep, out BSTR* parEnd, out BSTR* typeStart, out BSTR* typeEnd, out VARIANT_BOOL* typePrefixed ) { const MethodFormat* methodFormat = getMethodFormat(); if (methodFormat) { if (parStart) *parStart = BstrNewFormat(methodFormat->parStart); if (parSep) *parSep = BstrNewFormat(methodFormat->parSep); if (parEnd) *parEnd = BstrNewFormat(methodFormat->parEnd); if (typeStart) *typeStart= BstrNewFormat(methodFormat->typeStart); if (typeEnd) *typeEnd = BstrNewFormat(methodFormat->typeEnd); if (typePrefixed) *typePrefixed = methodFormat->typePrefixed; return S_OK; } else return E_NOTIMPL; } const MethodFormat* StdService::getMethodFormat() const { return NULL; } //--------------------------------------------------------- // IBabelService::GetImageList //--------------------------------------------------------- STDMETHODIMP StdService::GetImageList( out long* imageListHandle, out long* glyphCount ) { OUTARG(imageListHandle); OUTARG(glyphCount); return E_NOTIMPL; } //--------------------------------------------------------- // IBabelService::GetCommentFormat //--------------------------------------------------------- STDMETHODIMP StdService::GetCommentFormat( out BSTR* lineStart, out BSTR* blockStart, out BSTR* blockEnd, out VARIANT_BOOL* useLineComments ) { if (!lineStart) return E_INVALIDARG; if (!blockStart) return E_INVALIDARG; if (!blockEnd) return E_INVALIDARG; if (!useLineComments) return E_INVALIDARG; const CommentFormat* commentFormat = getCommentFormat(); if (commentFormat) { *lineStart = BstrNewFormat(commentFormat->lineStart); *blockStart = BstrNewFormat(commentFormat->blockStart); *blockEnd = BstrNewFormat(commentFormat->blockEnd); *useLineComments = commentFormat->useLineComments; return S_OK; } else return E_NOTIMPL; } const CommentFormat* StdService::getCommentFormat() const { return NULL; } //--------------------------------------------------------- // Parenthesis //--------------------------------------------------------- void StdService::matchPair( in const Location& loc1, in const Location& loc2 ) const { if (!m_buffer->sink) return; if (!MATCHBRACES(m_buffer->reason)) return; enterSink(); { m_buffer->sink->MatchPair( loc1.startRow, loc1.startIdx, loc1.endRow, loc1.endIdx , loc2.startRow, loc2.startIdx, loc2.endRow, loc2.endIdx ); } leaveSink(); } void StdService::matchTriple( in const Location& loc1, in const Location& loc2, in const Location& loc3 ) const { if (!m_buffer->sink) return; if (!MATCHBRACES(m_buffer->reason)) return; enterSink(); { m_buffer->sink->MatchTriple( loc1.startRow, loc1.startIdx, loc1.endRow, loc1.endIdx , loc2.startRow, loc2.startIdx, loc2.endRow, loc2.endIdx , loc3.startRow, loc3.startIdx, loc3.endRow, loc3.endIdx); } leaveSink(); } //--------------------------------------------------------- // Scope functions //--------------------------------------------------------- final void StdService::addScope( in const Location& start, in const Location& end, in ScopeKind kind, in ScopeAccess access, in ScopeStorage storage, in const Location& name, in const Location& descStart, in const Location& descEnd, in const Location* type, in long glyph, in bool merge, in bool makeDescription /* = false */ ) { if (!m_buffer->sink) return; if (!CHECK(m_buffer->reason)) return; BSTR bstrName = tokenBstr(&name); BSTR bstrType = type ? tokenBstr(type) : NULL; BSTR bstrDescription = NULL; if (makeDescription && bstrType) { const size_t bufferSize = MaxStr+5; OLECHAR buffer[bufferSize]; buffer[0] = 0; int iTypeLen = ::SysStringLen(bstrType); int iNameLen = ::SysStringLen(bstrName); if ( iTypeLen + iNameLen < MaxStr) { if (iTypeLen > 0) { if (0==wcscpy_s(buffer, bufferSize, bstrType)) wcscat_s(buffer, bufferSize, L" "); } if (iNameLen > 0) wcscat_s(buffer, bufferSize, bstrName); bstrDescription = ::SysAllocString(buffer); } } else { bstrDescription = tokenBstr(&descStart,&descEnd); } enterSink(); { m_buffer->sink->AddScope( start.startRow, start.startIdx, end.endRow, end.endIdx, kind, access, storage, glyph, bstrName, bstrType, bstrName, bstrDescription, merge ); } leaveSink(); // free the strings bstrFree(bstrName); bstrFree(bstrType); bstrFree(bstrDescription); } final void StdService::addScopeText( in const Location& start, in const Location& end, in ScopeKind kind, in ScopeAccess access, in ScopeStorage storage, in const char* name, in const char* description , in const char* type , in const char* display , in long glyph, in bool merge ) { if (!m_buffer->sink) return; if (!CHECK(m_buffer->reason)) return; BSTR bstrName=BstrNew(name); BSTR bstrType=BstrNew(type); BSTR bstrDescription=BstrNew(description); BSTR bstrDisplay=BstrNew(display); enterSink(); { m_buffer->sink->AddScope( start.startRow, start.startIdx, end.endRow, end.endIdx, kind, access, storage, glyph, bstrName, bstrType, bstrDisplay, bstrDescription, merge ); } leaveSink(); // free the strings bstrFree(bstrName); bstrFree(bstrType); bstrFree(bstrDescription); bstrFree(bstrDisplay); } //--------------------------------------------------------- // Scope functions //--------------------------------------------------------- Location StdService::range( in const Location& loc1, in const Location& loc2 ) const { Location result(loc1,loc2); return result; } const char* StdService::tokenText( in const Location* tokenStart , in const Location* tokenEnd ) const { if (tokenStart == NULL) tokenStart = &m_buffer->location; if (tokenEnd == NULL) tokenEnd = tokenStart; { static char buffer[MaxStr+1]; Location token( *tokenStart, *tokenEnd ); int len = MaxStr > token.textLen ? token.textLen : MaxStr; size_t convertedSize; if (0!=wcstombs_s(&convertedSize, buffer, MaxStr+1, m_buffer->inputStart + token.textOfs, len)) buffer[0] = 0; return buffer; } } BSTR StdService::tokenBstr( in const Location* tokenStart , in const Location* tokenEnd ) const { if (tokenStart == NULL) tokenStart = &m_buffer->location; if (tokenEnd == NULL) tokenEnd = tokenStart; Location token( *tokenStart, *tokenEnd ); int len = token.textLen; return SysAllocStringLen( m_buffer->inputStart + token.textOfs, token.textLen ); } final void StdService::addExtern( in const Location& start, in const Location& end, in IScope* scope ) { if (!m_buffer->sink) return; if (!CHECK(m_buffer->reason)) return; enterSink(); { m_buffer->sink->AddExtern( start.startRow, start.startIdx, end.endRow, end.endIdx, scope ); } leaveSink(); } //--------------------------------------------------------- // Context //--------------------------------------------------------- void StdService::getProject( out IBabelProject** project ) { if (project) *project = NULL; if (!m_buffer->sink) return; if (!CHECK(m_buffer->reason)) return; if (!project) return; HRESULT hr; enterSink(); { hr = m_buffer->sink->GetProject( project ); } leaveSink(); if (FAILED(hr)) { *project = NULL; } return; } void StdService::getPackage( out IBabelPackage** package ) { if (package) *package = NULL; if (!m_buffer->sink) return; if (!CHECK(m_buffer->reason)) return; if (!package) { return;} HRESULT hr; enterSink(); { hr = m_buffer->sink->GetPackage( package ); } leaveSink(); if (FAILED(hr)) {return;} } void StdService::getFileName( out char* filePath, in int nameLen ) { if (filePath) filePath[0] = 0; if (!m_buffer->sink) return; if (!CHECK(m_buffer->reason)) return; if (!filePath || nameLen <= 0) return; HRESULT hr; BSTR bstrFilePath = NULL; enterSink(); { hr = m_buffer->sink->GetFileName( &bstrFilePath ); } leaveSink(); if (hr == S_OK && bstrFilePath) { size_t convertedSize; wcstombs_s(&convertedSize, filePath, nameLen, bstrFilePath, ::SysStringLen(bstrFilePath)); SysFreeString(bstrFilePath); } return; } void StdService::searchFile( inout char* fileName, in int nameLen ) { if (!fileName || nameLen <= 0) return; IBabelProject* project = NULL; getProject( &project ); if (!project) return; BSTR bstrFileName = BstrNew(fileName); if (!bstrFileName) { RELEASE(project); return; } BSTR bstrFilePath = NULL; HRESULT hr = project->SearchFile( bstrFileName, &bstrFilePath ); RELEASE(project); SysFreeString(bstrFileName); if (FAILED(hr)) return; size_t convertedSize; wcstombs_s(&convertedSize, fileName, nameLen, bstrFilePath, ::SysStringLen(bstrFilePath)); SysFreeString(bstrFilePath); return; } void StdService::loadScope( in const char* fileName, out IScope** scope ) { if (!scope)return; else *scope = NULL; if (!fileName) {return;} IBabelPackage* package = NULL; getPackage( &package ); if (!package) {return; } IBabelProject* project = NULL; getProject( &project ); BSTR bstrFileName = BstrNew(fileName); if (!bstrFileName) { RELEASE(package); RELEASE(project); return;} HRESULT hr = package->LoadScope( 0, bstrFileName, project, scope ); RELEASE(project); RELEASE(package); SysFreeString(bstrFileName); if (FAILED(hr)) {return;} return; } //--------------------------------------------------------- // Member selection //--------------------------------------------------------- void StdService::startName( in const Location& loc ) const { if (!SELECT(m_buffer->reason) && !AUTOS(m_buffer->reason)) return; if (!m_buffer->sink) return; enterSink(); { m_buffer->sink->StartName( loc.endRow, loc.startIdx, loc.endIdx ); } leaveSink(); } void StdService::qualifyName( in const Location& locSelector, in const Location& loc) const { if (!SELECT(m_buffer->reason) && !AUTOS(m_buffer->reason)) return; if (!m_buffer->sink) return; enterSink(); { m_buffer->sink->QualifyName( locSelector.endRow, locSelector.startIdx, locSelector.endIdx, loc.endRow, loc.startIdx, loc.endIdx ); } leaveSink(); } void StdService::autoExpression( in const Location& loc ) const { if (!AUTOS(m_buffer->reason)) return; if (!m_buffer->sink) return; enterSink(); { m_buffer->sink->AutoExpression( loc.startRow, loc.startIdx, loc.endRow, loc.endIdx ); } leaveSink(); } void StdService::codeSpan( in const Location& start, in const Location& end ) const { if (!CODESPAN(m_buffer->reason)) return; if (!m_buffer->sink) return; enterSink(); { m_buffer->sink->CodeSpan( start.startRow, start.startIdx, end.endRow, end.endIdx ); } leaveSink(); } //--------------------------------------------------------- // Method info //--------------------------------------------------------- void StdService::startParameters( in const Location& loc ) const { if (!m_buffer->sink) return; if (!METHODTIP(m_buffer->reason)) return; enterSink(); { m_buffer->sink->StartParameters(loc.endRow,loc.endIdx); } leaveSink(); } void StdService::parameter(in const Location& loc) const { if (!m_buffer->sink) return; if (!METHODTIP(m_buffer->reason)) return; enterSink(); { m_buffer->sink->Parameter(loc.endRow,loc.endIdx); } leaveSink(); } void StdService::endParameters(in const Location& loc) const { if (!m_buffer->sink) return; if (!METHODTIP(m_buffer->reason)) return; enterSink(); { m_buffer->sink->EndParameters(loc.endRow,loc.endIdx); } leaveSink(); } //--------------------------------------------------------- // init/done //--------------------------------------------------------- void StdService::initColorizerState( inout ColorizerState& cstate ) { LexState lexstate = cstate.load( StateBits ); setLexState( lexstate ); } void StdService::doneColorizerState( inout ColorizerState& cstate ) { cstate.save( getLexState(), StateBits ); } //--------------------------------------------------------- // Construction & Destruction //--------------------------------------------------------- StdService::StdService() : m_lexerBuffer(1024), m_parserBuffer() { m_refCount = 1; InitializeCriticalSection( &m_parserLock ); InitializeCriticalSection( &m_lexerLock ); IncRefCount( &g_dllRefCount ); g_service = (Service*)this; m_buffer = NULL; ColorizerState cstate( 0 ); initColorizerState(cstate); }; StdService::~StdService() { ASSERT(m_buffer == NULL); g_service = NULL; DeleteCriticalSection( &m_lexerLock ); DeleteCriticalSection( &m_parserLock ); DecRefCount( &g_dllRefCount ); } final void StdService::enterParser() { EnterCriticalSection( &m_parserLock ); } final void StdService::leaveParser() { LeaveCriticalSection( &m_parserLock ); } final void StdService::enterLexer() { EnterCriticalSection( &m_lexerLock ); } final void StdService::leaveLexer() { LeaveCriticalSection( &m_lexerLock ); } //enter/leaveSink simply use the lexer lock final void StdService::enterSink() const { EnterCriticalSection( const_cast<LPCRITICAL_SECTION>(&m_lexerLock) ); } final void StdService::leaveSink() const { LeaveCriticalSection( const_cast<LPCRITICAL_SECTION>(&m_lexerLock) ); } final void StdService::switchBuffer( in LexBuffer& buffer, in State state, in int inputLen, in const InputChar* input, in IParseSink* sink, in ParseReason reason ) { enterLexer(); { ASSERT(buffer.prevBuffer == NULL); ASSERT(buffer.input == NULL); //save previous buffer buffer.prevBuffer = m_buffer; if (m_buffer) { TRACE(L"save buffer"); //save context doneColorizerState( m_buffer->cstate ); m_buffer->yylloc = yylloc; m_buffer->yylval = yylval; m_buffer->service = g_service; } buffer.cstate.reset( state ); buffer.location.initialize(); buffer.token = 0; buffer.sink = sink; if (buffer.sink) buffer.sink->AddRef(); buffer.reason = reason; buffer.input = input; buffer.inputStart = input; buffer.inputLim = input + inputLen; yy_flush_buffer( buffer.yy_buffer ); //set new buffer m_buffer = &buffer; //and switch yy_switch_to_buffer( buffer.yy_buffer ); initColorizerState( buffer.cstate ); } leaveLexer(); return; } final State StdService::doneBuffer() { State state = 0; enterLexer(); { ASSERT(m_buffer); doneColorizerState( m_buffer->cstate ); state = m_buffer->cstate.getState(); yy_flush_buffer( m_buffer->yy_buffer ); m_buffer->inputLim = NULL; m_buffer->input = NULL; m_buffer->inputStart= NULL; RELEASE(m_buffer->sink); m_buffer->token = 0; m_buffer->location.initialize(); if (m_buffer->prevBuffer) { TRACE(L"restore buffer"); LexBuffer* prev = m_buffer->prevBuffer; m_buffer->prevBuffer = NULL; //restore previous buffer m_buffer = prev; yylloc = m_buffer->yylloc; yylval = m_buffer->yylval; g_service = m_buffer->service; yy_switch_to_buffer( m_buffer->yy_buffer ); initColorizerState( m_buffer->cstate ); } else { m_buffer = NULL; } } leaveLexer(); return state; } /*final void StdService::internInit( in State state, in int inputLen, in const InputChar* input, in IParseSink* sink ) { enter(); { g_service = (Service*)this; m_buffer->location.initialize(); m_buffer->token = 0; m_buffer->input = input; m_buffer->inputStart = input; m_buffer->inputLim = input + inputLen; m_buffer->reason = ReasonMatchingPair; m_buffer->sink = sink; if (m_buffer->sink) m_buffer->sink->AddRef(); ColorizerState cstate( state ); init( cstate ); } leave(); }; State StdService::internDone() { State state; enter(); { ColorizerState cstate; done( cstate ); if (m_buffer->sink) { m_buffer->sink->Release(); m_buffer->sink = NULL; } m_buffer->input = NULL; m_buffer->inputLim = NULL; m_buffer->token = 0; m_buffer->location.initialize(); g_service = NULL; state = cstate.getState(); } leave(); return state; };*/ //--------------------------------------------------------- // Lexer state //--------------------------------------------------------- void StdService::setLexState( in LexState lexstate ) { primSetLexState( lexstate ); } LexState StdService::getLexState() const { return primGetLexState(); } //--------------------------------------------------------- // Read input from our input buffer (called by the lexer) //--------------------------------------------------------- void StdService::readInput( out char* buffer, out int* result, in int maxSize ) { enterLexer(); { ASSERT(m_buffer); ASSERT(buffer); ASSERT(result); // Check our output parameters for NULL if (buffer == NULL || result == NULL) { return; } // Check that we have characters in the input buffer and space in the // output buffer before the first iteration of the "do" loop. if (m_buffer->input >= m_buffer->inputLim || m_buffer->input == NULL || maxSize == 0) { *result = 0; } else { char* current = buffer; do { //treat "\r\n" as " \n" (MS-DOS CR/LF) //treat just "\r" as "\n" (UNIX) if (m_buffer->input[0] == '\r') { m_buffer->input++; // If we have reached then end of our input characters or we are // at the end of the output buffer we insert a "\n". If not we // check the next character and if it is a "\n" we insert a space // for the "\r". Any other character and we insert a "\n" for the "\r". if ((m_buffer->input < m_buffer->inputLim) && ((current - buffer) < (maxSize - 1))) { // We have not reached the end of our input or output buffers // so we can check if the next character is a "\n" if (m_buffer->input[0] == '\n') current[0] = ' '; else current[0] = '\n'; } else { current[0] = '\n'; } current++; } //treat "\0" (end of file) as "\n" else if (m_buffer->input[0] == '\0' ) { current[0] = '\n'; current++; m_buffer->input++; } else { // Convert our input wide character to multibyte representation. // Note we need to ensure there is sufficent space in our output // buffer and we also need to test for failure char tempBuf[DOUBLE_BYTE_BUF_SIZE]; // Much bigger than we will ever need int count; if (0== wctomb_s(&count, tempBuf, DOUBLE_BYTE_BUF_SIZE, m_buffer->input[0]) && count > 0) { // If the conversion is successful then copy the byte(s) to the output if ((current - buffer) <= (maxSize - count)) // Check for room in the output buffer { memcpy(current, tempBuf, count); current += count; } else { // We don't have room so we output a space current[0] = ' '; current++; } } m_buffer->input++; } } while (m_buffer->input < m_buffer->inputLim && ((current - buffer) < maxSize)); *result = (int)(current - buffer); } } leaveLexer(); } /*--------------------------------------------------------- IUnknown -----------------------------------------------------------*/ STDMETHODIMP StdService::QueryInterface( in REFIID iid, out void** obj ) { OUTARG(obj); if (iid == IID_IUnknown) { TRACE(L"StdService::QueryInterface for IUnknown"); *obj = static_cast<IUnknown*>(this); } else if (iid == IID_IDispatch) { TRACE(L"StdService::QueryInterface for IDispatch"); *obj = static_cast<IDispatch*>(this); } else if (iid == IID_IBabelService) { TRACE(L"StdService::QueryInterface for IBabelService"); *obj = static_cast<IBabelService*>(this); } else return E_NOINTERFACE; AddRef(); return S_OK; } STDMETHODIMP_(ULONG) StdService::AddRef() { return IncRefCount(&m_refCount); } STDMETHODIMP_(ULONG) StdService::Release() { if (DecRefCount(&m_refCount) == 0) { delete this; return 0; } else return m_refCount; } /*--------------------------------------------------------- implement IDispatch (for IBabelService only) -----------------------------------------------------------*/ STDMETHODIMP StdService::GetTypeInfoCount( out UINT* count ) { OUTARG(count); if (g_typeInfoBabelService) *count = 1; else *count = 0; return S_OK; } STDMETHODIMP StdService::GetTypeInfo( in UINT index, in LCID lcid, out ITypeInfo** typeInfo ) { OUTARG(typeInfo); if (index != 0) return E_INVALIDARG; if (!g_typeInfoBabelService) return TYPE_E_CANTLOADLIBRARY; *typeInfo = g_typeInfoBabelService; return S_OK; } STDMETHODIMP StdService::GetIDsOfNames( in REFIID iid, in OLECHAR** names, in UINT count, in LCID lcid, out DISPID* dispids ) { if (!g_typeInfoBabelService) return TYPE_E_CANTLOADLIBRARY; return g_typeInfoBabelService->GetIDsOfNames( names, count, dispids ); } STDMETHODIMP StdService::Invoke( in DISPID dispid, in REFIID iid, in LCID lcid, in WORD flags, in DISPPARAMS* args, out VARIANT* result, out EXCEPINFO* error, out UINT* errorArg ) { if (!g_typeInfoBabelService) return TYPE_E_CANTLOADLIBRARY; return g_typeInfoBabelService->Invoke( static_cast<IBabelService*>(this), dispid, flags, args, result, error, errorArg ); }
[ "alon@rogue.(none)" ]
[ [ [ 1, 1521 ] ] ]
e96460b08ab4d7cf524e43fe8dad3e1d28ba0455
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/MapLib/Shared/src/HttpClientConnection.cpp
d07ab101c482dd828f7e06630ae7b33f1feded7d
[ "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
ISO-8859-1
C++
false
false
21,130
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. */ #include "config.h" #include<string.h> #include <ctype.h> // For sprintf #include <stdio.h> #include <algorithm> #include "HttpClientConnection.h" #include "HttpClientConnectionListener.h" #include "SharedBuffer.h" #include "SharedHttpHeader.h" class HttpClientConnectionReader { public: /** * Creates a new HttpClientConnectionReader */ HttpClientConnectionReader(HttpClientConnection* connection, HttpClientConnectionListener* listener); /// Destroys the internal stuff. ~HttpClientConnectionReader(); /** * Handles that a read is done. */ TCPClientConnection::status_t readDone(TCPClientConnection::status_t status, const byte* bytes, int nbrBytes); /** * */ void setListener(HttpClientConnectionListener* listener ) { m_listener = listener; } public: /// The connection HttpClientConnection* m_connection; /// The connection listener HttpClientConnectionListener* m_listener; /// The header SharedHttpHeader m_header; enum state_t { IDLE = 0, READING_HEADER = 1, READING_BODY = 2, } m_state; /// The content length. int m_contentLength; /// The content length left. int m_contentLengthLeft; /// The current position in the body int m_curBodyPos; /// Max length to read int m_readLength; /// Read buffer. byte* m_readBuffer; }; HttpClientConnectionReader:: HttpClientConnectionReader(HttpClientConnection* connection, HttpClientConnectionListener* listener) { m_connection = connection; m_listener = listener; m_readLength = 1024; m_state = IDLE; } HttpClientConnectionReader::~HttpClientConnectionReader() { setListener(NULL); if ( m_connection ) { m_connection->setListener(NULL); } } TCPClientConnection::status_t HttpClientConnectionReader::readDone(TCPClientConnection::status_t status, const byte* bytes, int nbrBytes) { mc2dbg << "[HttpClientConnectionReader::readDone called with status = " << int(status) << " and nbr bytes = " << nbrBytes << endl; if ( m_state == IDLE ) { if ( m_connection->getNbrSent() ) { m_state = READING_HEADER; m_header.reset(); m_curBodyPos = 0; } else { return TCPClientConnection::ERROR; } } // FIXME: Divide this into more functions. if ( status == TCPClientConnection::OK ) { int headerBytes = 0; while ( nbrBytes > 0 ) { int currentRequest = m_connection->getCurrentRequestNbr(); if ( m_state == READING_HEADER ) { mc2dbg << "[HttpClientConnectionReader]: Adding max " << nbrBytes << "bytes to header" << endl; headerBytes = m_header.addBytes(bytes, nbrBytes); if ( headerBytes < 0 ) { m_state = IDLE; m_connection->connectionClosed(TCPClientConnection::ERROR); return TCPClientConnection::ERROR; } bytes += headerBytes; nbrBytes -= headerBytes; if ( headerBytes < 0 ) { // ERROR m_state = IDLE; return TCPClientConnection::ERROR; } if ( m_header.complete() ) { mc2dbg << "[HttpClientConnectionReader]: HTTP-status is " << m_header.getStatusCode() << endl; // Status is ok. m_contentLength = 0; const char* contentLengthStr = m_header.getHeaderValue("Content-Length"); if ( contentLengthStr ) { m_contentLength = atoi(contentLengthStr); } m_contentLengthLeft = m_contentLength; mc2dbg << "[Http]: Content-length = " << m_contentLength << endl; // Tell the listener that there are bytes. if ( m_listener ) { m_listener->bytesReceived(currentRequest, m_header.getStatusCode(), NULL, 0, 0, m_contentLength); } m_state = READING_BODY; m_curBodyPos = 0; } } mc2dbg << "[HttpClientConnectionReader]: headerBytes = " << headerBytes << endl; if ( m_state == READING_BODY ) { if ( nbrBytes ) { int nbrBytesToListener = MIN(nbrBytes, m_contentLengthLeft); if ( m_listener ) { m_listener->bytesReceived(currentRequest, m_header.getStatusCode(), bytes, m_curBodyPos, nbrBytesToListener, m_contentLength); } m_contentLengthLeft -= nbrBytesToListener; m_curBodyPos += nbrBytesToListener; nbrBytes -= nbrBytesToListener; bytes += nbrBytesToListener; } mc2dbg << "[HttpClientConnectionReader]: m_contentLengthLeft = " << m_contentLengthLeft << endl; if ( (m_contentLength != 0) && (m_contentLengthLeft == 0) ) { m_connection->oneRequestComplete(); if ( m_connection->getNbrSent() == 0 ) { mc2dbg << "[HttpClientConnectionReader]: Should be IDLE now" << endl; m_state = IDLE; } else { m_state = READING_HEADER; m_curBodyPos = 0; m_contentLengthLeft = 0; m_contentLength = 0; m_header.reset(); } } } } } else if ( ( status == TCPClientConnection::CLOSED ) && ( m_state == READING_BODY ) && ( m_contentLength == 0) ) { const int currentRequest = m_connection->getCurrentRequestNbr(); // The server didn't send content length. // We're done when the connection is closed. if ( m_listener ) { m_listener->bytesReceived(currentRequest, m_header.getStatusCode(), bytes, m_curBodyPos, nbrBytes, m_curBodyPos+nbrBytes); } m_curBodyPos += nbrBytes; bytes += nbrBytes; m_connection->oneRequestComplete(); m_state = READING_HEADER; m_curBodyPos = 0; m_header.reset(); } else { // Error! m_state = IDLE; return TCPClientConnection::ERROR; } // Always check for more data. m_connection->readNextRequest(); return status; } HttpClientConnection:: HttpClientConnection(const char* host, unsigned int port, HttpClientConnectionListener* listener, TCPConnectionHandler* connHandler) #ifdef __SYMBIAN32__ : m_userAgent("SymbClientConn/0.01"), #elif WIN32 : m_userAgent("WinClientConn/0.01"), #else : m_userAgent("MC2ClientConn/0.01"), #endif m_maxNbrRetries(3) { m_maxNbrGet = 3; m_proxyHeaderLines = ""; setHostAndPort(host, port); m_connHandler = connHandler; m_connecting = false; m_reading = false; m_writing = false; m_state = NOT_CONNECTED; m_nbrWaiting = 0; m_listener = listener; m_connReader = new HttpClientConnectionReader(this, listener); m_nextID = 0; m_nbrRetries = 0; } void HttpClientConnection::setHostAndPort(const char* host, unsigned int port) { m_host = host; m_port = port; #if defined(__unix__) || defined(__MACH__) // Check for proxy environment variable. const char* proxy = getenv("http_proxy"); if ( ( proxy != NULL ) && ( proxy[0] != 0 ) ) { char proxyHostName[1024]; strcpy(proxyHostName, proxy); int len = strlen(proxyHostName); for ( int i = 0; i < len; ++i ) { if( proxyHostName[i] == ':' ) { proxyHostName[i] = ' '; } } unsigned int proxyPort = 0; if ( sscanf( proxyHostName, "http //%s %u/", proxyHostName, &proxyPort) == 2 ) { char urlPrefix[1024]; sprintf(urlPrefix, "http://%s:%u", m_host.c_str(), m_port); m_urlPrefix = urlPrefix; m_host = proxyHostName; m_port = proxyPort; m_proxyHeaderLines = "Proxy-Connection: Keep-Alive\r\n"; } else { mc2dbg << "proxyHostName = " << proxyHostName << endl; mc2dbg << "[HttpCC]: Could not parse proxy " << MC2CITE(proxy) << ". Should be of the form " << "http://host:port/" << endl; } } #endif } HttpClientConnection::~HttpClientConnection() { m_connHandler->remove(this); // Close connection. // Delete buffers. delete m_connReader; // FIXME: Delete the requests... } void HttpClientConnection::setListener(HttpClientConnectionListener* listener) { m_listener = listener; m_connReader->setListener(listener); if ( m_listener == NULL ) { m_connHandler->remove(this); } } void HttpClientConnection::readDone(status_t status, const byte* bytes, int nbrBytes) { m_reading = false; m_connReader->readDone(status, bytes, nbrBytes); } void HttpClientConnection::connectionClosed(status_t /*status*/) { m_connecting = false; m_reading = false; m_writing = false; m_connReader->readDone(TCPClientConnection::CLOSED, 0, 0); m_state = NOT_CONNECTED; // Move back the waiting fors to the requestlist std::reverse(m_waitingFor.begin(), m_waitingFor.end()); for( requestList_t::iterator it = m_waitingFor.begin(); it != m_waitingFor.end(); ++it ) { mc2dbg << "[HttpClientConnection]: Moving back " << (*it).first << endl; m_requestsToSend.push_front(*it); } if ( ! m_currentlyWriting.empty() ) { mc2dbg << "[HttpClientConnection]: Moving back " << m_currentlyWriting.front().first << " from current" << endl; m_requestsToSend.push_front(m_currentlyWriting.front()); } m_currentlyWriting.clear(); m_waitingFor.clear(); writeNextRequest(); } void HttpClientConnection::connectDone(status_t status) { m_connecting = false; if ( status == OK ) { mc2dbg << "[HttpClientConnection]: Connected! " << endl; m_state = CONNECTED; // Check if there are requests to be written. writeNextRequest(); } else { m_state = NOT_CONNECTED; if ( m_nbrRetries >= m_maxNbrRetries ) { // Signal the error to the listener if ( ! m_waitingFor.empty() ) { mc2dbg << "[HttpClientConnection:] Could not connect " << " and m_waitingFor is not empty that is wrong." << endl; } if ( ! m_currentlyWriting.empty() ) { m_waitingFor.push_back(m_currentlyWriting.front()); m_currentlyWriting.pop_front(); } else if ( ! m_requestsToSend.empty() ) { m_waitingFor.push_back(m_requestsToSend.front()); m_requestsToSend.pop_front(); } int reqNbr = getCurrentRequestNbr(); oneRequestComplete(); if ( m_listener ) { m_listener->bytesReceived(reqNbr, 999, NULL, -1, -1, -1); } // Just try once for the rest. writeNextRequest(); } else { writeNextRequest(); } } } void HttpClientConnection::readNextRequest() { mc2dbg << "HttpClientConnection::readNextRequest" << endl; if ( m_state == CONNECTED ) { m_connHandler->read(m_connReader->m_readLength, this); } } int HttpClientConnection::getCurrentRequestNbr() const { if ( m_waitingFor.empty() ) { return -1; } else { return m_waitingFor.front().first; } } void HttpClientConnection::writeDone(status_t status) { mc2dbg << "[HttpClientConnection]: writeDone(" << (int)status << " for " << m_currentlyWriting.front().first << endl; m_writing = false; if ( status == OK ) { // Ok one down // Move the request to the waitingfor-list. m_waitingFor.push_back(m_currentlyWriting.front()); m_currentlyWriting.pop_front(); } else { // Connect and send again. m_connHandler->connect(m_host.c_str(), m_port, this); m_nbrRetries++; return; } if ( status == OK ) { m_nbrWaiting++; if ( m_state == CONNECTED ) { // Request read too. readNextRequest(); } // Check if we need to resend data. writeNextRequest(); } else { m_state = NOT_CONNECTED; } } void HttpClientConnection::oneRequestComplete() { if ( ! m_waitingFor.empty() ) { mc2dbg << "[HttpClientConnection]: Receieved all for " << m_waitingFor.front().first << endl; delete m_waitingFor.front().second; m_waitingFor.pop_front(); } writeNextRequest(); } void HttpClientConnection::writeNextRequest() { mc2dbg << "[HttpClientConnection]: writeNextRequest" << endl; // Check if we are connected. if ( m_state == NOT_CONNECTED && ( !m_requestsToSend.empty() || ! m_currentlyWriting.empty() ) ) { if ( ! m_connecting ) { mc2dbg << "[HttpClientConnection]: connecting!" << endl; m_nbrRetries++; // VARUN m_connHandler->connect(m_host.c_str(), m_port, this); //m_nbrRetries++; VARUN : SHIFTING ABOVE RETRY m_connecting = true; } return; } if ( m_writing ) { mc2dbg << " [HttpClientConnection]: Writing already - strange" << endl; } bool isRetry = true; // Check if we are writing and if there are requests to send. // Also check if we have to many outstanding requests or not. if ( ( m_currentlyWriting.empty() ) && ( ! m_requestsToSend.empty() ) && ( int(m_waitingFor.size()) < m_maxNbrGet ) ) { isRetry = false; // Remove first element in requests to send. m_currentlyWriting.push_back(m_requestsToSend.front()); m_requestsToSend.pop_front(); } else { mc2dbg << "[HttpClientConnection]: m_currentlyWriting.empty() = " << int(m_currentlyWriting.empty()) << endl << "m_requestsToSend.empty() = " << int(m_requestsToSend.empty()) << endl << "m_waitingFor.size() = " << m_waitingFor.size() << endl; } if ( ! m_currentlyWriting.empty() ) { mc2dbg << "[HttpClientConnection]: Will write " << m_currentlyWriting.front().first << endl; m_writing = true; SharedBuffer* curBuf = m_currentlyWriting.front().second; m_connHandler->write( curBuf->getBufferAddress(), curBuf->getBufferSize(), this); if ( isRetry ) { m_nbrRetries++; } } } void HttpClientConnection::timerExpired(int timerID) { mc2dbg << "[HttpClientConnection]: timerExpired = " << timerID << endl; } int HttpClientConnection::get(const char* filespec1, const char* filespec2, const char* filespec3, const char* urlParams) { if ( filespec2 == NULL ) { filespec2 = ""; } if ( filespec3 == NULL ) { filespec3 = ""; } mc2dbg << "[HttpClientConnection]: get " << filespec1 << filespec2 << endl; // Check number of if ( m_requestsToSend.size() >= (uint32)m_maxNbrGet ) { mc2dbg << "[HttpClientConnection]: To many pending requests" << endl; return -1; } static const int maxStr = 4024; char* tmpRequest = new char[maxStr]; memset( tmpRequest, 0, maxStr ); snprintf(tmpRequest, maxStr, "GET %s%s%s%s%s HTTP/1.0\r\n" "User-Agent: %s\r\n" "Host: %s:%u\r\n" "%s" // ProxyHeaderLines "Connection: Keep-Alive""\r\n" "\r\n", m_urlPrefix.c_str(), filespec1, filespec2, filespec3, urlParams, m_userAgent.c_str(), m_host.c_str(), m_port, m_proxyHeaderLines); // Should never happen, but ... zero terminate tmpRequest[maxStr-1] = '\0'; m_nextID++; if ( m_nextID < 0 ) { // If we have sent _very_ many requests, this can wrap. m_nextID = 0; } int bufLength = strlen(tmpRequest); m_requestsToSend.push_back( std::make_pair(m_nextID, new SharedBuffer((uint8*)tmpRequest, bufLength))); // tmpRequest is now handled by the bitbuffer. // Writes the next request if possible. writeNextRequest(); return m_nextID; } int HttpClientConnection::post(const char* filespecPart1, const char* filespecPart2, const char* /*mimeType*/, const SharedBuffer& body, const char* urlParams) { static const int maxStr = 4024; char* tmpRequest = new char[maxStr]; int contentLength = body.getBufferSize(); memset( tmpRequest, 0, maxStr ); snprintf(tmpRequest, maxStr, "POST %s%s%s%s HTTP/1.0\r\n" "User-Agent: %s\r\n" "Host: %s:%u\r\n" "%s" // ProxyHeaderLines "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n" "\r\n", m_urlPrefix.c_str(), filespecPart1, filespecPart2, urlParams, m_userAgent.c_str(), m_host.c_str(), m_port, m_proxyHeaderLines, contentLength); int tmpReqLen = strlen(tmpRequest); m_nextID++; if ( m_nextID < 0 ) { // If we have sent _very_ many requests, this can wrap. m_nextID = 0; } // Copy the stuff into a new buffer. SharedBuffer* tmpBuf = new SharedBuffer(tmpReqLen + body.getBufferSize()); tmpBuf->writeNextByteArray((const uint8*)tmpRequest, tmpReqLen); tmpBuf->writeNextByteArray( body.getBufferAddress(), body.getBufferSize()); m_requestsToSend.push_back(std::make_pair(m_nextID, tmpBuf)); delete [] tmpRequest; writeNextRequest(); return m_nextID; }
[ [ [ 1, 640 ] ] ]
05879e8362ff2f90d340ee9d82395106ab1ee3fb
011359e589f99ae5fe8271962d447165e9ff7768
/src/burn/cave/d_hotdogst.cpp
f00dc3da05b27c3604fba505d426bcfbe8b0303f
[]
no_license
PS3emulators/fba-next-slim
4c753375fd68863c53830bb367c61737393f9777
d082dea48c378bddd5e2a686fe8c19beb06db8e1
refs/heads/master
2021-01-17T23:05:29.479865
2011-12-01T18:16:02
2011-12-01T18:16:02
2,899,840
1
0
null
null
null
null
UTF-8
C++
false
false
17,696
cpp
// hotdogst #include "cave.h" #include "msm6295.h" #include "burn_ym2203.h" #define CAVE_VBLANK_LINES 12 static unsigned char DrvJoy1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static unsigned char DrvJoy2[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static unsigned short DrvInput[2] = {0x0000, 0x0000}; static unsigned char *Mem = NULL, *MemEnd = NULL; static unsigned char *RamStart, *RamEnd; static unsigned char *Rom01, *RomZ80; static unsigned char *Ram01, *RamZ80; static unsigned char *MSM6295ROMSrc; static unsigned char DrvReset = 0; static unsigned char bDrawScreen; static bool bVBlank; static char nVideoIRQ; static char nSoundIRQ; static char nUnknownIRQ; static char nIRQPending; static int nCyclesTotal[2]; static int nCyclesDone[2]; static unsigned short DrvSoundLatch; static unsigned char DrvZ80Bank; static unsigned char DrvOkiBank1; static unsigned char DrvOkiBank2; static struct BurnInputInfo hotdogstInputList[] = { {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 8, "p1 coin"}, {"P1 Start", BIT_DIGITAL, DrvJoy1 + 7, "p1 start"}, {"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up"}, {"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down"}, {"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left"}, {"P1 Right", BIT_DIGITAL, DrvJoy1 + 3, "p1 right"}, {"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p1 fire 1"}, {"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 5, "p1 fire 2"}, {"P1 Button 3", BIT_DIGITAL, DrvJoy1 + 6, "p1 fire 3"}, {"P2 Coin", BIT_DIGITAL, DrvJoy2 + 8, "p2 coin"}, {"P2 Start", BIT_DIGITAL, DrvJoy2 + 7, "p2 start"}, {"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up"}, {"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down"}, {"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left"}, {"P2 Right", BIT_DIGITAL, DrvJoy2 + 3, "p2 right"}, {"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1"}, {"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p2 fire 2"}, {"P2 Button 3", BIT_DIGITAL, DrvJoy2 + 6, "p2 fire 3"}, {"Reset", BIT_DIGITAL, &DrvReset, "reset"}, {"Diagnostics", BIT_DIGITAL, DrvJoy1 + 9, "diag"}, {"Service", BIT_DIGITAL, DrvJoy2 + 9, "service"}, }; STDINPUTINFO(hotdogst) static void UpdateIRQStatus() { nIRQPending = (nVideoIRQ == 0 || nSoundIRQ == 0 || nUnknownIRQ == 0); SekSetIRQLine(1, nIRQPending ? SEK_IRQSTATUS_ACK : SEK_IRQSTATUS_NONE); } unsigned short __fastcall hotdogstReadWord(unsigned int sekAddress) { switch (sekAddress) { case 0xa80000: case 0xa80002: { unsigned char nRet = (nUnknownIRQ << 1) | nVideoIRQ; return nRet; } case 0xa80004: { unsigned char nRet = (nUnknownIRQ << 1) | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0xa80006: { unsigned char nRet = (nUnknownIRQ << 1) | nVideoIRQ; nUnknownIRQ = 1; UpdateIRQStatus(); return nRet; } // case 0xa8006e: { // return 0xff; // } case 0xc80000: return DrvInput[0] ^ 0xFFFF; case 0xC80002: return (DrvInput[1] ^ 0xF7FF) | (EEPROMRead() << 11); default: { bprintf(PRINT_NORMAL, "Attempt to read word value of location %x\n", sekAddress); } } return 0; } void __fastcall hotdogstWriteWord(unsigned int sekAddress, unsigned short wordValue) { switch (sekAddress) { case 0xa80000: nCaveXOffset = wordValue; return; case 0xa80002: nCaveYOffset = wordValue; return; case 0xa80008: CaveSpriteBuffer(); nCaveSpriteBank = wordValue; return; case 0xa8006e: { DrvSoundLatch = wordValue; ZetOpen(0); ZetNmi(); ZetClose(); return; } case 0xb00000: CaveTileReg[0][0] = wordValue; break; case 0xb00002: CaveTileReg[0][1] = wordValue; break; case 0xb00004: CaveTileReg[0][2] = wordValue; break; case 0xb80000: CaveTileReg[1][0] = wordValue; break; case 0xb80002: CaveTileReg[1][1] = wordValue; break; case 0xb80004: CaveTileReg[1][2] = wordValue; break; case 0xc00000: CaveTileReg[2][0] = wordValue; break; case 0xc00002: CaveTileReg[2][1] = wordValue; break; case 0xc00004: CaveTileReg[2][2] = wordValue; break; case 0xD00000: wordValue >>= 8; EEPROMWrite(wordValue & 0x04, wordValue & 0x02, wordValue & 0x08); break; case 0xd00002: { //nop return; } default: { bprintf(PRINT_NORMAL, "Attempt to write word value %x to location %x\n", wordValue, sekAddress); } } } unsigned char __fastcall hotdogstZIn(unsigned short nAddress) { nAddress &= 0xFF; switch (nAddress) { case 0x30: { return DrvSoundLatch & 0xff; } case 0x40: { return (DrvSoundLatch & 0xff00) >> 8; } case 0x50: { return BurnYM2203Read(0, 0); } case 0x60: { return MSM6295ReadStatus(0); } default: { bprintf(PRINT_NORMAL, "Z80 Port Read %x\n", nAddress); } } return 0; } void __fastcall hotdogstZOut(unsigned short nAddress, unsigned char nValue) { nAddress &= 0xFF; switch (nAddress) { case 0x00: { DrvZ80Bank = nValue & 0x0f; ZetMapArea(0x4000, 0x7FFF, 0, RomZ80 + (DrvZ80Bank * 0x4000)); ZetMapArea(0x4000, 0x7FFF, 2, RomZ80 + (DrvZ80Bank * 0x4000)); return; } case 0x50: { BurnYM2203Write(0, 0, nValue); return; } case 0x51: { BurnYM2203Write(0, 1, nValue); return; } case 0x60: { MSM6295Command(0, nValue); return; } case 0x70: { DrvOkiBank1 = (nValue >> 0) & 0x03; DrvOkiBank2 = (nValue >> 4) & 0x03; memcpy(MSM6295ROM + 0x00000, MSM6295ROMSrc + 0x20000 * DrvOkiBank1, 0x20000); memcpy(MSM6295ROM + 0x20000, MSM6295ROMSrc + 0x20000 * DrvOkiBank2, 0x20000); return; } default: { bprintf(PRINT_NORMAL, "Z80 Port Write %x, %x\n", nAddress, nValue); } } } unsigned char __fastcall hotdogstZRead(unsigned short a) { // switch (a) { // default: { // bprintf(PRINT_NORMAL, "Z80 Read => %04X\n", a); // } // } return 0; } void __fastcall hotdogstZWrite(unsigned short a, unsigned char d) { // switch (a) { // default: { // bprintf(PRINT_NORMAL, "Z80 Write => %04X, %02X\n", a, d); // } // } } static int DrvExit() { EEPROMExit(); MSM6295Exit(0); CaveTileExit(); CaveSpriteExit(); CavePalExit(); SekExit(); // Deallocate 68000s ZetExit(); BurnYM2203Exit(); DrvSoundLatch = 0; DrvZ80Bank = 0; DrvOkiBank1 = 0; DrvOkiBank2 = 0; // Deallocate all used memory free(Mem); Mem = NULL; return 0; } static int DrvDoReset() { SekOpen(0); SekReset(); SekClose(); ZetOpen(0); ZetReset(); ZetClose(); BurnYM2203Reset(); MSM6295Reset(0); EEPROMReset(); nVideoIRQ = 1; nSoundIRQ = 1; nUnknownIRQ = 1; nIRQPending = 0; DrvSoundLatch = 0; DrvZ80Bank = 0; DrvOkiBank1 = 0; DrvOkiBank2 = 0; return 0; } static int DrvDraw() { CavePalUpdate4Bit(0, 128); // Update the palette CaveClearScreen(CavePalette[0x3F00]); if (bDrawScreen) { // CaveGetBitmap(); CaveTileRender(1); // Render tiles } return 0; } static inline int CheckSleep(int) { return 0; } static int DrvFrame() { int nCyclesVBlank; int nInterleave = 80; int nSoundBufferPos = 0; int nCyclesSegment; if (DrvReset) { // Reset machine DrvDoReset(); } // Compile digital inputs DrvInput[0] = 0x0000; // Player 1 DrvInput[1] = 0x0000; // Player 2 for (int i = 0; i < 10; i++) { DrvInput[0] |= (DrvJoy1[i] & 1) << i; DrvInput[1] |= (DrvJoy2[i] & 1) << i; } CaveClearOpposites(&DrvInput[0]); CaveClearOpposites(&DrvInput[1]); SekNewFrame(); ZetNewFrame(); SekOpen(0); nCyclesTotal[0] = (int)((long long)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE)); nCyclesTotal[1] = (int)(4000000 / CAVE_REFRESHRATE); nCyclesDone[0] = nCyclesDone[1] = 0; nCyclesVBlank = nCyclesTotal[0] - (int)((nCyclesTotal[0] * CAVE_VBLANK_LINES) / 271.5); bVBlank = false; for (int i = 1; i <= nInterleave; i++) { int nCurrentCPU = 0; int nNext = i * nCyclesTotal[nCurrentCPU] / nInterleave; // Run 68000 // See if we need to trigger the VBlank interrupt if (!bVBlank && nNext > nCyclesVBlank) { if (nCyclesDone[nCurrentCPU] < nCyclesVBlank) { nCyclesSegment = nCyclesVBlank - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } } if (pBurnDraw != NULL) { DrvDraw(); // Draw screen if needed } CaveSpriteBuffer(); bVBlank = true; nVideoIRQ = 0; UpdateIRQStatus(); } nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } ZetOpen(0); BurnTimerUpdate(i * (nCyclesTotal[1] / nInterleave)); if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen - nSoundBufferPos; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); BurnYM2203Update(pSoundBuf, nSegmentLength); MSM6295Render(0, pSoundBuf, nSegmentLength); nSoundBufferPos += nSegmentLength; } ZetClose(); } SekClose(); ZetOpen(0); BurnTimerEndFrame(nCyclesTotal[1]); ZetClose(); if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen - nSoundBufferPos; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); if (nSegmentLength) { ZetOpen(0); BurnYM2203Update(pSoundBuf, nSegmentLength); MSM6295Render(0, pSoundBuf, nSegmentLength); ZetClose(); } } return 0; } // This routine is called first to determine how much memory is needed (MemEnd-(unsigned char *)0), // and then afterwards to set up all the pointers static int MemIndex() { unsigned char* Next; Next = Mem; Rom01 = Next; Next += 0x100000; // 68K program RomZ80 = Next; Next += 0x040000; CaveSpriteROM = Next; Next += 0x800000; CaveTileROM[0] = Next; Next += 0x100000; // Tile layer 0 CaveTileROM[1] = Next; Next += 0x100000; // Tile layer 1 CaveTileROM[2] = Next; Next += 0x100000; // Tile layer 2 MSM6295ROM = Next; Next += 0x040000; MSM6295ROMSrc = Next; Next += 0x080000; RamStart = Next; Ram01 = Next; Next += 0x010000; // CPU #0 work RAM RamZ80 = Next; Next += 0x002000; CaveTileRAM[0] = Next; Next += 0x008000; CaveTileRAM[1] = Next; Next += 0x008000; CaveTileRAM[2] = Next; Next += 0x008000; CaveSpriteRAM = Next; Next += 0x010000; CavePalSrc = Next; Next += 0x001000; // palette RamEnd = Next; MemEnd = Next; return 0; } static void NibbleSwap1(unsigned char* pData, int nLen) { unsigned char* pOrg = pData + nLen - 1; unsigned char* pDest = pData + ((nLen - 1) << 1); for (int i = 0; i < nLen; i++, pOrg--, pDest -= 2) { pDest[0] = *pOrg & 15; pDest[1] = *pOrg >> 4; } return; } static void NibbleSwap2(unsigned char* pData, int nLen) { unsigned char* pOrg = pData + nLen - 1; unsigned char* pDest = pData + ((nLen - 1) << 1); for (int i = 0; i < nLen; i++, pOrg--, pDest -= 2) { pDest[1] = *pOrg & 15; pDest[0] = *pOrg >> 4; } return; } static int LoadRoms() { BurnLoadRom(Rom01 + 1, 0, 2); BurnLoadRom(Rom01 + 0, 1, 2); BurnLoadRom(RomZ80, 2, 1); BurnLoadRom(CaveSpriteROM + 0x000000, 3, 1); BurnLoadRom(CaveSpriteROM + 0x200000, 4, 1); NibbleSwap1(CaveSpriteROM, 0x400000); BurnLoadRom(CaveTileROM[0], 5, 1); NibbleSwap2(CaveTileROM[0], 0x080000); BurnLoadRom(CaveTileROM[1], 6, 1); NibbleSwap2(CaveTileROM[1], 0x080000); BurnLoadRom(CaveTileROM[2], 7, 1); NibbleSwap2(CaveTileROM[2], 0x080000); // Load MSM6295 ADPCM data BurnLoadRom(MSM6295ROMSrc, 8, 1); return 0; } // Scan ram static int DrvScan(int nAction, int *pnMin) { struct BurnArea ba; if (pnMin) { // Return minimum compatible version *pnMin = 0x020902; } EEPROMScan(nAction, pnMin); // Scan EEPROM if (nAction & ACB_VOLATILE) { // Scan volatile ram memset(&ba, 0, sizeof(ba)); ba.Data = RamStart; ba.nLen = RamEnd - RamStart; ba.szName = "RAM"; BurnAcb(&ba); SekScan(nAction); ZetScan(nAction); BurnYM2203Scan(nAction, pnMin); MSM6295Scan(0, nAction); SCAN_VAR(nVideoIRQ); SCAN_VAR(nSoundIRQ); SCAN_VAR(nUnknownIRQ); SCAN_VAR(bVBlank); CaveScanGraphics(); SCAN_VAR(DrvInput); SCAN_VAR(DrvSoundLatch); SCAN_VAR(DrvZ80Bank); SCAN_VAR(DrvOkiBank1); SCAN_VAR(DrvOkiBank2); if (nAction & ACB_WRITE) { ZetOpen(0); ZetMapArea(0x4000, 0x7FFF, 0, RomZ80 + (DrvZ80Bank * 0x4000)); ZetMapArea(0x4000, 0x7FFF, 2, RomZ80 + (DrvZ80Bank * 0x4000)); ZetClose(); memcpy(MSM6295ROM + 0x00000, MSM6295ROMSrc + 0x20000 * DrvOkiBank1, 0x20000); memcpy(MSM6295ROM + 0x20000, MSM6295ROMSrc + 0x20000 * DrvOkiBank2, 0x20000); CaveRecalcPalette = 1; } } return 0; } static void DrvFMIRQHandler(int, int nStatus) { if (nStatus & 1) { ZetSetIRQLine(0xff, ZET_IRQSTATUS_ACK); } else { ZetSetIRQLine(0, ZET_IRQSTATUS_NONE); } } static int DrvSynchroniseStream(int nSoundRate) { return (long long)ZetTotalCycles() * nSoundRate / 4000000; } static double DrvGetTime() { return (double)ZetTotalCycles() / 4000000; } static int drvZInit() { ZetInit(1); ZetOpen(0); ZetSetInHandler(hotdogstZIn); ZetSetOutHandler(hotdogstZOut); ZetSetReadHandler(hotdogstZRead); ZetSetWriteHandler(hotdogstZWrite); // ROM bank 1 ZetMapArea (0x0000, 0x3FFF, 0, RomZ80 + 0x0000); // Direct Read from ROM ZetMapArea (0x0000, 0x3FFF, 2, RomZ80 + 0x0000); // Direct Fetch from ROM // ROM bank 2 ZetMapArea (0x4000, 0x7FFF, 0, RomZ80 + 0x4000); // Direct Read from ROM ZetMapArea (0x4000, 0x7FFF, 2, RomZ80 + 0x4000); // // RAM ZetMapArea (0xE000, 0xFFFF, 0, RamZ80); // Direct Read from RAM ZetMapArea (0xE000, 0xFFFF, 1, RamZ80); // Direct Write to RAM ZetMapArea (0xE000, 0xFFFF, 2, RamZ80); // ZetMemEnd(); ZetClose(); return 0; } static const UINT8 default_eeprom[16] = {0xF3,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; static int DrvInit() { int nLen; BurnSetRefreshRate(CAVE_REFRESHRATE); // Find out how much memory is needed Mem = NULL; MemIndex(); nLen = MemEnd - (unsigned char *)0; if ((Mem = (unsigned char *)malloc(nLen)) == NULL) { return 1; } memset(Mem, 0, nLen); // blank all memory MemIndex(); // Index the allocated memory EEPROMInit(&eeprom_interface_93C46); if (!EEPROMAvailable()) EEPROMFill(default_eeprom,0, sizeof(default_eeprom)); // Load the roms into memory if (LoadRoms()) { return 1; } { SekInit(0, 0x68000); // Allocate 68000 SekOpen(0); // Map 68000 memory: SekMapMemory(Rom01, 0x000000, 0x0FFFFF, SM_ROM); // CPU 0 ROM SekMapMemory(Ram01, 0x300000, 0x30FFFF, SM_RAM); SekMapMemory(CavePalSrc, 0x408000, 0x408FFF, SM_RAM); // Palette RAM SekMapMemory(CaveTileRAM[0], 0x880000, 0x887FFF, SM_RAM); SekMapMemory(CaveTileRAM[1], 0x900000, 0x907FFF, SM_RAM); SekMapMemory(CaveTileRAM[2], 0x980000, 0x987FFF, SM_RAM); SekMapMemory(CaveSpriteRAM, 0xf00000, 0xf0fFFF, SM_RAM); SekSetReadWordHandler(0, hotdogstReadWord); SekSetWriteWordHandler(0, hotdogstWriteWord); SekClose(); } drvZInit(); CavePalInit(0x8000); CaveTileInit(); CaveSpriteInit(2, 0x0800000); CaveTileInitLayer(0, 0x100000, 8, 0); CaveTileInitLayer(1, 0x100000, 8, 0); CaveTileInitLayer(2, 0x100000, 8, 0); nCaveExtraXOffset = -32; nCaveExtraYOffset = 32; BurnYM2203Init(1, 4000000, &DrvFMIRQHandler, DrvSynchroniseStream, DrvGetTime, 0); BurnTimerAttachZet(4000000); memcpy(MSM6295ROM, MSM6295ROMSrc, 0x40000); MSM6295Init(0, 1056000 / 132, 50.0, 1); bDrawScreen = true; #if defined FBA_DEBUG && defined USE_SPEEDHACKS bprintf(PRINT_IMPORTANT, " * Using speed-hacks (detecting idle loops).\n"); #endif DrvDoReset(); // Reset machine return 0; } // Rom information static struct BurnRomInfo hotdogstRomDesc[] = { { "mp3u29", 0x080000, 0x1f4e5479, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "mp4u28", 0x080000, 0x6f1c3c4b, BRF_ESS | BRF_PRG }, // 1 { "mp2u19", 0x040000, 0xff979ebe, BRF_ESS | BRF_PRG }, // 2 Z80 Code { "mp9u55", 0x200000, 0x258d49ec, BRF_GRA }, // 3 Sprite data { "mp8u54", 0x200000, 0xbdb4d7b8, BRF_GRA }, // 4 { "mp7u56", 0x080000, 0x87c21c50, BRF_GRA }, // 5 Layer 0 Tile data { "mp6u61", 0x080000, 0x4dafb288, BRF_GRA }, // 6 Layer 1 Tile data { "mp5u64", 0x080000, 0x9b26458c, BRF_GRA }, // 7 Layer 2 Tile data { "mp1u65", 0x080000, 0x4868be1b, BRF_SND }, // 8 MSM6295 #1 ADPCM data { "eeprom-hotdogst.bin", 0x0080, 0x12b4f934, BRF_OPT }, }; STD_ROM_PICK(hotdogst) STD_ROM_FN(hotdogst) struct BurnDriver BurnDrvhotdogst = { "hotdogst", NULL, NULL, "1996", "Hotdog Storm (International)\0", NULL, "Marble", "Cave", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_16BIT_ONLY, 2, HARDWARE_CAVE_68K_Z80, NULL, hotdogstRomInfo, hotdogstRomName, hotdogstInputInfo, NULL, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &CaveRecalcPalette, 240, 384, 3, 4 };
[ [ [ 1, 730 ] ] ]
2d64dff758f9e55f955d283a74c60896103e73f0
8fb9ccf49a324a586256bb08c22edc92e23affcf
/src/Engine/FilterLp06db.h
5fa0db13eefda9df6ec2ab31270b425e17fbfb3c
[]
no_license
eriser/tal-noisemak3r
76468c98db61dfa28315284b4a5b1acfeb9c1ff6
1043c8f237741ea7beb89b5bd26243f8891cb037
refs/heads/master
2021-01-18T18:29:56.446225
2010-08-05T20:51:35
2010-08-05T20:51:35
62,891,642
1
0
null
null
null
null
UTF-8
C++
false
false
4,092
h
/* ============================================================================== This file is part of Tal-NoiseMaker by Patrick Kunz. Copyright(c) 2005-2010 Patrick Kunz, TAL Togu Audio Line, Inc. http://kunz.corrupt.ch This file may be licensed under the terms of of the GNU General Public License Version 2 (the ``GPL''). Software distributed under the License is distributed on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the GPL for the specific language governing rights and limitations. You should have received a copy of the GPL along with this program. If not, go to http://www.gnu.org/licenses/gpl.html or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ============================================================================== */ #ifndef __FilterLp06db_h_ #define __FilterLp06db_h_ #include "OscNoise.h" class FilterLp06db { public: private: float pi; float v2, iv2; float ay1, ay2, ay3, ay4, amf; float az1, az2, az3, az4; float at1, at2, at3, at4; float kfc, kfcr, kacr, k2vg, k2vgNoisy; // temporary variables float tmp; float sampleRateFactor, cutoffInOld; float resonanceInOld; float resonanceCorrPre; float resonanceCorrPost; OscNoise *oscNoise; public: FilterLp06db(float sampleRate) { pi= 3.1415926535f; v2= 2.0f; // twice the 'thermal voltage of a transistor' iv2= 1.0f/v2; cutoffInOld = -1.0f; resonanceInOld = -1.0f; sampleRateFactor= 44100.0f/sampleRate; if (sampleRateFactor > 1.0f) { sampleRateFactor= 1.0f; } oscNoise = new OscNoise(sampleRate); reset(); } public: void reset() { az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f; at1= at2= at3 = at4 = 0.0f; } inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff) { // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo if (resonanceInOld != resonance) { resonanceInOld = resonance; float resonanceInverted = 1.0f - resonance; float invertedSquare = resonanceInverted * resonanceInverted; resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f; resonanceCorrPost = 1.0f + resonance * 1.1f; } *input *= resonanceCorrPre; // Resonance [0..1] // Cutoff from 0 (0Hz) to 1 (nyquist) if (calcCeff && cutoffIn != cutoffInOld) { cutoffInOld = cutoffIn; kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction // Frequency & amplitude correction kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f; kacr = 1.0f + 0.8f * cutoffIn; tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f)); } float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn); k2vgNoisy = k2vg + rnd1 * cutoffIn; float inWithRes = *input - 4.2f * resonance * amf * kacr; ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1); at1 = ay1; ay2 = az2 + k2vgNoisy * (at1-at2); at2 = ay2; ay3 = az3 + k2vgNoisy * (at2-at3); at3 = ay3; ay4 = az4 + k2vgNoisy * (at3-at4); at4 = ay4; az1 = ay1; az2 = ay2; az3 = ay3; az4 = ay4; // 1/2-sample delay for phase compensation amf = ay4; // * 0.625f + az4 * 0.375f; amf = tanhClipper(amf); if (amf > 0.0f) { amf *= 0.99f; } *input = tanhClipper(at1) * (resonanceCorrPost + cutoffIn * resonance * 1.5f); } inline float tanhApp(const float x) { return x; } inline float tanhClipper(float x) { // return tanh(x); x *= 2.0f; float a = fabs(x); float b = 6.0f+a*(3.0f+a); return (x*b)/(a*b+12.0f); } }; #endif
[ "patrickkunzch@1672e8fc-9579-4a43-9460-95afed9bdb0b" ]
[ [ [ 1, 158 ] ] ]
ff453d6eaa6c69c85fbff005884d249937b518bf
3187b0dd0d7a7b83b33c62357efa0092b3943110
/src/dlib/threads/threads_kernel_shared.cpp
3e2031d4aa306b83a6e1c8e68fba309e6bc1a5a2
[ "BSL-1.0" ]
permissive
exi/gravisim
8a4dad954f68960d42f1d7da14ff1ca7a20e92f2
361e70e40f58c9f5e2c2f574c9e7446751629807
refs/heads/master
2021-01-19T17:45:04.106839
2010-10-22T09:11:24
2010-10-22T09:11:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,113
cpp
// Copyright (C) 2003 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_THREADS_KERNEL_SHARED_CPp_ #define DLIB_THREADS_KERNEL_SHARED_CPp_ #include "threads_kernel_shared.h" #include "../assert.h" #include <iostream> #ifndef DLIB_THREAD_POOL_TIMEOUT // default to 30000 milliseconds #define DLIB_THREAD_POOL_TIMEOUT 30000 #endif namespace dlib { // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // threader functions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- namespace threads_kernel_shared { threader& thread_pool ( ) { static threader thread_pool; return thread_pool; } // ---------------------------------------------------------------------------------------- bool threader:: is_dlib_thread ( thread_id_type id ) { auto_mutex M(data_mutex); return thread_ids.is_member(id); } // ---------------------------------------------------------------------------------------- threader:: threader ( ) : total_count(0), pool_count(0), data_ready(data_mutex), data_empty(data_mutex), destruct(false), destructed(data_mutex) {} // ---------------------------------------------------------------------------------------- threader:: ~threader ( ) { data_mutex.lock(); destruct = true; data_ready.broadcast(); member_function_pointer<>::kernel_1a mfp; // call all the handlers for anything that has registered for this event while(queue_of_enders.size()) { queue_of_enders.dequeue(mfp); data_mutex.unlock(); mfp(); data_mutex.lock(); } // wait for all the threads to end while (total_count > 0) destructed.wait(); data_mutex.unlock(); } // ---------------------------------------------------------------------------------------- void threader:: add_ender ( member_function_pointer<>::kernel_1a mfp ) { auto_mutex M(data_mutex); queue_of_enders.enqueue(mfp); } // ---------------------------------------------------------------------------------------- void threader:: call_end_handlers ( ) { reg.m.lock(); const thread_id_type id = get_thread_id(); thread_id_type id_copy; unsigned long count = reg.reg.count(id); member_function_pointer<>::kernel_1a mfp; // Remove all the member function pointers for this thread from the tree // and call them. for (unsigned long i = 0; i < count; ++i) { reg.reg.remove(id,id_copy,mfp); reg.m.unlock(); mfp(); reg.m.lock(); } reg.m.unlock(); } // ------------------------------------------------------------------------------------ bool threader:: create_new_thread ( void (*funct)(void*), void* param ) { // get a lock on the data mutex auto_mutex M(data_mutex); // loop to ensure that the new function poitner is in the data while (true) { // if the data is empty then add new data and quit loop if (function_pointer == 0) { parameter = param; function_pointer = funct; break; } else { // wait for data to become empty data_empty.wait(); } } // get a thread for this new data // if a new thread must be crated if (pool_count == 0) { // make thread and add it to the pool if ( threads_kernel_shared_helpers::spawn_thread(thread_starter, this) == false ) { function_pointer = 0; parameter = 0; data_empty.signal(); return false; } ++total_count; } // wake up a thread from the pool else { data_ready.signal(); } return true; } // ------------------------------------------------------------------------------------ void thread_starter ( void* object ) { // get a reference to the calling threader object threader& self = *reinterpret_cast<threader*>(object); auto_mutex M(self.data_mutex); // add this thread id thread_id_type thread_id = get_thread_id(); self.thread_ids.add(thread_id); // indicate that this thread is now in the thread pool ++self.pool_count; while (true) { // if data is ready then process it and launch the thread // if its not ready then go back into the pool while (self.function_pointer != 0) { // indicate that this thread is now out of the thread pool --self.pool_count; // get the data for the function call void (*funct)(void*) = self.function_pointer; void* param = self.parameter; self.function_pointer = 0; // signal that the data is now empty self.data_empty.signal(); self.data_mutex.unlock(); // call funct with its intended parameter try { funct(param); self.call_end_handlers(); } catch (std::exception& e) { std::cerr << "An exception was thrown in a thread and was not caught. Its what() string is:\n" << e.what() << std::endl; self.data_mutex.lock(); --self.total_count; self.destructed.signal(); self.data_mutex.unlock(); abort(); } catch (...) { std::cerr << "An exception was thrown in a thread and was not caught." << std::endl; self.data_mutex.lock(); --self.total_count; self.destructed.signal(); self.data_mutex.unlock(); abort(); } self.data_mutex.lock(); // indicate that this thread is now back in the thread pool ++self.pool_count; } if (self.destruct == true) break; // if we timed out and there isn't any work to do then // this thread will quit this loop and end. if (self.data_ready.wait_or_timeout(DLIB_THREAD_POOL_TIMEOUT) == false && self.function_pointer == 0) break; } // remove this thread id from thread_ids thread_id = get_thread_id(); self.thread_ids.destroy(thread_id); // indicate that this thread is now out of the thread pool --self.pool_count; --self.total_count; self.destructed.signal(); } // ------------------------------------------------------------------------------------ } // ---------------------------------------------------------------------------------------- bool is_dlib_thread ( thread_id_type id ) { return threads_kernel_shared::thread_pool().is_dlib_thread(id); } // ---------------------------------------------------------------------------------------- } #endif // DLIB_THREADS_KERNEL_SHARED_CPp_
[ [ [ 1, 287 ] ] ]
36543204683666f0484bf1a9a48ec2dad661aedf
8a88075abf60e213a490840bebee97df01b8827a
/implementation/geometry/include/geometry/impl/enablers.hpp
9cc53a23ed3aa9c63e1e74bb1db8cacfa7071b88
[]
no_license
DavidGeorge528/minigeolib
e078f1bbc874c09584ae48e1c269f5f90789ebfb
58233609203953acf1c0346cd48950d2212b8922
refs/heads/master
2020-05-20T09:36:53.921996
2009-04-23T16:25:30
2009-04-23T16:25:30
33,925,133
0
1
null
null
null
null
UTF-8
C++
false
false
941
hpp
#ifndef GEOMETRY_IMPL_ENABLERS_HPP #define GEOMETRY_IMPL_ENABLERS_HPP #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_same.hpp> namespace geometry { namespace impl { template< typename CS, typename Tag> struct is_system_type { BOOST_STATIC_CONSTANT( bool, value = (boost::is_same< Tag, typename CS::system_type>::value)); }; template< typename CS, unsigned D> struct has_dimensions { BOOST_STATIC_CONSTANT( bool, value = (CS::DIMENSIONS == D)); }; template< typename E, typename Tag> struct is_a { BOOST_STATIC_CONSTANT( bool, value = (boost::is_same< Tag, typename E::tag>::value)); }; template< typename CS, unsigned D, typename CSType, typename OutType = void> struct enabled_for: public boost::enable_if_c< has_dimensions<CS,D>::value && is_system_type< CS, CSType>::value, OutType> {}; } } // namespace impl // namespace geometry #endif // GEOMETRY_IMPL_ENABLERS_HPP
[ "cpitis@834bb202-e8be-11dd-9d8c-a70aa0a93a20" ]
[ [ [ 1, 35 ] ] ]
774c753b134c41ba22d7075b5574cf8020077d08
891e876aafde31b093ff8a67907c4b36a1e632b2
/common/LibHeaders/Indie.h
0aad870b7065f4650645157c3883a2a6fb19f134
[]
no_license
aramande/Nirena
fc51d8768e9a9fb7e44dd6fadf726ed3fc1d51c8
1e7299ee4915ab073dc7c64569789a07769e71be
refs/heads/master
2021-01-18T20:17:52.943977
2010-12-04T00:05:10
2010-12-04T00:05:10
1,217,641
0
0
null
null
null
null
ISO-8859-2
C++
false
false
1,847
h
/***************************************************************************************** /* File: IndieLib.h /* Desc: Includes /*****************************************************************************************/ #ifndef _INDIELIB_ #define _INDIELIB_ /* IndieLib 2d library Copyright (C) 2005 Javier López López ([email protected]) 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. 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 */ // Namespace #include <windows.h> #include <fstream> using namespace std; // Defines and types #include "Defines.h" // Init/End #include "IndieLib.h" // Display #include "IND_Window.h" // Render #include "IND_Render.h" // Timer #include "IND_Timer.h" // Math #include "IND_Math.h" // Entities #include "IND_Entity2dManager.h" #include "IND_Entity3dManager.h" // Input #include "IND_Input.h" // 2d Objects #include "IND_ImageManager.h" #include "IND_SurfaceManager.h" #include "IND_AnimationManager.h" #include "IND_FontManager.h" // 3d Objects #include "IND_3dMeshManager.h" // Cameras #include "IND_Camera2d.h" #include "IND_Camera3d.h" // Common #include "IND_LightManager.h" #endif // _INDIELIB_
[ [ [ 1, 73 ] ] ]
155667f9655b006b43dc79e68e40d7260af08395
53ee90fbc1011cb17ba013d0a49812697d4e6130
/MootoritePlaat/OmniMotion/CHolonomicWheels.cpp
5c36ec6f68327927c474347c165d29b8dafda691
[]
no_license
janoschtraumstunde/Robin
c3f68667c37c44e19473119b4b9b9be0fe2fb57f
bd691cbd2a0091e5100df5dfe1268d27c99b39f6
refs/heads/master
2021-01-12T14:06:44.095094
2010-12-09T14:34:27
2010-12-09T14:34:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,876
cpp
#include "CHolonomicWheels.h" HolonomicWheels::HolonomicWheels(Motor& left, Motor& right, Motor& back, MagnetSensor& leftMagnet, MagnetSensor& rightMagnet, MagnetSensor& backMagnet) : motorLeft(left), motorRight(right), motorBack(back), magnetLeft(leftMagnet), magnetRight(rightMagnet), magnetBack(backMagnet) { } void HolonomicWheels::Update() { //Acceleration(); InverseKinematics(); PidControl(); } void HolonomicWheels::Hold(enum Axis axis, bool hold) { AxisData axisData = GetAxisData(axis); axisData.isHolding = true; } void HolonomicWheels::ForwardKinematics() { const long sqrt3 = 1732; // sqrt(3) = 1.73205081 int x = ((sqrt3 * magnetLeft.speed) - (sqrt3 * magnetRight.speed)) / 3000; // (3 * 1000) int y = (magnetLeft.speed + magnetRight.speed - (2 * magnetBack.speed)) / 3; int rotation = (magnetLeft.speed + magnetRight.speed + magnetBack.speed) / 3; } void HolonomicWheels::InverseKinematics() { int velX, velY, rotation; long temp1 = (-500 * velX) / 1000; long temp2 = (866 * velY) / 1000; long speedLeft = (temp1 - temp2) + rotation; long speedRight = (temp1 + temp2) + rotation; long speedBack = velX + rotation; } void HolonomicWheels::Acceleration() { } void HolonomicWheels::SetPidGains(unsigned int p, unsigned int i, unsigned int d) { pGain = p; iGain = i; dGain = d; } void HolonomicWheels::PidControl() { int position = magnetLeft.speed; int error = leftSetpoint - position; int pwm = pGain * error + dGain * (error - errorPrevious); if (iGain) { pwm += iGain * errorIntegral; errorIntegral += error; } errorPrevious = error; motorLeft.setSpeed(pwm); } AxisData& HolonomicWheels::GetAxisData(enum Axis axis) { switch(axis) { default: case X: return axisX; case Y: return axisY; case ROTATION: return axisRotation; } }
[ [ [ 1, 74 ] ] ]
2316187b7193edc910feedad4afa9bbb0937f6f5
8902879a2619a8278c4dd064f62d8e0e8ffb4e3b
/UIlib/UIActiveX.h
fbb101d9c5c19821f0cac43275c1a5c1de1f0e5a
[ "BSD-2-Clause" ]
permissive
ArnCarveris/directui
4d9911143db125dfb114ca97a70f426dbd89dd79
da531f8bc7737f932c960906cc5f4481a0e162b8
refs/heads/master
2023-03-17T00:59:28.853973
2011-05-19T02:38:42
2011-05-19T02:38:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,267
h
#if !defined(AFX_UIACTIVEX_H__20060223_0330_20DB_3F74_0080AD509054__INCLUDED_) #define AFX_UIACTIVEX_H__20060223_0330_20DB_3F74_0080AD509054__INCLUDED_ class ActiveXCtrl; struct IOleObject; class UILIB_API ActiveXUI : public ControlUI, public IMessageFilterUI { friend ActiveXCtrl; public: ActiveXUI(); virtual ~ActiveXUI(); virtual const char* GetClass() const; bool CreateControl(const CLSID clsid); bool CreateControl(const char* pstrCLSID); HRESULT GetControl(const IID iid, LPVOID* ppRet); void SetWidth(int cx); void SetHeight(int cy); virtual void SetPos(RECT rc); virtual SIZE EstimateSize(SIZE szAvailable); virtual void DoPaint(HDC hDC, const RECT& rcPaint); virtual void SetAttribute(const char* name, const char* value); virtual LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled); protected: void ReleaseControl(); bool DelayedControlCreation(); protected: CLSID m_clsid; bool m_bCreated; IOleObject* m_pUnk; ActiveXCtrl* m_ctrl; HWND m_hwndHost; SIZE m_szFixed; }; #endif // !defined(AFX_UIACTIVEX_H__20060223_0330_20DB_3F74_0080AD509054__INCLUDED_)
[ [ [ 1, 44 ] ] ]
e0f3ac8fed8089923f3fe2808e4472d1db3e55cc
cb6bc528c9f07375cdd93de4eab1ae963bd9d4ac
/Xedithor/src/hlinegraphicsitem.cpp
0559229d6b9eefee1629608f8ca50be30127ff4e
[]
no_license
xedixermawan/xedithor
9a867b975e6bea5a42a3bc2a9196e82ff9bbb14c
73ea074c2c06a9ea4f1e6305a58dcb7b54b04a4b
refs/heads/master
2016-09-06T14:26:44.552920
2011-12-14T06:18:57
2011-12-14T06:18:57
2,930,606
0
0
null
null
null
null
UTF-8
C++
false
false
1,171
cpp
#include <QPainter> #include <math.h> #include "hlinegraphicsitem.h" #include <iostream> QRectF HLineGraphicsItem::boundingRect() const { qreal penWidth = 3; qreal extra = (penWidth ) / 2.0; return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(), destPoint.y() - sourcePoint.y())) .normalized() .adjusted(-extra, -extra, extra, extra); } void HLineGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QLineF line(sourcePoint, destPoint); painter->setPen(QPen(Qt::red, 1, Qt::DotLine, Qt::RoundCap, Qt::RoundJoin)); painter->drawLine(line); } void HLineGraphicsItem::setSourcePoint(QPointF& pointSrc) { sourcePoint=pointSrc; } void HLineGraphicsItem::setDestPoint(QPointF& pointDest) { destPoint=pointDest; } /* void HLineGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent* event) { std::cout<<"rect press event"<<std::endl; } void HLineGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { std::cout<<"rect release event"<<std::endl; } */
[ [ [ 1, 51 ] ] ]
27079021b45429e0d5f06bffb50b1b35506d9b14
a51ac532423cf58c35682415c81aee8e8ae706ce
/MachineAPI/MachineDotDispenceCommand.h
c5bc38519a31162ddb358d5c5b95e0960bd5bbf5
[]
no_license
anderslindmark/PickNPlace
b9a89fb2a6df839b2b010b35a0c873af436a1ab9
00ca4f6ce2ecfeddfea7db5cb7ae8e9d0023a5e1
refs/heads/master
2020-12-24T16:59:20.515351
2008-05-25T01:32:31
2008-05-25T01:32:31
34,914,321
1
0
null
null
null
null
UTF-8
C++
false
false
1,110
h
/** \file MachineDotDispenceCommand.h \brief Header file for the MachineDotDispenceCommand class \author Henrik Mäkitaavola & Anders Lindmark **/ #ifndef __MACHINEDOTDISPENCECOMMAND_H__ #define __MACHINEDOTDISPENCECOMMAND_H__ #include "machinecommand.h" /// \class MachineDotDispenceCommand /// \brief Dispence a dot of paste at the specified coordinates class MachineDotDispenceCommand : public MachineCommand { MACHINE_COMMAND_FRIENDS; public: /// \brief Constructor. /// /// \param dotX X position where the dot should be placed /// \param dotY Y position where the dot should be placed MachineDotDispenceCommand(int dotX, int dotY); /// \brief Destructor. ~MachineDotDispenceCommand(void); string ToString(); MachineState GetAfterState(MachineState &oldms); private: int m_x; ///< The x position of the dot int m_y; ///< The y position of the dot MachineStateStruct m_state; ///< Stores a copy of the machine state MachineDotDispenceCommand *Copy(); bool DoCommand(SerialPort &sp); }; #endif // __MACHINEDOTDISPENCECOMMAND_H__
[ "anders@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7", "henmak-4@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7" ]
[ [ [ 1, 12 ], [ 14, 16 ], [ 43, 44 ] ], [ [ 13, 13 ], [ 17, 42 ] ] ]
186610d8cbecd78f12f3f8e74bb18699cd0bfac3
6712f8313dd77ae820aaf400a5836a36af003075
/check_ths8200.cpp
40e608a559f54313dc4c01e1eead3fa4ddd36506
[]
no_license
AdamTT1/bdScript
d83c7c63c2c992e516dca118cfeb34af65955c14
5483f239935ec02ad082666021077cbc74d1790c
refs/heads/master
2021-12-02T22:57:35.846198
2010-08-08T22:32:02
2010-08-08T22:32:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,084
cpp
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <sys/errno.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <ctype.h> //#include <asm/types.h> typedef unsigned short __u16; typedef unsigned char __u8; #include <string.h> #include <ctype.h> #include "physMem.h" #define VENC_BASE 0x01c72000 #define VENC_HINT 0x01c72418 #define VENC_VINT 0x01c72424 #define PAGE_SIZE 4096 inline unsigned long readLong(physMem_t &pm, unsigned long reg) { unsigned offs = reg-VENC_BASE ; if( offs >= PAGE_SIZE ){ fprintf( stderr, "Invalid register 0x%x\n", reg ); exit(-1); } void const *p = (char *)pm.ptr() + offs ; unsigned long rval ; memcpy(&rval,p,sizeof(rval)); return rval ; } #define READLONG(addr) *((unsigned long *) char const hexCharSet[] = "0123456789abcdef"; unsigned getByte(char *readfile, int fdwrite, int reg) { int fdread; int rval; int val; char buf[16]; buf[0] = hexCharSet[(reg >> 4) & 0xf]; buf[1] = hexCharSet[reg & 0xf]; buf[2] = 0; if (write(fdwrite, buf, 2) != 2) { printf("error selecting register %02x(%s)\n", reg, strerror(errno)); return ~0; } if ((fdread = open(readfile, O_RDONLY)) < 0) { printf("error opening %s(%s)\n", readfile, strerror(errno)); return ~0; } rval = read(fdread, buf, 15); close(fdread); if (rval != 3) { printf("error reading register %02x(%s)%i\n", reg, strerror(errno), rval); printf("%s\n", buf); return ~0; } rval = sscanf(buf, "%x", &val); if (rval != 1) { printf("error parsing register %02x(%s)%i\n", reg, strerror(errno), rval); return ~0; } return val; } int main(void) { unsigned long ths_hint, ths_vint; int fdwrite; int adapter_nr = 1; /* probably dynamically determined */ char filename[80]; sprintf(filename,"/sys/class/i2c-adapter/i2c-%d/1-0021/write",adapter_nr); if ((fdwrite = open(filename,O_WRONLY)) < 0) { printf("error opening %s(%s)\n",filename,strerror(errno)); return -1 ; } sprintf(filename,"/sys/class/i2c-adapter/i2c-%d/1-0021/read",adapter_nr); physMem_t venc_regs( VENC_BASE, PAGE_SIZE, O_RDWR ); if( !venc_regs.worked() ){ fprintf(stderr, "Error mapping venc regs\n" ); return -1 ; } unsigned venc_hint = readLong(venc_regs,VENC_HINT); unsigned venc_vint = readLong(venc_regs,VENC_VINT); ths_hint = (getByte(filename, fdwrite, 0x34) << 8) | getByte(filename, fdwrite, 0x35); ths_vint = (((getByte(filename, fdwrite, 0x39) >> 4) & 7) << 8 ) | getByte(filename, fdwrite, 0x3a); close(fdwrite); printf( "VENC:\thint 0x%08lx, vint 0x%08lx\n", venc_hint, venc_vint ); printf( "THS:\thint 0x%08lx, vint 0x%08lx\n", ths_hint, ths_vint ); if ((venc_hint != (ths_hint-1)) || (venc_vint != (ths_vint-1)) ){ fprintf( stderr, "Invalid horizontal or vertical resolutions in THS8200\n" ); return -1 ; } return 0 ; }
[ "ericn", "[email protected]" ]
[ [ [ 1, 40 ], [ 74, 75 ], [ 78, 78 ], [ 82, 84 ], [ 87, 95 ], [ 100, 100 ], [ 104, 104 ], [ 106, 110 ] ], [ [ 41, 73 ], [ 76, 77 ], [ 79, 81 ], [ 85, 86 ], [ 96, 99 ], [ 101, 103 ], [ 105, 105 ] ] ]
8e6381b45d4605e37baaab2b4b2f93ea9d5fdb88
14447604061a3ded605cd609b44fec3979d9b1cc
/unittest/CacooDiagramTest.cpp
5610a4b6d743172b186c84d5cfaa9ef368abe973
[]
no_license
sinsoku/cacoon
459e441aacf4dc01311a6b5cd7eae2425fbf4c3f
36e81b689b53505c2d8117ff60ce8e4012d6eae6
refs/heads/master
2020-05-30T23:34:08.361671
2010-12-03T17:44:20
2010-12-03T17:44:20
809,470
0
0
null
null
null
null
UTF-8
C++
false
false
2,779
cpp
#include "stdafx.h" #include "CacooApi.h" #include "CacooDiagram.hpp" TEST(CacooDiagram, init) { char rawXmlData[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<diagram>" " <url>https://cacoo.com/diagrams/00e77f4dc9973517</url>" " <imageUrl>https://cacoo.com/diagrams/00e77f4dc9973517.png</imageUrl>" " <imageUrlForApi>https://cacoo.com/api/v1/diagrams/00e77f4dc9973517.png</imageUrlForApi>" " <diagramId>00e77f4dc9973517</diagramId>" " <title>shape1</title>" " <security>url</security>" " <ownerName>yoko</ownerName>" " <ownerNickname>Yoko</ownerNickname>" " <owner>" " <name>yoko</name>" " <nickname>Yoko</nickname>" " <imageUrl>https://cacoo.com/account/yoko/image/32x32</imageUrl>" " </owner>" " <editing>false</editing>" " <own>true</own>" " <shared>true</shared>" " <sheetCount>0</sheetCount>" " <created>Mon, 10 Aug 2009 17:00:00 +0900</created>" " <updated>Mon, 10 Aug 2009 17:00:00 +0900</updated>" "</diagram>"; boost::shared_ptr<TiXmlDocument> doc = CacooApi::parseXml(rawXmlData); CacooDiagram actual( doc->RootElement() ); time_t t = actual.getCreated(); struct tm* cal = localtime( &t ); EXPECT_EQ(2009, cal->tm_year + 1900); EXPECT_EQ(8, cal->tm_mon + 1); EXPECT_EQ(10, cal->tm_mday); EXPECT_EQ(17, cal->tm_hour); EXPECT_EQ(0, cal->tm_min); EXPECT_EQ(0, cal->tm_sec); time_t t2 = actual.getCreated(); struct tm* cal2 = localtime( &t2 ); EXPECT_EQ(2009, cal2->tm_year + 1900); EXPECT_EQ(8, cal2->tm_mon + 1); EXPECT_EQ(10, cal2->tm_mday); EXPECT_EQ(17, cal2->tm_hour); EXPECT_EQ(0, cal2->tm_min); EXPECT_EQ(0, cal2->tm_sec); } TEST(CacooDiagram, nullerror) { char rawXmlData[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<diagram>" " <url>https://cacoo.com/diagrams/00e77f4dc9973517</url>" " <imageUrl>https://cacoo.com/diagrams/00e77f4dc9973517.png</imageUrl>" " <imageUrlForApi>https://cacoo.com/api/v1/diagrams/00e77f4dc9973517.png</imageUrlForApi>" " <diagramId>00e77f4dc9973517</diagramId>" " <title></title>" " <security>url</security>" " <ownerName>yoko</ownerName>" " <ownerNickname>Yoko</ownerNickname>" " <owner>" " <name>yoko</name>" " <nickname>Yoko</nickname>" " <imageUrl>https://cacoo.com/account/yoko/image/32x32</imageUrl>" " </owner>" " <editing>false</editing>" " <own>true</own>" " <shared>true</shared>" " <sheetCount>0</sheetCount>" " <created>Mon, 10 Aug 2009 17:00:00 +0900</created>" " <updated>Mon, 10 Aug 2009 17:00:00 +0900</updated>" "</diagram>"; boost::shared_ptr<TiXmlDocument> doc = CacooApi::parseXml(rawXmlData); CacooDiagram actual( doc->RootElement() ); }
[ [ [ 1, 80 ] ] ]
6029411220a0f0be6b1899aab4b9c60d9f5b0aa9
a2ba072a87ab830f5343022ed11b4ac365f58ef0
/ urt-bumpy-q3map2 --username [email protected]/libs/cmdlib/cmdlib.cpp
1bcaafa2909957c7a5057490cb33217d44580747
[]
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
3,695
cpp
/* 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. */ // // start of shared cmdlib stuff // #include "cmdlib.h" #include <string.h> #include <stdio.h> #include "string/string.h" #include "os/path.h" #include "container/array.h" #ifdef WIN32 #include <windows.h> #endif #if defined (__linux__) || defined (__APPLE__) #include <unistd.h> #endif #if defined (__linux__) || defined (__APPLE__) bool Q_Exec(const char *cmd, char *cmdline, const char *, bool) { char fullcmd[2048]; char *pCmd; #ifdef _DEBUG printf("Q_Exec damnit\n"); #endif switch (fork()) { case -1: return true; break; case 0: // always concat the command on linux if (cmd) { strcpy(fullcmd, cmd); } else fullcmd[0] = '\0'; if (cmdline) { strcat(fullcmd, " "); strcat(fullcmd, cmdline); } pCmd = fullcmd; while (*pCmd == ' ') pCmd++; #ifdef _DEBUG printf("Running system...\n"); printf("Command: %s\n", pCmd); #endif system( pCmd ); #ifdef _DEBUG printf ("system() returned\n"); #endif _exit (0); break; } return true; } #endif #ifdef WIN32 // NOTE TTimo windows is VERY nitpicky about the syntax in CreateProcess bool Q_Exec(const char *cmd, char *cmdline, const char *execdir, bool bCreateConsole) { PROCESS_INFORMATION ProcessInformation; STARTUPINFO startupinfo = {0}; DWORD dwCreationFlags; GetStartupInfo (&startupinfo); if (bCreateConsole) dwCreationFlags = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS; else dwCreationFlags = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS; const char *pCmd; char *pCmdline; pCmd = cmd; if (pCmd) { while (*pCmd == ' ') pCmd++; } pCmdline = cmdline; if (pCmdline) { while (*pCmdline == ' ') pCmdline++; } if (CreateProcess( pCmd, pCmdline, NULL, NULL, FALSE, dwCreationFlags, NULL, execdir, &startupinfo, &ProcessInformation )) return true; return false; } #endif
[ [ [ 1, 133 ] ] ]
16694b5123cd3ecda339f102e59b43e6513c46cb
93eac58e092f4e2a34034b8f14dcf847496d8a94
/Recommender/LocalAgent/include/Context.h
590d8862012a31b10047f0e52b6f328295df15a4
[]
no_license
lince/ginga-srpp
f8154049c7e287573f10c472944315c1c7e9f378
5dce1f7cded43ef8486d2d1a71ab7878c8f120b4
refs/heads/master
2020-05-27T07:54:24.324156
2011-10-17T13:59:11
2011-10-17T13:59:11
2,576,332
0
0
null
null
null
null
UTF-8
C++
false
false
949
h
#ifndef _CONTEXT_H_ #define _CONTEXT_H_ #include <string> #include <ginga/recommender/utils/Utils.h> using namespace ::br::ufscar::lince::ginga::recommender::util; #include "Document.h" using namespace std; namespace br { namespace ufscar { namespace lince { namespace ginga { namespace recommender { class Context { private: static int idContext; string id; Context* context; Document* document; public: Context(string id, Context* context, Document* document); string generateSql(); int getIdContext(); static void setIdContext(int id); static void incIdContext(); string getId(); void setId(string id); Context* getContext(); void setContext(Context* context); Document* getDocument(); void setDocument(Document* document); }; } } } } } #endif /*_CONTEXT_H_*/
[ [ [ 1, 48 ] ] ]
053cdbb73ce73fb989f47b90a81bcca808db17c4
9b6eced5d80668bd4328a8f3d1f75c97f04f5e08
/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalcommand.h
09ecc258dfb15d44f6119bca3c7287dd6872f4b8
[]
no_license
SymbianSource/oss.FCL.sf.os.bt
3ca94a01740ac84a6a35718ad3063884ea885738
ba9e7d24a7fa29d6dd93808867c28bffa2206bae
refs/heads/master
2021-01-18T23:42:06.315016
2010-10-14T10:30:12
2010-10-14T10:30:12
72,765,157
1
0
null
null
null
null
UTF-8
C++
false
false
1,388
h
// Copyright (c) 2007-2010 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: // /** @file @internalComponent */ #ifndef HCTLUSBORIGINALCONTROL_H #define HCTLUSBORIGINALCONTROL_H #include <e32base.h> #include <d32usbdi.h> class MHCTLChannelObserver; /** Control pipe in the spec. defined USB transport is one way. */ NONSHARABLE_CLASS(CHCTLUsbOriginalCommand) : public CActive { public: static CHCTLUsbOriginalCommand* NewL(RUsbInterface& aInterface); ~CHCTLUsbOriginalCommand(); TInt Write(const TDesC8& aData); void SetChannelObserver(MHCTLChannelObserver& aObserver); private: CHCTLUsbOriginalCommand(RUsbInterface& aInterface); private: // from CActive virtual void RunL(); virtual void DoCancel(); private: MHCTLChannelObserver* iChannelObserver; RUsbInterface& iInterface; RUsbInterface::TUsbTransferRequestDetails iEp0Details; TBuf8<255> iRecvData; // TODO test if we can remove this. }; #endif // HCTLUSBORIGINALCONTROL_H
[ "none@none" ]
[ [ [ 1, 57 ] ] ]
eebad2fcd263badc7b9e6a47dc37bf14af0c9a9f
6e563096253fe45a51956dde69e96c73c5ed3c18
/dhnetsdk/TPLayer_IOCP/TPMulticastClient.h
d5761603bf633aca565c5ca7c50fbfc8c7f08a65
[]
no_license
15831944/phoebemail
0931b76a5c52324669f902176c8477e3bd69f9b1
e10140c36153aa00d0251f94bde576c16cab61bd
refs/heads/master
2023-03-16T00:47:40.484758
2010-10-11T02:31:02
2010-10-11T02:31:02
null
0
0
null
null
null
null
GB18030
C++
false
false
913
h
/* * Copyright (c) 2008, 浙江亿蛙技术股份有限公司 * All rights reserved. * * 文件名称:TPMulticastClient.h * 摘  要:多播客户端功能类 * * * 取代版本:0.1 * 原作者 :Peng Dongfeng * 完成日期:2008年8月6日 * 修订记录:创建 */ ////////////////////////////////////////////////////////////////////// #ifndef _TPMulticastClient_H_ #define _TPMulticastClient_H_ #include "TPUDPClient.h" class TPMulticastClient : public TPUDPClient { public: TPMulticastClient(ITPListener *callback, int engineId = 0); virtual ~TPMulticastClient(); public: /* 接口 */ virtual int Close(void); virtual int Connect(const char* szIp, int nPort); virtual int Connect(const char* szLocalIp, int nLocalPort, const char* szRemoteIp, int nRemotePort); private: SOCKET m_sockMultipoint; }; #endif // _TPMulticastClient_H_
[ "guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd" ]
[ [ [ 1, 41 ] ] ]
66e30208b2387fe04b589ca7e053f8a7c494df36
011359e589f99ae5fe8271962d447165e9ff7768
/src/burn/misc/pre90s/d_tigerheli.cpp
5276212dff010d9210a90d9e56174288dee1e8e9
[]
no_license
PS3emulators/fba-next-slim
4c753375fd68863c53830bb367c61737393f9777
d082dea48c378bddd5e2a686fe8c19beb06db8e1
refs/heads/master
2021-01-17T23:05:29.479865
2011-12-01T18:16:02
2011-12-01T18:16:02
2,899,840
1
0
null
null
null
null
UTF-8
C++
false
false
69,281
cpp
// Tiger Heli, Get Star / Guardian, & Slap Fight #include "burnint.h" #include "../../taito/taito_m68705.h" #include "driver.h" extern "C" { #include "ay8910.h" } static int nWhichGame; static bool bInterruptEnable; static bool bSoundCPUEnable; static bool bSoundNMIEnable; static int nStatusIndex; static int nProtectIndex; // --------------------------------------------------------------------------- // Inputs static unsigned char tigerhInput[4] = {0,0,0,0}; static unsigned char tigerhInpJoy1[8]; static unsigned char tigerhInpMisc[8]; static unsigned char tigerhReset = 0; // Dip Switch and Input Definitions static struct BurnInputInfo tigerhInputList[] = { {"P1 Coin", BIT_DIGITAL, tigerhInpMisc + 6, "p1 coin"}, {"P1 Start", BIT_DIGITAL, tigerhInpMisc + 4, "p1 start"}, {"P1 Up", BIT_DIGITAL, tigerhInpJoy1 + 0, "p1 up"}, {"P1 Down", BIT_DIGITAL, tigerhInpJoy1 + 1, "p1 down"}, {"P1 Left", BIT_DIGITAL, tigerhInpJoy1 + 3, "p1 left"}, {"P1 Right", BIT_DIGITAL, tigerhInpJoy1 + 2, "p1 right"}, {"P1 Button 1", BIT_DIGITAL, tigerhInpMisc + 1, "p1 fire 1"}, {"P1 Button 2", BIT_DIGITAL, tigerhInpMisc + 0, "p1 fire 2"}, {"P2 Coin", BIT_DIGITAL, tigerhInpMisc + 7, "p2 coin"}, {"P2 Start", BIT_DIGITAL, tigerhInpMisc + 5, "p2 start"}, {"P2 Up", BIT_DIGITAL, tigerhInpJoy1 + 4, "p2 up"}, {"P2 Down", BIT_DIGITAL, tigerhInpJoy1 + 5, "p2 down"}, {"P2 Left", BIT_DIGITAL, tigerhInpJoy1 + 7, "p2 left"}, {"P2 Right", BIT_DIGITAL, tigerhInpJoy1 + 6, "p2 right"}, {"P2 Button 1", BIT_DIGITAL, tigerhInpMisc + 3, "p2 fire 1"}, {"P2 Button 2", BIT_DIGITAL, tigerhInpMisc + 2, "p2 fire 2"}, {"Reset", BIT_DIGITAL, &tigerhReset, "reset"}, {"Dip A", BIT_DIPSWITCH, tigerhInput + 2, "dip"}, {"Dip B", BIT_DIPSWITCH, tigerhInput + 3, "dip"}, }; STDINPUTINFO(tigerh) static struct BurnInputInfo gtstarbaInputList[] = { {"P1 Coin", BIT_DIGITAL, tigerhInpMisc + 6, "p1 coin"}, {"P1 Start", BIT_DIGITAL, tigerhInpMisc + 4, "p1 start"}, {"P1 Up", BIT_DIGITAL, tigerhInpJoy1 + 0, "p1 up"}, {"P1 Down", BIT_DIGITAL, tigerhInpJoy1 + 2, "p1 down"}, {"P1 Left", BIT_DIGITAL, tigerhInpJoy1 + 3, "p1 left"}, {"P1 Right", BIT_DIGITAL, tigerhInpJoy1 + 1, "p1 right"}, {"P1 Button 1", BIT_DIGITAL, tigerhInpMisc + 1, "p1 fire 1"}, {"P1 Button 2", BIT_DIGITAL, tigerhInpMisc + 0, "p1 fire 2"}, {"P2 Coin", BIT_DIGITAL, tigerhInpMisc + 7, "p2 coin"}, {"P2 Start", BIT_DIGITAL, tigerhInpMisc + 5, "p2 start"}, {"P2 Up", BIT_DIGITAL, tigerhInpJoy1 + 4, "p2 up"}, {"P2 Down", BIT_DIGITAL, tigerhInpJoy1 + 6, "p2 down"}, {"P2 Left", BIT_DIGITAL, tigerhInpJoy1 + 7, "p2 left"}, {"P2 Right", BIT_DIGITAL, tigerhInpJoy1 + 5, "p2 right"}, {"P2 Button 1", BIT_DIGITAL, tigerhInpMisc + 3, "p2 fire 1"}, {"P2 Button 2", BIT_DIGITAL, tigerhInpMisc + 2, "p2 fire 2"}, {"Reset", BIT_DIGITAL, &tigerhReset, "reset"}, {"Dip A", BIT_DIPSWITCH, tigerhInput + 2, "dip"}, {"Dip B", BIT_DIPSWITCH, tigerhInput + 3, "dip"}, }; STDINPUTINFO(gtstarba) static struct BurnDIPInfo tigerhDIPList[] = { // Defaults {0x11, 0xFF, 0xFF, 0x10, NULL}, {0x12, 0xFF, 0xFF, 0x00, NULL}, // DIP A {0, 0xFE, 0, 2, "Hero speed"}, {0x11, 0x01, 0x80, 0x00, "Normal"}, {0x11, 0x01, 0x80, 0x80, "Fast"}, {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x40, 0x00, "Normal game"}, {0x11, 0x01, 0x40, 0x40, "DIP switch test"}, {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x20, 0x00, "Normal screen"}, {0x11, 0x01, 0x20, 0x20, "Invert screen"}, {0, 0xFE, 0, 2, "Cabinet"}, {0x11, 0x01, 0x10, 0x10, "Upright"}, {0x11, 0x01, 0x10, 0x00, "Table"}, {0, 0xFE, 0, 2, "Advertise sound"}, {0x11, 0x01, 0x08, 0x00, "On"}, {0x11, 0x01, 0x08, 0x08, "Off"}, {0, 0xFE, 0, 7, "Coinage"}, {0x11, 0x01, 0x07, 0x00, "1 coin 1 credit"}, {0x11, 0x01, 0x07, 0x01, "1 coin 2 credits"}, {0x11, 0x01, 0x07, 0x02, "1 coin 3 credits"}, {0x11, 0x01, 0x07, 0x03, "2 coins 1 credit"}, {0x11, 0x01, 0x07, 0x04, "2 coins 3 credits"}, {0x11, 0x01, 0x07, 0x05, "3 coins 1 credit"}, {0x11, 0x01, 0x07, 0x07, "Free play"}, {0x11, 0x01, 0x07, 0x06, "3 coins 1 credit"}, // DIP B {0, 0xFE, 0, 2, "Extend"}, {0x12, 0x01, 0x10, 0x00, "20000 & 80000"}, {0x12, 0x01, 0x10, 0x10, "50000 & 120000"}, {0, 0xFE, 0, 4, "Game difficulty"}, {0x12, 0x01, 0x0C, 0x00, "0"}, {0x12, 0x01, 0x0C, 0x04, "1"}, {0x12, 0x01, 0x0C, 0x08, "2"}, {0x12, 0x01, 0x0C, 0x0C, "3"}, {0, 0xFE, 0, 4, "Number of heroes"}, {0x12, 0x01, 0x03, 0x00, "3"}, {0x12, 0x01, 0x03, 0x01, "5"}, {0x12, 0x01, 0x03, 0x02, "1"}, {0x12, 0x01, 0x03, 0x03, "2"}, }; STDDIPINFO(tigerh) static struct BurnDIPInfo getstarDIPList[] = { // Defaults {0x11, 0xFF, 0xFF, 0x10, NULL}, // DIP A {0, 0xFE, 0, 2, "Hero speed"}, // really work? {0x11, 0x01, 0x80, 0x00, "Normal"}, {0x11, 0x01, 0x80, 0x80, "Fast"}, {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x40, 0x00, "Normal game"}, {0x11, 0x01, 0x40, 0x40, "DIP switch test"}, {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x20, 0x00, "Normal screen"}, {0x11, 0x01, 0x20, 0x20, "Invert screen"}, {0, 0xFE, 0, 2, "Cabinet"}, {0x11, 0x01, 0x10, 0x10, "Upright"}, {0x11, 0x01, 0x10, 0x00, "Table"}, {0, 0xFE, 0, 2, "Advertise sound"}, {0x11, 0x01, 0x08, 0x00, "On"}, {0x11, 0x01, 0x08, 0x08, "Off"}, {0, 0xFE, 0, 7, "Coinage"}, {0x11, 0x01, 0x07, 0x00, "1 coin 1 credit"}, {0x11, 0x01, 0x07, 0x01, "1 coin 2 credits"}, {0x11, 0x01, 0x07, 0x02, "1 coin 3 credits"}, {0x11, 0x01, 0x07, 0x03, "2 coins 1 credit"}, {0x11, 0x01, 0x07, 0x04, "2 coins 3 credits"}, {0x11, 0x01, 0x07, 0x05, "3 coins 1 credit"}, {0x11, 0x01, 0x07, 0x07, "Free play"}, {0x11, 0x01, 0x07, 0x06, "3 coins 1 credit"}, // DIP B {0, 0xFE, 0, 2, "Extend"}, {0x12, 0x01, 0x10, 0x00, "30000 & 100000"}, {0x12, 0x01, 0x10, 0x10, "50000 & 150000"}, {0, 0xFE, 0, 4, "Game difficulty"}, {0x12, 0x01, 0x0C, 0x00, "0"}, {0x12, 0x01, 0x0C, 0x04, "1"}, {0x12, 0x01, 0x0C, 0x08, "2"}, {0x12, 0x01, 0x0C, 0x0C, "3"}, }; static struct BurnDIPInfo getstarHeroesDIPList[] = { // Defaults {0x12, 0xFF, 0xFF, 0x01, NULL}, // DIP B {0, 0xFE, 0, 4, "Number of heroes"}, {0x12, 0x01, 0x03, 0x01, "3"}, {0x12, 0x01, 0x03, 0x02, "4"}, {0x12, 0x01, 0x03, 0x03, "5"}, {0x12, 0x01, 0x03, 0x00, "240 (cheat)"}, }; static struct BurnDIPInfo gtstarbaHeroesDIPList[] = { // Defaults {0x12, 0xFF, 0xFF, 0x00, NULL}, // DIP B {0, 0xFE, 0, 4, "Number of heroes"}, {0x12, 0x01, 0x03, 0x02, "1"}, {0x12, 0x01, 0x03, 0x03, "2"}, {0x12, 0x01, 0x03, 0x00, "3"}, {0x12, 0x01, 0x03, 0x01, "5"}, }; STDDIPINFOEXT(getstar, getstar, getstarHeroes) STDDIPINFOEXT(gtstarba, getstar, gtstarbaHeroes) static struct BurnDIPInfo slapfighDIPList[] = { // Defaults {0x11, 0xFF, 0xFF, 0x80, NULL}, {0x12, 0xFF, 0xFF, 0x00, NULL}, // DIP A {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x80, 0x80, "Up-right type"}, {0x11, 0x01, 0x80, 0x00, "Table type"}, {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x40, 0x00, "Normal screen"}, {0x11, 0x01, 0x40, 0x40, "Invert screen"}, {0, 0xFE, 0, 2, NULL}, {0x11, 0x01, 0x20, 0x00, "Normal game"}, {0x11, 0x01, 0x20, 0x20, "Screen test mode"}, {0, 0xFE, 0, 2, "Advertise sound"}, {0x11, 0x01, 0x10, 0x00, "On"}, {0x11, 0x01, 0x10, 0x10, "Off"}, {0, 0xFE, 0, 4, "Coin A"}, {0x11, 0x01, 0x0C, 0x00, "1 coin 1 play"}, {0x11, 0x01, 0x0C, 0x08, "1 coin 2 plays"}, {0x11, 0x01, 0x0C, 0x04, "2 coins 1 play"}, {0x11, 0x01, 0x0C, 0x0C, "2 coins 3 plays"}, {0, 0xFE, 0, 4, "Coin B"}, {0x11, 0x01, 0x03, 0x00, "1 coin 1 play"}, {0x11, 0x01, 0x03, 0x02, "1 coin 2 plays"}, {0x11, 0x01, 0x03, 0x01, "2 coins 1 play"}, {0x11, 0x01, 0x03, 0x03, "2 coins 3 plays"}, // DIP B {0, 0xFE, 0, 4, "Game difficulty"}, {0x12, 0x01, 0xC0, 0x00, "B"}, {0x12, 0x01, 0xC0, 0x80, "A"}, {0x12, 0x01, 0xC0, 0x40, "C"}, {0x12, 0x01, 0xC0, 0xC0, "D"}, {0, 0xFE, 0, 4, "Extend"}, {0x12, 0x01, 0x30, 0x00, "30000, 100000"}, {0x12, 0x01, 0x30, 0x20, "50000, 200000"}, {0x12, 0x01, 0x30, 0x10, "50000 only"}, {0x12, 0x01, 0x30, 0x30, "100000 only"}, {0, 0xFE, 0, 4, "Fighter counts"}, {0x12, 0x01, 0x0C, 0x00, "3"}, {0x12, 0x01, 0x0C, 0x08, "5"}, {0x12, 0x01, 0x0C, 0x04, "1"}, {0x12, 0x01, 0x0C, 0x0C, "2"}, {0, 0xFE, 0, 2, NULL}, {0x12, 0x01, 0x02, 0x00, "Normal game"}, {0x12, 0x01, 0x02, 0x02, "DIP-switch display"}, }; STDDIPINFO(slapfigh) // --------------------------------------------------------------------------- static unsigned char *Mem, *MemEnd, *RamStart, *RamEnd; static unsigned char *Rom01, *Rom02, *Rom03; static unsigned char *TigerHeliTileROM, *TigerHeliSpriteROM, *TigerHeliTextROM; static unsigned char *Ram01, *RamShared, *Ram03; static unsigned char *TigerHeliTileRAM, *TigerHeliSpriteRAM, *TigerHeliSpriteBuf, *TigerHeliTextRAM; static unsigned char* TigerHeliPaletteROM; static unsigned int* TigerHeliPalette; static short* pFMBuffer; static short* pAY8910Buffer[6]; static int use_mcu = 0; static int MemIndex() { unsigned char* Next; Next = Mem; Rom01 = Next; Next += 0x012000; // Z80 main program Rom02 = Next; Next += 0x002000; // Z80 sound program Rom03 = Next; Next += 0x000800; // m68705 mcu program TigerHeliTextROM = Next; Next += 0x010000; TigerHeliSpriteROM = Next; Next += 0x040000; TigerHeliTileROM = Next; Next += 0x040000; RamStart = Next; Ram01 = Next; Next += 0x000800; // Z80 main work RAM RamShared = Next; Next += 0x000800; // Shared RAM TigerHeliTextRAM = Next; Next += 0x001000; TigerHeliSpriteRAM = Next; Next += 0x000800; TigerHeliSpriteBuf = Next; Next += 0x000800; TigerHeliTileRAM = Next; Next += 0x001000; Ram03 = Next; Next += 0x000080; RamEnd = Next; pFMBuffer = (short*)Next; Next += nBurnSoundLen * 6 * sizeof(short); TigerHeliPaletteROM = Next; Next += 0x000300; TigerHeliPalette = (unsigned int*)Next; Next += 0x000100 * sizeof(int); MemEnd = Next; return 0; } // --------------------------------------------------------------------------- // Graphics static int nTigerHeliTileXPosLo, nTigerHeliTileXPosHi, nTigerHeliTileYPosLo; static int nTigerHeliTileMask; static unsigned char* pTileData; static int nTileNumber; static int nTilePalette; static unsigned short* pTileRow; static unsigned short* pTile; static int nTileXPos, nTileYPos; // --------------------------------------------------------------------------- // Palette static unsigned char tigerhRecalcPalette = 0; static void TigerHeliPaletteInit() { for (int i = 0; i < 0x0100; i++) { int r, g, b; r = TigerHeliPaletteROM[i + 0x0000]; // Red r |= r << 4; g = TigerHeliPaletteROM[i + 0x0100]; // Green g |= g << 4; b = TigerHeliPaletteROM[i + 0x0200]; // Blue b |= b << 4; TigerHeliPalette[i] = BurnHighCol(r, g, b, 0); } return; } static void TigerHeliPaletteUpdate() { if (tigerhRecalcPalette) { tigerhRecalcPalette = 0; TigerHeliPaletteInit(); } } // --------------------------------------------------------------------------- // Text layer static unsigned char* TigerHeliTextAttrib = NULL; static void TigerHeliTextExit() { free(TigerHeliTextAttrib); TigerHeliTextAttrib = NULL; } static int TigerHeliTextInit() { if ((TigerHeliTextAttrib = (unsigned char*)malloc(0x0400)) == NULL) { return 1; } for (int i = 0; i < 0x0400; i++) { bool bEmpty = true; for (int j = 0; j < 64; j++) { if (TigerHeliTextROM[(i << 6) + j]) { bEmpty = false; break; } } if (bEmpty) { TigerHeliTextAttrib[i] = 0; } else { TigerHeliTextAttrib[i] = 1; } } return 0; } #define PLOTPIXEL(x) if (pTileData[x]) { pPixel[x] = nPalette + pTileData[x]; } static void TigerHeliRenderTextTile() { unsigned short nPalette = nTilePalette << 2; pTileData = TigerHeliTextROM + (nTileNumber << 6); unsigned short* pPixel = pTile; for (int y = 0; y < 8; y++, pPixel += 280, pTileData += 8) { if ((nTileYPos + y) >= 240) { break; } if ((nTileYPos + y) < 0) { continue; } PLOTPIXEL(0); PLOTPIXEL(1); PLOTPIXEL(2); PLOTPIXEL(3); PLOTPIXEL(4); PLOTPIXEL(5); PLOTPIXEL(6); PLOTPIXEL(7); } } #undef PLOTPIXEL static void TigerHeliTextRender() { unsigned char* pTextRAM; if ((nBurnLayer & 2) == 0) { return; } switch (nWhichGame) { case 0: // Tiger Heli nTileYPos = -15; break; case 1: // Get Star nTileYPos = -15; break; case 2: // Slap Fight nTileYPos = -16; break; } pTileRow = pTransDraw + nTileYPos * 280; for (int y = 0; y < 32; y++, nTileYPos += 8, pTileRow += (280 << 3)) { if (nTileYPos <= -8 || nTileYPos >= 240 ) { continue; } pTextRAM = TigerHeliTextRAM + (y << 6); pTile = pTileRow; for (int x = 1; x < 36; x++, pTile += 8) { nTileNumber = pTextRAM[x] | (pTextRAM[0x0800 + x] << 8); nTilePalette = nTileNumber >> 10; nTileNumber &= 0x03FF; if (TigerHeliTextAttrib[nTileNumber]) { TigerHeliRenderTextTile(); } } } return; } // --------------------------------------------------------------------------- // Tile layer static void TigerHeliTileExit() { return; } static int TigerHeliTileInit() { return 0; } #define PLOTPIXEL(x) pPixel[x] = nPalette + pTileData[x]; #define CLIPPIXEL(a,b) if ((nTileXPos + a) >= 0 && (nTileXPos + a) < 280) { b; } static void TigerHeliRenderTileNoClip() { unsigned char nPalette = nTilePalette << 4; pTileData = TigerHeliTileROM + (nTileNumber << 6); unsigned short* pPixel = pTile; for (int y = 0; y < 8; y++, pPixel += 280, pTileData += 8) { PLOTPIXEL(0); PLOTPIXEL(1); PLOTPIXEL(2); PLOTPIXEL(3); PLOTPIXEL(4); PLOTPIXEL(5); PLOTPIXEL(6); PLOTPIXEL(7); } } static void TigerHeliRenderTileClip() { unsigned char nPalette = nTilePalette << 4; pTileData = TigerHeliTileROM + (nTileNumber << 6); unsigned short* pPixel = pTile; for (int y = 0; y < 8; y++, pPixel += 280, pTileData += 8) { if ((nTileYPos + y) >= 240) { break; } if ((nTileYPos + y) < 0) { continue; } CLIPPIXEL(0, PLOTPIXEL(0)); CLIPPIXEL(1, PLOTPIXEL(1)); CLIPPIXEL(2, PLOTPIXEL(2)); CLIPPIXEL(3, PLOTPIXEL(3)); CLIPPIXEL(4, PLOTPIXEL(4)); CLIPPIXEL(5, PLOTPIXEL(5)); CLIPPIXEL(6, PLOTPIXEL(6)); CLIPPIXEL(7, PLOTPIXEL(7)); } } #undef CLIPPIXEL #undef PLOTPIXEL static void TigerHeliTileRender() { unsigned char* pTileRAM; if ((nBurnLayer & 3) == 0) { BurnTransferClear(); return; } int nTigerHeliTileXPos = nTigerHeliTileXPosLo + (nTigerHeliTileXPosHi << 8); int nTigerHeliTileYPos = nTigerHeliTileYPosLo; switch (nWhichGame) { case 0: // Tiger Heli nTigerHeliTileYPos -= 1; break; case 1: // Get Star nTigerHeliTileYPos -= 1; break; case 2: // Slap Fight nTigerHeliTileYPos += 1; break; } int nXPos = -nTigerHeliTileXPos & 7; nTileYPos = -nTigerHeliTileYPos & 7; if (nTigerHeliTileXPos & 7) { nXPos -= 8; } if (nTigerHeliTileYPos & 7) { nTileYPos -= 8; } pTileRow = pTransDraw; pTileRow -= (nTigerHeliTileXPos & 7); pTileRow -= (nTigerHeliTileYPos & 7) * 280; for (int y = 2; y < 33; y++, nTileYPos += 8, pTileRow += (280 << 3)) { pTileRAM = TigerHeliTileRAM + ((y + (nTigerHeliTileYPos >> 3) << 6) & 0x07C0); pTile = pTileRow; nTileXPos = nXPos; for (int x = 1; x < 37; x++, nTileXPos += 8, pTile += 8) { int x2 = (x + (nTigerHeliTileXPos >> 3) & 0x3F); nTileNumber = pTileRAM[x2] | (pTileRAM[0x0800 + x2] << 8); nTilePalette = nTileNumber >> 12; nTileNumber &= nTigerHeliTileMask; if (nTileXPos < 0 || nTileXPos > 272 || nTileYPos < 0 || nTileYPos > 232) { TigerHeliRenderTileClip(); } else { TigerHeliRenderTileNoClip(); } } } return; } // --------------------------------------------------------------------------- // Sprites static int nSpriteXPos, nSpriteYPos, nSpriteNumber, nSpritePalette; static int nTigerHeliSpriteMask; static void TigerHeliSpriteExit() { return; } static int TigerHeliSpriteInit() { return 0; } #define PLOTPIXEL(a) if (pSpriteData[a]) { pPixel[a] = nPalette + pSpriteData[a]; } #define CLIPPIXEL(a,b) if ((nSpriteXPos + a) >= 0 && (nSpriteXPos + a) < 280) { b; } static void TigerHeliRenderSpriteNoClip() { unsigned char nPalette = nSpritePalette << 4; unsigned char* pSpriteData = TigerHeliSpriteROM + (nSpriteNumber << 8); unsigned short* pPixel = pTransDraw + nSpriteXPos + nSpriteYPos * 280; for (int y = 0; y < 16; y++, pPixel += 280, pSpriteData += 16) { PLOTPIXEL( 0); PLOTPIXEL( 1); PLOTPIXEL( 2); PLOTPIXEL( 3); PLOTPIXEL( 4); PLOTPIXEL( 5); PLOTPIXEL( 6); PLOTPIXEL( 7); PLOTPIXEL( 8); PLOTPIXEL( 9); PLOTPIXEL(10); PLOTPIXEL(11); PLOTPIXEL(12); PLOTPIXEL(13); PLOTPIXEL(14); PLOTPIXEL(15); } } static void TigerHeliRenderSpriteClip() { unsigned char nPalette = nSpritePalette << 4; unsigned char* pSpriteData = TigerHeliSpriteROM + (nSpriteNumber << 8); unsigned short* pPixel = pTransDraw + nSpriteXPos + nSpriteYPos * 280; for (int y = 0; y < 16; y++, pPixel += 280, pSpriteData += 16) { if ((nSpriteYPos + y) < 0 || (nSpriteYPos + y) >= 240) { continue; } CLIPPIXEL( 0, PLOTPIXEL( 0)); CLIPPIXEL( 1, PLOTPIXEL( 1)); CLIPPIXEL( 2, PLOTPIXEL( 2)); CLIPPIXEL( 3, PLOTPIXEL( 3)); CLIPPIXEL( 4, PLOTPIXEL( 4)); CLIPPIXEL( 5, PLOTPIXEL( 5)); CLIPPIXEL( 6, PLOTPIXEL( 6)); CLIPPIXEL( 7, PLOTPIXEL( 7)); CLIPPIXEL( 8, PLOTPIXEL( 8)); CLIPPIXEL( 9, PLOTPIXEL( 9)); CLIPPIXEL(10, PLOTPIXEL(10)); CLIPPIXEL(11, PLOTPIXEL(11)); CLIPPIXEL(12, PLOTPIXEL(12)); CLIPPIXEL(13, PLOTPIXEL(13)); CLIPPIXEL(14, PLOTPIXEL(14)); CLIPPIXEL(15, PLOTPIXEL(15)); } } #undef CLIPPIXEL #undef PLOTPIXEL static void TigerHeliSpriteRender() { unsigned char* pSpriteRAM = TigerHeliSpriteBuf; int nSpriteYOffset = 0; if ((nBurnLayer & 1) == 0) { return; } switch (nWhichGame) { case 0: // Tiger Heli nSpriteYOffset = -16; break; case 1: // Get Star nSpriteYOffset = -16; break; case 2: // Slap Fight nSpriteYOffset = -17; break; } for (int i = 0; i < 0x0800; i += 4) { nSpriteNumber = pSpriteRAM[i + 0x00] | ((pSpriteRAM[i + 0x02] & 0xC0) << 2); nSpriteNumber &= nTigerHeliSpriteMask; nSpritePalette = (pSpriteRAM[i + 0x02] >> 1) & 0x0F; nSpriteXPos = (pSpriteRAM[i + 0x01] | ((pSpriteRAM[i + 0x02] & 0x01) << 8)) - 21; nSpriteYPos = pSpriteRAM[i + 0x03] + nSpriteYOffset; if (nSpriteXPos > -16 && nSpriteXPos < 280 && nSpriteYPos > -16 && nSpriteYPos < 240) { if (nSpriteXPos >= 0 && nSpriteXPos <= 264 && nSpriteYPos >= 0 && nSpriteYPos <= 224) { TigerHeliRenderSpriteNoClip(); } else { TigerHeliRenderSpriteClip(); } } } return; } static void TigerHeliBufferSprites() { memcpy(TigerHeliSpriteBuf, TigerHeliSpriteRAM, 0x0800); } // --------------------------------------------------------------------------- static inline void sync_mcu() { int cycles = (ZetTotalCycles() / 2) - m6805TotalCycles(); if (cycles > 0) { // bprintf (0, _T("mcu %d\n"), cycles); m6805Run(cycles); } } unsigned char __fastcall tigerhReadCPU0(unsigned short a) { if (a >= 0xc800 && a <= 0xcfff) { if (ZetPc(-1) == 0x6d34) return 0xff; return RamShared[a - 0xc800]; } switch (a) { case 0xE803: { if (use_mcu) { sync_mcu(); return standard_taito_mcu_read(); } unsigned char nProtectSequence[3] = { 0, 1, (0 + 5) ^ 0x56 }; // if (nProtectIndex == 3) { // nProtectIndex = 0; // } // bprintf(PRINT_NORMAL, "Protection read (%02X) PC: %04X.\n", nProtectSequence[nProtectIndex], ZetPc(-1)); // return nProtectSequence[nProtectIndex++]; unsigned char val = nProtectSequence[nProtectIndex]; nProtectIndex = (nProtectIndex + 1) % 3; return val; } // default: // bprintf(PRINT_NORMAL, _T("Attempt by CPU0 to read address %04X.\n"), a); } return 0; } unsigned char __fastcall tigerhReadCPU0_tigerhb1(unsigned short a) { if (a >= 0xc800 && a <= 0xcfff) { if (ZetPc(-1) == 0x6d34) return 0xff; return RamShared[a - 0xc800]; } switch (a) { case 0xE803: { return 0x83; } } return 0; } void __fastcall tigerhWriteCPU0(unsigned short a, unsigned char d) { switch (a) { case 0xE800: nTigerHeliTileXPosLo = d; break; case 0xE801: nTigerHeliTileXPosHi = d; break; case 0xE802: nTigerHeliTileYPosLo = d; break; case 0xe803: if (use_mcu) { sync_mcu(); from_main = d; main_sent = 1; mcu_sent = 0; m68705SetIrqLine(0, 1 /*ASSERT_LINE*/); } break; // default: // bprintf(PRINT_NORMAL, "Attempt by CPU0 to write address %04X -> %02X.\n", a, d); } } void __fastcall tigerhWriteCPU0_slapbtuk(unsigned short a, unsigned char d) { switch (a) { case 0xE800: nTigerHeliTileXPosHi = d; break; case 0xE802: nTigerHeliTileYPosLo = d; break; case 0xE803: nTigerHeliTileXPosLo = d; break; // default: // bprintf(PRINT_NORMAL, "Attempt by CPU0 to write address %04X -> %02X.\n", a, d); } } unsigned char __fastcall tigerhInCPU0(unsigned short a) { a &= 0xFF; switch (a) { case 0x00: { unsigned char nStatusSequence[3] = { 0xC7, 0x55, 0x00 }; // if (nStatusIndex == 3) { // nStatusIndex = 0; // } // bprintf(PRINT_NORMAL, "Status read (%02X) PC: %04X.\n", nStatusSequence[nStatusIndex], ZetPc(-1)); // return nStatusSequence[nStatusIndex++]; unsigned char nStatus = nStatusSequence[nStatusIndex]; nStatusIndex++; if (nStatusIndex > 2) nStatusIndex = 0; if (use_mcu) { sync_mcu(); nStatus &= 0xf9; if (!main_sent) nStatus |= 0x02; if (!mcu_sent) nStatus |= 0x04; } return nStatus; } // default: // bprintf(PRINT_NORMAL, "Attempt by CPU0 to read port %02X.\n", a); } return 0; } unsigned char __fastcall tigerhInCPU0_gtstarba(unsigned short a) { a &= 0xFF; switch (a) { case 0x00: { if (ZetPc(-1) == 0x6d1e) return 0; if (ZetPc(-1) == 0x6d24) return 6; if (ZetPc(-1) == 0x6d2c) return 2; if (ZetPc(-1) == 0x6d34) return 4; return 0; } // default: // bprintf(PRINT_NORMAL, "Attempt by CPU0 to read port %02X.\n", a); } return 0; } void __fastcall tigerhOutCPU0(unsigned short a, unsigned char /* d */) { a &= 0xFF; switch (a) { case 0x00: // Assert reset line on sound CPU // bprintf(PRINT_NORMAL, "Sound CPU disabled.\n"); if (bSoundCPUEnable) { ZetClose(); ZetOpen(1); ZetReset(); ZetClose(); ZetOpen(0); bSoundCPUEnable = false; } break; case 0x01: // Release reset line on sound CPU // bprintf(PRINT_NORMAL, "Sound CPU enabled.\n"); bSoundCPUEnable = true; break; // case 0x03: // break; // case 0x05: // bprintf(PRINT_NORMAL, "Sound NMI triggered.\n"); /* if (bSoundNMIEnable) { ZetClose(); ZetOpen(1); ZetNmi(); ZetClose(); ZetOpen(0); } */ // break; case 0x06: // Disable interrupts // bprintf(PRINT_NORMAL, "Interrupts disabled.\n"); bInterruptEnable = false; ZetLowerIrq(0); break; case 0x07: // Enable interrupts // bprintf(PRINT_NORMAL, "Interrupts enabled.\n"); bInterruptEnable = true; break; case 0x08: // bprintf(PRINT_NORMAL, "ROM bank 0 selected.\n"); // ROM bank 0 selected ZetMapArea(0x8000, 0xBFFF, 0, Rom01 + 0x8000); ZetMapArea(0x8000, 0xBFFF, 2, Rom01 + 0x8000); break; case 0x09: // bprintf(PRINT_NORMAL, "ROM bank 1 selected.\n"); // ROM bank 1 selected ZetMapArea(0x8000, 0xBFFF, 0, Rom01 + 0xC000); ZetMapArea(0x8000, 0xBFFF, 2, Rom01 + 0xC000); break; // default: // bprintf(PRINT_NORMAL, "Attempt by CPU0 to write port %02X -> %02X.\n", a, d); } } unsigned char __fastcall tigerhReadCPU1(unsigned short a) { switch (a) { case 0xA081: // bprintf(PRINT_NORMAL, "AY8910 0 read (%02X).\n", AY8910Read(0)); return AY8910Read(0); case 0xA091: // bprintf(PRINT_NORMAL, "AY8910 1 read (%02X).\n", AY8910Read(1)); return AY8910Read(1); // default: // bprintf(PRINT_NORMAL, "Attempt by CPU1 to read address %04X.\n", a); } return 0; } void __fastcall tigerhWriteCPU1(unsigned short a, unsigned char d) { switch (a) { case 0xA080: // bprintf(PRINT_NORMAL, "AY8910 0 Register select (%02X).\n", d); AY8910Write(0, 0, d); break; case 0xA082: // bprintf(PRINT_NORMAL, "AY8910 0 Register Write (%02X).\n", d); AY8910Write(0, 1, d); break; case 0xA090: // bprintf(PRINT_NORMAL, "AY8910 1 Register select (%02X).\n", d); AY8910Write(1, 0, d); break; case 0xA092: // bprintf(PRINT_NORMAL, "AY8910 1 Register Write (%02X).\n", d); AY8910Write(1, 1, d); break; case 0xA0E0: // bprintf(PRINT_NORMAL, "Sound NMI enabled.\n"); bSoundNMIEnable = true; break; // default: // bprintf(PRINT_NORMAL, "Attempt by CPU1 to write address %04X -> %02X.\n", a, d); } } unsigned char __fastcall tigerhInCPU1(unsigned short /* a */) { // bprintf(PRINT_NORMAL, "Attempt by CPU1 to read port %02X.\n", a); return 0; } void __fastcall tigerhOutCPU1(unsigned short /* a */, unsigned char /* d */) { // bprintf(PRINT_NORMAL, "Attempt by CPU1 to write port %02X -> %02X.\n", a, d); } static unsigned char tigerhReadPort0(unsigned int) { return ~tigerhInput[0]; } static unsigned char tigerhReadPort1(unsigned int) { return ~tigerhInput[1]; } static unsigned char tigerhReadPort2(unsigned int) { return ~tigerhInput[2]; } static unsigned char tigerhReadPort3(unsigned int) { return ~tigerhInput[3]; } //---------------------------------------------------------------------------- void tigerh_m68705_portA_write(unsigned char *data) { from_mcu = *data; mcu_sent = 1; } void tigerh_m68705_portC_read() { portC_in = 0; if (!main_sent) portC_in |= 0x01; if ( mcu_sent) portC_in |= 0x02; } static m68705_interface tigerh_m68705_interface = { tigerh_m68705_portA_write, standard_m68705_portB_out, NULL, NULL, NULL, NULL, NULL, NULL, tigerh_m68705_portC_read }; // --------------------------------------------------------------------------- static int tigerhLoadROMs() { int nRomOffset = 0; if (!strcmp(BurnDrvGetTextA(DRV_NAME), "slapbtuk")) nRomOffset = 1; if (!strcmp(BurnDrvGetTextA(DRV_NAME), "slapfgtr")) nRomOffset = 2; // Z80 main program switch (nWhichGame) { case 0: // Tiger Heli if (BurnLoadRom(Rom01 + 0x0000, 0, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x4000, 1, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x8000, 2, 1)) { return 1; } break; case 1: // Get Star if (BurnLoadRom(Rom01 + 0x0000, 0, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x4000, 1, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x8000, 2, 1)) { return 1; } break; case 2: { // Slap Fight if (!strcmp(BurnDrvGetTextA(DRV_NAME), "slapbtuk")) { if (BurnLoadRom(Rom01 + 0x0000, 0, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x4000, 1, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x8000, 2, 1)) { return 1; } break; } else { if (!strcmp(BurnDrvGetTextA(DRV_NAME), "slapfgtr")) { if (BurnLoadRom(Rom01 + 0x0000, 0, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x4000, 1, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x10000, 2, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x8000, 3, 1)) { return 1; } break; } else { if (BurnLoadRom(Rom01 + 0x0000, 0, 1)) { return 1; } if (BurnLoadRom(Rom01 + 0x8000, 1, 1)) { return 1; } break; } } } } // Sprites { int nRet = 0, nBaseROM = 0; switch (nWhichGame) { case 0: // Tiger Heli nBaseROM = 3; break; case 1: // Get Star nBaseROM = 3; break; case 2: // Slap Fight nBaseROM = 2 + nRomOffset; break; } int nSize; { struct BurnRomInfo ri; ri.nType = 0; ri.nLen = 0; BurnDrvGetRomInfo(&ri, nBaseROM); nSize = ri.nLen; } unsigned char* pTemp = (unsigned char*)malloc(nSize * 4); for (int i = 0; i < 4; i++) { nRet |= BurnLoadRom(pTemp + nSize * i, nBaseROM + i, 1); } for (int i = 0; i < nSize; i++) { for (int j = 0; j < 8; j++) { TigerHeliSpriteROM[(i << 3) + j] = ((pTemp[i + nSize * 0] >> (7 - j)) & 1) << 3; TigerHeliSpriteROM[(i << 3) + j] |= ((pTemp[i + nSize * 1] >> (7 - j)) & 1) << 2; TigerHeliSpriteROM[(i << 3) + j] |= ((pTemp[i + nSize * 2] >> (7 - j)) & 1) << 1; TigerHeliSpriteROM[(i << 3) + j] |= ((pTemp[i + nSize * 3] >> (7 - j)) & 1) << 0; } } free(pTemp); nTigerHeliSpriteMask = (nSize >> 5) - 1; if (nRet) { return 1; } } // Text layer { int nBaseROM = 0; switch (nWhichGame) { case 0: // Tiger Heli nBaseROM = 7; break; case 1: // Get Star nBaseROM = 7; break; case 2: // Slap Fight nBaseROM = 6 + nRomOffset; break; } unsigned char* pTemp = (unsigned char*)malloc(0x4000); if (BurnLoadRom(pTemp + 0x0000, nBaseROM + 0, 1)) { return 1; } if (BurnLoadRom(pTemp + 0x2000, nBaseROM + 1, 1)) { return 1; } for (int i = 0; i < 0x02000; i++) { for (int j = 0; j < 8; j++) { TigerHeliTextROM[(i << 3) + j] = ((pTemp[i + 0x0000] >> (7 - j)) & 1) << 1; TigerHeliTextROM[(i << 3) + j] |= ((pTemp[i + 0x2000] >> (7 - j)) & 1) << 0; } } free(pTemp); } // Tile layer { int nRet = 0, nBaseROM = 0; switch (nWhichGame) { case 0: // Tiger Heli nBaseROM = 9; break; case 1: // Get Star nBaseROM = 9; break; case 2: // Slap Fight nBaseROM = 8 + nRomOffset; break; } int nSize; { struct BurnRomInfo ri; ri.nType = 0; ri.nLen = 0; BurnDrvGetRomInfo(&ri, nBaseROM); nSize = ri.nLen; } unsigned char* pTemp = (unsigned char*)malloc(nSize * 4); for (int i = 0; i < 4; i++) { nRet |= BurnLoadRom(pTemp + nSize * i, nBaseROM + i, 1); } for (int i = 0; i < nSize; i++) { for (int j = 0; j < 8; j++) { TigerHeliTileROM[(i << 3) + j] = ((pTemp[i + nSize * 0] >> (7 - j)) & 1) << 3; TigerHeliTileROM[(i << 3) + j] |= ((pTemp[i + nSize * 1] >> (7 - j)) & 1) << 2; TigerHeliTileROM[(i << 3) + j] |= ((pTemp[i + nSize * 2] >> (7 - j)) & 1) << 1; TigerHeliTileROM[(i << 3) + j] |= ((pTemp[i + nSize * 3] >> (7 - j)) & 1) << 0; } } free(pTemp); nTigerHeliTileMask = (nSize >> 3) - 1; if (nRet) { return 1; } } // Colour PROMs { int nBaseROM = 0; switch (nWhichGame) { case 0: // Tiger Heli nBaseROM = 13; break; case 1: // Get Star nBaseROM = 13; break; case 2: // Slap Fight nBaseROM = 12 + nRomOffset; break; } if (BurnLoadRom(TigerHeliPaletteROM + 0x0000, nBaseROM + 0, 1)) { return 1; } if (BurnLoadRom(TigerHeliPaletteROM + 0x0100, nBaseROM + 1, 1)) { return 1; } if (BurnLoadRom(TigerHeliPaletteROM + 0x0200, nBaseROM + 2, 1)) { return 1; } } // Z80 program { int nBaseROM = 0; switch (nWhichGame) { case 0: // Tiger Heli nBaseROM = 16; break; case 1: // Get Star nBaseROM = 16; break; case 2: // Slap Fight nBaseROM = 15 + nRomOffset; break; } if (BurnLoadRom(Rom02, nBaseROM, 1)) { return 1; } } // MCU program { if (strcmp(BurnDrvGetTextA(DRV_NAME), "tigerh") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "tigerhj") == 0) { if (BurnLoadRom(Rom03, 17, 1)) { return 1; } use_mcu = 1; } } return 0; } static int tigerhExit() { BurnTransferExit(); TigerHeliSpriteExit(); TigerHeliTextExit(); TigerHeliTileExit(); ZetExit(); if (use_mcu) { use_mcu = 0; m67805_taito_exit(); } // Deallocate all used memory free(Mem); Mem = NULL; return 0; } static void tigerhDoReset() { bInterruptEnable = false; bSoundNMIEnable = false; bSoundCPUEnable = true; nStatusIndex = 0; nProtectIndex = 0; ZetOpen(0); ZetReset(); ZetClose(); ZetOpen(1); ZetReset(); ZetClose(); if (use_mcu) { m67805_taito_reset(); } return; } static int tigerhInit() { int nLen; nWhichGame = -1; if (strcmp(BurnDrvGetTextA(DRV_NAME), "tigerh") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "tigerhb1") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "tigerhb2") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "tigerhb3") == 0) { nWhichGame = 0; } if (strcmp(BurnDrvGetTextA(DRV_NAME), "getstar") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "gtstarb1") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "gtstarb2") == 0) { nWhichGame = 1; } if (strcmp(BurnDrvGetTextA(DRV_NAME), "slapfigh") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "slapfgtr") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "slapbtjp") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "slapbtuk") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "alcon") == 0 || strcmp(BurnDrvGetTextA(DRV_NAME), "slapfigha") == 0) { nWhichGame = 2; } // Find out how much memory is needed Mem = NULL; MemIndex(); nLen = MemEnd - (unsigned char*)0; if ((Mem = (unsigned char*)malloc(nLen)) == NULL) { return 1; } memset(Mem, 0, nLen); // blank all memory MemIndex(); // Index the allocated memory // Load the roms into memory if (tigerhLoadROMs()) { return 1; } { ZetInit(2); // Main CPU setup ZetOpen(0); // Program ROM ZetMapArea(0x0000, 0x7FFF, 0, Rom01); ZetMapArea(0x0000, 0x7FFF, 2, Rom01); // Banked ROM ZetMapArea(0x8000, 0xBFFF, 0, Rom01 + 0x8000); ZetMapArea(0x8000, 0xBFFF, 2, Rom01 + 0x8000); // Work RAM ZetMapArea(0xC000, 0xC7FF, 0, Ram01); ZetMapArea(0xC000, 0xC7FF, 1, Ram01); ZetMapArea(0xC000, 0xC7FF, 2, Ram01); // Shared RAM if (strcmp(BurnDrvGetTextA(DRV_NAME), "gtstarb1")) { ZetMapArea(0xC800, 0xCFFF, 0, RamShared); } ZetMapArea(0xC800, 0xCFFF, 1, RamShared); ZetMapArea(0xC800, 0xCFFF, 2, RamShared); // Tile RAM ZetMapArea(0xD000, 0xDFFF, 0, TigerHeliTileRAM); ZetMapArea(0xD000, 0xDFFF, 1, TigerHeliTileRAM); ZetMapArea(0xD000, 0xDFFF, 2, TigerHeliTileRAM); // Sprite RAM ZetMapArea(0xE000, 0xE7FF, 0, TigerHeliSpriteRAM); ZetMapArea(0xE000, 0xE7FF, 1, TigerHeliSpriteRAM); ZetMapArea(0xE000, 0xE7FF, 2, TigerHeliSpriteRAM); if (!strcmp(BurnDrvGetTextA(DRV_NAME), "slapbtuk") || !strcmp(BurnDrvGetTextA(DRV_NAME), "slapfgtr")) { ZetMapArea(0xec00, 0xeFFF, 0, Rom01 + 0x10c00); ZetMapArea(0xec00, 0xeFFF, 2, Rom01 + 0x10c00); } // Text RAM ZetMapArea(0xF000, 0xFFFF, 0, TigerHeliTextRAM); ZetMapArea(0xF000, 0xFFFF, 1, TigerHeliTextRAM); ZetMapArea(0xF000, 0xFFFF, 2, TigerHeliTextRAM); ZetMemEnd(); if (!strcmp(BurnDrvGetTextA(DRV_NAME), "tigerhb1")) { ZetSetReadHandler(tigerhReadCPU0_tigerhb1); } else { ZetSetReadHandler(tigerhReadCPU0); } if (!strcmp(BurnDrvGetTextA(DRV_NAME), "slapbtuk") || !strcmp(BurnDrvGetTextA(DRV_NAME), "slapfgtr")) { ZetSetWriteHandler(tigerhWriteCPU0_slapbtuk); } else { ZetSetWriteHandler(tigerhWriteCPU0); } if (!strcmp(BurnDrvGetTextA(DRV_NAME), "gtstarb1")) { ZetSetInHandler(tigerhInCPU0_gtstarba); } else { ZetSetInHandler(tigerhInCPU0); } ZetSetOutHandler(tigerhOutCPU0); ZetClose(); // Sound CPU setup ZetOpen(1); // Program ROM ZetMapArea(0x0000, 0x1FFF, 0, Rom02); ZetMapArea(0x0000, 0x1FFF, 2, Rom02); // Work RAM ZetMapArea(0xC800, 0xCFFF, 0, RamShared); ZetMapArea(0xC800, 0xCFFF, 1, RamShared); ZetMapArea(0xC800, 0xCFFF, 2, RamShared); ZetMemEnd(); ZetSetReadHandler(tigerhReadCPU1); ZetSetWriteHandler(tigerhWriteCPU1); ZetSetInHandler(tigerhInCPU1); ZetSetOutHandler(tigerhOutCPU1); ZetClose(); if (use_mcu) { m67805_taito_init(Rom03, Ram03, &tigerh_m68705_interface); } } pAY8910Buffer[0] = pFMBuffer + nBurnSoundLen * 0; pAY8910Buffer[1] = pFMBuffer + nBurnSoundLen * 1; pAY8910Buffer[2] = pFMBuffer + nBurnSoundLen * 2; pAY8910Buffer[3] = pFMBuffer + nBurnSoundLen * 3; pAY8910Buffer[4] = pFMBuffer + nBurnSoundLen * 4; pAY8910Buffer[5] = pFMBuffer + nBurnSoundLen * 5; AY8910Init(0, 1500000, nBurnSoundRate, &tigerhReadPort0, &tigerhReadPort1, NULL, NULL); AY8910Init(1, 1500000, nBurnSoundRate, &tigerhReadPort2, &tigerhReadPort3, NULL, NULL); TigerHeliTileInit(); TigerHeliTextInit(); TigerHeliSpriteInit(); TigerHeliPaletteInit(); BurnTransferInit(); tigerhDoReset(); return 0; } static int tigerhScan(int nAction, int* pnMin) { struct BurnArea ba; if (pnMin) { // Return minimum compatible version *pnMin = 0x029521; } if (nAction & ACB_VOLATILE) { // Scan volatile ram memset(&ba, 0, sizeof(ba)); ba.Data = RamStart; ba.nLen = RamEnd-RamStart; ba.szName = "All Ram"; BurnAcb(&ba); ZetScan(nAction); // Scan Z80 // Scan critical driver variables SCAN_VAR(bInterruptEnable); SCAN_VAR(bSoundCPUEnable); SCAN_VAR(bSoundNMIEnable); SCAN_VAR(nStatusIndex); SCAN_VAR(nProtectIndex); SCAN_VAR(tigerhInput); } return 0; } static void tigerhDraw() { TigerHeliPaletteUpdate(); TigerHeliTileRender(); TigerHeliSpriteRender(); TigerHeliTextRender(); BurnTransferCopy(TigerHeliPalette); return; } static inline int CheckSleep(int) { return 0; } static int tigerhFrame() { int nCyclesTotal[3], nCyclesDone[3]; if (tigerhReset) { // Reset machine tigerhDoReset(); } ZetNewFrame(); m6805NewFrame(); // Compile digital inputs tigerhInput[0] = 0x00; tigerhInput[1] = 0x00; for (int i = 0; i < 8; i++) { tigerhInput[0] |= (tigerhInpJoy1[i] & 1) << i; if (nWhichGame == 0 && i < 4) { tigerhInput[1] |= (tigerhInpMisc[i] & 1) << (i ^ 1); } else { tigerhInput[1] |= (tigerhInpMisc[i] & 1) << i; } } if ((tigerhInput[0] & 0x03) == 0x03) { tigerhInput[0] &= ~0x03; } if ((tigerhInput[0] & 0x0C) == 0x0C) { tigerhInput[0] &= ~0x0C; } if ((tigerhInput[0] & 0x30) == 0x30) { tigerhInput[0] &= ~0x30; } if ((tigerhInput[0] & 0xC0) == 0xC0) { tigerhInput[0] &= ~0xC0; } if (nWhichGame == 1) { tigerhInput[0] = (tigerhInput[0] & 0x99) | ((tigerhInput[0] << 1) & 0x44) | ((tigerhInput[0] >> 1) & 0x22); } nCyclesTotal[0] = nCyclesTotal[1] = 6000000 / 60; nCyclesDone[0] = nCyclesDone[1] = nCyclesDone[2] = 0; nCyclesTotal[2] = 3000000 / 60; const int nVBlankCycles = 248 * 6000000 / 60 / 262; const int nInterleave = 12; int nSoundBufferPos = 0; int nSoundNMIMask = 0; switch (nWhichGame) { case 0: nSoundNMIMask = 1; break; case 1: nSoundNMIMask = 3; break; case 2: nSoundNMIMask = 3; break; } bool bVBlank = false; for (int i = 0; i < nInterleave; i++) { int nCurrentCPU; int nNext, nCyclesSegment; nCurrentCPU = 0; ZetOpen(nCurrentCPU); nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave; if (nNext > nVBlankCycles && !bVBlank) { nCyclesDone[nCurrentCPU] += ZetRun(nNext - nVBlankCycles); if (pBurnDraw != NULL) { tigerhDraw(); // Draw screen if needed } TigerHeliBufferSprites(); bVBlank = true; if (bInterruptEnable) { ZetRaiseIrq(0xFF); #if 0 ZetClose(); ZetOpen(1); ZetRaiseIrq(0xFF); ZetClose(); ZetOpen(0); #endif } } nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; if (bVBlank || (!CheckSleep(nCurrentCPU))) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += nCyclesSegment; } ZetClose(); if (use_mcu) { m6805Open(0); nCyclesSegment = (nCyclesTotal[2] * (i + 1)) / nInterleave; nCyclesSegment -= m6805TotalCycles(); if (nCyclesSegment > 0) { nCyclesDone[2] += m6805Run(nCyclesSegment); } m6805Close(); } nCurrentCPU = 1; nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave; nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; if (bSoundCPUEnable) { ZetOpen(nCurrentCPU); if ((i & nSoundNMIMask) == 0) { if (bSoundNMIEnable) { ZetNmi(); } } nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment); ZetClose(); } else { nCyclesDone[nCurrentCPU] += nCyclesSegment; } { // Render sound segment if (pBurnSoundOut) { int nSample; int nSegmentLength = nBurnSoundLen / nInterleave; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); AY8910Update(0, &pAY8910Buffer[0], nSegmentLength); AY8910Update(1, &pAY8910Buffer[3], nSegmentLength); for (int n = 0; n < nSegmentLength; n++) { nSample = pAY8910Buffer[0][n] >> 2; nSample += pAY8910Buffer[1][n] >> 2; nSample += pAY8910Buffer[2][n] >> 2; nSample += pAY8910Buffer[3][n] >> 2; nSample += pAY8910Buffer[4][n] >> 2; nSample += pAY8910Buffer[5][n] >> 2; if (nSample < -32768) { nSample = -32768; } else { if (nSample > 32767) { nSample = 32767; } } pSoundBuf[(n << 1) + 0] = nSample; pSoundBuf[(n << 1) + 1] = nSample; } nSoundBufferPos += nSegmentLength; } } } { // Make sure the buffer is entirely filled. if (pBurnSoundOut) { int nSample; int nSegmentLength = nBurnSoundLen - nSoundBufferPos; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); if (nSegmentLength) { AY8910Update(0, &pAY8910Buffer[0], nSegmentLength); AY8910Update(1, &pAY8910Buffer[3], nSegmentLength); for (int n = 0; n < nSegmentLength; n++) { nSample = pAY8910Buffer[0][n] >> 2; nSample += pAY8910Buffer[1][n] >> 2; nSample += pAY8910Buffer[2][n] >> 2; nSample += pAY8910Buffer[3][n] >> 2; nSample += pAY8910Buffer[4][n] >> 2; nSample += pAY8910Buffer[5][n] >> 2; if (nSample < -32768) { nSample = -32768; } else { if (nSample > 32767) { nSample = 32767; } } pSoundBuf[(n << 1) + 0] = nSample; pSoundBuf[(n << 1) + 1] = nSample; } } } } return 0; } // --------------------------------------------------------------------------- // Rom information static struct BurnRomInfo tigerhRomDesc[] = { { "0.4", 0x004000, 0x4BE73246, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "1.4", 0x004000, 0xAAD04867, BRF_ESS | BRF_PRG }, // 1 { "2.4", 0x004000, 0x4843F15C, BRF_ESS | BRF_PRG }, // 2 { "a47_13.bin", 0x004000, 0x739A7E7E, BRF_GRA }, // 3 Sprite data { "a47_12.bin", 0x004000, 0xC064ECDB, BRF_GRA }, // 4 { "a47_11.bin", 0x004000, 0x744FAE9B, BRF_GRA }, // 5 { "a47_10.bin", 0x004000, 0xE1CF844E, BRF_GRA }, // 6 { "a47_05.bin", 0x002000, 0xC5325B49, BRF_GRA }, // 7 Text layer { "a47_04.bin", 0x002000, 0xCD59628E, BRF_GRA }, // 8 { "a47_09.bin", 0x004000, 0x31FAE8A8, BRF_GRA }, // 9 Background layer { "a47_08.bin", 0x004000, 0xE539AF2B, BRF_GRA }, // 10 { "a47_07.bin", 0x004000, 0x02FDD429, BRF_GRA }, // 11 { "a47_06.bin", 0x004000, 0x11FBCC8C, BRF_GRA }, // 12 { "82s129.12q", 0x000100, 0x2C69350D, BRF_GRA }, // 13 { "82s129.12m", 0x000100, 0x7142E972, BRF_GRA }, // 14 { "82s129.12n", 0x000100, 0x25F273F2, BRF_GRA }, // 15 { "a47_03.bin", 0x002000, 0xD105260F, BRF_ESS | BRF_PRG }, // 16 { "a47_14.6a", 0x000800, 0x4042489F, BRF_ESS | BRF_PRG }, // 17 MCU { "pal16r4a.2e", 260, 0x00000000, BRF_NODUMP }, }; STD_ROM_PICK(tigerh) STD_ROM_FN(tigerh) static struct BurnRomInfo tigerhjRomDesc[] = { { "a47_00.bin", 0x004000, 0xcbdbe3cc, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "a47_01.bin", 0x004000, 0x65df2152, BRF_ESS | BRF_PRG }, // 1 { "a47_02.bin", 0x004000, 0x633d324b, BRF_ESS | BRF_PRG }, // 2 { "a47_13.bin", 0x004000, 0x739A7E7E, BRF_GRA }, // 3 Sprite data { "a47_12.bin", 0x004000, 0xC064ECDB, BRF_GRA }, // 4 { "a47_11.bin", 0x004000, 0x744FAE9B, BRF_GRA }, // 5 { "a47_10.bin", 0x004000, 0xE1CF844E, BRF_GRA }, // 6 { "a47_05.bin", 0x002000, 0xC5325B49, BRF_GRA }, // 7 Text layer { "a47_04.bin", 0x002000, 0xCD59628E, BRF_GRA }, // 8 { "a47_09.bin", 0x004000, 0x31FAE8A8, BRF_GRA }, // 9 Background layer { "a47_08.bin", 0x004000, 0xE539AF2B, BRF_GRA }, // 10 { "a47_07.bin", 0x004000, 0x02FDD429, BRF_GRA }, // 11 { "a47_06.bin", 0x004000, 0x11FBCC8C, BRF_GRA }, // 12 { "82s129.12q", 0x000100, 0x2C69350D, BRF_GRA }, // 13 { "82s129.12m", 0x000100, 0x7142E972, BRF_GRA }, // 14 { "82s129.12n", 0x000100, 0x25F273F2, BRF_GRA }, // 15 { "a47_03.bin", 0x002000, 0xD105260F, BRF_ESS | BRF_PRG }, // 16 { "a47_14.6a", 0x000800, 0x4042489f, BRF_ESS | BRF_PRG }, // 17 MCU ROM }; STD_ROM_PICK(tigerhj) STD_ROM_FN(tigerhj) static struct BurnRomInfo tigerhb1RomDesc[] = { { "b0.5", 0x004000, 0x6ae7e13c, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "a47_01.bin", 0x004000, 0x65df2152, BRF_ESS | BRF_PRG }, // 1 { "a47_02.bin", 0x004000, 0x633D324B, BRF_ESS | BRF_PRG }, // 2 { "a47_13.bin", 0x004000, 0x739A7E7E, BRF_GRA }, // 3 Sprite data { "a47_12.bin", 0x004000, 0xC064ECDB, BRF_GRA }, // 4 { "a47_11.bin", 0x004000, 0x744FAE9B, BRF_GRA }, // 5 { "a47_10.bin", 0x004000, 0xE1CF844E, BRF_GRA }, // 6 { "a47_05.bin", 0x002000, 0xC5325B49, BRF_GRA }, // 7 Text layer { "a47_04.bin", 0x002000, 0xCD59628E, BRF_GRA }, // 8 { "a47_09.bin", 0x004000, 0x31FAE8A8, BRF_GRA }, // 9 Background layer { "a47_08.bin", 0x004000, 0xE539AF2B, BRF_GRA }, // 10 { "a47_07.bin", 0x004000, 0x02FDD429, BRF_GRA }, // 11 { "a47_06.bin", 0x004000, 0x11FBCC8C, BRF_GRA }, // 12 { "82s129.12q", 0x000100, 0x2C69350D, BRF_GRA }, // 13 { "82s129.12m", 0x000100, 0x7142E972, BRF_GRA }, // 14 { "82s129.12n", 0x000100, 0x25F273F2, BRF_GRA }, // 15 { "a47_03.bin", 0x002000, 0xD105260F, BRF_ESS | BRF_PRG }, // 16 }; STD_ROM_PICK(tigerhb1) STD_ROM_FN(tigerhb1) static struct BurnRomInfo tigerhb2RomDesc[] = { { "rom00_09.bin", 0x004000, 0xef738c68, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "a47_01.bin", 0x004000, 0x65df2152, BRF_ESS | BRF_PRG }, // 1 { "rom02_07.bin", 0x004000, 0x36e250b9, BRF_ESS | BRF_PRG }, // 2 { "a47_13.bin", 0x004000, 0x739A7E7E, BRF_GRA }, // 3 Sprite data { "a47_12.bin", 0x004000, 0xC064ECDB, BRF_GRA }, // 4 { "a47_11.bin", 0x004000, 0x744FAE9B, BRF_GRA }, // 5 { "a47_10.bin", 0x004000, 0xE1CF844E, BRF_GRA }, // 6 { "a47_05.bin", 0x002000, 0xC5325B49, BRF_GRA }, // 7 Text layer { "a47_04.bin", 0x002000, 0xCD59628E, BRF_GRA }, // 8 { "a47_09.bin", 0x004000, 0x31FAE8A8, BRF_GRA }, // 9 Background layer { "a47_08.bin", 0x004000, 0xE539AF2B, BRF_GRA }, // 10 { "a47_07.bin", 0x004000, 0x02FDD429, BRF_GRA }, // 11 { "a47_06.bin", 0x004000, 0x11FBCC8C, BRF_GRA }, // 12 { "82s129.12q", 0x000100, 0x2C69350D, BRF_GRA }, // 13 { "82s129.12m", 0x000100, 0x7142E972, BRF_GRA }, // 14 { "82s129.12n", 0x000100, 0x25F273F2, BRF_GRA }, // 15 { "a47_03.bin", 0x002000, 0xD105260F, BRF_ESS | BRF_PRG }, // 16 }; STD_ROM_PICK(tigerhb2) STD_ROM_FN(tigerhb2) static struct BurnRomInfo tigerhb3RomDesc[] = { { "14", 0x004000, 0xCA59DD73, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "13", 0x004000, 0x38BD54DB, BRF_ESS | BRF_PRG }, // 1 { "a47_02.bin", 0x004000, 0x633D324B, BRF_ESS | BRF_PRG }, // 2 { "a47_13.bin", 0x004000, 0x739A7E7E, BRF_GRA }, // 3 Sprite data { "a47_12.bin", 0x004000, 0xC064ECDB, BRF_GRA }, // 4 { "a47_11.bin", 0x004000, 0x744FAE9B, BRF_GRA }, // 5 { "a47_10.bin", 0x004000, 0xE1CF844E, BRF_GRA }, // 6 { "a47_05.bin", 0x002000, 0xC5325B49, BRF_GRA }, // 7 Text layer { "a47_04.bin", 0x002000, 0xCD59628E, BRF_GRA }, // 8 { "a47_09.bin", 0x004000, 0x31FAE8A8, BRF_GRA }, // 9 Background layer { "a47_08.bin", 0x004000, 0xE539AF2B, BRF_GRA }, // 10 { "a47_07.bin", 0x004000, 0x02FDD429, BRF_GRA }, // 11 { "a47_06.bin", 0x004000, 0x11FBCC8C, BRF_GRA }, // 12 { "82s129.12q", 0x000100, 0x2C69350D, BRF_GRA }, // 13 { "82s129.12m", 0x000100, 0x7142E972, BRF_GRA }, // 14 { "82s129.12n", 0x000100, 0x25F273F2, BRF_GRA }, // 15 { "a47_03.bin", 0x002000, 0xD105260F, BRF_ESS | BRF_PRG }, // 16 }; STD_ROM_PICK(tigerhb3) STD_ROM_FN(tigerhb3) static struct BurnRomInfo getstarRomDesc[] = { { "rom0", 0x004000, 0x6A8BDC6C, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "rom1", 0x004000, 0xEBE8DB3C, BRF_ESS | BRF_PRG }, // 1 { "rom2", 0x008000, 0x343E8415, BRF_ESS | BRF_PRG }, // 2 { "a68-13", 0x008000, 0x643FB282, BRF_GRA }, // 3 Sprite data { "a68-12", 0x008000, 0x11F74E32, BRF_GRA }, // 4 { "a68-11", 0x008000, 0xF24158CF, BRF_GRA }, // 5 { "a68-10", 0x008000, 0x83161Ed0, BRF_GRA }, // 6 { "a68_05-1", 0x002000, 0x06F60107, BRF_GRA }, // 7 Text layer { "a68_04-1", 0x002000, 0x1FC8F277, BRF_GRA }, // 8 { "a68_09", 0x008000, 0xA293CC2E, BRF_GRA }, // 9 Background layer { "a68_08", 0x008000, 0x37662375, BRF_GRA }, // 10 { "a68_07", 0x008000, 0xCF1A964C, BRF_GRA }, // 11 { "a68_06", 0x008000, 0x05F9EB9A, BRF_GRA }, // 12 { "rom21", 0x000100, 0xD6360B4D, BRF_GRA }, // 13 { "rom20", 0x000100, 0x4CA01887, BRF_GRA }, // 14 { "rom19", 0x000100, 0x513224F0, BRF_GRA }, // 15 { "a68-03", 0x002000, 0x18DAA44C, BRF_ESS | BRF_PRG }, // 16 { "68705.bin", 0x000800, 0x00000000, BRF_NODUMP | BRF_ESS | BRF_PRG }, // 17 MCU ROM }; STD_ROM_PICK(getstar) STD_ROM_FN(getstar) static struct BurnRomInfo getstarjRomDesc[] = { { "a68_00.bin", 0x004000, 0xAD1A0143, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "a68_01.bin", 0x004000, 0x3426EB7C, BRF_ESS | BRF_PRG }, // 1 { "a68_02.bin", 0x008000, 0x3567DA17, BRF_ESS | BRF_PRG }, // 2 { "a68-13", 0x008000, 0x643FB282, BRF_GRA }, // 3 Sprite data { "a68-12", 0x008000, 0x11F74E32, BRF_GRA }, // 4 { "a68-11", 0x008000, 0xF24158CF, BRF_GRA }, // 5 { "a68-10", 0x008000, 0x83161Ed0, BRF_GRA }, // 6 { "a68_05", 0x002000, 0xE3D409E7, BRF_GRA }, // 7 Text layer { "a68_04", 0x002000, 0x6E5AC9D4, BRF_GRA }, // 8 { "a68_09", 0x008000, 0xA293CC2E, BRF_GRA }, // 9 Background layer { "a68_08", 0x008000, 0x37662375, BRF_GRA }, // 10 { "a68_07", 0x008000, 0xCF1A964C, BRF_GRA }, // 11 { "a68_06", 0x008000, 0x05F9EB9A, BRF_GRA }, // 12 { "rom21", 0x000100, 0xD6360B4D, BRF_GRA }, // 13 { "rom20", 0x000100, 0x4CA01887, BRF_GRA }, // 14 { "rom19", 0x000100, 0x513224F0, BRF_GRA }, // 15 { "a68-03", 0x002000, 0x18DAA44C, BRF_ESS | BRF_PRG }, // 16 { "68705.bin", 0x000800, 0x00000000, BRF_ESS | BRF_PRG | BRF_NODUMP }, // 17 MCU ROM }; STD_ROM_PICK(getstarj) STD_ROM_FN(getstarj) static struct BurnRomInfo gtstarb1RomDesc[] = { { "gs_rb_1.bin", 0x004000, 0x9afad7e0, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "gs_rb_2.bin", 0x004000, 0x5feb0a60, BRF_ESS | BRF_PRG }, // 1 { "gs_rb_3.bin", 0x008000, 0xe3cfb1ba, BRF_ESS | BRF_PRG }, // 2 { "a68-13", 0x008000, 0x643FB282, BRF_GRA }, // 3 Sprite data { "a68-12", 0x008000, 0x11F74E32, BRF_GRA }, // 4 { "a68-11", 0x008000, 0xF24158CF, BRF_GRA }, // 5 { "a68-10", 0x008000, 0x83161Ed0, BRF_GRA }, // 6 { "a68_05.bin", 0x002000, 0xE3D409E7, BRF_GRA }, // 7 Text layer { "a68_04.bin", 0x002000, 0x6E5AC9D4, BRF_GRA }, // 8 { "a68_09", 0x008000, 0xA293CC2E, BRF_GRA }, // 9 Background layer { "a68_08", 0x008000, 0x37662375, BRF_GRA }, // 10 { "a68_07", 0x008000, 0xCF1A964C, BRF_GRA }, // 11 { "a68_06", 0x008000, 0x05F9EB9A, BRF_GRA }, // 12 { "rom21", 0x000100, 0xD6360B4D, BRF_GRA }, // 13 { "rom20", 0x000100, 0x4CA01887, BRF_GRA }, // 14 { "rom19", 0x000100, 0x513224F0, BRF_GRA }, // 15 { "a68-03", 0x002000, 0x18DAA44C, BRF_ESS | BRF_PRG }, // 16 }; STD_ROM_PICK(gtstarb1) STD_ROM_FN(gtstarb1) static struct BurnRomInfo gtstarb2RomDesc[] = { { "gs_14.rom", 0x004000, 0x1A57A920, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "gs_13.rom", 0x004000, 0x805F8E77, BRF_ESS | BRF_PRG }, // 1 { "a68_02.bin", 0x008000, 0x3567DA17, BRF_ESS | BRF_PRG }, // 2 { "a68-13", 0x008000, 0x643FB282, BRF_GRA }, // 3 Sprite data { "a68-12", 0x008000, 0x11F74E32, BRF_GRA }, // 4 { "a68-11", 0x008000, 0xF24158CF, BRF_GRA }, // 5 { "a68-10", 0x008000, 0x83161Ed0, BRF_GRA }, // 6 { "a68_05.bin", 0x002000, 0xE3D409E7, BRF_GRA }, // 7 Text layer { "a68_04.bin", 0x002000, 0x6E5AC9D4, BRF_GRA }, // 8 { "a68_09", 0x008000, 0xA293CC2E, BRF_GRA }, // 9 Background layer { "a68_08", 0x008000, 0x37662375, BRF_GRA }, // 10 { "a68_07", 0x008000, 0xCF1A964C, BRF_GRA }, // 11 { "a68_06", 0x008000, 0x05F9EB9A, BRF_GRA }, // 12 { "rom21", 0x000100, 0xD6360B4D, BRF_GRA }, // 13 { "rom20", 0x000100, 0x4CA01887, BRF_GRA }, // 14 { "rom19", 0x000100, 0x513224F0, BRF_GRA }, // 15 { "a68-03", 0x002000, 0x18DAA44C, BRF_ESS | BRF_PRG }, // 16 }; STD_ROM_PICK(gtstarb2) STD_ROM_FN(gtstarb2) static struct BurnRomInfo slapfighRomDesc[] = { { "sf_r19.bin", 0x008000, 0x674C0E0F, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "sf_rh.bin", 0x008000, 0x3C42E4A7, BRF_ESS | BRF_PRG }, // 1 { "sf_r03.bin", 0x008000, 0x8545D397, BRF_GRA }, // 2 Sprite data { "sf_r01.bin", 0x008000, 0xB1B7B925, BRF_GRA }, // 3 { "sf_r04.bin", 0x008000, 0x422D946B, BRF_GRA }, // 4 { "sf_r02.bin", 0x008000, 0x587113AE, BRF_GRA }, // 5 { "sf_r11.bin", 0x002000, 0x2AC7B943, BRF_GRA }, // 6 Text layer { "sf_r10.bin", 0x002000, 0x33CADC93, BRF_GRA }, // 7 { "sf_r06.bin", 0x008000, 0xB6358305, BRF_GRA }, // 8 Background layer { "sf_r09.bin", 0x008000, 0xE92D9D60, BRF_GRA }, // 9 { "sf_r08.bin", 0x008000, 0x5FAEEEA3, BRF_GRA }, // 10 { "sf_r07.bin", 0x008000, 0x974E2EA9, BRF_GRA }, // 11 { "sf_col21.bin", 0x000100, 0xA0EFAF99, BRF_GRA }, // 12 { "sf_col20.bin", 0x000100, 0xA56D57E5, BRF_GRA }, // 13 { "sf_col19.bin", 0x000100, 0x5CBF9FBF, BRF_GRA }, // 14 { "sf_r05.bin", 0x002000, 0x87F4705A, BRF_ESS | BRF_PRG }, // 15 { "68705.bin", 0x000800, 0x00000000, BRF_NODUMP | BRF_ESS | BRF_PRG }, // 16 MCU ROM }; STD_ROM_PICK(slapfigh) STD_ROM_FN(slapfigh) static struct BurnRomInfo slapbtjpRomDesc[] = { { "sf_r19jb.bin", 0x008000, 0x9A7AC8B3, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "sf_rh.bin", 0x008000, 0x3C42E4A7, BRF_ESS | BRF_PRG }, // 1 { "sf_r03.bin", 0x008000, 0x8545D397, BRF_GRA }, // 2 Sprite data { "sf_r01.bin", 0x008000, 0xB1B7B925, BRF_GRA }, // 3 { "sf_r04.bin", 0x008000, 0x422D946B, BRF_GRA }, // 4 { "sf_r02.bin", 0x008000, 0x587113AE, BRF_GRA }, // 5 { "sf_r11.bin", 0x002000, 0x2AC7B943, BRF_GRA }, // 6 Text layer { "sf_r10.bin", 0x002000, 0x33CADC93, BRF_GRA }, // 7 { "sf_r06.bin", 0x008000, 0xB6358305, BRF_GRA }, // 8 Background layer { "sf_r09.bin", 0x008000, 0xE92D9D60, BRF_GRA }, // 9 { "sf_r08.bin", 0x008000, 0x5FAEEEA3, BRF_GRA }, // 10 { "sf_r07.bin", 0x008000, 0x974E2EA9, BRF_GRA }, // 11 { "sf_col21.bin", 0x000100, 0xA0EFAF99, BRF_GRA }, // 12 { "sf_col20.bin", 0x000100, 0xA56D57E5, BRF_GRA }, // 13 { "sf_col19.bin", 0x000100, 0x5CBF9FBF, BRF_GRA }, // 14 { "sf_r05.bin", 0x002000, 0x87F4705A, BRF_ESS | BRF_PRG }, // 15 }; STD_ROM_PICK(slapbtjp) STD_ROM_FN(slapbtjp) static struct BurnRomInfo SlapfighaRomDesc[] = { { "a76-00.bin", 0x4000, 0xac22bb86, BRF_ESS | BRF_PRG }, // 0 { "a76-01.bin", 0x4000, 0xd6b4f02e, BRF_ESS | BRF_PRG }, // 1 { "a76-13.bin", 0x008000, 0x8545d397, BRF_GRA }, // 2 Sprite data { "a76-12.bin", 0x008000, 0xb1b7b925, BRF_GRA }, // 3 { "a76-11.bin", 0x008000, 0x422d946b, BRF_GRA }, // 4 { "a76-10.bin", 0x008000, 0x587113ae, BRF_GRA }, // 5 { "a76-05.bin", 0x002000, 0xbe9a1bc5, BRF_GRA }, // 6 Text layer { "a76-04.bin", 0x002000, 0x3519daa4, BRF_GRA }, // 7 { "a76-09.bin", 0x008000, 0xb6358305, BRF_GRA }, // 8 Background layer { "a76-08.bin", 0x008000, 0xe92d9d60, BRF_GRA }, // 9 { "a76-07.bin", 0x008000, 0x5faeeea3, BRF_GRA }, // 10 { "a76-06.bin", 0x008000, 0x974e2ea9, BRF_GRA }, // 11 { "sf_col21.bin", 0x000100, 0xA0EFAF99, BRF_GRA }, // 12 { "sf_col20.bin", 0x000100, 0xA56D57E5, BRF_GRA }, // 13 { "sf_col19.bin", 0x000100, 0x5CBF9FBF, BRF_GRA }, // 14 { "a76-03.bin", 0x002000, 0x87F4705A, BRF_ESS | BRF_PRG }, // 15 { "a76-02.bin", 0x8000, 0x9dd0971f, BRF_ESS | BRF_PRG }, // 16 (third prog. rom) { "68705.bin", 0x000800, 0x00000000, BRF_ESS | BRF_PRG | BRF_NODUMP }, // 17 MCU ROM }; STD_ROM_PICK(Slapfigha) STD_ROM_FN(Slapfigha) static struct BurnRomInfo slapbtukRomDesc[] = { { "sf_r19eb.bin", 0x004000, 0x2efe47af, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "sf_r20eb.bin", 0x004000, 0xf42c7951, BRF_ESS | BRF_PRG }, // 1 { "sf_rh.bin", 0x008000, 0x3C42E4A7, BRF_ESS | BRF_PRG }, // 1 { "sf_r03.bin", 0x008000, 0x8545D397, BRF_GRA }, // 2 Sprite data { "sf_r01.bin", 0x008000, 0xB1B7B925, BRF_GRA }, // 3 { "sf_r04.bin", 0x008000, 0x422D946B, BRF_GRA }, // 4 { "sf_r02.bin", 0x008000, 0x587113AE, BRF_GRA }, // 5 { "sf_r11.bin", 0x002000, 0x2AC7B943, BRF_GRA }, // 6 Text layer { "sf_r10.bin", 0x002000, 0x33CADC93, BRF_GRA }, // 7 { "sf_r06.bin", 0x008000, 0xB6358305, BRF_GRA }, // 8 Background layer { "sf_r09.bin", 0x008000, 0xE92D9D60, BRF_GRA }, // 9 { "sf_r08.bin", 0x008000, 0x5FAEEEA3, BRF_GRA }, // 10 { "sf_r07.bin", 0x008000, 0x974E2EA9, BRF_GRA }, // 11 { "sf_col21.bin", 0x000100, 0xA0EFAF99, BRF_GRA }, // 12 { "sf_col20.bin", 0x000100, 0xA56D57E5, BRF_GRA }, // 13 { "sf_col19.bin", 0x000100, 0x5CBF9FBF, BRF_GRA }, // 14 { "sf_r05.bin", 0x002000, 0x87F4705A, BRF_ESS | BRF_PRG }, // 15 }; STD_ROM_PICK(slapbtuk) STD_ROM_FN(slapbtuk) static struct BurnRomInfo slapfgtrRomDesc[] = { { "k1-10.u90", 0x004000, 0x2efe47af, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "k1-09.u89", 0x004000, 0x17c187c5, BRF_ESS | BRF_PRG }, // 1 { "k1-08.u88", 0x002000, 0x945af97f, BRF_ESS | BRF_PRG }, // 1 { "k1-07.u87", 0x008000, 0x3C42E4A7, BRF_ESS | BRF_PRG }, // 1 { "k1-15.u60", 0x008000, 0x8545D397, BRF_GRA }, // 2 Sprite data { "k1-13.u50", 0x008000, 0xB1B7B925, BRF_GRA }, // 3 { "k1-14.u59", 0x008000, 0x422D946B, BRF_GRA }, // 4 { "k1-12.u49", 0x008000, 0x587113AE, BRF_GRA }, // 5 { "k1-02.u57" , 0x002000, 0x2AC7B943, BRF_GRA }, // 6 Text layer { "k1-03.u58", 0x002000, 0x33CADC93, BRF_GRA }, // 7 { "k1-01.u49" , 0x008000, 0xB6358305, BRF_GRA }, // 8 Background layer { "k1-04.u62", 0x008000, 0xE92D9D60, BRF_GRA }, // 9 { "k1-05.u63", 0x008000, 0x5FAEEEA3, BRF_GRA }, // 10 { "k1-06.u64", 0x008000, 0x974E2EA9, BRF_GRA }, // 11 { "sf_col21.bin", 0x000100, 0xA0EFAF99, BRF_GRA }, // 12 { "sf_col20.bin", 0x000100, 0xA56D57E5, BRF_GRA }, // 13 { "sf_col19.bin", 0x000100, 0x5CBF9FBF, BRF_GRA }, // 14 { "k1-11.u89", 0x002000, 0x87F4705A, BRF_ESS | BRF_PRG }, // 15 }; STD_ROM_PICK(slapfgtr) STD_ROM_FN(slapfgtr) static struct BurnRomInfo alconRomDesc[] = { { "00", 0x008000, 0x2ba82d60, BRF_ESS | BRF_PRG }, // 0 CPU #0 code { "01", 0x008000, 0x18bb2f12, BRF_ESS | BRF_PRG }, // 1 { "sf_r03.bin", 0x008000, 0x8545D397, BRF_GRA }, // 2 Sprite data { "sf_r01.bin", 0x008000, 0xB1B7B925, BRF_GRA }, // 3 { "sf_r04.bin", 0x008000, 0x422D946B, BRF_GRA }, // 4 { "sf_r02.bin", 0x008000, 0x587113AE, BRF_GRA }, // 5 { "04", 0x002000, 0x31003483, BRF_GRA }, // 6 Text layer { "03", 0x002000, 0x404152c0, BRF_GRA }, // 7 { "sf_r06.bin", 0x008000, 0xB6358305, BRF_GRA }, // 8 Background layer { "sf_r09.bin", 0x008000, 0xE92D9D60, BRF_GRA }, // 9 { "sf_r08.bin", 0x008000, 0x5FAEEEA3, BRF_GRA }, // 10 { "sf_r07.bin", 0x008000, 0x974E2EA9, BRF_GRA }, // 11 { "sf_col21.bin", 0x000100, 0xA0EFAF99, BRF_GRA }, // 12 { "sf_col20.bin", 0x000100, 0xA56D57E5, BRF_GRA }, // 13 { "sf_col19.bin", 0x000100, 0x5CBF9FBF, BRF_GRA }, // 14 { "sf_r05.bin", 0x002000, 0x87F4705A, BRF_ESS | BRF_PRG }, // 15 { "68705.bin", 0x000800, 0x00000000, BRF_ESS | BRF_PRG | BRF_NODUMP }, // 16 MCU ROM }; STD_ROM_PICK(alcon) STD_ROM_FN(alcon) struct BurnDriver BurnDrvTigerH = { "tigerh", NULL, NULL, "1985", "Tiger Heli (US)\0", "Protection MCU not emulated", "Taito", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, tigerhRomInfo, tigerhRomName, tigerhInputInfo, tigerhDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvTigerHB1 = { "tigerhb1", "tigerh", NULL, "1985", "Tiger Heli (bootleg, set 1)\0", NULL, "bootleg", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, tigerhb1RomInfo, tigerhb1RomName, tigerhInputInfo, tigerhDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvTigerHB2 = { "tigerhb2", "tigerh", NULL, "1985", "Tiger Heli (bootleg, set 2)\0", NULL, "bootleg", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, tigerhb2RomInfo, tigerhb2RomName, tigerhInputInfo, tigerhDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvTigerHB3 = { "tigerhb3", "tigerh", NULL, "1985", "Tiger Heli (bootleg, set 3)\0", NULL, "bootleg", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, tigerhb3RomInfo, tigerhb3RomName, tigerhInputInfo, tigerhDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvTigerHj = { "tigerhj", "tigerh", NULL, "1985", "Tiger Heli (Japan)\0", NULL, "Taito / Toaplan", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, tigerhjRomInfo, tigerhjRomName, tigerhInputInfo, tigerhDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvGetStar = { "getstar", NULL, NULL, "1986", "Guardian\0", "Protection MCU not emulated", "Taito", "Early Toaplan", NULL, NULL, NULL, NULL, 0, 2, HARDWARE_MISC_MISC, NULL, getstarRomInfo, getstarRomName, tigerhInputInfo, getstarDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 280, 240, 4, 3 }; struct BurnDriver BurnDrvGetStarj = { "getstarj", "getstar", NULL, "1986", "Get Star (Japan)\0", "Protection MCU not emulated", "Taito", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, getstarjRomInfo, getstarjRomName, tigerhInputInfo, getstarDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 280, 240, 4, 3 }; struct BurnDriver BurnDrvGtstarb1 = { "gtstarb1", "getstar", NULL, "1986", "Get Star (bootleg set 1)\0", NULL, "bootleg", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_MISC_MISC, NULL, gtstarb1RomInfo, gtstarb1RomName, gtstarbaInputInfo, gtstarbaDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 280, 240, 4, 3 }; struct BurnDriver BurnDrvGtstarb2 = { "gtstarb2", "getstar", NULL, "1986", "Get Star (bootleg set 2)\0", NULL, "bootleg", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_MISC_MISC, NULL, gtstarb2RomInfo, gtstarb2RomName, tigerhInputInfo, getstarDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 280, 240, 4, 3 }; struct BurnDriver BurnDrvSlapFigh = { "slapfigh", NULL, NULL, "1986", "Slap Fight (set 1)\0", "Protection MCU not emulated", "Taito", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, slapfighRomInfo, slapfighRomName, tigerhInputInfo, slapfighDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvSlapBtJP = { "slapbtjp", "slapfigh", NULL, "1986", "Slap Fight (Japan bootleg)\0", NULL, "Taito / Toaplan", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, slapbtjpRomInfo, slapbtjpRomName, tigerhInputInfo, slapfighDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvSlapBtUK = { "slapbtuk", "slapfigh", NULL, "1986", "Slap Fight (English bootleg)\0", NULL, "Taito / Toaplan", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, slapbtukRomInfo, slapbtukRomName, tigerhInputInfo, slapfighDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvSlapfigha = { "slapfigha", "slapfigh", NULL, "1986", "Slap Fight (set 2)\0", "Protection MCU not emulated", "Taito / Toaplan", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, SlapfighaRomInfo, SlapfighaRomName, tigerhInputInfo, slapfighDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvSlapFghtr = { "slapfgtr", "slapfigh", NULL, "1986", "Slap Fight (bootleg)\0", NULL, "Taito", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, slapfgtrRomInfo, slapfgtrRomName, tigerhInputInfo, slapfighDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 }; struct BurnDriver BurnDrvAlcon = { "alcon", "slapfigh", NULL, "1986", "Alcon\0", NULL, "Taito America Corp.", "Early Toaplan", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, alconRomInfo, alconRomName, tigerhInputInfo, slapfighDIPInfo, tigerhInit, tigerhExit, tigerhFrame, NULL, tigerhScan, &tigerhRecalcPalette, 240, 280, 3, 4 };
[ [ [ 1, 2361 ] ] ]
c9f9b615ae2666d68327339e5fa38b84b854fef7
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Physics/Dynamics/Constraint/Bilateral/PointToPlane/hkpPointToPlaneConstraintData.h
cf647deb1a54cc9f7f20b77b9b893a0b283347be
[]
no_license
blockspacer/transporter-game
23496e1651b3c19f6727712a5652f8e49c45c076
083ae2ee48fcab2c7d8a68670a71be4d09954428
refs/heads/master
2021-05-31T04:06:07.101459
2009-02-19T20:59:59
2009-02-19T20:59:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,583
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_DYNAMICS2_POINT_TO_PLANE_CONSTRAINT_H #define HK_DYNAMICS2_POINT_TO_PLANE_CONSTRAINT_H #include <Physics/ConstraintSolver/Solve/hkpSolverResults.h> #include <Physics/Dynamics/Constraint/hkpConstraintData.h> #include <Physics/ConstraintSolver/Constraint/Atom/hkpConstraintAtom.h> extern const hkClass hkpPointToPlaneConstraintDataClass; /// A stiff spring constraint. It holds the constrained bodies apart at a specified distance, /// as if they were attached at each end of an invisible rod. class hkpPointToPlaneConstraintData : public hkpConstraintData { public: HK_DECLARE_REFLECTION(); hkpPointToPlaneConstraintData(); /// Sets the point-to-plane up with world space information. /// \param pivotW Specifies both the origin point for the constraining plane, and bodyB's pivot point, specified in world space. /// \param planeNormalW Specifies the normal direction of the constraining plane, specified in world space. void setInWorldSpace(const hkTransform& bodyATransform, const hkTransform& bodyBTransform, const hkVector4& pivotW, const hkVector4& planeNormalW); /// Sets the point-to-plane up with body space information. /// \param pivotA Specifies the origin point for the constraining plane, specified in bodyA's space. /// \param pivotB BodyB's pivot point, specified in bodyB's space. /// \param planeNormalB Specifies the normal direction of the constraining plane, specified in bodyB's space. void setInBodySpace( const hkVector4& pivotA, const hkVector4& pivotB, const hkVector4& planeNormalB); /// Check consistency of constraint hkBool isValid() const; /// Get type from this constraint virtual int getType() const; public: enum { SOLVER_RESULT_LIN_0 = 0, // linear constraint SOLVER_RESULT_MAX = 1 }; struct Runtime { HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DYNAMICS, hkpPointToPlaneConstraintData::Runtime ); class hkpSolverResults m_solverResults[1/*VC6 doesn't like the scoping for SOLVER_RESULT_MAX*/]; }; inline const Runtime* getRuntime( hkpConstraintRuntime* runtime ){ return reinterpret_cast<Runtime*>(runtime); } struct Atoms { HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DYNAMICS, hkpPointToPlaneConstraintData::Atoms ); HK_DECLARE_REFLECTION(); struct hkpSetLocalTransformsConstraintAtom m_transforms; struct hkpLinConstraintAtom m_lin; Atoms(){} // get a pointer to the first atom const hkpConstraintAtom* getAtoms() const { return &m_transforms; } // get the size of all atoms (we can't use sizeof(*this) because of align16 padding) int getSizeOfAllAtoms() const { return hkGetByteOffsetInt(this, &m_lin+1); } Atoms(hkFinishLoadedObjectFlag f) : m_transforms(f), m_lin(f) {} }; HK_ALIGN16( struct Atoms m_atoms ); public: // Internal functions // hkpConstraintData interface implementations virtual void getConstraintInfo( ConstraintInfo& infoOut ) const ; // hkpConstraintData interface implementations virtual void getRuntimeInfo( hkBool wantRuntime, hkpConstraintData::RuntimeInfo& infoOut ) const; public: hkpPointToPlaneConstraintData(hkFinishLoadedObjectFlag f) : hkpConstraintData(f), m_atoms(f) {} }; #endif // HK_DYNAMICS2_POINT_TO_PLANE_CONSTRAINT_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529) * * Confidential Information of Havok. (C) Copyright 1999-2008 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at * www.havok.com/tryhavok * */
[ "uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4" ]
[ [ [ 1, 117 ] ] ]
a0ffeb0c5f0645c0ab516fd0ce96cb417539affa
14bc620a0365e83444dad45611381c7f6bcd052b
/ITUEngine/Events/EventData/EmptyEventData.cpp
15ec6845bf37be2add50d6089b0401ba88e71741
[]
no_license
jumoel/itu-gameengine
a5750bfdf391ae64407217bfc1df8b2a3db551c7
062dd47bc1be0f39a0add8615e81361bcaa2bd4c
refs/heads/master
2020-05-03T20:39:31.307460
2011-12-19T10:54:10
2011-12-19T10:54:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
304
cpp
#include <Events/EventData/EmptyEventData.hpp> EmptyEventData::EmptyEventData( const EventType & eventType, const float timeStamp /*= 0.0f */ ) : m_EventType ( eventType ) , BaseEventData ( timeStamp ) { } const EventType & EmptyEventData::GetEventType() const { return m_EventType; }
[ [ [ 1, 13 ] ] ]
0d7e8e9c0e1b09e869d4aa15f05566d6b3c61b79
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEFoundation/SESharedArrays/SEVector2Array.cpp
829831d9de1f2101187c331cedc3e6fe7d9fc637
[]
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
1,175
cpp
// 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 #include "SEFoundationPCH.h" #include "SEVector2Array.h" using namespace Swing; SE_IMPLEMENT_TEMPLATE_RTTI(Swing, SEVector2fArray, SEObject); SE_IMPLEMENT_TEMPLATE_STREAM(SEVector2fArray); //SE_REGISTER_STREAM(SEVector2fArray);
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 29 ] ] ]
a5c43bc8b8c4821772232134e67314e997294b49
91e66307c16b7bc5ac09a00e59e22872029d2dfe
/code/fdynamics/source/core/RealType.h
956193bdc1beb03fcdb203b2af0c59ad46b0e832
[]
no_license
BackupTheBerlios/artbody-svn
52a7d0e780b077c9972ab25558916b772b8d8289
3dde2231e92d6c53b33021e333da1a434ab10c44
refs/heads/master
2016-09-03T01:53:14.446671
2008-02-06T16:33:58
2008-02-06T16:33:58
40,725,063
0
0
null
null
null
null
UTF-8
C++
false
false
1,944
h
/////////////////////////////////////////////////////////////////////////////// // // Copyright 1998 Mitsubishi Electric Information Technology Center // America (MEITCA). All Rights Reserved. // // Permission to use, copy, modify and distribute this software and // its documentation for educational, research and non-profit // purposes, without fee, and without a written agreement is hereby // granted, provided that the above copyright notice and the // following three paragraphs appear in all copies. // // Permission to incorporate this software into commercial products // may be obtained from MERL - A Mitsubishi Electric Research Lab, 201 // Broadway, Cambridge, MA 02139. // // IN NO EVENT SHALL MEITCA BE LIABLE TO ANY PARTY FOR DIRECT, // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING // LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS // DOCUMENTATION, EVEN IF MEITCA HAS BEEN ADVISED OF THE POSSIBILITY // OF SUCH DAMAGES. // // MEITCA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON // AN "AS IS" BASIS, AND MEITCA HAS NO OBLIGATIONS TO PROVIDE // MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. // // Author: // Brian Mirtich // [email protected] // 617.621.7573 // www.merl.com/people/mirtich // // Library and API: // James Kuffner, Jr. // [email protected] // 650.725.8812 // http://robotics.stanford.edu/~kuffner // /////////////////////////////////////////////////////////////////////////////// #ifndef REAL_TYPE_H #define REAL_TYPE_H #if OPCOUNTS #include "OpCounter.h" #endif namespace mrt{ #if OPCOUNTS typedef Double Real; #else typedef double Real; #endif } // namespace mrt #endif // REAL_TYPE_H
[ "ilya_p@70fd935d-ab2c-0410-87c7-a1c3f06a4c7f" ]
[ [ [ 1, 59 ] ] ]
f972368262a68e5d788fea6f92c2cca13580e5c5
74e7667ad65cbdaa869c6e384fdd8dc7e94aca34
/MicroFrameworkPK_v4_1/BuildOutput/public/debug/Client/stubs/corlib_native_System_Reflection_ConstructorInfo.h
272752fa74b1f9d295eb647cb56b59d3621aa2af
[ "BSD-3-Clause", "OpenSSL", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
gezidan/NETMF-LPC
5093ab223eb9d7f42396344ea316cbe50a2f784b
db1880a03108db6c7f611e6de6dbc45ce9b9adce
refs/heads/master
2021-01-18T10:59:42.467549
2011-06-28T08:11:24
2011-06-28T08:11:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,098
h
//----------------------------------------------------------------------------- // // ** WARNING! ** // This file was generated automatically by a tool. // Re-running the tool will overwrite this file. // You should copy this file to a custom location // before adding any customization in the copy to // prevent loss of your changes when the tool is // re-run. // //----------------------------------------------------------------------------- #ifndef _CORLIB_NATIVE_SYSTEM_REFLECTION_CONSTRUCTORINFO_H_ #define _CORLIB_NATIVE_SYSTEM_REFLECTION_CONSTRUCTORINFO_H_ namespace System { namespace Reflection { struct ConstructorInfo { // Helper Functions to access fields of managed object // Declaration of stubs. These functions are implemented by Interop code developers static UNSUPPORTED_TYPE Invoke( CLR_RT_HeapBlock* pMngObj, CLR_RT_TypedArray_UNSUPPORTED_TYPE param0, HRESULT &hr ); }; } } #endif //_CORLIB_NATIVE_SYSTEM_REFLECTION_CONSTRUCTORINFO_H_
[ [ [ 1, 29 ] ] ]
7ffd0d06400a6f3ad68eb08fb999924e2c2d63b1
8b506bf34b36af04fa970f2749e0c8033f1a9d7a
/Code/Game/gaMeshDrawer.h
75d59ab9115b2159cd16d0d4490728b33ecfdc74
[]
no_license
gunstar/Prototype
a5155e25d7d54a1991425e7be85bfc7da42c634f
a4448b5f6d18048ecaedf26c71e2b107e021ea6e
refs/heads/master
2021-01-10T21:42:24.221750
2011-11-06T10:16:26
2011-11-06T10:16:26
2,708,481
0
0
null
null
null
null
UTF-8
C++
false
false
409
h
/* gaMeshDrawer */ #ifndef _gaMeshDrawer #define _gaMeshDrawer #include "eiEngine.h" class gaMeshDrawer { public: gaMeshDrawer (eiMesh* mesh) { Mesh = mesh; } void drawCursor (); void drawGrid (int sx, int sz); void drawMap (int sx, int sz); void drawRandomWalk1 (); void drawRandomWalk2 (); void drawTriangle (); private: eiMesh* Mesh; }; #endif
[ [ [ 1, 26 ] ] ]
619800d10f7c85d0ef4b24de90292dc70753d758
ee065463a247fda9a1927e978143186204fefa23
/Src/Engine/Resource/IResource.h
c3114835c819d41206ab53a7eecf2d19417d1d8c
[]
no_license
ptrefall/hinsimviz
32e9a679170eda9e552d69db6578369a3065f863
9caaacd39bf04bbe13ee1288d8578ece7949518f
refs/heads/master
2021-01-22T09:03:52.503587
2010-09-26T17:29:20
2010-09-26T17:29:20
32,448,374
1
0
null
null
null
null
UTF-8
C++
false
false
763
h
#pragma once #include <ClanLib/core.h> namespace Engine { namespace Resource { class ResManager; class IResource { public: IResource(ResManager *manager, const char *fileName) {} virtual ~IResource() {} virtual const char *getResourceType() const = 0; virtual int getInt(const char *id) { return -1; } virtual bool getBool(const char *id) { return false; } virtual CL_String getString(const char *id) { return CL_String(); } virtual unsigned int getGLId() { return 0; } virtual unsigned int getDpp() { return 0; } virtual unsigned int getWidth() { return 0; } virtual unsigned int getHeight() { return 0; } virtual BYTE *getTexBits() { return 0; } virtual CL_DataBuffer *getBuffer() const { return 0; } }; } }
[ "[email protected]@28a56cb3-1e7c-bc60-7718-65c159e1d2df" ]
[ [ [ 1, 33 ] ] ]
08aa47cf27b0ba7e845ca8e6059f71ef3a3fb8cb
105cc69f4207a288be06fd7af7633787c3f3efb5
/HovercraftUniverse/HovercraftUniverse/CharacterContextContainer.cpp
121f56e1ff4ca63ccf7b7cffffdde06cdf75106d
[]
no_license
allenjacksonmaxplayio/uhasseltaacgua
330a6f2751e1d6675d1cf484ea2db0a923c9cdd0
ad54e9aa3ad841b8fc30682bd281c790a997478d
refs/heads/master
2020-12-24T21:21:28.075897
2010-06-09T18:05:23
2010-06-09T18:05:23
56,725,792
0
0
null
null
null
null
UTF-8
C++
false
false
2,133
cpp
#include "CharacterContextContainer.h" namespace HovUni { CharacterContextContainer::CharacterContextContainer() { //create default { hkpCharacterState* state; hkpCharacterStateManager* manager = new hkpCharacterStateManager(); state = new hkpCharacterStateOnGround(); manager->registerState( state, HK_CHARACTER_ON_GROUND); state->removeReference(); state = new hkpCharacterStateInAir(); manager->registerState( state, HK_CHARACTER_IN_AIR); state->removeReference(); state = new hkpCharacterStateJumping(); manager->registerState( state, HK_CHARACTER_JUMPING); state->removeReference(); state = new hkpCharacterStateClimbing(); manager->registerState( state, HK_CHARACTER_CLIMBING); state->removeReference(); hkpCharacterContext * characterContext = new hkpCharacterContext(manager, HK_CHARACTER_IN_AIR); manager->removeReference(); // Set new filter parameters for final output velocity filtering // Smoother interactions with small dynamic boxes characterContext->setCharacterType(hkpCharacterContext::HK_CHARACTER_RIGIDBODY); characterContext->setFilterParameters(0.9f,12.0f,200.0f); registerContext("Default", characterContext); characterContext->removeReference(); } } CharacterContextContainer::~CharacterContextContainer(){ CharacterContextMap::Iterator i = mMap.getIterator(); while ( mMap.isValid(i) ){ hkpCharacterContext * value = mMap.getValue(i); value->removeReference(); //remove the reference added in register mMap.setValue(i, HK_NULL); i = mMap.getNext(i); } mMap.clear(); } void CharacterContextContainer::registerContext( const char * key, hkpCharacterContext * context ) { context->addReference(); //add a reference since we add it to our map mMap.insert(key,context); } hkpCharacterContext * CharacterContextContainer::getCharacterContext( const char * key ){ hkpCharacterContext * context; if ( mMap.get(key,&context) == HK_SUCCESS ){ context->addReference(); return context; } return HK_NULL; } }
[ "pintens.pieterjan@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c" ]
[ [ [ 1, 69 ] ] ]
b4869adc90a5d747fe086cff2cae1a2c6c1125be
7acbb1c1941bd6edae0a4217eb5d3513929324c0
/GLibrary-CPP/sources/GStr.cpp
a7a3c2eb8e3f1e2b537cd9f2f089f9f9d4ce6b85
[]
no_license
hungconcon/geofreylibrary
a5bfc96e0602298b5a7b53d4afe7395a993498f1
3abf3e1c31a245a79fa26b4bcf2e6e86fa258e4d
refs/heads/master
2021-01-10T10:11:51.535513
2009-11-30T15:29:34
2009-11-30T15:29:34
46,771,895
1
1
null
null
null
null
UTF-8
C++
false
false
410
cpp
#include "GStr.h" void GStrcpy(char *dest, char *source) { unsigned int i = 0; while (source[i]) { dest[i] = source[i]; ++i; } dest[i] = 0; } void GStrcpy(char *dest, char *source, unsigned int Size) { unsigned int i = 0; while (i < Size) { dest[i] = source[i]; ++i; } } unsigned int GStrlen(char *Str) { unsigned int i = 0; while (Str[i]) ++i; return (i); }
[ "mvoirgard@34e8d5ee-a372-11de-889f-a79cef5dd62c", "[email protected]" ]
[ [ [ 1, 20 ] ], [ [ 21, 28 ] ] ]
6a25727cb1991e817464a9428dd51733aad3510d
119ba245bea18df8d27b84ee06e152b35c707da1
/unreal/branches/robots/qrgui/kernel/roles.h
3e7ff240e2a27654cab3b39ec16927e2556b03bb
[]
no_license
nfrey/qreal
05cd4f9b9d3193531eb68ff238d8a447babcb3d2
71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164
refs/heads/master
2020-04-06T06:43:41.910531
2011-05-30T19:30:09
2011-05-30T19:30:09
1,634,768
0
0
null
null
null
null
UTF-8
C++
false
false
1,157
h
#pragma once #include <QString> #include <QList> #include "ids.h" namespace qReal { namespace roles { // roles that are heavily used by front-end. should be present in all entities enum { idRole = Qt::UserRole + 1, // element's ID. e.g. qReal::Id logicalIdRole, // For elements of graphical model it is an Id of corresponding logical element, if any. Otherwise it's Id(). positionRole, // element's position within current context (model knows which one it is) configurationRole, // element's configuration (e.g. shape, size) within current context fromRole, // for edges it's an ID of a node, which this edge starts from. is ignored for nodes toRole, // for edges it's an ID of a node, which this edge ends on. is ignored for nodes fromPortRole, // for edges it's a port ID, which this edge starts from. is ignored for nodes toPortRole, // for edges it's a port ID, which this edge ends on. is ignored for nodes customPropertiesBeginRole, // generated roles start from this one // also, `name' is also among the mandatory attributes. it's handled by Qt::EditRole and Qt::DisplayRole }; } }
[ [ [ 1, 24 ] ] ]
d92dcabfbfeff3531460f93043e92c37f1accd93
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/JointSphere.cpp
8a42d041e277816620b37ecd2d809314b770ca23
[]
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
4,193
cpp
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: JointSphere.cpp Version: 0.03 --------------------------------------------------------------------------- */ #include "PrecompiledHeaders.h" #include "JointSphere.h" #include "JointEnumerator.h" #include "PhysXMapping.h" #include "PhysicsActor.h" #pragma warning(push) #pragma warning(disable:4512) #include "NxScene.h" #include "NxSphericalJointDesc.h" #pragma warning(pop) namespace nGENE { // Initialize static members TypeInfo JointSphere::Type(L"JointSphere", &Joint::Type); JointSphere::JointSphere(NxScene* _scene, SJointDesc& _desc): Joint(_scene, _desc), m_pSphereDesc(new NxSphericalJointDesc()) { } //---------------------------------------------------------------------- JointSphere::~JointSphere() { cleanup(); } //---------------------------------------------------------------------- void JointSphere::init() { m_pSphereDesc->actor[0] = m_JointDesc.actor1 ? m_JointDesc.actor1->getActor() : NULL; m_pSphereDesc->actor[1] = m_JointDesc.actor2 ? m_JointDesc.actor2->getActor() : NULL; m_pSphereDesc->localAnchor[0] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localAnchor1); m_pSphereDesc->localAnchor[1] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localAnchor2); m_pSphereDesc->localAxis[0] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localDirection1); m_pSphereDesc->localAxis[1] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localDirection2); SSphereJointDesc& desc = ((SSphereJointDesc&)m_JointDesc); m_pSphereDesc->swingAxis = PhysXMapping::vector3ToNxVec3(desc.swingAxis); m_pSphereDesc->flags = desc.flags; m_pSphereDesc->twistLimit.high.value = desc.twistLimit.highValue; m_pSphereDesc->twistLimit.high.restitution = desc.twistLimit.highRestitution; m_pSphereDesc->twistLimit.low.value = desc.twistLimit.lowValue; m_pSphereDesc->twistLimit.low.restitution = desc.twistLimit.lowRestitution; m_pSphereDesc->swingLimit.value = desc.swingLimit.value; m_pSphereDesc->swingLimit.restitution = desc.swingLimit.restitution; m_pSphereDesc->twistSpring.spring = desc.twistSpring.springCoeff; m_pSphereDesc->twistSpring.damper = desc.twistSpring.damperCoeff; m_pSphereDesc->swingSpring.spring = desc.swingSpring.springCoeff; m_pSphereDesc->swingSpring.damper = desc.swingSpring.damperCoeff; m_pSphereDesc->projectionDistance = desc.projectionDistance; m_pSphereDesc->projectionMode = NX_JPM_POINT_MINDIST; if(!m_pSphereDesc->isValid()) { Log::log(LET_ERROR, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__, L"Spherical joint description is invalid"); return; } if(m_JointDesc.globalDirection != Vector3::ZERO_VECTOR) m_pSphereDesc->setGlobalAxis(PhysXMapping::vector3ToNxVec3(m_JointDesc.globalDirection)); if(m_JointDesc.globalAnchor != Vector3::ZERO_VECTOR) m_pSphereDesc->setGlobalAnchor(PhysXMapping::vector3ToNxVec3(m_JointDesc.globalAnchor)); m_pJoint = m_pScene->createJoint(*m_pSphereDesc); } //---------------------------------------------------------------------- void JointSphere::cleanup() { NGENE_DELETE(m_pSphereDesc); } //---------------------------------------------------------------------- NxJointDesc* JointSphere::getJointDesc() { return (static_cast<NxJointDesc*>(m_pSphereDesc)); } //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- JointSphereFactory::JointSphereFactory() { } //---------------------------------------------------------------------- JointSphereFactory::~JointSphereFactory() { } //---------------------------------------------------------------------- Joint* JointSphereFactory::createJoint(NxScene* _scene, JOINT_DESC& _desc) { return (new JointSphere(_scene, _desc)); } //---------------------------------------------------------------------- }
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 115 ] ] ]
a14e3435131abeec5b68e3bf867d2e01d0b76ebf
c1b7571589975476405feab2e8b72cdd2a592f8f
/chopshop10/Pneumatics166.cpp
4d8b9d087c143bccb45eddb694767d419f84f242
[]
no_license
chopshop-166/frc-2010
ea9cd83f85c9eb86cc44156f21894410a9a4b0b5
e15ceff05536768c29fad54fdefe65dba9a5fab5
refs/heads/master
2021-01-21T11:40:07.493930
2010-12-10T02:04:05
2010-12-10T02:04:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,840
cpp
/******************************************************************************* * Project : chopshop10 - 2010 Chopshop Robot Controller Code * File Name : Pneumatics166.cpp * Owner : Software Group (FIRST Chopshop Team 166) * Creation Date : January 18, 2010 * Revision History : From Explorer with TortoiseSVN, Use "Show log" menu item * File Description : Robot code which controls the pneumatics *******************************************************************************/ /*----------------------------------------------------------------------------*/ /* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */ /*----------------------------------------------------------------------------*/ #include "WPILib.h" #include "Pneumatics166.h" // To locally enable debug printing: set true, to disable false #define DPRINTF if(false)dprintf // Sample in memory buffer struct pbuf166 { struct timespec tp; // Time of snapshot // Any values that need to be logged go here float pressure; // psi bool compressor_on; }; // Memory Log class PneumaticsLog : public MemoryLog166 { public: PneumaticsLog() : MemoryLog166( sizeof(struct pbuf166), PNEUMATICS_CYCLE_TIME, "pneumatics", "Seconds,Nanoseconds,Elapsed Time,PSI,Compressor State\n" ) { return; }; ~PneumaticsLog() {return;}; unsigned int DumpBuffer( // Dump the next buffer into the file char *nptr, // Buffer that needs to be formatted FILE *outputFile); // and then stored in this file unsigned int PutOne(float ppressure, bool compresson_on); // Log the values needed-add in arguments }; // Write one buffer into memory unsigned int PneumaticsLog::PutOne(float ppress, bool c_on) { struct pbuf166 *ob; // Output buffer // Get output buffer if ((ob = (struct pbuf166 *)GetNextBuffer(sizeof(struct pbuf166)))) { // Fill it in. clock_gettime(CLOCK_REALTIME, &ob->tp); // Add any values to be logged here ob->pressure = ppress; ob->compressor_on = c_on; return (sizeof(struct pbuf166)); } // Did not get a buffer. Return a zero length return (0); } // Format the next buffer for file output unsigned int PneumaticsLog::DumpBuffer(char *nptr, FILE *ofile) { struct pbuf166 *ab = (struct pbuf166 *)nptr; // Output the data into the file fprintf(ofile, "%u,%u,%4.5f,%f,%d\n", ab->tp.tv_sec, ab->tp.tv_nsec, ((ab->tp.tv_sec - starttime.tv_sec) + ((ab->tp.tv_nsec-starttime.tv_nsec)/1000000000.)), ab->pressure, ab->compressor_on); // Add values here // Done return (sizeof(struct pbuf166)); } // task constructor Pneumatics166::Pneumatics166(void) { Start((char *)"166PneumaticsTask", PNEUMATICS_CYCLE_TIME); return; }; // task destructor Pneumatics166::~Pneumatics166(void) { return; }; // Main function of the task int Pneumatics166::Main(int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10) { // THE VARS LIVE HERE!!!!!!!!!! Proxy166 *proxy; // Get handle for joystick Robot166 *lHandle; // Local handle PneumaticsLog sl; // Pneumatics log DigitalInput PressureSwitch(T166_PNEUMATIC_PRESSURE_SWITCH); // Pressure switch Relay CompressorSpike(T166_COMPRESSOR_RELAY_CHANNEL,Relay::kForwardOnly); // Compressor spike int CompressorOn = 0; // Compressor state AnalogChannel ps(T166_PNEU_MOD,TI66_PNEU_PRESS); // Pressure sensor float pressure; // Pressure from a/d converter float ppressure; // Pressure converted to psi bool PressureSensorGood = true; // Whether the pressure sensor's good int doprint = 0; // Let the world know we're in DPRINTF(LOG_DEBUG,"In the 166 Pneumatics task\n"); // Wait for Robot go-ahead (e.g. entering Autonomous or Tele-operated mode) WaitForGoAhead(); // Register our logger lHandle = Robot166::getInstance(); lHandle->RegisterLogger(&sl); // Get handle to main Proxy166 proxy = Proxy166::getInstance(); //int printstop=0; // General main loop (while in Autonomous or Tele mode) while ((lHandle->RobotMode == T166_AUTONOMOUS) || (lHandle->RobotMode == T166_OPERATOR)) { // Capture the pressure by adjusted voltage // Subtract 0.5 because sensor ranges from 0.5 to 4.5 pressure = (ps.GetVoltage()-0.5); // If the value is below acceptable range, assume minimum value if( (pressure < 0) || (pressure > 4.0) ) { // 4.5V or greater? SetStatus("error"); if(PressureSensorGood) { DPRINTF(LOG_DEBUG, "Bad values, using backup sensor"); } PressureSensorGood = false; } // Convert voltage to PSI // (250 (Max PSI)/4 (Max adjusted voltage)==62.5) if(PressureSensorGood) { ppressure = (pressure * 62.5); } else { ppressure = (PressureSwitch.Get())? T166_PNEU_HIGH+1 : T166_PNEU_LOW-1; } // Update the pressure value in the proxy proxy->SetPressure(ppressure); // Print various values for debugging if ((doprint++ %40) == 0) DPRINTF(LOG_DEBUG, "Pressure switch value: %d %d \n\t Trim: %f Psi: %f\n", PressureSwitch.Get(), CompressorOn, pressure, ppressure); if(!PressureSwitch.Get()) { CompressorSpike.Set(Relay::kOn); SetStatus("Compressing"); CompressorOn = true; } else { CompressorSpike.Set(Relay::kOff); SetStatus("Decompressing"); CompressorOn = false; } // Logging any values sl.PutOne(ppressure, CompressorOn); // Wait for our next lap WaitForNextLoop(); } return (0); };
[ [ [ 1, 32 ], [ 39, 71 ], [ 76, 108 ], [ 110, 159 ], [ 169, 178 ] ], [ [ 33, 38 ], [ 72, 75 ], [ 109, 109 ], [ 160, 168 ] ] ]
164bb4b42c5ce0df5264f8b08b7d868ea921caa6
30e4267e1a7fe172118bf26252aa2eb92b97a460
/code/pkg_Core/Interface/Log/ILogObserver.h
1d05beb36c6956e7921a04b4c904357afcf0f00d
[ "Apache-2.0" ]
permissive
thinkhy/x3c_extension
f299103002715365160c274314f02171ca9d9d97
8a31deb466df5d487561db0fbacb753a0873a19c
refs/heads/master
2020-04-22T22:02:44.934037
2011-01-07T06:20:28
2011-01-07T06:20:28
1,234,211
2
0
null
null
null
null
GB18030
C++
false
false
3,056
h
// Copyright 2008-2011 Zhang Yun Gui, [email protected] // https://sourceforge.net/projects/x3c/ // // 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. /*! \file ILogObserver.h * \brief 定义日志输出观察者的接口 ILogObserver * \author Zhang Yun Gui, C++ Plugin Framework * \date 2010.10.19 */ #ifndef X3_LOG_ILOGOBSERVER_H_ #define X3_LOG_ILOGOBSERVER_H_ #include "Ix_Object.h" //! 日志输出观察者的接口 /*! 使用 RegisterLogObserver(ILogObserver*)注册观察者, 使用 UnRegisterLogObserver 注销观察者 \interface ILogObserver \ingroup _GROUP_PLUGIN_LOG_ \see RegisterLogObserver, UnRegisterLogObserver, CLogObserverImpl */ interface ILogObserver { //! 开始新的一组日志 /*! \param level 新的一组日志的组号,从1开始 \param msg 组信息,已本地化 \param extra 附加的上下文信息 \param module 模块名 \param idname 串ID名称 */ virtual void OnPushGroup(long level, const std::wstring& msg, const std::wstring& extra, const std::wstring& module, const std::wstring& idname) = 0; //! 结束一组日志 /*! \param level 要结束的一组日志的组号,和相应的 OnPushGroup 同值 */ virtual void OnPopGroup(long level) = 0; //! 响应日志信息的输出通知 /*! \param type 日志类型, kLogType 枚举值 \param msg 日志内容信息,已本地化 \param extra 附加的上下文信息 \param module 模块名 \param idname 串ID名称 \param file 源代码文件名 \param line 源代码行号 */ virtual void OnWriteLog(int type, const std::wstring& msg, const std::wstring& extra, const std::wstring& module, const std::wstring& idname, const std::wstring& file, long line) = 0; }; //! 日志输出观察者的默认实现 /*! \ingroup _GROUP_PLUGIN_LOG_ */ class CLogObserverImpl : public ILogObserver { public: CLogObserverImpl() {} virtual ~CLogObserverImpl() {} virtual void OnPushGroup(long level, const std::wstring& msg, const std::wstring& extra, const std::wstring& module, const std::wstring& idname) { level; msg; extra; module; idname; } virtual void OnPopGroup(long level) { level; } virtual void OnWriteLog(int type, const std::wstring& msg, const std::wstring& extra, const std::wstring& module, const std::wstring& idname, const std::wstring& file, long line) { type; msg; extra; module; idname; file; line; } }; #endif // X3_LOG_ILOGOBSERVER_H_
[ "rhcad1@71899303-b18e-48b3-b26e-8aaddbe541a3" ]
[ [ [ 1, 100 ] ] ]
33be8624608639e2ad1b1595d4b28228ed6511a5
2e5fd1fc05c0d3b28f64abc99f358145c3ddd658
/deps/quickfix/examples/ordermatch/test/OrderMatcherTestCase.cpp
f6e88ee9352c6de8f28c2e26a76ba745dafa0a8d
[ "BSD-2-Clause" ]
permissive
indraj/fixfeed
9365c51e2b622eaff4ce5fac5b86bea86415c1e4
5ea71aab502c459da61862eaea2b78859b0c3ab3
refs/heads/master
2020-12-25T10:41:39.427032
2011-02-15T13:38:34
2011-02-15T20:50:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,702
cpp
/**************************************************************************** ** Copyright (c) quickfixengine.org All rights reserved. ** ** This file is part of the QuickFIX FIX Engine ** ** This file may be distributed under the terms of the quickfixengine.org ** license as defined by quickfixengine.org and appearing in the file ** LICENSE included in the packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.quickfixengine.org/LICENSE for licensing information. ** ** Contact [email protected] if any conditions of this licensing are ** not clear to you. ** ****************************************************************************/ #ifdef _MSC_VER #pragma warning( disable : 4503 4355 4786 ) #else #include "config.h" #endif #include <UnitTest++.h> #include "OrderMatcher.h" TEST( matchFull ) { OrderMatcher object; Order order1("1", "LNUX", "OWNER1", "TARGET", Order::buy, Order::limit, 12.32, 100); Order order2("2", "LNUX", "OWNER2", "TARGET", Order::sell, Order::limit, 12.32, 100); CHECK(object.insert(order1)); CHECK(object.insert(order2)); std::queue<Order> orders; CHECK(object.match("LNUX", orders)); CHECK_EQUAL(1, orders.size()); Order matchedOrder1 = orders.front(); orders.pop(); Order matchedOrder2 = orders.front(); orders.pop(); CHECK_EQUAL("1", matchedOrder1.getClientID()); CHECK(matchedOrder1.isFilled()); CHECK(matchedOrder1.isClosed()); CHECK_EQUAL(0, matchedOrder1.getOpenQuantity()); CHECK_EQUAL(100, matchedOrder1.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder1.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder1.getLastExecutedPrice()); CHECK_EQUAL(100, matchedOrder1.getLastExecutedQuantity()); CHECK_EQUAL("2", matchedOrder2.getClientID()); CHECK(matchedOrder2.isFilled()); CHECK(matchedOrder2.isClosed()); CHECK_EQUAL(0, matchedOrder2.getOpenQuantity()); CHECK_EQUAL(100, matchedOrder2.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder2.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder2.getLastExecutedPrice()); CHECK_EQUAL(100, matchedOrder2.getLastExecutedQuantity()); } TEST( matchPartial ) { OrderMatcher object; Order order1("1", "LNUX", "OWNER1", "TARGET", Order::buy, Order::limit, 12.32, 100); Order order2("2", "LNUX", "OWNER2", "TARGET", Order::sell, Order::limit, 12.32, 50); Order order3("3", "LNUX", "OWNER3", "TARGET", Order::sell, Order::limit, 12.30, 50); CHECK(object.insert(order1)); CHECK(object.insert(order2)); std::queue<Order> orders; CHECK(object.match("LNUX", orders)); CHECK_EQUAL(2, orders.size()); Order matchedOrder1 = orders.front(); orders.pop(); Order matchedOrder2 = orders.front(); orders.pop(); CHECK_EQUAL("1", matchedOrder1.getClientID()); CHECK(!matchedOrder1.isFilled()); CHECK(!matchedOrder1.isClosed()); CHECK_EQUAL(50, matchedOrder1.getOpenQuantity()); CHECK_EQUAL(50, matchedOrder1.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder1.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder1.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder1.getLastExecutedQuantity()); CHECK_EQUAL("2", matchedOrder2.getClientID()); CHECK(matchedOrder2.isFilled()); CHECK(matchedOrder2.isClosed()); CHECK_EQUAL(0, matchedOrder2.getOpenQuantity()); CHECK_EQUAL(50, matchedOrder2.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder2.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder2.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder2.getLastExecutedQuantity()); CHECK(object.insert(order3)); CHECK(object.match("LNUX", orders)); CHECK_EQUAL(2, orders.size()); matchedOrder1 = orders.front(); orders.pop(); Order matchedOrder3 = orders.front(); orders.pop(); CHECK_EQUAL("1", matchedOrder1.getClientID()); CHECK(!matchedOrder1.isFilled()); CHECK(!matchedOrder1.isClosed()); CHECK_EQUAL(0, matchedOrder1.getOpenQuantity()); CHECK_EQUAL(100, matchedOrder1.getExecutedQuantity()); CHECK_EQUAL(12.31, matchedOrder1.getAvgExecutedPrice()); CHECK_EQUAL(12.30, matchedOrder1.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder1.getLastExecutedQuantity()); CHECK_EQUAL("3", matchedOrder3.getClientID()); CHECK(matchedOrder3.isFilled()); CHECK(matchedOrder3.isClosed()); CHECK_EQUAL(0, matchedOrder3.getOpenQuantity()); CHECK_EQUAL(50, matchedOrder3.getExecutedQuantity()); CHECK_EQUAL(12.30, matchedOrder3.getAvgExecutedPrice()); CHECK_EQUAL(12.30, matchedOrder3.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder3.getLastExecutedQuantity()); } TEST( matchTimePriority ) { OrderMatcher object; Order order1("1", "LNUX", "OWNER1", "TARGET", Order::sell, Order::limit, 12.32, 50); Order order2("2", "LNUX", "OWNER2", "TARGET", Order::sell, Order::limit, 12.32, 50); Order order3("3", "LNUX", "OWNER3", "TARGET", Order::buy, Order::limit, 12.32, 50); CHECK(object.insert(order1)); CHECK(object.insert(order2)); std::queue<Order> orders; CHECK(!object.match("LNUX", orders)); CHECK_EQUAL(0, orders.size()); CHECK(object.insert(order3)); CHECK(object.match("LNUX", orders)); CHECK_EQUAL(2, orders.size()); Order matchedOrder3 = orders.front(); orders.pop(); Order matchedOrder1 = orders.front(); orders.pop(); CHECK_EQUAL("1", matchedOrder1.getClientID()); CHECK_EQUAL("3", matchedOrder3.getClientID()); } TEST( matchPricePriority ) { OrderMatcher object; Order order1("1", "LNUX", "OWNER1", "TARGET", Order::sell, Order::limit, 12.32, 50); Order order2("2", "LNUX", "OWNER2", "TARGET", Order::sell, Order::limit, 12.31, 50); Order order3("3", "LNUX", "OWNER3", "TARGET", Order::buy, Order::limit, 12.32, 50); CHECK(object.insert(order1)); CHECK(object.insert(order2)); std::queue<Order> orders; CHECK(!object.match("LNUX", orders)); CHECK_EQUAL(0, orders.size()); CHECK(object.insert(order3)); CHECK(object.match("LNUX", orders)); CHECK_EQUAL(2, orders.size()); Order matchedOrder3 = orders.front(); orders.pop(); Order matchedOrder2 = orders.front(); orders.pop(); CHECK_EQUAL("2", matchedOrder2.getClientID()); CHECK_EQUAL("3", matchedOrder3.getClientID()); } TEST( matchMultiple ) { OrderMatcher object; Order order1("1", "LNUX", "OWNER1", "TARGET", Order::sell, Order::limit, 12.32, 50); Order order2("2", "LNUX", "OWNER2", "TARGET", Order::sell, Order::limit, 12.30, 50); Order order3("3", "LNUX", "OWNER3", "TARGET", Order::buy, Order::limit, 12.32, 100); CHECK(object.insert(order1)); CHECK(object.insert(order2)); CHECK(object.insert(order3)); std::queue<Order> orders; CHECK(object.match("LNUX", orders)); CHECK_EQUAL(4, orders.size()); Order matchedOrder3_1 = orders.front(); orders.pop(); Order matchedOrder2 = orders.front(); orders.pop(); Order matchedOrder3_2 = orders.front(); orders.pop(); Order matchedOrder1 = orders.front(); orders.pop(); CHECK_EQUAL("3", matchedOrder3_1.getClientID()); CHECK(!matchedOrder3_1.isFilled()); CHECK(!matchedOrder3_1.isClosed()); CHECK_EQUAL(50, matchedOrder3_1.getOpenQuantity()); CHECK_EQUAL(50, matchedOrder3_1.getExecutedQuantity()); CHECK_EQUAL(12.30, matchedOrder3_1.getAvgExecutedPrice()); CHECK_EQUAL(12.30, matchedOrder3_1.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder3_1.getLastExecutedQuantity()); CHECK_EQUAL("2", matchedOrder2.getClientID()); CHECK(matchedOrder2.isFilled()); CHECK(matchedOrder2.isClosed()); CHECK_EQUAL(0, matchedOrder2.getOpenQuantity()); CHECK_EQUAL(50, matchedOrder2.getExecutedQuantity()); CHECK_EQUAL(12.3, matchedOrder2.getAvgExecutedPrice()); CHECK_EQUAL(12.3, matchedOrder2.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder2.getLastExecutedQuantity()); CHECK_EQUAL("3", matchedOrder3_2.getClientID()); CHECK(matchedOrder3_2.isFilled()); CHECK(matchedOrder3_2.isClosed()); CHECK_EQUAL(0, matchedOrder3_2.getOpenQuantity()); CHECK_EQUAL(100, matchedOrder3_2.getExecutedQuantity()); CHECK_EQUAL(12.31, matchedOrder3_2.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder3_2.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder3_2.getLastExecutedQuantity()); CHECK_EQUAL("1", matchedOrder1.getClientID()); CHECK(matchedOrder1.isFilled()); CHECK(matchedOrder1.isClosed()); CHECK_EQUAL(0, matchedOrder1.getOpenQuantity()); CHECK_EQUAL(50, matchedOrder1.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder1.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder1.getLastExecutedPrice()); CHECK_EQUAL(50, matchedOrder1.getLastExecutedQuantity()); } TEST( overMatch ) { OrderMatcher object; Order order1("1", "LNUX", "OWNER1", "TARGET", Order::buy, Order::limit, 12.32, 100); Order order2("2", "LNUX", "OWNER2", "TARGET", Order::sell, Order::limit, 12.32, 110); Order order3("3", "LNUX", "OWNER3", "TARGET", Order::buy, Order::limit, 12.32, 100); CHECK(object.insert(order1)); CHECK(object.insert(order2)); std::queue<Order> orders; CHECK(object.match("LNUX", orders)); CHECK_EQUAL(2, orders.size()); Order matchedOrder1 = orders.front(); orders.pop(); Order matchedOrder2 = orders.front(); orders.pop(); CHECK_EQUAL("1", matchedOrder1.getClientID()); CHECK(matchedOrder1.isFilled()); CHECK(matchedOrder1.isClosed()); CHECK_EQUAL(0, matchedOrder1.getOpenQuantity()); CHECK_EQUAL(100, matchedOrder1.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder1.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder1.getLastExecutedPrice()); CHECK_EQUAL(100, matchedOrder1.getLastExecutedQuantity()); CHECK_EQUAL("2", matchedOrder2.getClientID()); CHECK(!matchedOrder2.isFilled()); CHECK(!matchedOrder2.isClosed()); CHECK_EQUAL(10, matchedOrder2.getOpenQuantity()); CHECK_EQUAL(100, matchedOrder2.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder2.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder2.getLastExecutedPrice()); CHECK_EQUAL(100, matchedOrder2.getLastExecutedQuantity()); CHECK(object.insert(order3)); CHECK(object.match("LNUX", orders)); CHECK_EQUAL(2, orders.size()); Order matchedOrder3 = orders.front(); orders.pop(); matchedOrder2 = orders.front(); orders.pop(); CHECK_EQUAL("3", matchedOrder3.getClientID()); CHECK(!matchedOrder3.isFilled()); CHECK(!matchedOrder3.isClosed()); CHECK_EQUAL(90, matchedOrder3.getOpenQuantity()); CHECK_EQUAL(10, matchedOrder3.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder3.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder3.getLastExecutedPrice()); CHECK_EQUAL(10, matchedOrder3.getLastExecutedQuantity()); CHECK_EQUAL("2", matchedOrder2.getClientID()); CHECK(matchedOrder2.isFilled()); CHECK(matchedOrder2.isClosed()); CHECK_EQUAL(0, matchedOrder2.getOpenQuantity()); CHECK_EQUAL(110, matchedOrder2.getExecutedQuantity()); CHECK_EQUAL(12.32, matchedOrder2.getAvgExecutedPrice()); CHECK_EQUAL(12.32, matchedOrder2.getLastExecutedPrice()); CHECK_EQUAL(10, matchedOrder2.getLastExecutedQuantity()); }
[ [ [ 1, 329 ] ] ]
4fbbb18984784b19af4e1a2810db8e9710b93015
6c8c4728e608a4badd88de181910a294be56953a
/CommunicationModule/TelepathyIM/VideoWidget.h
5e35ff19d29ba39225d6cce15e71b230db4cf852
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
caocao/naali
29c544e121703221fe9c90b5c20b3480442875ef
67c5aa85fa357f7aae9869215f840af4b0e58897
refs/heads/master
2021-01-21T00:25:27.447991
2010-03-22T15:04:19
2010-03-22T15:04:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,108
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_Communication_TelepathyIM_VideoWidget_h #define incl_Communication_TelepathyIM_VideoWidget_h #include <QWidget> #include <gst/gst.h> #include <gst/farsight/fs-element-added-notifier.h> #include "VideoPlaybackWidgetInterface.h" #include "AudioDataProducerInterface.h" //#include "../interface.h" namespace TelepathyIM { /** * Based on call example of telepathy-qt4 library * QWidget for video playback. Created by FarsightChannel object and used by communication UI widgets. */ class VideoWidget : public Communication::VideoPlaybackWidgetInterface { Q_OBJECT static const int VIDEO_WIDTH = 320; static const int VIDEO_HEIGHT = 200; public: VideoWidget(GstBus *bus, QWidget *parent, const QString &name, const QString &video_src_name); virtual ~VideoWidget(); //! Getters virtual bool VideoAvailable(); GstElement *GetVideoPlaybackElement() const; GstElement *video_overlay_; // todo: get method //! Glib callbacks static void OnElementAdded(FsElementAddedNotifier *notifier, GstBin *bin, GstElement *element, VideoWidget *self); static void OnSyncMessage(GstBus *bus, GstMessage *message, VideoWidget *self); protected: void showEvent(QShowEvent *showEvent); void closeEvent(QCloseEvent *closeEvent); public slots: void SetOverlay(); void WindowExposed(); private: //! Gst Fs variables GstBus *bus_; GstElement *video_playback_bin_; GstElement *video_playback_element_; FsElementAddedNotifier *notifier_; gulong on_element_added_g_signal_; gulong on_sync_message_g_signal_; //! Qt variables WId window_id_; QString name_; }; typedef boost::shared_ptr<VideoWidget> VideoWidgetPtr; } // End of namespace: TelepathyIM #endif // incl_Communication_TelepathyIM_VideoWidget_h
[ "Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3", "mattiku@5b2332b8-efa3-11de-8684-7d64432d61a3", "jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3", "[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3", "jonnenau@5b2332b8-efa3-11de-8684-7d64432d61a3", "[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 2 ], [ 13, 13 ], [ 42, 42 ] ], [ [ 3, 9 ], [ 14, 19 ], [ 21, 21 ], [ 27, 27 ], [ 29, 30 ], [ 32, 32 ], [ 35, 35 ], [ 43, 43 ], [ 45, 48 ], [ 50, 50 ], [ 53, 56 ], [ 58, 58 ], [ 60, 60 ], [ 62, 65 ] ], [ [ 10, 12 ] ], [ [ 20, 20 ], [ 28, 28 ] ], [ [ 22, 23 ], [ 26, 26 ], [ 31, 31 ], [ 33, 33 ], [ 36, 41 ], [ 49, 49 ], [ 52, 52 ], [ 57, 57 ], [ 59, 59 ] ], [ [ 24, 25 ], [ 34, 34 ], [ 44, 44 ], [ 51, 51 ], [ 61, 61 ] ] ]
3b655675c29341b2ba1c238bf3cbd70a4cfc0cac
12ea67a9bd20cbeed3ed839e036187e3d5437504
/winxgui/Tools/Dev/mg/dspfile.cpp
56763888ee69982d404120622dbe9bcdae9e19a5
[]
no_license
cnsuhao/winxgui
e0025edec44b9c93e13a6c2884692da3773f9103
348bb48994f56bf55e96e040d561ec25642d0e46
refs/heads/master
2021-05-28T21:33:54.407837
2008-09-13T19:43:38
2008-09-13T19:43:38
null
0
0
null
null
null
null
GB18030
C++
false
false
1,500
cpp
/* ------------------------------------------------------------------------- // 文件名 : mg/dspfile.cpp // 创建者 : 许式伟 // 创建时间 : 2003-3-2 21:07:38 // 功能描述 : // // -----------------------------------------------------------------------*/ #include "stdafx.h" #include "MakeGen.h" #include <stdlib.h> // ------------------------------------------------------------------------- typedef struct __KHandleDspFileLocal { TCHAR szSrcFile[_MAX_PATH]; TCHAR szLine[MG_LINE_MAX]; }KHandleDspFileLocal; STDMETHODIMP HandleSingleFile(LPCTSTR szSrcFile, KHandlerParam* pParam); STDMETHODIMP HandleDspFile(LPCTSTR szSrcFile, KHandlerParam* pParam) { KHandleDspFileLocal* p; LPTSTR token; TCHAR* szLine; FILE* fpSrc; p = (KHandleDspFileLocal*)malloc(sizeof(KHandleDspFileLocal)); szLine = p->szLine; MergePath(p->szSrcFile, pParam->szProjPath, szSrcFile); fpSrc = fopen(p->szSrcFile, "r"); if (fpSrc == NULL) { delete p; return S_FALSE; } for (;;) { *szLine = 0; _fgetts(szLine, MG_LINE_MAX, fpSrc); if (*szLine == 0 && feof(fpSrc)) break; if (_tcsncmp(szLine, "SOURCE=", 7) == 0) { token = _tcstok(szLine+7, g_szSeps); for (LPTSTR psz = token; *psz; ++psz) if (*psz == '\\') *psz = '/'; HandleSingleFile(token, pParam); } } delete p; fclose(fpSrc); return S_OK; } // -------------------------------------------------------------------------
[ "[email protected]@86f14454-5125-0410-a45d-e989635d7e98" ]
[ [ [ 1, 64 ] ] ]
35dbf7a59f6ddfb3df6de14449192711a887e397
ade08cd4a76f2c4b9b5fdbb9b9edfbc7996b1bbc
/computer_graphics/lab5/Src/Application/object.cpp
ecccca0924005d390a4387d900f2931725ee318d
[]
no_license
smi13/semester07
6789be72d74d8d502f0a0d919dca07ad5cbaed0d
4d1079a446269646e1a0e3fe12e8c5e74c9bb409
refs/heads/master
2021-01-25T09:53:45.424234
2011-01-07T16:08:11
2011-01-07T16:08:11
859,509
0
0
null
null
null
null
UTF-8
C++
false
false
1,731
cpp
#include "object.h" #include "render_context.h" using namespace cg_labs; Object::Object() : _vbuf(0), _ibuf(0), _toRender(true) { } Object::Object( std::string &name ) : _vbuf(0), _ibuf(0), _name(name), _toRender(true) { D3DXMatrixIdentity(&_matrix); } std::string &Object::getName() { return _name; } void Object::translate( float x, float y, float z ) { D3DXMATRIX tmp; D3DXMatrixTranslation(&tmp, x, y, z); _matrix *= tmp; } void Object::rotateX( float angle ) { D3DXMATRIX tmp; D3DXMatrixRotationX(&tmp, angle); _matrix *= tmp; } void Object::rotateY( float angle ) { D3DXMATRIX tmp; D3DXMatrixRotationY(&tmp, angle); _matrix *= tmp; } void Object::rotateZ( float angle ) { D3DXMATRIX tmp; D3DXMatrixRotationZ(&tmp, angle); _matrix *= tmp; } void Object::scale( float scl ) { D3DXMATRIX tmp; D3DXMatrixScaling(&tmp, scl, scl, scl); _matrix *= tmp; } void Object::scale( float scl_x, float scl_y, float scl_z ) { D3DXMATRIX tmp; D3DXMatrixScaling(&tmp, scl_x, scl_y, scl_z); _matrix *= tmp; } void Object::setIdentity() { D3DXMatrixIdentity(&_matrix); } void Object::setVisible( bool value ) { _toRender = value; } void Object::setLighting( bool value ) { _isLightenUp = value; } bool Object::isVisible() { return _toRender; } void Object::clear() { if (_vbuf != 0) { _vbuf->Release(); _vbuf = 0; } if (_ibuf != 0) { _ibuf->Release(); _ibuf = 0; } } void Object::render() { getDevice()->SetTransform(D3DTS_WORLD, &_matrix); } Object::~Object() { clear(); }
[ [ [ 1, 118 ] ] ]
00da492178d4b2eb15d2663bf960b61c856f5017
823e34ee3931091af33fbac28b5c5683a39278e4
/WebBrowser/WebBrowserView.h
619667d2a6e31091adda89c0cd87c4bb63698c90
[]
no_license
tangooricha/tangoorichas-design-for-graduation
aefdd0fdf0e8786308c22311f2598ad62b3f5be8
cf227651b9baa0deb5748a678553b145a3ce6803
refs/heads/master
2020-06-06T17:48:37.691814
2010-04-14T07:22:23
2010-04-14T07:22:23
34,887,842
0
0
null
null
null
null
UTF-8
C++
false
false
1,826
h
// WebBrowserView.h : interface of the CWebBrowserView class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_WEBBROWSERVIEW_H__06488E66_D224_442B_BF22_8BED062A18A5__INCLUDED_) #define AFX_WEBBROWSERVIEW_H__06488E66_D224_442B_BF22_8BED062A18A5__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "RefreshDlg.h" class CWebBrowserView : public CHtmlView { protected: // create from serialization only CWebBrowserView(); DECLARE_DYNCREATE(CWebBrowserView) // Attributes public: CWebBrowserDoc* GetDocument(); // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CWebBrowserView) public: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual void OnInitialUpdate(); // called first time after construct //}}AFX_VIRTUAL // Implementation public: RefreshDlg refreshDlg; TCHAR URLString[1024]; virtual ~CWebBrowserView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CWebBrowserView) afx_msg void OnMenuRefresh(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; #ifndef _DEBUG // debug version in WebBrowserView.cpp inline CWebBrowserDoc* CWebBrowserView::GetDocument() { return (CWebBrowserDoc*)m_pDocument; } #endif ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_WEBBROWSERVIEW_H__06488E66_D224_442B_BF22_8BED062A18A5__INCLUDED_)
[ "[email protected]@91cf4698-544a-0410-9e3e-f171e2291419" ]
[ [ [ 1, 69 ] ] ]
2283c5ebb4825e08149d361e54499ed57cc15145
4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61
/CleanProject/MyGUI/include/MyGUI_TabItem.h
71e146bcece7e07c8c7015af4279e3d9c4b29af8
[]
no_license
bahao247/apeengine2
56560dbf6d262364fbc0f9f96ba4231e5e4ed301
f2617b2a42bdf2907c6d56e334c0d027fb62062d
refs/heads/master
2021-01-10T14:04:02.319337
2009-08-26T08:23:33
2009-08-26T08:23:33
45,979,392
0
1
null
null
null
null
UTF-8
C++
false
false
2,679
h
/*! @file @author Albert Semenov @date 01/2008 @module *//* This file is part of MyGUI. MyGUI 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 3 of the License, or (at your option) any later version. MyGUI 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 MyGUI. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __MYGUI_TAB_ITEM_H__ #define __MYGUI_TAB_ITEM_H__ #include "MyGUI_Prerequest.h" #include "MyGUI_Widget.h" #include "MyGUI_Tab.h" namespace MyGUI { //OBSOLETE namespace factory { class SheetFactory; } class MYGUI_EXPORT TabItem : public Widget { // для вызова закрытого конструктора friend class factory::BaseWidgetFactory<TabItem>; friend class factory::SheetFactory; MYGUI_RTTI_CHILD_HEADER( TabItem, Widget ); public: /** Set item caption */ virtual void setCaption(const Ogre::UTFString & _caption) { mOwner->setItemName(this, _caption); } /** Get item caption */ virtual const Ogre::UTFString & getCaption() { return mOwner->getItemName(this); } //! Set button width void setButtonWidth(int _width = DEFAULT) { mOwner->setButtonWidth(this, _width); } //! Get button width int getButtonWidth() { return mOwner->getButtonWidth(this); } //! Get item name const Ogre::UTFString & getItemName() { return mOwner->getItemName(this); } //! Replace an item name void setItemName(const Ogre::UTFString & _name) { mOwner->setItemName(this, _name); } //! Replace an item name void setItemData(Any _data) { mOwner->setItemData(this, _data); } //! Get item data template <typename ValueType> ValueType * getItemData(bool _throw = true) { return mOwner->getItemData<ValueType>(this, _throw); } //! Select sheet void setItemSelected() { mOwner->setItemSelected(this); } //! Remove item void removeItem() { mOwner->removeItem(this); } protected: TabItem(WidgetStyle _style, const IntCoord& _coord, Align _align, const WidgetSkinInfoPtr _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string & _name); virtual ~TabItem(); private: TabPtr mOwner; }; } // namespace MyGUI #endif // __MYGUI_TAB_ITEM_H__
[ "pablosn@06488772-1f9a-11de-8b5c-13accb87f508" ]
[ [ [ 1, 88 ] ] ]
e854807c2580402a6b4f3f776b45726d6717f251
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/wave/samples/waveidl/instantiate_predef_macros.cpp
d1a4fbaa770274f3871f390cd626627b7db79eae
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
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
1,599
cpp
/*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library Sample: IDL oriented preprocessor Explicit instantiation of the predefined_macros_grammar template http://www.boost.org/ Copyright (c) 2001-2007 Hartmut Kaiser. 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) =============================================================================*/ #include "idl.hpp" #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 #include <string> #include <boost/wave/token_ids.hpp> #include <boost/wave/cpplexer/cpp_lex_token.hpp> #include "idllexer/idl_lex_iterator.hpp" #include <boost/wave/grammars/cpp_predef_macros_grammar.hpp> /////////////////////////////////////////////////////////////////////////////// // // Explicit instantiation of the predefined_macros_grammar_gen template // with the correct token type. This instantiates the corresponding pt_parse // function, which in turn instantiates the cpp_predefined_macros_grammar // object (see wave/grammars/cpp_predef_macros_grammar.hpp) // /////////////////////////////////////////////////////////////////////////////// typedef boost::wave::idllexer::lex_iterator< boost::wave::cpplexer::lex_token<> > lexer_type; template struct boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>; #endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 42 ] ] ]
ce30b79b7ac1c51bc963f84cb8f376a0fbf5c932
e03ee4538dce040fe16fc7bb48d495735ac324f4
/AI/GameAI/StateMachine/main_states.cpp
58b49b44ccf801df29cd1c9d0155a7d1fde947fa
[]
no_license
vdelgadov/itcvideogame
dca6bcb084c5dde25ecf29ab1555dbe8b0a9a441
5eac60e901b29bff4d844f34cd52f97f4d1407b5
refs/heads/master
2020-05-16T23:43:48.956373
2009-12-01T02:09:08
2009-12-01T02:09:08
42,265,496
0
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
#include <iostream> #include <windows.h> #include "MockEntity.cpp" using namespace std; int main(){ MockEntity* actor = new MockEntity("Actor 1"); while(1){ Sleep(500); actor->update(); //actor->getFSM()->update(); } }
[ "victor.delgadov@972b8bf6-92a2-11de-b72a-e7346c8bff7a" ]
[ [ [ 1, 13 ] ] ]
17ef99ddc01fe9efaedfea20eed84cd076e473f8
011359e589f99ae5fe8271962d447165e9ff7768
/src/burn/misc/pre90s/d_vigilant.cpp
850da3547a79c3e02315aab4ddfed81d936269f2
[]
no_license
PS3emulators/fba-next-slim
4c753375fd68863c53830bb367c61737393f9777
d082dea48c378bddd5e2a686fe8c19beb06db8e1
refs/heads/master
2021-01-17T23:05:29.479865
2011-12-01T18:16:02
2011-12-01T18:16:02
2,899,840
1
0
null
null
null
null
UTF-8
C++
false
false
66,926
cpp
#include "tiles_generic.h" #include "burn_ym2151.h" #include "burn_ym2203.h" #include "dac.h" static unsigned char DrvInputPort0[8] = {0, 0, 0, 0, 0, 0, 0, 0}; static unsigned char DrvInputPort1[8] = {0, 0, 0, 0, 0, 0, 0, 0}; static unsigned char DrvInputPort2[8] = {0, 0, 0, 0, 0, 0, 0, 0}; static unsigned char DrvDip[3] = {0, 0, 0}; static unsigned char DrvInput[3] = {0x00, 0x00, 0x00}; static unsigned char DrvReset = 0; static unsigned char *Mem = NULL; static unsigned char *MemEnd = NULL; static unsigned char *RamStart = NULL; static unsigned char *RamEnd = NULL; static unsigned char *DrvZ80Rom1 = NULL; static unsigned char *DrvZ80Rom2 = NULL; static unsigned char *DrvZ80Ram1 = NULL; static unsigned char *DrvZ80Ram2 = NULL; static unsigned char *DrvVideoRam = NULL; static unsigned char *DrvSpriteRam = NULL; static unsigned char *DrvPaletteRam = NULL; static unsigned char *DrvChars = NULL; static unsigned char *DrvBackTiles = NULL; static unsigned char *DrvSprites = NULL; static unsigned char *DrvSamples = NULL; static unsigned char *DrvTempRom = NULL; static unsigned int *DrvPalette = NULL; static unsigned char DrvRomBank; static unsigned char DrvSoundLatch; static unsigned char DrvIrqVector; static int DrvRearColour; static int DrvRearDisable; static int DrvHorizScrollLo; static int DrvHorizScrollHi; static int DrvRearHorizScrollLo; static int DrvRearHorizScrollHi; static int DrvSampleAddress; static int nCyclesDone[2], nCyclesTotal[2]; static int nCyclesSegment; static unsigned char DrvHasYM2203 = 0; static unsigned char DrvKikcubicDraw = 0; #define VECTOR_INIT 0 #define YM2151_ASSERT 1 #define YM2151_CLEAR 2 #define Z80_ASSERT 3 #define Z80_CLEAR 4 static struct BurnInputInfo DrvInputList[] = { {"Coin 1" , BIT_DIGITAL , DrvInputPort0 + 3, "p1 coin" }, {"Start 1" , BIT_DIGITAL , DrvInputPort0 + 0, "p1 start" }, {"Coin 2" , BIT_DIGITAL , DrvInputPort2 + 4, "p2 coin" }, {"Start 2" , BIT_DIGITAL , DrvInputPort0 + 1, "p2 start" }, {"Up" , BIT_DIGITAL , DrvInputPort1 + 3, "p1 up" }, {"Down" , BIT_DIGITAL , DrvInputPort1 + 2, "p1 down" }, {"Left" , BIT_DIGITAL , DrvInputPort1 + 1, "p1 left" }, {"Right" , BIT_DIGITAL , DrvInputPort1 + 0, "p1 right" }, {"Fire 1" , BIT_DIGITAL , DrvInputPort1 + 5, "p1 fire 1" }, {"Fire 2" , BIT_DIGITAL , DrvInputPort1 + 7, "p1 fire 2" }, {"Up (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 3, "p2 up" }, {"Down (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 2, "p2 down" }, {"Left (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 1, "p2 left" }, {"Right (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 0, "p2 right" }, {"Fire 1 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 5, "p2 fire 1" }, {"Fire 2 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 7, "p2 fire 2" }, {"Reset" , BIT_DIGITAL , &DrvReset , "reset" }, {"Service" , BIT_DIGITAL , DrvInputPort0 + 2, "service" }, {"Dip 1" , BIT_DIPSWITCH, DrvDip + 0 , "dip" }, {"Dip 2" , BIT_DIPSWITCH, DrvDip + 1 , "dip" }, }; STDINPUTINFO(Drv) static struct BurnInputInfo BuccanrsInputList[] = { {"Coin 1" , BIT_DIGITAL , DrvInputPort0 + 4, "p1 coin" }, {"Start 1" , BIT_DIGITAL , DrvInputPort0 + 7, "p1 start" }, {"Coin 2" , BIT_DIGITAL , DrvInputPort2 + 4, "p2 coin" }, {"Start 2" , BIT_DIGITAL , DrvInputPort0 + 6, "p2 start" }, {"Up" , BIT_DIGITAL , DrvInputPort1 + 3, "p1 up" }, {"Down" , BIT_DIGITAL , DrvInputPort1 + 2, "p1 down" }, {"Left" , BIT_DIGITAL , DrvInputPort1 + 1, "p1 left" }, {"Right" , BIT_DIGITAL , DrvInputPort1 + 0, "p1 right" }, {"Fire 1" , BIT_DIGITAL , DrvInputPort1 + 7, "p1 fire 1" }, {"Fire 2" , BIT_DIGITAL , DrvInputPort1 + 5, "p1 fire 2" }, {"Up (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 3, "p2 up" }, {"Down (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 2, "p2 down" }, {"Left (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 1, "p2 left" }, {"Right (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 0, "p2 right" }, {"Fire 1 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 7, "p2 fire 1" }, {"Fire 2 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 5, "p2 fire 2" }, {"Reset" , BIT_DIGITAL , &DrvReset , "reset" }, {"Dip 1" , BIT_DIPSWITCH, DrvDip + 0 , "dip" }, {"Dip 2" , BIT_DIPSWITCH, DrvDip + 1 , "dip" }, {"Dip 3" , BIT_DIPSWITCH, DrvDip + 2 , "dip" }, }; STDINPUTINFO(Buccanrs) static struct BurnInputInfo BuccanrsaInputList[] = { {"Coin 1" , BIT_DIGITAL , DrvInputPort0 + 3, "p1 coin" }, {"Start 1" , BIT_DIGITAL , DrvInputPort0 + 0, "p1 start" }, {"Coin 2" , BIT_DIGITAL , DrvInputPort2 + 4, "p2 coin" }, {"Start 2" , BIT_DIGITAL , DrvInputPort0 + 1, "p2 start" }, {"Up" , BIT_DIGITAL , DrvInputPort1 + 3, "p1 up" }, {"Down" , BIT_DIGITAL , DrvInputPort1 + 2, "p1 down" }, {"Left" , BIT_DIGITAL , DrvInputPort1 + 1, "p1 left" }, {"Right" , BIT_DIGITAL , DrvInputPort1 + 0, "p1 right" }, {"Fire 1" , BIT_DIGITAL , DrvInputPort1 + 7, "p1 fire 1" }, {"Fire 2" , BIT_DIGITAL , DrvInputPort1 + 5, "p1 fire 2" }, {"Up (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 3, "p2 up" }, {"Down (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 2, "p2 down" }, {"Left (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 1, "p2 left" }, {"Right (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 0, "p2 right" }, {"Fire 1 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 7, "p2 fire 1" }, {"Fire 2 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 5, "p2 fire 2" }, {"Reset" , BIT_DIGITAL , &DrvReset , "reset" }, {"Dip 1" , BIT_DIPSWITCH, DrvDip + 0 , "dip" }, {"Dip 2" , BIT_DIPSWITCH, DrvDip + 1 , "dip" }, {"Dip 3" , BIT_DIPSWITCH, DrvDip + 2 , "dip" }, }; STDINPUTINFO(Buccanrsa) static struct BurnInputInfo KikcubicInputList[] = { {"Coin 1" , BIT_DIGITAL , DrvInputPort0 + 4, "p1 coin" }, {"Start 1" , BIT_DIGITAL , DrvInputPort0 + 0, "p1 start" }, {"Coin 2" , BIT_DIGITAL , DrvInputPort0 + 5, "p2 coin" }, {"Start 2" , BIT_DIGITAL , DrvInputPort0 + 1, "p2 start" }, {"Up" , BIT_DIGITAL , DrvInputPort1 + 3, "p1 up" }, {"Down" , BIT_DIGITAL , DrvInputPort1 + 2, "p1 down" }, {"Left" , BIT_DIGITAL , DrvInputPort1 + 1, "p1 left" }, {"Right" , BIT_DIGITAL , DrvInputPort1 + 0, "p1 right" }, {"Fire 1" , BIT_DIGITAL , DrvInputPort1 + 7, "p1 fire 1" }, {"Fire 2" , BIT_DIGITAL , DrvInputPort1 + 5, "p1 fire 2" }, {"Up (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 3, "p2 up" }, {"Down (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 2, "p2 down" }, {"Left (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 1, "p2 left" }, {"Right (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 0, "p2 right" }, {"Fire 1 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 7, "p2 fire 1" }, {"Fire 2 (Cocktail)" , BIT_DIGITAL , DrvInputPort2 + 5, "p2 fire 2" }, {"Reset" , BIT_DIGITAL , &DrvReset , "reset" }, {"Dip 1" , BIT_DIPSWITCH, DrvDip + 0 , "dip" }, {"Dip 2" , BIT_DIPSWITCH, DrvDip + 1 , "dip" }, }; STDINPUTINFO(Kikcubic) static inline void DrvMakeInputs() { // Reset Inputs DrvInput[0] = DrvInput[1] = DrvInput[2] = 0x00; // Compile Digital Inputs for (int i = 0; i < 8; i++) { DrvInput[0] |= (DrvInputPort0[i] & 1) << i; DrvInput[1] |= (DrvInputPort1[i] & 1) << i; DrvInput[2] |= (DrvInputPort2[i] & 1) << i; } // Clear Opposites DrvClearOpposites(&DrvInput[1]); DrvClearOpposites(&DrvInput[2]); } static struct BurnDIPInfo DrvDIPList[]= { // Default Values {0x12, 0xff, 0xff, 0xff, NULL }, {0x13, 0xff, 0xff, 0xfd, NULL }, // Dip 1 {0 , 0xfe, 0 , 4 , "Lives" }, {0x12, 0x01, 0x03, 0x02, "2" }, {0x12, 0x01, 0x03, 0x03, "3" }, {0x12, 0x01, 0x03, 0x01, "4" }, {0x12, 0x01, 0x03, 0x00, "5" }, {0 , 0xfe, 0 , 2 , "Difficulty" }, {0x12, 0x01, 0x04, 0x04, "Normal" }, {0x12, 0x01, 0x04, 0x00, "Hard" }, {0 , 0xfe, 0 , 2 , "Energy Decrease Rate" }, {0x12, 0x01, 0x08, 0x08, "Slow" }, {0x12, 0x01, 0x08, 0x00, "Fast" }, {0 , 0xfe, 0 , 16 , "Coinage" }, {0x12, 0x01, 0xf0, 0xa0, "6 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0xb0, "5 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0xc0, "4 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0xd0, "3 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x10, "8 Coins 3 Plays" }, {0x12, 0x01, 0xf0, 0xe0, "2 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x20, "5 Coins 3 Plays" }, {0x12, 0x01, 0xf0, 0x30, "3 Coins 2 Plays" }, {0x12, 0x01, 0xf0, 0xf0, "1 Coin 1 Play" }, {0x12, 0x01, 0xf0, 0x40, "2 Coins 3 Plays" }, {0x12, 0x01, 0xf0, 0x90, "1 Coin 2 Plays" }, {0x12, 0x01, 0xf0, 0x80, "1 Coin 3 Plays" }, {0x12, 0x01, 0xf0, 0x70, "1 Coin 4 Plays" }, {0x12, 0x01, 0xf0, 0x60, "1 Coin 5 Plays" }, {0x12, 0x01, 0xf0, 0x50, "1 Coin 6 Plays" }, {0x12, 0x01, 0xf0, 0x00, "Freeplay" }, // Dip 2 {0 , 0xfe, 0 , 2 , "Flip Screen" }, {0x13, 0x01, 0x01, 0x01, "Off" }, {0x13, 0x01, 0x01, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Cabinet" }, {0x13, 0x01, 0x02, 0x00, "Upright" }, {0x13, 0x01, 0x02, 0x02, "Cocktail" }, {0 , 0xfe, 0 , 2 , "Coin Mode" }, {0x13, 0x01, 0x04, 0x04, "Mode 1" }, {0x13, 0x01, 0x04, 0x00, "Mode 2" }, {0 , 0xfe, 0 , 2 , "Demo Sounds" }, {0x13, 0x01, 0x08, 0x00, "Off" }, {0x13, 0x01, 0x08, 0x08, "On" }, {0 , 0xfe, 0 , 2 , "Allow Continue" }, {0x13, 0x01, 0x10, 0x00, "Off" }, {0x13, 0x01, 0x10, 0x10, "On" }, {0 , 0xfe, 0 , 2 , "Stop Mode" }, {0x13, 0x01, 0x20, 0x20, "Off" }, {0x13, 0x01, 0x20, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Invulnerability" }, {0x13, 0x01, 0x40, 0x40, "Off" }, {0x13, 0x01, 0x40, 0x00, "On" }, }; STDDIPINFO(Drv) static struct BurnDIPInfo BuccanrsDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0x2f, NULL }, {0x12, 0xff, 0xff, 0xff, NULL }, {0x13, 0xff, 0xff, 0x7f, NULL }, // Dip 1 {0 , 0xfe, 0 , 2 , "Service Mode" }, {0x11, 0x01, 0x01, 0x01, "Off" }, {0x11, 0x01, 0x01, 0x00, "On" }, // Dip 2 {0 , 0xfe, 0 , 12 , "Coin A" }, {0x12, 0x01, 0x0f, 0x04, "4 Coins 1 Play" }, {0x12, 0x01, 0x0f, 0x07, "3 Coins 1 Play" }, {0x12, 0x01, 0x0f, 0x00, "5 Coins 2 Plays" }, {0x12, 0x01, 0x0f, 0x0a, "2 Coins 1 Play" }, {0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Plays" }, {0x12, 0x01, 0x0f, 0x03, "4 Coins 3 Plays" }, {0x12, 0x01, 0x0f, 0x0f, "1 Coin 1 Play" }, {0x12, 0x01, 0x0f, 0x05, "3 Coins 5 Plays" }, {0x12, 0x01, 0x0f, 0x0e, "1 Coin 2 Plays" }, {0x12, 0x01, 0x0f, 0x0d, "1 Coin 3 Plays" }, {0x12, 0x01, 0x0f, 0x0c, "1 Coin 4 Plays" }, {0x12, 0x01, 0x0f, 0x0b, "1 Coin 5 Plays" }, {0 , 0xfe, 0 , 12 , "Coin B" }, {0x12, 0x01, 0xf0, 0x40, "4 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x70, "3 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x00, "5 Coins 2 Plays" }, {0x12, 0x01, 0xf0, 0xa0, "2 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Plays" }, {0x12, 0x01, 0xf0, 0x30, "4 Coins 3 Plays" }, {0x12, 0x01, 0xf0, 0xf0, "1 Coin 1 Play" }, {0x12, 0x01, 0xf0, 0x50, "3 Coins 5 Plays" }, {0x12, 0x01, 0xf0, 0xe0, "1 Coin 2 Plays" }, {0x12, 0x01, 0xf0, 0xd0, "1 Coin 3 Plays" }, {0x12, 0x01, 0xf0, 0xc0, "1 Coin 4 Plays" }, {0x12, 0x01, 0xf0, 0xb0, "1 Coin 5 Plays" }, // Dip 3 {0 , 0xfe, 0 , 2 , "Flip Screen" }, {0x13, 0x01, 0x01, 0x01, "Off" }, {0x13, 0x01, 0x01, 0x00, "On" }, {0 , 0xfe, 0 , 4 , "Lives" }, {0x13, 0x01, 0x06, 0x06, "2" }, {0x13, 0x01, 0x06, 0x04, "3" }, {0x13, 0x01, 0x06, 0x02, "4" }, {0x13, 0x01, 0x06, 0x00, "5" }, {0 , 0xfe, 0 , 4 , "Difficulty" }, {0x13, 0x01, 0x18, 0x18, "Normal" }, {0x13, 0x01, 0x18, 0x08, "Medium" }, {0x13, 0x01, 0x18, 0x10, "Hard" }, {0x13, 0x01, 0x18, 0x00, "Invincibilty" }, {0 , 0xfe, 0 , 2 , "Cabinet" }, {0x13, 0x01, 0x20, 0x20, "Upright" }, {0x13, 0x01, 0x20, 0x00, "Cocktail" }, {0 , 0xfe, 0 , 2 , "Demo Sounds" }, {0x13, 0x01, 0x40, 0x00, "Off" }, {0x13, 0x01, 0x40, 0x40, "On" }, {0 , 0xfe, 0 , 2 , "Allow Continue" }, {0x13, 0x01, 0x80, 0x80, "Off" }, {0x13, 0x01, 0x80, 0x00, "On" }, }; STDDIPINFO(Buccanrs) static struct BurnDIPInfo BuccanrsaDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xf4, NULL }, {0x12, 0xff, 0xff, 0xff, NULL }, {0x13, 0xff, 0xff, 0x7f, NULL }, // Dip 1 {0 , 0xfe, 0 , 2 , "Service Mode" }, {0x11, 0x01, 0xf4, 0xf4, "Off" }, {0x11, 0x01, 0xf4, 0x00, "On" }, // Dip 2 {0 , 0xfe, 0 , 12 , "Coin A" }, {0x12, 0x01, 0x0f, 0x04, "4 Coins 1 Play" }, {0x12, 0x01, 0x0f, 0x07, "3 Coins 1 Play" }, {0x12, 0x01, 0x0f, 0x00, "5 Coins 2 Plays" }, {0x12, 0x01, 0x0f, 0x0a, "2 Coins 1 Play" }, {0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Plays" }, {0x12, 0x01, 0x0f, 0x03, "4 Coins 3 Plays" }, {0x12, 0x01, 0x0f, 0x0f, "1 Coin 1 Play" }, {0x12, 0x01, 0x0f, 0x05, "3 Coins 5 Plays" }, {0x12, 0x01, 0x0f, 0x0e, "1 Coin 2 Plays" }, {0x12, 0x01, 0x0f, 0x0d, "1 Coin 3 Plays" }, {0x12, 0x01, 0x0f, 0x0c, "1 Coin 4 Plays" }, {0x12, 0x01, 0x0f, 0x0b, "1 Coin 5 Plays" }, {0 , 0xfe, 0 , 12 , "Coin B" }, {0x12, 0x01, 0xf0, 0x40, "4 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x70, "3 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x00, "5 Coins 2 Plays" }, {0x12, 0x01, 0xf0, 0xa0, "2 Coins 1 Play" }, {0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Plays" }, {0x12, 0x01, 0xf0, 0x30, "4 Coins 3 Plays" }, {0x12, 0x01, 0xf0, 0xf0, "1 Coin 1 Play" }, {0x12, 0x01, 0xf0, 0x50, "3 Coins 5 Plays" }, {0x12, 0x01, 0xf0, 0xe0, "1 Coin 2 Plays" }, {0x12, 0x01, 0xf0, 0xd0, "1 Coin 3 Plays" }, {0x12, 0x01, 0xf0, 0xc0, "1 Coin 4 Plays" }, {0x12, 0x01, 0xf0, 0xb0, "1 Coin 5 Plays" }, // Dip 3 {0 , 0xfe, 0 , 2 , "Flip Screen" }, {0x13, 0x01, 0x01, 0x01, "Off" }, {0x13, 0x01, 0x01, 0x00, "On" }, {0 , 0xfe, 0 , 4 , "Lives" }, {0x13, 0x01, 0x06, 0x06, "2" }, {0x13, 0x01, 0x06, 0x04, "3" }, {0x13, 0x01, 0x06, 0x02, "4" }, {0x13, 0x01, 0x06, 0x00, "5" }, {0 , 0xfe, 0 , 4 , "Difficulty" }, {0x13, 0x01, 0x18, 0x18, "Normal" }, {0x13, 0x01, 0x18, 0x08, "Medium" }, {0x13, 0x01, 0x18, 0x10, "Hard" }, {0x13, 0x01, 0x18, 0x00, "Invincibilty" }, {0 , 0xfe, 0 , 2 , "Cabinet" }, {0x13, 0x01, 0x20, 0x20, "Upright" }, {0x13, 0x01, 0x20, 0x00, "Cocktail" }, {0 , 0xfe, 0 , 2 , "Demo Sounds" }, {0x13, 0x01, 0x40, 0x00, "Off" }, {0x13, 0x01, 0x40, 0x40, "On" }, {0 , 0xfe, 0 , 2 , "Allow Continue" }, {0x13, 0x01, 0x80, 0x80, "Off" }, {0x13, 0x01, 0x80, 0x00, "On" }, }; STDDIPINFO(Buccanrsa) static struct BurnDIPInfo KikcubicDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xff, NULL }, {0x12, 0xff, 0xff, 0xd5, NULL }, // Dip 1 {0 , 0xfe, 0 , 4 , "Difficulty" }, {0x11, 0x01, 0x03, 0x02, "Easy" }, {0x11, 0x01, 0x03, 0x03, "Medium" }, {0x11, 0x01, 0x03, 0x01, "Hard" }, {0x11, 0x01, 0x03, 0x00, "Hardest" }, {0 , 0xfe, 0 , 4 , "Lives" }, {0x11, 0x01, 0x0c, 0x08, "1" }, {0x11, 0x01, 0x0c, 0x04, "2" }, {0x11, 0x01, 0x0c, 0x0c, "3" }, {0x11, 0x01, 0x0c, 0x00, "4" }, {0 , 0xfe, 0 , 12 , "Coinage" }, {0x11, 0x01, 0xf0, 0xa0, "6 Coins 1 Play" }, {0x11, 0x01, 0xf0, 0xb0, "5 Coins 1 Play" }, {0x11, 0x01, 0xf0, 0xc0, "4 Coins 1 Play" }, {0x11, 0x01, 0xf0, 0xd0, "3 Coins 1 Play" }, {0x11, 0x01, 0xf0, 0xe0, "2 Coins 1 Play" }, {0x11, 0x01, 0xf0, 0xf0, "1 Coin 1 Play" }, {0x11, 0x01, 0xf0, 0x70, "1 Coin 2 Plays" }, {0x11, 0x01, 0xf0, 0x60, "1 Coin 3 Plays" }, {0x11, 0x01, 0xf0, 0x50, "1 Coin 4 Plays" }, {0x11, 0x01, 0xf0, 0x40, "1 Coin 5 Plays" }, {0x11, 0x01, 0xf0, 0x30, "1 Coin 6 Plays" }, {0x11, 0x01, 0xf0, 0x00, "Freeplay" }, // Dip 2 {0 , 0xfe, 0 , 2 , "Flip Screen" }, {0x12, 0x01, 0x01, 0x01, "Off" }, {0x12, 0x01, 0x01, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Cabinet" }, {0x12, 0x01, 0x02, 0x00, "Upright" }, {0x12, 0x01, 0x02, 0x02, "Cocktail" }, {0 , 0xfe, 0 , 2 , "Coin Mode" }, {0x12, 0x01, 0x04, 0x04, "Mode 1" }, {0x12, 0x01, 0x04, 0x00, "Mode 2" }, {0 , 0xfe, 0 , 2 , "Demo Sounds" }, {0x12, 0x01, 0x08, 0x08, "Off" }, {0x12, 0x01, 0x08, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Invulnerability" }, {0x12, 0x01, 0x10, 0x10, "Off" }, {0x12, 0x01, 0x10, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Level Select" }, {0x12, 0x01, 0x20, 0x20, "Off" }, {0x12, 0x01, 0x20, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Player Adding" }, {0x12, 0x01, 0x40, 0x40, "Off" }, {0x12, 0x01, 0x40, 0x00, "On" }, {0 , 0xfe, 0 , 2 , "Service Mode" }, {0x12, 0x01, 0x80, 0x80, "Off" }, {0x12, 0x01, 0x80, 0x00, "On" }, }; STDDIPINFO(Kikcubic) static struct BurnRomInfo DrvRomDesc[] = { { "g07_c03.bin", 0x08000, 0x9dcca081, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "j07_c04.bin", 0x10000, 0xe0159105, BRF_ESS | BRF_PRG }, // 1 { "g05_c02.bin", 0x10000, 0x10582b2d, BRF_ESS | BRF_PRG }, // 2 Z80 #2 Program { "f05_c08.bin", 0x10000, 0x01579d20, BRF_GRA }, // 3 Characters { "h05_c09.bin", 0x10000, 0x4f5872f0, BRF_GRA }, // 4 { "n07_c12.bin", 0x10000, 0x10af8eb2, BRF_GRA }, // 5 Sprites { "k07_c10.bin", 0x10000, 0x9576f304, BRF_GRA }, // 6 { "o07_c13.bin", 0x10000, 0xb1d9d4dc, BRF_GRA }, // 7 { "l07_c11.bin", 0x10000, 0x4598be4a, BRF_GRA }, // 8 { "t07_c16.bin", 0x10000, 0xf5425e42, BRF_GRA }, // 9 { "p07_c14.bin", 0x10000, 0xcb50a17c, BRF_GRA }, // 10 { "v07_c17.bin", 0x10000, 0x959ba3c7, BRF_GRA }, // 11 { "s07_c15.bin", 0x10000, 0x7f2e91c5, BRF_GRA }, // 12 { "d01_c05.bin", 0x10000, 0x81b1ee5c, BRF_GRA }, // 13 Background { "e01_c06.bin", 0x10000, 0xd0d33673, BRF_GRA }, // 14 { "f01_c07.bin", 0x10000, 0xaae81695, BRF_GRA }, // 15 { "d04_c01.bin", 0x10000, 0x9b85101d, BRF_SND }, // 16 Samples { "pal16l8.8r", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 17 PALs { "pal16l8.4m", 0x00104, 0x6c628a26, BRF_GRA }, // 18 { "pal16l8.1b", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 19 }; STD_ROM_PICK(Drv) STD_ROM_FN(Drv) static struct BurnRomInfo DrvuRomDesc[] = { { "a-8h", 0x08000, 0x8d15109e, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "a-8l", 0x10000, 0x7f95799b, BRF_ESS | BRF_PRG }, // 1 { "g05_c02.bin", 0x10000, 0x10582b2d, BRF_ESS | BRF_PRG }, // 2 Z80 #2 Program { "f05_c08.bin", 0x10000, 0x01579d20, BRF_GRA }, // 3 Characters { "h05_c09.bin", 0x10000, 0x4f5872f0, BRF_GRA }, // 4 { "n07_c12.bin", 0x10000, 0x10af8eb2, BRF_GRA }, // 5 Sprites { "k07_c10.bin", 0x10000, 0x9576f304, BRF_GRA }, // 6 { "o07_c13.bin", 0x10000, 0xb1d9d4dc, BRF_GRA }, // 7 { "l07_c11.bin", 0x10000, 0x4598be4a, BRF_GRA }, // 8 { "t07_c16.bin", 0x10000, 0xf5425e42, BRF_GRA }, // 9 { "p07_c14.bin", 0x10000, 0xcb50a17c, BRF_GRA }, // 10 { "v07_c17.bin", 0x10000, 0x959ba3c7, BRF_GRA }, // 11 { "s07_c15.bin", 0x10000, 0x7f2e91c5, BRF_GRA }, // 12 { "d01_c05.bin", 0x10000, 0x81b1ee5c, BRF_GRA }, // 13 Background { "e01_c06.bin", 0x10000, 0xd0d33673, BRF_GRA }, // 14 { "f01_c07.bin", 0x10000, 0xaae81695, BRF_GRA }, // 15 { "d04_c01.bin", 0x10000, 0x9b85101d, BRF_SND }, // 16 Samples { "pal16l8.8r", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 17 PALs { "pal16l8.4m", 0x00104, 0x6c628a26, BRF_GRA }, // 18 { "pal16l8.1b", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 19 }; STD_ROM_PICK(Drvu) STD_ROM_FN(Drvu) static struct BurnRomInfo DrvjRomDesc[] = { { "vg_a-8h.rom", 0x08000, 0xba848713, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "vg_a-8l.rom", 0x10000, 0x3b12b1d8, BRF_ESS | BRF_PRG }, // 1 { "g05_c02.bin", 0x10000, 0x10582b2d, BRF_ESS | BRF_PRG }, // 2 Z80 #2 Program { "f05_c08.bin", 0x10000, 0x01579d20, BRF_GRA }, // 3 Characters { "h05_c09.bin", 0x10000, 0x4f5872f0, BRF_GRA }, // 4 { "n07_c12.bin", 0x10000, 0x10af8eb2, BRF_GRA }, // 5 Sprites { "k07_c10.bin", 0x10000, 0x9576f304, BRF_GRA }, // 6 { "o07_c13.bin", 0x10000, 0xb1d9d4dc, BRF_GRA }, // 7 { "l07_c11.bin", 0x10000, 0x4598be4a, BRF_GRA }, // 8 { "t07_c16.bin", 0x10000, 0xf5425e42, BRF_GRA }, // 9 { "p07_c14.bin", 0x10000, 0xcb50a17c, BRF_GRA }, // 10 { "v07_c17.bin", 0x10000, 0x959ba3c7, BRF_GRA }, // 11 { "s07_c15.bin", 0x10000, 0x7f2e91c5, BRF_GRA }, // 12 { "d01_c05.bin", 0x10000, 0x81b1ee5c, BRF_GRA }, // 13 Background { "e01_c06.bin", 0x10000, 0xd0d33673, BRF_GRA }, // 14 { "f01_c07.bin", 0x10000, 0xaae81695, BRF_GRA }, // 15 { "d04_c01.bin", 0x10000, 0x9b85101d, BRF_SND }, // 16 Samples { "pal16l8.8r", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 17 PALs { "pal16l8.4m", 0x00104, 0x6c628a26, BRF_GRA }, // 18 { "pal16l8.1b", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 19 }; STD_ROM_PICK(Drvj) STD_ROM_FN(Drvj) static struct BurnRomInfo BuccanrsRomDesc[] = { { "11.u58", 0x10000, 0xbf1d7e6f, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "12.u25", 0x10000, 0x87303ba8, BRF_ESS | BRF_PRG }, // 1 { "1.u128", 0x10000, 0xeb65f8c3, BRF_ESS | BRF_PRG }, // 2 Z80 #2 Program { "7.u212", 0x10000, 0x95e3c517, BRF_GRA }, // 3 Characters { "8.u189", 0x10000, 0xfe2377ab, BRF_GRA }, // 4 { "3.u100", 0x20000, 0x16dc435f, BRF_GRA }, // 5 Sprites { "4.u80", 0x10000, 0x4fe3bf97, BRF_GRA }, // 6 { "6.u52", 0x20000, 0x078aef7f, BRF_GRA }, // 7 { "5.u70", 0x10000, 0xf650fa90, BRF_GRA }, // 8 { "9.u49", 0x20000, 0x0c6188fb, BRF_GRA }, // 9 Background { "10.u27", 0x20000, 0x2d383ff8, BRF_GRA }, // 10 { "2.u74", 0x10000, 0x36ee1dac, BRF_SND }, // 11 Samples { "prom1.u54", 0x00100, 0xc324835e, BRF_GRA }, // 12 PROMs { "prom4.u79", 0x00100, 0xe6506ef4, BRF_GRA }, // 13 { "prom3.u88", 0x00100, 0xb43d094f, BRF_GRA }, // 14 { "prom2.u99", 0x00100, 0xe0aa8869, BRF_GRA }, // 15 { "pal16l8.u103", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 16 PALs { "pal16l8.u156", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 17 { "pal16l8.u42", 0x00104, 0x00000000, BRF_GRA | BRF_NODUMP }, // 18 }; STD_ROM_PICK(Buccanrs) STD_ROM_FN(Buccanrs) static struct BurnRomInfo BuccanrsaRomDesc[] = { { "bc-011", 0x08000, 0x6b657ef1, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "12.u25", 0x10000, 0x87303ba8, BRF_ESS | BRF_PRG }, // 1 { "1.u128", 0x10000, 0xeb65f8c3, BRF_ESS | BRF_PRG }, // 2 Z80 #2 Program { "7.u212", 0x10000, 0x95e3c517, BRF_GRA }, // 3 Characters { "8.u189", 0x10000, 0xfe2377ab, BRF_GRA }, // 4 { "3.u100", 0x20000, 0x16dc435f, BRF_GRA }, // 5 Sprites { "4.u80", 0x10000, 0x4fe3bf97, BRF_GRA }, // 6 { "6.u52", 0x20000, 0x078aef7f, BRF_GRA }, // 7 { "5.u70", 0x10000, 0xf650fa90, BRF_GRA }, // 8 { "9.u49", 0x20000, 0x0c6188fb, BRF_GRA }, // 9 Background { "10.u27", 0x20000, 0x2d383ff8, BRF_GRA }, // 10 { "2.u74", 0x10000, 0x36ee1dac, BRF_SND }, // 11 Samples { "prom1.u54", 0x00100, 0xc324835e, BRF_GRA }, // 12 PROMs { "prom4.u79", 0x00100, 0xe6506ef4, BRF_GRA }, // 13 { "prom3.u88", 0x00100, 0xb43d094f, BRF_GRA }, // 14 { "prom2.u99", 0x00100, 0xe0aa8869, BRF_GRA }, // 15 }; STD_ROM_PICK(Buccanrsa) STD_ROM_FN(Buccanrsa) static struct BurnRomInfo KikcubicRomDesc[] = { { "mqj-p0", 0x08000, 0x9cef394a, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "mqj-b0", 0x10000, 0xd9bcf4cd, BRF_ESS | BRF_PRG }, // 1 { "mqj-b1", 0x10000, 0x54a0abe1, BRF_ESS | BRF_PRG }, // 2 { "mqj-sp", 0x10000, 0xbbcf3582, BRF_ESS | BRF_PRG }, // 3 Z80 #2 Program { "mqj-c0", 0x10000, 0x975585c5, BRF_GRA }, // 4 Characters { "mqj-c1", 0x10000, 0x49d9936d, BRF_GRA }, // 5 { "mqj-00", 0x40000, 0x7fb0c58f, BRF_GRA }, // 6 Sprites { "mqj-10", 0x40000, 0x3a189205, BRF_GRA }, // 7 { "mqj-v0", 0x10000, 0x54762956, BRF_SND }, // 8 Samples { "8d", 0x00100, 0x7379bb12, BRF_GRA }, // 9 PROMs { "6h", 0x00020, 0xface0cbb, BRF_GRA }, // 10 { "7s", 0x00020, 0xface0cbb, BRF_GRA }, // 11 }; STD_ROM_PICK(Kikcubic) STD_ROM_FN(Kikcubic) static struct BurnRomInfo KikcubicbRomDesc[] = { { "1.bin", 0x08000, 0xd3a589ba, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code { "4.bin", 0x10000, 0x9ae1e1a6, BRF_ESS | BRF_PRG }, // 1 { "5.bin", 0x08000, 0xa5a6bffd, BRF_ESS | BRF_PRG }, // 2 { "mqj-sp", 0x10000, 0xbbcf3582, BRF_ESS | BRF_PRG }, // 3 Z80 #2 Program { "7.bin", 0x10000, 0x1788d51a, BRF_GRA }, // 4 Characters { "mqj-c1", 0x10000, 0x49d9936d, BRF_GRA }, // 5 { "11.bin", 0x10000, 0x0f0cac92, BRF_GRA }, // 6 Sprites { "10.bin", 0x10000, 0x7d3822a8, BRF_GRA }, // 7 { "9.bin", 0x10000, 0x56fb4fa3, BRF_GRA }, // 8 { "8.bin", 0x10000, 0x947dbd4e, BRF_GRA }, // 9 { "mqj-v0", 0x10000, 0x54762956, BRF_SND }, // 10 Samples { "8d", 0x00100, 0x7379bb12, BRF_GRA }, // 11 PROMs { "6h", 0x00020, 0xface0cbb, BRF_GRA }, // 12 { "7s", 0x00020, 0xface0cbb, BRF_GRA }, // 13 }; STD_ROM_PICK(Kikcubicb) STD_ROM_FN(Kikcubicb) static int MemIndex() { unsigned char *Next; Next = Mem; DrvZ80Rom1 = Next; Next += 0x28000; DrvZ80Rom2 = Next; Next += 0x10000; DrvSamples = Next; Next += 0x10000; RamStart = Next; DrvZ80Ram1 = Next; Next += 0x02000; DrvZ80Ram2 = Next; Next += 0x01000; DrvSpriteRam = Next; Next += 0x00100; DrvPaletteRam = Next; Next += 0x00800; DrvVideoRam = Next; Next += 0x01000; DrvPalette = (unsigned int*)Next; Next += (512 + 32) * sizeof(unsigned int); RamEnd = Next; DrvChars = Next; Next += 0x1000 * 8 * 8; DrvSprites = Next; Next += 0x1000 * 16 * 16; DrvBackTiles = Next; Next += 0x4000 * 32; MemEnd = Next; return 0; } static void DrvSetVector(int Status) { switch (Status) { case VECTOR_INIT: { DrvIrqVector = 0xff; break; } case YM2151_ASSERT: { DrvIrqVector &= 0xef; break; } case YM2151_CLEAR: { DrvIrqVector |= 0x10; break; } case Z80_ASSERT: { DrvIrqVector &= 0xdf; break; } case Z80_CLEAR: { DrvIrqVector |= 0x20; break; } } if (DrvIrqVector == 0xff) { ZetSetVector(DrvIrqVector); ZetSetIRQLine(0/*DrvIrqVector*/, ZET_IRQSTATUS_NONE); } else { ZetSetVector(DrvIrqVector); ZetSetIRQLine(0/*DrvIrqVector*/, ZET_IRQSTATUS_ACK); nCyclesDone[1] += ZetRun(1000); } } static int DrvDoReset() { for (int i = 0; i < 2; i++) { ZetOpen(i); ZetReset(); if (i == 1) DrvSetVector(VECTOR_INIT); ZetClose(); } if (DrvHasYM2203) { BurnYM2203Reset(); } else { BurnYM2151Reset(); } DACReset(); DrvRomBank = 0; DrvSoundLatch = 0; DrvRearColour = 0; DrvRearDisable = 0; DrvHorizScrollLo = 0; DrvHorizScrollHi = 0; DrvRearHorizScrollLo = 0; DrvRearHorizScrollHi = 0; DrvSampleAddress = 0; return 0; } unsigned char __fastcall VigilanteZ80Read1(unsigned short a) { // switch (a) { // default: { // bprintf(PRINT_NORMAL, _T("Z80 #1 Read => %04X\n"), a); // } // } return 0; } void __fastcall VigilanteZ80Write1(unsigned short a, unsigned char d) { if (a >= 0xc020 && a <= 0xc0df) { DrvSpriteRam[a - 0xc020] = d; return; } if (a >= 0xc800 && a <= 0xcfff) { int Offset = a & 0x7ff; int Bank = Offset & 0x400; int r, g, b; DrvPaletteRam[Offset] = d; Offset &= 0xff; r = (DrvPaletteRam[Bank + Offset + 0x000] << 3) & 0xff; g = (DrvPaletteRam[Bank + Offset + 0x100] << 3) & 0xff; b = (DrvPaletteRam[Bank + Offset + 0x200] << 3) & 0xff; DrvPalette[(Bank >> 2) + Offset] = BurnHighCol(r, g, b, 0); return; } // switch (a) { // default: { // bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d); // } // } } unsigned char __fastcall VigilanteZ80PortRead1(unsigned short a) { a &= 0xff; switch (a) { case 0x00: { return 0xff - DrvInput[0]; } case 0x01: { return 0xff - DrvInput[1]; } case 0x02: { return 0xff - DrvInput[2]; } case 0x03: { return DrvDip[0]; } case 0x04: { return DrvDip[1]; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a); } #endif } return 0; } unsigned char __fastcall BuccanrsZ80PortRead1(unsigned short a) { a &= 0xff; switch (a) { case 0x00: { return (0xd0 - DrvInput[0]) | DrvDip[0]; } case 0x01: { return 0xff - DrvInput[1]; } case 0x02: { return 0xff - DrvInput[2]; } case 0x03: { return DrvDip[1]; } case 0x04: { return DrvDip[2]; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a); } #endif } return 0; } unsigned char __fastcall BuccanrsaZ80PortRead1(unsigned short a) { a &= 0xff; switch (a) { case 0x00: { return (0x0b - DrvInput[0]) | DrvDip[0]; } case 0x01: { return 0xff - DrvInput[1]; } case 0x02: { return 0xff - DrvInput[2]; } case 0x03: { return DrvDip[1]; } case 0x04: { return DrvDip[2]; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a); } #endif } return 0; } void __fastcall VigilanteZ80PortWrite1(unsigned short a, unsigned char d) { a &= 0xff; switch (a) { case 0x00: { DrvSoundLatch = d; ZetClose(); ZetOpen(1); DrvSetVector(Z80_ASSERT); ZetClose(); ZetOpen(0); return; } #if 0 case 0x01: { // output port? return; } #endif case 0x04: { DrvRomBank = d & 0x07; ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000)); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000)); return; } case 0x80: { DrvHorizScrollLo = d; return; } case 0x81: { DrvHorizScrollHi = (d & 0x01) << 8; return; } case 0x82: { DrvRearHorizScrollLo = d; return; } case 0x83: { DrvRearHorizScrollHi = (d & 0x07) << 8; return; } case 0x84: { DrvRearColour = d & 0x0d; DrvRearDisable = d & 0x40; return; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #1 Port Write => %02X, %02X\n"), a, d); } #endif } } unsigned char __fastcall KikcubicZ80Read1(unsigned short a) { // switch (a) { // default: { // bprintf(PRINT_NORMAL, _T("Z80 #1 Read => %04X\n"), a); // } // } return 0; } void __fastcall KikcubicZ80Write1(unsigned short a, unsigned char d) { if (a >= 0xc800 && a <= 0xcaff) { int Offset = a & 0x3ff; int Bank = Offset & 0x400; int r, g, b; DrvPaletteRam[Offset] = d; Offset &= 0xff; r = (DrvPaletteRam[Bank + Offset + 0x000] << 3) & 0xff; g = (DrvPaletteRam[Bank + Offset + 0x100] << 3) & 0xff; b = (DrvPaletteRam[Bank + Offset + 0x200] << 3) & 0xff; DrvPalette[(Bank >> 2) + Offset] = BurnHighCol(r, g, b, 0); return; } // switch (a) { // default: { // bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d); // } // } } unsigned char __fastcall KikcubicZ80PortRead1(unsigned short a) { a &= 0xff; switch (a) { case 0x00: { return DrvDip[0]; } case 0x01: { return DrvDip[1]; } case 0x02: { return 0xff - DrvInput[1]; } case 0x03: { return 0xff - DrvInput[0]; } case 0x04: { return 0xff - DrvInput[2]; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a); } #endif } return 0; } void __fastcall KikcubicZ80PortWrite1(unsigned short a, unsigned char d) { a &= 0xff; switch (a) { #if 0 case 0x00: { // coin write return; } #endif case 0x04: { DrvRomBank = d & 0x07; ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000)); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000)); return; } case 0x06: { DrvSoundLatch = d; ZetClose(); ZetOpen(1); DrvSetVector(Z80_ASSERT); ZetClose(); ZetOpen(0); return; } #if 0 case 0x07: { // nop??? return; } default: { bprintf(PRINT_NORMAL, _T("Z80 #1 Port Write => %02X, %02X\n"), a, d); } #endif } } unsigned char __fastcall VigilanteZ80Read2(unsigned short a) { // switch (a) { // default: { // bprintf(PRINT_NORMAL, _T("Z80 #2 Read => %04X\n"), a); // } // } return 0; } void __fastcall VigilanteZ80Write2(unsigned short a, unsigned char d) { // switch (a) { // default: { // bprintf(PRINT_NORMAL, _T("Z80 #2 Write => %04X, %02X\n"), a, d); // } // } } unsigned char __fastcall VigilanteZ80PortRead2(unsigned short a) { a &= 0xff; switch (a) { case 0x01: { return BurnYM2151ReadStatus(); } case 0x80: { return DrvSoundLatch; } case 0x84: { return DrvSamples[DrvSampleAddress]; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #2 Port Read => %02X\n"), a); } #endif } return 0; } void __fastcall VigilanteZ80PortWrite2(unsigned short a, unsigned char d) { a &= 0xff; switch (a) { case 0x00: { BurnYM2151SelectRegister(d); return; } case 0x01: { BurnYM2151WriteRegister(d); return; } case 0x80: { DrvSampleAddress = (DrvSampleAddress & 0xff00) | ((d << 0) & 0x00ff); return; } case 0x81: { DrvSampleAddress = (DrvSampleAddress & 0x00ff) | ((d << 8) & 0xff00); return; } case 0x82: { DACSignedWrite(d); DrvSampleAddress = (DrvSampleAddress + 1) & 0xffff; return; } case 0x83: { DrvSetVector(Z80_CLEAR); return; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #2 Port Write => %02X, %02X\n"), a, d); } #endif } } unsigned char __fastcall BuccanrsZ80PortRead2(unsigned short a) { a &= 0xff; switch (a) { case 0x00: { return YM2203Read(0, 0); } case 0x02: { return YM2203Read(1, 0); } case 0x80: { return DrvSoundLatch; } case 0x84: { return DrvSamples[DrvSampleAddress]; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #2 Port Read => %02X\n"), a); } #endif } return 0; } void __fastcall BuccanrsZ80PortWrite2(unsigned short a, unsigned char d) { a &= 0xff; switch (a) { case 0x00: { BurnYM2203Write(0, 0, d); return; } case 0x01: { BurnYM2203Write(0, 1, d); return; } case 0x02: { BurnYM2203Write(1, 0, d); return; } case 0x03: { BurnYM2203Write(1, 1, d); return; } case 0x80: { DrvSampleAddress = (DrvSampleAddress & 0xff00) | ((d << 0) & 0x00ff); return; } case 0x81: { DrvSampleAddress = (DrvSampleAddress & 0x00ff) | ((d << 8) & 0xff00); return; } case 0x82: { DACSignedWrite(d); DrvSampleAddress = (DrvSampleAddress + 1) & 0xffff; return; } case 0x83: { DrvSetVector(Z80_CLEAR); return; } #if 0 default: { bprintf(PRINT_NORMAL, _T("Z80 #2 Port Write => %02X, %02X\n"), a, d); } #endif } } static void VigilantYM2151IrqHandler(int Irq) { if (Irq) { DrvSetVector(YM2151_ASSERT); } else { DrvSetVector(YM2151_CLEAR); } } static inline void BuccanrsYM2203IRQHandler(int, int nStatus) { if (nStatus & 1) { DrvSetVector(YM2151_ASSERT); } else { DrvSetVector(YM2151_CLEAR); } } static inline int BuccanrsSynchroniseStream(int nSoundRate) { return (long long)ZetTotalCycles() * nSoundRate / (18432000 / 6); } static inline double BuccanrsGetTime() { return (double)ZetTotalCycles() / (18432000 / 6); } static int CharPlaneOffsets[4] = { 0x80000, 0x80004, 0, 4 }; static int CharXOffsets[8] = { 0, 1, 2, 3, 64, 65, 66, 67 }; static int CharYOffsets[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; static int SpritePlaneOffsets[4] = { 0x200000, 0x200004, 0, 4 }; static int SpriteXOffsets[16] = { 0, 1, 2, 3, 128, 129, 130, 131, 256, 257, 258, 259, 384, 385, 386, 387 }; static int SpriteYOffsets[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }; static int BackTilePlaneOffsets[4] = { 0, 2, 4, 6 }; static int BackTileXOffsets[32] = { 1, 0, 9, 8, 17, 16, 25, 24, 33, 32, 41, 40, 49, 48, 57, 56, 65, 64, 73, 72, 81, 80, 89, 88, 97, 96, 105, 104, 113, 112, 121, 120 }; static int BackTileYOffsets[1] = { 0 }; static int BuccSpriteXOffsets[16] = { 3, 2, 1, 0, 131, 130, 129, 128, 259, 258, 257, 256, 387, 386, 385, 384 }; static int BuccBackTilePlaneOffsets[4] = { 6, 4, 2, 0 }; static int DrvInit() { int nRet = 0, nLen; // Allocate and Blank all required memory Mem = NULL; MemIndex(); nLen = MemEnd - (unsigned char *)0; if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); MemIndex(); DrvTempRom = (unsigned char *)malloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1; // Load Z80 #2 Program Roms nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 2, 1); if (nRet != 0) return 1; // Load and decode the chars nRet = BurnLoadRom(DrvTempRom + 0x00000, 3, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 4, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars); // Load and decode the sprites memset(DrvTempRom, 0, 0x80000); nRet = BurnLoadRom(DrvTempRom + 0x00000, 5, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 6, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x20000, 7, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x30000, 8, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x40000, 9, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x50000, 10, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x60000, 11, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x70000, 12, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites); // Load and decode the bg tiles memset(DrvTempRom, 0, 0x80000); nRet = BurnLoadRom(DrvTempRom + 0x00000, 13, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 14, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x20000, 15, 1); if (nRet != 0) return 1; GfxDecode(0x4000, 4, 32, 1, BackTilePlaneOffsets, BackTileXOffsets, BackTileYOffsets, 0x80, DrvTempRom, DrvBackTiles); free(DrvTempRom); // Load sample Roms nRet = BurnLoadRom(DrvSamples + 0x00000, 16, 1); if (nRet != 0) return 1; // Setup the Z80 emulation ZetInit(2); ZetOpen(0); ZetSetReadHandler(VigilanteZ80Read1); ZetSetWriteHandler(VigilanteZ80Write1); ZetSetInHandler(VigilanteZ80PortRead1); ZetSetOutHandler(VigilanteZ80PortWrite1); ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1 ); ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1 ); ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000 ); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000 ); ZetMapArea(0xc800, 0xcfff, 0, DrvPaletteRam ); ZetMapArea(0xc800, 0xcfff, 2, DrvPaletteRam ); ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam ); ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam ); ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam ); ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram1 ); ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram1 ); ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram1 ); ZetMemEnd(); ZetClose(); ZetOpen(1); ZetSetReadHandler(VigilanteZ80Read2); ZetSetWriteHandler(VigilanteZ80Write2); ZetSetInHandler(VigilanteZ80PortRead2); ZetSetOutHandler(VigilanteZ80PortWrite2); ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2 ); ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2 ); ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2 ); ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2 ); ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2 ); ZetMemEnd(); ZetClose(); BurnSetRefreshRate(55.0); nCyclesTotal[0] = 3579645 / 55; nCyclesTotal[1] = 3579645 / 55; GenericTilesInit(); BurnYM2151Init(3579645, 25.0); BurnYM2151SetIrqHandler(&VigilantYM2151IrqHandler); DACInit(0, 1); DACSetVolShift(1); DrvDoReset(); return 0; } static int BuccanrsInit() { int nRet = 0, nLen; // Allocate and Blank all required memory Mem = NULL; MemIndex(); nLen = MemEnd - (unsigned char *)0; if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); MemIndex(); DrvTempRom = (unsigned char *)malloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1; // Load Z80 #2 Program Roms nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 2, 1); if (nRet != 0) return 1; // Load and decode the chars nRet = BurnLoadRom(DrvTempRom + 0x00000, 3, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 4, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars); // Load and decode the sprites memset(DrvTempRom, 0, 0x80000); nRet = BurnLoadRom(DrvTempRom + 0x00000, 5, 1); if (nRet != 0) return 1; memcpy(DrvTempRom + 0x20000, DrvTempRom + 0x10000, 0x10000); nRet = BurnLoadRom(DrvTempRom + 0x10000, 6, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x40000, 7, 1); if (nRet != 0) return 1; memcpy(DrvTempRom + 0x60000, DrvTempRom + 0x50000, 0x10000); nRet = BurnLoadRom(DrvTempRom + 0x50000, 8, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, BuccSpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites); // Load and decode the bg tiles memset(DrvTempRom, 0, 0x80000); nRet = BurnLoadRom(DrvTempRom + 0x20000, 9, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x00000, 10, 1); if (nRet != 0) return 1; GfxDecode(0x4000, 4, 32, 1, BuccBackTilePlaneOffsets, BackTileXOffsets, BackTileYOffsets, 0x80, DrvTempRom, DrvBackTiles); free(DrvTempRom); // Load sample Roms nRet = BurnLoadRom(DrvSamples + 0x00000, 11, 1); if (nRet != 0) return 1; // Setup the Z80 emulation ZetInit(2); ZetOpen(0); ZetSetReadHandler(VigilanteZ80Read1); ZetSetWriteHandler(VigilanteZ80Write1); ZetSetInHandler(BuccanrsZ80PortRead1); ZetSetOutHandler(VigilanteZ80PortWrite1); if (!strcmp(BurnDrvGetTextA(DRV_NAME), "buccanrsa")) ZetSetInHandler(BuccanrsaZ80PortRead1); ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1 ); ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1 ); ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000 ); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000 ); ZetMapArea(0xc800, 0xcfff, 0, DrvPaletteRam ); ZetMapArea(0xc800, 0xcfff, 2, DrvPaletteRam ); ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam ); ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam ); ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam ); ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram1 ); ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram1 ); ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram1 ); ZetMemEnd(); ZetClose(); ZetOpen(1); ZetSetReadHandler(VigilanteZ80Read2); ZetSetWriteHandler(VigilanteZ80Write2); ZetSetInHandler(BuccanrsZ80PortRead2); ZetSetOutHandler(BuccanrsZ80PortWrite2); ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2 ); ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2 ); ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2 ); ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2 ); ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2 ); ZetMemEnd(); ZetClose(); BurnSetRefreshRate(55.0); nCyclesTotal[0] = 5688800 / 55; nCyclesTotal[1] = (18432000 / 6) / 55; GenericTilesInit(); DrvHasYM2203 = 1; BurnYM2203Init(2, 18432000 / 6, &BuccanrsYM2203IRQHandler, BuccanrsSynchroniseStream, BuccanrsGetTime, 0); BurnTimerAttachZet(18432000 / 6); DACInit(0, 1); DACSetVolShift(1); DrvDoReset(); return 0; } static int KikcubicInit() { int nRet = 0, nLen; // Allocate and Blank all required memory Mem = NULL; MemIndex(); nLen = MemEnd - (unsigned char *)0; if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); MemIndex(); DrvTempRom = (unsigned char *)malloc(0x80000); if (!strcmp(BurnDrvGetTextA(DRV_NAME), "kikcubicb")) { // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000, 2, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x28000, 2, 1); if (nRet != 0) return 1; // Load Z80 #2 Program Roms nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 3, 1); if (nRet != 0) return 1; // Load and decode the chars nRet = BurnLoadRom(DrvTempRom + 0x00000, 4, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 5, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars); // Load and decode the sprites memset(DrvTempRom, 0, 0x80000); nRet = BurnLoadRom(DrvTempRom + 0x00000, 6, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x20000, 6, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 7, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x30000, 7, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x40000, 8, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x60000, 8, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x50000, 9, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x70000, 9, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites); // Load sample Roms nRet = BurnLoadRom(DrvSamples + 0x00000, 10, 1); if (nRet != 0) return 1; } else { // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000, 2, 1); if (nRet != 0) return 1; // Load Z80 #2 Program Roms nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 3, 1); if (nRet != 0) return 1; // Load and decode the chars nRet = BurnLoadRom(DrvTempRom + 0x00000, 4, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x10000, 5, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars); // Load and decode the sprites memset(DrvTempRom, 0, 0x80000); nRet = BurnLoadRom(DrvTempRom + 0x00000, 6, 1); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvTempRom + 0x40000, 7, 1); if (nRet != 0) return 1; GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites); // Load sample Roms nRet = BurnLoadRom(DrvSamples + 0x00000, 8, 1); if (nRet != 0) return 1; } free(DrvTempRom); // Setup the Z80 emulation ZetInit(2); ZetOpen(0); ZetSetReadHandler(KikcubicZ80Read1); ZetSetWriteHandler(KikcubicZ80Write1); ZetSetInHandler(KikcubicZ80PortRead1); ZetSetOutHandler(KikcubicZ80PortWrite1); ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1 ); ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1 ); ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000 ); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000 ); ZetMapArea(0xc000, 0xc0ff, 0, DrvSpriteRam ); ZetMapArea(0xc000, 0xc0ff, 1, DrvSpriteRam ); ZetMapArea(0xc000, 0xc0ff, 2, DrvSpriteRam ); ZetMapArea(0xc800, 0xcaff, 0, DrvPaletteRam ); ZetMapArea(0xc800, 0xcaff, 2, DrvPaletteRam ); ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam ); ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam ); ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam ); ZetMapArea(0xe000, 0xffff, 0, DrvZ80Ram1 ); ZetMapArea(0xe000, 0xffff, 1, DrvZ80Ram1 ); ZetMapArea(0xe000, 0xffff, 2, DrvZ80Ram1 ); ZetMemEnd(); ZetClose(); ZetOpen(1); ZetSetReadHandler(VigilanteZ80Read2); ZetSetWriteHandler(VigilanteZ80Write2); ZetSetInHandler(VigilanteZ80PortRead2); ZetSetOutHandler(VigilanteZ80PortWrite2); ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2 ); ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2 ); ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2 ); ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2 ); ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2 ); ZetMemEnd(); ZetClose(); BurnSetRefreshRate(55.0); nCyclesTotal[0] = 3579645 / 55; nCyclesTotal[1] = 3579645 / 55; GenericTilesInit(); BurnYM2151Init(3579645, 25.0); BurnYM2151SetIrqHandler(&VigilantYM2151IrqHandler); DACInit(0, 1); DACSetVolShift(1); DrvKikcubicDraw = 1; DrvDoReset(); return 0; } static int DrvExit() { ZetExit(); BurnYM2151Exit(); BurnYM2203Exit(); GenericTilesExit(); if (Mem) { free(Mem); Mem = NULL; } DrvRomBank = 0; DrvSoundLatch = 0; DrvIrqVector = 0; DrvRearColour = 0; DrvRearDisable = 0; DrvHorizScrollLo = 0; DrvHorizScrollHi = 0; DrvRearHorizScrollLo = 0; DrvRearHorizScrollHi = 0; DrvSampleAddress = 0; DrvHasYM2203 = 0; DrvKikcubicDraw = 0; return 0; } static void DrvRenderBackground() { int CharCode = 0; int Scroll = 0x17a - (DrvRearHorizScrollLo + DrvRearHorizScrollHi); if (Scroll > 0) Scroll -= 2048; for (int i = 0; i < 16; i++) { int r, g, b; r = (DrvPaletteRam[0x400 + 16 * DrvRearColour + i] << 3) & 0xff; g = (DrvPaletteRam[0x500 + 16 * DrvRearColour + i] << 3) & 0xff; b = (DrvPaletteRam[0x600 + 16 * DrvRearColour + i] << 3) & 0xff; DrvPalette[512 + i] = BurnHighCol(r, g, b, 0); r = (DrvPaletteRam[0x400 + 16 * DrvRearColour + 32 + i] << 3) & 0xff; g = (DrvPaletteRam[0x500 + 16 * DrvRearColour + 32 + i] << 3) & 0xff; b = (DrvPaletteRam[0x600 + 16 * DrvRearColour + 32 + i] << 3) & 0xff; DrvPalette[512 + 16 + i] = BurnHighCol(r, g, b, 0); } for (int Page = 0; Page < 4; Page++) { for (int Row = 0; Row < 256; Row++) { for (int Col = 0; Col < 512; Col += 32) { int Colour = (Row < 128) ? 0 : 1; UINT32 nPalette = 512 | (Colour << 4); for (int px = 0; px < 32; px++) { unsigned char c = DrvBackTiles[(CharCode * 32) + px]; int xPos = (512 * Page) + Col + px + Scroll; if (Row >= 0 && Row < nScreenHeight) { unsigned short* pPixel = pTransDraw + (Row * nScreenWidth); if (xPos >= 0 && xPos < nScreenWidth) { pPixel[xPos] = c | nPalette; } } } CharCode++; } } } } static void DrvDrawForeground(int Priority, int Opaque) { int Scroll = -(DrvHorizScrollLo + DrvHorizScrollHi); for (int Offset = 0; Offset < 0x1000; Offset += 2) { int sy = 8 * ((Offset / 2) / 64); int sx = 8 * ((Offset / 2) % 64); int Attr = DrvVideoRam[Offset + 1]; int Colour = Attr & 0x0f; int Tile = DrvVideoRam[Offset + 0] | ((Attr & 0xf0) << 4); if (Priority) { // Sprite masking if ((Colour & 0x0c) == 0x0c) { if (sy >= 48) { sx = (sx + Scroll) & 0x1ff; sx -= 128; int px, py; UINT32 nPalette = 256 | (Colour << 4); for (py = 0; py < 8; py++) { for (px = 0; px < 8; px++) { unsigned char c = DrvChars[(Tile * 64) + (py * 8) + px]; if (((0xff >> c) & 0x01) == 0) { int xPos = sx + px; int yPos = sy + py; if (yPos >= 0 && yPos < nScreenHeight) { unsigned short* pPixel = pTransDraw + (yPos * nScreenWidth); if (xPos >= 0 && xPos < nScreenWidth) { pPixel[xPos] = c | nPalette; } } } } } } } } else { if (sy >= 48) sx = (sx + Scroll) & 0x1ff; sx -= 128; if (sx >= 0 && sx < (nScreenWidth - 8) && sy >= 0 && sy < (nScreenHeight - 8)) { if (Opaque || Colour >= 4) { Render8x8Tile(pTransDraw, Tile, sx, sy, Colour, 4, 256, DrvChars); } else { Render8x8Tile_Mask(pTransDraw, Tile, sx, sy, Colour, 4, 0, 256, DrvChars); } } else { if (Opaque || Colour >= 4) { Render8x8Tile_Clip(pTransDraw, Tile, sx, sy, Colour, 4, 256, DrvChars); } else { Render8x8Tile_Mask_Clip(pTransDraw, Tile, sx, sy, Colour, 4, 0, 256, DrvChars); } } } } } static void DrvDrawSprites() { int DrvSpriteRamSize = 0xc0; if (DrvKikcubicDraw) DrvSpriteRamSize = 0x100; for (int Offset = 0; Offset < DrvSpriteRamSize; Offset += 8) { int Code, Colour, sx, sy, xFlip, yFlip, h; Code = DrvSpriteRam[Offset + 4] | ((DrvSpriteRam[Offset + 5] & 0x0f) << 8); Colour = DrvSpriteRam[Offset + 0] & 0x0f; sx = (DrvSpriteRam[Offset + 6] | ((DrvSpriteRam[Offset + 7] & 0x01) << 8)); sy = 256 + 128 - (DrvSpriteRam[Offset + 2] | ((DrvSpriteRam[Offset + 3] & 0x01) << 8)); xFlip = DrvSpriteRam[Offset + 5] & 0x40; yFlip = DrvSpriteRam[Offset + 5] & 0x80; h = 1 << ((DrvSpriteRam[Offset + 5] & 0x30) >> 4); sy -= 16 * h; Code &= ~(h - 1); if (DrvKikcubicDraw) { sx -= 64; } else { sx -= 128; } for (int y = 0; y < h; y++) { int c = Code; if (yFlip) { c += h - 1 - y; } else { c += y; } if (sx > 16 && sx < (nScreenWidth - 16) && (sy + (16 * y)) > 16 && (sy + (16 * y)) < (nScreenHeight - 16)) { if (xFlip) { if (yFlip) { Render16x16Tile_Mask_FlipXY(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } else { Render16x16Tile_Mask_FlipX(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } } else { if (yFlip) { Render16x16Tile_Mask_FlipY(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } else { Render16x16Tile_Mask(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } } } else { if (xFlip) { if (yFlip) { Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } else { Render16x16Tile_Mask_FlipX_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } } else { if (yFlip) { Render16x16Tile_Mask_FlipY_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } else { Render16x16Tile_Mask_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites); } } } } } } static void DrvDraw() { BurnTransferClear(); if (DrvRearDisable) { DrvDrawForeground(0, 1); DrvDrawSprites(); DrvDrawForeground(1, 0); } else { DrvRenderBackground(); DrvDrawForeground(0, 0); DrvDrawSprites(); DrvDrawForeground(1, 0); } BurnTransferCopy(DrvPalette); } static void KikcubicDraw() { BurnTransferClear(); for (int Offset = 0; Offset < 0x1000; Offset += 2) { int sy = 8 * ((Offset / 2) / 64); int sx = 8 * ((Offset / 2) % 64); int Attr = DrvVideoRam[Offset + 1]; int Colour = (Attr & 0xf0) >> 4; int Code = DrvVideoRam[Offset] | ((Attr & 0x0f) << 8); sx -= 64; if (sx >= 0 && sx < (nScreenWidth - 8) && sy >= 0 && sy < (nScreenHeight - 8)) { Render8x8Tile(pTransDraw, Code, sx, sy, Colour, 4, 0, DrvChars); } else { Render8x8Tile_Clip(pTransDraw, Code, sx, sy, Colour, 4, 0, DrvChars); } } DrvDrawSprites(); BurnTransferCopy(DrvPalette); } static int DrvFrame() { int nInterleave = nBurnSoundLen; int nFireNmiEveryFrames = 3; if (nBurnSoundRate == 11025) nFireNmiEveryFrames = 2; if (nBurnSoundRate == 44100) nFireNmiEveryFrames = 6; if (nBurnSoundRate == 48000) nFireNmiEveryFrames = 7; int nSoundBufferPos = 0; if (DrvReset) DrvDoReset(); DrvMakeInputs(); nCyclesDone[0] = nCyclesDone[1] = 0; ZetNewFrame(); for (int i = 0; i < nInterleave; i++) { int nCurrentCPU, nNext; // Run Z80 #1 nCurrentCPU = 0; ZetOpen(nCurrentCPU); nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave; nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment); if (i == (nInterleave - 1)) ZetRaiseIrq(0); ZetClose(); // Run Z80 #2 nCurrentCPU = 1; ZetOpen(nCurrentCPU); if (!DrvHasYM2203) { nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave; nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment); } else { BurnTimerUpdate(i * (nCyclesTotal[nCurrentCPU] / nInterleave)); } if ((i % nFireNmiEveryFrames) == 0) { ZetNmi(); } ZetClose(); if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen / nInterleave; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); ZetOpen(1); if (DrvHasYM2203) { BurnYM2203Update(pSoundBuf, nSegmentLength); } else { BurnYM2151Render(pSoundBuf, nSegmentLength); } ZetClose(); DACUpdate(pSoundBuf, nSegmentLength); nSoundBufferPos += nSegmentLength; } } if (DrvHasYM2203) { ZetOpen(1); BurnTimerEndFrame(nCyclesTotal[1]); ZetClose(); } if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen - nSoundBufferPos; if (nSegmentLength) { short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); ZetOpen(1); if (DrvHasYM2203) { BurnYM2203Update(pSoundBuf, nSegmentLength); } else { BurnYM2151Render(pSoundBuf, nSegmentLength); } ZetClose(); DACUpdate(pSoundBuf, nSegmentLength); } } if (pBurnDraw) { if (DrvKikcubicDraw) { KikcubicDraw(); } else { DrvDraw(); } } return 0; } static int DrvScan(int nAction, int *pnMin) { struct BurnArea ba; if (pnMin != NULL) { // Return minimum compatible version *pnMin = 0x029705; } if (nAction & ACB_MEMORY_RAM) { memset(&ba, 0, sizeof(ba)); ba.Data = RamStart; ba.nLen = RamEnd-RamStart; ba.szName = "All Ram"; BurnAcb(&ba); } if (nAction & ACB_DRIVER_DATA) { ZetScan(nAction); if (DrvHasYM2203) { BurnYM2203Scan(nAction, pnMin); } else { BurnYM2151Scan(nAction); } DACScan(nAction, pnMin); // Scan critical driver variables SCAN_VAR(nCyclesDone); SCAN_VAR(nCyclesSegment); SCAN_VAR(DrvRomBank); SCAN_VAR(DrvSoundLatch); SCAN_VAR(DrvDip); SCAN_VAR(DrvInput); SCAN_VAR(DrvIrqVector); SCAN_VAR(DrvRearColour); SCAN_VAR(DrvRearDisable); SCAN_VAR(DrvHorizScrollLo); SCAN_VAR(DrvHorizScrollHi); SCAN_VAR(DrvRearHorizScrollLo); SCAN_VAR(DrvRearHorizScrollHi); SCAN_VAR(DrvSampleAddress); } if (nAction & ACB_WRITE) { ZetOpen(0); ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000)); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000)); ZetClose(); } return 0; } #undef VECTOR_INIT #undef YM2151_ASSERT #undef YM2151_CLEAR #undef Z80_ASSERT #undef Z80_CLEAR struct BurnDriver BurnDrvVigilant = { "vigilant", NULL, NULL, "1988", "Vigilante (World)\0", NULL, "Irem", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_MISC_MISC, NULL, DrvRomInfo, DrvRomName, DrvInputInfo, DrvDIPInfo, DrvInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 256, 256, 4, 3 }; struct BurnDriver BurnDrvVigilantu = { "vigilantu", "vigilant", NULL, "1988", "Vigilante (US)\0", NULL, "Irem (Data East USA License)", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, DrvuRomInfo, DrvuRomName, DrvInputInfo, DrvDIPInfo, DrvInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 256, 256, 4, 3 }; struct BurnDriver BurnDrvVigilantj = { "vigilantj", "vigilant", NULL, "1988", "Vigilante (Japan)\0", NULL, "Irem", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, DrvjRomInfo, DrvjRomName, DrvInputInfo, DrvDIPInfo, DrvInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 256, 256, 4, 3 }; struct BurnDriver BurnDrvKikcubic = { "kikcubic", NULL, NULL, "1988", "Meikyu Jima (Japan)\0", NULL, "Irem", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_MISC_MISC, NULL, KikcubicRomInfo, KikcubicRomName, KikcubicInputInfo, KikcubicDIPInfo, KikcubicInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 384, 256, 4, 3 }; struct BurnDriver BurnDrvKikcubicb = { "kikcubicb", "kikcubic", NULL, "1988", "Kickle Cubele\0", NULL, "bootleg", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_MISC_MISC, NULL, KikcubicbRomInfo, KikcubicbRomName, KikcubicInputInfo, KikcubicDIPInfo, KikcubicInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 384, 256, 4, 3 }; struct BurnDriver BurnDrvBuccanrs = { "buccanrs", NULL, NULL, "1989", "Buccaneers (set 1)\0", "No sound", "Duintronic", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_MISC_MISC, NULL, BuccanrsRomInfo, BuccanrsRomName, BuccanrsInputInfo, BuccanrsDIPInfo, BuccanrsInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 256, 256, 4, 3 }; struct BurnDriver BurnDrvBuccanrsa = { "buccanrsa", "buccanrs", NULL, "1989", "Buccaneers (set 2)\0", "No sound", "Duintronic", "Miscellaneous", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, BuccanrsaRomInfo, BuccanrsaRomName, BuccanrsaInputInfo, BuccanrsaDIPInfo, BuccanrsInit, DrvExit, DrvFrame, NULL, DrvScan, NULL, 256, 256, 4, 3 };
[ [ [ 1, 2089 ] ] ]