mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-18 14:22:34 -06:00
removed archive
This commit is contained in:
parent
3101422b9c
commit
db06207cae
709 changed files with 0 additions and 95973 deletions
|
|
@ -1,32 +0,0 @@
|
|||
description "Simple example of ActiveX control\377";
|
||||
|
||||
noblitz;
|
||||
|
||||
uses
|
||||
Ole\Ctrl,
|
||||
CtrlLib,
|
||||
Esc;
|
||||
|
||||
target
|
||||
calc.ocx;
|
||||
|
||||
link
|
||||
/def:calc.def;
|
||||
|
||||
file
|
||||
calc.idl,
|
||||
calc_idl.h,
|
||||
calc.cpp,
|
||||
calc_idl.cpp,
|
||||
calc.lay,
|
||||
calc.def,
|
||||
calc.rc
|
||||
depends() calc.tlb;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI DLL MT";
|
||||
|
||||
custom() "post-link",
|
||||
"regsvr32 /s /c $(OUTPATH)",
|
||||
"";
|
||||
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#include <Ole/Ctrl/OleCtrl.h>
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <Esc/Esc.h>
|
||||
|
||||
#include "calc_idl.h"
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE "calc.lay"
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
class Calculator : public WithCalculatorLayout<OcxRunnableControl>, public DispatchInterface<ICalculator> {
|
||||
void Eval();
|
||||
|
||||
public:
|
||||
virtual void Paint(UPP::Draw& w);
|
||||
|
||||
STDMETHOD(get_Input)(BSTR *result);
|
||||
STDMETHOD(put_Input)(BSTR input);
|
||||
STDMETHOD(Calculate)();
|
||||
STDMETHOD(get_Output)(BSTR *result);
|
||||
|
||||
typedef Calculator CLASSNAME;
|
||||
Calculator();
|
||||
};
|
||||
|
||||
OCX_OBJECT(Calculator)
|
||||
|
||||
void Calculator::Paint(UPP::Draw& w)
|
||||
{
|
||||
w.DrawRect(GetSize(), SColorFace());
|
||||
}
|
||||
|
||||
Calculator::Calculator()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
ok.Ok() <<= THISBACK(Eval);
|
||||
ok.Tip("Evaluate given expression");
|
||||
NoWantFocus();
|
||||
}
|
||||
|
||||
void Calculator::Eval()
|
||||
{
|
||||
ArrayMap<String, EscValue> global;
|
||||
value <<= Evaluate((String)~expr, global).ToString();
|
||||
}
|
||||
|
||||
HRESULT Calculator::get_Input(BSTR *result)
|
||||
{
|
||||
ReturnString(result, ~expr);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Calculator::put_Input(BSTR input)
|
||||
{
|
||||
expr <<= BSTRToString(input);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Calculator::Calculate()
|
||||
{
|
||||
Eval();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Calculator::get_Output(BSTR *result)
|
||||
{
|
||||
ReturnString(result, ~value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
OCX_APP_MAIN
|
||||
{
|
||||
SetLanguage(LNG_CZECH);
|
||||
SetDefaultCharset(CHARSET_WIN1250);
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
LIBRARY "OleCalc.dll"
|
||||
|
||||
EXPORTS
|
||||
DllCanUnloadNow PRIVATE
|
||||
DllGetClassObject PRIVATE
|
||||
DllRegisterServer PRIVATE
|
||||
DllUnregisterServer PRIVATE
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// calculator.idl: simple OCX expression evaluator.
|
||||
|
||||
import "oaidl.idl";
|
||||
import "oleidl.idl";
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(2CFA5DB2-A740-11d3-981C-000000000000),
|
||||
dual,
|
||||
helpstring("ICalculator Interface")
|
||||
]
|
||||
interface ICalculator : IDispatch
|
||||
{
|
||||
[id(1), propget, helpstring("Returns and sets calculator input field text (expression).")]
|
||||
HRESULT Input([out, retval] BSTR *_value);
|
||||
[propput, helpstring("Put")]
|
||||
HRESULT Input([in] BSTR _value);
|
||||
[id(2), helpstring("Calculate computes the result and places the it in the history list.")]
|
||||
HRESULT Calculate();
|
||||
[id(3), propget, helpstring("Value retrieves the result of the computation.")]
|
||||
HRESULT Output([out, retval] BSTR *value);
|
||||
};
|
||||
|
||||
[
|
||||
uuid(2CFA5DB0-A740-11d3-981C-000000000000),
|
||||
version(1.0),
|
||||
helpstring("Ultimate Calculator 1.0 Type Library")
|
||||
]
|
||||
library Calculator_TypeLib
|
||||
{
|
||||
importlib("stdole32.tlb");
|
||||
|
||||
[
|
||||
uuid(2CFA5DB1-A740-11d3-981C-000000000000),
|
||||
helpstring("Calculator Control")
|
||||
]
|
||||
coclass Calculator
|
||||
{
|
||||
[default] interface ICalculator;
|
||||
};
|
||||
};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
LAYOUT(CalculatorLayout, 376, 56)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Expression")).LeftPosZ(4, 56).TopPosZ(4, 19))
|
||||
ITEM(EditField, expr, HSizePosZ(64, 4).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Value:")).LeftPosZ(112, 56).TopPosZ(28, 16))
|
||||
ITEM(EditField, value, HSizePosZ(168, 4).TopPosZ(26, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("Evaluate")).LeftPosZ(4, 80).TopPosZ(28, 22))
|
||||
END_LAYOUT
|
||||
|
|
@ -1 +0,0 @@
|
|||
1 TYPELIB "calc.idl"
|
||||
|
|
@ -1 +0,0 @@
|
|||
MSFT
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
|
||||
|
||||
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
|
||||
|
||||
/* link this file in with the server and any clients */
|
||||
|
||||
|
||||
/* File created by MIDL compiler version 6.00.0361 */
|
||||
/* at Thu Jan 24 22:09:58 2008
|
||||
*/
|
||||
/* Compiler settings for d:\examples\OleCalc\calc.idl:
|
||||
Oicf, W1, Zp8, env=Win32 (32b run)
|
||||
protocol : dce , ms_ext, c_ext, robust
|
||||
error checks: allocation ref bounds_check enum stub_data
|
||||
VC __declspec() decoration level:
|
||||
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||
*/
|
||||
//@@MIDL_FILE_HEADING( )
|
||||
|
||||
#if !defined(_M_IA64) && !defined(_M_AMD64)
|
||||
|
||||
|
||||
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
|
||||
#include <rpc.h>
|
||||
#include <rpcndr.h>
|
||||
|
||||
#ifdef _MIDL_USE_GUIDDEF_
|
||||
|
||||
#ifndef INITGUID
|
||||
#define INITGUID
|
||||
#include <guiddef.h>
|
||||
#undef INITGUID
|
||||
#else
|
||||
#include <guiddef.h>
|
||||
#endif
|
||||
|
||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
|
||||
|
||||
#else // !_MIDL_USE_GUIDDEF_
|
||||
|
||||
#ifndef __IID_DEFINED__
|
||||
#define __IID_DEFINED__
|
||||
|
||||
typedef struct _IID
|
||||
{
|
||||
unsigned long x;
|
||||
unsigned short s1;
|
||||
unsigned short s2;
|
||||
unsigned char c[8];
|
||||
} IID;
|
||||
|
||||
#endif // __IID_DEFINED__
|
||||
|
||||
#ifndef CLSID_DEFINED
|
||||
#define CLSID_DEFINED
|
||||
typedef IID CLSID;
|
||||
#endif // CLSID_DEFINED
|
||||
|
||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
|
||||
|
||||
#endif
|
||||
|
||||
MIDL_DEFINE_GUID(IID, IID_ICalculator,0x2CFA5DB2,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
|
||||
MIDL_DEFINE_GUID(IID, LIBID_Calculator_TypeLib,0x2CFA5DB0,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
|
||||
MIDL_DEFINE_GUID(CLSID, CLSID_Calculator,0x2CFA5DB1,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
#undef MIDL_DEFINE_GUID
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/
|
||||
|
||||
|
||||
|
||||
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
|
||||
|
||||
/* link this file in with the server and any clients */
|
||||
|
||||
|
||||
/* File created by MIDL compiler version 6.00.0361 */
|
||||
/* at Thu Jan 24 22:09:58 2008
|
||||
*/
|
||||
/* Compiler settings for d:\examples\OleCalc\calc.idl:
|
||||
Oicf, W1, Zp8, env=Win64 (32b run,appending)
|
||||
protocol : dce , ms_ext, c_ext, robust
|
||||
error checks: allocation ref bounds_check enum stub_data
|
||||
VC __declspec() decoration level:
|
||||
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||
*/
|
||||
//@@MIDL_FILE_HEADING( )
|
||||
|
||||
#if defined(_M_IA64) || defined(_M_AMD64)
|
||||
|
||||
|
||||
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
|
||||
#include <rpc.h>
|
||||
#include <rpcndr.h>
|
||||
|
||||
#ifdef _MIDL_USE_GUIDDEF_
|
||||
|
||||
#ifndef INITGUID
|
||||
#define INITGUID
|
||||
#include <guiddef.h>
|
||||
#undef INITGUID
|
||||
#else
|
||||
#include <guiddef.h>
|
||||
#endif
|
||||
|
||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
|
||||
|
||||
#else // !_MIDL_USE_GUIDDEF_
|
||||
|
||||
#ifndef __IID_DEFINED__
|
||||
#define __IID_DEFINED__
|
||||
|
||||
typedef struct _IID
|
||||
{
|
||||
unsigned long x;
|
||||
unsigned short s1;
|
||||
unsigned short s2;
|
||||
unsigned char c[8];
|
||||
} IID;
|
||||
|
||||
#endif // __IID_DEFINED__
|
||||
|
||||
#ifndef CLSID_DEFINED
|
||||
#define CLSID_DEFINED
|
||||
typedef IID CLSID;
|
||||
#endif // CLSID_DEFINED
|
||||
|
||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
|
||||
|
||||
#endif
|
||||
|
||||
MIDL_DEFINE_GUID(IID, IID_ICalculator,0x2CFA5DB2,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
|
||||
MIDL_DEFINE_GUID(IID, LIBID_Calculator_TypeLib,0x2CFA5DB0,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
|
||||
MIDL_DEFINE_GUID(CLSID, CLSID_Calculator,0x2CFA5DB1,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
#undef MIDL_DEFINE_GUID
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* defined(_M_IA64) || defined(_M_AMD64)*/
|
||||
|
|
@ -1,304 +0,0 @@
|
|||
|
||||
|
||||
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
|
||||
|
||||
|
||||
/* File created by MIDL compiler version 6.00.0366 */
|
||||
/* at Thu Jan 24 22:57:13 2008
|
||||
*/
|
||||
/* Compiler settings for C:\Upp.uvs\examples.uc\OleCalc\calc.idl:
|
||||
Oicf, W1, Zp8, env=Win32 (32b run)
|
||||
protocol : dce , ms_ext, c_ext, robust
|
||||
error checks: allocation ref bounds_check enum stub_data
|
||||
VC __declspec() decoration level:
|
||||
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||
*/
|
||||
//@@MIDL_FILE_HEADING( )
|
||||
|
||||
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||
|
||||
|
||||
/* verify that the <rpcndr.h> version is high enough to compile this file*/
|
||||
#ifndef __REQUIRED_RPCNDR_H_VERSION__
|
||||
#define __REQUIRED_RPCNDR_H_VERSION__ 475
|
||||
#endif
|
||||
|
||||
#include "rpc.h"
|
||||
#include "rpcndr.h"
|
||||
|
||||
#ifndef __RPCNDR_H_VERSION__
|
||||
#error this stub requires an updated version of <rpcndr.h>
|
||||
#endif // __RPCNDR_H_VERSION__
|
||||
|
||||
#ifndef COM_NO_WINDOWS_H
|
||||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#endif /*COM_NO_WINDOWS_H*/
|
||||
|
||||
#ifndef __calc_idl_h__
|
||||
#define __calc_idl_h__
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
/* Forward Declarations */
|
||||
|
||||
#ifndef __ICalculator_FWD_DEFINED__
|
||||
#define __ICalculator_FWD_DEFINED__
|
||||
typedef interface ICalculator ICalculator;
|
||||
#endif /* __ICalculator_FWD_DEFINED__ */
|
||||
|
||||
|
||||
#ifndef __Calculator_FWD_DEFINED__
|
||||
#define __Calculator_FWD_DEFINED__
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef class Calculator Calculator;
|
||||
#else
|
||||
typedef struct Calculator Calculator;
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __Calculator_FWD_DEFINED__ */
|
||||
|
||||
|
||||
/* header files for imported files */
|
||||
#include "oaidl.h"
|
||||
#include "oleidl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void * __RPC_USER MIDL_user_allocate(size_t);
|
||||
void __RPC_USER MIDL_user_free( void * );
|
||||
|
||||
#ifndef __ICalculator_INTERFACE_DEFINED__
|
||||
#define __ICalculator_INTERFACE_DEFINED__
|
||||
|
||||
/* interface ICalculator */
|
||||
/* [helpstring][dual][uuid][object] */
|
||||
|
||||
|
||||
EXTERN_C const IID IID_ICalculator;
|
||||
|
||||
#if defined(__cplusplus) && !defined(CINTERFACE)
|
||||
|
||||
MIDL_INTERFACE("2CFA5DB2-A740-11d3-981C-000000000000")
|
||||
ICalculator : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Input(
|
||||
/* [retval][out] */ BSTR *_value) = 0;
|
||||
|
||||
virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_Input(
|
||||
/* [in] */ BSTR _value) = 0;
|
||||
|
||||
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Calculate( void) = 0;
|
||||
|
||||
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Output(
|
||||
/* [retval][out] */ BSTR *value) = 0;
|
||||
|
||||
};
|
||||
|
||||
#else /* C style interface */
|
||||
|
||||
typedef struct ICalculatorVtbl
|
||||
{
|
||||
BEGIN_INTERFACE
|
||||
|
||||
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
|
||||
ICalculator * This,
|
||||
/* [in] */ REFIID riid,
|
||||
/* [iid_is][out] */ void **ppvObject);
|
||||
|
||||
ULONG ( STDMETHODCALLTYPE *AddRef )(
|
||||
ICalculator * This);
|
||||
|
||||
ULONG ( STDMETHODCALLTYPE *Release )(
|
||||
ICalculator * This);
|
||||
|
||||
HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(
|
||||
ICalculator * This,
|
||||
/* [out] */ UINT *pctinfo);
|
||||
|
||||
HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(
|
||||
ICalculator * This,
|
||||
/* [in] */ UINT iTInfo,
|
||||
/* [in] */ LCID lcid,
|
||||
/* [out] */ ITypeInfo **ppTInfo);
|
||||
|
||||
HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(
|
||||
ICalculator * This,
|
||||
/* [in] */ REFIID riid,
|
||||
/* [size_is][in] */ LPOLESTR *rgszNames,
|
||||
/* [in] */ UINT cNames,
|
||||
/* [in] */ LCID lcid,
|
||||
/* [size_is][out] */ DISPID *rgDispId);
|
||||
|
||||
/* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(
|
||||
ICalculator * This,
|
||||
/* [in] */ DISPID dispIdMember,
|
||||
/* [in] */ REFIID riid,
|
||||
/* [in] */ LCID lcid,
|
||||
/* [in] */ WORD wFlags,
|
||||
/* [out][in] */ DISPPARAMS *pDispParams,
|
||||
/* [out] */ VARIANT *pVarResult,
|
||||
/* [out] */ EXCEPINFO *pExcepInfo,
|
||||
/* [out] */ UINT *puArgErr);
|
||||
|
||||
/* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Input )(
|
||||
ICalculator * This,
|
||||
/* [retval][out] */ BSTR *_value);
|
||||
|
||||
/* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Input )(
|
||||
ICalculator * This,
|
||||
/* [in] */ BSTR _value);
|
||||
|
||||
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *Calculate )(
|
||||
ICalculator * This);
|
||||
|
||||
/* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Output )(
|
||||
ICalculator * This,
|
||||
/* [retval][out] */ BSTR *value);
|
||||
|
||||
END_INTERFACE
|
||||
} ICalculatorVtbl;
|
||||
|
||||
interface ICalculator
|
||||
{
|
||||
CONST_VTBL struct ICalculatorVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef COBJMACROS
|
||||
|
||||
|
||||
#define ICalculator_QueryInterface(This,riid,ppvObject) \
|
||||
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
|
||||
|
||||
#define ICalculator_AddRef(This) \
|
||||
(This)->lpVtbl -> AddRef(This)
|
||||
|
||||
#define ICalculator_Release(This) \
|
||||
(This)->lpVtbl -> Release(This)
|
||||
|
||||
|
||||
#define ICalculator_GetTypeInfoCount(This,pctinfo) \
|
||||
(This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
|
||||
|
||||
#define ICalculator_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
|
||||
(This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
|
||||
|
||||
#define ICalculator_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
|
||||
(This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
|
||||
|
||||
#define ICalculator_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
|
||||
(This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
|
||||
|
||||
|
||||
#define ICalculator_get_Input(This,_value) \
|
||||
(This)->lpVtbl -> get_Input(This,_value)
|
||||
|
||||
#define ICalculator_put_Input(This,_value) \
|
||||
(This)->lpVtbl -> put_Input(This,_value)
|
||||
|
||||
#define ICalculator_Calculate(This) \
|
||||
(This)->lpVtbl -> Calculate(This)
|
||||
|
||||
#define ICalculator_get_Output(This,value) \
|
||||
(This)->lpVtbl -> get_Output(This,value)
|
||||
|
||||
#endif /* COBJMACROS */
|
||||
|
||||
|
||||
#endif /* C style interface */
|
||||
|
||||
|
||||
|
||||
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE ICalculator_get_Input_Proxy(
|
||||
ICalculator * This,
|
||||
/* [retval][out] */ BSTR *_value);
|
||||
|
||||
|
||||
void __RPC_STUB ICalculator_get_Input_Stub(
|
||||
IRpcStubBuffer *This,
|
||||
IRpcChannelBuffer *_pRpcChannelBuffer,
|
||||
PRPC_MESSAGE _pRpcMessage,
|
||||
DWORD *_pdwStubPhase);
|
||||
|
||||
|
||||
/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE ICalculator_put_Input_Proxy(
|
||||
ICalculator * This,
|
||||
/* [in] */ BSTR _value);
|
||||
|
||||
|
||||
void __RPC_STUB ICalculator_put_Input_Stub(
|
||||
IRpcStubBuffer *This,
|
||||
IRpcChannelBuffer *_pRpcChannelBuffer,
|
||||
PRPC_MESSAGE _pRpcMessage,
|
||||
DWORD *_pdwStubPhase);
|
||||
|
||||
|
||||
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICalculator_Calculate_Proxy(
|
||||
ICalculator * This);
|
||||
|
||||
|
||||
void __RPC_STUB ICalculator_Calculate_Stub(
|
||||
IRpcStubBuffer *This,
|
||||
IRpcChannelBuffer *_pRpcChannelBuffer,
|
||||
PRPC_MESSAGE _pRpcMessage,
|
||||
DWORD *_pdwStubPhase);
|
||||
|
||||
|
||||
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE ICalculator_get_Output_Proxy(
|
||||
ICalculator * This,
|
||||
/* [retval][out] */ BSTR *value);
|
||||
|
||||
|
||||
void __RPC_STUB ICalculator_get_Output_Stub(
|
||||
IRpcStubBuffer *This,
|
||||
IRpcChannelBuffer *_pRpcChannelBuffer,
|
||||
PRPC_MESSAGE _pRpcMessage,
|
||||
DWORD *_pdwStubPhase);
|
||||
|
||||
|
||||
|
||||
#endif /* __ICalculator_INTERFACE_DEFINED__ */
|
||||
|
||||
|
||||
|
||||
#ifndef __Calculator_TypeLib_LIBRARY_DEFINED__
|
||||
#define __Calculator_TypeLib_LIBRARY_DEFINED__
|
||||
|
||||
/* library Calculator_TypeLib */
|
||||
/* [helpstring][version][uuid] */
|
||||
|
||||
|
||||
EXTERN_C const IID LIBID_Calculator_TypeLib;
|
||||
|
||||
EXTERN_C const CLSID CLSID_Calculator;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class DECLSPEC_UUID("2CFA5DB1-A740-11d3-981C-000000000000")
|
||||
Calculator;
|
||||
#endif
|
||||
#endif /* __Calculator_TypeLib_LIBRARY_DEFINED__ */
|
||||
|
||||
/* Additional Prototypes for ALL interfaces */
|
||||
|
||||
unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * );
|
||||
unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * );
|
||||
unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * );
|
||||
void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * );
|
||||
|
||||
/* end of Additional Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,889 +0,0 @@
|
|||
|
||||
|
||||
/* this ALWAYS GENERATED file contains the proxy stub code */
|
||||
|
||||
|
||||
/* File created by MIDL compiler version 6.00.0361 */
|
||||
/* at Thu Jan 24 22:09:58 2008
|
||||
*/
|
||||
/* Compiler settings for d:\examples\OleCalc\calc.idl:
|
||||
Oicf, W1, Zp8, env=Win32 (32b run)
|
||||
protocol : dce , ms_ext, c_ext, robust
|
||||
error checks: allocation ref bounds_check enum stub_data
|
||||
VC __declspec() decoration level:
|
||||
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||
*/
|
||||
//@@MIDL_FILE_HEADING( )
|
||||
|
||||
#if !defined(_M_IA64) && !defined(_M_AMD64)
|
||||
|
||||
|
||||
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||
#if _MSC_VER >= 1200
|
||||
#pragma warning(push)
|
||||
#endif
|
||||
#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */
|
||||
#pragma warning( disable: 4211 ) /* redefine extent to static */
|
||||
#pragma warning( disable: 4232 ) /* dllimport identity*/
|
||||
#define USE_STUBLESS_PROXY
|
||||
|
||||
|
||||
/* verify that the <rpcproxy.h> version is high enough to compile this file*/
|
||||
#ifndef __REDQ_RPCPROXY_H_VERSION__
|
||||
#define __REQUIRED_RPCPROXY_H_VERSION__ 475
|
||||
#endif
|
||||
|
||||
|
||||
#include "rpcproxy.h"
|
||||
#ifndef __RPCPROXY_H_VERSION__
|
||||
#error this stub requires an updated version of <rpcproxy.h>
|
||||
#endif // __RPCPROXY_H_VERSION__
|
||||
|
||||
|
||||
#include "calc_idl.h"
|
||||
|
||||
#define TYPE_FORMAT_STRING_SIZE 57
|
||||
#define PROC_FORMAT_STRING_SIZE 139
|
||||
#define TRANSMIT_AS_TABLE_SIZE 0
|
||||
#define WIRE_MARSHAL_TABLE_SIZE 1
|
||||
|
||||
typedef struct _MIDL_TYPE_FORMAT_STRING
|
||||
{
|
||||
short Pad;
|
||||
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
|
||||
} MIDL_TYPE_FORMAT_STRING;
|
||||
|
||||
typedef struct _MIDL_PROC_FORMAT_STRING
|
||||
{
|
||||
short Pad;
|
||||
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
|
||||
} MIDL_PROC_FORMAT_STRING;
|
||||
|
||||
|
||||
static RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax =
|
||||
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};
|
||||
|
||||
|
||||
extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
|
||||
extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
|
||||
|
||||
|
||||
extern const MIDL_STUB_DESC Object_StubDesc;
|
||||
|
||||
|
||||
extern const MIDL_SERVER_INFO ICalculator_ServerInfo;
|
||||
extern const MIDL_STUBLESS_PROXY_INFO ICalculator_ProxyInfo;
|
||||
|
||||
|
||||
extern const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ];
|
||||
|
||||
#if !defined(__RPC_WIN32__)
|
||||
#error Invalid build platform for this stub.
|
||||
#endif
|
||||
|
||||
#if !(TARGET_IS_NT50_OR_LATER)
|
||||
#error You need a Windows 2000 or later to run this stub because it uses these features:
|
||||
#error /robust command line switch.
|
||||
#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
|
||||
#error This app will die there with the RPC_X_WRONG_STUB_VERSION error.
|
||||
#endif
|
||||
|
||||
|
||||
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
|
||||
{
|
||||
0,
|
||||
{
|
||||
|
||||
/* Procedure get_Input */
|
||||
|
||||
0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 6 */ NdrFcShort( 0x7 ), /* 7 */
|
||||
/* 8 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||
/* 10 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 12 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 14 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */
|
||||
0x2, /* 2 */
|
||||
/* 16 */ 0x8, /* 8 */
|
||||
0x3, /* Ext Flags: new corr desc, clt corr check, */
|
||||
/* 18 */ NdrFcShort( 0x1 ), /* 1 */
|
||||
/* 20 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 22 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Parameter _value */
|
||||
|
||||
/* 24 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
|
||||
/* 26 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||
/* 28 */ NdrFcShort( 0x20 ), /* Type Offset=32 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 30 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 32 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
|
||||
/* 34 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
/* Procedure put_Input */
|
||||
|
||||
/* 36 */ 0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 38 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 42 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 44 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||
/* 46 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 48 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 50 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
|
||||
0x2, /* 2 */
|
||||
/* 52 */ 0x8, /* 8 */
|
||||
0x5, /* Ext Flags: new corr desc, srv corr check, */
|
||||
/* 54 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 56 */ NdrFcShort( 0x1 ), /* 1 */
|
||||
/* 58 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Parameter _value */
|
||||
|
||||
/* 60 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
|
||||
/* 62 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||
/* 64 */ NdrFcShort( 0x2e ), /* Type Offset=46 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 66 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 68 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
|
||||
/* 70 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
/* Procedure Calculate */
|
||||
|
||||
/* 72 */ 0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 74 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 78 */ NdrFcShort( 0x9 ), /* 9 */
|
||||
/* 80 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
|
||||
/* 82 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 84 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 86 */ 0x44, /* Oi2 Flags: has return, has ext, */
|
||||
0x1, /* 1 */
|
||||
/* 88 */ 0x8, /* 8 */
|
||||
0x1, /* Ext Flags: new corr desc, */
|
||||
/* 90 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 92 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 94 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 96 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 98 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||
/* 100 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
/* Procedure get_Output */
|
||||
|
||||
/* 102 */ 0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 104 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 108 */ NdrFcShort( 0xa ), /* 10 */
|
||||
/* 110 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||
/* 112 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 114 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 116 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */
|
||||
0x2, /* 2 */
|
||||
/* 118 */ 0x8, /* 8 */
|
||||
0x3, /* Ext Flags: new corr desc, clt corr check, */
|
||||
/* 120 */ NdrFcShort( 0x1 ), /* 1 */
|
||||
/* 122 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 124 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Parameter value */
|
||||
|
||||
/* 126 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
|
||||
/* 128 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||
/* 130 */ NdrFcShort( 0x20 ), /* Type Offset=32 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 132 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 134 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
|
||||
/* 136 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
0x0
|
||||
}
|
||||
};
|
||||
|
||||
static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
|
||||
{
|
||||
0,
|
||||
{
|
||||
NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 2 */
|
||||
0x11, 0x4, /* FC_RP [alloced_on_stack] */
|
||||
/* 4 */ NdrFcShort( 0x1c ), /* Offset= 28 (32) */
|
||||
/* 6 */
|
||||
0x13, 0x0, /* FC_OP */
|
||||
/* 8 */ NdrFcShort( 0xe ), /* Offset= 14 (22) */
|
||||
/* 10 */
|
||||
0x1b, /* FC_CARRAY */
|
||||
0x1, /* 1 */
|
||||
/* 12 */ NdrFcShort( 0x2 ), /* 2 */
|
||||
/* 14 */ 0x9, /* Corr desc: FC_ULONG */
|
||||
0x0, /* */
|
||||
/* 16 */ NdrFcShort( 0xfffc ), /* -4 */
|
||||
/* 18 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||
/* 20 */ 0x6, /* FC_SHORT */
|
||||
0x5b, /* FC_END */
|
||||
/* 22 */
|
||||
0x17, /* FC_CSTRUCT */
|
||||
0x3, /* 3 */
|
||||
/* 24 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 26 */ NdrFcShort( 0xfff0 ), /* Offset= -16 (10) */
|
||||
/* 28 */ 0x8, /* FC_LONG */
|
||||
0x8, /* FC_LONG */
|
||||
/* 30 */ 0x5c, /* FC_PAD */
|
||||
0x5b, /* FC_END */
|
||||
/* 32 */ 0xb4, /* FC_USER_MARSHAL */
|
||||
0x83, /* 131 */
|
||||
/* 34 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 36 */ NdrFcShort( 0x4 ), /* 4 */
|
||||
/* 38 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 40 */ NdrFcShort( 0xffde ), /* Offset= -34 (6) */
|
||||
/* 42 */
|
||||
0x12, 0x0, /* FC_UP */
|
||||
/* 44 */ NdrFcShort( 0xffea ), /* Offset= -22 (22) */
|
||||
/* 46 */ 0xb4, /* FC_USER_MARSHAL */
|
||||
0x83, /* 131 */
|
||||
/* 48 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 50 */ NdrFcShort( 0x4 ), /* 4 */
|
||||
/* 52 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 54 */ NdrFcShort( 0xfff4 ), /* Offset= -12 (42) */
|
||||
|
||||
0x0
|
||||
}
|
||||
};
|
||||
|
||||
static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ] =
|
||||
{
|
||||
|
||||
{
|
||||
BSTR_UserSize
|
||||
,BSTR_UserMarshal
|
||||
,BSTR_UserUnmarshal
|
||||
,BSTR_UserFree
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Object interface: IUnknown, ver. 0.0,
|
||||
GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
|
||||
|
||||
|
||||
/* Object interface: IDispatch, ver. 0.0,
|
||||
GUID={0x00020400,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
|
||||
|
||||
|
||||
/* Object interface: ICalculator, ver. 0.0,
|
||||
GUID={0x2CFA5DB2,0xA740,0x11d3,{0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00}} */
|
||||
|
||||
#pragma code_seg(".orpc")
|
||||
static const unsigned short ICalculator_FormatStringOffsetTable[] =
|
||||
{
|
||||
(unsigned short) -1,
|
||||
(unsigned short) -1,
|
||||
(unsigned short) -1,
|
||||
(unsigned short) -1,
|
||||
0,
|
||||
36,
|
||||
72,
|
||||
102
|
||||
};
|
||||
|
||||
static const MIDL_STUBLESS_PROXY_INFO ICalculator_ProxyInfo =
|
||||
{
|
||||
&Object_StubDesc,
|
||||
__MIDL_ProcFormatString.Format,
|
||||
&ICalculator_FormatStringOffsetTable[-3],
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
static const MIDL_SERVER_INFO ICalculator_ServerInfo =
|
||||
{
|
||||
&Object_StubDesc,
|
||||
0,
|
||||
__MIDL_ProcFormatString.Format,
|
||||
&ICalculator_FormatStringOffsetTable[-3],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
CINTERFACE_PROXY_VTABLE(11) _ICalculatorProxyVtbl =
|
||||
{
|
||||
&ICalculator_ProxyInfo,
|
||||
&IID_ICalculator,
|
||||
IUnknown_QueryInterface_Proxy,
|
||||
IUnknown_AddRef_Proxy,
|
||||
IUnknown_Release_Proxy ,
|
||||
0 /* (void *) (INT_PTR) -1 /* IDispatch::GetTypeInfoCount */ ,
|
||||
0 /* (void *) (INT_PTR) -1 /* IDispatch::GetTypeInfo */ ,
|
||||
0 /* (void *) (INT_PTR) -1 /* IDispatch::GetIDsOfNames */ ,
|
||||
0 /* IDispatch_Invoke_Proxy */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::get_Input */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::put_Input */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::Calculate */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::get_Output */
|
||||
};
|
||||
|
||||
|
||||
static const PRPC_STUB_FUNCTION ICalculator_table[] =
|
||||
{
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
NdrStubCall2,
|
||||
NdrStubCall2,
|
||||
NdrStubCall2,
|
||||
NdrStubCall2
|
||||
};
|
||||
|
||||
CInterfaceStubVtbl _ICalculatorStubVtbl =
|
||||
{
|
||||
&IID_ICalculator,
|
||||
&ICalculator_ServerInfo,
|
||||
11,
|
||||
&ICalculator_table[-3],
|
||||
CStdStubBuffer_DELEGATING_METHODS
|
||||
};
|
||||
|
||||
static const MIDL_STUB_DESC Object_StubDesc =
|
||||
{
|
||||
0,
|
||||
NdrOleAllocate,
|
||||
NdrOleFree,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
__MIDL_TypeFormatString.Format,
|
||||
1, /* -error bounds_check flag */
|
||||
0x50002, /* Ndr library version */
|
||||
0,
|
||||
0x6000169, /* MIDL Version 6.0.361 */
|
||||
0,
|
||||
UserMarshalRoutines,
|
||||
0, /* notify & notify_flag routine table */
|
||||
0x1, /* MIDL flag */
|
||||
0, /* cs routines */
|
||||
0, /* proxy/server info */
|
||||
0 /* Reserved5 */
|
||||
};
|
||||
|
||||
const CInterfaceProxyVtbl * _calc_ProxyVtblList[] =
|
||||
{
|
||||
( CInterfaceProxyVtbl *) &_ICalculatorProxyVtbl,
|
||||
0
|
||||
};
|
||||
|
||||
const CInterfaceStubVtbl * _calc_StubVtblList[] =
|
||||
{
|
||||
( CInterfaceStubVtbl *) &_ICalculatorStubVtbl,
|
||||
0
|
||||
};
|
||||
|
||||
PCInterfaceName const _calc_InterfaceNamesList[] =
|
||||
{
|
||||
"ICalculator",
|
||||
0
|
||||
};
|
||||
|
||||
const IID * _calc_BaseIIDList[] =
|
||||
{
|
||||
&IID_IDispatch,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
#define _calc_CHECK_IID(n) IID_GENERIC_CHECK_IID( _calc, pIID, n)
|
||||
|
||||
int __stdcall _calc_IID_Lookup( const IID * pIID, int * pIndex )
|
||||
{
|
||||
|
||||
if(!_calc_CHECK_IID(0))
|
||||
{
|
||||
*pIndex = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ExtendedProxyFileInfo calc_ProxyFileInfo =
|
||||
{
|
||||
(PCInterfaceProxyVtblList *) & _calc_ProxyVtblList,
|
||||
(PCInterfaceStubVtblList *) & _calc_StubVtblList,
|
||||
(const PCInterfaceName * ) & _calc_InterfaceNamesList,
|
||||
(const IID ** ) & _calc_BaseIIDList,
|
||||
& _calc_IID_Lookup,
|
||||
1,
|
||||
2,
|
||||
0, /* table of [async_uuid] interfaces */
|
||||
0, /* Filler1 */
|
||||
0, /* Filler2 */
|
||||
0 /* Filler3 */
|
||||
};
|
||||
#if _MSC_VER >= 1200
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/
|
||||
|
||||
|
||||
|
||||
/* this ALWAYS GENERATED file contains the proxy stub code */
|
||||
|
||||
|
||||
/* File created by MIDL compiler version 6.00.0361 */
|
||||
/* at Thu Jan 24 22:09:58 2008
|
||||
*/
|
||||
/* Compiler settings for d:\examples\OleCalc\calc.idl:
|
||||
Oicf, W1, Zp8, env=Win64 (32b run,appending)
|
||||
protocol : dce , ms_ext, c_ext, robust
|
||||
error checks: allocation ref bounds_check enum stub_data
|
||||
VC __declspec() decoration level:
|
||||
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||
*/
|
||||
//@@MIDL_FILE_HEADING( )
|
||||
|
||||
#if defined(_M_IA64) || defined(_M_AMD64)
|
||||
|
||||
|
||||
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||
#if _MSC_VER >= 1200
|
||||
#pragma warning(push)
|
||||
#endif
|
||||
|
||||
#pragma warning( disable: 4211 ) /* redefine extent to static */
|
||||
#pragma warning( disable: 4232 ) /* dllimport identity*/
|
||||
#define USE_STUBLESS_PROXY
|
||||
|
||||
|
||||
/* verify that the <rpcproxy.h> version is high enough to compile this file*/
|
||||
#ifndef __REDQ_RPCPROXY_H_VERSION__
|
||||
#define __REQUIRED_RPCPROXY_H_VERSION__ 475
|
||||
#endif
|
||||
|
||||
|
||||
#include "rpcproxy.h"
|
||||
#ifndef __RPCPROXY_H_VERSION__
|
||||
#error this stub requires an updated version of <rpcproxy.h>
|
||||
#endif // __RPCPROXY_H_VERSION__
|
||||
|
||||
|
||||
#include "calc_idl.h"
|
||||
|
||||
#define TYPE_FORMAT_STRING_SIZE 57
|
||||
#define PROC_FORMAT_STRING_SIZE 147
|
||||
#define TRANSMIT_AS_TABLE_SIZE 0
|
||||
#define WIRE_MARSHAL_TABLE_SIZE 1
|
||||
|
||||
typedef struct _MIDL_TYPE_FORMAT_STRING
|
||||
{
|
||||
short Pad;
|
||||
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
|
||||
} MIDL_TYPE_FORMAT_STRING;
|
||||
|
||||
typedef struct _MIDL_PROC_FORMAT_STRING
|
||||
{
|
||||
short Pad;
|
||||
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
|
||||
} MIDL_PROC_FORMAT_STRING;
|
||||
|
||||
|
||||
static RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax =
|
||||
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};
|
||||
|
||||
|
||||
extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
|
||||
extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
|
||||
|
||||
|
||||
extern const MIDL_STUB_DESC Object_StubDesc;
|
||||
|
||||
|
||||
extern const MIDL_SERVER_INFO ICalculator_ServerInfo;
|
||||
extern const MIDL_STUBLESS_PROXY_INFO ICalculator_ProxyInfo;
|
||||
|
||||
|
||||
extern const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ];
|
||||
|
||||
#if !defined(__RPC_WIN64__)
|
||||
#error Invalid build platform for this stub.
|
||||
#endif
|
||||
|
||||
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
|
||||
{
|
||||
0,
|
||||
{
|
||||
|
||||
/* Procedure get_Input */
|
||||
|
||||
0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 6 */ NdrFcShort( 0x7 ), /* 7 */
|
||||
/* 8 */ NdrFcShort( 0x18 ), /* ia64 Stack size/offset = 24 */
|
||||
/* 10 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 12 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 14 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */
|
||||
0x2, /* 2 */
|
||||
/* 16 */ 0xa, /* 10 */
|
||||
0x3, /* Ext Flags: new corr desc, clt corr check, */
|
||||
/* 18 */ NdrFcShort( 0x1 ), /* 1 */
|
||||
/* 20 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 22 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 24 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Parameter _value */
|
||||
|
||||
/* 26 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
|
||||
/* 28 */ NdrFcShort( 0x8 ), /* ia64 Stack size/offset = 8 */
|
||||
/* 30 */ NdrFcShort( 0x20 ), /* Type Offset=32 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 32 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 34 */ NdrFcShort( 0x10 ), /* ia64 Stack size/offset = 16 */
|
||||
/* 36 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
/* Procedure put_Input */
|
||||
|
||||
/* 38 */ 0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 40 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 44 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 46 */ NdrFcShort( 0x18 ), /* ia64 Stack size/offset = 24 */
|
||||
/* 48 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 50 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 52 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
|
||||
0x2, /* 2 */
|
||||
/* 54 */ 0xa, /* 10 */
|
||||
0x5, /* Ext Flags: new corr desc, srv corr check, */
|
||||
/* 56 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 58 */ NdrFcShort( 0x1 ), /* 1 */
|
||||
/* 60 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 62 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Parameter _value */
|
||||
|
||||
/* 64 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
|
||||
/* 66 */ NdrFcShort( 0x8 ), /* ia64 Stack size/offset = 8 */
|
||||
/* 68 */ NdrFcShort( 0x2e ), /* Type Offset=46 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 70 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 72 */ NdrFcShort( 0x10 ), /* ia64 Stack size/offset = 16 */
|
||||
/* 74 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
/* Procedure Calculate */
|
||||
|
||||
/* 76 */ 0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 78 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 82 */ NdrFcShort( 0x9 ), /* 9 */
|
||||
/* 84 */ NdrFcShort( 0x10 ), /* ia64 Stack size/offset = 16 */
|
||||
/* 86 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 88 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 90 */ 0x44, /* Oi2 Flags: has return, has ext, */
|
||||
0x1, /* 1 */
|
||||
/* 92 */ 0xa, /* 10 */
|
||||
0x1, /* Ext Flags: new corr desc, */
|
||||
/* 94 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 96 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 98 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 100 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 102 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 104 */ NdrFcShort( 0x8 ), /* ia64 Stack size/offset = 8 */
|
||||
/* 106 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
/* Procedure get_Output */
|
||||
|
||||
/* 108 */ 0x33, /* FC_AUTO_HANDLE */
|
||||
0x6c, /* Old Flags: object, Oi2 */
|
||||
/* 110 */ NdrFcLong( 0x0 ), /* 0 */
|
||||
/* 114 */ NdrFcShort( 0xa ), /* 10 */
|
||||
/* 116 */ NdrFcShort( 0x18 ), /* ia64 Stack size/offset = 24 */
|
||||
/* 118 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 120 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 122 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */
|
||||
0x2, /* 2 */
|
||||
/* 124 */ 0xa, /* 10 */
|
||||
0x3, /* Ext Flags: new corr desc, clt corr check, */
|
||||
/* 126 */ NdrFcShort( 0x1 ), /* 1 */
|
||||
/* 128 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 130 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 132 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
|
||||
/* Parameter value */
|
||||
|
||||
/* 134 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
|
||||
/* 136 */ NdrFcShort( 0x8 ), /* ia64 Stack size/offset = 8 */
|
||||
/* 138 */ NdrFcShort( 0x20 ), /* Type Offset=32 */
|
||||
|
||||
/* Return value */
|
||||
|
||||
/* 140 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||
/* 142 */ NdrFcShort( 0x10 ), /* ia64 Stack size/offset = 16 */
|
||||
/* 144 */ 0x8, /* FC_LONG */
|
||||
0x0, /* 0 */
|
||||
|
||||
0x0
|
||||
}
|
||||
};
|
||||
|
||||
static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
|
||||
{
|
||||
0,
|
||||
{
|
||||
NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 2 */
|
||||
0x11, 0x4, /* FC_RP [alloced_on_stack] */
|
||||
/* 4 */ NdrFcShort( 0x1c ), /* Offset= 28 (32) */
|
||||
/* 6 */
|
||||
0x13, 0x0, /* FC_OP */
|
||||
/* 8 */ NdrFcShort( 0xe ), /* Offset= 14 (22) */
|
||||
/* 10 */
|
||||
0x1b, /* FC_CARRAY */
|
||||
0x1, /* 1 */
|
||||
/* 12 */ NdrFcShort( 0x2 ), /* 2 */
|
||||
/* 14 */ 0x9, /* Corr desc: FC_ULONG */
|
||||
0x0, /* */
|
||||
/* 16 */ NdrFcShort( 0xfffc ), /* -4 */
|
||||
/* 18 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||
/* 20 */ 0x6, /* FC_SHORT */
|
||||
0x5b, /* FC_END */
|
||||
/* 22 */
|
||||
0x17, /* FC_CSTRUCT */
|
||||
0x3, /* 3 */
|
||||
/* 24 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 26 */ NdrFcShort( 0xfff0 ), /* Offset= -16 (10) */
|
||||
/* 28 */ 0x8, /* FC_LONG */
|
||||
0x8, /* FC_LONG */
|
||||
/* 30 */ 0x5c, /* FC_PAD */
|
||||
0x5b, /* FC_END */
|
||||
/* 32 */ 0xb4, /* FC_USER_MARSHAL */
|
||||
0x83, /* 131 */
|
||||
/* 34 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 36 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 38 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 40 */ NdrFcShort( 0xffde ), /* Offset= -34 (6) */
|
||||
/* 42 */
|
||||
0x12, 0x0, /* FC_UP */
|
||||
/* 44 */ NdrFcShort( 0xffea ), /* Offset= -22 (22) */
|
||||
/* 46 */ 0xb4, /* FC_USER_MARSHAL */
|
||||
0x83, /* 131 */
|
||||
/* 48 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 50 */ NdrFcShort( 0x8 ), /* 8 */
|
||||
/* 52 */ NdrFcShort( 0x0 ), /* 0 */
|
||||
/* 54 */ NdrFcShort( 0xfff4 ), /* Offset= -12 (42) */
|
||||
|
||||
0x0
|
||||
}
|
||||
};
|
||||
|
||||
static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ] =
|
||||
{
|
||||
|
||||
{
|
||||
BSTR_UserSize
|
||||
,BSTR_UserMarshal
|
||||
,BSTR_UserUnmarshal
|
||||
,BSTR_UserFree
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Object interface: IUnknown, ver. 0.0,
|
||||
GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
|
||||
|
||||
|
||||
/* Object interface: IDispatch, ver. 0.0,
|
||||
GUID={0x00020400,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */
|
||||
|
||||
|
||||
/* Object interface: ICalculator, ver. 0.0,
|
||||
GUID={0x2CFA5DB2,0xA740,0x11d3,{0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00}} */
|
||||
|
||||
#pragma code_seg(".orpc")
|
||||
static const unsigned short ICalculator_FormatStringOffsetTable[] =
|
||||
{
|
||||
(unsigned short) -1,
|
||||
(unsigned short) -1,
|
||||
(unsigned short) -1,
|
||||
(unsigned short) -1,
|
||||
0,
|
||||
38,
|
||||
76,
|
||||
108
|
||||
};
|
||||
|
||||
static const MIDL_STUBLESS_PROXY_INFO ICalculator_ProxyInfo =
|
||||
{
|
||||
&Object_StubDesc,
|
||||
__MIDL_ProcFormatString.Format,
|
||||
&ICalculator_FormatStringOffsetTable[-3],
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
static const MIDL_SERVER_INFO ICalculator_ServerInfo =
|
||||
{
|
||||
&Object_StubDesc,
|
||||
0,
|
||||
__MIDL_ProcFormatString.Format,
|
||||
&ICalculator_FormatStringOffsetTable[-3],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
CINTERFACE_PROXY_VTABLE(11) _ICalculatorProxyVtbl =
|
||||
{
|
||||
&ICalculator_ProxyInfo,
|
||||
&IID_ICalculator,
|
||||
IUnknown_QueryInterface_Proxy,
|
||||
IUnknown_AddRef_Proxy,
|
||||
IUnknown_Release_Proxy ,
|
||||
0 /* (void *) (INT_PTR) -1 /* IDispatch::GetTypeInfoCount */ ,
|
||||
0 /* (void *) (INT_PTR) -1 /* IDispatch::GetTypeInfo */ ,
|
||||
0 /* (void *) (INT_PTR) -1 /* IDispatch::GetIDsOfNames */ ,
|
||||
0 /* IDispatch_Invoke_Proxy */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::get_Input */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::put_Input */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::Calculate */ ,
|
||||
(void *) (INT_PTR) -1 /* ICalculator::get_Output */
|
||||
};
|
||||
|
||||
|
||||
static const PRPC_STUB_FUNCTION ICalculator_table[] =
|
||||
{
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
STUB_FORWARDING_FUNCTION,
|
||||
NdrStubCall2,
|
||||
NdrStubCall2,
|
||||
NdrStubCall2,
|
||||
NdrStubCall2
|
||||
};
|
||||
|
||||
CInterfaceStubVtbl _ICalculatorStubVtbl =
|
||||
{
|
||||
&IID_ICalculator,
|
||||
&ICalculator_ServerInfo,
|
||||
11,
|
||||
&ICalculator_table[-3],
|
||||
CStdStubBuffer_DELEGATING_METHODS
|
||||
};
|
||||
|
||||
static const MIDL_STUB_DESC Object_StubDesc =
|
||||
{
|
||||
0,
|
||||
NdrOleAllocate,
|
||||
NdrOleFree,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
__MIDL_TypeFormatString.Format,
|
||||
1, /* -error bounds_check flag */
|
||||
0x50002, /* Ndr library version */
|
||||
0,
|
||||
0x6000169, /* MIDL Version 6.0.361 */
|
||||
0,
|
||||
UserMarshalRoutines,
|
||||
0, /* notify & notify_flag routine table */
|
||||
0x1, /* MIDL flag */
|
||||
0, /* cs routines */
|
||||
0, /* proxy/server info */
|
||||
0 /* Reserved5 */
|
||||
};
|
||||
|
||||
const CInterfaceProxyVtbl * _calc_ProxyVtblList[] =
|
||||
{
|
||||
( CInterfaceProxyVtbl *) &_ICalculatorProxyVtbl,
|
||||
0
|
||||
};
|
||||
|
||||
const CInterfaceStubVtbl * _calc_StubVtblList[] =
|
||||
{
|
||||
( CInterfaceStubVtbl *) &_ICalculatorStubVtbl,
|
||||
0
|
||||
};
|
||||
|
||||
PCInterfaceName const _calc_InterfaceNamesList[] =
|
||||
{
|
||||
"ICalculator",
|
||||
0
|
||||
};
|
||||
|
||||
const IID * _calc_BaseIIDList[] =
|
||||
{
|
||||
&IID_IDispatch,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
#define _calc_CHECK_IID(n) IID_GENERIC_CHECK_IID( _calc, pIID, n)
|
||||
|
||||
int __stdcall _calc_IID_Lookup( const IID * pIID, int * pIndex )
|
||||
{
|
||||
|
||||
if(!_calc_CHECK_IID(0))
|
||||
{
|
||||
*pIndex = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ExtendedProxyFileInfo calc_ProxyFileInfo =
|
||||
{
|
||||
(PCInterfaceProxyVtblList *) & _calc_ProxyVtblList,
|
||||
(PCInterfaceStubVtblList *) & _calc_StubVtblList,
|
||||
(const PCInterfaceName * ) & _calc_InterfaceNamesList,
|
||||
(const IID ** ) & _calc_BaseIIDList,
|
||||
& _calc_IID_Lookup,
|
||||
1,
|
||||
2,
|
||||
0, /* table of [async_uuid] interfaces */
|
||||
0, /* Filler1 */
|
||||
0, /* Filler2 */
|
||||
0 /* Filler3 */
|
||||
};
|
||||
#if _MSC_VER >= 1200
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* defined(_M_IA64) || defined(_M_AMD64)*/
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*********************************************************
|
||||
DllData file -- generated by MIDL compiler
|
||||
|
||||
DO NOT ALTER THIS FILE
|
||||
|
||||
This file is regenerated by MIDL on every IDL file compile.
|
||||
|
||||
To completely reconstruct this file, delete it and rerun MIDL
|
||||
on all the IDL files in this DLL, specifying this file for the
|
||||
/dlldata command line option
|
||||
|
||||
*********************************************************/
|
||||
|
||||
#define PROXY_DELEGATION
|
||||
|
||||
#include <rpcproxy.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
EXTERN_PROXY_FILE( calc )
|
||||
|
||||
|
||||
PROXYFILE_LIST_START
|
||||
/* Start of list */
|
||||
REFERENCE_PROXY_FILE( calc ),
|
||||
/* End of list */
|
||||
PROXYFILE_LIST_END
|
||||
|
||||
|
||||
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C" */
|
||||
#endif
|
||||
|
||||
/* end of generated dlldata file */
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
#include "PaintGL.h"
|
||||
|
||||
#pragma comment( lib, "opengl32.lib" ) // Search For OpenGL32.lib While Linking
|
||||
#pragma comment( lib, "glu32.lib" ) // Search For GLu32.lib While Linking
|
||||
#pragma comment( lib, "glaux.lib" ) // Search For GLaux.lib While Linking
|
||||
|
||||
PaintGL::PaintGL()
|
||||
{
|
||||
size = Null;
|
||||
hbmp = ohbmp = NULL;
|
||||
hdc = NULL;
|
||||
hrc = NULL;
|
||||
}
|
||||
|
||||
PaintGL::~PaintGL()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
void PaintGL::Free()
|
||||
{
|
||||
if(hrc) {
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(hrc);
|
||||
SelectObject(hdc, ohbmp);
|
||||
DeleteDC(hdc);
|
||||
DeleteObject(hbmp);
|
||||
hrc = NULL;
|
||||
hbmp = ohbmp = NULL;
|
||||
hdc = NULL;
|
||||
hbmp = NULL;
|
||||
}
|
||||
size = Null;
|
||||
}
|
||||
|
||||
|
||||
void PaintGL::Init(Size sz) {
|
||||
Free();
|
||||
|
||||
size = sz;
|
||||
|
||||
BITMAPINFOHEADER bih;
|
||||
memset(&bih, 0, sizeof(bih));
|
||||
bih.biSize = sizeof(bih);
|
||||
bih.biWidth = ((((int) sz.cx * 8) + 31) & ~31) >> 3;
|
||||
bih.biHeight = sz.cy;
|
||||
bih.biPlanes = 1;
|
||||
bih.biBitCount = 32;
|
||||
bih.biCompression = BI_RGB;
|
||||
|
||||
hdc = CreateCompatibleDC(NULL);
|
||||
|
||||
void *dummy;
|
||||
|
||||
hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_PAL_COLORS, &dummy, NULL, 0);
|
||||
|
||||
ohbmp = (HBITMAP)SelectObject(hdc, hbmp);
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL/* | PFD_SUPPORT_GDI | PFD_ACCELERATED*/;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cDepthBits = 32;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
|
||||
GLuint PixelFormat = ChoosePixelFormat(hdc, &pfd);
|
||||
SetPixelFormat(hdc, PixelFormat, &pfd);
|
||||
hrc = wglCreateContext(hdc);
|
||||
wglMakeCurrent(hdc, hrc);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
glClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
glViewport(0, 0, (GLsizei)sz.cx, (GLsizei)sz.cy);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45.0f, (GLfloat)(sz.cx)/(GLfloat)(sz.cy), 1.0f, 100.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
void PaintGL::Paint(Draw& w, const Rect& r, Callback gl)
|
||||
{
|
||||
if(r.Size() != size)
|
||||
Init(r.Size());
|
||||
gl();
|
||||
glFlush();
|
||||
HDC whdc = w.BeginGdi();
|
||||
BitBlt(whdc, 0, 0, size.cx, size.cy, hdc, r.left, r.top, SRCCOPY);
|
||||
w.EndGdi();
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef _PaintGL_PaintGL_h
|
||||
#define _PaintGL_PaintGL_h
|
||||
|
||||
#include <Draw/Draw.h>
|
||||
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glaux.h>
|
||||
|
||||
class PaintGL {
|
||||
Size size;
|
||||
HBITMAP hbmp, ohbmp;
|
||||
HDC hdc;
|
||||
HGLRC hrc;
|
||||
|
||||
void Free();
|
||||
void Init(Size sz);
|
||||
|
||||
public:
|
||||
void Paint(Draw& w, const Rect& r, Callback gl);
|
||||
|
||||
PaintGL();
|
||||
~PaintGL();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
file
|
||||
PaintGL.h,
|
||||
PaintGL.cpp,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
|
|
@ -1,677 +0,0 @@
|
|||
#include "RichBook.h"
|
||||
|
||||
#include <DocTypes/DocTypes.h>
|
||||
#include <PdfDraw/PdfDraw.h>
|
||||
|
||||
namespace Upp {
|
||||
|
||||
struct FieldTypeVarCls : public RichPara::FieldType
|
||||
{
|
||||
virtual Array<RichPara::Part> Evaluate(const String& param, VectorMap<String, Value>& vars,
|
||||
const RichPara::CharFormat& fmt);
|
||||
};
|
||||
|
||||
Array<RichPara::Part> FieldTypeVarCls::Evaluate(const String& dest,
|
||||
VectorMap<String, Value>& vars, const RichPara::CharFormat& linkfmt)
|
||||
{
|
||||
RichPara para;
|
||||
RichPara::CharFormat fmt = linkfmt;
|
||||
int f = vars.Find(dest);
|
||||
if(f < 0) {
|
||||
fmt.ink = LtRed();
|
||||
fmt.paper = WhiteGray();
|
||||
para.Cat(dest, fmt);
|
||||
}
|
||||
else
|
||||
para.Cat(StdFormat(vars[f]), fmt);
|
||||
return para.part;
|
||||
}
|
||||
|
||||
RichPara::FieldType& GLOBAL_V(FieldTypeVarCls, FieldTypeVar);
|
||||
|
||||
Id FieldTypeVarID()
|
||||
{
|
||||
static Id ftv("VAR");
|
||||
return ftv;
|
||||
}
|
||||
|
||||
INITBLOCK {
|
||||
RichPara::Register(FieldTypeVarID(), FieldTypeVar());
|
||||
}
|
||||
|
||||
/*
|
||||
RichPara::FieldType& FieldTypeIndexEntry()
|
||||
{
|
||||
}
|
||||
|
||||
Id FieldTypeIndexEntryID()
|
||||
{
|
||||
}
|
||||
|
||||
String EncodeIndexEntry(const RichIndexEntry& idx)
|
||||
{
|
||||
}
|
||||
|
||||
RichIndexEntry DecodeIndexEntry(String encoded_indexentry)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
RichBookSection::RichBookSection()
|
||||
{
|
||||
// pagesize = pg;
|
||||
columns = 1;
|
||||
firstpage = 1;
|
||||
margin = Rect(0, 0, 0, 0);
|
||||
header_space = 200;
|
||||
footer_space = 200;
|
||||
column_space = 200;
|
||||
// footer[1] = "- # -";
|
||||
}
|
||||
|
||||
Rect RichBookSection::GetPageRect(Size pagesize) const
|
||||
{
|
||||
return Rect(pagesize).Deflated(margin);
|
||||
}
|
||||
|
||||
Rect RichBookSection::GetTextRect(Size pagesize, int colindex) const
|
||||
{
|
||||
Rect textarea = GetPageRect(pagesize).Deflated(0, header_space, 0, footer_space);
|
||||
if(columns <= 1)
|
||||
return textarea;
|
||||
int colwd = (textarea.Width() - column_space * (columns - 1)) / columns;
|
||||
int offset = iscale(textarea.Width() - colwd, colindex, columns - 1);
|
||||
textarea.left += offset;
|
||||
textarea.right = textarea.left + colwd;
|
||||
return textarea;
|
||||
}
|
||||
|
||||
Size RichBookSection::GetTextSize(Size pagesize) const
|
||||
{
|
||||
return GetTextRect(pagesize, 0).Size();
|
||||
}
|
||||
|
||||
class RichSectionPageDraw : public PageDraw
|
||||
{
|
||||
public:
|
||||
RichSectionPageDraw(Size drawingsize, Gate2<int, int> progress, int& progress_pos);
|
||||
|
||||
virtual Draw& Page(int page);
|
||||
virtual Draw& Info();
|
||||
|
||||
Vector<Drawing> Close();
|
||||
|
||||
private:
|
||||
Gate2<int, int> progress;
|
||||
int& progress_pos;
|
||||
Size drawingsize;
|
||||
Vector<Drawing> pages;
|
||||
DrawingDraw ddraw;
|
||||
DrawingDraw info;
|
||||
int currentpage;
|
||||
};
|
||||
|
||||
RichSectionPageDraw::RichSectionPageDraw(Size dsz, Gate2<int, int> progress, int& progress_pos)
|
||||
: progress(progress)
|
||||
, progress_pos(progress_pos)
|
||||
{
|
||||
currentpage = -1;
|
||||
info.Create(drawingsize = dsz);
|
||||
}
|
||||
|
||||
Draw& RichSectionPageDraw::Page(int page)
|
||||
{
|
||||
if(page != currentpage) {
|
||||
ASSERT(ddraw.GetCloffLevel() == 0);
|
||||
progress(progress_pos + page, -1);
|
||||
if(currentpage >= 0)
|
||||
pages.At(currentpage) = ddraw;
|
||||
ddraw.Create(drawingsize);
|
||||
ddraw.DrawDrawing(drawingsize, pages.At(currentpage = page));
|
||||
}
|
||||
return ddraw;
|
||||
}
|
||||
|
||||
Draw& RichSectionPageDraw::Info()
|
||||
{
|
||||
return Page(0);
|
||||
}
|
||||
|
||||
Vector<Drawing> RichSectionPageDraw::Close()
|
||||
{
|
||||
if(currentpage >= 0) {
|
||||
ASSERT(ddraw.GetCloffLevel() == 0);
|
||||
pages.At(currentpage) = ddraw;
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
static String ExpandHFText(const char *text, int pageno)
|
||||
{
|
||||
String out;
|
||||
for(char c; c = *text++;)
|
||||
if(c == '#')
|
||||
switch(*text++) {
|
||||
case 'r': out.Cat(FormatIntRoman(pageno, false)); break;
|
||||
case 'R': out.Cat(FormatIntRoman(pageno, true)); break;
|
||||
case 'a': out.Cat(FormatIntAlpha(pageno, false)); break;
|
||||
case 'A': out.Cat(FormatIntAlpha(pageno, true)); break;
|
||||
default: text--; out.Cat(FormatInt(pageno)); break;
|
||||
}
|
||||
else
|
||||
out.Cat(c);
|
||||
return out;
|
||||
}
|
||||
|
||||
Vector<Drawing> RichPrintSection::Print(Size pagesize, Gate2<int, int> progress, int& progress_pos) const
|
||||
{
|
||||
ASSERT(columns > 0);
|
||||
Size drawingsize = GetTextSize(pagesize);
|
||||
RichSectionPageDraw spdraw(drawingsize, progress, progress_pos);
|
||||
PaintInfo paintinfo;
|
||||
paintinfo.top = PageY(0, 0);
|
||||
paintinfo.bottom = PageY(32767, 0);
|
||||
paintinfo.indexentry = Null;
|
||||
text.Paint(spdraw, drawingsize, paintinfo);
|
||||
Vector<Drawing> in = spdraw.Close();
|
||||
Vector<Drawing> out;
|
||||
for(int i = 0; i < in.GetCount(); i += columns) {
|
||||
int pageno = firstpage + out.GetCount();
|
||||
DrawingDraw ddraw(pagesize);
|
||||
Rect pagerect = GetPageRect(pagesize);
|
||||
for(int c = 0; c < columns && c + i < in.GetCount(); c++)
|
||||
ddraw.DrawDrawing(GetTextRect(pagesize, c), in[i + c]);
|
||||
for(int hf = 0; hf < 3; hf++) {
|
||||
if(!IsNull(header[hf])) {
|
||||
String s = ExpandHFText(header[hf], pageno);
|
||||
Size sz = UPP::GetTextSize(s, charformat);
|
||||
int x;
|
||||
switch(hf) {
|
||||
case 0: x = pagerect.left; break;
|
||||
case 1: x = (pagerect.left + pagerect.right - sz.cx) >> 1; break;
|
||||
case 2: x = pagerect.right - sz.cx; break;
|
||||
}
|
||||
ddraw.DrawText(x, pagerect.top, s, charformat);
|
||||
}
|
||||
if(!IsNull(footer[hf])) {
|
||||
String s = ExpandHFText(footer[hf], pageno);
|
||||
Size sz = UPP::GetTextSize(s, charformat);
|
||||
int x;
|
||||
switch(hf) {
|
||||
case 0: x = pagerect.left; break;
|
||||
case 1: x = (pagerect.left + pagerect.right - sz.cx) >> 1; break;
|
||||
case 2: x = pagerect.right - sz.cx; break;
|
||||
}
|
||||
ddraw.DrawText(x, pagerect.bottom - sz.cy, s, charformat);
|
||||
}
|
||||
}
|
||||
out.Add() = ddraw;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
String GetLangSuffix(int language = GetCurrentLanguage())
|
||||
{
|
||||
String lt = LNGAsText(language);
|
||||
String out;
|
||||
out << '$' << (char)ToLower(lt[0]) << (char)ToLower(lt[1]) << '-' << (char)ToLower(lt[3]) << (char)ToLower(lt[4]);
|
||||
return out;
|
||||
}
|
||||
|
||||
void MakeStdToc(RichText& out, const RichToc& toc, int print_width)
|
||||
{
|
||||
VectorMap< String, ArrayMap<String, RichPara> > subparts;
|
||||
String suffix = GetLangSuffix();
|
||||
for(int i = 0; i < toc.entries.GetCount(); i++) {
|
||||
const RichTocEntry& e = toc.entries[i];
|
||||
RichPara::Format pfmt = out.GetStyle(out.GetStyleId("Toc" + FormatInt(e.level))).format;
|
||||
RichPara para;
|
||||
para.format = pfmt;
|
||||
WString name = e.text;
|
||||
String tname = e.topic, subpart;
|
||||
int th = tname.Find('#');
|
||||
if(th >= 0) {
|
||||
subpart = tname.Mid(th);
|
||||
tname.Trim(th);
|
||||
}
|
||||
tname.Cat(suffix);
|
||||
Topic tp = GetTopic(tname);
|
||||
if(!IsNull(name))
|
||||
para.Cat(name, pfmt);
|
||||
else {
|
||||
if(!IsNull(subpart)) {
|
||||
int sp = subparts.Find(tname);
|
||||
if(sp < 0) {
|
||||
sp = subparts.GetCount();
|
||||
ArrayMap<String, RichPara>& spmap = subparts.Add(tname);
|
||||
RichText rt = ParseQTF(tp.text);
|
||||
for(int p = 0; p < rt.GetPartCount(); p++)
|
||||
if(rt.IsPara(p)) {
|
||||
RichPara rp = rt.Get(p);
|
||||
// if(*rp.format.label == '#')
|
||||
spmap.AddPick("#" + rp.format.label, rp);
|
||||
}
|
||||
}
|
||||
para <<= subparts[sp].Get(subpart, RichPara());
|
||||
Array<RichObject> objs;
|
||||
String packed = para.Pack(para.format, objs);
|
||||
para.Unpack(packed, objs, pfmt);
|
||||
}
|
||||
else if(!IsNull(tp.title))
|
||||
para.Cat(FromUtf8(tp.title), pfmt);
|
||||
}
|
||||
if(para.part.IsEmpty()) {
|
||||
pfmt.ink = LtRed();
|
||||
pfmt.paper = WhiteGray();
|
||||
para.Cat((WString)(tname + subpart), pfmt);
|
||||
}
|
||||
para.Cat("\t", pfmt);
|
||||
para.Cat(FieldTypeVarID(), String().Cat() << tname << subpart << "$page", pfmt);
|
||||
out.Cat(para);
|
||||
}
|
||||
RLOG("MakeStdToc:\n" << AsQTF(out));
|
||||
}
|
||||
|
||||
void MakeOnlineToc(RichText& out, const RichToc& toc)
|
||||
{
|
||||
String suffix = GetLangSuffix();
|
||||
VectorMap< String, ArrayMap<String, RichPara> > subparts;
|
||||
for(int i = 0; i < toc.entries.GetCount(); i++) {
|
||||
const RichTocEntry& e = toc.entries[i];
|
||||
RichPara::Format pfmt = out.GetStyle(out.GetStyleId("Topics" + FormatInt(e.level))).format;
|
||||
RichPara para;
|
||||
para.format = pfmt;
|
||||
WString name = e.text;
|
||||
String tname = e.topic, subpart;
|
||||
int th = tname.Find('#');
|
||||
if(th >= 0) {
|
||||
subpart = tname.Mid(th);
|
||||
tname.Trim(th);
|
||||
}
|
||||
tname.Cat(suffix);
|
||||
Topic tp = GetTopic(tname);
|
||||
pfmt.link = tname;
|
||||
if(!IsNull(name))
|
||||
para.Cat(name, pfmt);
|
||||
else {
|
||||
if(!IsNull(subpart)) {
|
||||
int sp = subparts.Find(tname);
|
||||
if(sp < 0) {
|
||||
sp = subparts.GetCount();
|
||||
ArrayMap<String, RichPara>& spmap = subparts.Add(tname);
|
||||
RichText rt = ParseQTF(tp.text);
|
||||
for(int p = 0; p < rt.GetPartCount(); p++)
|
||||
if(rt.IsPara(p)) {
|
||||
RichPara rp = rt.Get(p);
|
||||
// if(*rp.format.label == '#')
|
||||
spmap.AddPick("#" + rp.format.label, rp);
|
||||
}
|
||||
}
|
||||
para <<= subparts[sp].Get(subpart, RichPara());
|
||||
Array<RichObject> objs;
|
||||
String packed = para.Pack(para.format, objs);
|
||||
para.Unpack(packed, objs, pfmt);
|
||||
}
|
||||
else if(!IsNull(tp.title))
|
||||
para.Cat(FromUtf8(tp.title), pfmt);
|
||||
}
|
||||
if(para.part.IsEmpty()) {
|
||||
pfmt.ink = LtRed();
|
||||
pfmt.paper = WhiteGray();
|
||||
para.Cat((WString)(tname + subpart), pfmt);
|
||||
}
|
||||
out.Cat(para);
|
||||
}
|
||||
RLOG("MakeOnlineToc:\n" << AsQTF(out));
|
||||
}
|
||||
|
||||
void MakeTocTopics(RichText& out, const RichToc& toc)
|
||||
{
|
||||
String suffix = GetLangSuffix();
|
||||
VectorMap< String, VectorMap<String, int> > topic_tocrefs;
|
||||
for(int i = 0; i < toc.entries.GetCount(); i++) {
|
||||
String tname = toc.entries[i].topic;
|
||||
int th = tname.Find('#');
|
||||
if(th >= 0)
|
||||
topic_tocrefs.GetAdd(tname.Left(th)).GetAdd(tname.Mid(th), i);
|
||||
}
|
||||
Index<String> done;
|
||||
for(int i = 0; i < toc.entries.GetCount(); i++) {
|
||||
const RichTocEntry& e = toc.entries[i];
|
||||
WString name = e.text;
|
||||
String tname = e.topic;
|
||||
int th = tname.Find('#');
|
||||
if(th >= 0)
|
||||
tname.Trim(th);
|
||||
int tr = topic_tocrefs.Find(tname);
|
||||
tname << suffix;
|
||||
if(done.Find(tname) >= 0)
|
||||
continue;
|
||||
done.Add(tname);
|
||||
Topic tp = GetTopic(tname);
|
||||
RichPara title_para;
|
||||
title_para.format = out.GetStyle(out.GetStyleId("Heading" + FormatInt(e.level))).format;
|
||||
if(IsNull(name) && IsNull(name = FromUtf8(tp.title))) {
|
||||
name = (WString)tname;
|
||||
title_para.format.ink = LtRed();
|
||||
title_para.format.paper = WhiteGray();
|
||||
}
|
||||
title_para.format.label = tname;
|
||||
title_para.Cat(name, title_para.format);
|
||||
out.Cat(title_para);
|
||||
RichText data = ParseQTF(tp.text);
|
||||
int pcount = out.GetPartCount();
|
||||
out.CatPick(data);
|
||||
for(int t = pcount; t < out.GetPartCount(); t++)
|
||||
if(out.IsPara(t)) {
|
||||
RichPara p = out.Get(t);
|
||||
String lbl = "#" + p.format.label;
|
||||
int tx;
|
||||
if(tr >= 0 && (tx = topic_tocrefs[tr].Find(lbl)) >= 0) {
|
||||
const RichTocEntry& ex = toc.entries[topic_tocrefs[tr][tx]];
|
||||
Array<RichObject> objs;
|
||||
String pack = p.Pack(p.format, objs);
|
||||
p.format = out.GetStyle(out.GetStyleId("Heading" + FormatInt(ex.level))).format;
|
||||
p.Unpack(pack, objs, p.format);
|
||||
p.format.label = tname + lbl;
|
||||
out.Set(t, p, out.GetStyles());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//RichText MakeStdIndex(
|
||||
|
||||
RichBook::RichBook(Size pg)
|
||||
: page_size(pg)
|
||||
{
|
||||
RichStyle toc1, toc2, toc3, toc4;
|
||||
RichPara::Tab& t1tab = toc1.format.tab.Add();
|
||||
t1tab.pos = pg.cx - 300;
|
||||
t1tab.align = ALIGN_RIGHT;
|
||||
t1tab.fillchar = 1;
|
||||
toc2 = toc3 = toc4 = toc1;
|
||||
t1tab.fillchar = 0;
|
||||
|
||||
toc1.name = "Toc1";
|
||||
(Font&)toc1.format = Arial(90).Bold();
|
||||
toc1.format.indent = 100;
|
||||
toc1.format.before = 100;
|
||||
toc1.format.number[0] = RichPara::NUMBER_1;
|
||||
|
||||
toc2.name = "Toc2";
|
||||
(Font&)toc2.format = Arial(84).Bold();
|
||||
toc2.format.indent = 200;
|
||||
toc2.format.lm = 200;
|
||||
toc2.format.number[0] = toc2.format.number[1] = RichPara::NUMBER_1;
|
||||
|
||||
toc3.name = "Toc3";
|
||||
(Font&)toc3.format = Arial(84);
|
||||
toc3.format.indent = 300;
|
||||
toc3.format.lm = 300;
|
||||
toc3.format.number[0] = toc3.format.number[1] = toc3.format.number[2] = RichPara::NUMBER_1;
|
||||
|
||||
toc4.name = "Toc4";
|
||||
toc4.format.number[0] = toc4.format.number[1] = toc4.format.number[2] = toc4.format.number[3] = RichPara::NUMBER_1;
|
||||
|
||||
RichStyle head1, head2, head3, head4;
|
||||
head1.name = "Heading1";
|
||||
(Font&)head1.format = Arial(144).Bold();
|
||||
head1.format.newpage = true;
|
||||
head1.format.before = 300;
|
||||
head1.format.after = 100;
|
||||
head1.format.indent = 150;
|
||||
head1.format.number[0] = RichPara::NUMBER_1;
|
||||
|
||||
head2.name = "Heading2";
|
||||
(Font&)head2.format = Arial(120).Bold();
|
||||
head2.format.before = 200;
|
||||
head2.format.after = 100;
|
||||
head2.format.indent = 200;
|
||||
head2.format.number[0] = head2.format.number[1] = RichPara::NUMBER_1;
|
||||
|
||||
head3.name = "Heading3";
|
||||
(Font&)head3.format = Arial(100).Bold();
|
||||
head3.format.before = 100;
|
||||
head3.format.after = 50;
|
||||
head3.format.indent = 250;
|
||||
head3.format.number[0] = head3.format.number[1] = head3.format.number[2] = RichPara::NUMBER_1;
|
||||
|
||||
head4 = head3;
|
||||
head4.name = "Heading4";
|
||||
head4.format.number[0] = head4.format.number[1] = head4.format.number[2] = head4.format.number[3] = RichPara::NUMBER_1;
|
||||
|
||||
default_styles.Add(Uuid::Create(), toc1);
|
||||
default_styles.Add(Uuid::Create(), toc2);
|
||||
default_styles.Add(Uuid::Create(), toc3);
|
||||
default_styles.Add(Uuid::Create(), toc4);
|
||||
|
||||
default_styles.Add(Uuid::Create(), head1);
|
||||
default_styles.Add(Uuid::Create(), head2);
|
||||
default_styles.Add(Uuid::Create(), head3);
|
||||
default_styles.Add(Uuid::Create(), head4);
|
||||
}
|
||||
|
||||
RichPrintSection& RichBook::AddSection()
|
||||
{
|
||||
RichText init;
|
||||
init.OverrideStyles(default_styles);
|
||||
return sections.Add(new RichPrintSection(default_section, init));
|
||||
}
|
||||
|
||||
Vector<Drawing> RichBook::Print(Size pagesize, Gate2<int, int> progress)
|
||||
{
|
||||
Vector<Drawing> out;
|
||||
int pos = 0;
|
||||
|
||||
VectorMap<String, Value> vars;
|
||||
vars.GetAdd("$book") = 1;
|
||||
bool stable = false;
|
||||
enum { MAX_PASSES = 10 };
|
||||
int pass;
|
||||
for(pass = 1; !stable && pass <= MAX_PASSES; pass++) {
|
||||
if(progress(pass, 0))
|
||||
throw AbortExc();
|
||||
stable = true;
|
||||
int pageno = 1;
|
||||
Index<String> chkdup;
|
||||
for(int s = 0; s < sections.GetCount(); s++) {
|
||||
RichPrintSection& psec = sections[s];
|
||||
if(psec.text.GetPartCount() > 0 && psec.text.IsPara(0)) {
|
||||
RichPara p0 = psec.text.Get(0);
|
||||
if(p0.format.newpage) {
|
||||
p0.format.newpage = false;
|
||||
psec.text.Set(0, p0, psec.text.GetStyles());
|
||||
}
|
||||
}
|
||||
Size textsize = psec.GetTextSize(pagesize);
|
||||
PageY begin;
|
||||
pageno = Nvl(psec.firstpage, pageno);
|
||||
psec.text.EvaluateFields(vars);
|
||||
int numpages = psec.text.GetHeight(textsize).page / psec.columns + 1;
|
||||
Vector<RichValPos> posinfo = psec.text.GetValPos(textsize, RichText::LABELS);
|
||||
for(int i = 0; i < posinfo.GetCount(); i++) {
|
||||
String key = posinfo[i].data.ToString() + "$page";
|
||||
if(chkdup.Find(key) >= 0) {
|
||||
if(pass == 1)
|
||||
RLOG("Duplicate: " << key);
|
||||
continue;
|
||||
}
|
||||
chkdup.Add(key);
|
||||
int oldpage = vars.Get(key, Value());
|
||||
int newpage = pageno + posinfo[i].py.page;
|
||||
if(newpage != oldpage) {
|
||||
if(pass > 2)
|
||||
RLOG("Unstable: " << key << ": " << oldpage << " -> " << newpage);
|
||||
vars.GetAdd(key) = newpage;
|
||||
stable = false;
|
||||
}
|
||||
}
|
||||
pageno += numpages;
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < sections.GetCount(); i++)
|
||||
out.AppendPick(sections[i].Print(pagesize, progress, pos));
|
||||
#ifdef _DEBUG
|
||||
RichText symtext;
|
||||
Vector<int> order = GetSortOrder(vars.GetKeys());
|
||||
for(int o = 0; o < order.GetCount(); o++) {
|
||||
RichPara para;
|
||||
para.Cat(NFormat("<%s> %vt", vars.GetKey(order[o]), vars[order[o]]), para.format);
|
||||
symtext.Cat(para);
|
||||
}
|
||||
RichPrintSection symsec(default_section, symtext);
|
||||
out.AppendPick(symsec.Print(pagesize, progress, pos));
|
||||
#endif
|
||||
return out;
|
||||
}
|
||||
|
||||
void CreateHelpBook(RichBook& book)
|
||||
{
|
||||
Progress progress(t_("Typesetting page %d..."));
|
||||
DocReport report;
|
||||
Vector<Drawing> pages = book.Print(report.GetPageSize(), progress);
|
||||
progress.SetText(t_("Printing page %d..."));
|
||||
for(int i = 0; i < pages.GetCount(); i++) {
|
||||
if(progress.SetCanceled(i, pages.GetCount()))
|
||||
throw AbortExc();
|
||||
if(i)
|
||||
report.NextPage();
|
||||
report.DrawDrawing(pages[i].GetSize(), pages[i]);
|
||||
}
|
||||
report.Perform();
|
||||
}
|
||||
|
||||
String CreateHelpPDF(RichBook& book)
|
||||
{
|
||||
PdfDraw pdf(210 * 6000 / 254, 297 * 6000 / 254);
|
||||
Rect margin = Rect(pdf.GetPagePixels()).Deflated(236);
|
||||
Progress progress(t_("Typesetting..."));
|
||||
Vector<Drawing> pages = book.Print(margin.Size(), progress);
|
||||
progress.SetText(t_("Exporting PDF..."));
|
||||
progress.SetTotal(pages.GetCount());
|
||||
for(int i = 0; i < pages.GetCount(); i++) {
|
||||
if(progress.StepCanceled())
|
||||
throw AbortExc();
|
||||
pdf.StartPage();
|
||||
pdf.DrawDrawing(margin, pages[i]);
|
||||
pdf.EndPage();
|
||||
}
|
||||
return pdf.Finish();
|
||||
}
|
||||
|
||||
String CreateHelpRTF(RichBook& book, byte charset)
|
||||
{
|
||||
RichText richtext;
|
||||
for(int i = 0; i < book.sections.GetCount(); i++)
|
||||
richtext.CatPick(book.sections[i].text);
|
||||
return EncodeRTF(richtext, charset);
|
||||
}
|
||||
|
||||
RichBookHtml::RichBookHtml()
|
||||
{
|
||||
}
|
||||
|
||||
void RichBookHtml::AddFile(String url, String data)
|
||||
{
|
||||
}
|
||||
|
||||
void RichBookHtml::AddImage(String url, String data)
|
||||
{
|
||||
}
|
||||
|
||||
String RichBookHtml::GetURLFile(String url) const
|
||||
{
|
||||
String out;
|
||||
return out;
|
||||
}
|
||||
|
||||
void CreateHelpHtml(RichBook& book, RichBookHtml& html)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL_VAR(Callback1<RichBook&>, DefaultBook)
|
||||
|
||||
void CreateDefaultBook()
|
||||
{
|
||||
RichBook book;
|
||||
DefaultBook()(book);
|
||||
CreateHelpBook(book);
|
||||
}
|
||||
|
||||
void CreateDefaultPDF()
|
||||
{
|
||||
RichBook book;
|
||||
DefaultBook()(book);
|
||||
try {
|
||||
String data = CreateHelpPDF(book);
|
||||
FileSelector fsel;
|
||||
fsel.Type(t_("PDF documents (*.pdf)"), "*.pdf")
|
||||
.DefaultExt("pdf")
|
||||
.AllFilesType();
|
||||
static String recent;
|
||||
fsel <<= recent;
|
||||
if(fsel.ExecuteSaveAs(t_("PDF export"))) {
|
||||
recent = ~fsel;
|
||||
if(!SaveFile(recent, data))
|
||||
throw Exc(NFormat("Error saving file '%s' (%d B).", recent, data.GetLength()));
|
||||
}
|
||||
}
|
||||
catch(Exc e) {
|
||||
ShowExc(e);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateDefaultRTF()
|
||||
{
|
||||
RichBook book;
|
||||
DefaultBook()(book);
|
||||
try {
|
||||
String data = CreateHelpRTF(book, GetDefaultCharset());
|
||||
FileSelector fsel;
|
||||
fsel.Type(t_("Rich text documents (*.rtf)"), "*.rtf")
|
||||
.DefaultExt("rtf")
|
||||
.AllFilesType();
|
||||
static String recent;
|
||||
fsel <<= recent;
|
||||
if(fsel.ExecuteSaveAs(t_("Save manual as"))) {
|
||||
recent = ~fsel;
|
||||
if(!SaveFile(recent, data))
|
||||
throw Exc(NFormat("Error saving file '%s' (%d B).", recent, data.GetLength()));
|
||||
}
|
||||
}
|
||||
catch(Exc e) {
|
||||
ShowExc(e);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateDefaultHTML()
|
||||
{
|
||||
RichBook book;
|
||||
DefaultBook()(book);
|
||||
try {
|
||||
RichBookHtml html;
|
||||
CreateHelpHtml(book, html);
|
||||
}
|
||||
catch(Exc e) {
|
||||
ShowExc(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ManualMenu()
|
||||
{
|
||||
MenuBar menu;
|
||||
bool isdb = DefaultBook();
|
||||
menu.Add(isdb, t_("Print manual"), callback(&CreateDefaultBook));
|
||||
menu.Add(isdb, t_("PDF export"), callback(&CreateDefaultPDF));
|
||||
menu.Add(isdb, t_("RTF export"), callback(&CreateDefaultRTF));
|
||||
menu.Add(isdb, t_("HTML export"), callback(&CreateDefaultHTML));
|
||||
menu.Execute();
|
||||
}
|
||||
|
||||
void HelpBookMenu(Bar& bar)
|
||||
{
|
||||
bar.Add(t_("Save manual"), CtrlImg::save(), callback(&ManualMenu));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
#ifndef _RichBook_RichBook_h
|
||||
#define _RichBook_RichBook_h
|
||||
|
||||
#include <RichText/RichText.h>
|
||||
|
||||
namespace Upp {
|
||||
|
||||
RichPara::FieldType& FieldTypeVar();
|
||||
Id FieldTypeVarID();
|
||||
|
||||
class RichIndexEntry : DeepCopyOption<RichIndexEntry>
|
||||
{
|
||||
public:
|
||||
RichIndexEntry() {}
|
||||
RichIndexEntry(const RichIndexEntry& rti, bool deep) : reflist(rti.reflist, deep) {}
|
||||
|
||||
public:
|
||||
Vector<String> reflist;
|
||||
};
|
||||
|
||||
RichPara::FieldType& FieldTypeIndexEntry();
|
||||
Id FieldTypeIndexEntryID();
|
||||
String EncodeIndexEntry(const RichIndexEntry& idx);
|
||||
RichIndexEntry DecodeIndexEntry(String encoded_indexentry);
|
||||
|
||||
class RichBookSection {
|
||||
public:
|
||||
RichBookSection();
|
||||
|
||||
Rect GetPageRect(Size pagesize) const;
|
||||
Rect GetTextRect(Size pagesize, int columnindex) const;
|
||||
Size GetTextSize(Size pagesize) const;
|
||||
|
||||
public:
|
||||
bool nested;
|
||||
int columns;
|
||||
int firstpage;
|
||||
Rect margin;
|
||||
int header_space;
|
||||
int footer_space;
|
||||
int column_space;
|
||||
String header[3], footer[3];
|
||||
RichPara::CharFormat charformat;
|
||||
};
|
||||
|
||||
class RichPrintSection : public RichBookSection {
|
||||
public:
|
||||
RichPrintSection(const RichBookSection& s, pick_ RichText& t)
|
||||
: RichBookSection(s), text(t) {}
|
||||
|
||||
Vector<Drawing> Print(Size pagesize, Gate2<int, int> progress, int& progress_pos) const;
|
||||
|
||||
public:
|
||||
RichText text;
|
||||
};
|
||||
|
||||
class RichTocEntry {
|
||||
public:
|
||||
RichTocEntry(String topic = Null, int level = 1, bool numbered = true, bool appendix = false, WString text = Null)
|
||||
: topic(topic), level(level), numbered(numbered), text(text) {}
|
||||
|
||||
String topic;
|
||||
int level;
|
||||
bool numbered;
|
||||
bool appendix;
|
||||
WString text;
|
||||
};
|
||||
|
||||
class RichToc : DeepCopyOption<RichToc> {
|
||||
public:
|
||||
RichToc() {}
|
||||
RichToc(const RichToc& rtoc, int deep) : entries(rtoc.entries, deep) {}
|
||||
|
||||
void Add(String topic, int level, bool numbered = true, bool appendix = false, WString text = Null)
|
||||
{ entries.Add(new RichTocEntry(topic, level, numbered, appendix, text)); }
|
||||
|
||||
Array<RichTocEntry> entries;
|
||||
};
|
||||
|
||||
void MakeOnlineToc(RichText& out, const RichToc& toc);
|
||||
void MakeStdToc(RichText& out, const RichToc& toc, int print_width);
|
||||
void MakeTocTopics(RichText& out, const RichToc& toc);
|
||||
//RichText MakeStdIndex(
|
||||
|
||||
class RichBook {
|
||||
public:
|
||||
RichBook(Size page_size = Size(3968, 6074));
|
||||
|
||||
RichPrintSection& AddSection();
|
||||
|
||||
Vector<Drawing> Print(Size pagesize, Gate2<int, int> progress);
|
||||
|
||||
public:
|
||||
Size page_size;
|
||||
RichBookSection default_section;
|
||||
RichStyles default_styles;
|
||||
enum { TOC_DEPTH = 4 };
|
||||
Array<RichPrintSection> sections;
|
||||
};
|
||||
|
||||
void CreateHelpBook(RichBook& book);
|
||||
String CreateHelpPDF(RichBook& book);
|
||||
String CreateHelpRTF(RichBook& book, byte charset);
|
||||
|
||||
class RichBookHtml {
|
||||
public:
|
||||
RichBookHtml();
|
||||
|
||||
void AddFile(String url, String data);
|
||||
void AddImage(String url, String data);
|
||||
String GetURLFile(String url) const;
|
||||
|
||||
public:
|
||||
String output_path;
|
||||
enum { STYLE_DEEP, STYLE_FLAT, STYLE_ONEFILE };
|
||||
int style;
|
||||
VectorMap<String, String> files;
|
||||
VectorMap<String, String> images;
|
||||
};
|
||||
|
||||
void CreateHelpHtml(const RichBook& book, RichBookHtml& html);
|
||||
|
||||
Callback1<RichBook&>& DefaultBook();
|
||||
|
||||
void CreateDefaultBook();
|
||||
void CreateDefaultPDF();
|
||||
void CreateDefaultRTF();
|
||||
void CreateDefaultHTML();
|
||||
|
||||
void HelpBookMenu(Bar& bar);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
|
||||
// RichBook.cpp
|
||||
|
||||
T_("Typesetting page %d...")
|
||||
csCZ("Sázím stranu %d...")
|
||||
|
||||
T_("Printing page %d...")
|
||||
csCZ("Tisknu stranu %d...")
|
||||
|
||||
T_("Typesetting...")
|
||||
csCZ("Sázím...")
|
||||
|
||||
T_("Exporting PDF...")
|
||||
csCZ("Exportuji PDF...")
|
||||
|
||||
T_("PDF documents (*.pdf)")
|
||||
csCZ("Dokumenty PDF (*.pdf)")
|
||||
|
||||
T_("PDF export")
|
||||
csCZ("Export PDF")
|
||||
|
||||
T_("Rich text documents (*.rtf)")
|
||||
csCZ("Dokumenty Rich text (*.rtf)")
|
||||
|
||||
T_("Save manual as")
|
||||
csCZ("Uložit pøíruèku jako")
|
||||
|
||||
T_("Print manual")
|
||||
csCZ("Tisk pøíruèky")
|
||||
|
||||
T_("RTF export")
|
||||
csCZ("Export do RTF")
|
||||
|
||||
T_("HTML export")
|
||||
csCZ("Export do HTML")
|
||||
|
||||
T_("Save manual")
|
||||
csCZ("Uložit pøíruèku")
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
uses
|
||||
RichText,
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
RichBook.h,
|
||||
RichBook_init.icpp,
|
||||
RichBook.t,
|
||||
RichBook.cpp;
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#include "RichBook.h"
|
||||
|
||||
namespace Upp {
|
||||
|
||||
#define TFILE <RichBook/RichBook.t>
|
||||
#include <Core/t.h>
|
||||
|
||||
}
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <winver.h>
|
||||
#include <imagehlp.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define DLLFILENAME "imagehlp.dll"
|
||||
#define DLIHEADER "imagehlp.dli"
|
||||
#define DLIMODULE Imagehlp
|
||||
#include <Core/dli.h>
|
||||
|
||||
String AnalyzeMap(String fn)
|
||||
{
|
||||
Vector<unsigned> len;
|
||||
Vector<String> name;
|
||||
String map = LoadFile(fn);
|
||||
if(IsNull(map))
|
||||
return "can't open " + fn;
|
||||
const char *p = map;
|
||||
while(*p)
|
||||
if(*p++ == '\n' && !memcmp(p, " 0001:", 6)) {
|
||||
p += 5;
|
||||
while(IsXDigit(*++p))
|
||||
;
|
||||
while(*p == ' ')
|
||||
p++;
|
||||
const char *b = p;
|
||||
while((byte)*p > ' ')
|
||||
p++;
|
||||
const char *e = p;
|
||||
while(*p == ' ')
|
||||
p++;
|
||||
if(e > b && IsXDigit(*p)) {
|
||||
unsigned addr = strtoul(p, 0, 16);
|
||||
if(len.GetCount())
|
||||
len.Top() = addr - len.Top();
|
||||
len.Add(addr);
|
||||
name.Add(String(b, e));
|
||||
}
|
||||
|
||||
}
|
||||
// if(len.GetCount())
|
||||
// len.Top() -= addr;
|
||||
IndexSort(len, name, StdGreater<unsigned>());
|
||||
String r;
|
||||
for(int i = 0; i < len.GetCount(); i++) {
|
||||
r << Sprintf("%5d: ", len[i]);
|
||||
if(Imagehlp()) {
|
||||
char nm[1024];
|
||||
Imagehlp().UnDecorateSymbolName(name[i], nm, 1024, UNDNAME_NO_ACCESS_SPECIFIERS|
|
||||
UNDNAME_NO_MEMBER_TYPE|UNDNAME_NO_MS_KEYWORDS);
|
||||
r << nm;
|
||||
}
|
||||
else
|
||||
r << name[i];
|
||||
r << '\n';
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
class MapAnalyzer : public TopWindow {
|
||||
public:
|
||||
typedef MapAnalyzer CLASSNAME;
|
||||
MapAnalyzer();
|
||||
|
||||
void Run();
|
||||
|
||||
bool OpenFile();
|
||||
|
||||
virtual bool Key(dword key, int repcnt);
|
||||
|
||||
void LoadCrashFile();
|
||||
|
||||
private:
|
||||
LineEdit map;
|
||||
};
|
||||
|
||||
MapAnalyzer::MapAnalyzer()
|
||||
{
|
||||
Sizeable().Zoomable();
|
||||
Add(map.SizePos());
|
||||
}
|
||||
|
||||
void MapAnalyzer::Run()
|
||||
{
|
||||
if(!OpenFile())
|
||||
return;
|
||||
TopWindow::Run();
|
||||
}
|
||||
|
||||
bool MapAnalyzer::Key(dword key, int repcnt)
|
||||
{
|
||||
if(key == K_CTRL_O) {
|
||||
OpenFile();
|
||||
return true;
|
||||
}
|
||||
return TopWindow::Key(key, repcnt);
|
||||
}
|
||||
|
||||
bool MapAnalyzer::OpenFile()
|
||||
{
|
||||
FileSel fs;
|
||||
LoadFromFile(fs);
|
||||
fs.Type("Map file", "*.map");
|
||||
fs.DefaultExt("map");
|
||||
fs.Multi();
|
||||
if(!fs.ExecuteOpen()) return false;
|
||||
StoreToFile(fs);
|
||||
map <<= AnalyzeMap(~fs);
|
||||
return true;
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
SetDefaultCharset(CHARSET_WIN1250);
|
||||
MapAnalyzer viewer;
|
||||
viewer.Run();
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
description "Utility to analyze .map files\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
imagehlp.dli,
|
||||
Analyze.cpp,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 974 B |
|
|
@ -1,313 +0,0 @@
|
|||
# Microsoft Developer Studio Generated NMAKE File, Based on crash.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=crash - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to crash - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "crash - Win32 Release" && "$(CFG)" != "crash - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "crash.mak" CFG="crash - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "crash - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "crash - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "c:\tools\crash.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "VLib - Win32 Release" "tlib - Win32 Release" "tgui - Win32 Release" "CtrlLib - Win32 Release" "c:\tools\crash.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(RECURSE)" == "1"
|
||||
CLEAN :"CtrlLib - Win32 ReleaseCLEAN" "tgui - Win32 ReleaseCLEAN" "tlib - Win32 ReleaseCLEAN" "VLib - Win32 ReleaseCLEAN"
|
||||
!ELSE
|
||||
CLEAN :
|
||||
!ENDIF
|
||||
-@erase "$(INTDIR)\crash.obj"
|
||||
-@erase "$(INTDIR)\crash.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "c:\tools\crash.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP_PROJ=/nologo /MT /W3 /GR /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\crash.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC_PROJ=/l 0x405 /fo"$(INTDIR)\crash.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\crash.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=/nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\crash.pdb" /machine:I386 /out:"c:/tools/crash.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\crash.obj" \
|
||||
"$(INTDIR)\crash.res" \
|
||||
"..\CtrlLib\Release\CtrlLib.lib" \
|
||||
"E:\build\tgui\Release\tgui.lib" \
|
||||
"E:\build\tlib\Release\tlib.lib" \
|
||||
"..\VLib\Release\VLib.lib"
|
||||
|
||||
"c:\tools\crash.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\crash.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "VLib - Win32 Debug" "tlib - Win32 Debug" "tgui - Win32 Debug" "CtrlLib - Win32 Debug" "$(OUTDIR)\crash.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(RECURSE)" == "1"
|
||||
CLEAN :"CtrlLib - Win32 DebugCLEAN" "tgui - Win32 DebugCLEAN" "tlib - Win32 DebugCLEAN" "VLib - Win32 DebugCLEAN"
|
||||
!ELSE
|
||||
CLEAN :
|
||||
!ENDIF
|
||||
-@erase "$(INTDIR)\crash.obj"
|
||||
-@erase "$(INTDIR)\crash.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\crash.exe"
|
||||
-@erase "$(OUTDIR)\crash.ilk"
|
||||
-@erase "$(OUTDIR)\crash.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP_PROJ=/nologo /MTd /W3 /Gm /GR /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\crash.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC_PROJ=/l 0x405 /fo"$(INTDIR)\crash.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\crash.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=/nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\crash.pdb" /debug /machine:I386 /out:"$(OUTDIR)\crash.exe" /pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\crash.obj" \
|
||||
"$(INTDIR)\crash.res" \
|
||||
"..\CtrlLib\Debug\CtrlLib.lib" \
|
||||
"E:\build\tgui\Debug\tgui.lib" \
|
||||
"E:\build\tlib\Debug\tlib.lib" \
|
||||
"..\VLib\Debug\VLib.lib"
|
||||
|
||||
"$(OUTDIR)\crash.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("crash.dep")
|
||||
!INCLUDE "crash.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "crash.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release" || "$(CFG)" == "crash - Win32 Debug"
|
||||
SOURCE=.\crash.cpp
|
||||
|
||||
"$(INTDIR)\crash.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\crash.rc
|
||||
|
||||
"$(INTDIR)\crash.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"CtrlLib - Win32 Release" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Release"
|
||||
cd "..\crash"
|
||||
|
||||
"CtrlLib - Win32 ReleaseCLEAN" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Release" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"CtrlLib - Win32 Debug" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Debug"
|
||||
cd "..\crash"
|
||||
|
||||
"CtrlLib - Win32 DebugCLEAN" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Debug" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"tgui - Win32 Release" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Release"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tgui - Win32 ReleaseCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Release" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"tgui - Win32 Debug" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Debug"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tgui - Win32 DebugCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Debug" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"tlib - Win32 Release" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Release"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tlib - Win32 ReleaseCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Release" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"tlib - Win32 Debug" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Debug"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tlib - Win32 DebugCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Debug" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"VLib - Win32 Release" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Release"
|
||||
cd "..\crash"
|
||||
|
||||
"VLib - Win32 ReleaseCLEAN" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Release" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"VLib - Win32 Debug" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Debug"
|
||||
cd "..\crash"
|
||||
|
||||
"VLib - Win32 DebugCLEAN" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Debug" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
|
@ -1 +0,0 @@
|
|||
FN_C(DWORD, __stdcall, UnDecorateSymbolName, (PCSTR dn, PSTR udn, DWORD len, DWORD Flags))
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
// This is diagnostic package:
|
||||
// It compiles all U++ examples using MSC8 and MINGW build methods
|
||||
// or methods listed on commandline
|
||||
|
||||
String input = "c:/upp.src";
|
||||
String output = "c:/upp/all";
|
||||
String umk = "c:\\upp\\umk.exe ";
|
||||
Vector<String> bm;
|
||||
|
||||
bool failed;
|
||||
|
||||
const char *exclude[] = {
|
||||
"SDLEXAMPLE", "OLECALC", // REACTIVATE LATER
|
||||
"LOG:R",
|
||||
"WINFB", "LINUXFB", "FRAMEBUFFER", "COUNTER", "REGEXPEXT",
|
||||
#ifdef PLATFORM_WIN32
|
||||
"SQL_MYSQL",
|
||||
#endif
|
||||
#ifdef PLATFORM_LINUX
|
||||
"SQL_MSSQL", "CAPTURESCREENDLL", "UWORD_FB", "ODBCTST", "WMF"
|
||||
#endif
|
||||
};
|
||||
|
||||
bool IsIgnored(const String& name)
|
||||
{
|
||||
return Find(exclude, exclude + __countof(exclude), ToUpper(name));
|
||||
}
|
||||
|
||||
void Build(const char *nest, const char *bm, bool release)
|
||||
{
|
||||
String flags = release ? "r" : "b";
|
||||
String mn = release ? "R" : "D";
|
||||
String n = String().Cat() << nest << '-' << bm << '-' << mn;
|
||||
Cout() << n << '\n';
|
||||
String outdir = AppendFileName(output, n);
|
||||
DeleteFolderDeep(outdir);
|
||||
RealizeDirectory(outdir);
|
||||
FindFile ff(AppendFileName(AppendFileName(input, nest), "*.*"));
|
||||
bool first = true;
|
||||
while(ff) {
|
||||
String name = ff.GetName();
|
||||
if(ff.IsFolder() && !ff.IsHidden() &&
|
||||
!IsIgnored(name) && !IsIgnored(name + ":" + mn) && !IsIgnored(String(nest) + ':' + name + ':' + mn)) {
|
||||
String txt;
|
||||
txt << nest << ' ' << name << ' ' << bm << ' ' << mn;
|
||||
String c;
|
||||
c << umk << nest << ' ' << name << ' ' << bm << " -" << flags;
|
||||
if(first)
|
||||
c << 'a';
|
||||
#ifdef PLATFORM_POSIX
|
||||
c << 's';
|
||||
#endif
|
||||
c << ' ' << outdir;
|
||||
Cout() << c;
|
||||
String out;
|
||||
if(Sys(c, out)) {
|
||||
Cout() << " *** FAILED *** !\n";
|
||||
failed = true;
|
||||
LOG("FAILED: " << txt);
|
||||
LOG(c);
|
||||
LOG(out);
|
||||
}
|
||||
else {
|
||||
Cout() << " ok\n";
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
DeleteFile(AppendFileName(outdir, ff.GetName() + ".ilk"));
|
||||
DeleteFile(AppendFileName(outdir, ff.GetName() + ".pdb"));
|
||||
ff.Next();
|
||||
}
|
||||
}
|
||||
|
||||
void Build(const char *nest, bool release)
|
||||
{
|
||||
for(int i = 0; i < bm.GetCount(); i++)
|
||||
Build(nest, bm[i], release);
|
||||
}
|
||||
|
||||
void Build(const char *nest)
|
||||
{
|
||||
Build(nest, false);
|
||||
// Build(nest, true);
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
#ifdef PLATFORM_POSIX
|
||||
input = GetHomeDirFile("upp.src");
|
||||
output = GetHomeDirFile("tstout");
|
||||
umk = GetHomeDirFile("bin/umk") + ' ';
|
||||
#endif
|
||||
|
||||
LOG("BuildAll started");
|
||||
const Vector<String>& arg = CommandLine();
|
||||
input = GetFileFolder(GetFileFolder(GetFileFolder(GetDataFile("BuildAll.cpp"))));
|
||||
for(int i = 0; i < arg.GetCount(); i++)
|
||||
bm.Add(arg[i]);
|
||||
if(bm.GetCount() == 0) {
|
||||
// bm.Add("MSC71cdb");
|
||||
#ifdef PLATFORM_POSIX
|
||||
bm.Add("GCC");
|
||||
#else
|
||||
bm.Add("MSC9");
|
||||
#endif
|
||||
// bm.Add("MINGWI2");
|
||||
}
|
||||
Build("examples");
|
||||
Build("reference");
|
||||
Build("tutorial");
|
||||
Build("upptst", false);
|
||||
if(failed) {
|
||||
Cout() << "THERE WERE ERRORS!\n";
|
||||
SetExitCode(1);
|
||||
}
|
||||
else {
|
||||
Cout() << "OK.\n";
|
||||
LOG("OK");
|
||||
}
|
||||
// RDUMPC(failed);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
description "Utility that builds all U++ examples\377";
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
BuildAll.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
description "Utility to generate (long and repetitive) callback C++ source files\377";
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
CppGen.cpp,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
mainconfig
|
||||
"Normal" = "";
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
|
|
@ -1,401 +0,0 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
String If(String s, String txt)
|
||||
{
|
||||
return IsNull(s) ? String() : txt;
|
||||
}
|
||||
|
||||
void CallbackGen(String name, String rettype, int n, String extension, String atest = Null)
|
||||
{
|
||||
LOG("// -----------------------------------------------------------");
|
||||
String classdef, classlist, paramdef, paramlist;
|
||||
for(int i = 1; i <= n; i++) {
|
||||
if(i > 1) {
|
||||
classdef << ", ";
|
||||
classlist << ", ";
|
||||
paramdef << ", ";
|
||||
paramlist << ", ";
|
||||
}
|
||||
classdef << Format("class P%d", i);
|
||||
classlist << Format("P%d", i);
|
||||
paramdef << Format("P%d p%d", i, i);
|
||||
paramlist << Format("p%d", i);
|
||||
}
|
||||
String cl_list = If(classlist, "<" + classlist + ">");
|
||||
String cl_temp = String("template <class OBJECT, class METHOD").Cat() << If(classdef, ", " + classdef) << ">";
|
||||
String return_ = rettype == "void" ? "" : "return ";
|
||||
String name_cl = name + cl_list;
|
||||
LOG("");
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("struct " << name << "Action {");
|
||||
LOGBEGIN();
|
||||
LOG("Atomic count;");
|
||||
LOG("");
|
||||
LOG("virtual " << rettype << " Execute(" + paramdef + ") = 0;");
|
||||
LOG("virtual bool IsValid() const { return true; }");
|
||||
// LOG("virtual bool IsEqual(const " << name << "Action *other) const = 0;");
|
||||
// LOG("virtual unsigned GetHashValue() const = 0;");
|
||||
LOG("");
|
||||
LOG(name << "Action() { count = 1; }");
|
||||
LOG("virtual ~" << name << "Action() {}");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("");
|
||||
|
||||
LOG("#ifdef HAS_LAMBDA");
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("struct Lambda" << name << " : public " << name << "Action" << cl_list + " {");
|
||||
LOGBEGIN();
|
||||
LOG("std::function<" << rettype << " (" << classlist << ")> fn;");
|
||||
if(rettype == "void")
|
||||
LOG("virtual void Execute(" << paramdef << ") { fn(" << paramlist << "); }");
|
||||
else
|
||||
LOG("virtual " << rettype << " Execute(" << paramdef << ") { return fn(" << paramlist << "); }");
|
||||
LOG("");
|
||||
LOG("Lambda" << name << "(std::function<" << rettype << " (" << classlist << ")> fn) : fn(fn) {}");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("#endif");
|
||||
LOG("");
|
||||
|
||||
#if 0
|
||||
LOG(cl_temp);
|
||||
LOG("struct " << name << "MethodActionPte : public " << name << "Action" << cl_list + " {");
|
||||
LOGBEGIN();
|
||||
LOG("Ptr<OBJECT> object;");
|
||||
LOG("METHOD method;");
|
||||
LOG("");
|
||||
if(rettype == "void")
|
||||
LOG(rettype << " Execute(" << paramdef << ") { if(object) (object->*method)(" << paramlist << "); }");
|
||||
else
|
||||
LOG(rettype << " Execute(" << paramdef << ") { return object ? (object->*method)(" << paramlist << ") : false; }");
|
||||
LOG("bool IsValid() const { return object; }");
|
||||
// LOG("bool IsEqual(const " << name << "Action" << cl_list << " *other) const {");
|
||||
// LOGBEGIN();
|
||||
// LOG("const " << name << "MethodActionPte *q = dynamic_cast<const " << name <<
|
||||
// "MethodActionPte *>(other);");
|
||||
// LOG("return q ? q->object == object && q->method == method : false;");
|
||||
// LOGEND();
|
||||
// LOG("}");
|
||||
// LOG("unsigned GetHashValue() const {");
|
||||
// LOG("\treturn (unsigned)(uintptr_t)~object ^ (unsigned)brutal_cast<uintptr_t>(method);");
|
||||
// LOG("}");
|
||||
LOG("");
|
||||
LOG(name << "MethodActionPte(OBJECT *object, METHOD method) "
|
||||
": object(object), method(method) {}");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("");
|
||||
|
||||
LOG(cl_temp);
|
||||
LOG("struct " << name << "MethodAction : public " << name << "Action" << cl_list + " {");
|
||||
LOGBEGIN();
|
||||
LOG("OBJECT *object;");
|
||||
LOG("METHOD method;");
|
||||
LOG("");
|
||||
LOG(rettype << " Execute(" << paramdef << ") { " <<
|
||||
return_ << "(object->*method)(" << paramlist << "); }");
|
||||
/* LOG("bool IsEqual(const " << name << "Action" << cl_list << " *other) const {");
|
||||
LOGBEGIN();
|
||||
LOG("const " << name << "MethodAction *q = dynamic_cast<const " << name <<
|
||||
"MethodAction *>(other);");
|
||||
LOG("return q ? q->object == object && q->method == method : false;");
|
||||
LOGEND();
|
||||
LOG("}");
|
||||
LOG("unsigned GetHashValue() const {");
|
||||
LOG("\treturn (unsigned)(uintptr_t)object ^ (unsigned)brutal_cast<uintptr_t>(method);");
|
||||
LOG("}");
|
||||
*/ LOG("");
|
||||
LOG(name << "MethodAction(OBJECT *object, METHOD method) "
|
||||
": object(object), method(method) {}");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("");
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("struct " << name << "FnAction : public " << name << "Action" << cl_list << " {");
|
||||
LOGBEGIN();
|
||||
LOG(rettype << " (*fn)(" << paramdef << ");");
|
||||
LOG("");
|
||||
LOG(rettype << " Execute(" << paramdef << ") { " << return_ << "(*fn)(" <<
|
||||
paramlist << "); }");
|
||||
/* LOG("bool IsEqual(const " << name << "Action" << cl_list << " *other) const {");
|
||||
LOGBEGIN();
|
||||
LOG("const " << name << "FnAction *q = dynamic_cast<const " << name <<
|
||||
"FnAction *>(other);");
|
||||
LOG("return q ? q->fn == fn : false;");
|
||||
LOGEND();
|
||||
LOG("}");
|
||||
LOG("unsigned GetHashValue() const {");
|
||||
LOG("\treturn (unsigned)(uintptr_t)fn;");
|
||||
LOG("}");
|
||||
*/ LOG("");
|
||||
LOG(name << "FnAction(" << rettype << " (*fn)(" << paramdef << ")) : fn(fn) {}");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("");
|
||||
#endif
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("class " << name << " : Moveable< " << name_cl << " > {");
|
||||
LOGBEGIN();
|
||||
LOG(name << "Action" << cl_list << " *action;");
|
||||
LOG("");
|
||||
LOG("void Retain() const { if(action " << atest << ") AtomicInc(action->count); }");
|
||||
LOG("void Release() { if(action " << atest << " && AtomicDec(action->count) == 0) delete action; }");
|
||||
LOG("");
|
||||
LOG("bool operator==(const " << name << "&);");
|
||||
LOG("bool operator!=(const " << name << "&);");
|
||||
LOG("");
|
||||
LOGEND();
|
||||
LOG("public:");
|
||||
LOGBEGIN();
|
||||
LOG("typedef " << name << " CLASSNAME;");
|
||||
LOG("");
|
||||
LOG(name << "& operator=(const " << name << "& c);");
|
||||
LOG(name << "(const " << name << "& c);");
|
||||
LOG("void Clear() { Release(); action = NULL; }");
|
||||
LOG("");
|
||||
// LOG("unsigned GetHashValue() const { return action->GetHashValue(); }");
|
||||
LOG("");
|
||||
LOG(extension);
|
||||
LOG("");
|
||||
LOG("explicit " << name << "(" << name << "Action " << cl_list <<
|
||||
" *newaction) { action = newaction; }");
|
||||
// LOG(name << "& operator=(" << name << "Action" << cl_list <<
|
||||
// " *newaction) { action = newaction; return *this; }");
|
||||
LOG(name << "() { action = NULL; }");
|
||||
LOG(name << "(_CNULL) { action = NULL; }");
|
||||
LOG("~" << name << "();");
|
||||
LOGEND();
|
||||
LOG("#ifdef HAS_LAMBDA");
|
||||
LOGBEGIN();
|
||||
LOG(name << "& operator=(std::function<" << rettype << " (" << classlist << ")> l) { Clear(); action = new Lambda" << name << "<" << classlist << ">(l); return *this; }");
|
||||
LOGEND();
|
||||
LOG("#endif");
|
||||
LOGBEGIN();
|
||||
LOG("");
|
||||
LOG("static " << name << " Empty() { return CNULL; }");
|
||||
LOG("");
|
||||
// LOG("friend bool operator==(const " << name << "& a, const " << name << "& b)");
|
||||
// LOG("\t{ return a.action ? a.action->IsEqual(b.action) : !b.action; }");
|
||||
// LOG("friend bool operator!=(const " << name << "& a, const " << name << " & b)");
|
||||
// LOG("\t{ return !(a == b); }");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("");
|
||||
|
||||
#if 0
|
||||
LOG(cl_temp);
|
||||
LOG(name_cl << " pteback(OBJECT *object, " << rettype <<
|
||||
" (METHOD::*method)(" << paramdef << ")) {");
|
||||
LOG("\treturn " << name_cl <<
|
||||
"(new " << name << "MethodActionPte<OBJECT, " << rettype << " (METHOD::*)(" <<
|
||||
paramdef << ")" << If(classlist, ", " + classlist) << ">(object, method));");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
LOG(cl_temp);
|
||||
LOG(name_cl << " callback(OBJECT *object, " << rettype <<
|
||||
" (METHOD::*method)(" << paramdef << ")) {");
|
||||
LOG("\treturn " << name_cl <<
|
||||
"(new " << name << "MethodAction<OBJECT, " << rettype << " (METHOD::*)(" <<
|
||||
paramdef << ")" << If(classlist, ", " + classlist) << ">(object, method));");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
LOG(cl_temp);
|
||||
LOG(name_cl << " callback(const OBJECT *object, " << rettype <<
|
||||
" (METHOD::*method)(" << paramdef << ") const) {");
|
||||
LOG("\treturn " << name_cl <<
|
||||
"(new " << name << "MethodAction<const OBJECT, " << rettype << " (METHOD::*)("
|
||||
<< paramdef << ") const" << If(classlist, ", " + classlist) << ">(object, method));");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("inline " << name_cl << " callback(" << rettype << " (*fn)(" << paramdef << ")) {");
|
||||
LOG("\treturn " << name_cl << "(new " << name << "FnAction " << cl_list << "(fn));");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("struct " << name << "ForkAction : public " << name << "Action" << cl_list << " {");
|
||||
LOGBEGIN();
|
||||
LOG(name_cl << " cb1, cb2;");
|
||||
LOG("");
|
||||
LOG(rettype << " Execute(" << paramdef << ") { cb1(" << paramlist <<
|
||||
"); " << return_ << "cb2(" << paramlist << "); }");
|
||||
// LOG("bool IsEqual(const " << name << "Action " << cl_list << " *other) const {");
|
||||
// LOG("\tconst " << name << "ForkAction *q = dynamic_cast<const " << name
|
||||
// << "ForkAction *>(other);");
|
||||
// LOG("\treturn q ? q->cb1 == cb1 && q->cb2 == cb2 : false;");
|
||||
// LOG("}");
|
||||
// LOG("unsigned GetHashValue() const {");
|
||||
// LOG("\treturn ::GetHashValue(cb1) ^ ::GetHashValue(cb2);");
|
||||
// LOG("}");
|
||||
LOG("");
|
||||
LOG(name << "ForkAction(" << name_cl << " cb1, " << name_cl << " cb2)"
|
||||
"\n\t : cb1(cb1), cb2(cb2) {}");
|
||||
LOGEND();
|
||||
LOG("};");
|
||||
LOG("");
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG("inline " << name_cl << " Proxy(" << name_cl << "& cb)");
|
||||
LOG("{");
|
||||
LOG("\treturn callback(&cb, &" << name_cl << "::Execute);");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
if(IsNull(classdef)) {
|
||||
LOG(name_cl << " callback(" << name_cl << " cb1, " << name_cl << " cb2);");
|
||||
LOG(name_cl << "& operator<<(" << name_cl << "& a, " << name_cl << " b);");
|
||||
LOG("");
|
||||
LOG("#endif");
|
||||
LOG("#ifdef CPP_PART__");
|
||||
LOG("");
|
||||
}
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG(name_cl << " callback(" << name_cl << " cb1, " << name_cl << " cb2)");
|
||||
LOG("{");
|
||||
LOG("\treturn " << name_cl << "(new " << name << "ForkAction " << cl_list << "(cb1, cb2));");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG(name_cl << "& operator<<(" << name_cl << "& a, " << name_cl << " b)");
|
||||
LOG("{");
|
||||
LOG("\tif(a)");
|
||||
LOG("\t\ta = callback(a, b);");
|
||||
LOG("\telse");
|
||||
LOG("\t\ta = b;");
|
||||
LOG("\treturn a;");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG(name_cl << "& " << name_cl << "::operator=(const " << name << "& c)");
|
||||
LOG("{");
|
||||
LOG("\tc.Retain();");
|
||||
LOG("\tRelease();");
|
||||
LOG("\taction = c.action;");
|
||||
LOG("\treturn *this;");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG(name_cl << "::" << name << "(const " << name << "& c)");
|
||||
LOG("{");
|
||||
LOG("\taction = c.action;");
|
||||
LOG("\tRetain();");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
if(!IsNull(classdef))
|
||||
LOG("template <" << classdef << ">");
|
||||
LOG(name_cl << "::~" << name << "()");
|
||||
LOG("{");
|
||||
LOG("\tRelease();");
|
||||
LOG("}");
|
||||
LOG("");
|
||||
if(IsNull(classdef)) {
|
||||
LOG("#endif");
|
||||
LOG("#ifndef CPP_PART__");
|
||||
LOG("");
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
LOG("#ifndef CPP_PART__");
|
||||
LOG("");
|
||||
|
||||
CallbackGen("Callback", "void", 0,
|
||||
"operator bool() const { return action && action->IsValid(); }\n"
|
||||
"void Execute() const;\n"
|
||||
"void operator()() const { Execute(); }"
|
||||
);
|
||||
CallbackGen("Callback1", "void", 1,
|
||||
"operator bool() const { return action && action->IsValid(); }\n"
|
||||
"void Execute(P1 p1) const { if(action) action->Execute(p1); }\n"
|
||||
"void operator()(P1 p1) const { Execute(p1); }"
|
||||
);
|
||||
CallbackGen("Callback2", "void", 2,
|
||||
"operator bool() const { return action && action->IsValid(); }\n"
|
||||
"void Execute(P1 p1, P2 p2) const { if(action) action->Execute(p1, p2); }\n"
|
||||
"void operator()(P1 p1, P2 p2) const { Execute(p1, p2); }"
|
||||
);
|
||||
CallbackGen("Callback3", "void", 3,
|
||||
"operator bool() const { return action && action->IsValid(); }\n"
|
||||
"void Execute(P1 p1, P2 p2, P3 p3) const { if(action) action->Execute(p1, p2, p3); }\n"
|
||||
"void operator()(P1 p1, P2 p2, P3 p3) const { Execute(p1, p2, p3); }"
|
||||
);
|
||||
CallbackGen("Callback4", "void", 4,
|
||||
"operator bool() const { return action && action->IsValid(); }\n"
|
||||
"void Execute(P1 p1, P2 p2, P3 p3, P4 p4) const { if(action) action->Execute(p1, p2, p3, p4); }\n"
|
||||
"void operator()(P1 p1, P2 p2, P3 p3, P4 p4) const { Execute(p1, p2, p3, p4); }"
|
||||
);
|
||||
|
||||
CallbackGen("Gate", "bool", 0,
|
||||
"operator bool() const { return (void *)action != (void *)1 && action && action->IsValid(); }\n"
|
||||
"bool Execute() const;\n"
|
||||
"bool operator()() const { return Execute(); }\n"
|
||||
"void ClearTrue() { Clear(); action = (GateAction *)1; }\n"
|
||||
"void ClearFalse() { Clear(); }\n\n"
|
||||
"Gate(bool b) { action = (GateAction *)(int)b; }",
|
||||
"&& (void *)action != (void *)1"
|
||||
);
|
||||
CallbackGen("Gate1", "bool", 1,
|
||||
"operator bool() const { return (void *)action != (void *)1 && action && action->IsValid(); }\n"
|
||||
"bool Execute(P1 p1) const;\n"
|
||||
"bool operator()(P1 p1) const { return Execute(p1); }\n"
|
||||
"void ClearTrue() { Clear(); action = (Gate1Action<P1> *)1; }\n"
|
||||
"void ClearFalse() { Clear(); }\n\n"
|
||||
"Gate1(bool b) { action = (Gate1Action<P1> *)(uintptr_t)b; }",
|
||||
"&& (void *)action != (void *)1"
|
||||
);
|
||||
CallbackGen("Gate2", "bool", 2,
|
||||
"operator bool() const { return (void *)action != (void *)1 && action && action->IsValid(); }\n"
|
||||
"bool Execute(P1 p1, P2 p2) const;\n"
|
||||
"bool operator()(P1 p1, P2 p2) const { return Execute(p1, p2); }\n"
|
||||
"void ClearTrue() { Clear(); action = (Gate2Action<P1, P2> *)1; }\n"
|
||||
"void ClearFalse() { Clear(); }\n\n"
|
||||
"Gate2(bool b) { action = (Gate2Action<P1, P2> *)(uintptr_t)b; }",
|
||||
"&& (void *)action != (void *)1"
|
||||
);
|
||||
CallbackGen("Gate3", "bool", 3,
|
||||
"operator bool() const { return (void *)action != (void *)1 && action && action->IsValid(); }\n"
|
||||
"bool Execute(P1 p1, P2 p2, P3 p3) const;\n"
|
||||
"bool operator()(P1 p1, P2 p2, P3 p3) const { return Execute(p1, p2, p3); }\n"
|
||||
"void ClearTrue() { Clear(); action = (Gate3Action<P1, P2, P3> *)1; }\n"
|
||||
"void ClearFalse() { Clear(); }\n\n"
|
||||
"Gate3(bool b) { action = (Gate3Action<P1, P2, P3> *)(uintptr_t)b; }",
|
||||
"&& (void *)action != (void *)1"
|
||||
);
|
||||
CallbackGen("Gate4", "bool", 4,
|
||||
"operator bool() const { return (void *)action != (void *)1 && action && action->IsValid(); }\n"
|
||||
"bool Execute(P1 p1, P2 p2, P3 p3, P4 p4) const;\n"
|
||||
"bool operator()(P1 p1, P2 p2, P3 p3, P4 p4) const { return Execute(p1, p2, p3, p4); }\n"
|
||||
"void ClearTrue() { Clear(); action = (Gate4Action<P1, P2, P3, P4> *)1; }\n"
|
||||
"void ClearFalse() { Clear(); }\n\n"
|
||||
"Gate4(bool b) { action = (Gate4Action<P1, P2, P3, P4> *)(uintptr_t)b; }",
|
||||
"&& (void *)action != (void *)1"
|
||||
);
|
||||
LOG("");
|
||||
LOG("#endif");
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
description "Utility to examine content of .crash and .map files\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
imagehlp.dli,
|
||||
crash.cpp,
|
||||
crash.iml,
|
||||
crash.rc,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <winver.h>
|
||||
#include <imagehlp.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define DLLFILENAME "imagehlp.dll"
|
||||
#define DLIHEADER "imagehlp.dli"
|
||||
#define DLIMODULE Imagehlp
|
||||
#include <Core/dli.h>
|
||||
|
||||
Vector<unsigned > address;
|
||||
Vector<String> name;
|
||||
String mapname;
|
||||
|
||||
void LoadMap(String fn)
|
||||
{
|
||||
String fpos = GetFileName(fn);
|
||||
int dp = fpos.Find('.');
|
||||
if(dp >= 0)
|
||||
fpos.Trim(dp);
|
||||
fn = AppendFileName(GetFileDirectory(fn), fpos) + ".map";
|
||||
if(mapname == fn)
|
||||
return;
|
||||
mapname = fn;
|
||||
address.Clear();
|
||||
name.Clear();
|
||||
String map = LoadFile(fn);
|
||||
if(IsNull(map))
|
||||
return;
|
||||
const char *p = map;
|
||||
while(*p)
|
||||
if(*p++ == '\n' && !memcmp(p, " 0001:", 6)) {
|
||||
p += 5;
|
||||
while(IsXDigit(*++p))
|
||||
;
|
||||
while(*p == ' ')
|
||||
p++;
|
||||
const char *b = p;
|
||||
while((byte)*p > ' ')
|
||||
p++;
|
||||
const char *e = p;
|
||||
while(*p == ' ')
|
||||
p++;
|
||||
if(e > b && IsXDigit(*p)) {
|
||||
unsigned addr = strtoul(p, 0, 16);
|
||||
address.Add(addr);
|
||||
name.Add(String(b, e));
|
||||
}
|
||||
}
|
||||
IndexSort(address, name, StdLess<unsigned>());
|
||||
}
|
||||
|
||||
String Fname(dword addr, bool& recognized) {
|
||||
int pos = BinFindIndex(address, addr + 1) - 1;
|
||||
String s;
|
||||
s.Cat(Format("0x%08x", (int)addr));
|
||||
if(pos >= 0) {
|
||||
dword off = addr - address[pos];
|
||||
if(off < 8000) {
|
||||
s << ": ";
|
||||
if(Imagehlp()) {
|
||||
char nm[1024];
|
||||
Imagehlp().UnDecorateSymbolName(name[pos], nm, 1024, UNDNAME_NO_ACCESS_SPECIFIERS|
|
||||
UNDNAME_NO_MEMBER_TYPE|UNDNAME_NO_MS_KEYWORDS);
|
||||
s << nm;
|
||||
}
|
||||
else
|
||||
s << name[pos];
|
||||
s << Format(" + 0x%x bytes", (int)off);
|
||||
recognized = true;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
s << " = " << Format("%d [%d, %d]", (int)addr, (int)LOWORD(addr), (int)HIWORD(addr));
|
||||
recognized = false;
|
||||
return s;
|
||||
}
|
||||
|
||||
String LoadCrashFile(String filename)
|
||||
{
|
||||
LoadMap(filename);
|
||||
FileIn in(filename);
|
||||
String text;
|
||||
text << "Crash log " << GetFileName(filename) << "\n";
|
||||
if(name.GetCount() == 0)
|
||||
text << "No mapfile found" << "\n";
|
||||
dword version;
|
||||
dword code, address;
|
||||
int npar;
|
||||
in % version;
|
||||
in % code % address % npar;
|
||||
Vector<dword> info;
|
||||
Vector<dword> stack;
|
||||
bool r;
|
||||
int i;
|
||||
while(npar--)
|
||||
in % info.Add();
|
||||
switch(code) {
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
text << "Access violation ";
|
||||
if(info.GetCount() >= 2)
|
||||
text << (info[0] ? "writing" : "reading") << Format(" at 0x%08x", (int)info[1]);
|
||||
break;
|
||||
#define MEX(id) case id: text << #id; break;
|
||||
MEX(EXCEPTION_DATATYPE_MISALIGNMENT)
|
||||
MEX(EXCEPTION_BREAKPOINT)
|
||||
MEX(EXCEPTION_SINGLE_STEP)
|
||||
MEX(EXCEPTION_ARRAY_BOUNDS_EXCEEDED)
|
||||
MEX(EXCEPTION_FLT_DENORMAL_OPERAND)
|
||||
MEX(EXCEPTION_FLT_DIVIDE_BY_ZERO)
|
||||
MEX(EXCEPTION_FLT_INEXACT_RESULT)
|
||||
MEX(EXCEPTION_FLT_INVALID_OPERATION)
|
||||
MEX(EXCEPTION_FLT_OVERFLOW)
|
||||
MEX(EXCEPTION_FLT_STACK_CHECK)
|
||||
MEX(EXCEPTION_FLT_UNDERFLOW)
|
||||
MEX(EXCEPTION_INT_DIVIDE_BY_ZERO)
|
||||
MEX(EXCEPTION_INT_OVERFLOW)
|
||||
MEX(EXCEPTION_PRIV_INSTRUCTION)
|
||||
MEX(EXCEPTION_IN_PAGE_ERROR)
|
||||
MEX(EXCEPTION_ILLEGAL_INSTRUCTION)
|
||||
MEX(EXCEPTION_NONCONTINUABLE_EXCEPTION)
|
||||
MEX(EXCEPTION_STACK_OVERFLOW)
|
||||
MEX(EXCEPTION_INVALID_DISPOSITION)
|
||||
MEX(EXCEPTION_GUARD_PAGE)
|
||||
MEX(EXCEPTION_INVALID_HANDLE)
|
||||
default:
|
||||
text << Format("Exception 0x%08x", (int)code);
|
||||
}
|
||||
text << '\n' << Fname(address, r) << '\n';
|
||||
while(!in.IsEof())
|
||||
in % stack.Add();
|
||||
text << "\nRecognized stack dwords:\n";
|
||||
for(i = 0; i < stack.GetCount(); i++) {
|
||||
String s = Fname(stack[i], r);
|
||||
if(r) text << "\t" << s << '\n';
|
||||
}
|
||||
text << "\nComplete stack:\n";
|
||||
for(i = 0; i < stack.GetCount(); i++)
|
||||
text << "\t" << Fname(stack[i], r) << '\n';
|
||||
return text;
|
||||
}
|
||||
|
||||
class CrashViewer : public TopWindow {
|
||||
public:
|
||||
typedef CrashViewer CLASSNAME;
|
||||
CrashViewer();
|
||||
|
||||
void Run();
|
||||
|
||||
bool OpenFile();
|
||||
|
||||
virtual bool Key(dword key, int repcnt);
|
||||
|
||||
void LoadCrashFile();
|
||||
|
||||
private:
|
||||
Splitter splitter;
|
||||
ArrayCtrl crashfiles;
|
||||
LineEdit crashdump;
|
||||
};
|
||||
|
||||
CrashViewer::CrashViewer()
|
||||
{
|
||||
Sizeable().Zoomable();
|
||||
splitter.Horz(crashfiles, crashdump);
|
||||
splitter.SetPos(3000);
|
||||
Add(splitter.SizePos());
|
||||
crashfiles.AutoHideSb().NoHeader();
|
||||
crashfiles.AddColumn();
|
||||
crashfiles.WhenCursor = THISBACK(LoadCrashFile);
|
||||
crashdump.SetFont(Courier(14));
|
||||
}
|
||||
|
||||
void CrashViewer::Run()
|
||||
{
|
||||
if(!OpenFile())
|
||||
return;
|
||||
LoadCrashFile();
|
||||
TopWindow::Run();
|
||||
}
|
||||
|
||||
bool CrashViewer::Key(dword key, int repcnt)
|
||||
{
|
||||
if(key == K_CTRL_O) {
|
||||
OpenFile();
|
||||
return true;
|
||||
}
|
||||
return TopWindow::Key(key, repcnt);
|
||||
}
|
||||
|
||||
bool CrashViewer::OpenFile()
|
||||
{
|
||||
FileSelector fs;
|
||||
LoadFromFile(fs);
|
||||
fs.Type("Crash file", "*.crash");
|
||||
fs.DefaultExt("crash");
|
||||
fs.Multi();
|
||||
if(!fs.ExecuteOpen()) return false;
|
||||
StoreToFile(fs);
|
||||
int newln = -1;
|
||||
for(int i = 0; i < fs.GetCount(); i++) {
|
||||
String path = fs[i];
|
||||
int f = crashfiles.Find(path);
|
||||
if(f < 0) {
|
||||
newln = crashfiles.GetCount();
|
||||
crashfiles.Add(path);
|
||||
}
|
||||
}
|
||||
if(newln >= 0)
|
||||
crashfiles.SetCursor(newln);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CrashViewer::LoadCrashFile()
|
||||
{
|
||||
String fn = Null;
|
||||
if(crashfiles.IsCursor())
|
||||
fn = crashfiles.Get(0);
|
||||
String title = fn;
|
||||
if(!IsNull(title))
|
||||
title << " - crash analyzer";
|
||||
else
|
||||
title << "Crash analyzer";
|
||||
Title(title);
|
||||
if(IsNull(fn))
|
||||
crashdump <<= Null;
|
||||
else
|
||||
crashdump <<= ::LoadCrashFile(fn);
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
SetDefaultCharset(CHARSET_WIN1250);
|
||||
CrashViewer viewer;
|
||||
viewer.Run();
|
||||
/*
|
||||
FileSelector fs;
|
||||
LoadFromFile(fs);
|
||||
fs.Type("Crash file", "*.crash");
|
||||
if(!fs.ExecuteOpen()) return;
|
||||
String text = LoadCrashFile(~fs);
|
||||
TopWindow win;
|
||||
win.Title("Crash analyzer - " + ~fs).Sizeable().Zoomable();
|
||||
win.Icon(Image::Icon(100, true), Image::Icon(100, false));
|
||||
LineEdit edit;
|
||||
edit.SetFont(Courier(14));
|
||||
edit <<= text;
|
||||
win.Add(edit.SizePos());
|
||||
win.Run();
|
||||
*/
|
||||
// StoreToFile(fs);
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 974 B |
|
|
@ -1,14 +0,0 @@
|
|||
PREMULTIPLIED
|
||||
IMAGE_ID(app_large)
|
||||
IMAGE_ID(app_small)
|
||||
|
||||
IMAGE_BEGIN_DATA
|
||||
IMAGE_DATA(120,156,229,150,91,14,132,48,8,69,89,194,44,193,165,186,115,102,162,153,153,22,41,143,66,91,19,49,124,244,193,61)
|
||||
IMAGE_DATA(183,24,83,97,131,13,162,177,3,96,153,97,65,39,79,203,85,220,76,31,81,118,175,135,44,110,143,143,81,108,171,135)
|
||||
IMAGE_DATA(149,252,209,108,201,195,44,118,203,195,74,254,108,54,245,240,100,126,57,70,60,147,142,203,57,109,141,211,224,106,189,115)
|
||||
IMAGE_DATA(146,230,119,156,197,178,156,81,242,57,227,252,52,91,181,220,222,81,253,143,188,19,173,119,214,247,239,237,63,192,179,191)
|
||||
IMAGE_DATA(255,59,240,87,120,0,18,171,249,51,61,112,236,89,30,36,246,29,248,35,61,88,216,35,124,120,185,153,30,34,236,136)
|
||||
IMAGE_DATA(143,44,174,213,79,183,208,235,243,40,17,61,76,70,125,175,198,113,217,58,234,233,190,223,133,78,214,208,144,103,61,179)
|
||||
IMAGE_DATA(70,52,43,93,186,118,140,1,46,63,80,194,153,254,251,160,145,214,122,100,180,116,15,151,61,149,134,163,190,234,35,214)
|
||||
IMAGE_DATA(222,53,141,86,95,105,111,133,122,147,47,134,37,133,135,231,169,247,106,176,241,6,223,11,189,79,0,0,0,0,0,0)
|
||||
IMAGE_END_DATA(256, 2)
|
||||
|
|
@ -1,313 +0,0 @@
|
|||
# Microsoft Developer Studio Generated NMAKE File, Based on crash.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=crash - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to crash - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "crash - Win32 Release" && "$(CFG)" != "crash - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "crash.mak" CFG="crash - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "crash - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "crash - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "c:\tools\crash.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "VLib - Win32 Release" "tlib - Win32 Release" "tgui - Win32 Release" "CtrlLib - Win32 Release" "c:\tools\crash.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(RECURSE)" == "1"
|
||||
CLEAN :"CtrlLib - Win32 ReleaseCLEAN" "tgui - Win32 ReleaseCLEAN" "tlib - Win32 ReleaseCLEAN" "VLib - Win32 ReleaseCLEAN"
|
||||
!ELSE
|
||||
CLEAN :
|
||||
!ENDIF
|
||||
-@erase "$(INTDIR)\crash.obj"
|
||||
-@erase "$(INTDIR)\crash.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "c:\tools\crash.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP_PROJ=/nologo /MT /W3 /GR /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\crash.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC_PROJ=/l 0x405 /fo"$(INTDIR)\crash.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\crash.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=/nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\crash.pdb" /machine:I386 /out:"c:/tools/crash.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\crash.obj" \
|
||||
"$(INTDIR)\crash.res" \
|
||||
"..\CtrlLib\Release\CtrlLib.lib" \
|
||||
"E:\build\tgui\Release\tgui.lib" \
|
||||
"E:\build\tlib\Release\tlib.lib" \
|
||||
"..\VLib\Release\VLib.lib"
|
||||
|
||||
"c:\tools\crash.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\crash.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "VLib - Win32 Debug" "tlib - Win32 Debug" "tgui - Win32 Debug" "CtrlLib - Win32 Debug" "$(OUTDIR)\crash.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(RECURSE)" == "1"
|
||||
CLEAN :"CtrlLib - Win32 DebugCLEAN" "tgui - Win32 DebugCLEAN" "tlib - Win32 DebugCLEAN" "VLib - Win32 DebugCLEAN"
|
||||
!ELSE
|
||||
CLEAN :
|
||||
!ENDIF
|
||||
-@erase "$(INTDIR)\crash.obj"
|
||||
-@erase "$(INTDIR)\crash.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\crash.exe"
|
||||
-@erase "$(OUTDIR)\crash.ilk"
|
||||
-@erase "$(OUTDIR)\crash.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP_PROJ=/nologo /MTd /W3 /Gm /GR /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\crash.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC_PROJ=/l 0x405 /fo"$(INTDIR)\crash.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\crash.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=/nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\crash.pdb" /debug /machine:I386 /out:"$(OUTDIR)\crash.exe" /pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\crash.obj" \
|
||||
"$(INTDIR)\crash.res" \
|
||||
"..\CtrlLib\Debug\CtrlLib.lib" \
|
||||
"E:\build\tgui\Debug\tgui.lib" \
|
||||
"E:\build\tlib\Debug\tlib.lib" \
|
||||
"..\VLib\Debug\VLib.lib"
|
||||
|
||||
"$(OUTDIR)\crash.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("crash.dep")
|
||||
!INCLUDE "crash.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "crash.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release" || "$(CFG)" == "crash - Win32 Debug"
|
||||
SOURCE=.\crash.cpp
|
||||
|
||||
"$(INTDIR)\crash.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\crash.rc
|
||||
|
||||
"$(INTDIR)\crash.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"CtrlLib - Win32 Release" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Release"
|
||||
cd "..\crash"
|
||||
|
||||
"CtrlLib - Win32 ReleaseCLEAN" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Release" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"CtrlLib - Win32 Debug" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Debug"
|
||||
cd "..\crash"
|
||||
|
||||
"CtrlLib - Win32 DebugCLEAN" :
|
||||
cd "\SOURCE\CtrlLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\CtrlLib.mak CFG="CtrlLib - Win32 Debug" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"tgui - Win32 Release" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Release"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tgui - Win32 ReleaseCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Release" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"tgui - Win32 Debug" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Debug"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tgui - Win32 DebugCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tgui.mak CFG="tgui - Win32 Debug" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"tlib - Win32 Release" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Release"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tlib - Win32 ReleaseCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Release" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"tlib - Win32 Debug" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Debug"
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
"tlib - Win32 DebugCLEAN" :
|
||||
E:
|
||||
cd "E:\V\TLIB"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\tlib.mak CFG="tlib - Win32 Debug" RECURSE=1 CLEAN
|
||||
F:
|
||||
cd "F:\SOURCE\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "crash - Win32 Release"
|
||||
|
||||
"VLib - Win32 Release" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Release"
|
||||
cd "..\crash"
|
||||
|
||||
"VLib - Win32 ReleaseCLEAN" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Release" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ELSEIF "$(CFG)" == "crash - Win32 Debug"
|
||||
|
||||
"VLib - Win32 Debug" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Debug"
|
||||
cd "..\crash"
|
||||
|
||||
"VLib - Win32 DebugCLEAN" :
|
||||
cd "\SOURCE\VLib"
|
||||
$(MAKE) /$(MAKEFLAGS) /F .\VLib.mak CFG="VLib - Win32 Debug" RECURSE=1 CLEAN
|
||||
cd "..\crash"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
|
@ -1 +0,0 @@
|
|||
100 ICON DISCARDABLE "crash.ico"
|
||||
|
|
@ -1 +0,0 @@
|
|||
FN_C(DWORD, __stdcall, UnDecorateSymbolName, (PCSTR dn, PSTR udn, DWORD len, DWORD Flags))
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
#include "Crypto.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
template <int N>
|
||||
class Birc {
|
||||
byte r[N];
|
||||
int origin;
|
||||
public:
|
||||
byte& operator[](int i) { return r[(origin + i) % N]; }
|
||||
void Restart() { origin = 0; }
|
||||
void Move() { origin = (origin + 1) % N; }
|
||||
|
||||
Birc() { origin = 0; }
|
||||
};
|
||||
|
||||
struct BscF {
|
||||
static byte T1[256];
|
||||
static const int Krok;
|
||||
|
||||
Birc<81> R81, Q81;
|
||||
byte IV[10], Wk[10]; /* MAC, Klic na zpr. */
|
||||
|
||||
void MAC_init();
|
||||
void R81_init();
|
||||
void MAC_step();
|
||||
byte R81_step();
|
||||
void R81_start();
|
||||
void MACDummy();
|
||||
void MACGen(const char *s, const char *lim);
|
||||
void Start();
|
||||
};
|
||||
|
||||
const int BscF::Krok = 101;
|
||||
|
||||
byte BscF::T1[256] = {
|
||||
32, 124, 29, 247, 230, 199, 244, 5, 86, 19, 125, 149, 108, 74, 237, 176,
|
||||
165, 82, 240, 236, 144, 154, 107, 131, 147, 66, 118, 116, 126, 250, 127, 23,
|
||||
232, 223, 243, 45, 83, 67, 216, 202, 33, 145, 62, 114, 61, 34, 205, 109,
|
||||
14, 6, 193, 238, 55, 196, 163, 182, 140, 8, 115, 222, 217, 191, 112, 73,
|
||||
142, 75, 214, 1, 59, 46, 239, 72, 164, 68, 180, 119, 209, 84, 152, 159,
|
||||
184, 36, 47, 99, 235, 212, 42, 38, 123, 26, 17, 97, 155, 22, 190, 175,
|
||||
64, 25, 94, 166, 183, 69, 234, 65, 195, 197, 77, 173, 20, 104, 63, 201,
|
||||
249, 15, 134, 122, 57, 204, 139, 0, 210, 174, 3, 2, 80, 135, 106, 213,
|
||||
56, 221, 172, 12, 162, 103, 188, 128, 9, 138, 137, 133, 54, 169, 100, 132,
|
||||
60, 28, 113, 141, 44, 255, 181, 111, 10, 117, 254, 160, 90, 218, 186, 30,
|
||||
48, 246, 79, 187, 37, 35, 53, 179, 129, 157, 146, 203, 177, 71, 27, 189,
|
||||
252, 229, 143, 130, 11, 78, 226, 105, 88, 101, 251, 24, 170, 7, 76, 41,
|
||||
198, 245, 208, 31, 21, 242, 89, 98, 225, 81, 219, 58, 96, 91, 215, 110,
|
||||
227, 93, 39, 220, 52, 211, 253, 85, 151, 70, 228, 233, 171, 148, 206, 121,
|
||||
248, 156, 241, 102, 207, 161, 192, 185, 120, 153, 4, 40, 136, 194, 50, 95,
|
||||
87, 168, 178, 13, 18, 200, 49, 167, 150, 92, 16, 51, 231, 224, 43, 158
|
||||
};
|
||||
|
||||
void BscF::MAC_init() {
|
||||
for(int i = 0; i < 81; i++)
|
||||
Q81[i] = T1[i];
|
||||
}
|
||||
|
||||
|
||||
void BscF::R81_init() {
|
||||
for(int i = 80; i >= 0; i--)
|
||||
R81[i] = T1[i];
|
||||
}
|
||||
|
||||
void BscF::MAC_step() {
|
||||
byte zvq81, neq81;
|
||||
neq81 = T1[Q81[80]];
|
||||
zvq81 = Q81[0];
|
||||
Q81.Move();
|
||||
Q81[80] = zvq81 ^ neq81;
|
||||
Q81[54] = Q81[54] ^ zvq81;
|
||||
Q81[49] = Q81[49] ^ zvq81;
|
||||
Q81[16] = Q81[16] ^ zvq81;
|
||||
}
|
||||
|
||||
byte BscF::R81_step() {
|
||||
byte zvr81, ner81;
|
||||
ner81 = T1[R81[80]];
|
||||
zvr81 = R81[0];
|
||||
R81.Move();
|
||||
R81[80] = zvr81 ^ ner81;
|
||||
R81[79] = R81[79] ^ zvr81;
|
||||
R81[48] = R81[48] ^ zvr81;
|
||||
R81[16] = R81[16] ^ zvr81;
|
||||
return ner81;
|
||||
}
|
||||
|
||||
void BscF::R81_start() {
|
||||
int i;
|
||||
for(i = 0; i < 81; i++) {
|
||||
R81_step();
|
||||
R81[80] = R81[80] ^ Wk[i % 10];
|
||||
}
|
||||
for(i = 0; i < Krok; i++)
|
||||
R81_step();
|
||||
}
|
||||
|
||||
void BscF::MACDummy() {
|
||||
for(int k = 0; k < Krok; k++)
|
||||
MAC_step();
|
||||
}
|
||||
|
||||
void BscF::MACGen(const char *s, const char *lim) {
|
||||
int i;
|
||||
MAC_init();
|
||||
while(s < lim) {
|
||||
MAC_step();
|
||||
Q81[80] = Q81[80] ^ *s++;
|
||||
}
|
||||
MACDummy();
|
||||
for(i = 0; i < 10; i++)
|
||||
IV[i] = Q81[80 - i];
|
||||
}
|
||||
|
||||
void BscF::Start() {
|
||||
R81_init();
|
||||
R81_start();
|
||||
}
|
||||
|
||||
String EncodeBscF(const String& src) {
|
||||
String result;
|
||||
BscF f;
|
||||
const char *lim = src.End();
|
||||
f.MACGen(src, lim);
|
||||
memcpy(f.Wk, f.IV, 10);
|
||||
f.Start();
|
||||
result.Cat((const char *)f.IV, 10);
|
||||
for(const char *s = src; s < lim; s++)
|
||||
result.Cat(*s ^ f.R81_step());
|
||||
for(int i = 0; i < 10; i++)
|
||||
result.Cat(f.IV[i] ^ f.R81_step());
|
||||
return result;
|
||||
}
|
||||
|
||||
String DecodeBscF(const String& src) {
|
||||
if(src.GetLength() <= 20)
|
||||
return String::GetVoid();
|
||||
BscF f;
|
||||
String result;
|
||||
const char *s = ~src + 10;
|
||||
const char *lim = src.End() - 10;
|
||||
f.MAC_init();
|
||||
memcpy(f.Wk, src, 10);
|
||||
f.Start();
|
||||
while(s < lim) {
|
||||
byte b = *s++ ^ f.R81_step();
|
||||
result.Cat(b);
|
||||
f.MAC_step();
|
||||
f.Q81[80] ^= b;
|
||||
}
|
||||
f.MACDummy();
|
||||
for(int i = 0; i < 10; i++)
|
||||
if((byte)*s++ != (f.R81_step() ^ f.Q81[80 - i])) return String::GetVoid();
|
||||
return result;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
Copyright 1998-2008 The U++ Project. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE U++ PROJECT ``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 FREEBSD 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.
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="Crypto" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=Crypto - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Crypto.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Crypto.mak" CFG="Crypto - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Crypto - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "Crypto - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Crypto - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 2
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 1
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GR /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x405 /d "NDEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x405 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "Crypto - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 2
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 1
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x405 /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x405 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Crypto - Win32 Release"
|
||||
# Name "Crypto - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BscF.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sha1.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\INCLUDE\Crypto.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef CRYPTO_H
|
||||
#define CRYPTO_H
|
||||
|
||||
#include <Core/Core.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void SHA1Transform(dword state[5], byte buffer[64]);
|
||||
void SHA1Init(dword state[5]);
|
||||
void SHA1Size(byte buffer[64], dword size);
|
||||
String SHA1(const void *s, dword size);
|
||||
String SHA1(const String& s);
|
||||
|
||||
class Sha1 {
|
||||
dword state[5];
|
||||
byte buffer[64];
|
||||
int pos;
|
||||
dword size;
|
||||
|
||||
public:
|
||||
void Put(const void *data, dword length);
|
||||
void Put(const String& s) { Put(s, s.GetLength()); }
|
||||
String Finish();
|
||||
dword GetSize() { return size; }
|
||||
|
||||
Sha1();
|
||||
~Sha1();
|
||||
};
|
||||
|
||||
String EncodeBscF(const String& src);
|
||||
String DecodeBscF(const String& src);
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
Crypto.h,
|
||||
BscF.cpp,
|
||||
Sha1.cpp,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
#include "Crypto.h"
|
||||
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
/*
|
||||
SHA-1 in C
|
||||
By Steve Reid <steve@edmweb.com>
|
||||
100% Public Domain
|
||||
|
||||
Test Vectors (from FIPS PUB 180-1)
|
||||
"abc"
|
||||
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
|
||||
A million repetitions of "a"
|
||||
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||
*/
|
||||
|
||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||
/* blk0() and blk() perform the initial expand. */
|
||||
/* I got the idea of expanding during the round function from SSLeay */
|
||||
|
||||
#ifdef COMPILER_MSC
|
||||
#define rol(value, bits) _rotl(value, bits)
|
||||
#else
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
#endif
|
||||
|
||||
#define blk0(i) (block[i] = (rol(block[i],24)&0xFF00FF00)|(rol(block[i],8)&0x00FF00FF))
|
||||
#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \
|
||||
^block[(i+2)&15]^block[i&15],1))
|
||||
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
|
||||
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
|
||||
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
|
||||
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
|
||||
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
||||
|
||||
void SHA1Transform(dword state[5], byte buffer[64]) {
|
||||
dword a, b, c, d, e;
|
||||
dword *block = (dword *)buffer;
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
e = state[4];
|
||||
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
||||
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
||||
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
||||
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
||||
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
||||
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
||||
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
||||
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
||||
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
||||
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
||||
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
||||
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
||||
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
||||
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
||||
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
||||
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
||||
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
||||
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
||||
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
||||
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
a = b = c = d = e = 0;
|
||||
}
|
||||
|
||||
void SHA1Init(dword state[5]) {
|
||||
state[0] = 0x67452301;
|
||||
state[1] = 0xEFCDAB89;
|
||||
state[2] = 0x98BADCFE;
|
||||
state[3] = 0x10325476;
|
||||
state[4] = 0xC3D2E1F0;
|
||||
}
|
||||
|
||||
void SHA1Size(byte buffer[64], dword size) {
|
||||
buffer[63] = byte(size << 3);
|
||||
buffer[62] = byte(size >> 5);
|
||||
buffer[61] = byte(size >> 13);
|
||||
buffer[60] = byte(size >> 21);
|
||||
buffer[59] = byte(size >> 29);
|
||||
buffer[58] = 0;
|
||||
buffer[57] = 0;
|
||||
buffer[56] = 0;
|
||||
}
|
||||
|
||||
String SHA1Result(dword state[5]) {
|
||||
String r;
|
||||
for(int i = 0; i < 5; i++) {
|
||||
const byte *h = (const byte *)&state[i];
|
||||
if(i) r.Cat(' ');
|
||||
r.Cat(Format("%02X%02X%02X%02X", h[3], h[2], h[1], h[0]));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
String SHA1(const void *data, dword length) {
|
||||
dword state[5];
|
||||
byte buffer[64];
|
||||
dword pos = 0;
|
||||
SHA1Init(state);
|
||||
const char *s = (const char *) data;
|
||||
dword size = length;
|
||||
while(size >= 64) {
|
||||
memcpy(buffer, s, 64);
|
||||
SHA1Transform(state, buffer);
|
||||
size -= 64;
|
||||
s += 64;
|
||||
}
|
||||
memcpy(buffer, s, size);
|
||||
memset(buffer + size, 0, 64 - size);
|
||||
buffer[size] = 128;
|
||||
if(size > 55) {
|
||||
SHA1Transform(state, buffer);
|
||||
memset(buffer, 0, 64);
|
||||
}
|
||||
SHA1Size(buffer, length);
|
||||
SHA1Transform(state, buffer);
|
||||
String r = SHA1Result(state);
|
||||
size = 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(state, 0, sizeof(state));
|
||||
return r;
|
||||
}
|
||||
|
||||
String SHA1(const String& s) {
|
||||
return SHA1(s, s.GetLength());
|
||||
}
|
||||
|
||||
String Sha1::Finish() {
|
||||
memset(buffer + pos, 0, 64 - pos);
|
||||
buffer[pos] = 128;
|
||||
if(pos > 55) {
|
||||
SHA1Transform(state, buffer);
|
||||
memset(buffer, 0, 64);
|
||||
}
|
||||
SHA1Size(buffer, size);
|
||||
SHA1Transform(state, buffer);
|
||||
return SHA1Result(state);
|
||||
}
|
||||
|
||||
void Sha1::Put(const void *data, dword length) {
|
||||
const byte *s = (const byte *)data;
|
||||
size += length;
|
||||
while(pos + length >= 64) {
|
||||
int n = 64 - pos;
|
||||
memcpy(buffer + pos, s, n);
|
||||
SHA1Transform(state, buffer);
|
||||
s += n;
|
||||
length -= n;
|
||||
pos = 0;
|
||||
}
|
||||
memcpy(buffer + pos, s, length);
|
||||
pos += length;
|
||||
}
|
||||
|
||||
Sha1::Sha1() {
|
||||
SHA1Init(state);
|
||||
pos = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
Sha1::~Sha1() {
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(state, 0, sizeof(state));
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
|
|
@ -1,346 +0,0 @@
|
|||
#include "Docedit.h"
|
||||
|
||||
#define IMAGECLASS DppImg
|
||||
#define IMAGEFILE <Docedit/Docedit.iml>
|
||||
#include <Draw/iml_source.h>
|
||||
|
||||
bool IsCppKeyword(const String& id)
|
||||
{
|
||||
static Index<String> kw;
|
||||
if(kw.GetCount() == 0)
|
||||
for(int i = 0; CppKeyword[i]; i++)
|
||||
kw.Add(CppKeyword[i]);
|
||||
return kw.Find(id) >= 0;
|
||||
}
|
||||
|
||||
void DocItemDisplay::Paint(Draw& w, const Rect& r, const Value& q,
|
||||
Color _ink, Color paper, dword style) const
|
||||
{
|
||||
ValueArray va = q;
|
||||
String txt = va.Get(0);
|
||||
String name = va.Get(1);
|
||||
int kind = va.Get(2);
|
||||
int access = va.Get(3);
|
||||
int status = va.Get(4);
|
||||
String pname = va.Get(5);
|
||||
String tname = va.Get(6);
|
||||
Color c = Color(230, 255, 230);
|
||||
switch(status) {
|
||||
case DocDir::IGNORED: c = SGray; break;
|
||||
case DocDir::OBSOLETELINK:
|
||||
case DocDir::OBSOLETE: c = SLtRed; break;
|
||||
case DocDir::UNDOCUMENTED: c = paper; break;
|
||||
}
|
||||
w.DrawRect(r, style & (FOCUS|CURSOR) ? paper : c);
|
||||
if(IsNull(q)) return;
|
||||
int x0 = r.left;
|
||||
if(access == PROTECTED)
|
||||
w.DrawImage(x0, r.top + 1, DppImg::Protected());
|
||||
x0 += 6;
|
||||
Image img = DppImg::Other();
|
||||
switch(kind) {
|
||||
case FUNCTION:
|
||||
img = DppImg::Function();
|
||||
break;
|
||||
case INSTANCEFUNCTION:
|
||||
img = DppImg::InstanceFunction();
|
||||
break;
|
||||
case CLASSFUNCTION:
|
||||
img = DppImg::ClassFunction();
|
||||
break;
|
||||
case FUNCTIONTEMPLATE:
|
||||
img = DppImg::FunctionTemplate();
|
||||
break;
|
||||
case INSTANCEFUNCTIONTEMPLATE:
|
||||
img = DppImg::InstanceFunctionTemplate();
|
||||
break;
|
||||
case CLASSFUNCTIONTEMPLATE:
|
||||
img = DppImg::ClassFunctionTemplate();
|
||||
break;
|
||||
case STRUCT:
|
||||
img = DppImg::Struct();
|
||||
break;
|
||||
case STRUCTTEMPLATE:
|
||||
img = DppImg::StructTemplate();
|
||||
break;
|
||||
case INSTANCEVARIABLE:
|
||||
img = DppImg::InstanceVariable();
|
||||
break;
|
||||
case CLASSVARIABLE:
|
||||
img = DppImg::ClassVariable();
|
||||
break;
|
||||
case VARIABLE:
|
||||
img = DppImg::Variable();
|
||||
break;
|
||||
case ENUM:
|
||||
img = DppImg::Enum();
|
||||
break;
|
||||
case INLINEFRIEND:
|
||||
img = DppImg::InlineFriend();
|
||||
break;
|
||||
case TYPEDEF:
|
||||
img = DppImg::Typedef();
|
||||
break;
|
||||
case CONSTRUCTOR:
|
||||
img = DppImg::Constructor();
|
||||
break;
|
||||
case DESTRUCTOR:
|
||||
img = DppImg::Destructor();
|
||||
break;
|
||||
case MACRO:
|
||||
img = DppImg::Macro();
|
||||
break;
|
||||
}
|
||||
if(style & (CURSOR|FOCUS))
|
||||
DrawHighlightImage(w, x0, r.top + 1, img);
|
||||
else
|
||||
w.DrawImage(x0, r.top + 1, img);
|
||||
x0 += 20;
|
||||
int x = x0;
|
||||
int y = r.top + 2;
|
||||
const char *s = txt;
|
||||
while(*s && y < r.bottom) {
|
||||
Font f = Arial(11);
|
||||
Color ink = SBlack;
|
||||
int n = 1;
|
||||
if(*s >= '0' && *s <= '9') {
|
||||
while(s[n] >= '0' && s[n] <= '9')
|
||||
n++;
|
||||
ink = SRed;
|
||||
}
|
||||
else
|
||||
if(iscid(*s)) {
|
||||
if(strncmp(s, name, name.GetLength()) == 0 && !iscid(s[name.GetLength()])) {
|
||||
f = Arial(11).Bold();
|
||||
n = name.GetLength();
|
||||
name.Clear();
|
||||
}
|
||||
else {
|
||||
String id;
|
||||
n = 0;
|
||||
while(IsAlNum(s[n]) || s[n] == '_') {
|
||||
id.Cat(s[n]);
|
||||
n++;
|
||||
}
|
||||
if(IsCppKeyword(id))
|
||||
ink = SLtBlue;
|
||||
else
|
||||
if(InScList(id, pname)) {
|
||||
ink = SRed;
|
||||
f = Arial(11).Bold();
|
||||
}
|
||||
else
|
||||
if(InScList(id, tname)) {
|
||||
ink = SGreen;
|
||||
f = Arial(11).Bold();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ink = SMagenta;
|
||||
if(style & (CURSOR|FOCUS)) ink = _ink;
|
||||
Size fsz = w.GetTextSize(s, f, n);
|
||||
if(x + fsz.cx >= r.right && fsz.cx < r.Width()) {
|
||||
if(x0 + 70 < r.right)
|
||||
x = x0 + 24;
|
||||
else
|
||||
x = x0;
|
||||
y += fsz.cy;
|
||||
}
|
||||
w.DrawText(x, y, s, f, ink, n);
|
||||
x += fsz.cx;
|
||||
s += n;
|
||||
}
|
||||
}
|
||||
|
||||
void DocNestDisplay::Paint(Draw& w, const Rect& r, const Value& q,
|
||||
Color _ink, Color paper, dword style) const
|
||||
{
|
||||
String text = q;
|
||||
w.DrawRect(r, paper);
|
||||
if(IsNull(text)) {
|
||||
w.DrawText(r.left, r.top, "Globals", Arial(11).Bold().Italic(),
|
||||
style & (CURSOR|FOCUS) ? _ink : SBlue);
|
||||
return;
|
||||
}
|
||||
int x = r.left;
|
||||
int y = r.top;
|
||||
const char *s = text;
|
||||
Font idf = Arial(11).Bold();
|
||||
Color idink = SBlack;
|
||||
while(*s && y < r.bottom) {
|
||||
Font f = Arial(11);
|
||||
Color ink = SBlack;
|
||||
int n = 1;
|
||||
if(*s >= '0' && *s <= '9') {
|
||||
while(s[n] >= '0' && s[n] <= '9')
|
||||
n++;
|
||||
ink = SRed;
|
||||
}
|
||||
else
|
||||
if(iscid(*s)) {
|
||||
String id;
|
||||
n = 0;
|
||||
while(IsAlNum(s[n]) || s[n] == '_') {
|
||||
id.Cat(s[n]);
|
||||
n++;
|
||||
}
|
||||
if(IsCppKeyword(id)) {
|
||||
ink = SLtBlue;
|
||||
if(id == "class" || id == "typename")
|
||||
idink = SGreen;
|
||||
}
|
||||
else {
|
||||
ink = idink;
|
||||
f = idf;
|
||||
idink = SBlack;
|
||||
idf = Arial(11);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ink = SMagenta;
|
||||
if(*s == ':') {
|
||||
idf = Arial(11).Bold();
|
||||
idink = SBlack;
|
||||
}
|
||||
}
|
||||
if(style & (CURSOR|FOCUS)) ink = _ink;
|
||||
Size fsz = w.GetTextSize(s, f, n);
|
||||
w.DrawText(x, y, s, f, ink, n);
|
||||
x += fsz.cx;
|
||||
s += n;
|
||||
}
|
||||
}
|
||||
|
||||
int GetItemHeight(const String& txt, const String& nm, const String& pname,
|
||||
const String& tname, int cx)
|
||||
{
|
||||
String name = nm;
|
||||
int x = 26;
|
||||
int y = ScreenInfo().GetFontInfo(Arial(11)).GetHeight() + 3;
|
||||
const char *s = txt;
|
||||
while(*s) {
|
||||
Font f = Arial(11);
|
||||
int n = 1;
|
||||
if(*s >= '0' && *s <= '9')
|
||||
while(s[n] >= '0' && s[n] <= '9')
|
||||
n++;
|
||||
else
|
||||
if(iscid(*s)) {
|
||||
if(strncmp(s, name, name.GetLength()) == 0 && !iscid(s[name.GetLength()])) {
|
||||
f = Arial(11).Bold();
|
||||
n = name.GetLength();
|
||||
name.Clear();
|
||||
}
|
||||
else {
|
||||
String id;
|
||||
n = 0;
|
||||
while(IsAlNum(s[n]) || s[n] == '_') {
|
||||
id.Cat(s[n]);
|
||||
n++;
|
||||
}
|
||||
if(!IsCppKeyword(id) && InScList(id, pname) || InScList(id, tname))
|
||||
f = Arial(11).Bold();
|
||||
}
|
||||
}
|
||||
Size fsz = ScreenInfo().GetTextSize(s, f, n);
|
||||
if(x + fsz.cx >= cx && fsz.cx < cx) {
|
||||
if(26 + 70 < cx)
|
||||
x = 26 + 24;
|
||||
else
|
||||
x = 26;
|
||||
y += fsz.cy;
|
||||
}
|
||||
x += fsz.cx;
|
||||
s += n;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
void InitItemArray(ArrayCtrl& item)
|
||||
{
|
||||
item.NoHeader();
|
||||
item.AddIndex();
|
||||
item.AddIndex().Accel();
|
||||
item.AddIndex();
|
||||
item.AddIndex();
|
||||
item.AddIndex();
|
||||
item.AddIndex();
|
||||
item.AddIndex();
|
||||
item.AddIndex();
|
||||
item.AddIndex();
|
||||
item.AddColumnAt(0, "").Add(1).Add(2).Add(3).Add(4).Add(5).Add(6).Add(7).Add(8)
|
||||
.SetDisplay(Single<DocItemDisplay>()).Accel().HeaderTab().SetMargin(0);
|
||||
item.HeaderObject().Tab(0).SetMargin(0);
|
||||
}
|
||||
|
||||
void LoadItems(const DocSet& set, const String& nameing, const String& nesting, ArrayCtrl& item)
|
||||
{
|
||||
const ArrayMap<String, DocItem>& nt = set.Get(~nameing).Get(nesting);
|
||||
item.Clear();
|
||||
int cx = item.HeaderObject().GetTabWidth(0) - 2 * item.HeaderObject().Tab(0).GetMargin();
|
||||
for(int i = 0; i < nt.GetCount(); i++) {
|
||||
const DocItem& im = nt[i];
|
||||
if(im.cppitem) {
|
||||
item.Add(nt.GetKey(i), im.cppitem->name, im.cppitem->kind, im.cppitem->access,
|
||||
im.status, im.cppitem->pname, im.cppitem->tname,
|
||||
im.package, im.cppitem->file, im.cppitem->line);
|
||||
item.SetLineCy(item.GetCount() - 1,
|
||||
GetItemHeight(nt.GetKey(i), im.cppitem->name,
|
||||
im.cppitem->pname, im.cppitem->tname, cx));
|
||||
}
|
||||
else {
|
||||
item.Add(nt.GetKey(i), Null, Null, Null, im.status, Null, Null, im.package,
|
||||
Null, Null);
|
||||
item.SetLineCy(item.GetCount() - 1,
|
||||
GetItemHeight(nt.GetKey(i), Null, Null, Null, cx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ByOrder(int a1, int a2, int *order)
|
||||
{
|
||||
if(a1 == a2) return 0;
|
||||
while(*order != -1) {
|
||||
if(a1 == *order) return -1;
|
||||
if(a2 == *order) return 1;
|
||||
order++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompareItems(const Vector<Value>& row1, const Vector<Value>& row2)
|
||||
{
|
||||
int q;
|
||||
int status_order[] = {
|
||||
STATUS_UNDOCUMENTED, STATUS_OBSOLETE, STATUS_IGNORED, STATUS_EXTERNAL, STATUS_NORMAL,
|
||||
-1
|
||||
};
|
||||
int kind1 = row1[2];
|
||||
int kind2 = row2[2];
|
||||
if(kind1 != STRUCT && kind2 != STRUCT && kind1 != STRUCTTEMPLATE && kind2 != STRUCTTEMPLATE) {
|
||||
q = (int)row2[3] - (int)row1[3];
|
||||
if(q) return q;
|
||||
q = ByOrder(row1[4], row2[4], status_order);
|
||||
if(q) return q;
|
||||
}
|
||||
int kind_order[] = {
|
||||
STRUCT, STRUCTTEMPLATE,
|
||||
MACRO,
|
||||
CONSTRUCTOR, DESTRUCTOR,
|
||||
ENUM, TYPEDEF,
|
||||
INSTANCEFUNCTION, CLASSFUNCTION, INLINEFRIEND,
|
||||
INSTANCEVARIABLE, CLASSVARIABLE,
|
||||
INSTANCEFUNCTION, INSTANCEVARIABLE,
|
||||
VARIABLE, FUNCTION, FUNCTIONTEMPLATE,
|
||||
-1
|
||||
};
|
||||
q = ByOrder(kind1, kind2, kind_order);
|
||||
if(q) return q;
|
||||
return strcmp((String)row1[1], (String)row2[1]);
|
||||
}
|
||||
|
||||
int CompareNests(const Value& v1, const Value& v2)
|
||||
{
|
||||
return strcmp(String(v1), String(v2));
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
#include "Docedit.h"
|
||||
|
||||
void DocLinkDlg::Nameing()
|
||||
{
|
||||
nesting.Clear();
|
||||
if(IsNull(nameing)) {
|
||||
Nesting();
|
||||
return;
|
||||
}
|
||||
const VectorMap<String, ArrayMap<String, DocItem> >& ns = set->Get(~nameing);
|
||||
nesting.Clear();
|
||||
for(int i = 0; i < ns.GetCount(); i++)
|
||||
nesting.Add(ns.GetKey(i));
|
||||
nesting.Sort(0, CompareNests);
|
||||
nesting.GoBegin();
|
||||
Nesting();
|
||||
}
|
||||
|
||||
void DocLinkDlg::Nesting()
|
||||
{
|
||||
item.Clear();
|
||||
if(!nesting.IsCursor()) {
|
||||
Item();
|
||||
return;
|
||||
}
|
||||
LoadItems(*set, ~nameing, nesting.GetKey(), item);
|
||||
if(sort)
|
||||
item.Sort(CompareItems);
|
||||
item.GoBegin();
|
||||
}
|
||||
|
||||
String DocLinkDlg::Get()
|
||||
{
|
||||
return "dpp://" + String(~nameing) + "/" + String(nesting.GetKey()) + "/"
|
||||
+ String(item.GetKey());
|
||||
}
|
||||
|
||||
void DocLinkDlg::Item()
|
||||
{
|
||||
link <<= Get();
|
||||
String s = doc_dir.GetText(DocKey(~nameing, nesting.GetKey(), item.GetKey(), lang));
|
||||
label.KillCursor();
|
||||
label.Clear();
|
||||
label.Disable();
|
||||
if(IsNull(s)) return;
|
||||
Array<RichPosInfo> pi = ParseQTF(s).GetPosInfo(Rect(0, 0, 5000, 5000), PageY());
|
||||
for(int i = 0; i < pi.GetCount(); i++)
|
||||
if(pi[i].type == RichPosInfo::LABEL)
|
||||
label.Add(FromUnicode(pi[i].data, CHARSET_WIN1252));
|
||||
if(label.GetCount())
|
||||
label.Enable();
|
||||
}
|
||||
|
||||
void DocLinkDlg::Label()
|
||||
{
|
||||
if(label.IsCursor())
|
||||
link <<= Get() + "#" + String(label.GetKey());
|
||||
}
|
||||
|
||||
bool DocLinkDlg::Perform(const DocSet& _set, bool _sort, String& _link, dword _lang,
|
||||
const String& _nameing, const String& _nesting)
|
||||
{
|
||||
lang = _lang;
|
||||
set = &_set;
|
||||
sort = _sort;
|
||||
nameing.Clear();
|
||||
for(int i = 0; i < _set.GetCount(); i++)
|
||||
nameing.Add(_set.GetKey(i));
|
||||
if(nameing.GetCount())
|
||||
nameing.SetIndex(0);
|
||||
if(!IsNull(_nameing) && nameing.HasKey(_nameing))
|
||||
nameing <<= _nameing;
|
||||
Nameing();
|
||||
if(!IsNull(_nesting))
|
||||
nesting.FindSetCursor(_nesting);
|
||||
link <<= _link;
|
||||
link.SetFocus();
|
||||
if(Execute() == IDOK) {
|
||||
link.AddHistory();
|
||||
_link = link;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DocLinkDlg::DocLinkDlg()
|
||||
{
|
||||
CtrlLayoutOKCancel(*this, "Link");
|
||||
nesting.AddColumn().SetDisplay(Single<DocNestDisplay>());
|
||||
nesting.NoHeader().NoGrid();
|
||||
nameing <<= THISBACK(Nameing);
|
||||
nesting.WhenEnterRow = THISBACK(Nesting);
|
||||
InitItemArray(item);
|
||||
item.WhenLeftClick = THISBACK(Item);
|
||||
label.NoHeader().NoGrid();
|
||||
label.AddColumn();
|
||||
label.WhenLeftClick = THISBACK(Label);
|
||||
}
|
||||
|
||||
bool ParseLink(const String& link, DocKey& key, String& label)
|
||||
{
|
||||
if(memcmp(link, "dpp://", 6)) return false;
|
||||
Vector<String> p = Split(~link + 6, '/', false);
|
||||
if(p.GetCount() != 3) return false;
|
||||
key.nameing = p[0];
|
||||
key.nesting = p[1];
|
||||
key.item = p[2];
|
||||
int q = key.item.Find('#');
|
||||
label = Null;
|
||||
if(q < 0) return true;
|
||||
label = key.item.Mid(q + 1);
|
||||
key.item = key.item.Mid(0, q);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#include "Docedit.h"
|
||||
|
||||
String PackageDirectory(const String& name)
|
||||
{
|
||||
return AppendFileName("F:/uppsrc", name);
|
||||
}
|
||||
|
||||
String SourcePath(const String& package, const String& name)
|
||||
{
|
||||
return AppendFileName(PackageDirectory(package), name);
|
||||
}
|
||||
|
||||
String CommonPath(const String& filename)
|
||||
{
|
||||
return AppendFileName("f:/theide", filename);
|
||||
}
|
||||
|
||||
DocBase doc_base;
|
||||
|
||||
void DocBase::RemoveFile(const String& file)
|
||||
{
|
||||
CppBase base;
|
||||
CppBase& doc_base = *this;
|
||||
for(int i = 0; i < doc_base.GetCount(); i++) {
|
||||
String m = doc_base.GetKey(i);
|
||||
CppNamespace& mm = doc_base[i];
|
||||
for(int i = 0; i < mm.GetCount(); i++) {
|
||||
String n = mm.GetKey(i);
|
||||
CppNest& nn = mm[i];
|
||||
for(int i = 0; i < nn.GetCount(); i++) {
|
||||
CppItem& q = nn[i];
|
||||
if(q.file != file)
|
||||
base.GetAdd(m).GetAdd(n).GetAdd(nn.GetKey(i)) = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_base = base;
|
||||
}
|
||||
|
||||
void DocBase::ParseFile(const String& file, const String& package) throw(CParser::Error)
|
||||
{
|
||||
Parse(FileIn(file), ignore, doc_base, package, file);
|
||||
}
|
||||
|
||||
void DocBase::RefreshFile(const String& file, const String& package) throw(CParser::Error)
|
||||
{
|
||||
RemoveFile(file);
|
||||
ParseFile(file, package);
|
||||
}
|
||||
|
||||
Vector<String> DocBase::GetHeaders()
|
||||
{
|
||||
Index<String> h;
|
||||
for(int i = 0; i < doc_base.GetCount(); i++) {
|
||||
String m = doc_base.GetKey(i);
|
||||
CppNamespace& mm = doc_base[i];
|
||||
for(int i = 0; i < mm.GetCount(); i++) {
|
||||
String n = mm.GetKey(i);
|
||||
CppNest& nn = mm[i];
|
||||
for(int i = 0; i < nn.GetCount(); i++) {
|
||||
h.FindAdd(nn[i].file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return h.PickKeys();
|
||||
}
|
||||
|
|
@ -1,511 +0,0 @@
|
|||
#include "Docedit.h"
|
||||
|
||||
bool DocKey::operator==(const DocKey& b) const
|
||||
{
|
||||
return nameing == b.nameing && nesting == b.nesting && item == b.item && lang == b.lang;
|
||||
}
|
||||
|
||||
dword GetHashValue(const DocKey& k)
|
||||
{
|
||||
return CombineHash(GetHashValue(k.nameing), GetHashValue(k.nesting),
|
||||
GetHashValue(k.item)) << k.lang;
|
||||
}
|
||||
|
||||
int CharFilterNameing(int c)
|
||||
{
|
||||
return c == ':' ? '_' : c;
|
||||
}
|
||||
|
||||
String DocFile(const String& package, const String& name)
|
||||
{
|
||||
return AppendFileName(SourcePath(package, "doc.dpp"), name);
|
||||
}
|
||||
|
||||
Time GetFileTime(const char *path)
|
||||
{
|
||||
FindFile ff(path);
|
||||
return ff ? Time(ff.GetLastWriteTime()) : Null;
|
||||
}
|
||||
|
||||
void CreateDocDir(const String& package)
|
||||
{
|
||||
::CreateDirectory(SourcePath(package, "doc.dpp"), 0);
|
||||
}
|
||||
|
||||
String AsCode(const DocKey& k)
|
||||
{
|
||||
return AsCString(k.nameing) + ", " + AsCString(k.nesting) + ", " +
|
||||
AsCString(k.item) + ", " + AsCString(LNGAsText(k.lang));
|
||||
}
|
||||
|
||||
bool ReadCode(CParser& p, DocKey& key)
|
||||
{
|
||||
if(!p.IsString()) return false;
|
||||
key.nameing = p.ReadString();
|
||||
if(!p.Char(',') || !p.IsString()) return false;
|
||||
key.nesting = p.ReadString();
|
||||
if(!p.Char(',') || !p.IsString()) return false;
|
||||
key.item = p.ReadString();
|
||||
if(!p.Char(',') || !p.IsString()) return false;
|
||||
key.lang = LNGFromText(p.ReadString());
|
||||
return true;
|
||||
}
|
||||
|
||||
void DocDir::SaveLinks(const String& package) const
|
||||
{
|
||||
CreateDocDir(package);
|
||||
FileOut out(DocFile(package, "links"));
|
||||
int q = dir.Find(package);
|
||||
if(q >= 0) {
|
||||
const ArrayMap<DocKey, Entry>& p = dir[q];
|
||||
for(int i = 0; i < p.GetCount(); i++) {
|
||||
const Entry& w = p[i];
|
||||
const DocKey& k = p.GetKey(i);
|
||||
if(w.type == LINK)
|
||||
out << "LINK(" << AsCode(k) << ", " << AsCString(w.text) << ")\r\n";
|
||||
if(w.type == IGNORED)
|
||||
out << "IGNORED(" << AsCode(k) << ")\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DocDir::SaveDir(const String& package) const
|
||||
{
|
||||
CreateDocDir(package);
|
||||
FileOut out(DocFile(package, "dir.h"));
|
||||
int q = dir.Find(package);
|
||||
if(q >= 0) {
|
||||
const ArrayMap<DocKey, Entry>& p = dir[q];
|
||||
for(int i = 0; i < p.GetCount(); i++) {
|
||||
const Entry& w = p[i];
|
||||
if(w.type == NORMAL || w.type == EXTERNAL) {
|
||||
const DocKey& k = p.GetKey(i);
|
||||
out << "#ifdef INCLUDE_NAMESPACE_" <<
|
||||
Filter(k.nameing, CharFilterNameing) << "\r\n";
|
||||
out << "//" << k.item << "\r\n";
|
||||
out << "//" << k.nesting << "\r\n";
|
||||
out << "//" << k.nameing << "\r\n";
|
||||
out << "#include \"doc.dpp/";
|
||||
out << w.text;
|
||||
out << "\" //";
|
||||
if(w.type == EXTERNAL)
|
||||
out << "*";
|
||||
out << LNGAsText(k.lang) << "\r\n";
|
||||
out << "#endif\r\n\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
SaveLinks(package);
|
||||
}
|
||||
|
||||
bool DocDir::LoadLinks(const String& package)
|
||||
{
|
||||
String f = LoadFile(DocFile(package, "links"));
|
||||
CParser p(f);
|
||||
ArrayMap<DocKey, Entry>& pk = dir.GetAdd(package);
|
||||
try {
|
||||
while(!p.IsEof()) {
|
||||
if(p.Id("LINK")) {
|
||||
DocKey key;
|
||||
p.PassChar('(');
|
||||
if(!ReadCode(p, key)) return false;
|
||||
p.PassChar(',');
|
||||
String link = p.ReadString();
|
||||
p.PassChar(')');
|
||||
Entry& e = pk.GetAdd(key);
|
||||
e.text = link;
|
||||
e.type = LINK;
|
||||
}
|
||||
if(p.Id("IGNORED")) {
|
||||
DocKey key;
|
||||
p.PassChar('(');
|
||||
if(!ReadCode(p, key)) return false;
|
||||
p.PassChar(')');
|
||||
Entry& e = pk.GetAdd(key);
|
||||
e.text.Clear();
|
||||
e.type = IGNORED;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(CParser::Error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DocDir::LoadDir(const String& package)
|
||||
{
|
||||
ArrayMap<DocKey, Entry>& p = dir.GetAdd(package);
|
||||
p.Clear();
|
||||
LoadLinks(package);
|
||||
FileIn in(DocFile(package, "dir.h"));
|
||||
int q = 0;
|
||||
String d[3];
|
||||
while(!in.IsEof()) {
|
||||
String l = in.GetLine();
|
||||
if(memcmp(l, "#include ", 9) == 0) {
|
||||
const char *b = strchr(l, '/');
|
||||
if(!b) return false;
|
||||
const char *e = strchr(b + 1, '\"');
|
||||
if(!e) return false;
|
||||
String fn = String(b + 1, e);
|
||||
e = strchr(e, '/');
|
||||
if(!e || e[1] != '/') return false;
|
||||
e += 2;
|
||||
int type = NORMAL;
|
||||
if(*e == '*') {
|
||||
type = EXTERNAL;
|
||||
e++;
|
||||
}
|
||||
Entry& w = p.GetAdd(DocKey(d[2], d[1], d[0], LNGFromText(e)));
|
||||
w.text = fn;
|
||||
w.type = type;
|
||||
q = 0;
|
||||
}
|
||||
if(l[0] == '/' && l[1] == '/') {
|
||||
if(q >= 3) return false;
|
||||
d[q] = l.Mid(2);
|
||||
q++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DocDir::ReadDocHeader(const char *filename, DocKey& key)
|
||||
{
|
||||
FileIn in(filename);
|
||||
if(!in) return -1;
|
||||
String l = in.GetLine();
|
||||
CParser p(l);
|
||||
if(!p.Id("ITEM") || !p.Char('(') || !ReadCode(p, key)) return -1;
|
||||
p.Char(')');
|
||||
if(p.Id("EXTERNAL"))
|
||||
return EXTERNAL;
|
||||
return NORMAL;
|
||||
}
|
||||
|
||||
void DocDir::RebuildDir(const String& package)
|
||||
{
|
||||
FindFile ff(DocFile(package, "*.dpp"));
|
||||
Progress pi("Rebuilding " + package + " doc directory %d");
|
||||
ArrayMap<DocKey, Entry>& p = dir.GetAdd(package);
|
||||
p.Clear();
|
||||
LoadLinks(package);
|
||||
while(ff) {
|
||||
DocKey key;
|
||||
pi.Step();
|
||||
int q = ReadDocHeader(DocFile(package, ff.GetName()), key);
|
||||
if(q >= 0) {
|
||||
Entry& w = p.GetAdd(key);
|
||||
w.text = ff.GetName();
|
||||
w.type = q;
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
SaveDir(package);
|
||||
}
|
||||
|
||||
void DocDir::Refresh(const String& package)
|
||||
{
|
||||
FindFile ff(DocFile(package, "dir.h"));
|
||||
if(!ff) {
|
||||
RebuildDir(package);
|
||||
return;
|
||||
}
|
||||
FileTime dirtime = ff.GetLastWriteTime();
|
||||
ff.Search(DocFile(package, "links"));
|
||||
if(ff && ff.GetLastWriteTime() > dirtime) {
|
||||
RebuildDir(package);
|
||||
return;
|
||||
}
|
||||
const ArrayMap<DocKey, Entry>& p = dir.GetAdd(package);
|
||||
Index<String> dfn;
|
||||
for(int i = 0; i < p.GetCount(); i++)
|
||||
if(p[i].type == NORMAL || p[i].type == EXTERNAL)
|
||||
dfn.Add(p[i].text);
|
||||
ff.Search(DocFile(package, "*.dpp"));
|
||||
int count = 0;
|
||||
while(ff) {
|
||||
DocKey key;
|
||||
if(dfn.Find(ff.GetName()) >= 0)
|
||||
if(ff.GetLastWriteTime() > dirtime) {
|
||||
RebuildDir(package);
|
||||
return;
|
||||
}
|
||||
else
|
||||
count++;
|
||||
else
|
||||
if(ReadDocHeader(DocFile(package, ff.GetName()), key) >= 0) {
|
||||
RebuildDir(package);
|
||||
return;
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
if(count != dfn.GetCount())
|
||||
RebuildDir(package);
|
||||
}
|
||||
|
||||
int CharFilterLNG_(int c)
|
||||
{
|
||||
return c == '-' ? '_' : c;
|
||||
}
|
||||
|
||||
String DocDir::GetAddFileName(const String& package, const DocKey& key, int type)
|
||||
{
|
||||
Entry& w = dir.GetAdd(package).GetAdd(key);
|
||||
String& fn = w.text;
|
||||
w.type = type;
|
||||
if(!IsEmpty(fn)) return fn;
|
||||
String nm = key.nameing + '_' + key.nesting + '_' + key.item;
|
||||
String n;
|
||||
const char *s = nm;
|
||||
while(*s && n.GetLength() < 30)
|
||||
if(iscid(*s))
|
||||
n.Cat(*s++);
|
||||
else {
|
||||
n.Cat('_');
|
||||
while(*s && !iscid(*s))
|
||||
s++;
|
||||
}
|
||||
n << '_' << LNGAsText(key.lang);
|
||||
int i = 0;
|
||||
for(;;) {
|
||||
fn = n + FormatIntAlpha(i) + ".dpp";
|
||||
if(!FindFile(DocFile(package, fn)))
|
||||
return fn;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
bool DocDir::GetFileName(const DocKey& key, String& fn, String& package)
|
||||
{
|
||||
dword hv = GetHashValue(key);
|
||||
for(int i = 0; i < dir.GetCount(); i++) {
|
||||
const ArrayMap<DocKey, Entry>& p = dir[i];
|
||||
int q = p.Find(key, hv);
|
||||
if(q >= 0) {
|
||||
fn = p[q].text;
|
||||
package = dir.GetKey(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DocDir::RemoveOtherKey(const DocKey& key, int t1, int t2)
|
||||
{
|
||||
dword hv = GetHashValue(key);
|
||||
for(int i = 0; i < dir.GetCount(); i++) {
|
||||
int q = dir[i].Find(key, hv);
|
||||
if(q >= 0) {
|
||||
Entry& e = dir[i][q];
|
||||
if(e.type != t1 && e.type != t2) {
|
||||
if(e.type == NORMAL || e.type == EXTERNAL)
|
||||
DeleteFile(DocFile(dir.GetKey(i), dir[i][q].text));
|
||||
dir[i].Remove(q);
|
||||
}
|
||||
SaveDir(dir.GetKey(i));
|
||||
SaveLinks(dir.GetKey(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DocDir::Remove(const DocKey& k)
|
||||
{
|
||||
RemoveOtherKey(k, UNDOCUMENTED, UNDOCUMENTED);
|
||||
}
|
||||
|
||||
void DocDir::SaveText(const String& package, const DocKey& k, const String& text, bool external)
|
||||
{
|
||||
RemoveOtherKey(k, NORMAL, EXTERNAL);
|
||||
CreateDocDir(package);
|
||||
String fn = DocFile(package, GetAddFileName(package, k, external ? EXTERNAL : NORMAL));
|
||||
FileOut out(fn);
|
||||
out << "ITEM(" << AsCode(k) << ")";
|
||||
if(external)
|
||||
out << " EXTERNAL";
|
||||
out << "\r\n";
|
||||
int n = 0;
|
||||
for(;;) {
|
||||
int m = min(text.GetLength() - n, 2048);
|
||||
if(m == 0) break;
|
||||
out << "TEXT(\r\n\t";
|
||||
out << AsCString(~text + n, ~text + n + m, 64, "\t") << "\r\n";
|
||||
out << ")\r\n";
|
||||
n += m;
|
||||
}
|
||||
out << "END_ITEM\r\n";
|
||||
SaveDir(package);
|
||||
SaveLinks(package);
|
||||
}
|
||||
|
||||
void DocDir::SaveLink(const String& package, const DocKey& key, const String& text)
|
||||
{
|
||||
RemoveOtherKey(key, LINK);
|
||||
Entry& w = dir.GetAdd(package).GetAdd(key);
|
||||
w.text = text;
|
||||
w.type = LINK;
|
||||
SaveLinks(package);
|
||||
}
|
||||
|
||||
void DocDir::Ignore(const String& package, const DocKey& key)
|
||||
{
|
||||
RemoveOtherKey(key, IGNORED);
|
||||
Entry& w = dir.GetAdd(package).GetAdd(key);
|
||||
w.type = IGNORED;
|
||||
SaveLinks(package);
|
||||
}
|
||||
|
||||
DocDir::Entry *DocDir::Find(const DocKey& key, String& package) const
|
||||
{
|
||||
dword hv = GetHashValue(key);
|
||||
for(int i = 0; i < dir.GetCount(); i++) {
|
||||
int q = dir[i].Find(key, hv);
|
||||
if(q >= 0) {
|
||||
package = dir.GetKey(i);
|
||||
return const_cast<Entry *>(&dir[i][q]);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DocDir::Entry *DocDir::Find(const DocKey& key) const
|
||||
{
|
||||
String dm;
|
||||
return Find(key, dm);
|
||||
}
|
||||
|
||||
int DocDir::GetStatus(const DocKey& key)
|
||||
{
|
||||
DocDir::Entry *e = Find(key);
|
||||
return e ? e->type : UNDOCUMENTED;
|
||||
}
|
||||
|
||||
int DocDir::GetStatus(const String& nameing, const String& nesting, const String& item,
|
||||
int lang)
|
||||
{
|
||||
return GetStatus(DocKey(nameing, nesting, item, lang));
|
||||
}
|
||||
|
||||
String DocDir::GetFilePath(const DocKey& key) const
|
||||
{
|
||||
String package;
|
||||
Entry *e = Find(key, package);
|
||||
if(!e || e->type != NORMAL && e->type != EXTERNAL) return Null;
|
||||
return DocFile(package, e->text);
|
||||
}
|
||||
|
||||
String DocDir::GetPackage(const DocKey& key) const
|
||||
{
|
||||
String package;
|
||||
Entry *e = Find(key, package);
|
||||
return e ? package : Null;
|
||||
}
|
||||
|
||||
String DocDir::GetText(const DocKey& key) const
|
||||
{
|
||||
String s = LoadFile(GetFilePath(key));
|
||||
if(s.IsEmpty()) return Null;
|
||||
CParser p(s);
|
||||
DocKey dummy;
|
||||
if(!p.Id("ITEM") || !p.Char('(') || !ReadCode(p, dummy)) return "Invalid file";
|
||||
p.Char(')');
|
||||
p.Id("EXTERNAL");
|
||||
String text;
|
||||
while(p.Id("TEXT")) {
|
||||
p.Char('(');
|
||||
if(p.IsString())
|
||||
text.Cat(p.ReadString());
|
||||
else
|
||||
return "Invalid file";
|
||||
p.Char(')');
|
||||
}
|
||||
return p.Id("END_ITEM") ? text : "Invalid file";
|
||||
}
|
||||
|
||||
String DocDir::GetLink(const DocKey& key) const
|
||||
{
|
||||
DocDir::Entry *e = Find(key);
|
||||
if(!e) return Null;
|
||||
return e->type == LINK ? e->text : Null;
|
||||
}
|
||||
|
||||
bool Contains(const DocSet& r, const DocKey& key)
|
||||
{
|
||||
int q = r.Find(key.nameing);
|
||||
if(q < 0) return false;
|
||||
int w = r[q].Find(key.nesting);
|
||||
if(w < 0) return false;
|
||||
return r[q][w].Find(key.item) >= 0;
|
||||
}
|
||||
|
||||
bool Contains(const String& big, const String& part)
|
||||
{
|
||||
if(part.GetLength() > big.GetLength()) return false;
|
||||
const char *s = big;
|
||||
const char *e = s + big.GetLength() - part.GetLength();
|
||||
int l = part.GetLength();
|
||||
while(s <= e) {
|
||||
if(memcmp(s, part, l) == 0)
|
||||
return true;
|
||||
s++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DocSet DocDir::Select(const DocQuery& query)
|
||||
{
|
||||
DocSet r;
|
||||
CppBase base;
|
||||
int i;
|
||||
for(i = 0; i < doc_base.GetCount(); i++) {
|
||||
String nameing = doc_base.GetKey(i);
|
||||
CppNamespace& mm = doc_base[i];
|
||||
for(int i = 0; i < mm.GetCount(); i++) {
|
||||
String nesting = mm.GetKey(i);
|
||||
CppNest& nn = mm[i];
|
||||
for(int i = 0; i < nn.GetCount(); i++) {
|
||||
CppItem& q = nn[i];
|
||||
String item = nn.GetKey(i);
|
||||
if((query.name.IsEmpty() || query.name == q.name) &&
|
||||
(query.text.IsEmpty() || Contains(item, query.text)) &&
|
||||
(query.package.IsEmpty() || q.package.CompareNoCase(query.package) == 0) &&
|
||||
(query.header.IsEmpty() || q.file.CompareNoCase(query.header) == 0)) {
|
||||
String pk;
|
||||
const Entry *e = Find(DocKey(nameing, nesting, item, query.lang), pk);
|
||||
int st = e ? e->type : UNDOCUMENTED;
|
||||
if((query.undocumented || e) && (st != IGNORED || query.ignored)) {
|
||||
DocItem& a = r.GetAdd(nameing).GetAdd(nesting).GetAdd(item);
|
||||
a.cppitem = &q;
|
||||
a.item = item;
|
||||
a.status = st;
|
||||
a.package = e ? pk : q.package;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 0; i < dir.GetCount(); i++) {
|
||||
ArrayMap<DocKey, Entry>& pk = dir[i];
|
||||
String package = dir.GetKey(i);
|
||||
for(int j = 0; j < pk.GetCount(); j++) {
|
||||
const DocKey& k = pk.GetKey(j);
|
||||
if(k.lang == query.lang &&
|
||||
query.name.IsEmpty() &&
|
||||
(query.text.IsEmpty() || Contains(k.item, query.text)) &&
|
||||
(query.package.IsEmpty() || package.CompareNoCase(query.package) == 0) &&
|
||||
query.header.IsEmpty() &&
|
||||
!Contains(r, k)) {
|
||||
DocItem& a = r.GetAdd(k.nameing).GetAdd(k.nesting).GetAdd(k.item);
|
||||
a.cppitem = NULL;
|
||||
a.item = k.item;
|
||||
int st = pk[j].type;
|
||||
a.status = st == NORMAL ? OBSOLETE : st == LINK ? OBSOLETELINK : st;
|
||||
a.package = package;
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
DocDir doc_dir;
|
||||
|
|
@ -1,539 +0,0 @@
|
|||
#include <DocEdit/DocEdit.h>
|
||||
|
||||
int PosOf(const String& str, const String& sub)
|
||||
{
|
||||
if(sub.GetLength() > str.GetLength()) return -1;
|
||||
const char *s = str;
|
||||
const char *e = s + str.GetLength() - sub.GetLength();
|
||||
while(s <= e) {
|
||||
if(memcmp(s, sub, sub.GetLength()) == 0)
|
||||
return s - ~str;
|
||||
s++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DocBrowser::Nameing()
|
||||
{
|
||||
nesting.Clear();
|
||||
if(IsNull(nameing)) {
|
||||
Nesting();
|
||||
return;
|
||||
}
|
||||
const VectorMap<String, ArrayMap<String, DocItem> >& ns = set.Get(~nameing);
|
||||
nesting.Clear();
|
||||
for(int i = 0; i < ns.GetCount(); i++)
|
||||
nesting.Add(ns.GetKey(i));
|
||||
nesting.Sort(0, CompareNests);
|
||||
nesting.GoBegin();
|
||||
Nesting();
|
||||
}
|
||||
|
||||
void DocBrowser::Nesting()
|
||||
{
|
||||
item.Clear();
|
||||
if(!nesting.IsCursor()) {
|
||||
Item();
|
||||
return;
|
||||
}
|
||||
LoadItems(set, ~nameing, nesting.GetKey(), item);
|
||||
if(sort)
|
||||
item.Sort(CompareItems);
|
||||
item.GoBegin();
|
||||
edit.Enable(item.IsCursor());
|
||||
}
|
||||
|
||||
void DocBrowser::Item()
|
||||
{
|
||||
Flush();
|
||||
EnterItem();
|
||||
}
|
||||
|
||||
void DocBrowser::EnterItem()
|
||||
{
|
||||
String lbl;
|
||||
target = current = DocKey(~nameing, nesting.GetKey(), item.GetKey(), (int)~lang);
|
||||
if(doc_dir.GetStatus(current) == DocDir::LINK)
|
||||
if(!ParseLink(doc_dir.GetLink(current), target, lbl)) {
|
||||
View();
|
||||
view.SetQTF("[R9&&&=@3* Invalid link");
|
||||
return;
|
||||
}
|
||||
String txt = LoadFile(CommonPath("dppstyles.qtf")) + doc_dir.GetText(target);
|
||||
package <<= doc_dir.GetPackage(target);
|
||||
if(edit.IsShown()) {
|
||||
edit.SetPage(Size(3968, INT_MAX));
|
||||
edit.SetQTF(txt);
|
||||
edit.SetFocus();
|
||||
String p = doc_dir.GetFilePath(target);
|
||||
if(!IsNull(p)) {
|
||||
int q = editstate.Find(p);
|
||||
if(q >= 0) {
|
||||
FileInfo& fi = editstate[q];
|
||||
if(fi.time == GetFileTime(p)) {
|
||||
edit.SetPickUndoInfo(fi.info);
|
||||
fi.time = Time(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
int q = posinfo.Find(current);
|
||||
if(q >= 0)
|
||||
edit.SetPosInfo(posinfo[q]);
|
||||
else
|
||||
if(!lbl.IsEmpty())
|
||||
edit.GotoLabel(lbl);
|
||||
edit.ClearModify();
|
||||
}
|
||||
else {
|
||||
view.SetQTF(txt);
|
||||
if(!lbl.IsEmpty())
|
||||
view.GotoLabel(lbl);
|
||||
}
|
||||
trect.Color(SLtBlue);
|
||||
title.SetInk(SWhite);
|
||||
String s = " dpp://" + current.nameing + "/" + current.nesting + "/" + current.item;
|
||||
switch(GetCurrentStatus()) {
|
||||
case DocDir::UNDOCUMENTED:
|
||||
trect.Color(SGray);
|
||||
break;
|
||||
case DocDir::LINK:
|
||||
s << " -> " << target.nameing + "/" + target.nesting + "/" + target.item;
|
||||
trect.Color(SCyan);
|
||||
break;
|
||||
case DocDir::OBSOLETE:
|
||||
trect.Color(SRed);
|
||||
break;
|
||||
case DocDir::EXTERNAL:
|
||||
trect.Color(SGreen);
|
||||
break;
|
||||
}
|
||||
title = s;
|
||||
int status = item.Get(4);
|
||||
int kind = item.Get(2);
|
||||
String name = item.Get(1);
|
||||
String text = item.Get(0);
|
||||
String post;
|
||||
if(status == DocDir::EXTERNAL)
|
||||
post = " (external)";
|
||||
if(!name.IsEmpty() && status != DocDir::EXTERNAL) {
|
||||
int q = PosOf(text, name);
|
||||
if(q >= 0) {
|
||||
if(current.nesting.IsEmpty() || kind == STRUCT || kind == STRUCTTEMPLATE)
|
||||
Title(text.Mid(0, q) + current.nameing + text.Mid(q) + post);
|
||||
else
|
||||
Title(text.Mid(0, q) + current.nameing + current.nesting + "::" + text.Mid(q)
|
||||
+ post);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Title(current.nameing + "::" + current.nesting + "::" + text + post);
|
||||
}
|
||||
|
||||
void DocBrowser::Flush()
|
||||
{
|
||||
if(edit.IsShown() && target && item.IsCursor()) {
|
||||
posinfo.GetAdd(current) = edit.GetPosInfo();
|
||||
if(edit.IsModified()) {
|
||||
DocItem& im = set.Get(target.nameing).Get(target.nesting).Get(target.item);
|
||||
const RichText& txt = edit.Get();
|
||||
SaveFile(CommonPath("dppstyles.qtf"), StylesAsQTF(txt));
|
||||
if(edit.GetLength()) {
|
||||
doc_dir.SaveText(GetItemPackage(), target, BodyAsQTF(txt),
|
||||
doc_dir.GetStatus(target) == DocDir::EXTERNAL);
|
||||
im.status = DocDir::NORMAL;
|
||||
}
|
||||
else {
|
||||
doc_dir.Remove(target);
|
||||
im.status = DocDir::UNDOCUMENTED;
|
||||
}
|
||||
String p = doc_dir.GetFilePath(target);
|
||||
FileInfo& fi = editstate.GetAdd(p);
|
||||
fi.time = GetFileTime(p);
|
||||
fi.info = edit.PickUndoInfo();
|
||||
}
|
||||
target.Clear();
|
||||
if(edit.IsModified())
|
||||
ReloadItems();
|
||||
edit.ClearModify();
|
||||
}
|
||||
}
|
||||
|
||||
void DocBrowser::Query()
|
||||
{
|
||||
DocQuery q;
|
||||
q.lang = (int)~lang;
|
||||
q.undocumented = q.normal = q.external = q.obsolete = q.ignored = false;
|
||||
switch(query.status) {
|
||||
case 4:
|
||||
q.ignored = true;
|
||||
case 0:
|
||||
q.undocumented = q.normal = q.external = q.obsolete = true;
|
||||
break;
|
||||
case 1:
|
||||
q.undocumented = true;
|
||||
break;
|
||||
case 2:
|
||||
q.obsolete = true;
|
||||
break;
|
||||
case 3:
|
||||
q.ignored = true;
|
||||
break;
|
||||
}
|
||||
q.name = query.name;
|
||||
q.text = query.text;
|
||||
q.header = ~query.header;
|
||||
set = doc_dir.Select(q);
|
||||
nameing.ClearList();
|
||||
for(int i = 0; i < set.GetCount(); i++)
|
||||
nameing.Add(set.GetKey(i));
|
||||
if(nameing.GetCount())
|
||||
nameing.SetIndex(0);
|
||||
Nameing();
|
||||
}
|
||||
|
||||
void DocBrowser::Select()
|
||||
{
|
||||
int c;
|
||||
query.header.ClearList();
|
||||
Vector<String> h = doc_base.GetHeaders();
|
||||
for(int i = 0; i < h.GetCount(); i++)
|
||||
query.header.Add(h[i], GetFileName(h[i]));
|
||||
query.header.Add(Null, "<any>");
|
||||
for(;;) {
|
||||
c = query.Run();
|
||||
if(c == IDCANCEL)
|
||||
break;;
|
||||
if(c == IDYES) {
|
||||
query.status = 0;
|
||||
query.name <<= Null;
|
||||
query.text <<= Null;
|
||||
}
|
||||
if(c == IDOK)
|
||||
break;
|
||||
}
|
||||
query.Close();
|
||||
query.name.AddHistory();
|
||||
query.text.AddHistory();
|
||||
if(c == IDOK)
|
||||
Query();
|
||||
}
|
||||
|
||||
bool DocBrowser::Key(dword key, int)
|
||||
{
|
||||
switch(key) {
|
||||
case K_F6:
|
||||
Select();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DocBrowser::Edit()
|
||||
{
|
||||
Flush();
|
||||
edit.Show();
|
||||
view.Hide();
|
||||
EnterItem();
|
||||
}
|
||||
|
||||
void DocBrowser::View()
|
||||
{
|
||||
view.Show();
|
||||
edit.Hide();
|
||||
Item();
|
||||
}
|
||||
|
||||
void DocBrowser::Sort()
|
||||
{
|
||||
sort = !sort;
|
||||
Nesting();
|
||||
}
|
||||
|
||||
int DocBrowser::GetCurrentStatus()
|
||||
{
|
||||
return item.IsCursor() ? doc_dir.GetStatus(current) : Null;
|
||||
}
|
||||
|
||||
void DocBrowser::ReloadItems()
|
||||
{
|
||||
int c = item.GetCursor();
|
||||
int a = item.GetCursorSc();
|
||||
Nesting();
|
||||
if(c >= 0)
|
||||
item.SetCursor(c);
|
||||
item.ScCursor(a);
|
||||
}
|
||||
|
||||
void DocBrowser::SetCurrentStatus(int status)
|
||||
{
|
||||
set.GetAdd(current.nameing).GetAdd(current.nesting).GetAdd(current.item).status = status;
|
||||
ReloadItems();
|
||||
}
|
||||
|
||||
void DocBrowser::Link()
|
||||
{
|
||||
int q = GetCurrentStatus();
|
||||
if(q != DocDir::UNDOCUMENTED && q != DocDir::LINK || !item.IsCursor())
|
||||
return;
|
||||
String pk = GetItemPackage();
|
||||
String h;
|
||||
if(GetCurrentStatus() == DocDir::LINK)
|
||||
h = doc_dir.GetLink(current);
|
||||
if(linkdlg.Perform(set, sort, h, (int)~lang, ~nameing, nesting.GetKey())) {
|
||||
int c = item.GetCursor();
|
||||
item.KillCursor();
|
||||
doc_dir.SaveLink(pk, current, h);
|
||||
item.SetCursor(c);
|
||||
SetCurrentStatus(DocDir::LINK);
|
||||
}
|
||||
}
|
||||
|
||||
void DocBrowser::Ignore()
|
||||
{
|
||||
int q = GetCurrentStatus();
|
||||
if(q != DocDir::UNDOCUMENTED || !item.IsCursor()) return;
|
||||
int c = item.GetCursor();
|
||||
String pk = GetItemPackage();
|
||||
item.KillCursor();
|
||||
doc_dir.Ignore(pk, current);
|
||||
item.SetCursor(c);
|
||||
SetCurrentStatus(DocDir::IGNORED);
|
||||
}
|
||||
|
||||
void DocBrowser::Delete()
|
||||
{
|
||||
int q = GetCurrentStatus();
|
||||
if(q == DocDir::UNDOCUMENTED || !item.IsCursor()) return;
|
||||
int c = item.GetCursor();
|
||||
item.KillCursor();
|
||||
switch(q) {
|
||||
case DocDir::OBSOLETE:
|
||||
case DocDir::OBSOLETELINK:
|
||||
break;
|
||||
default:
|
||||
if(!PromptYesNo("Remove current current ?")) return;
|
||||
}
|
||||
doc_dir.Remove(current);
|
||||
item.SetCursor(c);
|
||||
SetCurrentStatus(DocDir::UNDOCUMENTED);
|
||||
}
|
||||
|
||||
void DocBrowser::New()
|
||||
{
|
||||
|
||||
external.package.Add("Core"); //!!!
|
||||
external.package <<= doc_dir.GetPackage(current);
|
||||
external.nameing <<= ~nameing;
|
||||
external.nesting <<= nesting.GetKey();
|
||||
again:
|
||||
if(external.Execute() != IDOK) return;
|
||||
if(IsNull(external.nameing)) {
|
||||
Exclamation("Missing namespace !");
|
||||
goto again;
|
||||
}
|
||||
if(IsNull(external.item)) {
|
||||
Exclamation("Missing item !");
|
||||
goto again;
|
||||
}
|
||||
external.nameing.AddHistory();
|
||||
external.nesting.AddHistory();
|
||||
DocKey k = DocKey(~external.nameing, ~external.nesting, ~external.item, (int)~lang);
|
||||
doc_dir.SaveText(~external.package, k, "", true);
|
||||
Query();
|
||||
nameing <<= k.nameing;
|
||||
Nameing();
|
||||
if(nesting.FindSetCursor(k.nesting))
|
||||
item.FindSetCursor(k.item);
|
||||
}
|
||||
|
||||
void DocBrowser::EditLink(String& s)
|
||||
{
|
||||
linkdlg.Perform(set, sort, s, (int)~lang, ~nameing, nesting.GetKey());
|
||||
}
|
||||
|
||||
void DocBrowser::FollowLink(const String& s)
|
||||
{
|
||||
if(memcmp(s, "dpp://", 6)) {
|
||||
Exclamation("Not a dpp link !");
|
||||
return;
|
||||
}
|
||||
Vector<String> l = Split(~s + 6, '/', false);
|
||||
if(l.GetCount() != 3) {
|
||||
Exclamation("Invalid link !");
|
||||
return;
|
||||
}
|
||||
if(nameing.HasKey(l[0])) {
|
||||
nameing.SetData(l[0]);
|
||||
Nameing();
|
||||
if(nesting.FindSetCursor(l[1])) {
|
||||
String n = l[2];
|
||||
String l;
|
||||
int q = n.Find('#');
|
||||
if(q >= 0) {
|
||||
l = n.Mid(q + 1);
|
||||
n = n.Mid(0, q);
|
||||
}
|
||||
if(item.FindSetCursor(n))
|
||||
return;
|
||||
}
|
||||
}
|
||||
Exclamation("Link not found");
|
||||
}
|
||||
|
||||
void DocBrowser::BrowseMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("Select..", THISBACK(Select))
|
||||
.Key(K_F6);
|
||||
bar.Separator();
|
||||
bar.Add("Edit", THISBACK(Edit))
|
||||
.Radio(edit.IsShown())
|
||||
.Key(K_CTRL_O);
|
||||
bar.Add("View", THISBACK(View))
|
||||
.Radio(view.IsShown())
|
||||
.Key(edit.IsShown() ? K_ESCAPE : 0);
|
||||
bar.Separator();
|
||||
bar.Add("Sort by types and names", THISBACK(Sort))
|
||||
.Check(sort);
|
||||
bar.Separator();
|
||||
}
|
||||
|
||||
void DocBrowser::ItemMenu(Bar& bar)
|
||||
{
|
||||
int q = GetCurrentStatus();
|
||||
bar.Add(q == DocDir::UNDOCUMENTED || q == DocDir::LINK,
|
||||
"Link..", THISBACK(Link))
|
||||
.Key(K_CTRL_L);
|
||||
bar.Add(q == DocDir::UNDOCUMENTED, "Ignore", THISBACK(Ignore))
|
||||
.Key(K_CTRL_I);
|
||||
bar.Add(q != DocDir::UNDOCUMENTED, "Delete", THISBACK(Delete))
|
||||
.Key(K_CTRL_DELETE);
|
||||
bar.Add("New..", THISBACK(New));
|
||||
}
|
||||
|
||||
void DocBrowser::MainMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("Browse", THISBACK(BrowseMenu));
|
||||
bar.Add("Item", THISBACK(ItemMenu));
|
||||
}
|
||||
|
||||
void DocBrowser::EditBar(Bar& bar)
|
||||
{
|
||||
edit.StyleTool(bar);
|
||||
bar.Gap();
|
||||
edit.FontTools(bar);
|
||||
bar.Gap();
|
||||
edit.InkTool(bar);
|
||||
edit.PaperTool(bar);
|
||||
bar.Gap();
|
||||
edit.LanguageTool(bar);
|
||||
edit.SpellCheckTool(bar);
|
||||
bar.Break();
|
||||
|
||||
edit.HyperlinkTool(bar, 300);
|
||||
bar.Gap();
|
||||
edit.LabelTool(bar);
|
||||
bar.Gap();
|
||||
edit.IndexEntryTool(bar);
|
||||
bar.Break();
|
||||
|
||||
edit.ParaTools(bar);
|
||||
bar.Gap();
|
||||
edit.EditTools(bar);
|
||||
bar.Gap();
|
||||
edit.PrintTool(bar);
|
||||
}
|
||||
|
||||
void DocBrowser::SetEditBar()
|
||||
{
|
||||
editbar.Set(THISBACK(EditBar));
|
||||
}
|
||||
|
||||
void DocBrowser::SetMainBar()
|
||||
{
|
||||
menu.Set(THISBACK(MainMenu));
|
||||
}
|
||||
|
||||
void DocBrowser::Close()
|
||||
{
|
||||
Flush();
|
||||
TopWindow::Close();
|
||||
}
|
||||
|
||||
DocBrowser::DocBrowser()
|
||||
{
|
||||
Zoomable().Sizeable().Icon(DppImg::SmallIcon);
|
||||
ni_split.Vert(nesting, item);
|
||||
ni_split.SetPos(3000);
|
||||
int q = nameing.GetMinSize().cy;
|
||||
larea.Add(nameing.HSizePos().TopPos(0, q));
|
||||
larea.Add(ni_split.HSizePos().VSizePos(q + 4, 0));
|
||||
rarea.AddFrame(trect.Height(q + 4));
|
||||
trect.SetFrame(ThinInsetFrame());
|
||||
trect.Add(title.SizePos());
|
||||
trect.Add(package.RightPos(0, 100).VSizePos());
|
||||
rarea.Add(view.SizePos());
|
||||
rarea.Add(edit.SizePos());
|
||||
vi_split.Horz(larea, rarea);
|
||||
vi_split.SetPos(3000);
|
||||
Add(vi_split);
|
||||
nesting.AddColumn().SetDisplay(Single<DocNestDisplay>());
|
||||
nesting.NoHeader().NoGrid();
|
||||
nameing <<= THISBACK(Nameing);
|
||||
nesting.WhenEnterRow = THISBACK(Nesting);
|
||||
InitItemArray(item);
|
||||
item.WhenEnterRow = THISBACK(Item);
|
||||
item.WhenKillCursor = THISBACK(Flush);
|
||||
item.WhenBar = THISBACK(ItemMenu);
|
||||
item.WhenLeftDouble = THISBACK(Edit);
|
||||
|
||||
view.Show();
|
||||
edit.Hide();
|
||||
edit.SetPage(Size(3968, INT_MAX));
|
||||
|
||||
CtrlLayoutOKCancel(query, "Select");
|
||||
query.clear <<= query.Breaker(IDYES);
|
||||
query.status = 0;
|
||||
|
||||
AddFrame(menu);
|
||||
SetMainBar();
|
||||
menu.Ctrl::Add(lang.RightPos(10, 70).TopPos(0, EditField::GetStdHeight()));
|
||||
lang.Add((int)LNG_ENGLISH, "EN-US");
|
||||
lang.Add((int)LNGFromText("EN-GB"), "EN-GB");
|
||||
lang.Add((int)LNGFromText("DE-DE"), "DE-DE");
|
||||
lang.Add((int)LNG_CZECH, "CS-CZ");
|
||||
lang <<= (int)LNGFromText("EN-US");
|
||||
lang <<= THISBACK(Query);
|
||||
|
||||
edit.InsertFrame(1, editbar);
|
||||
edit.WhenRefreshBar = THISBACK(SetEditBar);
|
||||
edit.WhenHyperlink = THISBACK(EditLink);
|
||||
|
||||
view.WhenLink = THISBACK(FollowLink);
|
||||
|
||||
sort = false;
|
||||
|
||||
CtrlLayoutOKCancel(external, "New external item");
|
||||
external.ActiveFocus(external.item);
|
||||
}
|
||||
|
||||
void AppMain()
|
||||
{
|
||||
doc_base.ignore.Add("pick_");
|
||||
FindFile ff("f:/uppsrc/Core/*.h");
|
||||
while(ff) {
|
||||
String fn = String("f:/uppsrc/Core/") + ff.GetName();
|
||||
try {
|
||||
doc_base.ParseFile(fn, "Core");
|
||||
}
|
||||
catch(Parser::Error e) {
|
||||
LOG(e);
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
doc_dir.Refresh("Core");
|
||||
DocBrowser d;
|
||||
d.Query();
|
||||
d.Run();
|
||||
}
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
#include <RichEdit/RichEdit.h>
|
||||
#include <docpp/docpp.h>
|
||||
|
||||
#define IMAGECLASS DppImg
|
||||
#define IMAGEFILE <Docedit/Docedit.iml>
|
||||
#include <Draw/iml_header.h>
|
||||
|
||||
// before placed to IDE...
|
||||
|
||||
String SourcePath(const String& package, const String& name);
|
||||
String PackageDirectory(const String& name);
|
||||
String CommonPath(const String& filename);
|
||||
|
||||
// ------
|
||||
|
||||
struct DocBase : public CppBase {
|
||||
Vector<String> DocBase::ignore;
|
||||
Vector<String> package;
|
||||
|
||||
void RemoveFile(const String& file);
|
||||
void ParseFile(const String& file, const String& package) throw(Parser::Error);
|
||||
void RefreshFile(const String& file, const String& package) throw(Parser::Error);
|
||||
Vector<String> GetHeaders();
|
||||
Vector<String> GetPackages();
|
||||
};
|
||||
|
||||
extern DocBase doc_base;
|
||||
|
||||
Time GetFileTime(const char *path);
|
||||
String DocFile(const String& package, const String& name);
|
||||
|
||||
struct DocKey {
|
||||
String nameing;
|
||||
String nesting;
|
||||
String item;
|
||||
dword lang;
|
||||
|
||||
bool operator==(const DocKey& b) const;
|
||||
dword GetHashValue(const DocKey& k);
|
||||
operator bool() const { return item.GetLength(); }
|
||||
void Clear() { item.Clear(); nesting.Clear(); nameing.Clear(); lang = 0; }
|
||||
|
||||
DocKey() {}
|
||||
DocKey(const String& m, const String& n, const String& s, dword l)
|
||||
: nameing(m), nesting(n), item(s), lang(l) {}
|
||||
};
|
||||
|
||||
dword GetHashValue(const DocKey& k);
|
||||
|
||||
struct DocQuery {
|
||||
String name, text, package, header;
|
||||
bool undocumented, normal, external, obsolete, ignored;
|
||||
dword lang;
|
||||
};
|
||||
|
||||
struct DocItem {
|
||||
CppItem *cppitem;
|
||||
String item;
|
||||
int status;
|
||||
String package;
|
||||
};
|
||||
|
||||
typedef VectorMap<String, VectorMap<String, ArrayMap<String, DocItem> > > DocSet;
|
||||
|
||||
class DocDir {
|
||||
struct Entry {
|
||||
int type;
|
||||
String text;
|
||||
};
|
||||
VectorMap<String, ArrayMap<DocKey, Entry> > dir;
|
||||
|
||||
int ReadDocHeader(const char *filename, DocKey& key);
|
||||
String GetAddFileName(const String& package, const DocKey& key, int type);
|
||||
bool GetFileName(const DocKey& key, String& fn, String& package);
|
||||
|
||||
bool LoadLinks(const String& package);
|
||||
void SaveLinks(const String& package) const;
|
||||
|
||||
void RemoveOtherKey(const DocKey& k, int t1, int t2 = UNDOCUMENTED);
|
||||
Entry *Find(const DocKey& key, String& package) const;
|
||||
Entry *Find(const DocKey& key) const;
|
||||
|
||||
public:
|
||||
enum {
|
||||
NORMAL, EXTERNAL, LINK, IGNORED,
|
||||
UNDOCUMENTED = -1, OBSOLETE = -2, OBSOLETELINK = -3
|
||||
};
|
||||
|
||||
bool LoadDir(const String& package);
|
||||
void SaveDir(const String& package) const;
|
||||
|
||||
void RebuildDir(const String& package);
|
||||
|
||||
void Refresh(const String& package);
|
||||
|
||||
int GetStatus(const DocKey& key);
|
||||
int GetStatus(const String& nameing, const String& nesting, const String& item, int lang);
|
||||
|
||||
String GetFilePath(const DocKey& key) const;
|
||||
String GetPackage(const DocKey& key) const;
|
||||
String GetText(const DocKey& key) const;
|
||||
String GetLink(const DocKey& key) const;
|
||||
|
||||
void Remove(const DocKey& key);
|
||||
void SaveText(const String& package, const DocKey& key, const String& text, bool external);
|
||||
void SaveLink(const String& package, const DocKey& key, const String& text);
|
||||
void Ignore(const String& package, const DocKey& key);
|
||||
|
||||
DocSet Select(const DocQuery& query);
|
||||
};
|
||||
|
||||
bool ParseLink(const String& link, DocKey& key, String& label);
|
||||
|
||||
extern DocDir doc_dir;
|
||||
|
||||
#define LAYOUTFILE "DocEdit.lay"
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
struct DocItemDisplay : public Display
|
||||
{
|
||||
virtual void Paint(Draw& w, const Rect& r, const Value& q,
|
||||
Color _ink, Color paper, dword style) const;
|
||||
};
|
||||
|
||||
struct DocNestDisplay : public Display
|
||||
{
|
||||
virtual void Paint(Draw& w, const Rect& r, const Value& q,
|
||||
Color _ink, Color paper, dword style) const;
|
||||
};
|
||||
|
||||
void InitItemArray(ArrayCtrl& item);
|
||||
void LoadItems(const DocSet& set, const String& nameing, const String& nesting, ArrayCtrl& item);
|
||||
int PosOf(const String& s, const String& subs);
|
||||
bool IsCppKeyword(const String& id);
|
||||
int CompareNests(const Value& v1, const Value& v2);
|
||||
int CompareItems(const Vector<Value>& row1, const Vector<Value>& row2);
|
||||
|
||||
struct DocLinkDlg : public WithLinkLayout<TopWindow> {
|
||||
const DocSet *set;
|
||||
bool sort;
|
||||
dword lang;
|
||||
|
||||
void Nameing();
|
||||
void Nesting();
|
||||
void Item();
|
||||
bool Perform(const DocSet& set, bool sort, String& link, int lang,
|
||||
const String& nameing = Null, const String& nesting = Null);
|
||||
void Label();
|
||||
String Get();
|
||||
|
||||
typedef DocLinkDlg CLASSNAME;
|
||||
|
||||
DocLinkDlg();
|
||||
};
|
||||
|
||||
class DocBrowser : public TopWindow {
|
||||
public:
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual void Close();
|
||||
|
||||
private:
|
||||
struct FileInfo {
|
||||
Time time;
|
||||
RichEdit::UndoInfo info;
|
||||
};
|
||||
|
||||
ArrayMap<String, FileInfo> editstate;
|
||||
ArrayMap<DocKey, RichEdit::PosInfo> posinfo;
|
||||
|
||||
DropList nameing;
|
||||
StaticRect larea, rarea;
|
||||
ArrayCtrl nesting;
|
||||
ArrayCtrl item;
|
||||
Splitter ni_split;
|
||||
Splitter vi_split;
|
||||
|
||||
FrameTop<StaticRect> trect;
|
||||
Label title;
|
||||
DataPusher package;
|
||||
RichTextView view;
|
||||
RichEdit edit;
|
||||
|
||||
DropList lang;
|
||||
|
||||
MenuBar menu;
|
||||
ToolBar tool;
|
||||
|
||||
ToolBar editbar;
|
||||
|
||||
WithQueryLayout<TopWindow> query;
|
||||
DocSet set;
|
||||
DocKey current, target;
|
||||
|
||||
DocLinkDlg linkdlg;
|
||||
|
||||
bool sort;
|
||||
|
||||
WithExternalLayout<TopWindow> external;
|
||||
|
||||
void Nameing();
|
||||
void Nesting();
|
||||
void Item();
|
||||
void EnterItem();
|
||||
|
||||
void ReloadItems();
|
||||
|
||||
DocKey Key();
|
||||
void Flush();
|
||||
int GetCurrentStatus();
|
||||
void SetCurrentStatus(int status);
|
||||
String GetItemPackage() { return item.Get(7); }
|
||||
|
||||
void EditLink(String& s);
|
||||
|
||||
void Edit();
|
||||
void View();
|
||||
void Sort();
|
||||
void Select();
|
||||
void Link();
|
||||
void Ignore();
|
||||
void Delete();
|
||||
void New();
|
||||
|
||||
void FollowLink(const String& s);
|
||||
|
||||
void SetMainBar();
|
||||
|
||||
void MainMenu(Bar& bar);
|
||||
void ItemMenu(Bar& bar);
|
||||
void BrowseMenu(Bar& bar);
|
||||
|
||||
void EditBar(Bar& bar);
|
||||
void SetEditBar();
|
||||
|
||||
public:
|
||||
typedef DocBrowser CLASSNAME;
|
||||
|
||||
void Query();
|
||||
|
||||
DocBrowser();
|
||||
};
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
PREMULTIPLIED
|
||||
IMAGE_ID(Variable)
|
||||
IMAGE_ID(SmallIcon)
|
||||
IMAGE_ID(InstanceVariable)
|
||||
IMAGE_ID(ClassVariable)
|
||||
IMAGE_ID(Function)
|
||||
IMAGE_ID(InstanceFunction)
|
||||
IMAGE_ID(InlineFriend)
|
||||
IMAGE_ID(ClassFunction)
|
||||
IMAGE_ID(FunctionTemplate)
|
||||
IMAGE_ID(InstanceFunctionTemplate)
|
||||
IMAGE_ID(ClassFunctionTemplate)
|
||||
IMAGE_ID(Enum)
|
||||
IMAGE_ID(Protected)
|
||||
IMAGE_ID(Struct)
|
||||
IMAGE_ID(StructTemplate)
|
||||
IMAGE_ID(Other)
|
||||
IMAGE_ID(Typedef)
|
||||
IMAGE_ID(Constructor)
|
||||
IMAGE_ID(Destructor)
|
||||
IMAGE_ID(Macro)
|
||||
|
||||
IMAGE_BEGIN_DATA
|
||||
IMAGE_DATA(120,156,237,152,11,146,131,32,12,134,115,132,30,185,71,243,102,217,105,187,190,32,228,137,21,107,226,48,221,110,249,18)
|
||||
IMAGE_DATA(192,248,19,129,7,60,0,0,17,86,67,69,147,236,211,175,117,89,252,112,215,119,124,212,227,246,142,225,181,208,136,30)
|
||||
IMAGE_DATA(31,103,242,209,249,71,214,223,203,70,242,175,71,254,95,211,8,49,104,153,117,17,202,254,210,119,142,71,152,147,88,199)
|
||||
IMAGE_DATA(151,201,82,242,136,80,249,235,197,215,137,135,184,182,127,118,110,132,143,8,223,78,126,157,143,40,127,246,252,123,220,191)
|
||||
IMAGE_DATA(30,60,144,243,226,191,247,230,237,118,64,101,64,239,32,58,101,174,110,60,123,145,137,84,240,54,31,60,175,219,25,169)
|
||||
IMAGE_DATA(249,45,125,179,50,112,198,182,177,89,25,120,44,95,19,12,201,236,123,24,86,31,223,121,152,35,98,132,65,49,228,121)
|
||||
IMAGE_DATA(121,253,107,222,126,239,34,155,81,185,126,183,23,3,141,69,22,36,178,160,33,22,245,15,111,119,214,201,111,31,13,107)
|
||||
IMAGE_DATA(114,238,88,170,113,108,171,5,230,178,140,233,4,22,224,188,188,155,249,241,173,33,6,26,245,108,25,181,59,80,190,61)
|
||||
IMAGE_DATA(188,114,23,37,121,75,50,149,243,79,49,72,49,184,173,24,72,118,187,202,96,154,166,16,235,21,131,153,221,196,87,139)
|
||||
IMAGE_DATA(193,150,165,62,57,182,213,12,115,169,229,199,42,200,126,182,246,225,207,157,8,187,245,49,190,165,24,124,135,205,202,96)
|
||||
IMAGE_DATA(29,211,134,181,60,104,53,203,87,160,21,95,244,177,240,212,239,86,158,243,59,134,88,12,46,6,229,98,181,18,73,149)
|
||||
IMAGE_DATA(76,198,221,125,23,171,96,45,177,223,172,179,178,88,88,111,101,192,53,142,109,181,192,92,150,49,41,88,106,126,220,61)
|
||||
IMAGE_DATA(80,197,86,246,37,99,7,226,206,204,248,118,128,24,136,73,202,254,70,157,70,235,197,128,61,111,80,36,98,243,188,193)
|
||||
IMAGE_DATA(32,6,100,18,167,24,172,99,82,176,41,6,103,88,86,6,170,113,102,101,160,23,3,110,92,50,75,111,6,20,75,197)
|
||||
IMAGE_DATA(57,236,240,89,136,187,247,65,141,235,10,230,20,131,163,141,75,124,233,97,144,94,149,171,86,248,40,255,159,241,239,21)
|
||||
IMAGE_DATA(31,12,113,61,2,63,174,213,98,240,124,125,193,167,123,146,31,254,253,151,203,71,198,207,248,87,142,127,97,99,42,131)
|
||||
IMAGE_DATA(136,42,234,133,153,82,101,155,176,215,37,89,242,119,230,163,249,183,250,184,83,85,240,178,163,196,64,122,95,101,222,61)
|
||||
IMAGE_DATA(165,190,187,70,248,96,251,42,198,144,241,175,29,159,245,209,227,220,164,104,191,99,131,158,25,80,102,175,78,54,173,101)
|
||||
IMAGE_DATA(28,175,49,137,111,37,97,198,63,63,62,195,138,241,5,22,224,130,34,242,7,126,154,4,137,0,0,0,0,0,0,0)
|
||||
IMAGE_END_DATA(608, 16)
|
||||
|
||||
IMAGE_BEGIN_DATA
|
||||
IMAGE_DATA(120,156,237,150,137,13,195,48,8,69,25,33,35,103,52,111,70,213,86,74,28,204,241,125,201,74,90,34,164,28,188,143)
|
||||
IMAGE_DATA(141,45,28,218,104,35,34,102,26,111,108,56,206,107,23,174,161,243,184,134,205,99,26,62,31,107,196,188,175,49,55,127)
|
||||
IMAGE_DATA(207,252,123,234,95,179,254,125,251,239,247,172,178,25,212,22,51,143,103,46,23,211,221,140,34,62,122,142,52,172,251,112)
|
||||
IMAGE_DATA(14,239,88,233,0,123,201,101,240,150,142,202,88,110,105,116,228,31,49,255,131,165,182,250,15,89,127,71,79,126,71,236)
|
||||
IMAGE_DATA(217,205,100,226,159,193,104,107,237,238,95,102,223,79,199,117,174,156,116,164,33,180,243,62,27,107,172,230,87,215,239,212)
|
||||
IMAGE_DATA(104,95,255,82,231,201,13,193,105,6,218,233,81,117,162,164,148,62,158,243,202,59,51,175,136,53,223,89,121,17,159,193)
|
||||
IMAGE_DATA(119,142,255,95,191,181,245,43,198,145,243,64,222,219,218,11,170,178,33,106,0,0,0,0,0,0,0,0,0,0,0,0)
|
||||
IMAGE_END_DATA(224, 4)
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#ifdef LAYOUTFILE
|
||||
|
||||
LAYOUT(QueryLayout, 372, 120)
|
||||
ITEM(LabelBox, dv___0, LeftPosZ(8, 132).TopPosZ(4, 108).SetLabel("Status"))
|
||||
ITEM(Switch, status, LeftPosZ(16, 117).TopPosZ(20, 85).SetLabel("Any except ignored\nUndocumented\nObsolete\nIgnored\nAny"))
|
||||
ITEM(Label, dv___2, LeftPosZ(152, 48).TopPosZ(12, 13).SetLabel("Name"))
|
||||
ITEM(WithDropChoice<EditString>, name, LeftPosZ(204, 160).TopPosZ(8, 19))
|
||||
ITEM(Label, dv___4, LeftPosZ(152, 48).TopPosZ(36, 13).SetLabel("Contains"))
|
||||
ITEM(WithDropChoice<EditString>, text, LeftPosZ(204, 160).TopPosZ(32, 19))
|
||||
ITEM(Label, dv___6, LeftPosZ(152, 44).TopPosZ(59, 13).SetLabel("Header"))
|
||||
ITEM(DropList, header, LeftPosZ(204, 160).TopPosZ(56, 19))
|
||||
ITEM(Button, ok, LeftPosZ(232, 64).TopPosZ(88, 24).SetLabel("OK"))
|
||||
ITEM(Button, cancel, LeftPosZ(300, 64).TopPosZ(88, 24).SetLabel("Cancel"))
|
||||
ITEM(Button, clear, LeftPosZ(152, 64).TopPosZ(88, 24).SetLabel("Clear"))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(LinkLayout, 632, 500)
|
||||
ITEM(Label, dv___0, LeftPosZ(8, 28).TopPosZ(12, 13).SetLabel("Link"))
|
||||
ITEM(WithDropChoice<EditString>, link, LeftPosZ(44, 580).TopPosZ(8, 19))
|
||||
ITEM(DropList, nameing, LeftPosZ(8, 224).TopPosZ(36, 19))
|
||||
ITEM(ArrayCtrl, nesting, LeftPosZ(8, 224).TopPosZ(60, 400))
|
||||
ITEM(ArrayCtrl, item, LeftPosZ(240, 384).TopPosZ(36, 300))
|
||||
ITEM(ArrayCtrl, label, LeftPosZ(240, 384).TopPosZ(340, 120))
|
||||
ITEM(Button, ok, LeftPosZ(492, 64).TopPosZ(468, 24).SetLabel("OK"))
|
||||
ITEM(Button, cancel, LeftPosZ(560, 64).TopPosZ(468, 24).SetLabel("Cancel"))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(ExternalLayout, 400, 108)
|
||||
ITEM(Label, dv___0, LeftPosZ(4, 68).TopPosZ(8, 13).SetLabel("Namespace"))
|
||||
ITEM(WithDropChoice<EditString>, nameing, LeftPosZ(80, 76).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___2, LeftPosZ(176, 43).TopPosZ(8, 13).SetLabel("Nesting"))
|
||||
ITEM(WithDropChoice<EditString>, nesting, LeftPosZ(224, 168).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___4, LeftPosZ(4, 28).TopPosZ(31, 13).SetLabel("Item"))
|
||||
ITEM(EditString, item, LeftPosZ(80, 312).TopPosZ(28, 19))
|
||||
ITEM(Label, dv___6, LeftPosZ(4, 72).TopPosZ(56, 13).SetLabel("Host package"))
|
||||
ITEM(DropList, package, LeftPosZ(80, 100).TopPosZ(52, 19))
|
||||
ITEM(Button, ok, LeftPosZ(260, 64).TopPosZ(76, 24).SetLabel("OK"))
|
||||
ITEM(Button, cancel, LeftPosZ(328, 64).TopPosZ(76, 24).SetLabel("Cancel"))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(TemplateLayout, 672, 568)
|
||||
ITEM(Button, ok, LeftPosZ(532, 64).TopPosZ(536, 24).SetLabel("OK"))
|
||||
ITEM(Button, cancel, LeftPosZ(600, 64).TopPosZ(536, 24).SetLabel("Cancel"))
|
||||
ITEM(DocEdit, code, LeftPosZ(164, 500).TopPosZ(8, 160))
|
||||
ITEM(RichTextView, view, LeftPosZ(164, 500).TopPosZ(172, 352))
|
||||
END_LAYOUT
|
||||
|
||||
#endif
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
uses
|
||||
docpp,
|
||||
RichEdit;
|
||||
|
||||
file
|
||||
Docedit.h,
|
||||
Docbase.cpp,
|
||||
Docdir.cpp,
|
||||
DocItem.cpp,
|
||||
DocLink.cpp,
|
||||
Docedit.cpp,
|
||||
Docedit.iml,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
description "Windows GUI OLE encapsulation\377";
|
||||
|
||||
uses
|
||||
Ole,
|
||||
CtrlCore;
|
||||
|
||||
file
|
||||
OleCtrl.h,
|
||||
util.cpp,
|
||||
control.cpp,
|
||||
ocx.def;
|
||||
|
||||
custom() "idl",
|
||||
"midl /newtlb $(!/I) /h \"$(DIR)/$(TITLE)_idl.h\" /iid \"$(DIR)/$(TITLE"
|
||||
")_idl.cpp\" /tlb \"$(DIR)/$(TITLE).tlb\" \"$(PATH)\"\r\n",
|
||||
"$(DIR)/$(TITLE)_idl.h\r\n$(DIR)/$(TITLE).tlb\r\n";
|
||||
|
||||
|
|
@ -1,829 +0,0 @@
|
|||
#ifndef _Ole_Ctrl_OleCtrl_h_
|
||||
#define _Ole_Ctrl_OleCtrl_h_
|
||||
|
||||
#include <CtrlCore/CtrlCore.h>
|
||||
#include <Ole/Ole.h>
|
||||
|
||||
namespace Upp {
|
||||
|
||||
#define OCXLOG RLOG // redefine to RLOG if you want logs in retail versions
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LOG_SYSOCXS 1 // 1 = log system calls (DllCanUnloadNow, DllGetClassObject)
|
||||
#define LOG_METHODS 1 // 1 = log method calls
|
||||
#define LOG_CREATES 1 // 1 = log instance creations & destructions
|
||||
#define LOG_QUERIES 2 // 1 = log failed QueryInterface's
|
||||
// // 2 = log all QueryInterface's
|
||||
// // 3 = dump interface map whenever Query fails
|
||||
#define LOG_PERSIST 1 // 1 = log saves / loads
|
||||
#define LOG_RESULTS 2 // 1 = log error results
|
||||
// // 2 = log all results
|
||||
#define LOG_ADDREFS 1 // 1 = log AddRef's / Releases
|
||||
#define LOG_INVOKES 1 // 1 = log IDispatch::Invoke
|
||||
#else
|
||||
#define LOG_SYSOCXS 1
|
||||
#define LOG_METHODS 0
|
||||
#define LOG_CREATES 0
|
||||
#define LOG_QUERIES 0
|
||||
#define LOG_PERSIST 0
|
||||
#define LOG_RESULTS 0
|
||||
#define LOG_ADDREFS 0
|
||||
#define LOG_INVOKES 0
|
||||
#endif
|
||||
|
||||
#if LOG_SYSOCXS >= 1
|
||||
#define LOGSYSOCX(x) OCXLOG(x)
|
||||
#else
|
||||
#define LOGSYSOCX(x)
|
||||
#endif
|
||||
|
||||
#if LOG_METHODS >= 1
|
||||
#define LOGMETHOD(x) OCXLOG(x)
|
||||
#else
|
||||
#define LOGMETHOD(x)
|
||||
#endif
|
||||
|
||||
#if LOG_CREATES >= 1
|
||||
#define LOGCREATE(x) OCXLOG(x)
|
||||
#else
|
||||
#define LOGCREATE(x)
|
||||
#endif
|
||||
|
||||
#if LOG_QUERIES >= 1
|
||||
#define LOGQUERY(x) OCXLOG(x)
|
||||
#else
|
||||
#define LOGQUERY(x)
|
||||
#endif
|
||||
|
||||
#if LOG_PERSIST >= 1
|
||||
#define LOGPERSIST(x) OCXLOG(x)
|
||||
#else
|
||||
#define LOGPERSIST(x)
|
||||
#endif
|
||||
|
||||
#if LOG_RESULTS >= 2
|
||||
#define LOGRESULT(x) LogResult((x))
|
||||
#elif LOG_RESULTS >= 1
|
||||
#define LOGRESULT(x) LogError((x))
|
||||
#else
|
||||
#define LOGRESULT(x) (x)
|
||||
#endif
|
||||
|
||||
#if LOG_INVOKES >= 1
|
||||
#define LOGINVOKE(x) OCXLOG(x)
|
||||
#else
|
||||
#define LOGINVOKE(x)
|
||||
#endif
|
||||
|
||||
typedef void (*InitProc)();
|
||||
InitProc& LateInitProc();
|
||||
InitProc& LateExitProc();
|
||||
|
||||
void DoLateInit();
|
||||
void DoLateExit();
|
||||
|
||||
#define OCX_APP_MAIN \
|
||||
void _DllMainAppInit(); \
|
||||
\
|
||||
static void _DllMainLateExit() \
|
||||
{ \
|
||||
RLOGBLOCK("_DllMainLateExit"); \
|
||||
Ctrl::ExitWin32(); \
|
||||
} \
|
||||
\
|
||||
static void _DllMainLateInit() \
|
||||
{ \
|
||||
RLOGBLOCK("_DllMainLateInit"); \
|
||||
RLOG("Ctrl::InitWin32"); \
|
||||
Ctrl::InitWin32(AppGetHandle()); \
|
||||
RLOG("AppInitEnvironment"); \
|
||||
AppInitEnvironment__(); \
|
||||
RLOG("DllMainAppInit"); \
|
||||
_DllMainAppInit(); \
|
||||
LateExitProc() = &_DllMainLateExit; \
|
||||
} \
|
||||
\
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpReserved) \
|
||||
{ \
|
||||
if(fdwReason == DLL_PROCESS_ATTACH) { \
|
||||
AppSetHandle(hinstDll); \
|
||||
} \
|
||||
RLOG("DllMain(" << FormatIntHex(hinstDll) << ", reason = " << (int)fdwReason << ")"); \
|
||||
if(fdwReason == DLL_PROCESS_ATTACH) { \
|
||||
LateInitProc() = &_DllMainLateInit; \
|
||||
} \
|
||||
else if(fdwReason == DLL_PROCESS_DETACH) { \
|
||||
DoLateExit(); \
|
||||
} \
|
||||
RLOG("//DllMain(" << FormatIntHex(hinstDll) << ", reason = " << (int)fdwReason << ")"); \
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
void _DllMainAppInit()
|
||||
|
||||
/*
|
||||
_variant_t ValueToVariant(const Value& v);
|
||||
Value DispatchToValue(IDispatch *disp);
|
||||
Value UnknownToValue(IUnknown *unk);
|
||||
void ReturnVariant(VARIANT *var, const Value& v);
|
||||
HRESULT CheckReturnString(BSTR *bstr, const String& s);
|
||||
Color PackColor(long rgb);
|
||||
long UnpackColor(Color c);
|
||||
HRESULT CheckReturnColor(long *ptr, Color c);
|
||||
*/
|
||||
|
||||
#define std_method HRESULT STDMETHODCALLTYPE
|
||||
#define void_method void STDMETHODCALLTYPE
|
||||
|
||||
class OcxTypeInfo;
|
||||
|
||||
typedef VectorMap<Guid, IUnknown *> InterfaceMap;
|
||||
|
||||
inline void AddInterfaceRaw(InterfaceMap& map, const Guid& guid, IUnknown *iface)
|
||||
{
|
||||
map.Add(guid, iface);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void AddInterface(InterfaceMap& map, const Guid& guid, T *iface)
|
||||
{
|
||||
AddInterfaceRaw(map, guid, iface);
|
||||
}
|
||||
|
||||
#define PARENT_INTERFACE(clss, base) \
|
||||
template <> \
|
||||
inline void AddInterface(InterfaceMap& map, const Guid& guid, clss *iface) \
|
||||
{ \
|
||||
AddInterfaceRaw(map, guid, iface); \
|
||||
AddInterface<base>(map, __uuidof(base), iface); \
|
||||
}
|
||||
|
||||
PARENT_INTERFACE(IProvideClassInfo2, IProvideClassInfo)
|
||||
PARENT_INTERFACE(IViewObject2, IViewObject)
|
||||
PARENT_INTERFACE(IViewObjectEx, IViewObject2)
|
||||
PARENT_INTERFACE(IOleInPlaceObject, IOleWindow)
|
||||
PARENT_INTERFACE(IOleInPlaceObjectWindowless, IOleInPlaceObject)
|
||||
PARENT_INTERFACE(IOleInPlaceActiveObject, IOleWindow)
|
||||
PARENT_INTERFACE(IPersistStorage, IPersist)
|
||||
PARENT_INTERFACE(IPersistStream, IPersist)
|
||||
PARENT_INTERFACE(IPersistFile, IPersist)
|
||||
PARENT_INTERFACE(IClassFactory2, IClassFactory)
|
||||
|
||||
class OcxObject
|
||||
{
|
||||
friend class OcxTypeInfo;
|
||||
|
||||
public:
|
||||
OcxObject();
|
||||
|
||||
template <class T>
|
||||
void AddInterface(const Guid& guid, T *iface) { UPP::AddInterface<T>(interface_map, guid, iface); }
|
||||
template <class T>
|
||||
void AddInterface(T *iface) { UPP::AddInterface<T>(interface_map, __uuidof(T), iface); }
|
||||
|
||||
IUnknown *OuterUnknown() { return outer_unknown ? outer_unknown : &inner_unknown; }
|
||||
IUnknown *InnerUnknown() { return &inner_unknown; }
|
||||
|
||||
HRESULT InternalQueryInterface(const GUID& iid, void **ppv);
|
||||
HRESULT ExternalQueryInterface(const GUID& iid, void **ppv);
|
||||
|
||||
static HRESULT RawGetTypeInfo(IRef<ITypeInfo>& dispatch_info, unsigned tinfo, LCID lcid, ITypeInfo **ppinfo);
|
||||
static HRESULT RawGetIDsOfNames(IRef<ITypeInfo>& dispatch_info, REFIID riid, OLECHAR **names, unsigned cnames, LCID lcid, DISPID *dispid);
|
||||
static HRESULT RawInvoke(IRef<ITypeInfo>& dispatch_info, IDispatch *disp, DISPID dispid, word flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, unsigned *arg_err);
|
||||
|
||||
static const char *GetObjectName() { return ""; } // programmatic object name (synthetic = <ocx name>.<class name>)
|
||||
static const char *GetObjectHelp() { return ""; } // user-visible object name (synthetic = <class name> (CONTROL ? " Control " | " Object ") <version>
|
||||
// static GUID GetDispatchGUID() { return __uuidof(0); } // default ingoing dispatch interface
|
||||
static GUID GetEventGUID() { return __uuidof(0); } // default outgoing dispatch interface
|
||||
|
||||
enum
|
||||
{
|
||||
VERSION = 0,
|
||||
CONTROL = 0, // override with 1 to make a control class
|
||||
};
|
||||
|
||||
virtual int InternalAddRef() = 0;
|
||||
virtual int InternalRelease() = 0;
|
||||
|
||||
int ExternalAddRef();
|
||||
int ExternalRelease();
|
||||
|
||||
protected:
|
||||
class OcxInnerUnknown : public IUnknown {
|
||||
public:
|
||||
OcxInnerUnknown() : owner(0) {}
|
||||
ULONG STDMETHODCALLTYPE AddRef() { return owner->InternalAddRef(); }
|
||||
ULONG STDMETHODCALLTYPE Release() { return owner->InternalRelease(); }
|
||||
STDMETHOD(QueryInterface)(REFIID iid, void **ppv) { return owner->InternalQueryInterface(iid, ppv); }
|
||||
|
||||
public:
|
||||
OcxObject *owner;
|
||||
};
|
||||
|
||||
OcxTypeInfo *ocx_info;
|
||||
IUnknown *outer_unknown;
|
||||
InterfaceMap interface_map;
|
||||
OcxInnerUnknown inner_unknown;
|
||||
};
|
||||
|
||||
template <class I>
|
||||
class Interface : public I, virtual public OcxObject
|
||||
{
|
||||
public:
|
||||
Interface() { AddInterface<I>(this); }
|
||||
};
|
||||
|
||||
template <class I>
|
||||
class DispatchInterface : public Interface<I>
|
||||
{
|
||||
public:
|
||||
DispatchInterface() { AddInterface(__uuidof(I), this); AddInterface<IDispatch>(this); }
|
||||
// static GUID GetDispatchGUID() { return __uuidof(I); }
|
||||
|
||||
// IDispatch
|
||||
|
||||
STDMETHOD(GetTypeInfoCount)(unsigned *pctinfo);
|
||||
STDMETHOD(GetTypeInfo)(unsigned tinfo, LCID lcid, ITypeInfo **ppinfo);
|
||||
STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR **names, unsigned cnames, LCID lcid, DISPID *dispid);
|
||||
STDMETHOD(Invoke)(DISPID dispid, REFIID riid, LCID lcid, word flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, unsigned *arg_err);
|
||||
|
||||
protected:
|
||||
void LoadTypeInfo() { ocx_info->GetDispatchTypeInfo(dispatch_info, __uuidof(I)); }
|
||||
|
||||
protected:
|
||||
IRef<ITypeInfo> dispatch_info;
|
||||
};
|
||||
|
||||
template <class I>
|
||||
STDMETHODIMP DispatchInterface<I>::GetTypeInfoCount(unsigned *pctinfo)
|
||||
{
|
||||
if(!pctinfo) return E_POINTER;
|
||||
*pctinfo = 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
template <class I>
|
||||
STDMETHODIMP DispatchInterface<I>::GetTypeInfo(unsigned tinfo, LCID lcid, ITypeInfo **ppinfo)
|
||||
{
|
||||
if(!ppinfo) return E_POINTER;
|
||||
LoadTypeInfo();
|
||||
if(*ppinfo = ~dispatch_info) dispatch_info->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
template <class I>
|
||||
STDMETHODIMP DispatchInterface<I>::GetIDsOfNames(REFIID riid, OLECHAR **names, unsigned cnames, LCID lcid, DISPID *dispid)
|
||||
{
|
||||
LoadTypeInfo();
|
||||
return RawGetIDsOfNames(dispatch_info, riid, names, cnames, lcid, dispid);
|
||||
}
|
||||
|
||||
template <class I>
|
||||
STDMETHODIMP DispatchInterface<I>::Invoke(DISPID dispid, REFIID riid, LCID lcid, word flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, unsigned *arg_err)
|
||||
{
|
||||
LoadTypeInfo();
|
||||
return RawInvoke(dispatch_info, static_cast<I *>(this), dispid, flags, params, result, excep, arg_err);
|
||||
}
|
||||
|
||||
class OcxProvideClassInfo : public Interface<IProvideClassInfo2>
|
||||
{
|
||||
public:
|
||||
// IProvideClassInfo
|
||||
|
||||
STDMETHOD(GetClassInfo)(ITypeInfo **info);
|
||||
|
||||
// IProvideClassInfo2
|
||||
|
||||
STDMETHOD(GetGUID)(dword guidkind, GUID *guid);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class OcxObjectWrapper : public T
|
||||
{
|
||||
public:
|
||||
OcxObjectWrapper() : refcount(0) {}
|
||||
OcxObjectWrapper(OcxTypeInfo& _ocx_info) : refcount(0) { ocx_info = &_ocx_info; _ocx_info.object_count++; }
|
||||
|
||||
static OcxObject *New() { return new OcxObjectWrapper<T>(); }
|
||||
static OcxObject *New(OcxTypeInfo& _ocx_info) { return new OcxObjectWrapper<T>(_ocx_info); }
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() { return ExternalAddRef(); }
|
||||
virtual ULONG STDMETHODCALLTYPE Release() { return ExternalRelease(); }
|
||||
STDMETHOD(QueryInterface)(REFIID iid, void **ppv) { return ExternalQueryInterface(iid, ppv); }
|
||||
|
||||
static String GetName();
|
||||
|
||||
virtual int InternalAddRef();
|
||||
virtual int InternalRelease();
|
||||
|
||||
private:
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
ULONG refcount;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
int OcxObjectWrapper<T>::InternalAddRef()
|
||||
{
|
||||
++refcount;
|
||||
#if LOG_ADDREFS
|
||||
RLOG(GetTypeName(typeid(*this)) << "::InternalAddRef(" << refcount << ")");
|
||||
#endif
|
||||
return refcount;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int OcxObjectWrapper<T>::InternalRelease()
|
||||
{
|
||||
int u = --refcount;
|
||||
#if LOG_ADDREFS
|
||||
RLOG(GetTypeName(typeid(*this)) << "::InternalRelease(" << refcount << ")");
|
||||
#endif
|
||||
if(!u)
|
||||
Destroy();
|
||||
return u;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
String OcxObjectWrapper<T>::GetName()
|
||||
{
|
||||
if(*T::GetObjectName())
|
||||
return T::GetObjectName();
|
||||
return GetTypeName(typeid(T));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void OcxObjectWrapper<T>::Destroy()
|
||||
{
|
||||
if(ocx_info)
|
||||
{
|
||||
ocx_info->object_count--;
|
||||
LOGCREATE("\tdelete " << GetTypeName(typeid(T)) << ": "
|
||||
<< (int)ocx_info->object_count << " instances left in system");
|
||||
}
|
||||
else
|
||||
LOGCREATE("\tdelete " << GetTypeName(typeid(T)));
|
||||
delete this;
|
||||
}
|
||||
|
||||
class OcxTypeInfo : public Interface<IClassFactory2>
|
||||
{
|
||||
friend class OcxTypeLib;
|
||||
|
||||
public:
|
||||
typedef OcxObject *(*New)(OcxTypeInfo& entry);
|
||||
|
||||
OcxTypeInfo(const GUID& coclass_guid, /*const GUID& dispatch_guid,*/ const GUID& event_guid,
|
||||
New new_fn, String name, const char* help = "", int ver = 0,
|
||||
bool is_control = false);
|
||||
|
||||
bool IsControl() const { return is_control; }
|
||||
bool CanUnload() const;
|
||||
|
||||
const Guid& GetCoClassGUID() const { return coclass_guid; }
|
||||
// const Guid& GetDispatchGUID() const { return dispatch_guid; }
|
||||
const Guid& GetEventGUID() const { return event_guid; }
|
||||
|
||||
String GetName() const { return name; }
|
||||
|
||||
// IRef<ITypeInfo> GetDispatchTypeInfo();
|
||||
void GetDispatchTypeInfo(IRef<ITypeInfo>& dest, Guid dispatch_iid);
|
||||
IRef<ITypeInfo> GetCoClassTypeInfo();
|
||||
|
||||
// IUnknown
|
||||
|
||||
virtual int InternalAddRef() { return IncRef(); }
|
||||
virtual int InternalRelease() { return DecRef(); }
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() { return IncRef(); }
|
||||
virtual ULONG STDMETHODCALLTYPE Release() { return DecRef(); }
|
||||
STDMETHOD(QueryInterface)(REFIID iid, void **ppv) { return ExternalQueryInterface(iid, ppv); }
|
||||
|
||||
// IClassFactory
|
||||
|
||||
STDMETHOD(CreateInstance)(IUnknown *outer, REFIID iid, void **object);
|
||||
STDMETHOD(LockServer)(BOOL lock);
|
||||
|
||||
STDMETHOD(GetLicInfo)(/* [out] */ LICINFO *pLicInfo);
|
||||
STDMETHOD(RequestLicKey)(/* [in] */ DWORD dwReserved, /* [out] */ BSTR *pBstrKey);
|
||||
|
||||
STDMETHOD(CreateInstanceLic)(
|
||||
/* [in] */ IUnknown *pUnkOuter,
|
||||
/* [in] */ IUnknown *pUnkReserved,
|
||||
/* [in] */ REFIID riid,
|
||||
/* [in] */ BSTR bstrKey,
|
||||
/* [iid_is][out] */ PVOID *ppvObj);
|
||||
|
||||
public:
|
||||
long object_count; // managed object count
|
||||
IRef<ITypeInfo> coclass_info; // coclass type info
|
||||
// IRef<ITypeInfo> dispatch_info; // ingoing dispatch interface type info
|
||||
CriticalSection critical; // critical section used for initializations
|
||||
|
||||
private:
|
||||
int IncRef();
|
||||
int DecRef();
|
||||
|
||||
private:
|
||||
Guid coclass_guid; // coclass GUID
|
||||
Guid dispatch_guid; // GUID of default ingoing dispatch interface
|
||||
Guid event_guid; // GUID of default outgoing dispatch interface
|
||||
New new_fn; // constructor
|
||||
String name; // programmatic object name - <ocx name>.<class name>.<version> by default
|
||||
const char *help; // user-visible object name - <class name> (" Control " | " Object ") <version> by default
|
||||
int ver; // 0 = use main library version
|
||||
bool is_control; // false = generic object, true = insertable control
|
||||
|
||||
long refcount; // AddRef/Release counter
|
||||
Atomic lock_count; // LockServer lock count
|
||||
|
||||
#ifndef _USRDLL
|
||||
dword registration; // for CoRevokeClassObject
|
||||
#endif
|
||||
};
|
||||
|
||||
class OcxTypeLib
|
||||
{
|
||||
public:
|
||||
static OcxTypeLib& Get();
|
||||
|
||||
OcxTypeLib& Name(String name) { lib_name = name; return *this; }
|
||||
String GetName() const { return lib_name; }
|
||||
OcxTypeLib& DisplayName(String dn) { display_name = dn; return *this; }
|
||||
String GetDisplayName() const { return display_name; }
|
||||
String GetLibName() const;
|
||||
OcxTypeLib& UsesLibrary(String name) { uses_libraries.GetAdd(name); return *this; }
|
||||
|
||||
OcxTypeLib& Version(int _ver) { lib_ver = _ver; return *this; }
|
||||
int GetVersion() const { return lib_ver; }
|
||||
|
||||
HRESULT Register();
|
||||
HRESULT Unregister();
|
||||
HRESULT GetFactory(REFCLSID clsid, REFIID iid, void **ppv);
|
||||
bool CanUnload() const;
|
||||
#ifndef _USRDLL
|
||||
HRESULT RegisterObjects(); // call CoRegisterClassObject for each object
|
||||
void RevokeObjects(); // call CoRevokeClassObject
|
||||
#endif
|
||||
|
||||
void Add(OcxTypeInfo& entry) { objects.FindAdd(entry.coclass_guid, &entry); }
|
||||
void AddInit(void (*fn)()) { ocx_init.Add(fn); }
|
||||
|
||||
IRef<ITypeInfo> GetTypeInfo(const Guid& guid);
|
||||
|
||||
IRef<ITypeLib>& GetTypeLib();
|
||||
IRef<ITypeLib>& operator -> () { return GetTypeLib(); }
|
||||
|
||||
public:
|
||||
IRef<ITypeLib> typelib;
|
||||
CriticalSection critical;
|
||||
|
||||
private:
|
||||
OcxTypeLib();
|
||||
|
||||
private:
|
||||
VectorMap<Guid, OcxTypeInfo *> objects;
|
||||
Vector<void (*)()> ocx_init;
|
||||
String lib_name;
|
||||
String display_name;
|
||||
int lib_ver;
|
||||
VectorMap<String, IRef<ITypeLib> > uses_libraries;
|
||||
};
|
||||
|
||||
struct OcxInit { OcxInit(void (*fn)()) { OcxTypeLib::Get().AddInit(fn); } };
|
||||
#define OCX_INIT(fn) static OcxInit MK__s = fn;
|
||||
|
||||
#define OCX_OBJECT(type) \
|
||||
static OcxTypeInfo MK__s( \
|
||||
__uuidof(type), /* coclass GUID */ \
|
||||
/*type::GetDispatchGUID(),*/ /* default ingoing dispatch interface GUID */ \
|
||||
type::GetEventGUID(), /* default outgoing dispatch interface GUID */ \
|
||||
OcxObjectWrapper<type>::New, /* constructor */ \
|
||||
OcxObjectWrapper<type>::GetName(), /* name */ \
|
||||
type::GetObjectHelp(), /* help */ \
|
||||
type::VERSION, /* version */ \
|
||||
type::CONTROL); /* control object */
|
||||
|
||||
#define OCX_NEWOBJECT(type) \
|
||||
OCX_OBJECT(type) \
|
||||
static IRef<type> COMBINE(OcxNew_, type)() { return new OcxObjectWrapper<type>(MK__s); }
|
||||
|
||||
#ifndef _USRDLL
|
||||
bool ExeRegisterServer();
|
||||
bool ExeUnregisterServer();
|
||||
void ExeRunServer();
|
||||
#endif
|
||||
|
||||
Size ToHiMetric(Size pixel_size);
|
||||
Size FromHiMetric(Size himetric_size);
|
||||
Rect GetWindow(HDC hdc);
|
||||
Rect GetViewport(HDC hdc);
|
||||
|
||||
LPOLESTR AllocString(String s);
|
||||
|
||||
template <class T>
|
||||
class SinkMap : public VectorMap<dword, T>
|
||||
{
|
||||
public:
|
||||
typedef VectorMap<dword, T> Base;
|
||||
SinkMap() : next_sink_id(0) {}
|
||||
dword Add(const T& object) { Base::Add(++next_sink_id, object); return next_sink_id; }
|
||||
bool Remove(dword id) { int i = Find(id); return (i >= 0 ? (Base::Remove(i), true) : false); }
|
||||
|
||||
private:
|
||||
dword next_sink_id;
|
||||
};
|
||||
|
||||
//template OleType<IAdviseSinkPtr>;
|
||||
|
||||
class OcxControl : public Ctrl,
|
||||
public Interface<IOleInPlaceActiveObject>,
|
||||
public Interface<IOleInPlaceObject>,
|
||||
public Interface<IViewObjectEx>,
|
||||
public Interface<IDataObject>,
|
||||
public Interface<IPersistStorage>,
|
||||
public Interface<IPersistStreamInit>,
|
||||
public Interface<IOleObject>,
|
||||
public Interface<IOleControl>,
|
||||
public Interface<IPointerInactive>,
|
||||
public OcxProvideClassInfo
|
||||
{
|
||||
public:
|
||||
OcxControl();
|
||||
virtual ~OcxControl();
|
||||
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
bool Open(HWND parent);
|
||||
virtual void Serialize(Stream& stream);
|
||||
void SerializePos(Stream& stream);
|
||||
|
||||
virtual bool IsOcxChild();
|
||||
|
||||
using Ctrl::GetRect;
|
||||
using Ctrl::SetData;
|
||||
using Ctrl::GetData;
|
||||
|
||||
// IOleObject
|
||||
|
||||
STDMETHOD(SetClientSite)(IOleClientSite *site);
|
||||
STDMETHOD(GetClientSite)(IOleClientSite **res);
|
||||
STDMETHOD(SetHostNames)(LPCOLESTR app_name, LPCOLESTR doc_name);
|
||||
STDMETHOD(Close)(dword save_option);
|
||||
STDMETHOD(SetMoniker)(dword which, IMoniker *moniker);
|
||||
STDMETHOD(GetMoniker)(dword assign, dword which, IMoniker **moniker);
|
||||
STDMETHOD(InitFromData)(IDataObject *data, BOOL creation, dword);
|
||||
STDMETHOD(GetClipboardData)(dword, IDataObject **data);
|
||||
STDMETHOD(DoVerb)(long verb, MSG *msg, IOleClientSite *active_site, long index, HWND hwnd, const RECT *rc);
|
||||
STDMETHOD(EnumVerbs)(IEnumOLEVERB **verbs);
|
||||
STDMETHOD(Update)();
|
||||
STDMETHOD(IsUpToDate)();
|
||||
STDMETHOD(GetUserClassID)(GUID *guid);
|
||||
STDMETHOD(GetUserType)(dword form, LPOLESTR *type);
|
||||
STDMETHOD(SetExtent)(dword aspect, SIZEL *size);
|
||||
STDMETHOD(GetExtent)(dword aspect, SIZEL *size);
|
||||
STDMETHOD(Advise)(IAdviseSink *sink, dword *connection);
|
||||
STDMETHOD(Unadvise)(dword connection);
|
||||
STDMETHOD(EnumAdvise)(IEnumSTATDATA **sink_enum);
|
||||
STDMETHOD(GetMiscStatus)(dword aspect, dword *status);
|
||||
STDMETHOD(SetColorScheme)(LOGPALETTE *logpal);
|
||||
|
||||
// IPersistStorage
|
||||
|
||||
STDMETHOD(GetClassID)(GUID *guid);
|
||||
STDMETHOD(IsDirty)(); // IPersistStreamInit as well
|
||||
STDMETHOD(InitNew)(IStorage *stg);
|
||||
STDMETHOD(Load)(IStorage *stg);
|
||||
STDMETHOD(Save)(IStorage *stg, BOOL same_as_load);
|
||||
STDMETHOD(SaveCompleted)(IStorage *stg);
|
||||
STDMETHOD(HandsOffStorage)();
|
||||
|
||||
// IPersistStreamInit
|
||||
|
||||
STDMETHOD(Load)(IStream *stream);
|
||||
STDMETHOD(Save)(IStream *stream, BOOL clear_dirty);
|
||||
STDMETHOD(GetSizeMax)(ULARGE_INTEGER *size);
|
||||
STDMETHOD(InitNew)();
|
||||
|
||||
// IDataObject
|
||||
|
||||
STDMETHOD(GetData)(FORMATETC *format, STGMEDIUM *medium);
|
||||
STDMETHOD(GetDataHere)(FORMATETC *format, STGMEDIUM *medium);
|
||||
STDMETHOD(QueryGetData)(FORMATETC *format);
|
||||
STDMETHOD(GetCanonicalFormatEtc)(FORMATETC *in, FORMATETC *out);
|
||||
STDMETHOD(SetData)(FORMATETC *format, STGMEDIUM *medium, BOOL free);
|
||||
STDMETHOD(EnumFormatEtc)(dword dir, IEnumFORMATETC **enumerator);
|
||||
STDMETHOD(DAdvise)(FORMATETC *format, dword advf, IAdviseSink *sink, dword *connection);
|
||||
STDMETHOD(DUnadvise)(dword connection);
|
||||
STDMETHOD(EnumDAdvise)(IEnumSTATDATA **enumerator);
|
||||
|
||||
// IViewObject
|
||||
|
||||
STDMETHOD(Draw)(DWORD aspect, LONG index, void *aspectinfo,
|
||||
DVTARGETDEVICE *device, HDC target, HDC draw,
|
||||
const RECTL *bounds, const RECTL *wbounds,
|
||||
BOOL (STDMETHODCALLTYPE *progress)(ULONG_PTR dwContinue), ULONG_PTR arg);
|
||||
STDMETHOD(GetColorSet)(dword aspect, long index, void *aspectinfo,
|
||||
DVTARGETDEVICE *device, HDC target, LOGPALETTE **palette);
|
||||
STDMETHOD(Freeze)(dword aspect, long index, void *aspectinfo,
|
||||
dword *freeze_key);
|
||||
STDMETHOD(Unfreeze)(dword freeze_key);
|
||||
STDMETHOD(SetAdvise)(dword aspect, dword advf, IAdviseSink *sink);
|
||||
STDMETHOD(GetAdvise)(dword *aspect, dword *advf, IAdviseSink **sink);
|
||||
|
||||
// IViewObject2
|
||||
|
||||
STDMETHOD(GetExtent)(dword aspect, long index, DVTARGETDEVICE *device, SIZEL *size);
|
||||
|
||||
// IViewObjectEx
|
||||
|
||||
STDMETHOD(GetRect)(dword aspect, RECTL *rc);
|
||||
STDMETHOD(GetViewStatus)(dword *status);
|
||||
STDMETHOD(QueryHitPoint)(dword aspect, const RECT *bounds, POINT pos, long close_hint, dword *result);
|
||||
STDMETHOD(QueryHitRect)(dword aspect, const RECT *bounds, const RECT *, long close_hint, dword *result);
|
||||
STDMETHOD(GetNaturalExtent)(dword aspect, long index, DVTARGETDEVICE *ptd, HDC tdc, DVEXTENTINFO *extinfo, SIZEL *psize);
|
||||
|
||||
// IOleWindow
|
||||
|
||||
STDMETHOD(GetWindow)(HWND *hwnd);
|
||||
STDMETHOD(ContextSensitiveHelp)(BOOL enter_mode);
|
||||
|
||||
// IOleInPlaceObject
|
||||
|
||||
STDMETHOD(InPlaceDeactivate)();
|
||||
STDMETHOD(UIDeactivate)();
|
||||
STDMETHOD(SetObjectRects)(const RECT *pos, const RECT *clip);
|
||||
STDMETHOD(ReactivateAndUndo)();
|
||||
|
||||
// IOleInPlaceActiveObject
|
||||
|
||||
STDMETHOD(TranslateAccelerator)(MSG *msg);
|
||||
STDMETHOD(OnFrameWindowActivate)(BOOL activate);
|
||||
STDMETHOD(OnDocWindowActivate)(BOOL activate);
|
||||
STDMETHOD(ResizeBorder)(const RECT *border, IOleInPlaceUIWindow *ui, BOOL frame);
|
||||
STDMETHOD(EnableModeless)(BOOL enable);
|
||||
|
||||
// IOleControl
|
||||
|
||||
STDMETHOD(GetControlInfo)(CONTROLINFO *cinfo);
|
||||
STDMETHOD(OnMnemonic)(MSG *msg);
|
||||
STDMETHOD(OnAmbientPropertyChange)(DISPID dispid);
|
||||
STDMETHOD(FreezeEvents)(BOOL freeze);
|
||||
|
||||
// IPointerInactive
|
||||
|
||||
STDMETHOD(GetActivationPolicy)(DWORD *pdwPolicy);
|
||||
STDMETHOD(OnInactiveMouseMove)(LPCRECT pRectBounds, LONG x, LONG y, DWORD grfKeyState);
|
||||
STDMETHOD(OnInactiveSetCursor)(LPCRECT pRectBounds, LONG x, LONG y, DWORD dwMouseMsg, BOOL fSetAlways);
|
||||
|
||||
// default verb
|
||||
|
||||
virtual HRESULT DoVerbPrimary();
|
||||
virtual HRESULT DoVerbShow();
|
||||
virtual HRESULT DoVerbInPlaceActivate();
|
||||
virtual HRESULT DoVerbUIActivate();
|
||||
virtual HRESULT DoVerbOpen();
|
||||
virtual HRESULT DoVerbHide();
|
||||
virtual HRESULT DoVerbDiscardUndo();
|
||||
virtual HRESULT DoVerbProperties();
|
||||
|
||||
// various helpers
|
||||
|
||||
bool IsClosed() const { return status == CLOSED; }
|
||||
// bool IsForged() const { return status == FORGED; }
|
||||
bool IsActive() const { return status >= ACTIVE; }
|
||||
bool IsUIActive() const { return status == UIACTIVE; }
|
||||
|
||||
void RefreshSink();
|
||||
|
||||
enum { CONTROL = 1 };
|
||||
|
||||
protected:
|
||||
void UpdateControlRect();
|
||||
HRESULT ShowControl(bool ui_activate);
|
||||
void SetActiveObject(bool set);
|
||||
|
||||
void TimerThread();
|
||||
|
||||
protected:
|
||||
static const WCHAR data_stream_name[]; // default data stream
|
||||
|
||||
enum STATE { CLOSED, /* FORGED, */ ACTIVE, UIACTIVE };
|
||||
|
||||
// Thread timer_thread;
|
||||
IRef<IOleClientSite> client_site;
|
||||
IRef<IOleInPlaceSite> in_place_site;
|
||||
SinkMap< IRef<IAdviseSink> > advise_sinks;
|
||||
dword view_sink_aspect;
|
||||
dword view_sink_advf;
|
||||
IRef<IAdviseSink> view_sink;
|
||||
Rect ctrl_rect;
|
||||
Size extent_size;
|
||||
STATE status;
|
||||
// WPARAM ncmm_wParam;
|
||||
// LPARAM ncmm_lParam;
|
||||
bool stream_inited;
|
||||
bool timer_shutdown;
|
||||
};
|
||||
|
||||
class OcxRunnableControl : public OcxControl, public Interface<IRunnableObject>
|
||||
{
|
||||
public:
|
||||
OcxRunnableControl() {}
|
||||
|
||||
// IRunnableObject
|
||||
|
||||
STDMETHOD(GetRunningClass)(GUID *clsid);
|
||||
STDMETHOD(Run)(LPBC ctx);
|
||||
BOOL STDMETHODCALLTYPE IsRunning();
|
||||
STDMETHOD(LockRunning)(BOOL lock, BOOL last_unlock_closes);
|
||||
STDMETHOD(SetContainedObject)(BOOL contained);
|
||||
};
|
||||
|
||||
/*
|
||||
struct CtrlHook : public Ctrl
|
||||
{
|
||||
public:
|
||||
void _CreateChild() { Ctrl::CreateChild(); }
|
||||
};
|
||||
*/
|
||||
|
||||
class OcxConnectionPoint : public Interface<IConnectionPoint>
|
||||
{
|
||||
public:
|
||||
OcxConnectionPoint() {}
|
||||
|
||||
void SetEventGUID(const Guid& g) { guid = g; }
|
||||
void SetContainer(IConnectionPointContainer *cont) { container = cont; }
|
||||
void FireEvent(int method_id, const Vector<Value>& values);
|
||||
|
||||
STDMETHOD(GetConnectionInterface)(IID *iid);
|
||||
STDMETHOD(GetConnectionPointContainer)(IConnectionPointContainer **ppCPC);
|
||||
STDMETHOD(Advise)(IUnknown *ptr, DWORD *cookie);
|
||||
STDMETHOD(Unadvise)(DWORD cookie);
|
||||
STDMETHOD(EnumConnections)(IEnumConnections **enum_conn);
|
||||
|
||||
class Enumerator : public Interface<IEnumConnections>
|
||||
{
|
||||
public:
|
||||
Enumerator() {}
|
||||
|
||||
void Attach(OcxConnectionPoint *pt) { point = IRef<OcxConnectionPoint>(pt); index = 0; }
|
||||
|
||||
STDMETHOD(Next)(unsigned long count, CONNECTDATA *data, unsigned long *fetched);
|
||||
STDMETHOD(Skip)(unsigned long connections);
|
||||
STDMETHOD(Reset)();
|
||||
STDMETHOD(Clone)(IEnumConnections **enum_conn);
|
||||
|
||||
private:
|
||||
IRef<OcxConnectionPoint> point;
|
||||
int index;
|
||||
};
|
||||
|
||||
friend class Enumerator;
|
||||
|
||||
public:
|
||||
Guid guid;
|
||||
|
||||
protected:
|
||||
IConnectionPointContainer *container;
|
||||
VectorMap<dword, IRef<IDispatch> > conn_map;
|
||||
Vector<dword> free_id;
|
||||
};
|
||||
|
||||
class OcxConnectionPointContainer : public Interface<IConnectionPointContainer>
|
||||
{
|
||||
public:
|
||||
OcxConnectionPointContainer();
|
||||
|
||||
void AddConnectionPoint(OcxConnectionPoint *conn) { point_map.GetAdd(conn -> guid) = conn; conn -> SetContainer(this); }
|
||||
|
||||
STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints **ppEnum);
|
||||
STDMETHOD(FindConnectionPoint)(REFIID riid, IConnectionPoint **ppCP);
|
||||
|
||||
private:
|
||||
class Enumerator : public Interface<IEnumConnectionPoints>
|
||||
{
|
||||
public:
|
||||
Enumerator() {}
|
||||
|
||||
void Attach(OcxConnectionPointContainer *pt) { point = pt; index = 0; }
|
||||
|
||||
STDMETHOD(Next)(unsigned long count, IConnectionPoint **rgpcn, unsigned long *fetched);
|
||||
STDMETHOD(Skip)(unsigned long connections);
|
||||
STDMETHOD(Reset)();
|
||||
STDMETHOD(Clone)(IEnumConnectionPoints **enum_conn);
|
||||
|
||||
private:
|
||||
IRef<OcxConnectionPointContainer> point;
|
||||
int index;
|
||||
};
|
||||
|
||||
friend class Enumerator;
|
||||
|
||||
private:
|
||||
VectorMap<Guid, IConnectionPoint *> point_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +0,0 @@
|
|||
LIBRARY "test.ocx"
|
||||
|
||||
EXPORTS
|
||||
DllCanUnloadNow PRIVATE
|
||||
DllGetClassObject PRIVATE
|
||||
DllRegisterServer PRIVATE
|
||||
DllUnregisterServer PRIVATE
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#include <Ole/Ctrl/OleCtrl.h>
|
||||
|
||||
#ifdef flagMAIN
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpReserved)
|
||||
{
|
||||
switch(fdwReason) {
|
||||
case DLL_PROCESS_ATTACH: {
|
||||
Ctrl::InitWin32(hinstDll);
|
||||
AppInitEnvironment__();
|
||||
break;
|
||||
}
|
||||
case DLL_PROCESS_DETACH: {
|
||||
Ctrl::CloseTopCtrls();
|
||||
break;
|
||||
}
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,741 +0,0 @@
|
|||
#include <Ole/Ctrl/OleCtrl.h>
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
#define LDUMP(x)
|
||||
#define LLOG(x)
|
||||
|
||||
namespace Upp {
|
||||
|
||||
enum { HIMETRIC_INCH = 2540 }; // HIMETRIC units per inch
|
||||
|
||||
SystemDraw& ScreenInfo();
|
||||
|
||||
Size ToHiMetric(Size pixel_size)
|
||||
{
|
||||
static Size logdpi = ScreenInfo().GetSizeCaps(LOGPIXELSX, LOGPIXELSY);
|
||||
return Size(
|
||||
iscaleceil(pixel_size.cx, HIMETRIC_INCH, logdpi.cx),
|
||||
iscaleceil(pixel_size.cy, HIMETRIC_INCH, logdpi.cy));
|
||||
}
|
||||
|
||||
Size FromHiMetric(Size himetric_size)
|
||||
{
|
||||
static Size logdpi = ScreenInfo().GetSizeCaps(LOGPIXELSX, LOGPIXELSY);
|
||||
return Size(
|
||||
iscalefloor(himetric_size.cx, logdpi.cx, HIMETRIC_INCH),
|
||||
iscalefloor(himetric_size.cy, logdpi.cy, HIMETRIC_INCH));
|
||||
}
|
||||
|
||||
Rect GetWindow(HDC hdc)
|
||||
{
|
||||
Point pt;
|
||||
Size sz;
|
||||
GetWindowOrgEx(hdc, pt);
|
||||
GetWindowExtEx(hdc, sz);
|
||||
return Rect(pt, sz);
|
||||
}
|
||||
|
||||
Rect GetViewport(HDC hdc)
|
||||
{
|
||||
Point pt;
|
||||
Size sz;
|
||||
GetViewportOrgEx(hdc, pt);
|
||||
GetViewportExtEx(hdc, sz);
|
||||
return Rect(pt, sz);
|
||||
}
|
||||
|
||||
OcxObject::OcxObject()
|
||||
: ocx_info(0)
|
||||
{
|
||||
inner_unknown.owner = this;
|
||||
outer_unknown = NULL;
|
||||
}
|
||||
|
||||
int OcxObject::ExternalAddRef()
|
||||
{
|
||||
if(outer_unknown) {
|
||||
int res = outer_unknown->AddRef();
|
||||
#if LOG_ADDREFS
|
||||
OCXLOG("OcxObject::ExternalAddRef -> outer(" << FormatIntHex(outer_unknown) << ") -> " << res);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
return InternalAddRef();
|
||||
}
|
||||
|
||||
int OcxObject::ExternalRelease()
|
||||
{
|
||||
if(outer_unknown) {
|
||||
int res = outer_unknown->Release();
|
||||
#if LOG_ADDREFS
|
||||
// note: this might have been destructed by this time
|
||||
OCXLOG("OcxObject::ExternalRelease -> outer(" << FormatIntHex(outer_unknown) << ") -> " << res);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
return InternalRelease();
|
||||
}
|
||||
|
||||
HRESULT OcxObject::ExternalQueryInterface(const GUID& iid, void **ppv)
|
||||
{
|
||||
if(outer_unknown) {
|
||||
HRESULT hr = outer_unknown->QueryInterface(iid, ppv);
|
||||
#if LOG_QUERIES >= 2
|
||||
OCXLOG("OcxObject::ExternalQueryInterface(" << GetInterfaceName(iid) << ") -> outer(" << FormatIntHex(outer_unknown) << ") -> " << FormatIntHex(hr));
|
||||
#endif
|
||||
return hr;
|
||||
}
|
||||
return InternalQueryInterface(iid, ppv);
|
||||
}
|
||||
|
||||
HRESULT OcxObject::InternalQueryInterface(const GUID& iid, void **ppv)
|
||||
{
|
||||
#if LOG_QUERIES >= 2
|
||||
OCXLOG("OcxObject::InternalQueryInterface -> " << GetInterfaceName(iid));
|
||||
#endif
|
||||
int i;
|
||||
IUnknown *punk;
|
||||
if(iid == IID_IUnknown)
|
||||
punk = static_cast<IUnknown *>(&inner_unknown);
|
||||
else if((i = interface_map.Find(iid)) >= 0)
|
||||
punk = interface_map[i];
|
||||
else {
|
||||
*ppv = 0;
|
||||
#if LOG_QUERIES >= 1
|
||||
String name;
|
||||
if(ocx_info)
|
||||
name = ocx_info->GetName();
|
||||
else
|
||||
name = "<unknown object>";
|
||||
#endif
|
||||
LOGQUERY("\t\tcast ERROR: " << name << " -> "<< GetInterfaceName(iid) << ", " << Guid(iid));
|
||||
#if LOG_QUERIES >= 3
|
||||
OCXLOG("\tGUID = " << Format(iid));
|
||||
for(int i = 0; i < interface_map.GetCount(); i++) {
|
||||
const GUID& imid = interface_map.GetKey(i);
|
||||
String n = GetInterfaceName(imid);
|
||||
if(n.GetLength() < 30)
|
||||
n.Cat(' ', 30 - n.GetLength());
|
||||
OCXLOG("\t\t\t" << n << " - " << Format(imid));
|
||||
}
|
||||
#endif
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
punk->AddRef();
|
||||
*ppv = punk;
|
||||
#if LOG_QUERIES >= 2
|
||||
String name;
|
||||
if(ocx_info)
|
||||
name = ocx_info->GetName();
|
||||
else
|
||||
name = "<unknown object>";
|
||||
OCXLOG("\t\tcast OK: " << name << " -> " << GetInterfaceName(iid));
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxObject::RawGetTypeInfo(IRef<ITypeInfo>& typeinfo, unsigned tinfo, LCID lcid, ITypeInfo **ppinfo)
|
||||
{
|
||||
if(tinfo != 0)
|
||||
return DISP_E_BADINDEX;
|
||||
if(!typeinfo)
|
||||
return E_FAIL;
|
||||
// currently ignore lcid
|
||||
*ppinfo = typeinfo.AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxObject::RawGetIDsOfNames(IRef<ITypeInfo>& typeinfo, REFIID riid, OLECHAR **names, unsigned cnames, LCID lcid, DISPID *dispid)
|
||||
{
|
||||
if(!typeinfo)
|
||||
return E_FAIL;
|
||||
return typeinfo->GetIDsOfNames(names, cnames, dispid);
|
||||
}
|
||||
|
||||
HRESULT OcxObject::RawInvoke(IRef<ITypeInfo>& typeinfo, IDispatch *dispatch, DISPID dispid, word flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, unsigned *arg_err)
|
||||
{
|
||||
LOGINVOKE("IDispatch::Invoke");
|
||||
if(dispid == 0) { // convert object to dispatch value
|
||||
if(!result) return E_INVALIDARG;
|
||||
result->vt = VT_DISPATCH;
|
||||
result->pdispVal = dispatch;
|
||||
if(dispatch) dispatch->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
if(!typeinfo) {
|
||||
LOG("dispid = " << FormatIntHex(dispid) << ": typeinfo = NULL");
|
||||
return E_FAIL;
|
||||
}
|
||||
#if LOG_INVOKES >= 1
|
||||
BSTR names[1] = { NULL };
|
||||
unsigned count = 0;
|
||||
typeinfo->GetNames(dispid, names, 1, &count);
|
||||
String name;
|
||||
if(names[0])
|
||||
name = BSTRToString(names[0]);
|
||||
else
|
||||
name = FormatIntHex(dispid);
|
||||
switch(flags) {
|
||||
case DISPATCH_METHOD: name << " - method"; break;
|
||||
case DISPATCH_PROPERTYGET: name << " - propget"; break;
|
||||
case DISPATCH_PROPERTYPUT: name << " - propput"; break;
|
||||
case DISPATCH_PROPERTYPUTREF: name << " - propputref"; break;
|
||||
}
|
||||
LOG("Member name: " << name);
|
||||
#endif
|
||||
if(!typeinfo)
|
||||
return E_FAIL;
|
||||
TYPEATTR *attr;
|
||||
typeinfo->GetTypeAttr(&attr);
|
||||
LOGINVOKE("GetTypeInfo: typekind = " << (int)attr->typekind);
|
||||
// HRESULT res = typeinfo->Invoke(dispatch, dispid, flags, params, result, excep, arg_err);
|
||||
HRESULT res = DispInvoke(dispatch, ~typeinfo, dispid, flags, params, result, excep, arg_err);
|
||||
if(FAILED(res)) {
|
||||
LLOG("failure: dispid = " << (int)dispid << ", #args = " << (int)params->cArgs
|
||||
<< ", #named args = " << (int)params->cNamedArgs << ", return " << FormatIntHex(result));
|
||||
for(int i = 0; i < (int)params->cArgs; i++) {
|
||||
LLOG("arg[" << i << "] (vt = " << (int)params->rgvarg[i].vt << "): " << StdFormat(AsValue(params->rgvarg[i])));
|
||||
}
|
||||
LLOG("#funcs = " << attr->cFuncs);
|
||||
for(int i = 0; i < attr->cFuncs; i++) {
|
||||
FUNCDESC *func;
|
||||
typeinfo->GetFuncDesc(i, &func);
|
||||
LLOG("memid = " << func->memid << ", cParams " << func->cParams
|
||||
<< ", cParamsOpt = " << func->cParamsOpt << ", cScodes " << func->cScodes
|
||||
<< ", funckind = " << (int)func->funckind << ", invkind " << (int)func->invkind
|
||||
<< ", flags = " << FormatIntHex(func->wFuncFlags));
|
||||
|
||||
typeinfo->ReleaseFuncDesc(func);
|
||||
}
|
||||
}
|
||||
typeinfo->ReleaseTypeAttr(attr);
|
||||
LOGINVOKE("//IDispatch::Invoke");
|
||||
return LOGRESULT(res);
|
||||
}
|
||||
|
||||
HRESULT OcxProvideClassInfo::GetClassInfo(ITypeInfo **info)
|
||||
{
|
||||
if(!info) return E_INVALIDARG;
|
||||
if(!ocx_info) {
|
||||
*info = NULL;
|
||||
return E_POINTER;
|
||||
}
|
||||
*info = ocx_info->GetCoClassTypeInfo().AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxProvideClassInfo::GetGUID(dword guidkind, GUID *guid)
|
||||
{
|
||||
if(!guid)
|
||||
return E_POINTER;
|
||||
if(!ocx_info) {
|
||||
*guid = __uuidof(0);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
if(guidkind == GUIDKIND_DEFAULT_SOURCE_DISP_IID) {
|
||||
*guid = ~ocx_info->GetEventGUID();
|
||||
return ocx_info->GetEventGUID().IsEmpty() ? E_UNEXPECTED : S_OK;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
OcxTypeInfo::OcxTypeInfo(const GUID& coclass_guid, /*const GUID& dispatch_guid,*/ const GUID& event_guid,
|
||||
New new_fn, String name, const char* help, int ver, bool is_control)
|
||||
: coclass_guid(coclass_guid), /*dispatch_guid(dispatch_guid),*/ event_guid(event_guid)
|
||||
, new_fn(new_fn), name(name), help(help), ver(ver), is_control(is_control)
|
||||
, object_count(0)
|
||||
, refcount(1)
|
||||
, lock_count(0)
|
||||
#ifndef _USRDLL
|
||||
, registration(0)
|
||||
#endif
|
||||
{
|
||||
LLOG("OcxTypeInfo ctr (" << name << ", " << Guid(coclass_guid) << ")");
|
||||
OcxTypeLib::Get().Add(*this);
|
||||
}
|
||||
|
||||
bool OcxTypeInfo::CanUnload() const
|
||||
{
|
||||
LLOG("OcxTypeInfo::CanUnload(" << name << ", " << Guid(coclass_guid) << ")");
|
||||
LDUMP(object_count);
|
||||
LDUMP(refcount);
|
||||
return object_count == 0 && refcount <= 2 && lock_count <= 0;
|
||||
}
|
||||
|
||||
int OcxTypeInfo::IncRef()
|
||||
{
|
||||
int res = InterlockedIncrement(&refcount);
|
||||
LLOG("OcxTypeInfo::IncRef(" << name << " -> " << res << ")");
|
||||
return res;
|
||||
}
|
||||
|
||||
int OcxTypeInfo::DecRef()
|
||||
{
|
||||
int res = InterlockedDecrement(&refcount);
|
||||
LLOG("OcxTypeInfo::DecRef(" << name << " -> " << res << ")");
|
||||
VERIFY(res > 0); // if this throws, the factory has been over-released
|
||||
return res;
|
||||
}
|
||||
|
||||
GLOBAL_VAR(InitProc, LateInitProc);
|
||||
GLOBAL_VAR(InitProc, LateExitProc);
|
||||
static bool inited = false;
|
||||
|
||||
void DoLateInit()
|
||||
{
|
||||
if(!inited) {
|
||||
INTERLOCKED
|
||||
if(!inited) {
|
||||
inited = true;
|
||||
if(LateInitProc())
|
||||
LateInitProc()();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoLateExit()
|
||||
{
|
||||
if(inited) {
|
||||
INTERLOCKED
|
||||
if(inited) {
|
||||
inited = false;
|
||||
if(LateExitProc())
|
||||
LateExitProc()();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT OcxTypeInfo::CreateInstance(IUnknown *outer, REFIID iid, void **object)
|
||||
{
|
||||
LLOG("OcxTypeInfo::CreateInstance(" << name << ", iid = " << Guid(iid) << ", outer = " << FormatIntHex(outer) << ")");
|
||||
if(outer && iid != IID_IUnknown)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
try {
|
||||
DoLateInit();
|
||||
OcxObject *ocxobj = new_fn(*this);
|
||||
LOGCREATE("\tnew " << name << ": " << object_count << " instances in system");
|
||||
if(outer)
|
||||
ocxobj->outer_unknown = outer;
|
||||
HRESULT hr = ocxobj->InternalQueryInterface(iid, object);
|
||||
LOGCREATE("//OcxTypeInfo::CreateInstance -> " << FormatIntHex(hr));
|
||||
return hr;
|
||||
}
|
||||
catch(Exc e) {
|
||||
LLOG("OcxTypeInfo::CreateInstance error: " << e);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
catch(...) {
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT OcxTypeInfo::LockServer(BOOL lock)
|
||||
{
|
||||
LLOG("OcxTypeInfo::LockServer(" << name << ", " << lock << ")");
|
||||
if(lock)
|
||||
AtomicInc(lock_count);
|
||||
else
|
||||
VERIFY(AtomicDec(lock_count) >= 0); // over-unlock check
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxTypeInfo::GetLicInfo(/* [out] */ LICINFO *pLicInfo)
|
||||
{
|
||||
LLOG("OcxTypeInfo::GetLicInfo(" << name << ")");
|
||||
if(!pLicInfo)
|
||||
return E_INVALIDARG;
|
||||
pLicInfo->fLicVerified = TRUE;
|
||||
pLicInfo->fRuntimeKeyAvail = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxTypeInfo::RequestLicKey(/* [in] */ DWORD dwReserved, /* [out] */ BSTR *pBstrKey)
|
||||
{
|
||||
LLOG("OcxTypeInfo::RequestLicKey(" << name << ")");
|
||||
if(!pBstrKey) return E_INVALIDARG;
|
||||
*pBstrKey = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxTypeInfo::CreateInstanceLic(
|
||||
/* [in] */ IUnknown *pUnkOuter,
|
||||
/* [in] */ IUnknown *pUnkReserved,
|
||||
/* [in] */ REFIID riid,
|
||||
/* [in] */ BSTR bstrKey,
|
||||
/* [iid_is][out] */ PVOID *ppvObj)
|
||||
{
|
||||
LLOG("OcxTypeInfo::CreateInstanceLic(" << name << ")");
|
||||
return CreateInstance(pUnkOuter, riid, ppvObj);
|
||||
}
|
||||
|
||||
void OcxTypeInfo::GetDispatchTypeInfo(IRef<ITypeInfo>& dest, Guid dispatch_iid)
|
||||
{
|
||||
if(!dest) {
|
||||
CriticalSection::Lock lock(critical);
|
||||
if(!dest)
|
||||
dest = OcxTypeLib::Get().GetTypeInfo(dispatch_iid);
|
||||
}
|
||||
}
|
||||
|
||||
IRef<ITypeInfo> OcxTypeInfo::GetCoClassTypeInfo()
|
||||
{
|
||||
if(!coclass_info && !coclass_guid.IsEmpty()) { // oportunity lock used to initialize type info
|
||||
critical.Enter();
|
||||
if(!coclass_info)
|
||||
coclass_info = OcxTypeLib::Get().GetTypeInfo(coclass_guid);
|
||||
critical.Leave();
|
||||
}
|
||||
return coclass_info;
|
||||
}
|
||||
|
||||
OcxTypeLib::OcxTypeLib()
|
||||
: lib_ver(1)
|
||||
{
|
||||
CoInitialize(0);
|
||||
}
|
||||
|
||||
OcxTypeLib& OcxTypeLib::Get()
|
||||
{
|
||||
static OcxTypeLib ocx;
|
||||
return ocx;
|
||||
}
|
||||
|
||||
String OcxTypeLib::GetLibName() const
|
||||
{
|
||||
if(!IsNull(lib_name))
|
||||
return lib_name;
|
||||
String s = ToLower(GetFileTitle(GetModuleFileName()));
|
||||
if(!IsNull(s))
|
||||
s.Set(0, ToUpper(s[0]));
|
||||
return s;
|
||||
}
|
||||
|
||||
bool OcxTypeLib::CanUnload() const
|
||||
{
|
||||
for(int i = 0; i < objects.GetCount(); i++)
|
||||
if(!objects[i]->CanUnload()) {
|
||||
OCXLOG("OcxTypeLib::CanUnload failed for " << objects[i]->GetName());
|
||||
return false;
|
||||
}
|
||||
OCXLOG("OcxTypeLib::CanUnload succeeded");
|
||||
return true;
|
||||
}
|
||||
|
||||
IRef<ITypeInfo> OcxTypeLib::GetTypeInfo(const Guid& guid)
|
||||
{
|
||||
IRef<ITypeInfo> outinfo;
|
||||
HRESULT hr = GetTypeLib()->GetTypeInfoOfGuid(guid, outinfo.Set());
|
||||
if(FAILED(hr)) {
|
||||
LOGSYSOCX("OcxTypeLib::GetTypeInfo(" << guid << ") -> hr = " << FormatIntHex(hr));
|
||||
for(int i = 0; i < uses_libraries.GetCount(); i++) {
|
||||
if(!uses_libraries[i]) {
|
||||
String libname = uses_libraries.GetKey(i);
|
||||
WString wlibname = libname.ToWString();
|
||||
hr = LoadTypeLib(wlibname, uses_libraries[i].Set());
|
||||
if(!uses_libraries[i]) {
|
||||
LOGSYSOCX("LoadTypeLib(" << libname << ") -> hr = " << FormatIntHex(hr));
|
||||
}
|
||||
else {
|
||||
LOGSYSOCX("LoadTypeLib(" << uses_libraries.GetKey(i) << ") -> succeeded");
|
||||
if(IsFullPath(libname)) {
|
||||
hr = RegisterTypeLib(~uses_libraries[i], const_cast<OLECHAR *>(~wlibname), NULL);
|
||||
LOGSYSOCX("RegisterTypeLib(" << libname << ") -> hr = " << FormatIntHex(hr));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!!uses_libraries[i]) {
|
||||
hr = uses_libraries[i]->GetTypeInfoOfGuid(guid, outinfo.Set());
|
||||
if(!!outinfo)
|
||||
return outinfo;
|
||||
LOGSYSOCX("GetTypeInfoOfGuid(" << uses_libraries.GetKey(i) << ") -> hr = " << FormatIntHex(hr));
|
||||
}
|
||||
}
|
||||
}
|
||||
return outinfo;
|
||||
}
|
||||
|
||||
HRESULT OcxTypeLib::Register()
|
||||
{
|
||||
String modname = GetModuleFileName();
|
||||
String lib_name = GetLibName();
|
||||
LOGSYSOCX("Registering library \"" << modname << '\"');
|
||||
|
||||
HRESULT hr;
|
||||
IRef<ITypeLib>& typelib = GetTypeLib();
|
||||
if(!typelib)
|
||||
return SELFREG_E_TYPELIB;
|
||||
TLIBATTR *attr;
|
||||
if(FAILED(hr = typelib->GetLibAttr(&attr)))
|
||||
return hr;
|
||||
String lib_guid = Guid(attr->guid);
|
||||
typelib->ReleaseTLibAttr(attr);
|
||||
|
||||
for(int i = 0; i < objects.GetCount(); i++) {
|
||||
const OcxTypeInfo& entry = *objects[i];
|
||||
String progID = lib_name;
|
||||
String verID = progID << '.' << entry.name;
|
||||
verID << '.' << (entry.ver ? entry.ver : lib_ver);
|
||||
String guid = entry.coclass_guid;
|
||||
LOGSYSOCX("Registering object " << verID << ", CLSID = " << guid);
|
||||
String clss_key = "CLSID\\" + guid;
|
||||
#ifdef _USRDLL
|
||||
String server = clss_key + "\\InprocServer32";
|
||||
#endif
|
||||
String version;
|
||||
version << lib_ver << '.' << entry.ver;
|
||||
String help = entry.help;
|
||||
if(IsNull(help)) {
|
||||
if(!IsNull(display_name))
|
||||
help << display_name << ' ';
|
||||
help << entry.name << (entry.IsControl() ? " Control " : " Object ") << version;
|
||||
}
|
||||
DeleteWinReg(verID, HKEY_CLASSES_ROOT);
|
||||
DeleteWinReg(progID, HKEY_CLASSES_ROOT);
|
||||
DeleteWinReg(clss_key, HKEY_CLASSES_ROOT);
|
||||
if(!SetWinRegString(help, NULL, verID, HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(guid, NULL, verID + "\\CLSID", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(help, NULL, progID, HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(guid, NULL, progID + "\\CLSID", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(help, NULL, clss_key, HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(verID, NULL, clss_key + "\\ProgID", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(progID, NULL, clss_key + "\\VersionIndependentProgID", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(lib_guid, NULL, clss_key + "\\TypeLib", HKEY_CLASSES_ROOT)
|
||||
#ifdef _USRDLL
|
||||
|| !SetWinRegString(modname, NULL, server, HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString("Apartment", "ThreadingModel", server, HKEY_CLASSES_ROOT)
|
||||
#else
|
||||
|| !SetWinRegString(modname, NULL, clss_key + "\\LocalServer32", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(modname, NULL, clss_key + "\\LocalServer", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString("ole32.dll", NULL, clss_key + "\\InprocHandler32", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString("ole2.dll", NULL, clss_key + "\\InprocHandler", HKEY_CLASSES_ROOT)
|
||||
#endif
|
||||
|| !SetWinRegString(version, NULL, clss_key + "\\Version", HKEY_CLASSES_ROOT))
|
||||
return REGDB_E_WRITEREGDB;
|
||||
if(entry.IsControl()) {
|
||||
if(!SetWinRegString("", NULL, clss_key + "\\Control", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString(modname + ", 1", NULL, clss_key + "\\ToolboxBitmap32", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString("", NULL, verID + "\\Insertable", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString("", NULL, progID + "\\Insertable", HKEY_CLASSES_ROOT)
|
||||
|| !SetWinRegString("", NULL, clss_key + "\\Insertable", HKEY_CLASSES_ROOT))
|
||||
return REGDB_E_WRITEREGDB;
|
||||
}
|
||||
}
|
||||
|
||||
// UniStr ulib = modname;
|
||||
OleBstr ulib(modname);
|
||||
if(FAILED(hr = RegisterTypeLib(~typelib, (wchar_t *)~ulib, ~ulib)))
|
||||
return hr;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT OcxTypeLib::Unregister()
|
||||
{
|
||||
String lib = GetModuleFileName();
|
||||
String lib_name = GetLibName();
|
||||
LOGSYSOCX("Unregistering library \"" << lib << '\"');
|
||||
for(int i = 0; i < objects.GetCount(); i++) {
|
||||
const OcxTypeInfo& entry = *objects[i];
|
||||
String progID = lib_name;
|
||||
String verID = progID << '.' << entry.name;
|
||||
verID << '.' << (entry.ver ? entry.ver : lib_ver);
|
||||
DeleteWinReg(verID, HKEY_CLASSES_ROOT);
|
||||
DeleteWinReg(progID, HKEY_CLASSES_ROOT);
|
||||
DeleteWinReg("CLSID\\" + String(entry.coclass_guid), HKEY_CLASSES_ROOT);
|
||||
DeleteWinReg("SOFTWARE\\Classes\\" + verID, HKEY_LOCAL_MACHINE);
|
||||
}
|
||||
|
||||
IRef<ITypeLib>& typelib = GetTypeLib();
|
||||
if(!typelib)
|
||||
return SELFREG_E_TYPELIB;
|
||||
TLIBATTR *attr;
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = typelib->GetLibAttr(&attr)))
|
||||
return hr;
|
||||
hr = UnRegisterTypeLib(attr->guid,
|
||||
attr->wMajorVerNum, attr->wMinorVerNum,
|
||||
attr->lcid, attr->syskind);
|
||||
typelib->ReleaseTLibAttr(attr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
#ifndef _USRDLL
|
||||
HRESULT OcxTypeLib::RegisterObjects()
|
||||
{
|
||||
for(int i = 0; i < objects.GetCount(); i++) {
|
||||
OcxTypeInfo& entry = *objects[i];
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = CoRegisterClassObject(entry.GetCoClassGUID(), &entry,
|
||||
CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &entry.registration))) {
|
||||
RevokeObjects();
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _USRDLL
|
||||
void OcxTypeLib::RevokeObjects()
|
||||
{
|
||||
for(int i = 0; i < objects.GetCount(); i++) {
|
||||
OcxTypeInfo& entry = *objects[i];
|
||||
if(entry.registration) {
|
||||
CoRevokeClassObject(entry.registration);
|
||||
entry.registration = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT OcxTypeLib::GetFactory(REFCLSID rclsid, REFIID iid, void **ppv)
|
||||
{
|
||||
Guid clsid = rclsid;
|
||||
LOGSYSOCX("OcxTypeLib::GetFactory(clsid = " << clsid << ", iid = " << Guid(iid) << ")");
|
||||
LLOG("#ocx_init = " << ocx_init.GetCount());
|
||||
|
||||
for(int i = 0; i < ocx_init.GetCount(); i++)
|
||||
ocx_init[i]();
|
||||
ocx_init.Clear();
|
||||
|
||||
LLOG("#objects = " << objects.GetCount());
|
||||
for(int i = 0; i < objects.GetCount(); i++)
|
||||
LLOG("object[" << i << "] = " << Guid(objects.GetKey(i)));
|
||||
|
||||
*ppv = 0;
|
||||
int f = objects.Find(clsid);
|
||||
if(f < 0)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
OcxTypeInfo *entry = objects[f];
|
||||
HRESULT res = entry->QueryInterface(iid, ppv);
|
||||
LOGSYSOCX("//OcxTypeLib::GetFactory -> " << FormatIntHex(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
IRef<ITypeLib>& OcxTypeLib::GetTypeLib()
|
||||
{
|
||||
if(!typelib) { // opportunity lock used to initialize type library info
|
||||
critical.Enter();
|
||||
if(!typelib) {
|
||||
WString tlibname = GetModuleFileName().ToWString();
|
||||
HRESULT hr = LoadTypeLib(tlibname, typelib.Set());
|
||||
LOGSYSOCX("LoadTypeLib(" << tlibname << ") -> " << FormatIntHex(~typelib) << ", hr = " << FormatIntHex(hr));
|
||||
if(!!typelib) {
|
||||
hr = RegisterTypeLib(~typelib, const_cast<OLECHAR *>(~tlibname), NULL);
|
||||
LOGSYSOCX("RegisterTypeLib -> hr = " << FormatIntHex(hr));
|
||||
}
|
||||
}
|
||||
critical.Leave();
|
||||
}
|
||||
return typelib;
|
||||
}
|
||||
|
||||
#ifdef _USRDLL
|
||||
STDAPI DllCanUnloadNow()
|
||||
{
|
||||
LOGSYSOCX("DllCanUnloadNow");
|
||||
// DoLateInit();
|
||||
return (OcxTypeLib::Get().CanUnload() ? S_OK : S_FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _USRDLL
|
||||
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
||||
{
|
||||
LOGSYSOCX("DllGetClassObject, riid = " << Guid(riid));
|
||||
HRESULT res = OcxTypeLib::Get().GetFactory(rclsid, riid, ppv);
|
||||
LOGSYSOCX("//DllGetClassObject -> " << FormatIntHex(res, 8) << ", ppv = " << FormatIntHex(*ppv));
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _USRDLL
|
||||
STDAPI DllRegisterServer()
|
||||
{
|
||||
LOGSYSOCX("DllRegisterServer");
|
||||
try {
|
||||
DoLateInit();
|
||||
HRESULT hr = OcxTypeLib::Get().Register();
|
||||
if(SUCCEEDED(hr))
|
||||
LOGSYSOCX("-> succeeded");
|
||||
else
|
||||
LOGSYSOCX("-> failed: " << GetErrorMessage(hr));
|
||||
return hr;
|
||||
}
|
||||
catch(_com_error e) {
|
||||
LOGSYSOCX(e.Error());
|
||||
return e.Error();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _USRDLL
|
||||
STDAPI DllUnregisterServer()
|
||||
{
|
||||
LOGSYSOCX("DllUnregisterServer");
|
||||
try {
|
||||
DoLateInit();
|
||||
HRESULT hr = OcxTypeLib::Get().Unregister();
|
||||
LOGSYSOCX((SUCCEEDED(hr) ? "-> succeeded" : "-> failed"));
|
||||
return hr;
|
||||
}
|
||||
catch(_com_error e) {
|
||||
LOGSYSOCX(e.Error());
|
||||
return e.Error();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _USRDLL
|
||||
bool ExeRegisterServer()
|
||||
{
|
||||
LOGSYSOCX("ExeRegisterServer");
|
||||
HRESULT hr = OcxTypeLib::Get().Register();
|
||||
if(FAILED(hr))
|
||||
LOGSYSOCX("-> error: " << GetErrorMessage(hr));
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _USRDLL
|
||||
bool ExeUnregisterServer()
|
||||
{
|
||||
LOGSYSOCX("ExeRegisterServer");
|
||||
HRESULT hr = OcxTypeLib::Get().Unregister();
|
||||
if(FAILED(hr))
|
||||
LOGSYSOCX("-> error: " << GetErrorMessage(hr));
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _USRDLL
|
||||
void ExeRunServer()
|
||||
{
|
||||
LOGSYSOCX("ExeRunServer");
|
||||
// PromptOK("Running server!");
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = OcxTypeLib::Get().RegisterObjects())) {
|
||||
LOGSYSOCX("-> registration error: " << GetErrorMessage(hr));
|
||||
return;
|
||||
}
|
||||
LOGSYSOCX("-> registration OK");
|
||||
|
||||
int ms = msecs();
|
||||
bool quit = false;
|
||||
while(!quit) {
|
||||
if(msecs(ms) >= 2000) {
|
||||
if(OcxTypeLib::Get().CanUnload())
|
||||
break;
|
||||
ms = msecs();
|
||||
}
|
||||
if(!Ctrl::ProcessEvents(&quit))
|
||||
Sleep(10);
|
||||
}
|
||||
LOGSYSOCX("end of message loop");
|
||||
OcxTypeLib::Get().RevokeObjects();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef OLE_H
|
||||
#define OLE_H
|
||||
|
||||
#include <Core/Core.h>
|
||||
|
||||
#if defined(PLATFORM_WIN32) && !defined(PLATFORM_WINCE) && defined(COMPILER_MSC)
|
||||
|
||||
#define Ptr Ptr_
|
||||
#define StdFont StdFont_
|
||||
#define Font Font_
|
||||
#define Picture Picture_
|
||||
#define byte win32_byte_ // RpcNdr defines byte -> class with Upp::byte
|
||||
#define CY win32_CY_
|
||||
#include <comdef.h>
|
||||
#include <comip.h>
|
||||
#undef Ptr
|
||||
#undef StdFont
|
||||
#undef Font
|
||||
#undef Picture
|
||||
#undef byte
|
||||
#undef CY
|
||||
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#endif//OLE_H
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
description "Windows OLE encapsulation\377";
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
library(WIN32) ole32;
|
||||
|
||||
file
|
||||
Ole.h,
|
||||
util.h,
|
||||
util.cpp,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
TOPIC("ocx_en-us")
|
||||
#include "ocx_en-us.tpp"
|
||||
END_TOPIC
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
TITLE("Creating OCX Controls using U++")
|
||||
TOPIC_TEXT(
|
||||
"[2 $$0,0#00000000000000000000000000000000:Default][l288;i1120;a17;O9;~~~.1408;2 "
|
||||
"$$1,0#10431211400427159095818037425705:param][a83;*R6 $$2,5#31310162474203024125188417583966:caption][b83;*4 "
|
||||
"$$3,5#07864147445237544204411237157677:title][i288;O9;C2 $$4,6#40027414424643823182269349404212:item][b42;a42;2 "
|
||||
"$$5,5#45413000475342174754091244180557:text][l288;b17;a17;2 $$6,6#27521748481378242620020725143825:desc][l321;t246;C@5;1 "
|
||||
"$$7,7#20902679421464641399138805415013:code][b2503; $$8,0#65142375456100023862071332075487:separator][*@(0.0.255)2 "
|
||||
"$$9,0#83433469410354161042741608181528:base][t4167;C $$10,0#37138531426314131251341829483380:class][l288;a17;*1 "
|
||||
"$$11,11#70004532496200323422659154056402:requirement][i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam][b167;C2 "
|
||||
"$$13,13#92430459443460461911108080531343:item1][i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2][*@2$(0.128.128) "
|
||||
"$$15,15#34511555403152284025741354420178:NewsDate][l321;*C$7;2 $$16,16#03451589433145915344929335295360:result][l321;b83;a83;*C$7;2 "
|
||||
"$$17,17#07531550463529505371228428965313:result`-line][l160;t4167;*C+117 $$18,5#88603949442205825958800053222425:package`-title][ "
|
||||
"$$19,0#53580023442335529039900623488521:gap][t4167;C2 $$20,20#70211524482531209251820423858195:class`-nested][b50;2 "
|
||||
"$$21,21#03324558446220344731010354752573:Par][{_}%EN-US [s2; Creating OCX Controls "
|
||||
"using U`+`+&][s0; &][s0;i150;O9; 1.-|Use the U`+`+ version later than 2005`-11`-24. "
|
||||
"There was a very nasty bug in the OCX registration routine, capable of deleting half "
|
||||
"of CLSID registry keys and consequently nuking Windows installation. (Actually, this "
|
||||
"was not a bug in the routine as such, it was a bug in one of the overloads of the "
|
||||
"AsString routine).&][s0; &][s0;i150;O9; 2.-|Add DLL to the main configuration flags. "
|
||||
"This is more or less all that`'s needed to build into aDLL (OCX is technically a "
|
||||
"DLL).&][s0; &][s0;i150;O9; 3.-|You have to build the OCX interface using MIDL. You "
|
||||
"can use a custom step to do this:&][s0; &")
|
||||
TOPIC_TEXT(
|
||||
"][s7; Custom step (extension `= idl), output files: `$(DIR)/`$(TITLE)`_idl.h,&][s7; "
|
||||
"`$(DIR)/`$(TITLE)`_idl.cpp, `$(DIR)/`$(TITLE).tlb&][s7; &][s7; midl /newtlb `$(!/I) "
|
||||
"/h `\"`$(DIR)/`$(TITLE)`_idl.h`\" /iid&][s7; `\"`$(DIR)/`$(TITLE)`_idl.cpp`\" /tlb "
|
||||
"`\"`$(DIR)/`$(TITLE).tlb`\" `\"`$(PATH)`\"&][s0; &][s0;i150;O9; 4.-|You have to define "
|
||||
"a def`-file to declare public exports, like this:&][s0; &][s7; LIBRARY `\"mycontrol.ocx`\"&][s7; "
|
||||
"&][s7; EXPORTS&][s7; DllCanUnloadNow PRIVATE&][s7; DllGetClassObject PRIVATE&][s7; "
|
||||
"DllRegisterServer PRIVATE&][s7; DllUnregisterServer PRIVATE&][s0; &][s0;i150;O9; "
|
||||
"5.-|You need to put the type library (the TLB file created by MIDL from the IDL file) "
|
||||
"into your resources. Put this line on the beginning of your resource file:&][s0; "
|
||||
"&][s7; 1 TYPELIB `\"mycontrol.tlb`\"&][s0; &][s0; Do not forget to manually add `\"mycontrol.tlb`\" "
|
||||
"to the list of the resource file`'s dependencies. Otherwise next time you change "
|
||||
"the IDL file and the MIDL recompiles your TLB, TheIDE builder won`'t find out it "
|
||||
"needs to rebuild the resource script.&][s0; &][s0;i150;O9; 6.-|In the application, "
|
||||
"#include <Ole/Ctrl/OleCtrl.h> and use OCX`_APP`_MAIN to declare the `\"main`\" initialization "
|
||||
"routine. To be honest, the initialization routine is not really called during the "
|
||||
"very startup (DllMain `-> DLL`_PROCESS`_ATTACH), its invocation is postponed until "
|
||||
"1st object from the library is requested from the type factory. The reason for this "
|
||||
"is that too heavy initializations tend to deadlock or crash the Windows DLL loader.&][s0; "
|
||||
"&][s0;i150;O9; 7.-|To make an object an OCX control, derive it from OcxControl. You "
|
||||
"should also use multiple inheritance to derive it from your custom interfaces, perhaps "
|
||||
"like this:&][s0; &][s7; class MyViewOcx&][s7; : public OcxControl // handles OCX "
|
||||
"control client functionality&][s7; , public DispatchInterface<IMyView> // custom "
|
||||
"control`'s interface&][s7; , public OcxConnectionPointContainer // needed only for "
|
||||
"callback (aka event) interface&][s0; &][s0;i150;")
|
||||
TOPIC_TEXT(
|
||||
"O9; 8.-|The whole project should be demonstrated in a simple project called Ole/Ctrl/Calc.&][s0;i150;O9; "
|
||||
"]")
|
||||
|
|
@ -1,455 +0,0 @@
|
|||
#include "Ole.h"
|
||||
|
||||
#if defined(PLATFORM_WIN32) && defined(COMPILER_MSC)
|
||||
|
||||
namespace Upp {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GUID
|
||||
|
||||
GUID GetCoClassGUID(const char *name, bool prog_id)
|
||||
{
|
||||
OleBstr uni = String(name);
|
||||
GUID guid;
|
||||
Zero(guid);
|
||||
if(prog_id && *name != '{')
|
||||
CLSIDFromProgID(~uni, &guid);
|
||||
else
|
||||
CLSIDFromString(~uni, &guid);
|
||||
return guid;
|
||||
}
|
||||
|
||||
hash_t GetHashValue(const GUID& guid) {
|
||||
const dword *p = reinterpret_cast<const dword *>(&guid);
|
||||
return CombineHash(p[0], p[1], p[2], p[3]);
|
||||
}
|
||||
|
||||
String Format(const GUID& guid) {
|
||||
String result;
|
||||
wchar_t buffer[128];
|
||||
int length;
|
||||
if((length = StringFromGUID2(guid, buffer, __countof(buffer))) > 0)
|
||||
result = AsString(buffer, length - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
String CFormat(const GUID& guid) {
|
||||
String value = Format("{ 0x%08x, 0x%04x, 0x%04x, { ", (int)guid.Data1, (int)guid.Data2, (int)guid.Data3);
|
||||
for(int i = 0; i < 8; i++)
|
||||
value << Format("0x%02x, ", guid.Data4[i]);
|
||||
return value << "} }";
|
||||
}
|
||||
|
||||
String GetInterfaceName(const GUID& guid) {
|
||||
if(IsNull(Guid(guid)))
|
||||
return Null;
|
||||
String goo = Format(guid);
|
||||
return Nvl(GetWinRegString(NULL, "Interface\\" + goo, HKEY_CLASSES_ROOT), goo);
|
||||
}
|
||||
|
||||
String GetCoClassName(const GUID& guid) {
|
||||
if(IsNull(Guid(guid)))
|
||||
return Null;
|
||||
String goo = Format(guid);
|
||||
return Nvl(GetWinRegString(NULL, "CLSID\\" + goo + "\\ProgID", HKEY_CLASSES_ROOT), goo);
|
||||
}
|
||||
|
||||
String GetDisplayName(const GUID& guid) {
|
||||
if(IsNull(Guid(guid)))
|
||||
return Null;
|
||||
String goo = Format(guid);
|
||||
return Nvl(GetWinRegString(NULL, "CLSID\\" + goo, HKEY_CLASSES_ROOT), goo);
|
||||
}
|
||||
|
||||
bool Guid::IsNullInstance() const
|
||||
{
|
||||
const dword *p = reinterpret_cast<const dword *>(&guid);
|
||||
return (p[0] | p[1] | p[2] | p[3]) == 0;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// VARIANT
|
||||
|
||||
Value AsValue(const VARIANT& variant)
|
||||
{
|
||||
switch(variant.vt) {
|
||||
case VT_ERROR: return ErrorValue(GetErrorMessage(variant.scode));
|
||||
case VT_EMPTY: return Value(); // void
|
||||
case VT_NULL: return Null;
|
||||
|
||||
case VT_BOOL:
|
||||
case VT_UI1: return (int)variant.bVal;
|
||||
case VT_I2: return (int)variant.iVal;
|
||||
case VT_I4: return (int)variant.lVal;
|
||||
|
||||
case VT_R4: return variant.fltVal;
|
||||
case VT_R8: return variant.dblVal;
|
||||
|
||||
case VT_CY: return GetCurrency(variant.cyVal);
|
||||
|
||||
case VT_DATE: return FromDATE(variant.date);
|
||||
|
||||
case VT_BSTR: return BSTRToWString(variant.bstrVal);
|
||||
|
||||
case VT_DECIMAL: {
|
||||
const DECIMAL& d = variant.decVal;
|
||||
double h = (d.Lo32 + d.Mid32 * (65536.0 * 65536.0)) * pow(0.1, d.scale);
|
||||
return d.sign ? -h : h;
|
||||
}
|
||||
|
||||
case VT_ARRAY | VT_UI1: {
|
||||
int nelem = variant.parray->rgsabound[0].cElements;
|
||||
void *bits = 0;
|
||||
if(SUCCEEDED(SafeArrayAccessData(variant.parray, &bits)) && bits) {
|
||||
String out((const char *)bits, nelem);
|
||||
SafeArrayUnaccessData(variant.parray);
|
||||
return out;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ErrorValue(Format("Unknown variant type %d", variant.vt));
|
||||
}
|
||||
|
||||
OleVariant AsVariant(Value value) {
|
||||
OleVariant out(VT_NULL);
|
||||
if(value.IsNull())
|
||||
return out;
|
||||
switch(value.GetType()) {
|
||||
case BOOL_V: out.vt = VT_UI1; out.bVal = (byte)(int)value; break;
|
||||
case INT_V: out.vt = VT_I4; out.lVal = (int)value; break;
|
||||
case DOUBLE_V: out.vt = VT_R8; out.dblVal = value; break;
|
||||
case STRING_V: out.vt = VT_BSTR; out.bstrVal = StringToBSTR(value); break;
|
||||
case WSTRING_V: out.vt = VT_BSTR; out.bstrVal = WStringToBSTR(value); break;
|
||||
case DATE_V:
|
||||
case TIME_V: out.vt = VT_DATE; out.date = ToDATE((Time)value);
|
||||
// todo: VALUEARRAY_V ??
|
||||
default: break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
double GetCurrency(const win32_CY_& currency) {
|
||||
return (currency.Hi * (65536.0 * 65536.0) + currency.Lo) / 10000.0;
|
||||
}
|
||||
|
||||
OleVariant ValueToVariant(Value v)
|
||||
{
|
||||
if(IsTypeRaw< IRef<IDispatch> >(v))
|
||||
{
|
||||
OleVariant out(VT_DISPATCH);
|
||||
IRef<IDispatch> disp = ValueTo< IRef<IDispatch> >(v);
|
||||
if(!!disp) disp -> AddRef();
|
||||
out.pdispVal = ~disp;
|
||||
return out;
|
||||
}
|
||||
if(IsTypeRaw< IRef<IUnknown> >(v))
|
||||
{
|
||||
OleVariant out(VT_UNKNOWN);
|
||||
IRef<IUnknown> unk = ValueTo< IRef<IUnknown> >(v);
|
||||
if(!!unk) unk -> AddRef();
|
||||
out.punkVal = ~unk;
|
||||
return out;
|
||||
}
|
||||
return AsVariant(v);
|
||||
}
|
||||
|
||||
void ReturnVariant(VARIANT *var, const Value& v)
|
||||
{
|
||||
*var = AsVariant(v);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BSTR
|
||||
|
||||
String BSTRToString(BSTR bstr)
|
||||
{
|
||||
int l;
|
||||
if(!bstr || !(l = SysStringLen(bstr)))
|
||||
return Null;
|
||||
byte cs = GetDefaultCharset();
|
||||
if(cs == CHARSET_UTF8)
|
||||
return ToUtf8(TWchar(bstr));
|
||||
StringBuffer out(l);
|
||||
FromUnicode(out, TWchar(bstr), l, cs);
|
||||
return out;
|
||||
}
|
||||
|
||||
BSTR StringToBSTR(String s)
|
||||
{
|
||||
int len = s.GetLength();
|
||||
if(len == 0)
|
||||
return NULL;
|
||||
byte cs = GetDefaultCharset();
|
||||
if(cs == CHARSET_UTF8)
|
||||
return WStringToBSTR(FromUtf8(s));
|
||||
BSTR bstr = SysAllocStringLen(NULL, len);
|
||||
ToUnicode(TWchar(bstr), s, len, cs);
|
||||
return bstr;
|
||||
}
|
||||
|
||||
void ReturnString(BSTR *dest, String s)
|
||||
{
|
||||
if(*dest)
|
||||
SysFreeString(*dest);
|
||||
*dest = StringToBSTR(s);
|
||||
}
|
||||
|
||||
HRESULT CheckReturnString(BSTR *bstr, String s)
|
||||
{
|
||||
if(!bstr) return E_INVALIDARG;
|
||||
ReturnString(bstr, s);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void ReturnWString(BSTR *dest, WString s)
|
||||
{
|
||||
if(*dest)
|
||||
SysFreeString(*dest);
|
||||
*dest = WStringToBSTR(s);
|
||||
}
|
||||
|
||||
HRESULT CheckReturnWString(BSTR *bstr, WString s)
|
||||
{
|
||||
if(!bstr) return E_INVALIDARG;
|
||||
ReturnWString(bstr, s);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static ValueArray SAFEARRAYToValueArrayPart(SAFEARRAY *array, long *indices, int dim_index)
|
||||
{
|
||||
Vector<Value> dim_array;
|
||||
int nelem = array->rgsabound[dim_index].cElements;
|
||||
dim_array.SetCount(nelem);
|
||||
for(int e = 0; e < nelem; e++) {
|
||||
indices[dim_index] = e;
|
||||
if(dim_index > 0)
|
||||
dim_array[e] = SAFEARRAYToValueArrayPart(array, indices, dim_index - 1);
|
||||
else {
|
||||
OleVariant var;
|
||||
HRESULT hr = SafeArrayGetElement(array, indices, &var);
|
||||
if(SUCCEEDED(hr))
|
||||
dim_array[e] = AsValue(var);
|
||||
else {
|
||||
String dims;
|
||||
for(int i = 0; i < dim_index; i++)
|
||||
dims << (i ? ", " : "") << indices[i];
|
||||
dim_array[e] = ErrorValue(NFormat("SafeArrayGetElement(%s): error %08lx", dims, hr));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ValueArray(pick(dim_array));
|
||||
}
|
||||
|
||||
ValueArray SAFEARRAYToValueArray(SAFEARRAY *array)
|
||||
{
|
||||
int ndims = array->cDims;
|
||||
Vector<long> indices;
|
||||
indices.SetCount(ndims, -1);
|
||||
return SAFEARRAYToValueArrayPart(array, indices.Begin(), ndims - 1);
|
||||
}
|
||||
|
||||
Vector<WString> SAFEARRAYToWStringVector(SAFEARRAY *array)
|
||||
{
|
||||
Vector<WString> out;
|
||||
out.SetCount(array->rgsabound[0].cElements);
|
||||
Vector<long> indices;
|
||||
indices.SetCount(array->cDims, 0);
|
||||
for(int i = 0; i < out.GetCount(); i++) {
|
||||
OleBstr s;
|
||||
indices[0] = i;
|
||||
HRESULT hr = SafeArrayGetElement(array, indices.Begin(), s.Set());
|
||||
out[i] = s;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
SAFEARRAY *ToSAFEARRAY(const ValueArray& varray)
|
||||
{
|
||||
SAFEARRAY *a = SafeArrayCreateVector(VT_VARIANT, 0, varray.GetCount());
|
||||
if(!a)
|
||||
return NULL;
|
||||
for(long index = 0; index < varray.GetCount(); index++) {
|
||||
OleVariant var = AsVariant(varray[(int)index]);
|
||||
SafeArrayPutElement(a, &index, &var);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
SAFEARRAY *ToSAFEARRAY(const Vector<WString>& vstr)
|
||||
{
|
||||
SAFEARRAY *a = SafeArrayCreateVector(VT_BSTR, 0, vstr.GetCount());
|
||||
if(!a)
|
||||
return NULL;
|
||||
for(long index = 0; index < vstr.GetCount(); index++) {
|
||||
OleBstr var = vstr[(int)index];
|
||||
SafeArrayPutElement(a, &index, ~var);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// special types
|
||||
|
||||
Color PackColor(long rgb)
|
||||
{
|
||||
if(rgb < 0)
|
||||
return Null;
|
||||
return Color((rgb >> 16) & 255, (rgb >> 8) & 255, (rgb >> 0) & 255);
|
||||
}
|
||||
|
||||
long UnpackColor(Color c)
|
||||
{
|
||||
if(IsNull(c))
|
||||
return -1;
|
||||
return (c.GetR() << 16) | (c.GetG() << 8) | (c.GetB() << 0);
|
||||
}
|
||||
|
||||
HRESULT CheckReturnColor(long *ptr, Color c)
|
||||
{
|
||||
if(!ptr)
|
||||
return E_INVALIDARG;
|
||||
*ptr = UnpackColor(c);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// errors
|
||||
|
||||
OleExc::OleExc(HRESULT hresult)
|
||||
: Exc(NFormat("COM[%08x]: %s", (int)hresult, GetErrorMessage(hresult)))
|
||||
, hresult(hresult)
|
||||
{
|
||||
}
|
||||
|
||||
OleExc::OleExc(HRESULT hresult, const char *text)
|
||||
: Exc(NFormat("COM[%08x]: %s: %s", (int)hresult, GetErrorMessage(hresult), text))
|
||||
, hresult(hresult)
|
||||
{
|
||||
LOG("OleExc::OleExc " << *this);
|
||||
}
|
||||
|
||||
HRESULT LogResult(HRESULT hr)
|
||||
{
|
||||
LOGF("<= return 0x%08x: %s\r\n", hr, GetErrorMessage(hr));
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT LogError(HRESULT hr)
|
||||
{
|
||||
if(FAILED(hr))
|
||||
LogResult(hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// interfaces
|
||||
|
||||
Value DispatchToValue(IDispatch *disp)
|
||||
{
|
||||
return RawPickToValue(IRef<IDispatch>(disp));
|
||||
}
|
||||
|
||||
Value UnknownToValue(IUnknown *unk)
|
||||
{
|
||||
return RawPickToValue(IRef<IUnknown>(unk));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// OleStream::
|
||||
|
||||
OleStream::OleStream(IUnknown *stream)
|
||||
{
|
||||
Open(stream);
|
||||
}
|
||||
|
||||
bool OleStream::Open(IUnknown *stream)
|
||||
{
|
||||
Close();
|
||||
if(!stream)
|
||||
return false;
|
||||
if(FAILED(stream -> QueryInterface(IID_IStream, (void **)&istream)))
|
||||
return false;
|
||||
STATSTG stat;
|
||||
Zero(stat);
|
||||
// HRESULT statres = istream -> Stat(&stat, STATFLAG_NONAME);
|
||||
int mode = READWRITE;
|
||||
// if(SUCCEEDED(statres) && (stat.grfMode & (STGM_READ | STGM_WRITE | STGM_READWRITE)) == STGM_READ)
|
||||
// mode = READ;
|
||||
|
||||
ULARGE_INTEGER pos = AsULarge(0), len;
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = istream -> Seek(AsLarge(0), STREAM_SEEK_CUR, &pos))
|
||||
|| FAILED(hr = istream -> Seek(AsLarge(0), STREAM_SEEK_END, &len)))
|
||||
SetError(hr);
|
||||
current_offset = len.QuadPart;
|
||||
OpenInit(mode, len.QuadPart);
|
||||
Seek(pos.QuadPart);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OleStream::Close()
|
||||
{
|
||||
if(!(bool)istream)
|
||||
return;
|
||||
int64 pos = GetPos();
|
||||
Flush();
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = istream -> Seek(AsLarge(pos), STREAM_SEEK_SET, 0)))
|
||||
SetError(hr);
|
||||
istream = 0;
|
||||
}
|
||||
|
||||
void OleStream::SetStreamSize(dword size)
|
||||
{
|
||||
ASSERT((bool)istream && (GetStyle() & STRM_WRITE));
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = istream -> SetSize(AsULarge(size))))
|
||||
SetError(hr);
|
||||
ULARGE_INTEGER pos = AsULarge(0);
|
||||
if(FAILED(hr = istream -> Seek(AsLarge(0), STREAM_SEEK_CUR, &pos)))
|
||||
SetError(hr);
|
||||
current_offset = pos.LowPart;
|
||||
}
|
||||
|
||||
dword OleStream::Read(int64 at, void *ptr, dword size)
|
||||
{
|
||||
ASSERT((bool)istream && (GetStyle() & STRM_READ));
|
||||
RawSeek(at);
|
||||
dword done = 0;
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = istream -> Read(ptr, size, &done)))
|
||||
SetError(hr);
|
||||
else
|
||||
current_offset += done;
|
||||
return done;
|
||||
}
|
||||
|
||||
void OleStream::Write(int64 at, const void *data, dword size)
|
||||
{
|
||||
ASSERT((bool)istream && (GetStyle() & STRM_WRITE));
|
||||
RawSeek(at);
|
||||
dword done = 0;
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = istream -> Write(data, size, &done)) || done != size)
|
||||
SetError(hr);
|
||||
current_offset += done;
|
||||
}
|
||||
|
||||
void OleStream::RawSeek(int64 pos)
|
||||
{
|
||||
if(current_offset == pos)
|
||||
return;
|
||||
ULARGE_INTEGER new_pos = AsULarge(pos);
|
||||
HRESULT hr;
|
||||
if(FAILED(hr = istream -> Seek(AsLarge(pos), STREAM_SEEK_SET, &new_pos)))
|
||||
SetError(hr);
|
||||
pos = new_pos.LowPart;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
#if defined(PLATFORM_WIN32) && defined(COMPILER_MSC)
|
||||
|
||||
namespace Upp {
|
||||
|
||||
#ifdef COMPILER_MSC
|
||||
typedef __int64 longlong_t;
|
||||
#define LL_(x) COMBINE(x, i64)
|
||||
#else
|
||||
typedef long long longlong_t;
|
||||
#define LL_(x) COMBINE(x, LL)
|
||||
#endif//COMPILER
|
||||
|
||||
inline void OleInit() { CoInitialize(NULL); }
|
||||
|
||||
inline const wchar_t *WcharT(const wchar *w) { return (const wchar_t *)w; }
|
||||
inline wchar_t *WcharT(wchar *w) { return (wchar_t *)w; }
|
||||
inline const wchar *TWchar(const wchar_t *w) { return (const wchar *)w; }
|
||||
inline wchar *TWchar(wchar_t *w) { return (wchar *)w; }
|
||||
|
||||
template <class T>
|
||||
class OleBuffer
|
||||
{
|
||||
public:
|
||||
OleBuffer(T *ptr = 0) : ptr(ptr) {}
|
||||
~OleBuffer() { Clear(); }
|
||||
|
||||
void Clear() { if(ptr) { CoTaskMemFree(ptr); ptr = 0; } }
|
||||
T **Set() { Clear(); return &ptr; }
|
||||
|
||||
operator T * () { return ptr; }
|
||||
operator const T * () const { return ptr; }
|
||||
|
||||
private:
|
||||
T *ptr;
|
||||
};
|
||||
|
||||
hash_t GetHashValue(const GUID& guid);
|
||||
String Format(const GUID& guid);
|
||||
String CFormat(const GUID& guid);
|
||||
inline void Serialize(Stream& stream, GUID& guid) { stream.SerializeRaw((byte *)&guid, sizeof(GUID)); }
|
||||
String GetInterfaceName(const GUID& guid);
|
||||
String GetCoClassName(const GUID& guid);
|
||||
String GetDisplayName(const GUID& guid);
|
||||
GUID GetCoClassGUID(const char *name, bool prog_id = true);
|
||||
|
||||
class Guid : public ValueType<Guid, 70, Moveable<Guid> >
|
||||
{
|
||||
public:
|
||||
Guid(const Nuller& = Null) { Clear(); }
|
||||
Guid(const char *text, bool prid = true) { guid = GetCoClassGUID(text, prid); }
|
||||
Guid(const GUID& guid_) : guid(guid_) {}
|
||||
Guid(const Guid& guid_) : guid(guid_.guid) {}
|
||||
Guid(IDispatchPtr& dispatch); // dynamic GUID of a dispatch object
|
||||
Guid(Value v) { *this = ValueTo<Guid>(v); }
|
||||
|
||||
operator Value () const { return RichValue<Guid>(*this); }
|
||||
operator const GUID& () const { return guid; }
|
||||
operator GUID& () { return guid; }
|
||||
const GUID& operator ~() const { return guid; }
|
||||
|
||||
Guid& operator = (const GUID& _guid) { guid = _guid; return *this; }
|
||||
|
||||
bool IsNullInstance() const;
|
||||
bool IsEmpty() const { return IsNullInstance(); }
|
||||
void Clear() { Zero(guid); }
|
||||
|
||||
operator String () const { return UPP::Format(guid); }
|
||||
String CFormat() const { return UPP::CFormat(guid); }
|
||||
|
||||
void Serialize(Stream& stream) { UPP::Serialize(stream, guid); }
|
||||
|
||||
private:
|
||||
GUID guid;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline hash_t GetHashValue(const Guid& guid) { return GetHashValue(~guid); }
|
||||
template <>
|
||||
inline String AsString(const GUID& guid) { return Format(guid); }
|
||||
template <>
|
||||
inline String AsString(const Guid& guid) { return Format(~guid); }
|
||||
|
||||
inline bool operator == (const Guid& a, const Guid& b) { return ~a == ~b; }
|
||||
inline bool operator != (const Guid& a, const Guid& b) { return ~a != ~b; }
|
||||
|
||||
class OleExc : public Exc
|
||||
{
|
||||
public:
|
||||
OleExc(HRESULT hresult);
|
||||
OleExc(HRESULT hresult, const char *text);
|
||||
|
||||
public:
|
||||
HRESULT hresult;
|
||||
};
|
||||
|
||||
HRESULT LogResult(HRESULT hr);
|
||||
HRESULT LogError(HRESULT hr);
|
||||
|
||||
inline void OleVerify(HRESULT hr) { if(FAILED(hr)) throw OleExc(hr); }
|
||||
inline void OleVerify(HRESULT hr, const char *text) { if(FAILED(hr)) throw OleExc(hr, text); }
|
||||
|
||||
#define OLE_VERIFY(c) OleVerify(c, #c)
|
||||
|
||||
class OleVariant : public VARIANT
|
||||
{
|
||||
public:
|
||||
OleVariant(int vtype = VT_EMPTY) { VariantInit(this); vt = vtype; }
|
||||
OleVariant(const OleVariant& o) { VariantInit(this); VariantCopy(this, const_cast<OleVariant *>(&o)); }
|
||||
~OleVariant() { VariantClear(this); }
|
||||
OleVariant(const VARIANT& var) { VariantInit(this); VariantCopy(this, const_cast<VARIANT *>(&var)); }
|
||||
|
||||
OleVariant& operator = (const OleVariant& var) { if(this != &var) { VariantClear(this); VariantCopy(this, const_cast<VARIANT *>((VARIANT *)&var)); } return *this; }
|
||||
|
||||
VARIANT operator ~ () const { VARIANT v; VariantInit(&v); VariantCopy(&v, const_cast<OleVariant *>(this)); return v; }
|
||||
};
|
||||
|
||||
Value AsValue(const VARIANT& variant);
|
||||
OleVariant AsVariant(Value value);
|
||||
|
||||
//inline ULARGE_INTEGER AsULarge(dword value) { ULARGE_INTEGER i; i.QuadPart = value; return i; }
|
||||
//inline LARGE_INTEGER AsLarge(int value) { LARGE_INTEGER i; i.QuadPart = value; return i; }
|
||||
inline ULARGE_INTEGER AsULarge(int64 value) { ULARGE_INTEGER i; i.QuadPart = value; return i; }
|
||||
inline LARGE_INTEGER AsLarge(int64 value) { LARGE_INTEGER i; i.QuadPart = value; return i; }
|
||||
|
||||
double GetCurrency(const win32_CY_& currency);
|
||||
inline DATE ToDATE(Date date) { return date - Date(1899, 12, 30); }
|
||||
inline DATE ToDATE(Time time) { return (time - Time(1899, 12, 30)) / 86400.0; }
|
||||
inline Time FromDATE(DATE date) { return Time(1899, 12, 30) + (int64)floor(date * 86400.0 + 0.5); }
|
||||
|
||||
OleVariant ValueToVariant(Value v);
|
||||
void ReturnVariant(VARIANT *var, Value v);
|
||||
|
||||
inline WString BSTRToWString(BSTR bstr) { return WString((wchar *)bstr, SysStringLen(bstr)); }
|
||||
inline BSTR WStringToBSTR(WString w) { return SysAllocStringLen((BSTR)~w, w.GetLength()); }
|
||||
String BSTRToString(BSTR bstr);
|
||||
BSTR StringToBSTR(String s);
|
||||
|
||||
void ReturnString(BSTR *dest, String s);
|
||||
HRESULT CheckReturnString(BSTR *bstr, String s);
|
||||
void ReturnWString(BSTR *dest, WString s);
|
||||
HRESULT CheckReturnWString(BSTR *bstr, WString s);
|
||||
|
||||
ValueArray SAFEARRAYToValueArray(SAFEARRAY *array);
|
||||
Vector<WString> SAFEARRAYToWStringVector(SAFEARRAY *array);
|
||||
SAFEARRAY *ToSAFEARRAY(const ValueArray& varray);
|
||||
SAFEARRAY *ToSAFEARRAY(const Vector<WString>& varray);
|
||||
void ReturnSAFEARRAY(SAFEARRAY *dest, const ValueArray& array);
|
||||
void ReturnSAFEARRAY(SAFEARRAY *dest, const Vector<WString>& array);
|
||||
HRESULT CheckReturnSAFEARRAY(SAFEARRAY *dest, const ValueArray& array);
|
||||
HRESULT CheckReturnSAFEARRAY(SAFEARRAY *dest, const Vector<WString>& array);
|
||||
|
||||
class OleSafeArray {
|
||||
public:
|
||||
OleSafeArray() : array(NULL) {}
|
||||
OleSafeArray(const ValueArray& va) { array = ToSAFEARRAY(va); }
|
||||
OleSafeArray(const Vector<WString>& vs) { array = ToSAFEARRAY(vs); }
|
||||
OleSafeArray(const OleSafeArray& a) { array = NULL; if(a.array) OleVerify(SafeArrayCopy(a.array, &array)); }
|
||||
~OleSafeArray() { if(array) SafeArrayDestroy(array); }
|
||||
|
||||
operator ValueArray () const { return SAFEARRAYToValueArray(array); }
|
||||
operator Vector<WString> () const { return SAFEARRAYToWStringVector(array); }
|
||||
SAFEARRAY *operator ~ () const { return array; }
|
||||
|
||||
private:
|
||||
SAFEARRAY *array;
|
||||
};
|
||||
|
||||
class OleBstr
|
||||
{
|
||||
public:
|
||||
OleBstr(const Nuller& = Null) : bstr(NULL) {}
|
||||
OleBstr(WString w) : bstr(WStringToBSTR(w)) {}
|
||||
OleBstr(String s) : bstr(StringToBSTR(s)) {}
|
||||
~OleBstr() { if(bstr) SysFreeString(bstr); }
|
||||
|
||||
void Clear() { if(bstr) { SysFreeString(bstr); bstr = NULL; } }
|
||||
BSTR *Set() { Clear(); return &bstr; }
|
||||
|
||||
operator WString () const { return BSTRToWString(bstr); }
|
||||
operator String () const { return BSTRToString(bstr); }
|
||||
String ToString() const { return BSTRToString(bstr); }
|
||||
// operator BSTR () const { return bstr; }
|
||||
BSTR operator ~ () const { return bstr; }
|
||||
int GetLength() const { return SysStringLen(bstr); }
|
||||
|
||||
private:
|
||||
BSTR bstr;
|
||||
};
|
||||
|
||||
inline const RECTL& ToRectL(const Rect& rc) { return reinterpret_cast<const RECTL&>(rc); }
|
||||
inline const Rect& ToRect(const RECTL& rc) { return reinterpret_cast<const Rect&>(rc); }
|
||||
|
||||
Color PackColor(long rgb);
|
||||
long UnpackColor(Color c);
|
||||
HRESULT CheckReturnColor(long *ptr, Color c);
|
||||
|
||||
template <class T>
|
||||
class IRefBase : Moveable< IRefBase<T> >
|
||||
{
|
||||
public:
|
||||
IRefBase(T *ptr = NULL) : ptr(ptr) { if(ptr) ptr->AddRef(); }
|
||||
IRefBase(const IRefBase& i) { if(ptr = i.ptr) ptr->AddRef(); }
|
||||
~IRefBase() { if(ptr) ptr->Release(); }
|
||||
|
||||
static GUID GetIID() { return __uuidof(T); }
|
||||
|
||||
HRESULT Create(const GUID& clsid, dword flags = CLSCTX_INPROC_SERVER)
|
||||
{ return CoCreateInstance(clsid, NULL, flags, GetIID(), (void **)Set()); }
|
||||
|
||||
void Clear() { if(ptr) { ptr->Release(); ptr = 0; } }
|
||||
|
||||
T *operator->() const { ASSERT(ptr); return ptr; }
|
||||
T& operator * () const { ASSERT(ptr); return *ptr; }
|
||||
T *operator ~ () const { return ptr; }
|
||||
|
||||
T **Set() { Clear(); return &ptr; }
|
||||
IUnknown **SetUnk() { Clear(); return (IUnknown **)&ptr; }
|
||||
void **SetVoid() { Clear(); return (void **)&ptr; }
|
||||
void Set(T *p) { T *old = ptr; if(ptr = p) ptr->AddRef(); if(old) old->Release(); }
|
||||
|
||||
bool operator !() const { return !ptr; }
|
||||
|
||||
T *AddRef() { if(ptr) ptr->AddRef(); return ptr; }
|
||||
T *Detach() { T *out = ptr; ptr = 0; return out; }
|
||||
T *operator - () { return Detach(); }
|
||||
|
||||
protected:
|
||||
mutable T *ptr;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class IRef : public Moveable< IRef<T>, IRefBase<T> >
|
||||
{
|
||||
public:
|
||||
IRef() {}
|
||||
IRef(IUnknown *u) { if(u) OleVerify(u->QueryInterface(__uuidof(T), (void **)&ptr)); }
|
||||
IRef(T *t) { if(ptr = t) ptr->AddRef(); }
|
||||
IRef(const GUID& clsid, dword flags = CLSCTX_INPROC_SERVER) { OleVerify(Create(clsid, flags)); }
|
||||
IRef(const IRef<T>& x) : Moveable< IRef<T>, IRefBase<T> >(x) {}
|
||||
explicit IRef(const VARIANT& v)
|
||||
{
|
||||
ptr = NULL;
|
||||
if(v.vt == VT_DISPATCH)
|
||||
OleVerify(v.pdispVal->QueryInterface(__uuidof(T), (void **)&ptr));
|
||||
else if(v.vt == VT_UNKNOWN)
|
||||
OleVerify(v.punkVal->QueryInterface(__uuidof(T), (void **)&ptr));
|
||||
else
|
||||
{
|
||||
ASSERT(v.vt == VT_EMPTY || v.vt == VT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
IRef& operator = (const IRef<T>& x) { Set(x.ptr); return *this; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class IRef<IUnknown> : public IRefBase<IUnknown>
|
||||
{
|
||||
public:
|
||||
IRef() {}
|
||||
IRef(IUnknown *u) : IRefBase<IUnknown>(u) {}
|
||||
IRef(const GUID& clsid, dword flags = CLSCTX_INPROC_SERVER) { OleVerify(Create(clsid, flags)); }
|
||||
IRef(const IRef<IUnknown>& x) : IRefBase<IUnknown>(x.ptr) {}
|
||||
|
||||
IRef& operator = (const IRef<IUnknown>& x) { Set(x.ptr); return *this; }
|
||||
};
|
||||
|
||||
Value DispatchToValue(IDispatch *disp);
|
||||
Value UnknownToValue(IUnknown *unk);
|
||||
|
||||
template <class I>
|
||||
OleVariant DispVar(I& iface)
|
||||
{
|
||||
IRef<IDispatch> disp = iface;
|
||||
OleVariant out(VT_DISPATCH);
|
||||
if(!!disp) disp->AddRef();
|
||||
out.pdispVal = ~disp;
|
||||
return out;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct OleType : Moveable< OleType<T> >
|
||||
{
|
||||
friend T *Ptr(T& t) { return reinterpret_cast<T *>(&reinterpret_cast<char &>(t)); }
|
||||
friend T& Deref(T *t) { return reinterpret_cast<T&>(*reinterpret_cast<char *>(t)); }
|
||||
friend void Destroy(T& t) { t.~T(); }
|
||||
friend T& Construct(T& t) { return Deref(new(Ptr(t)) T); }
|
||||
friend void CopyConstruct(T& t, T& x) { new(Ptr(t)) T(x); }
|
||||
friend void DeepCopyConstruct(T& t, const T& x) { new(Ptr(t)) T(x); }
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
inline HRESULT QueryInterface(T& src, U& dest, const GUID& guid)
|
||||
{
|
||||
return src->QueryInterface(guid, (void **)dest.Set());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline HRESULT QueryInterface(T& src, U& dest)
|
||||
{
|
||||
return QueryInterface(src, dest, dest.GetIID());
|
||||
}
|
||||
|
||||
class OleStream : public BlockStream
|
||||
{
|
||||
public:
|
||||
OleStream(IUnknown *stream = 0);
|
||||
|
||||
bool Open(IUnknown *stream);
|
||||
virtual void Close();
|
||||
virtual bool IsOpen() const { return istream; }
|
||||
|
||||
protected:
|
||||
virtual void SetStreamSize(dword size);
|
||||
virtual dword Read(int64 at, void *ptr, dword size);
|
||||
virtual void Write(int64 at, const void *data, dword size);
|
||||
|
||||
void RawSeek(int64 pos);
|
||||
|
||||
protected:
|
||||
IStreamPtr istream;
|
||||
int64 current_offset;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2014, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,85 +0,0 @@
|
|||
#ifndef __OLEDB_H__
|
||||
#define __OLEDB_H__
|
||||
|
||||
#include <Sql/Sql.h>
|
||||
|
||||
#if defined(PLATFORM_WIN32) && defined(COMPILER_MSC)
|
||||
|
||||
#define Font OleFont
|
||||
#define Picture OlePicture
|
||||
#define byte win32_byte_ // RpcNdr defines byte -> class with Upp::byte
|
||||
#define CY win32_CY_
|
||||
#include <Ole/Ole.h>
|
||||
#include <winnls.h>
|
||||
#include <oleauto.h>
|
||||
#include <oledb.h>
|
||||
#include <msdasc.h>
|
||||
#include <msdaguid.h>
|
||||
#undef Font
|
||||
#undef Picture
|
||||
#undef byte
|
||||
#undef CY
|
||||
|
||||
namespace Upp {
|
||||
|
||||
bool OleDBPerformScript(const String& text, StatementExecutor& executor, Gate2<int, int> progress_canceled = false);
|
||||
String MSSQLTextType(int width);
|
||||
|
||||
class OleDBSession : public SqlSession
|
||||
{
|
||||
public:
|
||||
OleDBSession();
|
||||
virtual ~OleDBSession();
|
||||
|
||||
bool Open(String connect);
|
||||
bool Open(String user, String password, String datasource, String provider);
|
||||
bool OpenProp(String propset);
|
||||
void Close();
|
||||
|
||||
virtual void Begin();
|
||||
virtual void Commit();
|
||||
virtual void Rollback();
|
||||
|
||||
virtual String Savepoint();
|
||||
virtual void RollbackTo(const String& savepoint);
|
||||
|
||||
virtual bool IsOpen() const;
|
||||
virtual RunScript GetRunScript() const { return &OleDBPerformScript; }
|
||||
|
||||
virtual Vector<String> EnumUsers();
|
||||
virtual Vector<String> EnumDatabases();
|
||||
virtual Vector<String> EnumTables(String database);
|
||||
virtual Vector<String> EnumViews(String database);
|
||||
virtual Vector<String> EnumSequences(String database);
|
||||
virtual Vector<String> EnumPrimaryKey(String database, String table);
|
||||
virtual String EnumRowID(String database, String table);
|
||||
|
||||
struct Provider
|
||||
{
|
||||
String name;
|
||||
String description;
|
||||
String guid;
|
||||
};
|
||||
static Array<Provider> EnumProviders();
|
||||
|
||||
protected:
|
||||
virtual SqlConnection *CreateConnection();
|
||||
|
||||
protected:
|
||||
friend class OleDBConnection;
|
||||
|
||||
IRef<IDBInitialize> dbinit;
|
||||
IRef<IDBCreateCommand> dbsession;
|
||||
IRef<ITransactionLocal> transaction;
|
||||
IRef<ITransactionObject> transaction_object;
|
||||
Link<OleDBConnection> clink;
|
||||
Guid dialect;
|
||||
String user;
|
||||
int level;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif//__OLEDB_H__
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
description "OLEDB interface\377";
|
||||
|
||||
uses
|
||||
Ole,
|
||||
Sql;
|
||||
|
||||
link(MT DEBUG) /nodefaultlib:LIBCMT;
|
||||
|
||||
file
|
||||
OleDB.h,
|
||||
OleDBSchema.h,
|
||||
OleDB.cpp,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
#define BIT(x) COLUMN("bit", int, x, 0, 0)
|
||||
#define BIT_ARRAY(x, items) COLUMN_ARRAY("bit", int, x, 0, 0, items)
|
||||
#define BIT_(x) COLUMN_("bit", int, x, 0, 0)
|
||||
#define BIT_ARRAY_(x, items) COLUMN_ARRAY_("bit", int, x, 0, 0, items)
|
||||
|
||||
#define BOOL(x) COLUMN("bit", int, x, 0, 0)
|
||||
#define BOOL_ARRAY(x, items) COLUMN_ARRAY("bit", int, x, 0, 0, items)
|
||||
#define BOOL_(x) COLUMN_("bit", int, x, 0, 0)
|
||||
#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("bit", int, x, 0, 0, items)
|
||||
|
||||
#define INT(x) COLUMN("integer", int, x, 0, 0)
|
||||
#define INT_ARRAY(x, items) COLUMN_ARRAY("integer", int, x, 0, 0, items)
|
||||
#define INT_(x) COLUMN_("integer", int, x, 0, 0)
|
||||
#define INT_ARRAY_(x, items) COLUMN_ARRAY_("integer", int, x, 0, 0, items)
|
||||
|
||||
#define BIGINT(x) COLUMN("bigint", int64, x, 0, 0)
|
||||
#define BIGINT_ARRAY(x, items) COLUMN_ARRAY("bigint", int64, x, 0, 0, items)
|
||||
#define BIGINT_(x) COLUMN_("bigint", int64, x, 0, 0)
|
||||
#define BIGINT_ARRAY_(x, items) COLUMN_ARRAY_("bigint", int64, x, 0, 0, items)
|
||||
|
||||
#define DOUBLE(x) COLUMN("double precision", double, x, 0, 0)
|
||||
#define DOUBLE_ARRAY(x, items) COLUMN_ARRAY("double precision", double, x, 0, 0, items)
|
||||
#define DOUBLE_(x) COLUMN_("double precision", double, x, 0, 0)
|
||||
#define DOUBLE_ARRAY_(x, items) COLUMN_ARRAY_("double precision", double, x, 0, 0, items)
|
||||
|
||||
#define DATE(x) COLUMN("datetime", Date, x, 0, 0)
|
||||
#define DATE_ARRAY(x, items) COLUMN_ARRAY("datetime", Date, x, 0, 0, items)
|
||||
#define DATE_(x) COLUMN_("datetime", Date, x, 0, 0)
|
||||
#define DATE_ARRAY_(x, items) COLUMN_ARRAY_("datetime", Date, x, 0, 0, items)
|
||||
|
||||
#define TIME(x) COLUMN("datetime", Time, x, 0, 0)
|
||||
#define TIME_ARRAY(x, items) COLUMN_ARRAY("datetime", Time, x, 0, 0, items)
|
||||
#define TIME_(x) COLUMN_("datetime", Time, x, 0, 0)
|
||||
#define TIME_ARRAY_(x, items) COLUMN_ARRAY_("datetime", Time, x, 0, 0, items)
|
||||
|
||||
#define STRING(x, n) COLUMN(MSSQLTextType(n), String, x, n, 0)
|
||||
#define STRING_ARRAY(x, n, items) COLUMN_ARRAY(MSSQLTextType(n), String, x, n, 0, items)
|
||||
#define STRING_(x, n) COLUMN_(MSSQLTextType(n), String, x, n, 0)
|
||||
#define STRING_ARRAY_(x, n, items) COLUMN_ARRAY_(MSSQLTextType(n), String, x, n, 0, items)
|
||||
|
||||
#define LONGRAW(x) COLUMN("varbinary(max)", String, x, 0, 0)
|
||||
#define LONGRAW_(x) COLUMN_("varbinary(max)", String, x, 0, 0)
|
||||
|
||||
#ifndef PRIMARY_KEY
|
||||
#define PRIMARY_KEY INLINE_ATTRIBUTE("primary key")\
|
||||
ATTRIBUTE("alter table @t add constraint PK_@x primary key "\
|
||||
"(@c)",\
|
||||
"alter table @t drop constraint PK_@x;")\
|
||||
ATTRIBUTE("create index PKX_@x on @t(@c);", \
|
||||
"drop index PKX_@x;")
|
||||
#endif
|
||||
|
||||
#define KEY INLINE_ATTRIBUTE("key")
|
||||
#define NOT_NULL INLINE_ATTRIBUTE("not null")
|
||||
#define IDENTITY INLINE_ATTRIBUTE("identity")
|
||||
#define AUTO_INCREMENT INLINE_ATTRIBUTE("identity")
|
||||
|
||||
#define INDEX ATTRIBUTE("create index IDX_@x on @t(@c);", \
|
||||
"drop index IDX_@x;")
|
||||
#define UNIQUE ATTRIBUTE("create unique index UNQ_@x on @t(@c);", \
|
||||
"drop index UNQ_@x;")
|
||||
#define REFERENCES(x) ATTRIBUTE("alter table @t add constraint FK_@x foreign key "\
|
||||
"(@c) references @s" #x ";",\
|
||||
"alter table @t drop constraint FK_@x;")
|
||||
|
||||
#define TIMESTAMP(ts) SCHEMA("-- " ts "\n\n", NULL)
|
||||
|
||||
#define COMMENT(txt) SCHEMA("-- " #txt "\n", NULL)
|
||||
|
||||
#include <Sql/sch_model.h>
|
||||
|
||||
#undef INT
|
||||
#undef INT_ARRAY
|
||||
#undef INT_
|
||||
#undef INT_ARRAY_
|
||||
|
||||
#undef BIGINT
|
||||
#undef BIGINT_ARRAY
|
||||
#undef BIGINT_
|
||||
#undef BIGINT_ARRAY_
|
||||
|
||||
#undef DOUBLE
|
||||
#undef DOUBLE_ARRAY
|
||||
#undef DOUBLE_
|
||||
#undef DOUBLE_ARRAY_
|
||||
|
||||
#undef DATE
|
||||
#undef DATE_ARRAY
|
||||
#undef DATE_
|
||||
#undef DATE_ARRAY_
|
||||
|
||||
#undef TIME
|
||||
#undef TIME_ARRAY
|
||||
#undef TIME_
|
||||
#undef TIME_ARRAY_
|
||||
|
||||
#undef STRING
|
||||
#undef STRING_ARRAY
|
||||
#undef STRING_
|
||||
#undef STRING_ARRAY_
|
||||
|
||||
#undef PRIMARY_KEY
|
||||
#undef KEY
|
||||
#undef NOT_NULL
|
||||
#undef IDENTITY
|
||||
|
||||
#undef INDEX
|
||||
|
||||
#undef UNIQUE
|
||||
|
||||
#undef TIMESTAMP
|
||||
#undef COMMENT
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
#include <SqlCtrl/SqlCtrl.h>
|
||||
|
||||
#define HAVE_ORACLE
|
||||
|
||||
#ifndef flagNOSQLLITE
|
||||
#define HAVE_SQLLITE
|
||||
#include <plugin/sqlite3/Sqlite3.h>
|
||||
#endif
|
||||
|
||||
#ifndef flagNOMYSQL
|
||||
#define HAVE_MYSQL
|
||||
#endif
|
||||
|
||||
#ifndef flagNOPOSTGRESQL
|
||||
#define HAVE_POSTGRESQL
|
||||
#include <PostgreSQL/PostgreSQL.h>
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_WIN32) && defined(COMPILER_MSC)
|
||||
#define HAVE_OLEDB
|
||||
#include <OleDB/OleDB.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ORACLE
|
||||
#include <Oracle/Oracle7.h>
|
||||
#include <Oracle/Oracle8.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MYSQL
|
||||
#ifndef flagMT
|
||||
#error Must compile MySQL in multithreaded mode!
|
||||
#endif
|
||||
#include <MySql/MySql.h>
|
||||
#endif
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE <SqlCommander/login.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
class SqlCommanderApp {
|
||||
public:
|
||||
SqlCommanderApp();
|
||||
|
||||
void Run();
|
||||
void Serialize(Stream& s);
|
||||
|
||||
private:
|
||||
WithLoginLayout<TopWindow> login;
|
||||
enum SERVER_TYPE
|
||||
{
|
||||
SERVER_ORACLE,
|
||||
#ifdef HAVE_MYSQL
|
||||
SERVER_MYSQL
|
||||
#endif
|
||||
};
|
||||
One<SqlSession> session;
|
||||
};
|
||||
|
||||
SqlCommanderApp::SqlCommanderApp() {
|
||||
CtrlLayoutOKCancel(login, "Connect to server");
|
||||
login.password.Password();
|
||||
login.save_password = true;
|
||||
#ifdef HAVE_ORACLE
|
||||
login.connection.Add("OCI7");
|
||||
login.connection.Add("OCI8");
|
||||
#endif
|
||||
#ifdef HAVE_MYSQL
|
||||
login.connection.Add("MYSQL");
|
||||
#endif
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
login.connection.Add("POSTGRESQL");
|
||||
#endif
|
||||
#ifdef HAVE_SQLLITE
|
||||
login.connection.Add("SQLLITE");
|
||||
#endif
|
||||
#ifdef HAVE_OLEDB
|
||||
Array<OleDBSession::Provider> providers = OleDBSession::EnumProviders();
|
||||
for(int i = 0; i < providers.GetCount(); i++)
|
||||
login.connection.Add("OLEDB:" + providers[i].name);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SqlCommanderApp::Serialize(Stream& s) {
|
||||
int version = 3;
|
||||
s / version;
|
||||
if(version < 3)
|
||||
{
|
||||
s.SetError();
|
||||
return;
|
||||
}
|
||||
String pwd;
|
||||
if(s.IsStoring() && login.save_password)
|
||||
pwd = Garble(~login.password);
|
||||
s % login.username % login.database % login.server % login.connection % login.save_password % pwd;
|
||||
if(s.IsLoading() && login.save_password)
|
||||
login.password <<= Garble(pwd);
|
||||
}
|
||||
|
||||
void SqlCommanderApp::Run() {
|
||||
|
||||
LoadFromFile(*this);
|
||||
|
||||
do {
|
||||
if(login.Run() != IDOK) return;
|
||||
String un = ~login.username;
|
||||
String pw = ~login.password;
|
||||
String db = ~login.database;
|
||||
String sv = ~login.server;
|
||||
String co = ~login.connection;
|
||||
String connect = un;
|
||||
if(!pw.IsEmpty()) connect << '/' << pw;
|
||||
if(!sv.IsEmpty()) connect << '@' << sv;
|
||||
#ifdef HAVE_ORACLE
|
||||
if(co == "OCI7") {
|
||||
One<Oracle7> oci7 = new Oracle7;
|
||||
if(!oci7->Open(connect)) {
|
||||
Exclamation(NFormat("OCI7 login failed: [* \1%s\1].", oci7->GetLastError()));
|
||||
continue;
|
||||
}
|
||||
session = pick(oci7);
|
||||
}
|
||||
if(co == "OCI8") {
|
||||
One<Oracle8> oci8 = new Oracle8;
|
||||
if(!oci8->Open(connect, false)) {
|
||||
Exclamation(NFormat("OCI8 login failed: [* \1%s\1].", oci8->GetLastError()));
|
||||
continue;
|
||||
}
|
||||
session = pick(oci8);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_MYSQL
|
||||
if(co == "MYSQL") {
|
||||
One<MySqlSession> mysql = new MySqlSession;
|
||||
if(!mysql->Connect(un, pw, db, sv)) {
|
||||
Exclamation(NFormat("MySql login failed: [* \1%s\1].", mysql->GetLastError()));
|
||||
continue;
|
||||
}
|
||||
session = pick(mysql);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
if(co == "POSTGRESQL") {
|
||||
One<PostgreSQLSession> postgres = new PostgreSQLSession;
|
||||
String conninfo;
|
||||
conninfo << "user='" << un << "' password='" << pw << "' ";
|
||||
if(!IsNull(sv)) {
|
||||
String port;
|
||||
int f = sv.Find(':');
|
||||
if(f >= 0) {
|
||||
port = sv.Mid(f + 1);
|
||||
sv.Trim(f);
|
||||
}
|
||||
if(!IsNull(sv))
|
||||
conninfo << "host='" << sv << "' ";
|
||||
if(!IsNull(port))
|
||||
conninfo << "port=" << port << ' ';
|
||||
}
|
||||
if(!IsNull(db))
|
||||
conninfo << "dbname='" << db << "' ";
|
||||
postgres->Open(conninfo);
|
||||
session = pick(postgres);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SQLLITE
|
||||
if(co == "SQLLITE") {
|
||||
One<Sqlite3Session> sqlite = new Sqlite3Session;
|
||||
if(!sqlite->Open(db)) {
|
||||
Exclamation(NFormat("SQLite3 open failed, (db file = [* \1%s\1]): [* \1%s\1].", db, sqlite->GetLastError()));
|
||||
continue;
|
||||
}
|
||||
session = pick(sqlite);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_OLEDB
|
||||
if(!memcmp(co, "OLEDB:", 6)) {
|
||||
String conn = co.Mid(6);
|
||||
One<OleDBSession> oledb = new OleDBSession;
|
||||
if(!oledb->Open(un, pw, sv, conn)) {
|
||||
Exclamation(NFormat("OleDB login failed: [* \1%s\1].", oledb->GetLastError()));
|
||||
continue;
|
||||
}
|
||||
session = pick(oledb);
|
||||
}
|
||||
#endif
|
||||
if(!session)
|
||||
Exclamation(NFormat("Unsupported connection type: [* \1%s\1].", co));
|
||||
}
|
||||
while(!session);
|
||||
login.Close();
|
||||
SQLCommander(*session);
|
||||
StoreToFile(*this);
|
||||
}
|
||||
|
||||
#ifdef flagMAIN
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
SetLanguage(LNGC_('C', 'S', 'C', 'Z', CHARSET_WIN1250));
|
||||
SqlCommanderApp().Run();
|
||||
}
|
||||
#endif//flagMAIN
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
// SqlCommander.h : main header file for the SQLCOMMANDER application
|
||||
//
|
||||
|
||||
#if !defined(AFX_SQLCOMMANDER_H__CA1A67E7_56E3_11D3_A9AA_00C0DF48A075__INCLUDED_)
|
||||
#define AFX_SQLCOMMANDER_H__CA1A67E7_56E3_11D3_A9AA_00C0DF48A075__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSqlCommanderApp:
|
||||
// See SqlCommander.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_SQLCOMMANDER_H__CA1A67E7_56E3_11D3_A9AA_00C0DF48A075__INCLUDED_)
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
description "Simple SQL console utility\377";
|
||||
|
||||
uses
|
||||
SqlCtrl,
|
||||
Oracle,
|
||||
plugin\sqlite3,
|
||||
PostgreSQL;
|
||||
|
||||
uses(!NOMYSQL) MySql;
|
||||
|
||||
link(WIN32 DEBUG MSC) /NODEFAULTLIB:libcmt;
|
||||
|
||||
link(WIN32 !DEBUG MSC) /NODEFAULTLIB:libcmtd;
|
||||
|
||||
file
|
||||
SqlCommander.cpp,
|
||||
login.lay,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
mainconfig
|
||||
"" = ".NOMYSQL GUI .NOAPPSQL",
|
||||
"" = "GUI MT .NOAPPSQL",
|
||||
"" = ".NOMYSQL GUI .NOAPPSQL .NOPOSTGRESQL";
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// SqlCommander.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
LAYOUT(LoginLayout, 398, 106)
|
||||
ITEM(Label, dv___0, SetLabel(t_("&User name:")).LeftPosZ(4, 62).TopPosZ(4, 19))
|
||||
ITEM(EditField, username, LeftPosZ(68, 120).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___2, SetLabel(t_("&Password:")).LeftPosZ(4, 62).TopPosZ(26, 19))
|
||||
ITEM(EditField, password, LeftPosZ(68, 120).TopPosZ(26, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("&Database:")).LeftPosZ(208, 62).TopPosZ(4, 19))
|
||||
ITEM(EditField, database, LeftPosZ(274, 120).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___6, SetLabel(t_("&Server:")).LeftPosZ(208, 62).TopPosZ(26, 19))
|
||||
ITEM(EditField, server, LeftPosZ(274, 120).TopPosZ(26, 19))
|
||||
ITEM(Label, dv___8, SetLabel(t_("&Connection:")).LeftPosZ(4, 62).TopPosZ(48, 19))
|
||||
ITEM(DropList, connection, HSizePosZ(68, 4).TopPosZ(48, 19))
|
||||
ITEM(Option, save_password, SetLabel(t_("S&ave password (unsafe!)")).LeftPosZ(8, 140).TopPosZ(82, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(88, 80).BottomPosZ(5, 21))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22))
|
||||
END_LAYOUT
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
acceptflags
|
||||
NOHELP;
|
||||
|
||||
file
|
||||
Calc.h,
|
||||
CalcType.h,
|
||||
CalcType.cpp,
|
||||
CalcNode.h,
|
||||
CalcNode.cpp,
|
||||
CalcNode.lng,
|
||||
CalcBasic.cpp,
|
||||
CalcBasic.lng;
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef __TCore_CalcBasic__
|
||||
#define __TCore_CalcBasic__
|
||||
|
||||
namespace Upp {
|
||||
|
||||
String GroupComp();
|
||||
String GroupBitOp();
|
||||
String GroupArith();
|
||||
String GroupLog();
|
||||
String GroupString();
|
||||
String GroupDate();
|
||||
String GroupArray();
|
||||
String GroupConst();
|
||||
String GroupTrans();
|
||||
String GroupSystem();
|
||||
|
||||
}
|
||||
|
||||
#endif//__TCore_CalcBasic__
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,727 +0,0 @@
|
|||
namespace Upp {
|
||||
|
||||
struct CalcPacket;
|
||||
class CalcNode;
|
||||
class CalcContext;
|
||||
|
||||
typedef RefPtr<CalcNode> CalcNodePtr;
|
||||
|
||||
class CalcNode : public RefBase
|
||||
{
|
||||
public:
|
||||
CalcNode(String name = Null, pick_ Vector<CalcNodePtr> args = Vector<CalcNodePtr>()) : name(name), args(args) {}
|
||||
CalcNode(String name, const Vector<CalcNodePtr>& args, int deep) : name(name), args(args, 0) {}
|
||||
CalcNode(String name, CalcNodePtr arg) : name(name) { args.SetCount(1); args[0] = arg; }
|
||||
CalcNode(String name, CalcNodePtr arg1, CalcNodePtr arg2) : name(name) { args.SetCount(2); args[0] = arg1; args[1] = arg2; }
|
||||
CalcNode(const CalcNode& node) : name(node.name), args(node.args, 0) {}
|
||||
virtual ~CalcNode();
|
||||
|
||||
virtual Value Calc(CalcContext& context) const = 0;
|
||||
virtual CalcNodePtr Clone() const { return CalcNodePtr(); }
|
||||
virtual String Format() const { return Null; }
|
||||
virtual bool IsConst() const { return false; }
|
||||
virtual CalcNodePtr Optimize(CalcContext& context) { return this; }
|
||||
|
||||
Value TryCalc(CalcContext& context) const; // catches Exc to return ErrorValue
|
||||
|
||||
double CalcDouble(CalcContext& context) const;
|
||||
String CalcString(CalcContext& context) const;
|
||||
int CalcInt(CalcContext& context) const;
|
||||
int64 CalcInt64(CalcContext& context) const;
|
||||
Date CalcDate(CalcContext& context) const;
|
||||
Time CalcTime(CalcContext& context) const;
|
||||
bool CalcBool(CalcContext& context) const;
|
||||
|
||||
String GetName() const { return name; }
|
||||
|
||||
public:
|
||||
String name;
|
||||
Vector<CalcNodePtr> args;
|
||||
|
||||
protected:
|
||||
void Expect(const char *s, String found) const; // throws Exc
|
||||
|
||||
};
|
||||
|
||||
class CalcConstNode : public CalcNode {
|
||||
public:
|
||||
CalcConstNode(Value value) : CalcNode("(const)"), value(value) {}
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcConstNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
virtual bool IsConst() const { return true; }
|
||||
|
||||
public:
|
||||
Value value;
|
||||
};
|
||||
|
||||
class CalcLambdaNode : public CalcNode {
|
||||
public:
|
||||
CalcLambdaNode(CalcNodePtr arg) : CalcNode("#", arg) {}
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcLambdaNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
};
|
||||
|
||||
class CalcLogOrNode : public CalcNode {
|
||||
public:
|
||||
CalcLogOrNode(CalcNodePtr left, CalcNodePtr right) : CalcNode("||", left, right) {}
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcLogOrNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
virtual CalcNodePtr Optimize(CalcContext& context);
|
||||
};
|
||||
|
||||
class CalcLogAndNode : public CalcNode {
|
||||
public:
|
||||
CalcLogAndNode(CalcNodePtr left, CalcNodePtr right) : CalcNode("&&", left, right) {}
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcLogAndNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
virtual CalcNodePtr Optimize(CalcContext& context);
|
||||
};
|
||||
|
||||
class CalcSelectNode : public CalcNode {
|
||||
public:
|
||||
CalcSelectNode(CalcNodePtr cond, CalcNodePtr left, CalcNodePtr right)
|
||||
: CalcNode("?:") { args.SetCount(3); args[0] = cond; args[1] = left; args[2] = right; }
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcSelectNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
virtual CalcNodePtr Optimize(CalcContext& context);
|
||||
enum { COND, IFTRUE, IFFALSE };
|
||||
};
|
||||
|
||||
class CalcSwitchNode : public CalcNode {
|
||||
public:
|
||||
CalcSwitchNode(CalcNodePtr cond, pick_ Vector<CalcNodePtr>& list) : CalcNode("{}")
|
||||
{ args.Reserve(list.GetCount() + 1); args.Add(cond); args.AppendPick(list); }
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcSwitchNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
virtual CalcNodePtr Optimize(CalcContext& context);
|
||||
};
|
||||
|
||||
class CalcSequenceNode : public CalcNode {
|
||||
public:
|
||||
CalcSequenceNode(pick_ Vector<CalcNodePtr> nodes);
|
||||
CalcSequenceNode(CalcNodePtr node1, CalcNodePtr node2);
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcSequenceNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
virtual CalcNodePtr Optimize(CalcContext& context);
|
||||
};
|
||||
|
||||
class CalcFunctionNode : public CalcNode {
|
||||
public:
|
||||
CalcFunctionNode(String name) : CalcNode(name) {}
|
||||
CalcFunctionNode(String name, CalcNodePtr arg) : CalcNode(name, arg) {}
|
||||
CalcFunctionNode(String name, CalcNodePtr arg1, CalcNodePtr arg2) : CalcNode(name, arg1, arg2) {}
|
||||
CalcFunctionNode(String name, pick_ Vector<CalcNodePtr>& args) : CalcNode(name, args) {}
|
||||
CalcFunctionNode(String name, const Vector<CalcNodePtr>& args, int deep) : CalcNode(name, args, 0) {}
|
||||
|
||||
void ScanArgs(CalcPacket& packet) const;
|
||||
|
||||
virtual CalcNodePtr Clone() const { return new CalcFunctionNode(*this); }
|
||||
virtual Value Calc(CalcContext& context) const;
|
||||
virtual String Format() const;
|
||||
};
|
||||
|
||||
void RunDlgCalc(CalcContext& context);
|
||||
|
||||
CalcNodePtr GetVariableNode(String varname);
|
||||
CalcNodePtr GetFunctionNode(String fnname, pick_ Vector<CalcNodePtr>& args);
|
||||
|
||||
inline bool IsIdent(byte c)
|
||||
{
|
||||
return IsAlNum(c) || c == '_' || c == '$' || c == '@';
|
||||
}
|
||||
|
||||
int CharFilterCalcIdent(int c);
|
||||
int CharFilterCalcUpperIdent(int c);
|
||||
|
||||
struct CalcPacket
|
||||
{
|
||||
CalcPacket(CalcContext& context, const String& name) : context(context), name(name)
|
||||
, help(false)
|
||||
{}
|
||||
|
||||
String GetTypeNames() const;
|
||||
|
||||
CalcContext& context;
|
||||
String name;
|
||||
Vector<Value> args;
|
||||
Value result;
|
||||
bool help;
|
||||
};
|
||||
|
||||
typedef bool (*CalcProc)(CalcPacket& packet);
|
||||
typedef VectorMap<String, CalcProc> CalcProcMap;
|
||||
|
||||
typedef Gate1<CalcPacket&> CalcGate;
|
||||
typedef VectorMap<String, CalcGate> CalcGateMap;
|
||||
|
||||
class HelpCalc
|
||||
{
|
||||
public:
|
||||
HelpCalc(CalcGate proc, const char *ident, const char *topic, String (*groupfn)(), const char *function);
|
||||
|
||||
class Compare
|
||||
{
|
||||
public:
|
||||
enum MODE { ALPHABETIC, GROUPS };
|
||||
Compare(MODE mode = ALPHABETIC) : mode(mode), lang(GetLanguageInfo()) {}
|
||||
|
||||
bool operator () (const HelpCalc *a, const HelpCalc *b) const;
|
||||
|
||||
private:
|
||||
MODE mode;
|
||||
const LanguageInfo& lang;
|
||||
};
|
||||
|
||||
String GetTitle() const;
|
||||
|
||||
public:
|
||||
// int ord;
|
||||
CalcGate proc;
|
||||
String (*groupfn)();
|
||||
String ident;
|
||||
String topic;
|
||||
String function;
|
||||
|
||||
private:
|
||||
void Init(CalcGate proc, const char *ident, const char *topic, String (*groupfn)(), const char *function);
|
||||
};
|
||||
|
||||
typedef Vector<const HelpCalc *> HelpCalcMap;
|
||||
|
||||
HelpCalcMap& GetHelpCalcMap();
|
||||
void AddHelpCalc(const HelpCalc& calc);
|
||||
Vector<String> GetHelpCalcGroups();
|
||||
|
||||
/*
|
||||
class HelpCalcIndex
|
||||
{
|
||||
public:
|
||||
typedef VectorMap<String, const HelpCalc *> IdMap;
|
||||
|
||||
static HelpCalcIndex& Get();
|
||||
|
||||
int Add(const HelpCalc& calc) { index.Add(calc.ident, &calc); return index.GetCount(); }
|
||||
|
||||
void PutSummary() const;
|
||||
void PutGroups() const;
|
||||
void AddIndexEntries() const; // adds entries to dynamic index
|
||||
|
||||
const IdMap& GetIndex() const { return index; }
|
||||
|
||||
private:
|
||||
IdMap index;
|
||||
|
||||
private:
|
||||
HelpCalcIndex();
|
||||
};
|
||||
*/
|
||||
|
||||
String HelpCalcLink(const char *id, const char *ref = " (viz str._#)", bool bold = true);
|
||||
|
||||
class CalcSymbols : Moveable<CalcSymbols>, DeepCopyOption<CalcSymbols>
|
||||
{
|
||||
public:
|
||||
CalcSymbols() {}
|
||||
CalcSymbols(const CalcSymbols& l, int deep)
|
||||
: var_index(l.var_index, 0)
|
||||
, var_value(l.var_value, 0)
|
||||
, var_const(l.var_const, 0)
|
||||
, functions(l.functions, 0) {}
|
||||
|
||||
void Clear();
|
||||
void Add(String name, CalcGate proc) { functions.Add(name, proc); }
|
||||
void Set(String name, Value v, bool c) { int i = var_index.FindAdd(name); var_value.DoIndex(i) = v; var_const.DoIndex(i) = c; }
|
||||
void Remove(String name);
|
||||
|
||||
Index<String> var_index;
|
||||
Vector<Value> var_value;
|
||||
Vector<bool> var_const;
|
||||
CalcGateMap functions;
|
||||
};
|
||||
|
||||
class CalcSymbolsLevel : public CalcSymbols
|
||||
{
|
||||
public:
|
||||
CalcSymbolsLevel(Vector<CalcSymbols *>& owner) : owner(owner) { owner.Add(this); }
|
||||
~CalcSymbolsLevel() { owner.Drop(); }
|
||||
|
||||
private:
|
||||
Vector<CalcSymbols *>& owner;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CalcLocalItem;
|
||||
|
||||
template <class T>
|
||||
class CalcLocalMap
|
||||
{
|
||||
public:
|
||||
CalcLocalMap() : head(0), tail(0) {}
|
||||
|
||||
void Add(CalcLocalItem<T> *item);
|
||||
void Set(T *this_ptr, CalcSymbols& map);
|
||||
void Set(T *this_ptr) { Set(this_ptr, this_ptr -> stack.Top()); }
|
||||
|
||||
private:
|
||||
CalcLocalItem<T> *head, *tail;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CalcLocalItem
|
||||
{
|
||||
public:
|
||||
CalcLocalItem(CalcLocalMap<T>& map, const String& name, bool (T::*method)(CalcPacket&));
|
||||
|
||||
String name;
|
||||
bool (T::*method)(CalcPacket&);
|
||||
CalcLocalItem<T> *next;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
CalcLocalItem<T>::CalcLocalItem(CalcLocalMap<T>& map, const String& name, bool (T::*method)(CalcPacket&))
|
||||
: next(0)
|
||||
, name(name)
|
||||
, method(method)
|
||||
{
|
||||
map.Add(this);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CalcLocalMap<T>::Add(CalcLocalItem<T> *item)
|
||||
{
|
||||
if(head == 0)
|
||||
head = tail = item;
|
||||
else
|
||||
tail = tail -> next = item;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CalcLocalMap<T>::Set(T *this_ptr, CalcSymbols& map)
|
||||
{
|
||||
for(CalcLocalItem<T> *p = head; p; p = p -> next)
|
||||
map.functions.Add(p -> name, callback(this_ptr, p -> method));
|
||||
}
|
||||
|
||||
#define DECLARE_LOCAL_MAP() static CalcLocalMap<CLASSNAME>& GetLocalMap();
|
||||
#define IMPLEMENT_LOCAL_MAP() GLOBAL_VAR(CalcLocalMap<BASECLASS>, BASECLASS::GetLocalMap)
|
||||
|
||||
class CalcContext : Moveable<CalcContext>, DeepCopyOption<CalcContext>
|
||||
{
|
||||
public:
|
||||
typedef CalcContext CLASSNAME;
|
||||
|
||||
class Nesting
|
||||
{
|
||||
public:
|
||||
Nesting(CalcContext& context) : context(context) { context.PushLevel(); }
|
||||
~Nesting() { context.PopLevel(); }
|
||||
|
||||
private:
|
||||
CalcContext& context;
|
||||
};
|
||||
|
||||
class Global {
|
||||
public:
|
||||
Global(const String& name, CalcProc proc);
|
||||
};
|
||||
|
||||
CalcContext();
|
||||
CalcContext(const CalcContext& context, int);
|
||||
virtual ~CalcContext();
|
||||
|
||||
Value TryEvaluate(String expr);
|
||||
|
||||
Value Evaluate(String expr);
|
||||
double EvaluateDouble(String expr);
|
||||
String EvaluateString(String expr);
|
||||
int EvaluateInt(String expr);
|
||||
int64 EvaluateInt64(String expr);
|
||||
Date EvaluateDate(String expr);
|
||||
Time EvaluateTime(String expr);
|
||||
bool EvaluateBool(String expr, bool null_value = false);
|
||||
|
||||
String OptimizeConstant(String expr);
|
||||
CalcNodePtr OptimizeConstant(CalcNodePtr src);
|
||||
|
||||
String Convert(String s, bool throw_errors, const class Convert& convert = NoConvert());
|
||||
static void ParseConvert(String s, Vector<String>& sparts, Vector<String>& cparts);
|
||||
static void ParseConvert(String s, Vector<String>& sparts, Vector<CalcNodePtr>& cparts, bool throw_errors);
|
||||
String CalcConvert(const Vector<String>& sparts, const Vector<CalcNodePtr>& cparts, bool throw_errors, const UPP::Convert& convert = NoConvert());
|
||||
|
||||
virtual Value Calc(CalcPacket& packet);
|
||||
virtual Value TryCalc(CalcPacket& packet);
|
||||
virtual String GetTypeName(Value value) const;
|
||||
virtual String FormatNull(Value value, bool no_text = false);
|
||||
virtual String FormatText(Value value, const UPP::Convert& convert = NoConvert());
|
||||
|
||||
virtual void PushLevel();
|
||||
virtual void PopLevel();
|
||||
|
||||
CalcContext& Add(String name, CalcGate proc) { stack.Top().Add(name, proc); return *this; }
|
||||
CalcContext& Set(String name, Value v, bool c = false) { stack.Top().Set(name, v, c); return *this; }
|
||||
CalcContext& Remove(String name) { stack.Top().Remove(name); return *this; }
|
||||
Value Get(String name) const;
|
||||
|
||||
void AddExternal(CalcSymbols& e) { externals.Add(&e); }
|
||||
void AddExternal(const Vector<CalcSymbols *>& ext) { externals.Append(ext); }
|
||||
void RemoveExternal(CalcSymbols& e);
|
||||
|
||||
static CalcProcMap& GetGlobals();
|
||||
|
||||
public:
|
||||
enum { MAX_STACK_DEPTH = 1000 };
|
||||
|
||||
int language;
|
||||
int nesting;
|
||||
bool opt_const;
|
||||
Array<CalcSymbols> stack;
|
||||
Vector<CalcSymbols *> externals;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<const CalcNode *> : public CalcRawType<const CalcNode *>
|
||||
{
|
||||
static Value ToValue(const CalcNode *cn) { return cn ? RawValue<const CalcNode *>(cn) : Value(); }
|
||||
static const CalcNode *ValueTo(Value v) { return IsType(v) ? RawValue<const CalcNode *>::Extract(v) : 0; }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<CalcNodePtr> : public CalcRawType<CalcNodePtr>
|
||||
{
|
||||
static Value ToValue(CalcNodePtr cn) { return !!cn ? RawToValue(cn) : Value(); }
|
||||
static CalcNodePtr ValueTo(Value v) { return IsTypeRaw<CalcNodePtr>(v) ? UPP::ValueTo<CalcNodePtr>(v) : NULL; }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
class CalcParser
|
||||
{
|
||||
public:
|
||||
CalcParser(bool sql_style = false);
|
||||
|
||||
virtual CalcNodePtr Scan(const char *text);
|
||||
virtual CalcNodePtr ScanVoid(const char *text);
|
||||
|
||||
protected:
|
||||
virtual CalcNodePtr ScanAny();
|
||||
// virtual CalcNodePtr ScanLambda();
|
||||
virtual CalcNodePtr ScanSequence();
|
||||
virtual CalcNodePtr ScanSelect();
|
||||
virtual CalcNodePtr ScanLogOr();
|
||||
virtual CalcNodePtr ScanLogAnd();
|
||||
virtual CalcNodePtr ScanEq();
|
||||
virtual CalcNodePtr ScanCompare();
|
||||
virtual CalcNodePtr ScanBitXor();
|
||||
virtual CalcNodePtr ScanBitAnd();
|
||||
virtual CalcNodePtr ScanBitOr();
|
||||
virtual CalcNodePtr ScanAdditive();
|
||||
virtual CalcNodePtr ScanShift();
|
||||
virtual CalcNodePtr ScanMultiplicative();
|
||||
virtual CalcNodePtr ScanPow();
|
||||
virtual CalcNodePtr ScanPrefix();
|
||||
virtual CalcNodePtr ScanPostfix(CalcNodePtr node);
|
||||
virtual void ScanArgs(Vector<CalcNodePtr>& dest);
|
||||
|
||||
void Clear(const char *t);
|
||||
|
||||
int Skip();
|
||||
bool Expect(const String& s);
|
||||
|
||||
String GetIdent();
|
||||
Value GetNumberOrDate();
|
||||
String GetString();
|
||||
String GetSqlString();
|
||||
|
||||
enum OPERATOR
|
||||
{
|
||||
OP_NONE,
|
||||
OP_QUESTION, OP_COLON, OP_SEMICOLON,
|
||||
OP_LOG_AND, OP_LOG_OR,
|
||||
OP_LT, OP_LE, OP_GE, OP_GT,
|
||||
OP_EQ, OP_NE,
|
||||
OP_BIT_AND, OP_BIT_OR, OP_BIT_XOR,
|
||||
OP_LSHIFT, OP_RSHIFT,
|
||||
OP_ADD, OP_SUB,
|
||||
OP_MUL, OP_DIV, OP_MOD,
|
||||
OP_POW,
|
||||
OP_LOG_NOT, OP_BIT_NOT,
|
||||
OP_LAMBDA,
|
||||
OP_LPAR, OP_RPAR,
|
||||
OP_LBRACKET, OP_RBRACKET,
|
||||
OP_LBRACE, OP_RBRACE,
|
||||
OP_COMMA,
|
||||
OP_DOT, OP_DOTS,
|
||||
OP_SQL_BETWEEN, OP_SQL_IN, OP_SQL_LIKE,
|
||||
OP_SQL_IS, OP_SQL_NOT, OP_SQL_NULL,
|
||||
|
||||
OP_LAST,
|
||||
};
|
||||
|
||||
virtual int GetOperator();
|
||||
int SkipOperator();
|
||||
bool Check(int op);
|
||||
bool Force(int op, const char *expect);
|
||||
|
||||
protected:
|
||||
bool sql_style;
|
||||
|
||||
const char *start;
|
||||
const char *pos;
|
||||
|
||||
int op_last;
|
||||
const char *op_begin;
|
||||
const char *op_end;
|
||||
};
|
||||
|
||||
template <class BTA, class R>
|
||||
inline bool CalcCast(CalcPacket& packet, R (*fn)(), BTA * = 0)
|
||||
{
|
||||
if(packet.help)
|
||||
{ // generate help info
|
||||
packet.result = CalcType<R>::Describe();
|
||||
return true;
|
||||
}
|
||||
if(packet.args.GetCount() != 0)
|
||||
return false;
|
||||
packet.result = CalcType<R>::ToValue(fn());
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BTA, class R>
|
||||
inline bool CalcCastPacket(CalcPacket& packet, R (*fn)(CalcPacket& packet), BTA * = 0)
|
||||
{
|
||||
if(packet.help)
|
||||
{ // generate help info
|
||||
packet.result = CalcType<R>::Describe();
|
||||
return true;
|
||||
}
|
||||
if(packet.args.GetCount() != 0)
|
||||
return false;
|
||||
packet.result = CalcType<R>::ToValue(fn(packet));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BTA, class O, class M, class R>
|
||||
inline bool CalcCastMember(CalcPacket& packet, O *clss, R (M::*fn)(), BTA * = 0)
|
||||
{
|
||||
if(packet.help) { // generate help info
|
||||
packet.result = CalcType<R>::Describe();
|
||||
return true;
|
||||
}
|
||||
if(packet.args.GetCount() != 0)
|
||||
return false;
|
||||
packet.result = CalcType<R>::ToValue((clss ->* fn)());
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BTA, class O, class M, class R>
|
||||
inline bool CalcCastMemberPacket(CalcPacket& packet, O *clss, R (M::*fn)(), BTA * = 0)
|
||||
{
|
||||
if(packet.help) { // generate help info
|
||||
packet.result = CalcType<R>::Describe();
|
||||
return true;
|
||||
}
|
||||
if(packet.args.GetCount() != 0)
|
||||
return false;
|
||||
packet.result = CalcType<R>::ToValue((clss ->* fn)(packet));
|
||||
return true;
|
||||
}
|
||||
|
||||
struct BTA0 { enum { NIL = 0 }; };
|
||||
struct BTA1 { enum { NIL = 1 }; };
|
||||
|
||||
#define E__Class(I) class C##I
|
||||
#define E__Arg(I) C##I
|
||||
#define E__Descr(I) packet.args.Add(CalcType<C##I>::Describe())
|
||||
#define E__ChkArg(I) \
|
||||
if(BTA::NIL && IsNull(packet.args[I - 1])) \
|
||||
null = true; \
|
||||
else if(!CalcType<C##I>::IsType(packet.args[I - 1])) \
|
||||
return false;
|
||||
#define E__CvArg(I) CalcType<C##I>::ValueTo(packet.args[I - 1])
|
||||
|
||||
#define CalcCastTemplate(NM, I) \
|
||||
template <class BTA, class R, __List##I(E__Class)> \
|
||||
inline bool NM(CalcPacket& packet, R (*fn)(CP_ARG_PREFIX __List##I(E__Arg)), BTA * = 0) \
|
||||
{ \
|
||||
if(packet.help) \
|
||||
{ \
|
||||
packet.result = CalcType<R>::Describe(); \
|
||||
__List##I(E__Descr); \
|
||||
return true; \
|
||||
} \
|
||||
if(packet.args.GetCount() != I) \
|
||||
return false; \
|
||||
bool null = false; \
|
||||
__Expand##I(E__ChkArg) \
|
||||
if(BTA::NIL && null) \
|
||||
{ \
|
||||
packet.result = Value(); \
|
||||
return true; \
|
||||
} \
|
||||
packet.result = CalcType<R>::ToValue(fn(CP_PREFIX \
|
||||
__List##I(E__CvArg))); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
#define CalcCastMemberTemplate(NM, I) \
|
||||
template <class BTA, class O, class M, class R, __List##I(E__Class)> \
|
||||
inline bool NM(CalcPacket& packet, O *clss, R (M::*fn)(CP_ARG_PREFIX __List##I(E__Arg)), BTA * = 0) \
|
||||
{ \
|
||||
if(packet.help) { \
|
||||
packet.result = CalcType<R>::Describe(); \
|
||||
__List##I(E__Descr); \
|
||||
return true; \
|
||||
} \
|
||||
if(packet.args.GetCount() != I) \
|
||||
return false; \
|
||||
bool null = false; \
|
||||
__Expand##I(E__ChkArg) \
|
||||
if(BTA::NIL && null) { \
|
||||
packet.result = Value(); \
|
||||
return true; \
|
||||
} \
|
||||
packet.result = CalcType<R>::ToValue((clss ->* fn)(CP_PREFIX \
|
||||
__List##I(E__CvArg))); \
|
||||
return true; \
|
||||
} \
|
||||
|
||||
#define CP_ARG_PREFIX
|
||||
#define CP_PREFIX
|
||||
|
||||
CalcCastTemplate(CalcCast, 1)
|
||||
CalcCastTemplate(CalcCast, 2)
|
||||
CalcCastTemplate(CalcCast, 3)
|
||||
CalcCastTemplate(CalcCast, 4)
|
||||
CalcCastTemplate(CalcCast, 5)
|
||||
CalcCastTemplate(CalcCast, 6)
|
||||
|
||||
CalcCastMemberTemplate(CalcCastMember, 1)
|
||||
CalcCastMemberTemplate(CalcCastMember, 2)
|
||||
CalcCastMemberTemplate(CalcCastMember, 3)
|
||||
CalcCastMemberTemplate(CalcCastMember, 4)
|
||||
CalcCastMemberTemplate(CalcCastMember, 5)
|
||||
CalcCastMemberTemplate(CalcCastMember, 6)
|
||||
|
||||
#undef CP_ARG_PREFIX
|
||||
#undef CP_PREFIX
|
||||
|
||||
#define CP_ARG_PREFIX CalcPacket& packet,
|
||||
#define CP_PREFIX packet,
|
||||
|
||||
CalcCastTemplate(CalcCastPacket, 1)
|
||||
CalcCastTemplate(CalcCastPacket, 2)
|
||||
CalcCastTemplate(CalcCastPacket, 3)
|
||||
CalcCastTemplate(CalcCastPacket, 4)
|
||||
CalcCastTemplate(CalcCastPacket, 5)
|
||||
CalcCastTemplate(CalcCastPacket, 6)
|
||||
|
||||
CalcCastMemberTemplate(CalcCastMemberPacket, 1)
|
||||
CalcCastMemberTemplate(CalcCastMemberPacket, 2)
|
||||
CalcCastMemberTemplate(CalcCastMemberPacket, 3)
|
||||
CalcCastMemberTemplate(CalcCastMemberPacket, 4)
|
||||
CalcCastMemberTemplate(CalcCastMemberPacket, 5)
|
||||
CalcCastMemberTemplate(CalcCastMemberPacket, 6)
|
||||
|
||||
#undef CP_ARG_PREFIX
|
||||
#undef CP_PREFIX
|
||||
|
||||
#define FGENID2(tag, lnum) __##tag##lnum##__
|
||||
#define FGENID1(tag, lnum) FGENID2(tag, lnum)
|
||||
#define FGENID(a, b) COMBINE(COMBINE(a, b), __LINE__)
|
||||
|
||||
#define SUBEXPAND(M) M
|
||||
|
||||
#ifndef NOHELP
|
||||
#define FDECLTH(tag, topic, id, group, proc) \
|
||||
static GLOBAL_VARP(HelpCalc, FGENID(chlp, tag), (callback(proc), id, "Calc$" topic, group, ASSTRING(proc))); \
|
||||
INITBLOCK_(FGENID(hblk, tag)) { FGENID(chlp, tag)(); } \
|
||||
static void FGENID(chlt, tag)(String& out) { out.Cat(FGENID(chlp, tag)().GetTitle()); } \
|
||||
RegisterHelpTopicInfoTag(COMBINE(tag, __LINE__), "Calc$" topic, __FILE__, callback(&FGENID(chlt, tag)), CNULL)
|
||||
#else//NOHELP
|
||||
#define FDECLTH(tag, topic, id, group, proc)
|
||||
#endif//NOHELP
|
||||
|
||||
#define FDECLT(null, tag, topic, id, group, call) \
|
||||
static bool FGENID(proc, tag)(CalcPacket& packet) { return CalcCast<null>(packet, call); } \
|
||||
INITBLOCK_(FGENID(gblk, tag)) { static CalcContext::Global FGENID(init, tag)(id, &FGENID(proc, tag)); } \
|
||||
FDECLTH(tag, topic, id, group, &FGENID(proc, tag))
|
||||
|
||||
#define FDECLTA(null, tag, topic, id, group, call) \
|
||||
static bool FGENID(proc, tag)(CalcPacket& packet) { return CalcCastPacket<null>(packet, call); } \
|
||||
INITBLOCK_(FGENID(gblk, tag)) { static CalcContext::Global FGENID(init, tag)(id, &FGENID(proc, tag)); } \
|
||||
FDECLTH(tag, topic, id, group, &FGENID(proc, tag))
|
||||
|
||||
#define FDECLQ(topic, id, group, gate) \
|
||||
INITBLOCK_(FGENID(gblk, tag)) { static CalcContext::Global FGENID(init, dflt)(id, gate); } \
|
||||
FDECLTH(dflt, topic, id, group, gate)
|
||||
|
||||
#define FDECL(id, call, group) FDECLT(BTA0, dflt, ASSTRING(call), id, group, call)
|
||||
#define FDECLX(id, group) FDECLT(BTA0, id, ASSTRING(id), ASSTRING(id), group, id)
|
||||
#define FDECLP(id, x, group) FDECLT(BTA0, id, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
|
||||
#define FDECL0(id, call, group) FDECLT(BTA1, dflt, ASSTRING(call), id, group, call)
|
||||
#define FDECLX0(id, group) FDECLT(BTA1, id, ASSTRING(id), ASSTRING(id), group, id)
|
||||
#define FDECLP0(id, x, group) FDECLT(BTA1, id, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
|
||||
#define FDECLA(id, call, group) FDECLTA(BTA0, dflt, ASSTRING(call), id, group, call)
|
||||
#define FDECLAX(id, group) FDECLTA(BTA0, id, ASSTRING(id), ASSTRING(id), group, id)
|
||||
#define FDECLAP(id, x, group) FDECLTA(BTA0, id, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
|
||||
#define FDECLA0(id, call, group) FDECLTA(BTA1, dflt, ASSTRING(call), id, group, call)
|
||||
#define FDECLAX0(id, group) FDECLTA(BTA1, id, ASSTRING(id), ASSTRING(id), group, id)
|
||||
#define FDECLAP0(id, x, group) FDECLTA(BTA1, id, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
|
||||
#define MDECLT(null, topic, id, group, call) \
|
||||
struct FGENID(clcp, SUBEXPAND(MFILEID)) : public BASECLASS \
|
||||
{ FGENID(clcp, SUBEXPAND(MFILEID))(); bool CalcIt(CalcPacket& packet) { return CalcCastMember<null>(packet, this, &BASECLASS::call); } }; \
|
||||
static GLOBAL_VARP(HelpCalc, FGENID(chlp, SUBEXPAND(MFILEID)), (callback(static_cast<BASECLASS *>(0), \
|
||||
brutal_cast<bool (BASECLASS::*)(CalcPacket&)>(&FGENID(clcp, SUBEXPAND(MFILEID))::CalcIt)), \
|
||||
id, "Calc$" topic, group, ASSTRING(call))); \
|
||||
INITBLOCK_(FGENID(mblk, tag)) { \
|
||||
FGENID(chlp, SUBEXPAND(MFILEID))(); \
|
||||
static CalcLocalItem<BASECLASS> FGENID(clci, SUBEXPAND(MFILEID))(BASECLASS::GetLocalMap(), id, \
|
||||
brutal_cast<bool (BASECLASS::*)(CalcPacket&)>(&FGENID(clcp, SUBEXPAND(MFILEID))::CalcIt)); \
|
||||
} \
|
||||
static void FGENID(chlt, SUBEXPAND(MFILEID))(String& out) { out.Cat(FGENID(chlp, SUBEXPAND(MFILEID))().GetTitle()); } \
|
||||
RegisterHelpTopicInfo("Calc$" topic, __FILE__, callback(&FGENID(chlt, SUBEXPAND(MFILEID))), CNULL)
|
||||
|
||||
#define MDECLTA(null, topic, id, group, call) \
|
||||
struct FGENID(clcp, SUBEXPAND(MFILEID)) : public BASECLASS \
|
||||
{ FGENID(clcp, SUBEXPAND(MFILEID))(); bool CalcIt(CalcPacket& packet) { return CalcCastMemberPacket<null>(packet, this, &BASECLASS::call); } }; \
|
||||
static GLOBAL_VARP(HelpCalc, FGENID(chlp, SUBEXPAND(MFILEID)), (callback(static_cast<BASECLASS *>(0), \
|
||||
brutal_cast<bool (BASECLASS::*)(CalcPacket&)>(&FGENID(clcp, SUBEXPAND(MFILEID))::CalcIt)), \
|
||||
id, "Calc$" topic, group, ASSTRING(call))); \
|
||||
INITBLOCK_(FGENID(mblk, tag)) { \
|
||||
FGENID(chlp, SUBEXPAND(MFILEID))(); \
|
||||
static CalcLocalItem<BASECLASS> FGENID(clci, SUBEXPAND(MFILEID))(BASECLASS::GetLocalMap(), id, \
|
||||
brutal_cast<bool (BASECLASS::*)(CalcPacket&)>(&FGENID(clcp, SUBEXPAND(MFILEID))::CalcIt)); \
|
||||
} \
|
||||
static void FGENID(chlt, SUBEXPAND(MFILEID))(String& out) { out.Cat(FGENID(chlp, SUBEXPAND(MFILEID))().GetTitle()); } \
|
||||
RegisterHelpTopicInfo("Calc$" topic, __FILE__, callback(&FGENID(chlt, SUBEXPAND(MFILEID))), CNULL)
|
||||
|
||||
#define MDECL(id, x, group) MDECLT(BTA0, ASSTRING(call), id, group, call)
|
||||
#define MDECL0(id, x, group) MDECLT(BTA1, ASSTRING(id), id, group, COMBINE3(C, id, x))
|
||||
#define MDECLP(id, x, group) MDECLT(BTA0, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
#define MDECLP0(id, x, group) MDECLT(BTA1, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
|
||||
#define MDECLA(id, x, group) MDECLTA(BTA0, ASSTRING(call), id, group, call)
|
||||
#define MDECLA0(id, x, group) MDECLTA(BTA1, ASSTRING(id), id, group, COMBINE3(C, id, x))
|
||||
#define MDECLAP(id, x, group) MDECLTA(BTA0, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
#define MDECLAP0(id, x, group) MDECLTA(BTA1, "C" ASSTRING(id) ASSTRING(x), ASSTRING(id), group, COMBINE3(C, id, x))
|
||||
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
#include "TCoreCalc.h"
|
||||
#pragma hdrstop
|
||||
|
||||
namespace Upp {
|
||||
|
||||
String CalcTypeDescribeInt() { return t_("integer"); }
|
||||
|
||||
String CalcType<double>::Describe() { return t_("real number"); }
|
||||
String CalcType<int64>::Describe() { return t_("64-bit integer"); }
|
||||
String CalcType<String>::Describe() { return t_("string"); }
|
||||
String CalcType<Date>::Describe() { return t_("date"); }
|
||||
String CalcType<Time>::Describe() { return t_("date/time"); }
|
||||
String CalcType<bool>::Describe() { return t_("logical value"); }
|
||||
String CalcType<Value>::Describe() { return t_("any data type"); }
|
||||
String CalcType<ValueArray>::Describe() { return t_("array"); }
|
||||
String CalcType<Nuller>::Describe() { return t_("null value"); }
|
||||
|
||||
RegisterStdCalcTypeName(double)
|
||||
RegisterStdCalcTypeName(String)
|
||||
RegisterStdCalcTypeName(WString)
|
||||
RegisterStdCalcTypeName(Date)
|
||||
RegisterStdCalcTypeName(Time)
|
||||
RegisterStdCalcTypeName(bool)
|
||||
RegisterStdCalcTypeName(Value)
|
||||
RegisterStdCalcTypeName(ValueArray)
|
||||
|
||||
const char *CalcNanError()
|
||||
{
|
||||
return t_("real number operation error");
|
||||
}
|
||||
|
||||
const char *CalcInfError()
|
||||
{
|
||||
return t_("real number overflow");
|
||||
}
|
||||
|
||||
VectorMap<String, String (*)()>& CalcTypeNameConvert::Get()
|
||||
{
|
||||
static VectorMap<String, String (*)()> list;
|
||||
return list;
|
||||
}
|
||||
|
||||
String CalcTypeNameConvert::Format(const char *raw_name)
|
||||
{
|
||||
static const char rvr[] = "RawValueRep<";
|
||||
static const char cvr[] = "RichValueRep<";
|
||||
const char *s = raw_name;
|
||||
if(!memcmp(s, "struct ", 7))
|
||||
s += 7;
|
||||
else if(!memcmp(s, "class ", 6))
|
||||
s += 6;
|
||||
if(!memcmp(s, rvr, sizeof(rvr) - 1))
|
||||
s += sizeof(rvr) - 2;
|
||||
else if(!memcmp(s, cvr, sizeof(cvr) - 1))
|
||||
s += sizeof(cvr) - 2;
|
||||
String temp;
|
||||
if(*s == '<')
|
||||
{
|
||||
const char *p = ++s;
|
||||
p += strlen(p);
|
||||
if(p > s && p[-1] == '>')
|
||||
p--;
|
||||
temp = String(s, p);
|
||||
raw_name = temp;
|
||||
}
|
||||
int i = Get().Find(raw_name);
|
||||
if(i >= 0)
|
||||
return Get()[i]();
|
||||
return GetTypeName(raw_name);
|
||||
}
|
||||
|
||||
Value CalcType<double>::ToValue(double t)
|
||||
{
|
||||
if(IsNaN(t))
|
||||
throw Exc(CalcNanError());
|
||||
if(IsInf(t))
|
||||
throw Exc(CalcInfError());
|
||||
return t;
|
||||
}
|
||||
|
||||
bool CalcType<bool>::ValueTo(Value v)
|
||||
{
|
||||
if(IsNull(v))
|
||||
return false;
|
||||
return !IsNumber(v) || (double)v != 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
namespace Upp {
|
||||
|
||||
class CalcTypeNameConvert
|
||||
{
|
||||
public:
|
||||
CalcTypeNameConvert(const char *name, String (*outfn)()) { Get().Add(name, outfn); }
|
||||
|
||||
static VectorMap<String, String (*)()>& Get();
|
||||
static String Format(const char *raw_name);
|
||||
};
|
||||
|
||||
#define RegisterCalcTypeName(type, ctname) \
|
||||
static String COMBINE(ctn, MK__s)() { return ctname; } \
|
||||
static CalcTypeNameConvert COMBINE(tn, MK__s)(typeid(type).name(), &COMBINE(ctn, MK__s));
|
||||
|
||||
#define RegisterStdCalcTypeName(type) \
|
||||
static CalcTypeNameConvert COMBINE(tn, MK__s)(typeid(type).name(), &CalcType<type>::Describe);
|
||||
|
||||
template <class T>
|
||||
struct CalcRawType
|
||||
{
|
||||
static Value ToValue(const T& t) { return RawToValue(t); }
|
||||
static const T& ValueTo(Value v) { return RawValue<T>::Extract(v); }
|
||||
static bool IsType(Value v) { return IsTypeRaw<T>(v); }
|
||||
static String Describe() { return CalcTypeNameConvert::Format(typeid(T).name()); }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct CalcRawNullType : CalcRawType<T>
|
||||
{
|
||||
static bool IsType(Value v) { return v.IsVoid() || CalcRawType<T>::IsType(v); }
|
||||
static const T& ValueTo(Value v) { if(v.IsVoid()) { static T t; return t; } return CalcRawType<T>::ValueTo(v); }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct CalcCastType : CalcRawType<T>
|
||||
{
|
||||
static Value ToValue(const T& t) { return t; }
|
||||
static T ValueTo(Value v) { return v; }
|
||||
};
|
||||
|
||||
template <class T> struct CalcType : CalcRawType<T> {};
|
||||
|
||||
template <class T>
|
||||
inline Value CalcTypeToValue(const T& value) { return CalcType<T>::ToValue(value); }
|
||||
|
||||
String CalcTypeDescribeInt();
|
||||
|
||||
template <class T>
|
||||
struct CalcIntType
|
||||
{
|
||||
static Value ToValue(T t) { return int(t); }
|
||||
static T ValueTo(Value v) { return (T)(int)v; }
|
||||
static bool IsType(Value v) { return IsNumber(v); }
|
||||
static String Describe() { return CalcTypeDescribeInt(); }
|
||||
};
|
||||
|
||||
template <> struct CalcType<unsigned char> : public CalcIntType<unsigned char> {};
|
||||
template <> struct CalcType<signed char> : public CalcIntType<signed char> {};
|
||||
template <> struct CalcType<unsigned short> : public CalcIntType<unsigned short> {};
|
||||
template <> struct CalcType<signed short> : public CalcIntType<signed short> {};
|
||||
template <> struct CalcType<unsigned int> : public CalcIntType<unsigned int> {};
|
||||
template <> struct CalcType<signed int> : public CalcIntType<signed int> {};
|
||||
template <> struct CalcType<unsigned long> : public CalcIntType<unsigned long> {};
|
||||
template <> struct CalcType<signed long> : public CalcIntType<signed long> {};
|
||||
|
||||
const char *CalcNanError();
|
||||
const char *CalcInfError();
|
||||
|
||||
template <>
|
||||
struct CalcType<double> : CalcCastType<double>
|
||||
{
|
||||
static bool IsType(Value v) { return IsNumber(v); }
|
||||
static String Describe();
|
||||
static Value ToValue(double t);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<int64> : CalcCastType<int64>
|
||||
{
|
||||
static bool IsType(Value v) { return IsNumber(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<String> : CalcCastType<String>
|
||||
{
|
||||
static bool IsType(Value v) { return IsNull(v) || IsString(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<const String&> : CalcType<String> {};
|
||||
|
||||
template <>
|
||||
struct CalcType<WString> : CalcCastType<WString>
|
||||
{
|
||||
static bool IsType(Value v) { return IsNull(v) || IsString(v); }
|
||||
static String Describe() { return CalcType<String>::Describe(); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<const WString&> : CalcType<WString> {};
|
||||
|
||||
template <>
|
||||
struct CalcType<Date> : CalcCastType<Date>
|
||||
{
|
||||
static bool IsType(Value v) { return IsDateTime(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<Time> : CalcCastType<Time>
|
||||
{
|
||||
static bool IsType(Value v) { return IsDateTime(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<bool>
|
||||
{
|
||||
static Value ToValue(bool b) { return b ? 1 : 0; }
|
||||
static bool ValueTo(Value v);
|
||||
static bool IsType(Value v) { return IsNull(v) || IsNumber(v) || IsString(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<Value>
|
||||
{
|
||||
static Value ToValue(Value v) { return v; }
|
||||
static Value ValueTo(Value v) { return v; }
|
||||
static bool IsType(Value v) { return true; }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<const Value&> : CalcType<Value> {};
|
||||
|
||||
template <>
|
||||
struct CalcType<ValueArray>
|
||||
{
|
||||
static Value ToValue(const ValueArray& t) { return t; }
|
||||
static ValueArray ValueTo(Value v) { return IsValueArray(v) ? ValueArray(v) : ValueArray(); }
|
||||
static bool IsType(Value v) { return IsNull(v) || IsValueArray(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CalcType<const ValueArray&> : CalcType<ValueArray> {};
|
||||
|
||||
template <>
|
||||
struct CalcType<Nuller>
|
||||
{
|
||||
static Value ToValue(const Nuller&) { return Value(); }
|
||||
static Nuller ValueTo(Value v) { return Null; }
|
||||
static bool IsType(Value v) { return IsNull(v); }
|
||||
static String Describe();
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct CalcPtrType
|
||||
{
|
||||
static Value ToValue(T *t) { return t ? PtrToValue(t) : Value(); }
|
||||
static T *ValueTo(const Value& v) { return IsNull(v) ? NULL : PtrValue<T>::Extract(v); }
|
||||
static bool IsType(const Value& v) { return IsNull(v) || IsTypeRaw<T *>(v); }
|
||||
static String Describe() { return CalcTypeNameConvert::Format(typeid(T *).name()); }
|
||||
};
|
||||
|
||||
#define CALC_PTR_TYPE(t) \
|
||||
template <> struct CalcType<t *> : public CalcPtrType<t> {}; \
|
||||
template <> struct CalcType<const t *> : public CalcPtrType<const t> {};
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 2021, The U++ Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY 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.
|
||||
Binary file not shown.
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef __TCore__
|
||||
#define __TCore__
|
||||
|
||||
#include <Web/Web.h>
|
||||
|
||||
#ifdef flagNOHELP
|
||||
#define NOHELP
|
||||
#endif//flagNOHELP
|
||||
#include "template.h"
|
||||
#include "util.h"
|
||||
#include "setop.h"
|
||||
//#include "nls.h"
|
||||
#include "globcfg.h"
|
||||
#include "xmlparse.h"
|
||||
#include "help.h"
|
||||
|
||||
#endif//__TCore__
|
||||
|
|
@ -1,283 +0,0 @@
|
|||
#ifdef _MSC_VER
|
||||
#pragma setlocale("C")
|
||||
#endif
|
||||
// util.cpp
|
||||
|
||||
T_("Null value not allowed.")
|
||||
csCZ("Hodnota nesm\303\255 b\303\275t pr\303\241zdn\303\241.")
|
||||
|
||||
T_("Real number expected.")
|
||||
csCZ("O\304\215ek\303\241v\303\241no re\303\241ln\303\251 \304\215\303\255slo.")
|
||||
|
||||
T_("Fraction denominator is too small.")
|
||||
csCZ("Jmenovatel zlomku je p\305\231\303\255li\305\241 mal\303\275.")
|
||||
|
||||
T_("Illegal trailing character '%c' (0x%1:02x)")
|
||||
csCZ("Za \304\215\303\255slem byl nalezen neplatn\303\275 znak '%c' (0x%1:02x)")
|
||||
|
||||
T_("Lower bound exceeded.")
|
||||
csCZ("Zadan\303\251 \304\215\303\255slo je men\305\241\303\255 ne\305\276 povolen\303\241 "
|
||||
"doln\303\255 mez.")
|
||||
|
||||
T_("Upper bound exceeded.")
|
||||
csCZ("Zadan\303\251 \304\215\303\255slo je v\304\233t\305\241\303\255 ne\305\276 "
|
||||
"povolen\303\241 horn\303\255 mez.")
|
||||
|
||||
T_("'instsrv.exe' not found.")
|
||||
csCZ("Nebyl nalezen program 'instsrv.exe'.")
|
||||
|
||||
T_("'svrany.exe' not found.")
|
||||
csCZ("Nebyl nalezen program 'srvany.exe'.")
|
||||
|
||||
T_("Error running '%s'.")
|
||||
csCZ("Nelze spustit program '%s'.")
|
||||
|
||||
|
||||
// CalcType.cpp
|
||||
|
||||
T_("integer")
|
||||
csCZ("cel\303\251 \304\215\303\255slo")
|
||||
|
||||
T_("real number")
|
||||
csCZ("re\303\241ln\303\251 \304\215\303\255slo")
|
||||
|
||||
T_("64-bit integer")
|
||||
csCZ("cel\303\251 \304\215\303\255slo (64 bit\305\257)")
|
||||
|
||||
T_("string")
|
||||
csCZ("\305\231et\304\233zec")
|
||||
|
||||
T_("date")
|
||||
csCZ("datum")
|
||||
|
||||
T_("date/time")
|
||||
csCZ("datum/\304\215as")
|
||||
|
||||
T_("logical value")
|
||||
csCZ("logick\303\241 hodnota")
|
||||
|
||||
T_("any data type")
|
||||
csCZ("libovoln\303\275 typ")
|
||||
|
||||
T_("array")
|
||||
csCZ("pole hodnot")
|
||||
|
||||
T_("null value")
|
||||
csCZ("pr\303\241zdn\303\241 hodnota")
|
||||
|
||||
T_("real number operation error")
|
||||
csCZ("chyba p\305\231i v\303\275po\304\215tu v re\303\241ln\303\275ch \304\215\303\255slech")
|
||||
|
||||
T_("real number overflow")
|
||||
csCZ("p\305\231ete\304\215en\303\255 p\305\231i v\303\275po\304\215tu v re\303\241ln\303\275ch "
|
||||
"\304\215\303\255slech")
|
||||
|
||||
|
||||
// CalcNode.cpp
|
||||
|
||||
T_("lambda-expression")
|
||||
csCZ("lambda-v\303\275raz")
|
||||
|
||||
T_("Expression evaluator")
|
||||
csCZ("V\303\275razov\303\275 kalkul\303\241tor")
|
||||
|
||||
T_("boolean value")
|
||||
csCZ("logick\303\241 hodnota")
|
||||
|
||||
T_("function nesting too deep (%d levels)")
|
||||
csCZ("p\305\231\303\255li\305\241 hlubok\303\251 vno\305\231en\303\255 funkc\303\255 "
|
||||
"(%d \303\272rovn\303\255)")
|
||||
|
||||
T_("%s is not a constant")
|
||||
csCZ("%s nen\303\255 konstanta")
|
||||
|
||||
T_("variable/constant '")
|
||||
csCZ("prom\304\233nn\303\241/konstanta '")
|
||||
|
||||
T_("function '")
|
||||
csCZ("funkce '")
|
||||
|
||||
T_("' not found")
|
||||
csCZ("' nebyla nalezena")
|
||||
|
||||
T_("missing arguments")
|
||||
csCZ("chyb\303\255 parametry")
|
||||
|
||||
T_("illegal type ")
|
||||
csCZ("chybn\303\275 typ ")
|
||||
|
||||
T_(" or number of parameters")
|
||||
csCZ(" nebo po\304\215et parametr\305\257")
|
||||
|
||||
T_("illegal type combination ")
|
||||
csCZ("chybn\303\241 kombinace typ\305\257 ")
|
||||
|
||||
T_("Maximum nesting depth (")
|
||||
csCZ("Byla p\305\231ekro\304\215ena povolen\303\241 hloubka vno\305\231en\303\255 "
|
||||
"(")
|
||||
|
||||
T_(") exceeded (infinite recursion?)")
|
||||
csCZ(")")
|
||||
|
||||
T_("Expression stack underflow")
|
||||
csCZ("Podte\304\215en\303\255 v\303\275razov\303\251ho z\303\241sobn\303\255ku")
|
||||
|
||||
T_("Number expected, found: ")
|
||||
csCZ("O\304\215ek\303\241v\303\241no \304\215\303\255slo, nalezeno: ")
|
||||
|
||||
T_("String expected, found: ")
|
||||
csCZ("O\304\215ek\303\241v\303\241n \305\231et\304\233zec, nalezeno: ")
|
||||
|
||||
T_("Date expected, found: ")
|
||||
csCZ("O\304\215ek\303\241v\303\241no datum, nalezeno: ")
|
||||
|
||||
T_("Date/time expected, found: ")
|
||||
csCZ("O\304\215ek\303\241v\303\241no datum/\304\215as, nalezeno: ")
|
||||
|
||||
T_(": expected: ")
|
||||
csCZ(": o\304\215ek\303\241v\303\241no: ")
|
||||
|
||||
T_(", found: ")
|
||||
csCZ(", nalezeno: ")
|
||||
|
||||
T_("/* without matching */")
|
||||
csCZ("/* bez odpov\303\255daj\303\255c\303\255 */")
|
||||
|
||||
T_("expected ")
|
||||
csCZ("o\304\215ek\303\241v\303\241n ")
|
||||
|
||||
T_("symbol")
|
||||
csCZ("symbol")
|
||||
|
||||
T_("character")
|
||||
csCZ("znak")
|
||||
|
||||
T_(" '")
|
||||
csCZ(" '")
|
||||
|
||||
T_("', found: ")
|
||||
csCZ("', nalezeno: ")
|
||||
|
||||
T_("end of line")
|
||||
csCZ("konec \305\231\303\241dky")
|
||||
|
||||
T_("invalid day number (")
|
||||
csCZ("neplatn\303\251 \304\215\303\255slo dne (%d)")
|
||||
|
||||
T_("Unterminated string constant")
|
||||
csCZ("Neukon\304\215en\303\241 \305\231et\304\233zcov\303\241 konstanta")
|
||||
|
||||
T_("illegal characters after expression: %s (expression: %s)")
|
||||
csCZ("neplatn\303\251 znaky za v\303\275razem: %s (za\304\215\303\241tek v\303\275razu: "
|
||||
"%s)")
|
||||
|
||||
T_("expected 'between', 'in' or 'like'")
|
||||
csCZ("o\304\215ek\303\241v\303\241no 'between', 'in' nebo 'like'")
|
||||
|
||||
T_("left parenthesis not matched; subexpression starts at %s")
|
||||
csCZ("nep\303\241rov\303\241 lev\303\241 z\303\241vorka; za\304\215\303\241tek "
|
||||
"podv\303\275razu: %s")
|
||||
|
||||
T_("constant or function expected, found: ")
|
||||
csCZ("o\304\215ek\303\241v\303\241na konstanta nebo funkce, nalezeno: ")
|
||||
|
||||
T_("')' (subexpression starts at: %s)")
|
||||
csCZ("')' (za\304\215\303\241tek podv\303\275razu: %s)")
|
||||
|
||||
|
||||
// CalcBasic.cpp
|
||||
|
||||
T_("Comparison")
|
||||
csCZ("Porovn\303\241v\303\241n\303\255")
|
||||
|
||||
T_("Bit field operations")
|
||||
csCZ("Bitov\303\251 operace")
|
||||
|
||||
T_("Arithmetical operations")
|
||||
csCZ("Aritmetick\303\251 operace")
|
||||
|
||||
T_("Logical operations")
|
||||
csCZ("Logick\303\251 operace")
|
||||
|
||||
T_("Text operations")
|
||||
csCZ("Operace s texty")
|
||||
|
||||
T_("Date operations")
|
||||
csCZ("Operace s daty")
|
||||
|
||||
T_("Array functions")
|
||||
csCZ("Zpracov\303\241n\303\255 pol\303\255 hodnot")
|
||||
|
||||
T_("Constants")
|
||||
csCZ("Konstanty")
|
||||
|
||||
T_("Transcendental functions")
|
||||
csCZ("Transcendentn\303\255 funkce")
|
||||
|
||||
T_("System functions")
|
||||
csCZ("Speci\303\241ln\303\255 funkce")
|
||||
|
||||
T_("division by zero")
|
||||
csCZ("d\304\233len\303\255 nulou")
|
||||
|
||||
T_("invalid number of places (%d)")
|
||||
csCZ("chybn\303\275 po\304\215et m\303\255st (%d)")
|
||||
|
||||
T_("invalid numeric format: '%s'")
|
||||
csCZ("neplatn\303\275 form\303\241t \304\215\303\255sla: '%s'")
|
||||
|
||||
T_("invalid year number (%d)")
|
||||
csCZ("chybn\303\251 \304\215\303\255slo roku (%d)")
|
||||
|
||||
T_("invalid month number (%d)")
|
||||
csCZ("chybn\303\251 \304\215\303\255slo m\304\233s\303\255ce (%d)")
|
||||
|
||||
T_("invalid day number (%d)")
|
||||
csCZ("chybn\303\251 \304\215\303\255slo dne (%d)")
|
||||
|
||||
T_("invalid hour number: %d")
|
||||
csCZ("chybn\303\251 \304\215\303\255slo hodiny: %d")
|
||||
|
||||
T_("invalid minute number: %d")
|
||||
csCZ("chybn\303\251 \304\215\303\255slo minuty: %d")
|
||||
|
||||
T_("invalid second number: %d")
|
||||
csCZ("chybn\303\251 \304\215\303\255slo sekundy: %d")
|
||||
|
||||
T_("result date is out of range")
|
||||
csCZ("v\303\275sledn\303\251 datum je mimo povolen\303\275 rozsah")
|
||||
|
||||
T_("array is too long (%d elements)")
|
||||
csCZ("pole je p\305\231\303\255li\305\241 dlouh\303\251 (%d prvk\305\257)")
|
||||
|
||||
T_("invalid index %d, array has just %d elements")
|
||||
csCZ("neplatn\303\275 index %d, pole m\303\241 jen %d prvk\305\257")
|
||||
|
||||
T_("invalid index %d, string has just %d characters")
|
||||
csCZ("neplatn\303\275 index %d, \305\231et\304\233zec m\303\241 jen %d znak\305\257")
|
||||
|
||||
T_("array element has invalid data type (index %d), number expected: %s")
|
||||
csCZ("prvek pole m\303\241 neplatn\303\275 datov\303\275 typ (index %d), o\304\215ek\303\241v\303\241no "
|
||||
"\304\215\303\255slo: %s")
|
||||
|
||||
T_("array element has invalid data type (index %d), string expected: %s")
|
||||
csCZ("prvek pole m\303\241 neplatn\303\275 datov\303\275 typ (index %d), o\304\215ek\303\241v\303\241n "
|
||||
"\305\231et\304\233zec: %s")
|
||||
|
||||
T_("array element has invalid data type (index %d), array expected: %s")
|
||||
csCZ("prvek pole m\303\241 neplatn\303\275 datov\303\275 typ (index %d), o\304\215ek\303\241v\303\241no "
|
||||
"pole: %s")
|
||||
|
||||
T_("array element has invalid data type (index %d), number or string expected: "
|
||||
"%s")
|
||||
csCZ("prvek pole m\303\241 neplatn\303\275 datov\303\275 typ (index %d), o\304\215ek\303\241v\303\241no "
|
||||
"\304\215\303\255slo nebo \305\231et\304\233zec: %s")
|
||||
|
||||
T_("control variable has empty name")
|
||||
csCZ("pr\303\241zdn\303\275 n\303\241zev \305\231\303\255dic\303\255 prom\304\233nn\303\251")
|
||||
|
||||
T_("invalid number of array elements")
|
||||
csCZ("chybn\303\275 po\304\215et prvk\305\257 pole")
|
||||
|
||||
T_("invalid character index")
|
||||
csCZ("chybn\303\275 po\304\215\303\241te\304\215n\303\255 index")
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
description "Experimental (sometimes obsolete) non-GUI code\377";
|
||||
|
||||
charset "windows-1250";
|
||||
|
||||
uses
|
||||
Core,
|
||||
Web,
|
||||
plugin\dbf;
|
||||
|
||||
file
|
||||
TCore.h,
|
||||
TCore.t charset "UTF-8",
|
||||
tcore.usc,
|
||||
TCore_init.icpp,
|
||||
template.h,
|
||||
util.h,
|
||||
util.cpp,
|
||||
setop.h,
|
||||
nls_bw.h,
|
||||
nls_bw.hpp,
|
||||
globcfg.h,
|
||||
globcfg.cpp,
|
||||
xmlparse.h,
|
||||
xmlparse.cpp,
|
||||
"Basic help support" readonly separator,
|
||||
help.h,
|
||||
help.cpp,
|
||||
"Expression Calculator" readonly separator,
|
||||
TCoreCalc.h,
|
||||
CalcType.h,
|
||||
CalcType.cpp,
|
||||
CalcNode.h,
|
||||
CalcNode.cpp,
|
||||
CalcBasic.h,
|
||||
CalcBasic.cpp,
|
||||
"File-based Database" readonly separator,
|
||||
TCoreDb.h,
|
||||
datafile.h,
|
||||
datafile.cpp,
|
||||
database.h,
|
||||
database.cpp,
|
||||
datatest.cpp,
|
||||
dd_h.h,
|
||||
dd_cpp.h,
|
||||
Info readonly separator,
|
||||
Copying;
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef __TCoreCalc__
|
||||
#define __TCoreCalc__
|
||||
|
||||
#include <TCore/TCore.h>
|
||||
#include "CalcType.h"
|
||||
#include "CalcNode.h"
|
||||
|
||||
namespace Upp {
|
||||
|
||||
extern void UseCalcBasic();
|
||||
|
||||
String GroupComp();
|
||||
String GroupBitOp();
|
||||
String GroupArith();
|
||||
String GroupLog();
|
||||
String GroupString();
|
||||
String GroupDate();
|
||||
String GroupArray();
|
||||
String GroupConst();
|
||||
String GroupTrans();
|
||||
|
||||
}
|
||||
|
||||
#endif//__TCoreCalc__
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef __TCoreDb__
|
||||
#define __TCoreDb__
|
||||
|
||||
#include <TCore/TCoreCalc.h>
|
||||
#include "datafile.h"
|
||||
#include "database.h"
|
||||
|
||||
#endif//__TCore__
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#include "TCore.h"
|
||||
|
||||
namespace Upp {
|
||||
|
||||
#define TFILE <TCore/TCore.t>
|
||||
#include <Core/t.h>
|
||||
|
||||
}
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
TITLE("Aritmetické operace")
|
||||
REF("Calc$CaddNN")
|
||||
REF("Calc$CceilN")
|
||||
REF("Calc$CceilNN")
|
||||
REF("Calc$CceilrNN")
|
||||
REF("Calc$CdivNN")
|
||||
REF("Calc$CfloorN")
|
||||
REF("Calc$CfloorNN")
|
||||
REF("Calc$CfloorrNN")
|
||||
REF("Calc$CgeNN")
|
||||
REF("Calc$CgtNN")
|
||||
REF("Calc$ChypotNN")
|
||||
REF("Calc$CleNN")
|
||||
REF("Calc$CltNN")
|
||||
REF("Calc$CmaxNN")
|
||||
REF("Calc$CminNN")
|
||||
REF("Calc$CminmaxNNN")
|
||||
REF("Calc$CminusN")
|
||||
REF("Calc$CmodNN")
|
||||
REF("Calc$CmulNN")
|
||||
REF("Calc$CplusN")
|
||||
REF("Calc$CroundN")
|
||||
REF("Calc$CroundNN")
|
||||
REF("Calc$CroundrNN")
|
||||
REF("Calc$CsgnN")
|
||||
REF("Calc$CsqrN")
|
||||
REF("Calc$CsqrtN")
|
||||
REF("Calc$CsubNN")
|
||||
TOPIC_TEXT(
|
||||
"[2 $$0,0#00000000000000000000000000000000:Default][b100;a50;K* $$1,0#23046025415494101427921008701515:Paragraph][i167;b50;a25;kKN1;~~~>.3917;* "
|
||||
"$$2,0#52185223490867151055420261384346:Toc1`.Heading1][i333;kN11;~~~>.3917;* $$3,0#36545033421193513457240054113541:Toc2`.Heading2][i500;kN111;~~~>.3917; "
|
||||
"$$4,0#65092512416424580164828413186219:Toc3`.Heading3][i167;b50;a25;kKNA;~~~>.3917;* "
|
||||
"$$5,5#92291332474308709450111162202673:AppToc1`.AppHeading1][i333;kNA1;~~~>.3917;* "
|
||||
"$$6,15#61887903412252554674480251236992:AppToc2`.AppHeading2][i500;kNA11;~~~>.3917; "
|
||||
"$$7,7#03533551421653050355120437860335:AppToc3`.AppHeading3][i500;b100;a100;KN1;*4 "
|
||||
"$$8,0#94145093439740438411010082165944:Heading1][i500;b100;a50;kKN11;*+117 $$9,0#10901425421210535753260366156531:Heading2][i500;b100;a25;kKN111;* "
|
||||
"$$10,0#53209141402041366431858192225431:Heading3][i500;b100;a100;KNA;*4 $$11,8#32912651424211307887950041245434:AppHeading1][i500;b100;a50;kKNA1;*+117 "
|
||||
"$$12,8#51232055453458524230328032001901:AppHeading2][i500;b100;a25;kKNA11;* $$13,8#34108020439428305453439845463579:AppHeading3][b100;a50;k*4 "
|
||||
"$$14,0#49239115434362547028389207250014:Heading][b50;a25;k~~~>.3917;* $$15,15#40743698422276745552070108434023:Toc`.Heading][b100;a50;K~~~>.3917;*+117 "
|
||||
"$$16,16#15422850471211852294098111138263:Topics1][l167;b50;a50;K~~~>.3917;* $$17,17#35241722455500657380289596243808:Topics2][l333;~~~>.3917; "
|
||||
"$$18,18#31041344429742018840308064013200:Topics3][b83;a42;K* $$19,0#46440151113795363000000595230845:Paragraph][{_}%EN-US "
|
||||
"[s14; abs (reálné číslo) [S ®] reálné číslo&][s0; &][s0; Absolutní hodnota "
|
||||
"čísla. Pokud je číslo kladné, jeho absolutní hodnota je mu rovna. Absolutní "
|
||||
"hodnotou záporného čísla je číslo opačné.&][s0; &][s0; [* Příklad: ]abs(`-10.5) "
|
||||
"`= 10.5, abs(12) `= 12.&][s14;:Calc`$CaddNN: [%00-00 operátor `+ (reálné číslo, "
|
||||
"reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Operátor sečte "
|
||||
"zadanou dvojici reálných čísel. Pokud je některý z parametrů [* null], je "
|
||||
"výsled")
|
||||
TOPIC_TEXT(
|
||||
"kem součtu opět [* null]. &][s0; &][s0; [* Příklad: ]5`+7`=12&][s14;:Calc`$CceilN: "
|
||||
"[%00-00 ceil (reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Zaokrouhlení "
|
||||
"směrem nahoru. Funkce nalezne nejmenší celé číslo, které není menší než "
|
||||
"původní [/ hodnota].&][s0; &][s0; [* Příklad: ]ceil(`-2.5) `= `-2&][s14;:Calc`$CceilNN: "
|
||||
"[%00-00 ceil (reálné číslo ][%00-00/ hodnota][%00-00 , celé číslo ][%00-00/ "
|
||||
"počet`_desetinných`_míst][%00-00 ) ][%00-00S ®][%00-00 reálné číslo]&][s0; "
|
||||
"Zaokrouhlení směrem nahoru na zadaný počet desetinných míst. Funkce nalezne "
|
||||
"nejmenší reálné číslo, které je celistvým násobkem hodnoty [* 10_`*`*_][/ "
|
||||
"`-počet_míst] a_není menší než původní [/ hodnota].&][s0; &][s0; [* Příklad: "
|
||||
"]ceil(47.32, 1) `= 47.4, ceil(117, `-1) `= 120.&][s14;:Calc`$CceilrNN: [%00-00 ceilr(reálné "
|
||||
"číslo ][%00-00/ hodnota][%00-00 , celé číslo ][%00-00/ platných`_číslic][%00-00 "
|
||||
") ][%00-00S ®][%00-00 reálné číslo]&][s0; [Izaokrouhlování`; číslo`, zaokrouhlení; "
|
||||
"Zaokrouhlení] směrem nahoru na zadaný počet platných číslic. Funkce nalezne "
|
||||
"nejmenší reálné číslo, které je celistvým násobkem hodnoty [* 10_`*`*_][/ "
|
||||
"(ceil(log(hodnota))`-platných`_číslic)] a_není menší než původní [/ hodnota].&][s0; "
|
||||
"&][s0; [* Příklad: ]ceilr(47.32, 3) `= 47.4, ceilr(117, 1) `= 200.&][s14;:Calc`$CdivNN: "
|
||||
"[%00-00 operátor / (reálné číslo, reálné číslo) ][%00-00S ®][%00-00 reálné "
|
||||
"číslo]&][s0; Dělení. Pokud je na pravé straně operátoru nula, výpočet výrazu "
|
||||
"ohlásí chybu [* dělení nulou].&][s0; &][s0; [* Příklad: ]3.7 / 2.5 `= 1.48.&][s14;:Calc`$CfloorN: "
|
||||
"[%00-00 floor (reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Zaokrouhlení "
|
||||
"směrem dolů. Funkce nalezne nejvyšší celé číslo, které není vyšší než "
|
||||
"původní [/ hodnota].&][s0; &][s0; [* Příklad: ]floor(`-2.5) `= `-3&][s14;:Calc`$CfloorNN: "
|
||||
"[%00-00 floor (reálné číslo ][%00-00/ hodnota][")
|
||||
TOPIC_TEXT(
|
||||
"%00-00 , celé číslo ][%00-00/ počet`_desetinných`_míst][%00-00 ) ][%00-00S "
|
||||
"®][%00-00 reálné číslo]&][s0; Zaokrouhlení směrem dolů na zadaný počet "
|
||||
"desetinných míst. Funkce nalezne nejvyšší reálné číslo, které je celistvým "
|
||||
"násobkem hodnoty [* 10_`*`*_][/ `-počet_míst] a_není vyšší než původní "
|
||||
"[/ hodnota].&][s0; &][s0; [* Příklad: ]floor(47.32, 1) `= 47.3, floor(117, `-1) "
|
||||
"`= 110.&][s14;:Calc`$CfloorrNN: [%00-00 floorr(reálné číslo ][%00-00/ hodnota][%00-00 "
|
||||
", celé číslo ][%00-00/ platných`_číslic][%00-00 ) ][%00-00S ®][%00-00 reálné "
|
||||
"číslo]&][s0; Zaokrouhlení směrem dolů na zadaný počet platných číslic. "
|
||||
"Funkce nalezne nejvyšší reálné číslo, které je celistvým násobkem hodnoty "
|
||||
"[* 10_`*`*_][/ (ceil(log(hodnota))`-platných`_číslic)] a_není vyšší než původní "
|
||||
"[/ hodnota].&][s0; &][s0; [* Příklad: ]floorr(47.32, 3) `= 47.3, floorr(117, 1) "
|
||||
"`= 100.&][s14;:Calc`$CgeNN: operátor >`= (reálné číslo, reálné číslo) [S "
|
||||
"®] logická hodnota&][s0; Operátor porovná dvojici hodnot a_vrátí hodnotu 1, "
|
||||
"pokud nerovnost platí, respektive 0, pokud nerovnost neplatí. Texty se porovnávají "
|
||||
"lexikograficky ([/ slovníkové] uspořádání).&][s14;:Calc`$CgtNN: operátor > "
|
||||
" (reálné číslo [/ n1], reálné číslo [/ n2]) [S ®] logická hodnota&][s0; "
|
||||
"Operátor porovná dvojici hodnot a_vrátí hodnotu 1, pokud nerovnost platí, respektive "
|
||||
"0, pokud nerovnost neplatí. Texty se porovnávají lexikograficky ([/ slovníkové] "
|
||||
"uspořádání).&][s14;:Calc`$ChypotNN: [%00-00 hypot (reálné číslo ][%00-00/ "
|
||||
"x][%00-00 , reálné číslo ][%00-00/ y][%00-00 ) ][%00-00S ®][%00-00 reálné "
|
||||
"číslo]&][s0; Délka přepony pravoúhlého trojúhelníka. Výpočet přepony se "
|
||||
"provádí podle Pythagorovy věty: [* hypot(][*/ x][* , ][*/ y][* ) `= sqrt(][*/ "
|
||||
"x][* `* ][*/ x][* `+ ][*/ y][* `* ][*/ y][* )].&][s0; &][s0; [* Příklad]: hypot(3, "
|
||||
"4) `= 5&][s14;:Calc`$CleNN: [%00-00 operátor <`= (reálné čísl")
|
||||
TOPIC_TEXT(
|
||||
"o ][%00-00/ x][%00-00 , reálné číslo ][%00-00/ y][%00-00 ) ][%00-00S ®][%00-00 "
|
||||
" logická hodnota]&][s0; Operátor porovná dvojici čísel a_vrátí hodnotu 1 ([/ "
|
||||
"pravda]), pokud [* x <`= y].&][s0; &][s0; [* Příklad: ](10 <`= 20) `= 1&][s14;:Calc`$CltNN: "
|
||||
"[%00-00 operátor < (reálné číslo, reálné číslo) ][%00-00S ®][%00-00 logická "
|
||||
"hodnota]&][s0; Operátor porovná dvojici čísel a_vrátí hodnotu 1 ([/ pravda]), "
|
||||
"pokud [* x < y].&][s0; &][s0; [* Příklad: ](10 < 20) `= 1&][s14;:Calc`$CmaxNN: "
|
||||
"max (reálné číslo, reálné číslo) [S ®] reálné číslo&][s0; Funkce vrátí "
|
||||
"maximum ze dvou reálných čísel. Pokud je některé z čísel rovno [* null], "
|
||||
"je výsledkem funkce také [* null].&][s14;:Calc`$CminNN: [%00-00 min (reálné číslo, "
|
||||
"reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Funkce vrátí minimum "
|
||||
"ze dvou reálných čísel. Pokud je některé z čísel rovno [* null], je výsledkem "
|
||||
"funkce také [* null].&][s0; &][s0; [* Příklad: ]min(`-15, `-16) `= `-16&][s14;:Calc`$CminmaxNNN: "
|
||||
"[%00-00 minmax (reálné číslo ][%00-00/ x][%00-00 , reálné číslo ][%00-00/ "
|
||||
"xmin][%00-00 , reálné číslo ][%00-00/ xmax][%00-00 ) ][%00-00S ®][%00-00 reálné "
|
||||
"číslo]&][s0; Funkce vrátí hodnotu [* min(max(x, xmin), xmax)]. Pokud je některý "
|
||||
"z parametrů roven [* null], je výsledek také [* null].&][s0; &][s0; [* Příklad: "
|
||||
"]minmax(3, 5, 10) `= 5, minmax(7, 5, 10) `= 7, minmax(20, 5, 10) `= 10&][s14;:Calc`$CminusN: "
|
||||
"[%00-00 operátor `- (reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; "
|
||||
"Výsledkem aplikace unárního operátoru `- je číslo opačné k zadanému reálnému "
|
||||
"číslu.&][s0; &][s0; [* Příklad: ]`-(2 `* 2) `= `-4&][s0; Funkce vrátí počet "
|
||||
"minut ze zadaného parametru typu datum / čas.&][s14;:Calc`$CmodNN: [%00-00 operátor "
|
||||
"% (reálné číslo ][%00-00/ a][%00-00 , reálné číslo ][%00-00/ b][%00-00 ) "
|
||||
"][%00-00S ®][%00-00 reálné číslo]&][s0; Zbytek po dělení. Operátor určí "
|
||||
"nejmenš<EFBFBD>")
|
||||
TOPIC_TEXT(
|
||||
"<EFBFBD> nezáporné číslo ze všech čísel, která lze získat přičtením nebo odečtením "
|
||||
"celočíselného násobku hodnoty [/ b] k_hodnotě [/ a]. Pokud je na pravé straně "
|
||||
"operátoru nula, výpočet výrazu ohlásí chybu [* dělení nulou].&][s0; &][s0; "
|
||||
"[* Příklad]: 10.5 % 2.4 `= 0.9 (10.5 `= 4 `* 2.4 `+ 0.9).&][s0; Funkce vrátí "
|
||||
"číslo měsíce v roce pro zadané datum.&][s0; &][s0; [* Příklad: ]month(27.5.1984) "
|
||||
"`= 5&][s0; Operátor pro každý prvek zadaného pole vyhodnotí [/ lambda`-výraz] "
|
||||
"a vrátí pole obsahující výsledky těchto výpočtů. Výsledné pole má vždy "
|
||||
"stejný počet prvků jako vstupní pole. Při vyhodnocování [/ lambda`-výrazu] "
|
||||
"je pro každý prvek původního pole proměnná kalkulátoru [* I] nastavená na "
|
||||
"index tohoto prvku v poli (první prvek pole má index 0), proměnná [* A] obsahuje "
|
||||
"hodnotu zpracovávaného prvku.&][s0; &][s0; [* Příklad: ]`[1, 2, 3, 4`] `* #(A "
|
||||
"`* A) `= `[1, 4, 9, 16`]&][s14;:Calc`$CmulNN: [%00-00 operátor `* (reálné číslo, "
|
||||
"reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Součin reálných "
|
||||
"čísel.&][s0;* &][s0; [* Příklad: ]17 `* 15 `= 255.&][s14;:Calc`$CplusN: [%00-00 "
|
||||
"operátor `+ (reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Operátor "
|
||||
"ponechá reálné číslo beze změny. Slouží jako symetrický protějšek k unárnímu "
|
||||
"operátoru `- (minus).&][s0; &][s0; [* Příklad: ]`+(4`+5) `= 9&][s14;:Calc`$CroundN: "
|
||||
"[%00-00 round (reálné číslo) ][%00-00S ®][%00-00 reálné číslo]&][s0; Zaokrouhlení "
|
||||
"na nejbližší celé číslo. Pokud zadané číslo leží přesně v_polovině "
|
||||
"vzdálenosti mezi nejbližšími celými čísly, zaokrouhlí se směrem nahoru.&][s0; "
|
||||
"&][s0; [* Příklad: ]round(`-2.5) `= `-2, round(47.32) `= 47&][s14;:Calc`$CroundNN: "
|
||||
"[%00-00 round (reálné číslo ][%00-00/ hodnota][%00-00 , celé číslo ][%00-00/ "
|
||||
"počet`_desetinných`_míst][%00-00 ) ][%00-00S ®][%00-00 reálné číslo]&][s0; "
|
||||
"Zaokrouhlení na zadaný počet desetin")
|
||||
TOPIC_TEXT(
|
||||
"ných míst (0, pokud není zadáno). Směr zaokrouhlení je k_nejbližšímu reálnému "
|
||||
"číslu, které je celistvým násobkem hodnoty [* 10_`*`*_][/ `-počet_míst]. Pokud "
|
||||
"zadané číslo leží přesně v_polovině vzdálenosti mezi nejbližšími takovými "
|
||||
"čísly, zaokrouhlí se směrem nahoru.&][s0; &][s0; [* Příklad]: round(`-2.5) "
|
||||
"`= `-2, round(47.32, 1) `= 47.3, round(117, `-1) `= 120.&][s14;:Calc`$CroundrNN: "
|
||||
"[%00-00 roundr(reálné číslo ][%00-00/ hodnota][%00-00 , celé číslo ][%00-00/ "
|
||||
"platných`_číslic][%00-00 ) ][%00-00S ®][%00-00 reálné číslo]&][s0; Zaokrouhlení "
|
||||
"na zadaný počet platných číslic. Směr zaokrouhlení je k_nejbližšímu reálnému "
|
||||
"číslu, které je celistvým násobkem hodnoty [* 10_`*`*_][/ (ceil(log(hodnota))`-platných`_číslic)]. "
|
||||
"Pokud zadané číslo leží přesně v_polovině vzdálenosti mezi nejbližšími "
|
||||
"takovými čísly, zaokrouhlí se směrem nahoru.&][s0; &][s0; [* Příklad: ]roundr(47.32, "
|
||||
"2) `= 47, roundr(117, 1) `= 100.&][s0; Funkce doplní řetězec [* text] mezerami "
|
||||
"zprava na počet znaků [* délka]. Pokud je [* délka] menší nebo rovna délce "
|
||||
"původního řetězce [* text], funkce vrátí vstupní text beze změny.&][s0; &][s0;/ "
|
||||
"[*/ Příklad: ][/ rpad(`\"ahoj`\", 8) `= `\"ahoj `\" ](text [* ahoj] následovaný "
|
||||
"čtyřmi mezerami)&][s14;:Calc`$CsgnN: [%00-00 sgn (reálné číslo ][%00-00/ x][%00-00 "
|
||||
") ][%00-00S ®][%00-00 celé číslo]&][s0; Znaménko. Výpočet znaménka probíhá "
|
||||
"podle následující tabulky:&][s0; &][s0; &][s0; &][s0; [* Příklad]: sgn(`-13.5) "
|
||||
"`= `-1, sgn(0) `= 0, sgn(10) `= `+1.&][s14;:Calc`$CsqrN: [%00-00 sqr (reálné číslo "
|
||||
"][%00-00/ x][%00-00 ) ][%00-00S ®][%00-00 reálné číslo]&][s0; Druhá mocnina. "
|
||||
"Funkce vrátí hodnotu [* sqr(][*/ x][* ) `= ][*/ x][* `* ][*/ x].&][s0; &][s0; "
|
||||
"[* Příklad]: sqr(12) `= 144&][s14;:Calc`$CsqrtN: [%00-00 sqrt (reálné číslo "
|
||||
"][%00-00/ x][%00-00 ) ][%00-00S ®][%00-00 reálné číslo]&][s0; Druhá odmocnina. "
|
||||
"Funkce vrátí ta")
|
||||
TOPIC_TEXT(
|
||||
"kovou hodnotu [*/ a], pro kterou [*/ x][* `= ][*/ a][* `* ][*/ a]. Pokud je parametr "
|
||||
"funkce záporný, výpočet výrazu skončí s chybou chyba při výpočtu v reálných "
|
||||
"číslech.&][s0; &][s0; [* Příklad: ]sqrt(81) `= 9&][s14;:Calc`$CsubNN: [%00-00 "
|
||||
"operátor `- (reálné číslo, reálné číslo) ][%00-00S ®][%00-00 reálné "
|
||||
"číslo]&][s0; Operátor odečte dvě reálná čísla. Pokud je libovolné z čísel "
|
||||
"rovno [* null], výsledkem operátoru je opět [* null].&][s0; &][s0; [* Příklad: "
|
||||
"]7 `- (`-13) `= 20&][s0; &][s0; &][s0; &][s0; &][s0; &][s0; ]")
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
TITLE("Arithmetical operations")
|
||||
REF("Calc$CabsN")
|
||||
REF("Calc$CaddNN")
|
||||
REF("Calc$CceilN")
|
||||
REF("Calc$CceilNN")
|
||||
REF("Calc$CceilrNN")
|
||||
REF("Calc$CdivNN")
|
||||
REF("Calc$CfloorN")
|
||||
REF("Calc$CfloorNN")
|
||||
REF("Calc$CfloorrNN")
|
||||
REF("Calc$CgeNN")
|
||||
REF("Calc$ChypotNN")
|
||||
REF("Calc$CleNN")
|
||||
REF("Calc$ClogNotN")
|
||||
REF("Calc$CltNN")
|
||||
REF("Calc$CmaxNN")
|
||||
REF("Calc$CminNN")
|
||||
REF("Calc$CminmaxNNN")
|
||||
REF("Calc$CminusN")
|
||||
REF("Calc$CmodNN")
|
||||
REF("Calc$CmulNN")
|
||||
REF("Calc$CplusN")
|
||||
REF("Calc$CroundN")
|
||||
REF("Calc$CroundNN")
|
||||
REF("Calc$CroundrNN")
|
||||
REF("Calc$CsgnN")
|
||||
REF("Calc$CsqrN")
|
||||
REF("Calc$CsqrtN")
|
||||
REF("Calc$CsubNN")
|
||||
REF("Calc$CgtNN")
|
||||
TOPIC_TEXT(
|
||||
"[2 $$0,0#00000000000000000000000000000000:Default][b100;a50;K* $$1,0#23046025415494101427921008701515:Paragraph][i167;b50;a25;kKN1;~~~>.3917;* "
|
||||
"$$2,0#52185223490867151055420261384346:Toc1`.Heading1][i333;kN11;~~~>.3917;* $$3,0#36545033421193513457240054113541:Toc2`.Heading2][i500;kN111;~~~>.3917; "
|
||||
"$$4,0#65092512416424580164828413186219:Toc3`.Heading3][i167;b50;a25;kKNA;~~~>.3917;* "
|
||||
"$$5,5#92291332474308709450111162202673:AppToc1`.AppHeading1][i333;kNA1;~~~>.3917;* "
|
||||
"$$6,15#61887903412252554674480251236992:AppToc2`.AppHeading2][i500;kNA11;~~~>.3917; "
|
||||
"$$7,7#03533551421653050355120437860335:AppToc3`.AppHeading3][i500;b100;a100;KN1;*4 "
|
||||
"$$8,0#94145093439740438411010082165944:Heading1][i500;b100;a50;kKN11;*+117 $$9,0#10901425421210535753260366156531:Heading2][i500;b100;a25;kKN111;* "
|
||||
"$$10,0#53209141402041366431858192225431:Heading3][i500;b100;a100;KNA;*4 $$11,8#32912651424211307887950041245434:AppHeading1][i500;b100;a50;kKNA1;*+117 "
|
||||
"$$12,8#51232055453458524230328032001901:AppHeading2][i500;b100;a25;kKNA11;* $$13,8#34108020439428305453439845463579:AppHeading3][b100;a50;k*4 "
|
||||
"$$14,0#49239115434362547028389207250014:Heading][b50;a25;k~~~>.3917;* $$15,15#40743698422276745552070108434023:Toc`.Heading][b100;a50;K~~~>.3917;*+117 "
|
||||
"$$16,16#15422850471211852294098111138263:Topics1][l167;b50;a50;K~~~>.3917;* $$17,17#35241722455500657380289596243808:Topics2][l333;~~~>.3917; "
|
||||
"$$18,18#31041344429742018840308064013200:Topics3][b83;a42;K* $$19,0#46440151113795363000000595230845:Paragraph][{_}%EN-US "
|
||||
"[s14;:Calc`$CabsN: [%00-00 abs (real number) ][%00-00S ®][%00-00 real number]&][s0; "
|
||||
"Absolute value. If the number is positive, its absolute value is equal to it. The "
|
||||
"absolute value of a negative number is its inverse.&][s0; &][s0; [* Example]: abs(`-10.5) "
|
||||
"`= 10.5, abs(12) `= 12.&][s14;:Calc`$CaddNN: operator `+ (real number, real number) "
|
||||
"[S ®] real number&][s0; &][s0; &][s14;:Calc`$CceilN: [%00-00 ceil (real number) "
|
||||
"][%00-00S ®][%00-00 real number]&][s0; &][s14;:Calc`$CceilNN: [%00-00 ceil (real "
|
||||
"number")
|
||||
TOPIC_TEXT(
|
||||
" ][%00-00/ value][%00-00 , integer ][%00-00/ decimals][%00-00 ) ][%00-00S ®][%00-00 "
|
||||
" real number]&][s0; Rounding down (towards plus infinity) to the stated number of "
|
||||
"decimal places (0 by default). The function returns the lowest integral multiple "
|
||||
"of [* 10_`*`*_][/ `-decimals] not lower than the original [/ value].&][s0; &][s0; "
|
||||
"[* Example]: ceil(`-2.5) `= `-2, ceil(47.32, 1) `= 47.4, ceil(117, `-1) `= 120.&][s14;:Calc`$CceilrNN: "
|
||||
"[%00-00 ceilr(real number ][%00-00/ value][%00-00 , integer ][%00-00/ significant`_digits][%00-00 "
|
||||
") ][%00-00S ®][%00-00 real number]&][s0; Rounding up (towards plus infinity) to "
|
||||
"the stated number of significant digits. The function returns the lowest integral "
|
||||
"multiple of [* 10_`*`*_][/ (ceil(log(value))`-significant`_digits)] not lower than "
|
||||
"the original [/ value].&][s0; &][s0;* Example: ceilr(47.32, 3) `= 47.4, ceilr(117, "
|
||||
"1) `= 200.&][s14;:Calc`$CdivNN: [%00-00 operator / (real number, real number) ][%00-00S "
|
||||
"®][%00-00 real number]&][s0; Real number division. If the right operand equals "
|
||||
"zero, the computation aborts with the error [* division by zero].&][s0; &][s0; [* "
|
||||
"Example]: 3.7 / 2.5 `= 1.48.&][s14;:Calc`$CfloorN: [%00-00 floor (real number) ][%00-00S "
|
||||
"®][%00-00 real number]&][s0; &][s14;:Calc`$CfloorNN: [%00-00 floor (real number "
|
||||
"][%00-00/ value][%00-00 , integer ][%00-00/ decimals][%00-00 ) ][%00-00S ®][%00-00 "
|
||||
" real number]&][s0; Rounding down (towards minus infinity) to the stated number of "
|
||||
"decimal places (0 by default). The function returns the highest integral multiple "
|
||||
"of [* 10_`*`*_][/ `-decimals] not greater than the original [/ value].&][s0; &][s0; "
|
||||
"[* Example]: floor(`-2.5) `= `-3, floor(47.32, 1) `= 47.3, floor(117, `-1) `= 110.&][s14;:Calc`$CfloorrNN: "
|
||||
"[%00-00 floorr(real number ][%00-00/ value][%00-00 , integer ][%00-00/ significant`_digits][%00-00 "
|
||||
") ][%00-00S ®][%00-00 real number]&][s0; Rounding down (towards minus infinity) "
|
||||
"to the stated number of significant digits. The function returns the highest integral "
|
||||
"multiple ")
|
||||
TOPIC_TEXT(
|
||||
"of [* 10_`*`*_][/ (ceil(log(value))`-significant`_digits) ]not greater than the "
|
||||
"original [/ value].&][s0; &][s0;* Example: floorr(47.32, 3) `= 47.3, floorr(117, "
|
||||
"1) `= 100.&][s14;:Calc`$CgeNN: [%00-00 operator >`= (real number, real number) ][%00-00S "
|
||||
"®][%00-00 logical value]&][s0; The operator will compare its operands returning "
|
||||
"the value 1 if the relation holds, 0 when not. String values are compared lexicographically "
|
||||
"([/ dictionary] organization).&][s14;:Calc`$ChypotNN: [%00-00 hypot (real number "
|
||||
"][%00-00/ x][%00-00 , real number ][%00-00/ y][%00-00 ) ][%00-00S ®][%00-00 real "
|
||||
"number]&][s0; The length of the hypotenuse of the right`-angled triangle. The hypotenuse "
|
||||
"is calculated using the Pythagoras theorem, [* hypot(][*/ x][* , ][*/ y][* ) `= sqrt(][*/ "
|
||||
"x][* `* ][*/ x][* `+ ][*/ y][* `* ][*/ y][* )].&][s0; &][s0; [* Example]: hypot(3, "
|
||||
"4) `= 5&][s14;:Calc`$CleNN: operator <`= (real number, real number) [S ®] logical "
|
||||
"value&][s0; The operator will compare its operands returning the value 1 if the relation "
|
||||
"holds, 0 when not. String values are compared lexicographically ([/ dictionary] organization).&][s14;:Calc`$ClogNotN: "
|
||||
"[%00-00 operator ! (real number) ][%00-00S ®][%00-00 logical value]&][s0; Logical "
|
||||
"negation. The result is the logical value 1 ([* true]), if the argument is zero (zero "
|
||||
"number or the logical value [* false]). If the argument is nonzero or if it contains "
|
||||
"the logical value [* true], the result of logical negation is the value 0 ([* false]). "
|
||||
"If the operator ! is applied to a string, the result will be 1 ([* true]) when and "
|
||||
"only when the string is empty.&][s0; &][s0; [* Example]: !10 `= 0, !0 `= 1, !`\"hello`\" "
|
||||
"`= 0&][s14;:Calc`$CltNN: operator < (real number, real number) [S ®] logical value&][s0; "
|
||||
"The operator will compare its operands returning the value 1 if the relation holds, "
|
||||
"0 when not. String values are compared lexicographically ([/ dictionary] organization).&][s14;:Calc`$CmaxNN: "
|
||||
"max (real number, real number) [S ®] real number&][s0; &]")
|
||||
TOPIC_TEXT(
|
||||
"[s14;:Calc`$CminNN: min (real number, real number) [S ®] real number&][s0; &][s14;:Calc`$CminmaxNNN: "
|
||||
"minmax (real number, real number, real number) [S ®] real number&][s0; &][s14;:Calc`$CminusN: "
|
||||
"[%00-00 operator `- (real number) ][%00-00S ®][%00-00 real number]&][s0; &][s0; "
|
||||
"Function returns number of minutes of its date/time argument.&][s14;:Calc`$CmodNN: "
|
||||
"[%00-00 operator % (real number ][%00-00/ a][%00-00 , real number ][%00-00/ b][%00-00 "
|
||||
") ][%00-00S ®][%00-00 real number]&][s0; Division remainder. The operator determines "
|
||||
"the least non`-negative real number which can be obtained by adding or subtraction "
|
||||
"any integral multiples of [/ b] to value [/ a]. If [/ b] zero, the computation aborts "
|
||||
"with the error [* division by zero].&][s0; &][s0; [* Example]: 10.5 % 2.4 `= 0.9 "
|
||||
"(10.5 `= 4 `* 2.4 `+ 0.9).&][s0; The function returns the month number of its argument.&][s0; "
|
||||
"&][s14;:Calc`$CmulNN: [%00-00 operator `* (real number, real number) ][%00-00S ®][%00-00 "
|
||||
" real number]&][s0; The product of two real numbers.&][s0; &][s0; [* Example]: 17 "
|
||||
"`* 15 `= 255.&][s14;:Calc`$CplusN: operator `+ (real number) [S ®] real number&][s0; "
|
||||
"&][s0; &][s14;:Calc`$CroundN: [%00-00 round (real number) ][%00-00S ®][%00-00 real "
|
||||
"number]&][s0; &][s14;:Calc`$CroundNN: [%00-00 round (real number ][%00-00/ value][%00-00 "
|
||||
", integer ][%00-00/ decimals][%00-00 ) ][%00-00S ®][%00-00 real number]&][s0; Rounding "
|
||||
"to the stated number of decimal places (0 by default). The direction of rounding "
|
||||
"is towards the nearest integral multiple of [* 10_`*`*_][/ `-decimals]. If the number "
|
||||
"lies exactly in the middle between two such numbers, it is rounded up (towards positive "
|
||||
"infinity).&][s0; &][s0; [* Example]: round(`-2.5) `= `-2, round(47.32, 1) `= 47.3, "
|
||||
"round(117, `-1) `= 120.&][s14;:Calc`$CroundrNN: [%00-00 roundr(real number ][%00-00/ "
|
||||
"value][%00-00 , integer ][%00-00/ significant`_digits][%00-00 ) ][%00-00S ®][%00-00 "
|
||||
" real number]&][s0; Rounding to the stated number of significant digits. The direction "
|
||||
"o")
|
||||
TOPIC_TEXT(
|
||||
"f rounding is towards the nearest integral multiple of [* 10_`*`*_][/ (ceil(log(value)`-significant`_digits)]. "
|
||||
"If the number lies exactly in the middle between two such nearest numbers, it is "
|
||||
"rounded up (towards positive infinity).&][s0; &][s0;* Example: roundr(47.32, 3) `= "
|
||||
"47.3, roundr(117, 1) `= 100.&][s0; &][s14;:Calc`$CsgnN: [%00-00 sgn (real number "
|
||||
"][%00-00/ x][%00-00 ) ][%00-00S ®][%00-00 integer]&][s0; Sign. The sign computation "
|
||||
"is based on the following table:&][s0; &][s0; &][s0; &][s0; [* Example]: sgn(`-13.5) "
|
||||
"`= `-1, sgn(0) `= 0, sgn(10) `= `+1.&][s14;:Calc`$CsqrN: [%00-00 sqr (real number "
|
||||
"][%00-00/ x][%00-00 ) ][%00-00S ®][%00-00 real number]&][s0; Square. The function "
|
||||
"returns the value [* sqr(][*/ x][* ) `= ][*/ x][* `* ][*/ x].&][s0; &][s0; [* Example]: "
|
||||
"sqr(12) `= 144&][s14;:Calc`$CsqrtN: [%00-00 sqrt (real number ][%00-00/ x][%00-00 "
|
||||
") ][%00-00S ®][%00-00 real number]&][s0; [%00-00 Squared root.]&][s0; &][s14;:Calc`$CsubNN: "
|
||||
"operator `- (real number, real number) [S ®] real number&][s0; &][s14;:Calc`$CgtNN: "
|
||||
"operator > (real number, real number) [S ®] logical value&][s0; The operator will "
|
||||
"compare its operands returning the value 1 if the relation holds, 0 when not. String "
|
||||
"values are compared lexicographically ([/ dictionary] organization).&][s0; &][s0; "
|
||||
"]")
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
TITLE("Zpracování polí hodnot")
|
||||
REF("Calc$CarrayIndex")
|
||||
REF("Calc$CcountA")
|
||||
REF("Calc$CleftAN")
|
||||
REF("Calc$CmidAN")
|
||||
REF("Calc$CmidANN")
|
||||
REF("Calc$CrightAN")
|
||||
REF("Calc$CsumA")
|
||||
REF("Calc$CsumASC")
|
||||
TOPIC_TEXT(
|
||||
"[2 $$0,0#00000000000000000000000000000000:Default][b100;a50;K* $$1,0#23046025415494101427921008701515:Paragraph][i167;b50;a25;kKN1;~~~>.3917;* "
|
||||
"$$2,0#52185223490867151055420261384346:Toc1`.Heading1][i333;kN11;~~~>.3917;* $$3,0#36545033421193513457240054113541:Toc2`.Heading2][i500;kN111;~~~>.3917; "
|
||||
"$$4,0#65092512416424580164828413186219:Toc3`.Heading3][i167;b50;a25;kKNA;~~~>.3917;* "
|
||||
"$$5,5#922913324743")
|
||||
TOPIC_TEXT(
|
||||
"08709450111162202673:AppToc1`.AppHeading1][i333;kNA1;~~~>.3917;* $$6,15#61887903412252554674480251236992:AppToc2`.AppHeading2][i500;kNA11;~~~>.3917; "
|
||||
"$$7,7#03533551421653050355120437860335:AppToc3`.AppHeading3][i500;b100;a100;KN1;*4 "
|
||||
"$$8,0#94145093439740438411010082165944:Heading1][i500;b100;a50;kKN11;*+117 $$9,0#10901425421210535753260366156531:Heading2][i500;b100;a25;kKN111;* "
|
||||
"$$10,0#53209141402041")
|
||||
TOPIC_TEXT(
|
||||
"366431858192225431:Heading3][i500;b100;a100;KNA;*4 $$11,8#32912651424211307887950041245434:AppHeading1][i500;b100;a50;kKNA1;*+117 "
|
||||
"$$12,8#51232055453458524230328032001901:AppHeading2][i500;b100;a25;kKNA11;* $$13,8#34108020439428305453439845463579:AppHeading3][b100;a50;k*4 "
|
||||
"$$14,0#49239115434362547028389207250014:Heading][b50;a25;k~~~>.3917;* $$15,15#40743698422276745552070108434023:Toc`.Heading][b10")
|
||||
TOPIC_TEXT(
|
||||
"0;a50;K~~~>.3917;*+117 $$16,16#15422850471211852294098111138263:Topics1][l167;b50;a50;K~~~>.3917;* "
|
||||
"$$17,17#35241722455500657380289596243808:Topics2][l333;~~~>.3917; $$18,18#31041344429742018840308064013200:Topics3][b83;a42;K* "
|
||||
"$$19,0#46440151113795363000000595230845:Paragraph][{_}%EN-US [s14; oper\303\241tor "
|
||||
"`+ (pole hodnot, pole hodnot) [S \302\256] pole hodnot&][s0; Oper\303\241tor spoj\303\255 "
|
||||
"dv\304\233 pole (za\305\231ad\303\255 jeji")
|
||||
TOPIC_TEXT(
|
||||
"ch jednotliv\303\251 prvky za sebe).&][s14;:Calc`$CarrayIndex: [%00-00 oper\303\241tor "
|
||||
"`[`] (pole hodnot, cel\303\251 \304\215\303\255slo) ][%00-00S \302\256][%00-00 "
|
||||
"libovoln\303\275 typ]&][s0; Oper\303\241tor vr\303\241t\303\255 prvek pole na dan\303\251 "
|
||||
"pozici. Prvky pole jsou indexov\303\241ny od 0, posledn\303\255 prvek m\303\241 index "
|
||||
"[/ pole.count]`-1.&][s0; &][s0; [* P\305\231\303\255klad: ]`[`\"index0`\", `\"index1`\", "
|
||||
"`\"index2`\"`]`[1`] `= `\"index1`\"&][s0;* [* Pomoc\303\255 konstruktu ]`[a .")
|
||||
TOPIC_TEXT(
|
||||
". b`][* lze vytvo\305\231it pole hodnot z_dan\303\251ho intervalu. V\303\275sledn\303\251 "
|
||||
"pole bude obsahovat hodnoty ]`[a,a`+1,a`+2,...,[* round(]b[* )]`].&][s14;:Calc`$CcountA: "
|
||||
"[%00-00 count (pole hodnot) ][%00-00S \302\256][%00-00 cel\303\251 \304\215\303\255slo]&][s0; "
|
||||
"Funkce vr\303\241t\303\255 po\304\215et prvk\305\257 zadan\303\251ho pole.&][s0; "
|
||||
"&][s0; [* P\305\231\303\255klad: ]count(`[3..6`]) `= 4&][s14;:Calc`$CleftAN: [%00-00 "
|
||||
"group(pole hodnot ][%00-00/ data][%00-00 , pole h")
|
||||
TOPIC_TEXT(
|
||||
"odnot ][%00-00/ skupiny][%00-00 , \305\231et\304\233zec ][%00-00/ prom\304\233nn\303\241][%00-00 "
|
||||
", lambda`-v\303\275raz ][%00-00/ seskupit][%00-00 , lambda`-v\303\275raz ][%00-00/ "
|
||||
"v\303\275stup][%00-00 )] [S \302\256] pole hodnot&][s14;:Calc`$CleftAN: [%00-00 group(pole "
|
||||
"hodnot ][%00-00/ data][%00-00 , pole hodnot ][%00-00/ skupiny][%00-00 , \305\231et\304\233zec "
|
||||
"][%00-00/ prom\304\233nn\303\241][%00-00 , lambda`-v\303\275raz ][%00-00/ seskupit][%00-00 "
|
||||
")] [S \302\256] pole hodnot&")
|
||||
TOPIC_TEXT(
|
||||
"][s0; Funkce p\305\231eskup\303\255 hodnoty v zadan\303\251m poli [/ data] v z\303\241vislosti "
|
||||
"na obsahu \305\231\303\255dic\303\255ho pole [/ skupiny]. V\303\275sledkem funkce "
|
||||
"je pole se stejn\303\275m po\304\215tem prvk\305\257, jako m\303\241 pole [/ skupiny]. "
|
||||
"Pro ka\305\276d\303\275 prvek pole [/ data] (p\305\231i\305\231azen\303\275 do prom\304\233nn\303\251 "
|
||||
"[/ prom\304\233nn\303\241]) se nejprve vypo\304\215te lambda`-v\303\275raz [/ seskupit] "
|
||||
"a jeho v\303\275sledek se vyhled\303\241 v poli [/ skupiny]. Pokud hodnota v poli "
|
||||
"nen\303\255 nalezena")
|
||||
TOPIC_TEXT(
|
||||
", prvek se ignoruje. Pokud hodnota nalezena je, vypo\304\215\303\255t\303\241 se "
|
||||
"lambda`-v\303\275raz [/ v\303\275stup] a jeho v\303\275sledek se p\305\231i\304\215te "
|
||||
"k stejnolehl\303\251mu prvku v\303\275stupn\303\255mu pole hodnot, tedy k prvku se "
|
||||
"stejn\303\275m indexem, jako pod kter\303\275m byla v poli [/ skupiny] nalezena hodnota "
|
||||
"vypo\304\215ten\303\241 v\303\275razem [/ seskupit]. S\304\215\303\255t\303\241n\303\255 "
|
||||
"v\303\275stupn\303\255ch hodnot pracuje stejn\304\233 jako v p\305\231\303\255pad\304\233 "
|
||||
"funkce [/ sum], tedy pokud funkce [/ v\303")
|
||||
TOPIC_TEXT(
|
||||
"\275stup] vytv\303\241\305\231\303\255 hodnoty typu [/ \304\215\303\255slo], v\303\275sledn\303\251 "
|
||||
"prvky pole budou obsahovat sou\304\215ty t\304\233chto hodnot; pokud funkce vytv\303\241\305\231\303\255 "
|
||||
"\305\231et\304\233zce, v\303\275sledn\303\251 prvky pole budou obsahovat spojen\303\255 "
|
||||
"t\304\233chto \305\231et\304\233zc\305\257 za sebe, a v p\305\231\303\255pad\304\233 "
|
||||
"pol\303\255 budou ve v\303\275stupn\303\255m poli prvky vytvo\305\231en\303\251 spojen\303\255m "
|
||||
"d\303\255l\304\215\303\255ch pol\303\255.&][s0; &][s0; Posledn\303\255 parametr [/ "
|
||||
"v\303\275stup] je nepovinn\303\275; pokud nen\303\255 zad\303\241n, pou\305\276ije "
|
||||
"se ")
|
||||
TOPIC_TEXT(
|
||||
"jako v\303\275stupn\303\255 hodnota pr\303\241v\304\233 zpracov\303\241van\303\275 "
|
||||
"prvek vstupn\303\255ho pole [/ data].&][s0; &][s0;* P\305\231\303\255klad:&][s0; "
|
||||
"group(`[`[4, `\"D`\"`], `[2, `\"B`\"`], `[4, `\"C`\"`], `[1, `\"A`\"`]`], `[1, 2, "
|
||||
"3, 4`], `\"x`\", #(x`[0`]), #(`[x`[1`]`])) [S \302\256] `[`[`\"A`\"`], `[`\"B`\"`], "
|
||||
"null, `[`\"D`\", `\"C`\"`]`]&][s0; group(`[`[4, `\"D`\"`], `[2, `\"B`\"`], `[4, `\"C`\"`], "
|
||||
"`[1, `\"A`\"`]`], `[1, 2, 3, 4`], `\"x`\", #(x`[0`])) [S \302\256 ]`[`[1,")
|
||||
TOPIC_TEXT(
|
||||
" `\"A`\"`], `[2, `\"B`\"`], null, `[4, `\"D`\", 4, `\"C`\"`]`]&][s14; [%00-00 left "
|
||||
"(pole hodnot, cel\303\251 \304\215\303\255slo ][%00-00/ po\304\215et][%00-00 ) ][%00-00S "
|
||||
"\302\256][%00-00 pole hodnot]&][s0; Funkce vr\303\241t\303\255 pole obsahuj\303\255c\303\255 "
|
||||
"prvn\303\255ch [* po\304\215et] hodnot zadan\303\251ho pole hodnot. Pokud je hodnota "
|
||||
"[* po\304\215et] men\305\241\303\255 nebo rovna nule, funkce vr\303\241t\303\255 "
|
||||
"pr\303\241zdn\303\251 pole. Pokud je hodnota [* po\304\215et] v\304\233t\305\241\303\255 "
|
||||
"ne\305\276 po\304\215et prvk\305\257 pole, ")
|
||||
TOPIC_TEXT(
|
||||
"funkce vr\303\241t\303\255 p\305\257vodn\303\255 pole beze zm\304\233ny.&][s0; &][s0; "
|
||||
"[* P\305\231\303\255klad: ]left(`{1, 2, 3, 5, 8, 13`}, 4) `= `{1, 2, 3, 5`}&][s14;:Calc`$CmidAN: "
|
||||
"[%00-00 mid (pole hodnot, cel\303\251 \304\215\303\255slo ][%00-00/ i][%00-00 ) ][%00-00S "
|
||||
"\302\256][%00-00 pole hodnot]&][s0; Funkce vr\303\241t\303\255 ze zadan\303\251ho "
|
||||
"pole [* i]`-t\303\275 a\305\276 posledn\303\255 prvek. Prvn\303\255 prvek pole m\303\241 "
|
||||
"index 0.&][s0; &][s0; [* P\305\231\303\255klad: ]mid(`[`\"A`\", `\"B`\", `\"C`\", "
|
||||
"`\"D`\"")
|
||||
TOPIC_TEXT(
|
||||
", `\"E`\"`], 2) `= `[`\"C`\", `\"D`\", `\"E`\"`]&][s0;* &][s14;:Calc`$CmidANN: [%00-00 "
|
||||
"mid (pole hodnot, cel\303\251 \304\215\303\255slo ][%00-00/ i][%00-00 , cel\303\251 "
|
||||
"\304\215\303\255slo ][%00-00/ po\304\215et][%00-00 ) ][%00-00S \302\256][%00-00 "
|
||||
"pole hodnot]&][s0; Funkce vr\303\241t\303\255 ze zadan\303\251ho pole [* po\304\215et] "
|
||||
"prvk\305\257 po\304\215\303\255naje [* i]`-t\303\275m prvkem. Prvn\303\255 prvek "
|
||||
"pole m\303\241 index 0.&][s0; &][s0; [* P\305\231\303\255klad: ]mid(`[`\"A`\", `\"B`\", "
|
||||
"`\"C`\", `\"D`\", `\"E`\"`], 2")
|
||||
TOPIC_TEXT(
|
||||
", 2) `= `[`\"C`\", `\"D`\"`]&][s14;:Calc`$CrightAN: [%00-00 right (pole hodnot, "
|
||||
"cel\303\251 \304\215\303\255slo ][%00-00/ po\304\215et][%00-00 ) ][%00-00S \302\256][%00-00 "
|
||||
" pole hodnot]&][s0; Funkce vr\303\241t\303\255 posledn\303\255ch [* po\304\215et] "
|
||||
"hodnot z_konce zadan\303\251ho pole. Pokud je [* po\304\215et <`= 0], funkce vr\303\241t\303\255 "
|
||||
"pr\303\241zdn\303\251 pole. Je`-li [* po\304\215et ]v\304\233t\305\241\303\255 nebo "
|
||||
"roven po\304\215tu prvk\305\257 vstupn\303\255ho pole, funkce vr\303\241t\303\255 "
|
||||
"toto pole beze zm\304\233ny.&][s0; &]")
|
||||
TOPIC_TEXT(
|
||||
"[s0; [* P\305\231\303\255klad:] right(`[1..5`], 3) `= `[3, 4, 5`]&][s14;:Calc`$CsumA: "
|
||||
"[%00-00 sum (pole hodnot) ][%00-00S \302\256][%00-00 libovoln\303\275 typ]&][s0; "
|
||||
"Funkce vr\303\241t\303\255 sou\304\215et hodnot zadan\303\251ho pole. Pokud pole "
|
||||
"obsahuje jako prvky \304\215\303\255seln\303\251 hodnoty, funkce vr\303\241t\303\255 "
|
||||
"\304\215\303\255seln\303\275 sou\304\215et t\304\233chto hodnot. Pokud pole obsahuje "
|
||||
"\305\231et\304\233zce, funkce vr\303\241t\303\255 spojen\303\255 t\304\233chto \305\231et\304\233zc\305\257. "
|
||||
"P\305\231\303\255padn\303\251 hodnoty [* null] v_pol")
|
||||
TOPIC_TEXT(
|
||||
"i se ignoruj\303\255.&][s0; &][s0; [* P\305\231\303\255klad: ]sum(`{1..5`}) `= 15&][s14;:Calc`$CsumASC: "
|
||||
"[%00-00 sum(pole hodnot, \305\231et\304\233zec ][%00-00/ identifik\303\241tor][%00-00 "
|
||||
", lambda`-v\303\275raz) ][%00-00S \302\256][%00-00 libovoln\303\275 typ]&][s0; Funkce "
|
||||
"se\304\215te / spoj\303\255 hodnoty vypo\304\215ten\303\251 zadan\303\275m [* lambda`-v\303\275razem] "
|
||||
"z[/ ]prvk\305\257 zadan\303\251ho pole. [/ Lambda`-v\303\275raz] sm\303\255 pou\305\276\303\255vat "
|
||||
"zadan\303\275 [* identifik\303\241tor] pro p\305\231\303\255stup k aktu")
|
||||
TOPIC_TEXT(
|
||||
"\303\241ln\303\255mu prvku pole. V\303\275sledky v\303\275razu mus\303\255 b\303\275t "
|
||||
"jednoho z_podporovan\303\275ch datov\303\275ch typ\305\257:&][s0; &][s0;i150;O0;+-83 "
|
||||
"[* \304\215\303\255slo] `- funkce vr\303\241t\303\255 sou\304\215et v\305\241ech "
|
||||
"t\304\233chto \304\215\303\255sel; prvky obsahuj\303\255c\303\255 hodnotu [* null] "
|
||||
"se ignoruj\303\255&][s0;i150;O0;+-83 [* \305\231et\304\233zec] `- funkce vr\303\241t\303\255 "
|
||||
"spojen\303\255 v\305\241ech t\304\233chto \305\231et\304\233zc\305\257&][s0;i150;O0;+-83 "
|
||||
"[* pole] `- funkce vr\303\241t\303\255 spojen\303\255 v\305\241ech t\304\233chto "
|
||||
"pol\303\255&][s0;i200;+-")
|
||||
TOPIC_TEXT(
|
||||
"83 &][s0;+-83 [* P\305\231\303\255klad:] `[1, 4, 7`].sum(`\"X`\", #(X`*X)) `= 66, "
|
||||
"`[1, 4, 7`].sum(`\"T`\", #(T.text)) `= `\"147`\"&][s0; Funkce p\305\231evede zadan\303\251 "
|
||||
"pole na standardn\303\255 textovou reprezentaci ve tvaru&][s0; &][s0; `[[/ prvn\303\255 "
|
||||
"prvek, druh\303\275 prvek, t\305\231et\303\255 prvek...]`]&][s0; &][s0; [* P\305\231\303\255klad:] "
|
||||
"`[0.0, 1.0, 2.5`].text `= `\"`[0, 1, 2.5`]`\"&][s0; &][s0;* &][s0; &][s0; &][s0; "
|
||||
"&][s0; &][s0;3 ]")
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
TITLE("Array processing functions")
|
||||
REF("Calc$CaddAA")
|
||||
REF("Calc$CarrayIndex")
|
||||
REF("Calc$CcountA")
|
||||
REF("Calc$CleftAN")
|
||||
REF("Calc$CmidAN")
|
||||
REF("Calc$CmidANN")
|
||||
REF("Calc$CrightAN")
|
||||
REF("Calc$CsumA")
|
||||
REF("Calc$CsumASC")
|
||||
TOPIC_TEXT(
|
||||
"[2 $$0,0#00000000000000000000000000000000:Default][b100;a50;K* $$1,0#23046025415494101427921008701515:Paragraph][i167;b50;a25;kKN1;~~~>.3917;* "
|
||||
"$$2,0#52185223490867151055420261384346:Toc1`.Heading1][i333;kN11;~~~>.3917;* $$3,0#36545033421193513457240054113541:Toc2`.Heading2][i500;kN111;~~~>.3917; "
|
||||
"$$4,0#65092512416424580164828413186219:Toc3`.Heading3][i167;b50;a25;kKNA;~~~>.3917;* "
|
||||
"$$5,5#92291332474308709450111162202673:AppToc1`.AppHeading1][i333;kNA1;~~~>.3917;* "
|
||||
"$$6,15#61887903412252554674480251236992:AppToc2`.AppHeading2][i500;kNA11;~~~>.3917; "
|
||||
"$$7,7#03533551421653050355120437860335:AppToc3`.AppHeading3][i500;b100;a100;KN1;*4 "
|
||||
"$$8,0#94145093439740438411010082165944:Heading1][i500;b100;a50;kKN11;*+117 $$9,0#10901425421210535753260366156531:Heading2][i500;b100;a25;kKN111;* "
|
||||
"$$10,0#53209141402041366431858192225431:Heading3][i500;b100;a100;KNA;*4 $$11,8#32912651424211307887950041245434:AppHeading1][i500;b100;a50;kKNA1;*+117 "
|
||||
"$$12,8#51232055453458524230328032001901:AppHeading2][i500;b100;a25;kKNA11;* $$13,8#34108020439428305453439845463579:AppHeading3][b100;a50;k*4 "
|
||||
"$$14,0#49239115434362547028389207250014:Heading][b50;a25;k~~~>.3917;* $$15,15#40743698422276745552070108434023:Toc`.Heading][b100;a50;K~~~>.3917;*+117 "
|
||||
"$$16,16#15422850471211852294098111138263:Topics1][l167;b50;a50;K~~~>.3917;* $$17,17#35241722455500657380289596243808:Topics2][l333;~~~>.3917; "
|
||||
"$$18,18#31041344429742018840308064013200:Topics3][b83;a42;K* $$19,0#46440151113795363000000595230845:Paragraph][{_}%EN-US "
|
||||
"[s14;:Calc`$CaddAA: operator `+ (pole hodnot, pole hodnot) [S ®] pole hodnot&][s0; "
|
||||
"&][s14;:Calc`$CarrayIndex: operator `[`] (pole hodnot, integer) [S ®] any data "
|
||||
"type&][s0; &][s0; [* Example]: mesic(27.5.1984) `= 5&][s0; The binary operator [* "
|
||||
"`*] evaluates the [/ lambda`-expression] for each element of the original array and "
|
||||
"returns an array composed of the results. The output array has always the same number "
|
||||
"of elements as the input array. During evaluation of the lambda`-expression for each "
|
||||
"input arra")
|
||||
TOPIC_TEXT(
|
||||
"y element the calculator variable [* I] is set to the index of the current array "
|
||||
"element (first array element has index 0) and the variable [* A] contains the value "
|
||||
"of the array element being processed.&][s14;:Calc`$CcountA: count (pole hodnot) [S "
|
||||
"®] integer&][s14;:Calc`$CleftAN: [%00-00 left (pole hodnot, integer) ][%00-00S ®][%00-00 "
|
||||
" pole hodnot]&][s0; &][s14;:Calc`$CmidAN: [%00-00 mid (pole hodnot, integer) ][%00-00S "
|
||||
"®][%00-00 pole hodnot]&][s0; &][s14;:Calc`$CmidANN: [%00-00 mid (pole hodnot, integer, "
|
||||
"integer) ][%00-00S ®][%00-00 pole hodnot]&][s0; &][s14;:Calc`$CrightAN: [%00-00 "
|
||||
"right (pole hodnot, integer) ][%00-00S ®][%00-00 pole hodnot]&][s0; &][s14;:Calc`$CsumA: "
|
||||
"sum (pole hodnot) [S ®] any data type&][s0; &][s14;:Calc`$CsumASC: [%00-00 sum(pole "
|
||||
"hodnot, string ][%00-00/ identifier][%00-00 , lambda`-výraz) ][%00-00S ®][%00-00 "
|
||||
" any data type]&][s0; Function adds / concatenates values calculated from the members "
|
||||
"of its input array using a given [/ lambda`-expression]. [/ Lambda`-expressions] "
|
||||
"may use the given [/ identifier] to access the current array element. The calculated "
|
||||
"values must be of one of the supported types:&][s0; &][s0;i150;O0;+-83 [* numbers] "
|
||||
"`- function returns the arithmetic sum of all such numbers; elements containing the "
|
||||
"[* null] value are ignored&][s0;i150;O0;+-83 [* strings] `- function returns the "
|
||||
"string concatenation of all string values&][s0;i150;O0;+-83 [* arrays] `- function "
|
||||
"returns the array concatenation of all arrays&][s0;*+-83 &][s0;+-83 [*2 Example:][2 "
|
||||
" ]`[1, 4, 7`].sum(`\"X`\", #(X`*X)) `= 66, `[1, 4, 7`].sum(`\"T`\", #(T.text)) `= "
|
||||
"`\"147`\"&][s0; Function converts an array to its standard textual representation "
|
||||
"in the format&][s0; &][s0; `[[/ first element, second element, third element...]`]&][s0; "
|
||||
"&][s0; [* Example:] `[0.0, 1.0, 2.5`].text `= `\"`[0, 1, 2.5`]`\"&][s0; &][s0; ]")
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
TITLE("Funkce pro práci s datem / časem")
|
||||
REF("Calc$CaddDN")
|
||||
REF("Calc$CaddND")
|
||||
REF("Calc$Cadd_monthsDN")
|
||||
REF("Calc$Cadd_yearsDN")
|
||||
REF("Calc$CdateN")
|
||||
REF("Calc$CdateNN")
|
||||
REF("Calc$CdateNNN")
|
||||
REF("Calc$Cday_of_weekD")
|
||||
REF("Calc$Cfirst_day_of_monthD")
|
||||
REF("Calc$CgeTT")
|
||||
REF("Calc$CgtTT")
|
||||
REF("Calc$Clast_day_of_monthD")
|
||||
REF("Calc$CleTT")
|
||||
REF("Calc$CltTT")
|
||||
REF("Calc$CmaxTT")
|
||||
REF("Calc$CminTT")
|
||||
REF("Calc$CminmaxTTT")
|
||||
REF("Calc$CsubDD")
|
||||
REF("Calc$CsubDN")
|
||||
REF("Calc$CtimeNNNNNN")
|
||||
REF("Calc$Cyears_betweenDD")
|
||||
TOPIC_TEXT(
|
||||
"[2 $$0,0#00000000000000000000000000000000:Default][b100;a50;K* $$1,0#23046025415494101427921008701515:Paragraph][i167;b50;a25;kKN1;~~~>.3917;* "
|
||||
"$$2,0#52185223490867151055420261384346:Toc1`.Heading1][i333;kN11;~~~>.3917;* $$3,0#36545033421193513457240054113541:Toc2`.Heading2][i500;kN111;~~~>.3917; "
|
||||
"$$4,0#65092512416424580164828413186219:Toc3`.Heading3][i167;b50;a25;kKNA;~~~>.3917;* "
|
||||
"$$5,5#92291332474308709450111162202673:AppToc1`.AppHeading1][i333;kNA1;~~~>.3917;* "
|
||||
"$$6,15#61887903412252554674480251236992:AppToc2`.AppHeading2][i500;kNA11;~~~>.3917; "
|
||||
"$$7,7#03533551421653050355120437860335:AppToc3`.AppHeading3][i500;b100;a100;KN1;*4 "
|
||||
"$$8,0#94145093439740438411010082165944:Heading1][i500;b100;a50;kKN11;*+117 $$9,0#10901425421210535753260366156531:Heading2][i500;b100;a25;kKN111;* "
|
||||
"$$10,0#53209141402041366431858192225431:Heading3][i500;b100;a100;KNA;*4 $$11,8#32912651424211307887950041245434:AppHeading1][i500;b100;a50;kKNA1;*+117 "
|
||||
"$$12,8#51232055453458524230328032001901:AppHeading2][i500;b100;a25;kKNA11;* $$13,8#34108020439428305453439845463579:AppHeading3][b100;a50;k*4 "
|
||||
"$$14,0#49239115434362547028389207250014:Heading][b50;a25;k~~~>.3917;* $$15,15#40743698422276745552070108434023:Toc`.Heading][b100;a50;K~~~>.3917;*+117 "
|
||||
"$$16,16#15422850471211852294098111138263:Topics1][l167;b50;a50;K~~~>.3917;* $$17,17#35241722455500657380289596243808:Topics2][l333;~~~>.3917; "
|
||||
"$$18,18#31041344429742018840308064013200:Topics3][b83;a42;K* $$19,0#46440151113795363000000595230845:Paragraph][{_}%EN-US "
|
||||
"[s14;:Calc`$CaddDN: [%00-00 operátor `+ (datum/čas, reálné číslo) ][%00-00S "
|
||||
"®][%00-00 datum/čas]&][s0; Operátor posune zadané datum o_daný počet dní "
|
||||
"(dopředu, pokud je číslo kladné). Počet dní může být i neceločíselný, "
|
||||
"v_tom případě se posune i číslo sekundy, minuty a hodiny.&][s0; &][s0; [* Příklad: "
|
||||
"]27.12.1999 `+ 7 `= 3.1.2000&][s14;:Calc`$CaddND: [%00-00 operátor `+ (reálné "
|
||||
"číslo, datum/čas) ][%00-00S ®][%00-00 datum/čas]&][s0; Operátor posune zadané "
|
||||
"datum o_d")
|
||||
TOPIC_TEXT(
|
||||
"aný počet dní (dopředu, pokud je číslo kladné). Počet dní může být i "
|
||||
"neceločíselný, v_tom případě se posune i číslo sekundy, minuty a hodiny.&][s0; "
|
||||
"&][s0; [* Příklad: ]27.12.1999 `+ 7 `= 3.1.2000&][s14;:Calc`$Cadd`_monthsDN: [%00-00 "
|
||||
"add`_months (datum, celé číslo ][%00-00/ počet`_měsíců][%00-00 ) ][%00-00S "
|
||||
"®][%00-00 datum]&][s0; Funkce přičte k datu zadaný [/ počet měsíců]. Pokud "
|
||||
"cílový měsíc má méně dní, než je číslo dne v měsíci v původním datu, "
|
||||
"nastaví se číslo dne na číslo posledního dne v cílovém měsíci.&][s0; &][s0; "
|
||||
"[* Příklad: ]add`_months(29.2.1996, 12) `= 28.2.1997&][s14;:Calc`$Cadd`_yearsDN: "
|
||||
"[%00-00 add`_years (datum, celé číslo ][%00-00/ počet`_let][%00-00 ) ][%00-00S "
|
||||
"®][%00-00 datum]&][s0; Funkce přičte k datu zadaný [/ počet let]. Pokud původní "
|
||||
"datum je 29.2. v přestupném roce a cílový rok není přestupný, změní se číslo "
|
||||
"dne na 28.&][s0; &][s0; [* Příklad: ]add`_years(29.2.1992, 3) `= 28.2.1995&][s14;:Calc`$CdateN: "
|
||||
"[%00-00 date (celé číslo ][%00-00/ den][%00-00 ) ][%00-00S ®][%00-00 datum]&][s0; "
|
||||
"Funkce vrátí aktuální systémové datum, ve kterém zamění číslo dne hodnotou "
|
||||
"zadaného parametru [* den].&][s0; &][s0; Viz také:&][s0;i150;O0;*^dpp`:`/`/AppDoc`/`/`:`:`/`/Calc`$CdateNN^ "
|
||||
"date (celé číslo [/ den], celé číslo [/ měsíc]) [S ®] datum&][s0;i150;O0;*^dpp`:`/`/AppDoc`/`/`:`:`/`/Calc`$CdateNNN^ "
|
||||
"date (celé číslo [/ den], celé číslo [/ měsíc], celé číslo [/ rok]) [S "
|
||||
"®] datum&][s14;:Calc`$CdateNN: [%00-00 date (celé číslo ][%00-00/ den][%00-00 "
|
||||
", celé číslo ][%00-00/ měsíc][%00-00 ) ][%00-00S ®][%00-00 datum]&][s0; Funkce "
|
||||
"vrátí aktuální systémové datum, ve kterém zamění číslo dne hodnotou zadaného "
|
||||
"parametru [/ den] a číslo měsíce hodnotou parametru [/ měsíc].&][s14;:Calc`$CdateNNN: "
|
||||
"[%00-00 date (celé číslo ][%00-00/ den][%00-00 , celé číslo ][%00-00/ měsíc][%00-00 "
|
||||
", celé číslo ][%00-00/ rok][%00-0")
|
||||
TOPIC_TEXT(
|
||||
"0 ) ][%00-00S ®][%00-00 datum]&][s0; Funkce sestaví datum ze zadaných položek. "
|
||||
"Funkce bez parametru vrátí dnešní datum, zjištěné ze systému. Funkce s_jedním "
|
||||
"parametrem [/ den] vrátí den se zadaným číslem v_aktuálním měsíci. Funkce "
|
||||
"se dvěma parametry [/ den], [/ měsíc] vrátí den se zadaným číslem dne a_měsíce "
|
||||
"v_aktuálním roce. Varianta se třemi parametry pouze sestaví datum ze zadaných "
|
||||
"součástí.&][s0;* &][s0; [* Příklad: ]date `= 19.06.2003, date(10) `= 10.06.2003, "
|
||||
"date(15, 7) `= 15.07.2003, date(25, 1, 1974) `= 25.01.1974&][s0; [Idatum`, funkce; "
|
||||
"Funkce] vrátí číslo dne v měsíci pro zadané datum.&][s0; &][s0; [* Příklad: "
|
||||
"]den(27.5.1984) `= 27&][s14;:Calc`$Cday`_of`_weekD: [%00-00 day`_of`_week (datum) "
|
||||
"][%00-00S ®][%00-00 celé číslo]&][s0; Funkce vrátí index dne v_týdnu pro "
|
||||
"zadané datum. Prvním dnem v_týdnu s_indexem 0 je pro tuto funkci [* neděle], "
|
||||
"posledním dnem je [* sobota] s_indexem 6.&][s0; &][s0; [* Příklad: ]day`_of`_week(19.06.2003) "
|
||||
"`= 4&][s14;:Calc`$Cfirst`_day`_of`_monthD: [%00-00 first`_day`_of`_month (datum ][%00-00/ "
|
||||
"d][%00-00 ) ][%00-00S ®][%00-00 datum]&][s0; Funkce vrátí datum prvního dne "
|
||||
"v měsíci určeném parametrem [/ d].&][s0; &][s0; [* Příklad: ]first`_day`_of`_month(18.3.1994) "
|
||||
"`= 1.3.1994&][s14;:Calc`$CgeTT: [%00-00 operátor >`= (datum/čas ][%00-00/ dt1][%00-00 "
|
||||
", datum/čas ][%00-00/ dt2][%00-00 ) ][%00-00S ®][%00-00 logická hodnota]&][s0; "
|
||||
"Funkce porovná zadaná data / časy a vrátí hodnotu [/ pravda], pokud je [/ datum/čas1] "
|
||||
"pozdější nebo roven času [/ datum/čas2].&][s0; &][s0; [* Příklad: ](15.1.2004 "
|
||||
">`= 13.3.2003) `= 1&][s14;:Calc`$CgtTT: [%00-00 operátor > (datum/čas ][%00-00/ "
|
||||
"dt1][%00-00 , datum/čas ][%00-00/ dt2][%00-00 ) ][%00-00S ®][%00-00 logická hodnota]&][s0; "
|
||||
"Funkce porovná zadaná data / časy a vrátí hodnotu [/ pravda], pokud je [/ dt1] "
|
||||
"pozdější než [/ dt2].&][s0; &][s0; [* Příklad: ](15.1.2004 > 13.3.2003) `= "
|
||||
"1, (15.1.2004 > ")
|
||||
TOPIC_TEXT(
|
||||
"15.1.2004) `= 0&][s0; Funkce vrátí počet hodin svého argumentu typu datum/čas.&][s14;:Calc`$Clast`_day`_of`_monthD: "
|
||||
"[%00-00 last`_day`_of`_month (datum ][%00-00/ d][%00-00 ) ][%00-00S ®][%00-00 datum]&][s0; "
|
||||
"Funkce vrátí datum posledního dne v měsíci určeném parametrem [/ d].&][s0; "
|
||||
"&][s0; [* Příklad]: last`_day`_of`_month(3.2.1999) `= 28.2.1999&][s14;:Calc`$CleTT: "
|
||||
"[%00-00 operátor <`= (datum/čas, datum/čas) ][%00-00S ®][%00-00 logická hodnota]&][s0; "
|
||||
"Funkce porovná zadaná data / časy a vrátí hodnotu [/ pravda], pokud je [* datum/čas1] "
|
||||
"dřívější nebo roven času [* datum/čas2].&][s0; &][s0; [* Příklad: ](15.1.2003 "
|
||||
"< 13.3.2003) `= 1&][s14;:Calc`$CltTT: [%00-00 operátor < (datum/čas ][%00-00/ "
|
||||
"dt1][%00-00 , datum/čas ][%00-00/ dt2][%00-00 ) ][%00-00S ®][%00-00 logická hodnota]&][s0; "
|
||||
"Funkce porovná zadaná data / časy a vrátí hodnotu [/ pravda], pokud je čas "
|
||||
"[* dt1] dřívější než [* dt2].&][s0; &][s0; [* Příklad: ](15.1.2003 < 13.3.2003) "
|
||||
"`= 1&][s0; Funkce vrátí maximum z hodnot v daném poli. Pokud pole obsahuje řetězce, "
|
||||
"provede se jejich lexikografické srovnání.&][s0; &][s0; [* Příklad: ]max(`[8, "
|
||||
"5, 13, 2, 9`]) `= 13&][s14;:Calc`$CmaxTT: [%00-00 max (datum/čas, datum/čas) ][%00-00S "
|
||||
"®][%00-00 datum/čas]&][s0; Funkce vrátí větší z_dvojice zadaných dat/časů "
|
||||
"(pozdější čas/datum). Pokud je některý z parametrů roven [* null], je výsledkem "
|
||||
"funkce také [* null].&][s0; &][s0; [* Příklad: ]max(3.5.1994, 7.8.1998) `= 7.8.1998&][s14;:Calc`$CminTT: "
|
||||
"[%00-00 min (datum/čas, datum/čas) ][%00-00S ®][%00-00 datum/čas]&][s0; Funkce "
|
||||
"vrátí minimum ze dvou časů (dřívější z obou časů). Pokud je některý "
|
||||
"z parametrů roven [* null], je výsledkem funkce také [* null].&][s0;* &][s0; [* "
|
||||
"Příklad: ]min(1.8.1995, 3.6.1997) `= 1.8.1995&][s14;:Calc`$CminmaxTTT: [%00-00 "
|
||||
"minmax (datum/čas, datum/čas, datum/čas) ][%00-00S ®][%00-00 datum/čas]&][s0; "
|
||||
"Funkce vrátí hodnotu [* min(max(x, xmin), x")
|
||||
TOPIC_TEXT(
|
||||
"max)]. Pokud je některý z parametrů roven [* null], je výsledek také [* null].&][s0; "
|
||||
"&][s0; [* Příklad: ]minmax(3.1.1990, 8.8.1994, 2.5.1997) `= 8.8.1994, minmax(7.6.1995, "
|
||||
"8.8.1994, 2.5.1997) `= 7.6.1995, minmax(20.12.2003, 8.8.1994, 2.5.1997) `= 2.5.1997&][s14;:Calc`$CsubDD: "
|
||||
"[%00-00 operátor `- (datum/čas ][%00-00/ datum1][%00-00 , datum/čas ][%00-00/ "
|
||||
"datum2][%00-00 ) ][%00-00S ®][%00-00 reálné číslo]&][s0; Unární operátor "
|
||||
"[* `-] obrátí znaménko svého argumentu.&][s0; &][s0; Binární operátor [* `-] "
|
||||
"odečte své operandy. V_případě dvojice čísel je výsledkem běžný číselný "
|
||||
"rozdíl hodnot. V_případě rozdílu data a_celého čísla se od data odečte zadaný "
|
||||
"počet dní. Výsledkem rozdílu dvou dat je počet dní mezi nimi. Počet je kladný, "
|
||||
"pokud je první datum pozdější než druhé.&][s0; &][s0; [* Příklad]: 137 `- "
|
||||
"95 `= 42, 27.12.1999 `- 5 `= 22.12.1999, 4.1.2000 `- 28.12.1999 `= 7&][s14;:Calc`$CsubDN: "
|
||||
"[%00-00 operátor `- (datum/čas ][%00-00/ d][%00-00 , reálné číslo ][%00-00/ "
|
||||
"počet`_dní][%00-00 ) ][%00-00S ®][%00-00 datum/čas]&][s0; Operátor odečte "
|
||||
"od zadaného data/času [* d] zadaný [* počet dní]. Pokud je počet dní neceločíselný, "
|
||||
"posune se i číslo hodiny, minuty a sekundy. &][s0; &][s0; [* Příklad: ]11.6.2000 "
|
||||
"`+ 11.25 `= 22.6.2000 06:00:00&][s14;:Calc`$CtimeNNNNNN: [%00-00 time(celé číslo "
|
||||
"][%00-00/ den][%00-00 , celé číslo ][%00-00/ měsíc][%00-00 , celé číslo ][%00-00/ "
|
||||
"rok][%00-00 , celé číslo ][%00-00/ hodina][%00-00 , celé číslo ][%00-00/ minuta][%00-00 "
|
||||
", celé číslo ][%00-00/ sekunda][%00-00 ) ][%00-00S ®][%00-00 datum/čas]&][s0; "
|
||||
"Funkce vrátí hodnotu typu [* datum/čas] se zadaným číslem dne, hodiny, minuty "
|
||||
"a sekundy.&][s0; &][s0; [* Příklad: ]time(3, 7, 2003, 11, 15, 37).text `= `\"3.7.2003 "
|
||||
"11:15:37`\"&][s0; Funkce vrátí číslo roku pro zadané datum.&][s0; &][s0; [* "
|
||||
"Příklad]: rok(27.5.1984) `= 1984&][s14;:Calc`$Cyears`_betweenDD: [%00-00 years`_between")
|
||||
TOPIC_TEXT(
|
||||
" (datum ][%00-00/ d1][%00-00 , datum ][%00-00/ d2][%00-00 ) ][%00-00S ®][%00-00 "
|
||||
" celé číslo]&][s0; Funkce určí počet let, která leží mezi zadanými dvěma "
|
||||
"daty (věk osoby, narozené dne [/ d1], ke dni [/ d2]).&][s0; &][s0; [* Příklad]: "
|
||||
"years_between(25.1.1974, 27.12.1999) `= 25&][s0; &][s0; &][s0; &][s0; ]")
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue