-
Notifications
You must be signed in to change notification settings - Fork 1
/
rubyscript.h
153 lines (122 loc) · 4.46 KB
/
rubyscript.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* Copyright(c) 2000 arton
*
* You may distribute under the terms of either the GNU General Public
* License
*
* $Date: 2006-11-15 12:49:36 +0900 (水, 15 11 2006) $
*/
#ifndef __RUBYSCRIPT_H_
#define __RUBYSCRIPT_H_
#include "resource.h"
#include "RScriptCore.h"
#include "giplip.h"
class CRubyScript;
class CRubyObject;
typedef std::map<std::wstring, CRubyObject*> RubyObjMap;
typedef std::map<std::wstring, CRubyObject*>::iterator RubyObjMapIter;
typedef std::map<std::string, ID> RubyMethodMap;
typedef std::map<std::string, ID>::iterator RubyMethodMapIter;
/////////////////////////////////////////////////////////////////////////////
// CRubyScript
class ATL_NO_VTABLE CRubyScript :
public CComCoClass<CRubyScript, &CLSID_RubyScript>,
public IRubyEngine,
public CRScriptCore
{
public:
CRubyScript() :
m_valueModule(Qnil),
m_pWrapper(NULL),
m_dwSecurityLevel(0),
m_pModuleObject(NULL),
m_pRubyObject(NULL),
m_fRubyize(false)
{
}
enum {
MAX_RETRY = 10000,
};
DECLARE_REGISTRY_RESOURCEID(IDR_RUBYSCRIPT)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CRubyScript)
COM_INTERFACE_ENTRY(IRubyEngine)
COM_INTERFACE_ENTRY_CHAIN(CRScriptCore)
END_COM_MAP()
HRESULT FinalConstruct();
void FinalRelease();
public:
// IRubyEngine
HRESULT STDMETHODCALLTYPE CreateObject(
/* [in] */ CLSID clsid,
/* [string][in] */ LPCWSTR pszHost,
/* [in] */ REFIID riid,
/* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppv);
HRESULT STDMETHODCALLTYPE CheckInterfaceIsSafety(
/* [in] */ CLSID clsid,
/* [in] */ IUnknown __RPC_FAR *pUnk);
HRESULT STDMETHODCALLTYPE CheckActiveXIsSafety(CLSID);
HRESULT STDMETHODCALLTYPE EnterScript( void);
HRESULT STDMETHODCALLTYPE LeaveScript( void);
HRESULT STDMETHODCALLTYPE OnScriptError(
/* [in] */ IActiveScriptError __RPC_FAR *pError);
HRESULT STDMETHODCALLTYPE RegisterServiceProvider(
/* [in] */ IServiceProvider __RPC_FAR *pProvider);
HRESULT STDMETHODCALLTYPE UnregisterServiceProvider( void);
HRESULT STDMETHODCALLTYPE GetSecurityLevel(
/* [retval][out] */ long __RPC_FAR *pResult);
HRESULT STDMETHODCALLTYPE ClearModuleObject( void);
HRESULT STDMETHODCALLTYPE SetRubyize(
/* [in] */ boolean f);
HRESULT STDMETHODCALLTYPE GetRubyize( void);
HRESULT STDMETHODCALLTYPE GetModule(
/* [retval][out] */ unsigned long __RPC_FAR *pResult);
HRESULT STDMETHODCALLTYPE DisconnectObjects( void);
// IActiveScript
HRESULT STDMETHODCALLTYPE SetScriptSite(
/* [in] */ IActiveScriptSite __RPC_FAR *pass);
HRESULT STDMETHODCALLTYPE SetScriptState(
/* [in] */ SCRIPTSTATE ss);
HRESULT STDMETHODCALLTYPE Clone(
/* [out] */ IActiveScript __RPC_FAR *__RPC_FAR *ppscript);
HRESULT STDMETHODCALLTYPE Close( void);
HRESULT STDMETHODCALLTYPE InterruptScriptThread(
/* [in] */ SCRIPTTHREADID stidThread,
/* [in] */ const EXCEPINFO __RPC_FAR *pexcepinfo,
/* [in] */ DWORD dwFlags);
HRESULT STDMETHODCALLTYPE DefineGlobalObject( void);
//
virtual HRESULT Invoke(VALUE, int, int, LPCSTR, VARIANT*, EXCEPINFO FAR* pExcepInfo, DWORD dwFlags = 0);
virtual void AddNamedItem(LPCOLESTR);
virtual void Uninitialize();
virtual IActiveScriptSite* GetSite();
virtual HRESULT InternalGetScriptDispatch(LPCOLESTR pstrItemName, IDispatch** ppdisp);
virtual VALUE GetModuleValue();
protected:
inline void CopyPersistent(int n, std::string& s) { m_nStartLinePersistent = n; m_strScriptPersistent = s; }
HRESULT ParseText(int, LPCSTR, LPCOLESTR, EXCEPINFO *, VARIANT*, DWORD);
virtual void MakeScope();
virtual IDispatch* GetOuterDispatch(IDispatch*);
virtual IDispatch* GetGlobalDispatch();
virtual void DefineConstant(LPOLESTR, VARIANT*);
inline ID intern(char* p)
{
unsigned long id;
m_pWrapper->rb_intern(reinterpret_cast<unsigned char*>(p), &id);
return (ID)id;
}
inline void setModule(VALUE v) { m_valueModule = v; }
bool m_fRubyize;
private:
GIP(IActiveScriptSite) m_pGippedSite;
GIP(IInternetHostSecurityManager) m_pGippedScM;
DWORD m_dwSecurityLevel;
IRubyWrapper* m_pWrapper;
RubyObjMap m_mapObj;
VALUE m_valueModule;
VALUE m_valueHash;
RubyMethodMap m_mapMethods;
CRubyObject* m_pModuleObject;
CRubyObject* m_pRubyObject;
};
#endif //__RUBYSCRIPT_H_