1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "tools/toolsdllapi.h"
23 #include "sal/config.h"
24 #include "sal/types.h"
25 #include <tools/solar.h>
27 typedef long (*PSTUB
)( void*, void* );
29 #define DECL_LINK( Method, ArgType ) \
30 long Method( ArgType ); \
31 static long LinkStub##Method( void* pThis, void* )
33 #define DECL_STATIC_LINK( Class, Method, ArgType ) \
34 static long Method( Class*, ArgType )
36 #define DECL_DLLPRIVATE_LINK(Method, ArgType) \
37 SAL_DLLPRIVATE long Method(ArgType); \
38 SAL_DLLPRIVATE static long LinkStub##Method(void * pThis, void *)
40 #define DECL_DLLPRIVATE_STATIC_LINK(Class, Method, ArgType) \
41 SAL_DLLPRIVATE static long Method(Class *, ArgType)
43 #define IMPL_STUB(Class, Method, ArgType) \
44 long Class::LinkStub##Method( void* pThis, void* pCaller) \
46 return ((Class*)pThis )->Method( (ArgType)pCaller ); \
49 #define IMPL_STATIC_LINK( Class, Method, ArgType, ArgName ) \
50 long Class::Method( Class* pThis, ArgType ArgName )
52 #define IMPL_STATIC_LINK_NOINSTANCE( Class, Method, ArgType, ArgName ) \
53 long Class::Method( SAL_UNUSED_PARAMETER Class*, ArgType ArgName )
55 #define LINK( Inst, Class, Member ) \
56 Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member )
58 #define STATIC_LINK( Inst, Class, Member ) \
59 Link( (Class*)Inst, (PSTUB)&Class::Member )
61 #define IMPL_LINK( Class, Method, ArgType, ArgName ) \
62 IMPL_STUB( Class, Method, ArgType ) \
63 long Class::Method( ArgType ArgName )
65 #define IMPL_LINK_NOARG( Class, Method ) \
66 IMPL_STUB( Class, Method, void* ) \
67 long Class::Method( SAL_UNUSED_PARAMETER void* )
69 #define IMPL_LINK_INLINE_START( Class, Method, ArgType, ArgName ) \
70 inline long Class::Method( ArgType ArgName )
72 #define IMPL_LINK_INLINE_END( Class, Method, ArgType, ArgName ) \
73 IMPL_STUB( Class, Method, ArgType )
75 #define IMPL_LINK_NOARG_INLINE_START( Class, Method ) \
76 inline long Class::Method( SAL_UNUSED_PARAMETER void* )
78 #define IMPL_LINK_NOARG_INLINE_END( Class, Method ) \
79 IMPL_STUB( Class, Method, void* )
81 #define IMPL_LINK_INLINE( Class, Method, ArgType, ArgName, Body ) \
82 long Class::Method( ArgType ArgName ) \
84 IMPL_STUB( Class, Method, ArgType )
88 class TOOLS_DLLPUBLIC Link
95 Link( void* pLinkHdl
, PSTUB pMemFunc
);
97 long Call( void* pCaller
) const;
99 sal_Bool
IsSet() const;
100 sal_Bool
operator !() const;
102 sal_Bool
operator==( const Link
& rLink
) const;
103 sal_Bool
operator!=( const Link
& rLink
) const
104 { return !(Link::operator==( rLink
)); }
105 sal_Bool
operator<( const Link
& rLink
) const
106 { return ((sal_uIntPtr
)rLink
.pFunc
< (sal_uIntPtr
)pFunc
); }
115 inline Link::Link( void* pLinkHdl
, PSTUB pMemFunc
)
121 inline long Link::Call(void *pCaller
) const
123 return pFunc
? (*pFunc
)(pInst
, pCaller
) : 0;
126 inline sal_Bool
Link::IsSet() const
134 inline sal_Bool
Link::operator !() const
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */