Kaydet (Commit) 90067e80 authored tarafından Michael Meeks's avatar Michael Meeks

gtk3: cleanup some code inclusion, and share timeval operators

üst 306c79e2
...@@ -80,6 +80,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_svp,\ ...@@ -80,6 +80,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_svp,\
vcl/headless/svpframe \ vcl/headless/svpframe \
vcl/headless/svpgdi \ vcl/headless/svpgdi \
vcl/headless/svpinst \ vcl/headless/svpinst \
vcl/headless/svpdata \
vcl/headless/svpprn \ vcl/headless/svpprn \
vcl/headless/svppspgraphics \ vcl/headless/svppspgraphics \
vcl/headless/svptext \ vcl/headless/svptext \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2011 Novell, Inc.
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include <generic/gendata.hxx>
#include <headless/svpinst.hxx>
class SvpSalData : public SalGenericData
{
public:
SvpSalData( SalInstance *pInstance ) : SalGenericData( SAL_DATA_SVP, pInstance ) {}
virtual void ErrorTrapPush() {}
virtual bool ErrorTrapPop( bool ) { return false; }
};
// plugin factory function
extern "C"
{
SAL_DLLPUBLIC_EXPORT SalInstance* create_SalInstance()
{
SvpSalInstance* pInstance = new SvpSalInstance( new SalYieldMutex() );
new SvpSalData( pInstance );
return pInstance;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -45,28 +45,8 @@ ...@@ -45,28 +45,8 @@
#include <svdata.hxx> #include <svdata.hxx>
#include <generic/gendata.hxx> #include <generic/gendata.hxx>
#include <vcl/solarmutex.hxx> #include <vcl/solarmutex.hxx>
// FIXME: remove when we re-work the svp mainloop
// FIXME: split off into a separate, standalone module to aid linking #include <unx/salunxtime.h>
#ifndef GTK3_INCLUDED
class SvpSalData : public SalGenericData
{
public:
SvpSalData( SalInstance *pInstance ) : SalGenericData( SAL_DATA_SVP, pInstance ) { }
virtual void ErrorTrapPush() {}
virtual bool ErrorTrapPop( bool ) { return false; }
};
// plugin factory function
extern "C"
{
SAL_DLLPUBLIC_EXPORT SalInstance* create_SalInstance()
{
SvpSalInstance* pInstance = new SvpSalInstance( new SalYieldMutex() );
new SvpSalData( pInstance );
return pInstance;
}
}
#endif
bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const
{ {
...@@ -198,34 +178,6 @@ void SvpSalInstance::Wakeup() ...@@ -198,34 +178,6 @@ void SvpSalInstance::Wakeup()
OSL_VERIFY(write (m_pTimeoutFDS[1], "", 1) == 1); OSL_VERIFY(write (m_pTimeoutFDS[1], "", 1) == 1);
} }
// FIXME: share this with unx/generic [!] ....
#ifndef GTK3_INCLUDED
// -=-= timeval =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
inline int operator >= ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec >= t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
inline timeval &operator += ( timeval &t1, sal_uLong t2 )
{
t1.tv_sec += t2 / 1000;
t1.tv_usec += t2 ? (t2 % 1000) * 1000 : 500;
if( t1.tv_usec > 1000000 )
{
t1.tv_sec++;
t1.tv_usec -= 1000000;
}
return t1;
}
inline int operator > ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec > t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
#endif
bool SvpSalInstance::CheckTimeout( bool bExecuteTimers ) bool SvpSalInstance::CheckTimeout( bool bExecuteTimers )
{ {
bool bRet = false; bool bRet = false;
......
...@@ -71,7 +71,7 @@ class GenPspGraphics; ...@@ -71,7 +71,7 @@ class GenPspGraphics;
class SvpSalInstance : public SalGenericInstance class SvpSalInstance : public SalGenericInstance
{ {
timeval m_aTimeout; timeval m_aTimeout;
sal_uLong m_nTimeoutMS; sal_uLong m_nTimeoutMS;
int m_pTimeoutFDS[2]; int m_pTimeoutFDS[2];
// internal event queue // internal event queue
......
...@@ -29,15 +29,7 @@ ...@@ -29,15 +29,7 @@
#ifndef _SALUNX_H #ifndef _SALUNX_H
#define _SALUNX_H #define _SALUNX_H
// -=-= #includes =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include "unx/salunxtime.h"
#if defined LINUX || defined FREEBSD || \
defined NETBSD || defined OPENBSD || defined DRAGONFLY
#include <sys/time.h>
#elif defined AIX
#include <time.h>
#include <sys/time.h>
#include <strings.h>
#endif
#include <unx/svunx.h> #include <unx/svunx.h>
#include <unx/salstd.hxx> #include <unx/salstd.hxx>
...@@ -51,81 +43,6 @@ inline long Divide( long nDividend, long nDivisor ) ...@@ -51,81 +43,6 @@ inline long Divide( long nDividend, long nDivisor )
inline long DPI( long pixel, long mm ) inline long DPI( long pixel, long mm )
{ return Divide( pixel*254, mm*10 ); } { return Divide( pixel*254, mm*10 ); }
// -=-= timeval =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
inline int operator >= ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec >= t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
inline int operator > ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec > t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
inline int operator == ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec == t2.tv_usec;
return sal_False;
}
inline timeval &operator -= ( timeval &t1, const timeval &t2 )
{
if( t1.tv_usec < t2.tv_usec )
{
t1.tv_sec--;
t1.tv_usec += 1000000;
}
t1.tv_sec -= t2.tv_sec;
t1.tv_usec -= t2.tv_usec;
return t1;
}
inline timeval &operator += ( timeval &t1, const timeval &t2 )
{
t1.tv_sec += t2.tv_sec;
t1.tv_usec += t2.tv_usec;
if( t1.tv_usec > 1000000 )
{
t1.tv_sec++;
t1.tv_usec -= 1000000;
}
return t1;
}
inline timeval &operator += ( timeval &t1, sal_uIntPtr t2 )
{
t1.tv_sec += t2 / 1000;
t1.tv_usec += t2 ? (t2 % 1000) * 1000 : 500;
if( t1.tv_usec > 1000000 )
{
t1.tv_sec++;
t1.tv_usec -= 1000000;
}
return t1;
}
inline timeval operator + ( const timeval &t1, const timeval &t2 )
{
timeval t0 = t1;
return t0 += t2;
}
inline timeval operator + ( const timeval &t1, sal_uIntPtr t2 )
{
timeval t0 = t1;
return t0 += t2;
}
inline timeval operator - ( const timeval &t1, const timeval &t2 )
{
timeval t0 = t1;
return t0 -= t2;
}
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SALUNX_TIME_H
#define _SALUNX_TIME_H
#if defined LINUX || defined FREEBSD || \
defined NETBSD || defined OPENBSD || defined DRAGONFLY
#include <sys/time.h>
#elif defined AIX
#include <time.h>
#include <sys/time.h>
#include <strings.h>
#endif
#include <sal/types.h>
// -=-= timeval =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
inline int operator >= ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec >= t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
inline int operator > ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec > t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
inline int operator == ( const timeval &t1, const timeval &t2 )
{
if( t1.tv_sec == t2.tv_sec )
return t1.tv_usec == t2.tv_usec;
return sal_False;
}
inline timeval &operator -= ( timeval &t1, const timeval &t2 )
{
if( t1.tv_usec < t2.tv_usec )
{
t1.tv_sec--;
t1.tv_usec += 1000000;
}
t1.tv_sec -= t2.tv_sec;
t1.tv_usec -= t2.tv_usec;
return t1;
}
inline timeval &operator += ( timeval &t1, const timeval &t2 )
{
t1.tv_sec += t2.tv_sec;
t1.tv_usec += t2.tv_usec;
if( t1.tv_usec > 1000000 )
{
t1.tv_sec++;
t1.tv_usec -= 1000000;
}
return t1;
}
inline timeval &operator += ( timeval &t1, sal_uIntPtr t2 )
{
t1.tv_sec += t2 / 1000;
t1.tv_usec += t2 ? (t2 % 1000) * 1000 : 500;
if( t1.tv_usec > 1000000 )
{
t1.tv_sec++;
t1.tv_usec -= 1000000;
}
return t1;
}
inline timeval operator + ( const timeval &t1, const timeval &t2 )
{
timeval t0 = t1;
return t0 += t2;
}
inline timeval operator + ( const timeval &t1, sal_uIntPtr t2 )
{
timeval t0 = t1;
return t0 += t2;
}
inline timeval operator - ( const timeval &t1, const timeval &t2 )
{
timeval t0 = t1;
return t0 -= t2;
}
#endif // _SALUNX_TIME_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -620,7 +620,6 @@ GenPspGraphics *GtkInstance::CreatePrintGraphics() ...@@ -620,7 +620,6 @@ GenPspGraphics *GtkInstance::CreatePrintGraphics()
} }
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
#define GTK3_INCLUDED
#include "../../headless/svpinst.cxx" #include "../../headless/svpinst.cxx"
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment