ReactOS 0.4.17-dev-357-ga8f14ff
global.c File Reference
#include <assert.h>
#include <math.h>
#include "vbscript.h"
#include "vbscript_defs.h"
#include "mshtmhst.h"
#include "objsafe.h"
#include "wchar.h"
#include "wine/debug.h"
Include dependency graph for global.c:

Go to the source code of this file.

Classes

struct  string_constant_t
 
struct  _builtin_prop_t
 

Macros

#define VB_E_CANNOT_CREATE_OBJ   0x800a01ad
 
#define VB_E_MK_PARSE_ERROR   0x800a01b0
 
#define BP_GET   1
 
#define BP_GETPUT   2
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (vbscript)
 
static BuiltinDispimpl_from_IDispatch (IDispatch *iface)
 
static HRESULT WINAPI Builtin_QueryInterface (IDispatch *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI Builtin_AddRef (IDispatch *iface)
 
static ULONG WINAPI Builtin_Release (IDispatch *iface)
 
static HRESULT WINAPI Builtin_GetTypeInfoCount (IDispatch *iface, UINT *pctinfo)
 
static HRESULT WINAPI Builtin_GetTypeInfo (IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
HRESULT get_builtin_id (BuiltinDisp *disp, const WCHAR *name, DISPID *id)
 
static HRESULT WINAPI Builtin_GetIDsOfNames (IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, LCID lcid, DISPID *ids)
 
static HRESULT WINAPI Builtin_Invoke (IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
 
static HRESULT create_builtin_dispatch (script_ctx_t *ctx, const builtin_prop_t *members, size_t member_cnt, BuiltinDisp **ret)
 
static IInternetHostSecurityManagerget_sec_mgr (script_ctx_t *ctx)
 
static HRESULT return_string (VARIANT *res, const WCHAR *str)
 
static HRESULT return_bstr (VARIANT *res, BSTR str)
 
static HRESULT return_bool (VARIANT *res, BOOL val)
 
static HRESULT return_short (VARIANT *res, short val)
 
static HRESULT return_int (VARIANT *res, int val)
 
static HRESULT return_double (VARIANT *res, double val)
 
static HRESULT return_float (VARIANT *res, float val)
 
static HRESULT return_null (VARIANT *res)
 
static HRESULT return_date (VARIANT *res, double date)
 
HRESULT to_int (VARIANT *v, int *ret)
 
static HRESULT to_double (VARIANT *v, double *ret)
 
static HRESULT to_float (VARIANT *v, float *ret)
 
static HRESULT to_string (VARIANT *v, BSTR *ret)
 
static HRESULT to_system_time (VARIANT *v, SYSTEMTIME *st)
 
static HRESULT set_object_site (script_ctx_t *ctx, IUnknown *obj)
 
static IUnknowncreate_object (script_ctx_t *ctx, const WCHAR *progid)
 
static HRESULT show_msgbox (script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR orig_title, VARIANT *res)
 
static HRESULT Global_CCur (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CInt (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CLng (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CBool (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CByte (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CDate (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CDbl (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CSng (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CStr (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static WCHAR hex_char (unsigned n)
 
static HRESULT Global_Hex (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Oct (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_VarType (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_IsDate (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_IsEmpty (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_IsNull (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_IsNumeric (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_IsArray (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_IsObject (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Atn (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Cos (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Sin (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Tan (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Exp (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Log (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Sqr (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static unsigned int get_next_rnd (int value)
 
static HRESULT Global_Randomize (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Rnd (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Timer (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_LBound (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_UBound (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_RGB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Len (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_LenB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Left (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_LeftB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Right (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_RightB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Mid (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_MidB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_StrComp (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_LCase (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_UCase (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_LTrim (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_RTrim (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Trim (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Space (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_String (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_InStr (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_InStrB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_AscB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ChrB (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Asc (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Chr (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_AscW (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ChrW (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Abs (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Fix (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Int (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Sgn (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Now (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Date (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Time (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Day (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Month (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Weekday (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Year (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Hour (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Minute (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Second (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_SetLocale (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_DateValue (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_TimeValue (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_DateSerial (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_TimeSerial (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_InputBox (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_MsgBox (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_CreateObject (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_GetObject (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_DateAdd (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_DateDiff (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_DatePart (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_TypeName (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Array (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Erase (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Filter (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Join (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Split (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Replace (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_StrReverse (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_InStrRev (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_LoadPicture (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ScriptEngine (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ScriptEngineMajorVersion (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ScriptEngineMinorVersion (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ScriptEngineBuildVersion (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_FormatNumber (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_FormatCurrency (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_FormatPercent (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_GetLocale (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_FormatDateTime (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_WeekdayName (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_MonthName (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Round (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Escape (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Unescape (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Eval (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Execute (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_ExecuteGlobal (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_GetRef (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT Global_Err (BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 
static HRESULT err_string_prop (BSTR *prop, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_Description (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_HelpContext (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_HelpFile (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_Number (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_Source (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_Clear (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
static HRESULT Err_Raise (BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
 
void detach_global_objects (script_ctx_t *ctx)
 
HRESULT init_global (script_ctx_t *ctx)
 

Variables

const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
 
static const IDispatchVtbl BuiltinDispVtbl
 
static const string_constant_t vbCr = {1, {'\r'}}
 
static const string_constant_t vbCrLf = {2, {'\r','\n'}}
 
static const string_constant_t vbNewLine = {2, {'\r','\n'}}
 
static const string_constant_t vbFormFeed = {1, {0xc}}
 
static const string_constant_t vbLf = {1, {'\n'}}
 
static const string_constant_t vbNullChar = {1}
 
static const string_constant_t vbNullString = {0}
 
static const string_constant_t vbTab = {1, {'\t'}}
 
static const string_constant_t vbVerticalTab = {1, {0xb}}
 
static const builtin_prop_t global_props []
 
static const builtin_prop_t err_props []
 

Macro Definition Documentation

◆ BP_GET

#define BP_GET   1

Definition at line 45 of file global.c.

◆ BP_GETPUT

#define BP_GETPUT   2

Definition at line 46 of file global.c.

◆ VB_E_CANNOT_CREATE_OBJ

#define VB_E_CANNOT_CREATE_OBJ   0x800a01ad

Definition at line 38 of file global.c.

◆ VB_E_MK_PARSE_ERROR

#define VB_E_MK_PARSE_ERROR   0x800a01b0

Definition at line 39 of file global.c.

Function Documentation

◆ Builtin_AddRef()

static ULONG WINAPI Builtin_AddRef ( IDispatch iface)
static

Definition at line 87 of file global.c.

88{
91
92 TRACE("(%p) ref=%ld\n", This, ref);
93
94 return ref;
95}
#define InterlockedIncrement
Definition: armddk.h:53
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
static BuiltinDisp * impl_from_IDispatch(IDispatch *iface)
Definition: global.c:61

◆ Builtin_GetIDsOfNames()

static HRESULT WINAPI Builtin_GetIDsOfNames ( IDispatch iface,
REFIID  riid,
LPOLESTR *  names,
UINT  name_cnt,
LCID  lcid,
DISPID ids 
)
static

Definition at line 149 of file global.c.

151{
153 unsigned i;
155
156 TRACE("(%p)->(%s %p %u %lu %p)\n", This, debugstr_guid(riid), names, name_cnt, lcid, ids);
157
158 if(!This->ctx) {
159 FIXME("NULL context\n");
160 return E_UNEXPECTED;
161 }
162
163 for(i = 0; i < name_cnt; i++) {
165 if(FAILED(hres))
166 return hres;
167 }
168
169 return S_OK;
170}
#define FIXME(fmt,...)
Definition: precomp.h:53
LCID lcid
Definition: locale.c:5660
GLuint * ids
Definition: glext.h:5907
GLuint GLuint * names
Definition: glext.h:11545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:465
HRESULT get_builtin_id(BuiltinDisp *disp, const WCHAR *name, DISPID *id)
Definition: global.c:127
#define E_UNEXPECTED
Definition: winerror.h:3528

◆ Builtin_GetTypeInfo()

static HRESULT WINAPI Builtin_GetTypeInfo ( IDispatch iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 120 of file global.c.

121{
123 TRACE("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo);
124 return DISP_E_BADINDEX;
125}
#define DISP_E_BADINDEX
Definition: winerror.h:3623

◆ Builtin_GetTypeInfoCount()

static HRESULT WINAPI Builtin_GetTypeInfoCount ( IDispatch iface,
UINT pctinfo 
)
static

Definition at line 112 of file global.c.

113{
115 TRACE("(%p)->(%p)\n", This, pctinfo);
116 *pctinfo = 0;
117 return S_OK;
118}

◆ Builtin_Invoke()

static HRESULT WINAPI Builtin_Invoke ( IDispatch iface,
DISPID  id,
REFIID  riid,
LCID  lcid,
WORD  flags,
DISPPARAMS *  dp,
VARIANT res,
EXCEPINFO *  ei,
UINT err 
)
static

Definition at line 172 of file global.c.

174{
176 const builtin_prop_t *prop;
177 VARIANT args_buf[8], *args;
178 unsigned argn, i;
180
181 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, id, debugstr_guid(riid), lcid, flags, dp, res, ei, err);
182
183 if(!This->ctx) {
184 FIXME("NULL context\n");
185 return E_UNEXPECTED;
186 }
187
188 if(id >= This->member_cnt || (!This->members[id].proc && !This->members[id].flags))
190 prop = This->members + id;
191
192 switch(flags) {
194 if(!(prop->flags & (BP_GET|BP_GETPUT))) {
195 FIXME("property does not support DISPATCH_PROPERTYGET\n");
196 return E_FAIL;
197 }
198 break;
200 if(!prop->proc && prop->flags == BP_GET) {
201 const int vt = prop->min_args, val = prop->max_args;
202 switch(vt) {
203 case VT_I2:
204 V_VT(res) = VT_I2;
205 V_I2(res) = val;
206 break;
207 case VT_I4:
208 V_VT(res) = VT_I4;
209 V_I4(res) = val;
210 break;
211 case VT_BSTR: {
212 const string_constant_t *str = (const string_constant_t*)prop->max_args;
213 BSTR ret;
214
215 ret = SysAllocStringLen(str->buf, str->len);
216 if(!ret)
217 return E_OUTOFMEMORY;
218
219 V_VT(res) = VT_BSTR;
220 V_BSTR(res) = ret;
221 break;
222 }
224 }
225 return S_OK;
226 }
227 break;
228 case DISPATCH_METHOD:
229 if(prop->flags & (BP_GET|BP_GETPUT)) {
230 FIXME("Call on property\n");
231 return E_FAIL;
232 }
233 break;
235 if(!(prop->flags & BP_GETPUT)) {
236 FIXME("property does not support DISPATCH_PROPERTYPUT\n");
237 return E_FAIL;
238 }
239
240 FIXME("call put\n");
241 return E_NOTIMPL;
242 default:
243 FIXME("unsupported flags %x\n", flags);
244 return E_NOTIMPL;
245 }
246
247 argn = arg_cnt(dp);
248
249 if(argn < prop->min_args || argn > (prop->max_args ? prop->max_args : prop->min_args)) {
250 WARN("invalid number of arguments\n");
252 }
253
254 if(argn <= ARRAY_SIZE(args_buf)) {
255 args = args_buf;
256 }else {
257 args = malloc(argn * sizeof(*args));
258 if(!args)
259 return E_OUTOFMEMORY;
260 }
261
262 for(i=0; i < argn; i++) {
263 if(V_VT(dp->rgvarg+dp->cArgs-i-1) == (VT_BYREF|VT_VARIANT))
264 args[i] = *V_VARIANTREF(dp->rgvarg+dp->cArgs-i-1);
265 else
266 args[i] = dp->rgvarg[dp->cArgs-i-1];
267 }
268
269 hres = prop->proc(This, args, dp->cArgs, res);
270 if(args != args_buf)
271 free(args);
272 return hres;
273}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
OLECHAR * BSTR
Definition: compat.h:2293
@ VT_BSTR
Definition: compat.h:2303
@ VT_BYREF
Definition: compat.h:2342
@ VT_VARIANT
Definition: compat.h:2307
@ VT_I4
Definition: compat.h:2298
@ VT_I2
Definition: compat.h:2297
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
#define VBSE_FUNC_ARITY_MISMATCH
return ret
Definition: mutex.c:146
GLuint res
Definition: glext.h:9613
GLbitfield flags
Definition: glext.h:7161
GLuint GLfloat * val
Definition: glext.h:7180
GLuint id
Definition: glext.h:5910
#define DEFAULT_UNREACHABLE
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_VARIANTREF(A)
Definition: oleauto.h:283
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define V_I2(A)
Definition: oleauto.h:245
#define err(...)
const WCHAR * str
#define args
Definition: format.c:66
Definition: match.c:390
DWORD flags
Definition: jscript.h:177
#define BP_GETPUT
Definition: global.c:46
#define BP_GET
Definition: global.c:45
static unsigned arg_cnt(const DISPPARAMS *dp)
Definition: vbscript.h:175
#define MAKE_VBSERROR(code)
Definition: vbscript.h:425
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:3615

◆ Builtin_QueryInterface()

static HRESULT WINAPI Builtin_QueryInterface ( IDispatch iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 66 of file global.c.

67{
69
71 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
72 *ppv = &This->IDispatch_iface;
73 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
74 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
75 *ppv = &This->IDispatch_iface;
76 }else {
77 if(!IsEqualGUID(riid, &IID_IDispatchEx))
78 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
79 *ppv = NULL;
80 return E_NOINTERFACE;
81 }
82
83 IUnknown_AddRef((IUnknown*)*ppv);
84 return S_OK;
85}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID LPVOID * ppv
Definition: atlbase.h:39
const GUID IID_IDispatch
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ Builtin_Release()

static ULONG WINAPI Builtin_Release ( IDispatch iface)
static

Definition at line 97 of file global.c.

98{
101
102 TRACE("(%p) ref=%ld\n", This, ref);
103
104 if(!ref) {
105 assert(!This->ctx);
106 free(This);
107 }
108
109 return ref;
110}
#define InterlockedDecrement
Definition: armddk.h:52
#define assert(_expr)
Definition: assert.h:32

◆ create_builtin_dispatch()

static HRESULT create_builtin_dispatch ( script_ctx_t ctx,
const builtin_prop_t members,
size_t  member_cnt,
BuiltinDisp **  ret 
)
static

Definition at line 285 of file global.c.

286{
287 BuiltinDisp *disp;
288
289 if(!(disp = malloc(sizeof(*disp))))
290 return E_OUTOFMEMORY;
291
292 disp->IDispatch_iface.lpVtbl = &BuiltinDispVtbl;
293 disp->ref = 1;
294 disp->members = members;
295 disp->member_cnt = member_cnt;
296 disp->ctx = ctx;
297
298 *ret = disp;
299 return S_OK;
300}
size_t member_cnt
Definition: vbscript.h:149
LONG ref
Definition: vbscript.h:148
const builtin_prop_t * members
Definition: vbscript.h:150
IDispatch IDispatch_iface
Definition: vbscript.h:147
script_ctx_t * ctx
Definition: vbscript.h:151
static const IDispatchVtbl BuiltinDispVtbl
Definition: global.c:275

Referenced by init_global().

◆ create_object()

static IUnknown * create_object ( script_ctx_t ctx,
const WCHAR progid 
)
static

Definition at line 509 of file global.c.

510{
512 struct CONFIRMSAFETY cs;
513 IClassFactoryEx *cfex;
515 DWORD policy_size;
516 BYTE *bpolicy;
517 IUnknown *obj;
519 GUID guid;
521
523 if(FAILED(hres))
524 return NULL;
525
526 TRACE("GUID %s\n", debugstr_guid(&guid));
527
528 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
529 secmgr = get_sec_mgr(ctx);
530 if(!secmgr)
531 return NULL;
532
533 policy = 0;
534 hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN,
535 (BYTE*)&policy, sizeof(policy), (BYTE*)&guid, sizeof(GUID), 0, 0);
536 if(FAILED(hres) || policy != URLPOLICY_ALLOW)
537 return NULL;
538 }
539
540 hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf);
541 if(FAILED(hres))
542 return NULL;
543
544 hres = IClassFactory_QueryInterface(cf, &IID_IClassFactoryEx, (void**)&cfex);
545 if(SUCCEEDED(hres)) {
546 FIXME("Use IClassFactoryEx\n");
547 IClassFactoryEx_Release(cfex);
548 }
549
550 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
551 if(FAILED(hres))
552 return NULL;
553
554 if(secmgr) {
555 cs.clsid = guid;
556 cs.pUnk = obj;
557 cs.dwFlags = 0;
558 hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
559 &bpolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
560 if(SUCCEEDED(hres)) {
561 policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
562 CoTaskMemFree(bpolicy);
563 }
564
565 if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
566 IUnknown_Release(obj);
567 return NULL;
568 }
569 }
570
572 if(FAILED(hres)) {
573 IUnknown_Release(obj);
574 return NULL;
575 }
576
577 return obj;
578}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:73
const GUID IID_IClassFactory
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1437
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscontext, COSERVERINFO *server_info, REFIID riid, void **obj)
Definition: combase.c:1925
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
GUID guid
Definition: version.c:147
#define progid(str)
Definition: exdisp.idl:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define cs
Definition: i386-dis.c:442
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define DWORD
Definition: nt_native.h:44
static HRESULT set_object_site(script_ctx_t *ctx, IUnknown *obj)
Definition: global.c:488
static IInternetHostSecurityManager * get_sec_mgr(script_ctx_t *ctx)
Definition: global.c:302
const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
Definition: global.c:42
unsigned char BYTE
Definition: xxhash.c:193

Referenced by Global_CreateObject().

◆ detach_global_objects()

void detach_global_objects ( script_ctx_t ctx)

Definition at line 3602 of file global.c.

3603{
3604 if(ctx->err_obj) {
3605 ctx->err_obj->ctx = NULL;
3606 IDispatch_Release(&ctx->err_obj->IDispatch_iface);
3607 ctx->err_obj = NULL;
3608 }
3609
3610 if(ctx->global_obj) {
3611 ctx->global_obj->ctx = NULL;
3612 IDispatch_Release(&ctx->global_obj->IDispatch_iface);
3613 ctx->global_obj = NULL;
3614 }
3615}
CONTEXT ctx

Referenced by VBScript_Release().

◆ Err_Clear()

static HRESULT Err_Clear ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3529 of file global.c.

3530{
3531 TRACE("\n");
3532
3533 clear_ei(&This->ctx->ei);
3534 return S_OK;
3535}
void clear_ei(EXCEPINFO *ei)
Definition: interp.c:288

◆ Err_Description()

static HRESULT Err_Description ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3484 of file global.c.

3485{
3486 TRACE("\n");
3487 return err_string_prop(&This->ctx->ei.bstrDescription, args, args_cnt, res);
3488}
static HRESULT err_string_prop(BSTR *prop, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3467

◆ Err_HelpContext()

static HRESULT Err_HelpContext ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3490 of file global.c.

3491{
3492 TRACE("\n");
3493
3494 if(args_cnt) {
3495 FIXME("setter not implemented\n");
3496 return E_NOTIMPL;
3497 }
3498
3499 return return_int(res, This->ctx->ei.dwHelpContext);
3500}
static HRESULT return_int(VARIANT *res, int val)
Definition: global.c:373

◆ Err_HelpFile()

static HRESULT Err_HelpFile ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3502 of file global.c.

3503{
3504 TRACE("\n");
3505 return err_string_prop(&This->ctx->ei.bstrHelpFile, args, args_cnt, res);
3506}

◆ Err_Number()

static HRESULT Err_Number ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3508 of file global.c.

3509{
3510 HRESULT hres;
3511
3512 TRACE("\n");
3513
3514 if(args_cnt) {
3515 FIXME("setter not implemented\n");
3516 return E_NOTIMPL;
3517 }
3518
3519 hres = This->ctx->ei.scode;
3521}
#define FACILITY_VBS
Definition: vbscript.h:424
#define HRESULT_FACILITY(hr)
Definition: winerror.h:191
#define HRESULT_CODE(hr)
Definition: winerror.h:188

◆ Err_Raise()

static HRESULT Err_Raise ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3537 of file global.c.

3538{
3540 int code, helpcontext = 0;
3541 HRESULT hres;
3542
3543 TRACE("%s %u...\n", debugstr_variant(args), args_cnt);
3544
3545 hres = to_int(args, &code);
3546 if(FAILED(hres))
3547 return hres;
3548 if(code == 0 || code > 0xffff)
3549 return E_INVALIDARG;
3550
3551 if(args_cnt >= 2)
3552 hres = to_string(args + 1, &source);
3553 if(args_cnt >= 3 && SUCCEEDED(hres))
3554 hres = to_string(args + 2, &description);
3555 if(args_cnt >= 4 && SUCCEEDED(hres))
3556 hres = to_string(args + 3, &helpfile);
3557 if(args_cnt >= 5 && SUCCEEDED(hres))
3558 hres = to_int(args + 4, &helpcontext);
3559
3560 if(SUCCEEDED(hres)) {
3561 script_ctx_t *ctx = This->ctx;
3562
3563 if(source) {
3564 SysFreeString(ctx->ei.bstrSource);
3565 ctx->ei.bstrSource = source;
3566 }
3567 if(description) {
3568 SysFreeString(ctx->ei.bstrDescription);
3569 ctx->ei.bstrDescription = description;
3570 }
3571 if(helpfile) {
3572 SysFreeString(ctx->ei.bstrHelpFile);
3573 ctx->ei.bstrHelpFile = helpfile;
3574 }
3575 if(args_cnt >= 5)
3576 ctx->ei.dwHelpContext = helpcontext;
3577
3578 ctx->ei.scode = (code & ~0xffff) ? code : MAKE_VBSERROR(code);
3579 map_vbs_exception(&ctx->ei);
3580
3581 hres = SCRIPT_E_RECORDED;
3582 }else {
3586 }
3587
3588 return hres;
3589}
static const TCHAR helpfile[]
Definition: dialog.c:19
#define E_INVALIDARG
Definition: ddrawi.h:101
static const char * debugstr_variant(const VARIANT *var)
Definition: dom.c:505
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
Definition: inflate.c:139
void map_vbs_exception(EXCEPINFO *ei)
Definition: vbdisp.c:1605
HRESULT to_int(VARIANT *v, int *ret)
Definition: global.c:419
static HRESULT to_string(VARIANT *v, BSTR *ret)
Definition: global.c:461
const char * description
Definition: directx.c:2497

◆ Err_Source()

static HRESULT Err_Source ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3523 of file global.c.

3524{
3525 TRACE("\n");
3526 return err_string_prop(&This->ctx->ei.bstrSource, args, args_cnt, res);
3527}

◆ err_string_prop()

static HRESULT err_string_prop ( BSTR prop,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3467 of file global.c.

3468{
3469 BSTR str;
3470 HRESULT hres;
3471
3472 if(!args_cnt)
3473 return return_string(res, *prop ? *prop : L"");
3474
3475 hres = to_string(args, &str);
3476 if(FAILED(hres))
3477 return hres;
3478
3479 SysFreeString(*prop);
3480 *prop = str;
3481 return S_OK;
3482}
#define L(x)
Definition: resources.c:13
static HRESULT return_string(VARIANT *res, const WCHAR *str)
Definition: global.c:327

Referenced by Err_Description(), Err_HelpFile(), and Err_Source().

◆ get_builtin_id()

HRESULT get_builtin_id ( BuiltinDisp disp,
const WCHAR name,
DISPID id 
)

Definition at line 127 of file global.c.

128{
129 size_t min = 1, max = disp->member_cnt - 1, i;
130 int r;
131
132 while(min <= max) {
133 i = (min + max) / 2;
134 r = wcsicmp(disp->members[i].name, name);
135 if(!r) {
136 *id = i;
137 return S_OK;
138 }
139 if(r < 0)
140 min = i+1;
141 else
142 max = i-1;
143 }
144
146
147}
#define wcsicmp
Definition: compat.h:15
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define min(a, b)
Definition: monoChain.cc:55
const WCHAR * name
Definition: global.c:54
Definition: name.c:39
#define max(a, b)
Definition: svc.c:63

Referenced by Builtin_GetIDsOfNames().

◆ get_next_rnd()

static unsigned int get_next_rnd ( int  value)
static

Definition at line 1097 of file global.c.

1098{
1099 return (value * 0x43fd43fd + 0xc39ec3) & 0xffffff;
1100}
Definition: pdh_main.c:96

Referenced by Global_Rnd().

◆ get_sec_mgr()

static IInternetHostSecurityManager * get_sec_mgr ( script_ctx_t ctx)
static

Definition at line 302 of file global.c.

303{
307
308 if(!ctx->site)
309 return NULL;
310
311 if(ctx->secmgr)
312 return ctx->secmgr;
313
314 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
315 if(FAILED(hres))
316 return NULL;
317
318 hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
319 (void**)&secmgr);
320 IServiceProvider_Release(sp);
321 if(FAILED(hres))
322 return NULL;
323
324 return ctx->secmgr = secmgr;
325}
static const WCHAR sp[]
Definition: suminfo.c:287

Referenced by create_object().

◆ Global_Abs()

static HRESULT Global_Abs ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1945 of file global.c.

1946{
1947 HRESULT hres;
1948 VARIANT dst;
1949
1950 TRACE("(%s)\n", debugstr_variant(arg));
1951
1952 assert(args_cnt == 1);
1953
1954 hres = VarAbs(arg, &dst);
1955 if(FAILED(hres))
1956 return hres;
1957
1958 if (res)
1959 *res = dst;
1960 else
1961 VariantClear(&dst);
1962
1963 return S_OK;
1964}
GLenum GLenum dst
Definition: glext.h:6340
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
HRESULT WINAPI VarAbs(LPVARIANT pVarIn, LPVARIANT pVarOut)
Definition: variant.c:4263

◆ Global_Array()

static HRESULT Global_Array ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2535 of file global.c.

2536{
2537 SAFEARRAYBOUND bounds;
2538 SAFEARRAY *sa;
2539 VARIANT *data;
2540 HRESULT hres;
2541 unsigned i;
2542
2543 TRACE("arg_cnt=%u\n", args_cnt);
2544
2545 bounds.lLbound = 0;
2546 bounds.cElements = args_cnt;
2547 sa = SafeArrayCreate(VT_VARIANT, 1, &bounds);
2548 if(!sa)
2549 return E_OUTOFMEMORY;
2550
2551 hres = SafeArrayAccessData(sa, (void**)&data);
2552 if(FAILED(hres)) {
2554 return hres;
2555 }
2556
2557 for(i=0; i<args_cnt; i++) {
2559 if(FAILED(hres)) {
2562 return hres;
2563 }
2564 }
2566
2567 if(res) {
2569 V_ARRAY(res) = sa;
2570 }else {
2572 }
2573
2574 return S_OK;
2575}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
@ VT_ARRAY
Definition: compat.h:2341
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1137
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1168
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define V_ARRAY(A)
Definition: oleauto.h:222
HRESULT WINAPI VariantCopyInd(VARIANT *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:847

◆ Global_Asc()

static HRESULT Global_Asc ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1835 of file global.c.

1836{
1837 BSTR conv_str = NULL, str;
1838 HRESULT hres = S_OK;
1839
1840 TRACE("(%s)\n", debugstr_variant(arg));
1841
1842 switch(V_VT(arg)) {
1843 case VT_NULL:
1845 case VT_EMPTY:
1847 case VT_BSTR:
1848 str = V_BSTR(arg);
1849 break;
1850 default:
1851 hres = to_string(arg, &conv_str);
1852 if(FAILED(hres))
1853 return hres;
1854 str = conv_str;
1855 }
1856
1857 if(!SysStringLen(str))
1859 else if (This->ctx->codepage == CP_UTF8)
1860 hres = return_short(res, *str);
1861 else {
1862 unsigned char buf[2];
1863 short val = 0;
1864 int n = WideCharToMultiByte(This->ctx->codepage, 0, str, 1, (char*)buf, sizeof(buf), NULL, NULL);
1865 switch(n) {
1866 case 1:
1867 val = buf[0];
1868 break;
1869 case 2:
1870 val = (buf[0] << 8) | buf[1];
1871 break;
1872 default:
1873 WARN("Failed to convert %x\n", *str);
1875 }
1876 if(SUCCEEDED(hres))
1878 }
1879
1880 SysFreeString(conv_str);
1881 return hres;
1882}
#define WideCharToMultiByte
Definition: compat.h:111
@ VT_NULL
Definition: compat.h:2296
@ VT_EMPTY
Definition: compat.h:2295
#define VBSE_ILLEGAL_FUNC_CALL
#define VBSE_ILLEGAL_NULL_USE
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
#define CP_UTF8
Definition: nls.h:20
static HRESULT return_short(VARIANT *res, short val)
Definition: global.c:363

◆ Global_AscB()

static HRESULT Global_AscB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1823 of file global.c.

1824{
1825 FIXME("\n");
1826 return E_NOTIMPL;
1827}

◆ Global_AscW()

static HRESULT Global_AscW ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1933 of file global.c.

1934{
1935 FIXME("\n");
1936 return E_NOTIMPL;
1937}

◆ Global_Atn()

static HRESULT Global_Atn ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1007 of file global.c.

1008{
1009 HRESULT hres;
1010 double d;
1011
1012 hres = to_double(arg, &d);
1013 if(FAILED(hres))
1014 return hres;
1015
1016 return return_double(res, atan(d));
1017}
_ACRTIMP double __cdecl atan(double)
Definition: atan.c:44
#define d
Definition: ke_i.h:81
static HRESULT to_double(VARIANT *v, double *ret)
Definition: global.c:433
static HRESULT return_double(VARIANT *res, double val)
Definition: global.c:383

◆ Global_CBool()

static HRESULT Global_CBool ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 718 of file global.c.

719{
720 VARIANT v;
722
723 TRACE("%s\n", debugstr_variant(arg));
724
725 assert(args_cnt == 1);
726
727 V_VT(&v) = VT_EMPTY;
729 if(FAILED(hres))
730 return hres;
731
732 if(res)
733 *res = v;
734 else
735 VariantClear(&v);
736 return S_OK;
737}
@ VT_BOOL
Definition: compat.h:2306
const GLdouble * v
Definition: gl.h:2040
#define VARIANT_LOCALBOOL
Definition: oleauto.h:314
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:962

◆ Global_CByte()

static HRESULT Global_CByte ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 739 of file global.c.

740{
741 VARIANT v;
743
744 TRACE("%s\n", debugstr_variant(arg));
745
746 assert(args_cnt == 1);
747
748 V_VT(&v) = VT_EMPTY;
750 if(FAILED(hres))
751 return hres;
752
753 if(!res) {
754 VariantClear(&v);
755 return DISP_E_BADVARTYPE;
756 }
757
758 *res = v;
759 return S_OK;
760}
@ VT_UI1
Definition: compat.h:2311
#define DISP_E_BADVARTYPE
Definition: winerror.h:3620

◆ Global_CCur()

static HRESULT Global_CCur ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 655 of file global.c.

656{
657 VARIANT v;
659
660 TRACE("%s\n", debugstr_variant(arg));
661
662 assert(args_cnt == 1);
663
664 V_VT(&v) = VT_EMPTY;
666 if(FAILED(hres))
667 return hres;
668
669 if(!res) {
670 VariantClear(&v);
671 return DISP_E_BADVARTYPE;
672 }
673
674 *res = v;
675 return S_OK;
676}
@ VT_CY
Definition: compat.h:2301

◆ Global_CDate()

static HRESULT Global_CDate ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 762 of file global.c.

763{
764 VARIANT v;
766
767 TRACE("%s\n", debugstr_variant(arg));
768
769 assert(args_cnt == 1);
770
771 if(V_VT(arg) == VT_NULL)
773
774 V_VT(&v) = VT_EMPTY;
776 if(FAILED(hres)) {
778 if(FAILED(hres))
779 return hres;
780 hres = VariantChangeType(&v, &v, 0, VT_DATE);
781 if(FAILED(hres))
782 return hres;
783 }
784
785 if(!res)
786 return DISP_E_BADVARTYPE;
787 *res = v;
788 return S_OK;
789}
@ VT_R8
Definition: compat.h:2300
@ VT_DATE
Definition: compat.h:2302

◆ Global_CDbl()

static HRESULT Global_CDbl ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 791 of file global.c.

792{
793 VARIANT v;
795
796 TRACE("%s\n", debugstr_variant(arg));
797
798 assert(args_cnt == 1);
799
800 V_VT(&v) = VT_EMPTY;
802 if(FAILED(hres))
803 return hres;
804
805 if(!res)
806 return DISP_E_BADVARTYPE;
807 else {
808 *res = v;
809 return S_OK;
810 }
811}

◆ Global_Chr()

static HRESULT Global_Chr ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1884 of file global.c.

1885{
1886 int cp, c, len = 0;
1887 CPINFO cpi;
1888 WCHAR ch;
1889 char buf[2];
1890 HRESULT hres;
1891
1892 TRACE("%s\n", debugstr_variant(arg));
1893
1894 hres = to_int(arg, &c);
1895 if(FAILED(hres))
1896 return hres;
1897
1898 cp = This->ctx->codepage;
1899 if(!GetCPInfo(cp, &cpi))
1900 cpi.MaxCharSize = 1;
1901
1902 if((c!=(short)c && c!=(unsigned short)c) ||
1903 (unsigned short)c>=(cpi.MaxCharSize>1 ? 0x10000 : 0x100)) {
1904 WARN("invalid arg %d\n", c);
1906 }
1907
1908 if (cp == CP_UTF8)
1909 {
1910 ch = c;
1911 }
1912 else
1913 {
1914 if(c>>8)
1915 buf[len++] = c>>8;
1916 if(!len || IsDBCSLeadByteEx(cp, buf[0]))
1917 buf[len++] = c;
1918 if(!MultiByteToWideChar(cp, 0, buf, len, &ch, 1)) {
1919 WARN("invalid arg %d, cp %d\n", c, cp);
1920 return E_FAIL;
1921 }
1922 }
1923
1924 if(res) {
1925 V_VT(res) = VT_BSTR;
1927 if(!V_BSTR(res))
1928 return E_OUTOFMEMORY;
1929 }
1930 return S_OK;
1931}
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2146
BOOL WINAPI IsDBCSLeadByteEx(UINT codepage, BYTE testchar)
Definition: locale.c:2106
unsigned char ch[4][2]
Definition: console.c:118
const GLubyte * c
Definition: glext.h:8905
GLenum GLsizei len
Definition: glext.h:6722
#define c
Definition: ke_i.h:80
POINT cp
Definition: magnifier.c:59
short WCHAR
Definition: pedump.c:58
UINT MaxCharSize
Definition: winnls.h:662

◆ Global_ChrB()

static HRESULT Global_ChrB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1829 of file global.c.

1830{
1831 FIXME("\n");
1832 return E_NOTIMPL;
1833}

◆ Global_ChrW()

static HRESULT Global_ChrW ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1939 of file global.c.

1940{
1941 FIXME("\n");
1942 return E_NOTIMPL;
1943}

◆ Global_CInt()

static HRESULT Global_CInt ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 678 of file global.c.

679{
680 VARIANT v;
682
683 TRACE("%s\n", debugstr_variant(arg));
684
685 assert(args_cnt == 1);
686
687 V_VT(&v) = VT_EMPTY;
689 if(FAILED(hres))
690 return hres;
691
692 if(!res)
693 return DISP_E_BADVARTYPE;
694 else {
695 *res = v;
696 return S_OK;
697 }
698}

◆ Global_CLng()

static HRESULT Global_CLng ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 700 of file global.c.

701{
702 int i;
704
705 TRACE("%s\n", debugstr_variant(arg));
706
707 assert(args_cnt == 1);
708
709 hres = to_int(arg, &i);
710 if(FAILED(hres))
711 return hres;
712 if(!res)
713 return DISP_E_BADVARTYPE;
714
715 return return_int(res, i);
716}

◆ Global_Cos()

static HRESULT Global_Cos ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1019 of file global.c.

1020{
1021 HRESULT hres;
1022 double d;
1023
1024 hres = to_double(arg, &d);
1025 if(FAILED(hres))
1026 return hres;
1027
1028 return return_double(res, cos(d));
1029}
_ACRTIMP double __cdecl cos(double)
Definition: cos.c:21

◆ Global_CreateObject()

static HRESULT Global_CreateObject ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2317 of file global.c.

2318{
2319 IUnknown *obj;
2320 HRESULT hres;
2321
2322 TRACE("(%s)\n", debugstr_variant(arg));
2323
2324 if(V_VT(arg) != VT_BSTR) {
2325 FIXME("non-bstr arg\n");
2326 return E_INVALIDARG;
2327 }
2328
2329 obj = create_object(This->ctx, V_BSTR(arg));
2330 if(!obj)
2332
2333 if(res) {
2334 hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&V_DISPATCH(res));
2335 if(FAILED(hres))
2336 return hres;
2337
2338 V_VT(res) = VT_DISPATCH;
2339 }
2340
2341 IUnknown_Release(obj);
2342 return S_OK;
2343}
@ VT_DISPATCH
Definition: compat.h:2304
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define VB_E_CANNOT_CREATE_OBJ
Definition: global.c:38
static IUnknown * create_object(script_ctx_t *ctx, const WCHAR *progid)
Definition: global.c:509

◆ Global_CSng()

static HRESULT Global_CSng ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 813 of file global.c.

814{
815 VARIANT v;
817
818 TRACE("%s\n", debugstr_variant(arg));
819
820 assert(args_cnt == 1);
821
822 V_VT(&v) = VT_EMPTY;
824 if(FAILED(hres))
825 return hres;
826
827 if(!res)
828 return DISP_E_BADVARTYPE;
829
830 *res = v;
831 return S_OK;
832}
@ VT_R4
Definition: compat.h:2299

◆ Global_CStr()

static HRESULT Global_CStr ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 834 of file global.c.

835{
836 BSTR str;
838
839 TRACE("%s\n", debugstr_variant(arg));
840
841 if(V_VT(arg) == VT_NULL)
843
844 hres = to_string(arg, &str);
845 if(FAILED(hres))
846 return hres;
847
848 return return_bstr(res, str);
849}
static HRESULT return_bstr(VARIANT *res, BSTR str)
Definition: global.c:343

◆ Global_Date()

static HRESULT Global_Date ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2041 of file global.c.

2042{
2043 SYSTEMTIME lt;
2044 UDATE ud;
2045 DATE date;
2046 HRESULT hres;
2047
2048 TRACE("\n");
2049
2050 GetLocalTime(&lt);
2051 ud.st = lt;
2052 ud.wDayOfYear = 0;
2054 if(FAILED(hres))
2055 return hres;
2056 return return_date(res, date);
2057}
double DATE
Definition: compat.h:2253
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:272
__u16 date
Definition: mkdosfs.c:8
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
Definition: oleauto.h:720
SYSTEMTIME st
Definition: oleauto.h:721
USHORT wDayOfYear
Definition: oleauto.h:722
HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
Definition: variant.c:1345
static HRESULT return_date(VARIANT *res, double date)
Definition: global.c:410

◆ Global_DateAdd()

static HRESULT Global_DateAdd ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2402 of file global.c.

2403{
2404 BSTR interval = NULL;
2405 UDATE ud = {{ 0 }};
2406 HRESULT hres;
2407 double date;
2408 int count;
2409
2410 TRACE("\n");
2411
2412 assert(args_cnt == 3);
2413
2414 if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL)
2416
2417 if (V_VT(args + 2) == VT_NULL)
2418 return return_null(res);
2419
2421 if (SUCCEEDED(hres))
2422 hres = to_int(args + 1, &count);
2423 if (SUCCEEDED(hres))
2424 hres = to_system_time(args + 2, &ud.st);
2425 if (SUCCEEDED(hres))
2426 {
2427 if (!wcsicmp(interval, L"yyyy"))
2428 ud.st.wYear += count;
2429 else if (!wcsicmp(interval, L"q"))
2430 ud.st.wMonth += 3 * count;
2431 else if (!wcsicmp(interval, L"m"))
2432 ud.st.wMonth += count;
2433 else if (!wcsicmp(interval, L"y")
2434 || !wcsicmp(interval, L"d")
2435 || !wcsicmp(interval, L"w"))
2436 {
2437 ud.st.wDay += count;
2438 }
2439 else if (!wcsicmp(interval, L"ww"))
2440 ud.st.wDay += 7 * count;
2441 else if (!wcsicmp(interval, L"h"))
2442 ud.st.wHour += count;
2443 else if (!wcsicmp(interval, L"n"))
2444 ud.st.wMinute += count;
2445 else if (!wcsicmp(interval, L"s"))
2446 ud.st.wSecond += count;
2447 else
2448 {
2449 WARN("Unrecognized interval %s.\n", debugstr_w(interval));
2451 }
2452 }
2453
2455
2456 if (SUCCEEDED(hres))
2457 hres = VarDateFromUdateEx(&ud, 0, 0, &date);
2458
2459 if (SUCCEEDED(hres))
2461
2462 return hres;
2463}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define debugstr_w
Definition: kernel32.h:32
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
static HRESULT return_null(VARIANT *res)
Definition: global.c:403
static HRESULT to_system_time(VARIANT *v, SYSTEMTIME *st)
Definition: global.c:475

◆ Global_DateDiff()

static HRESULT Global_DateDiff ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2465 of file global.c.

2466{
2467 FIXME("\n");
2468 return E_NOTIMPL;
2469}

◆ Global_DatePart()

static HRESULT Global_DatePart ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2471 of file global.c.

2472{
2473 FIXME("\n");
2474 return E_NOTIMPL;
2475}

◆ Global_DateSerial()

static HRESULT Global_DateSerial ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2207 of file global.c.

2208{
2209 int year, month, day;
2210 UDATE ud = {{ 0 }};
2211 HRESULT hres;
2212 double date;
2213
2214 TRACE("\n");
2215
2216 assert(args_cnt == 3);
2217
2218 if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL || V_VT(args + 2) == VT_NULL)
2220
2221 hres = to_int(args, &year);
2222 if (SUCCEEDED(hres))
2223 hres = to_int(args + 1, &month);
2224 if (SUCCEEDED(hres))
2225 hres = to_int(args + 2, &day);
2226
2227 if (SUCCEEDED(hres))
2228 {
2229 ud.st.wYear = year;
2230 ud.st.wMonth = month;
2231 ud.st.wDay = day;
2232 hres = VarDateFromUdateEx(&ud, 0, 0, &date);
2233 }
2234
2235 if (SUCCEEDED(hres))
2237
2238 return hres;
2239}
static DOUBLE day(DOUBLE time)
Definition: date.c:75
static const WCHAR month[12][4]
Definition: session.c:2528

◆ Global_DateValue()

static HRESULT Global_DateValue ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2195 of file global.c.

2196{
2197 FIXME("\n");
2198 return E_NOTIMPL;
2199}

◆ Global_Day()

static HRESULT Global_Day ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2077 of file global.c.

2078{
2079 SYSTEMTIME st;
2080 HRESULT hres;
2081
2082 TRACE("(%s)\n", debugstr_variant(arg));
2083
2084 hres = to_system_time(arg, &st);
2085 return FAILED(hres) ? hres : return_short(res, st.wDay);
2086}

◆ Global_Erase()

static HRESULT Global_Erase ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2577 of file global.c.

2578{
2579 FIXME("\n");
2580 return E_NOTIMPL;
2581}

◆ Global_Err()

static HRESULT Global_Err ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3243 of file global.c.

3244{
3245 TRACE("\n");
3246
3247 if(args_cnt) {
3248 FIXME("Setter not supported\n");
3249 return E_NOTIMPL;
3250 }
3251
3252 V_VT(res) = VT_DISPATCH;
3253 V_DISPATCH(res) = &This->ctx->err_obj->IDispatch_iface;
3254 IDispatch_AddRef(V_DISPATCH(res));
3255 return S_OK;
3256}

◆ Global_Escape()

static HRESULT Global_Escape ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3207 of file global.c.

3208{
3209 FIXME("\n");
3210 return E_NOTIMPL;
3211}

◆ Global_Eval()

static HRESULT Global_Eval ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3219 of file global.c.

3220{
3221 FIXME("\n");
3222 return E_NOTIMPL;
3223}

◆ Global_Execute()

static HRESULT Global_Execute ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3225 of file global.c.

3226{
3227 FIXME("\n");
3228 return E_NOTIMPL;
3229}

◆ Global_ExecuteGlobal()

static HRESULT Global_ExecuteGlobal ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3231 of file global.c.

3232{
3233 FIXME("\n");
3234 return E_NOTIMPL;
3235}

◆ Global_Exp()

static HRESULT Global_Exp ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1055 of file global.c.

1056{
1057 HRESULT hres;
1058 double d;
1059
1060 hres = to_double(arg, &d);
1061 if(FAILED(hres))
1062 return hres;
1063
1064 return return_double(res, exp(d));
1065}
DWORD exp
Definition: msg.c:18625

◆ Global_Filter()

static HRESULT Global_Filter ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2583 of file global.c.

2584{
2585 FIXME("\n");
2586 return E_NOTIMPL;
2587}

◆ Global_Fix()

static HRESULT Global_Fix ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1966 of file global.c.

1967{
1968 HRESULT hres;
1969 VARIANT dst;
1970
1971 TRACE("(%s)\n", debugstr_variant(arg));
1972
1973 assert(args_cnt == 1);
1974
1975 hres = VarFix(arg, &dst);
1976 if(FAILED(hres))
1977 return hres;
1978
1979 if (res)
1980 *res = dst;
1981 else
1982 VariantClear(&dst);
1983
1984 return S_OK;
1985}
HRESULT WINAPI VarFix(LPVARIANT pVarIn, LPVARIANT pVarOut)
Definition: variant.c:4367

◆ Global_FormatCurrency()

static HRESULT Global_FormatCurrency ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3003 of file global.c.

3004{
3005 union
3006 {
3007 struct
3008 {
3009 int num_dig, inc_lead, use_parens, group;
3010 } s;
3011 int val[4];
3012 } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 };
3013 HRESULT hres;
3014 BSTR str;
3015 int i;
3016
3017 TRACE("\n");
3018
3019 assert(1 <= args_cnt && args_cnt <= 5);
3020
3021 for (i = 1; i < args_cnt; ++i)
3022 {
3023 if (V_VT(args+i) == VT_ERROR) continue;
3025 if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres;
3026 }
3027
3028 hres = VarFormatCurrency(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens,
3029 int_args.s.group, 0, &str);
3030 if (FAILED(hres)) return hres;
3031
3032 return return_bstr(res, str);
3033}
@ VT_ERROR
Definition: compat.h:2305
HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens, INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2420
GLdouble s
Definition: gl.h:2039
GLboolean GLuint group
Definition: glext.h:11120

◆ Global_FormatDateTime()

static HRESULT Global_FormatDateTime ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3073 of file global.c.

3074{
3075 int format = 0;
3076 HRESULT hres;
3077 BSTR str;
3078
3079 TRACE("\n");
3080
3081 assert(1 <= args_cnt && args_cnt <= 2);
3082
3083 if (V_VT(args) == VT_NULL)
3085
3086 if (args_cnt == 2)
3087 {
3089 if (V_VT(args+1) != VT_ERROR)
3090 {
3091 if (FAILED(hres = to_int(args+1, &format))) return hres;
3092 }
3093 }
3094
3096 if (FAILED(hres)) return hres;
3097
3098 return return_bstr(res, str);
3099}
HRESULT WINAPI VarFormatDateTime(LPVARIANT pVarIn, INT nFormat, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2190
#define VBSE_TYPE_MISMATCH
Definition: format.c:58

◆ Global_FormatNumber()

static HRESULT Global_FormatNumber ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2971 of file global.c.

2972{
2973 union
2974 {
2975 struct
2976 {
2977 int num_dig, inc_lead, use_parens, group;
2978 } s;
2979 int val[4];
2980 } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 };
2981 HRESULT hres;
2982 BSTR str;
2983 int i;
2984
2985 TRACE("\n");
2986
2987 assert(1 <= args_cnt && args_cnt <= 5);
2988
2989 for (i = 1; i < args_cnt; ++i)
2990 {
2991 if (V_VT(args+i) == VT_ERROR) continue;
2993 if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres;
2994 }
2995
2996 hres = VarFormatNumber(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens,
2997 int_args.s.group, 0, &str);
2998 if (FAILED(hres)) return hres;
2999
3000 return return_bstr(res, str);
3001}
HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens, INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2241

◆ Global_FormatPercent()

static HRESULT Global_FormatPercent ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3035 of file global.c.

3036{
3037 union
3038 {
3039 struct
3040 {
3041 int num_dig, inc_lead, use_parens, group;
3042 } s;
3043 int val[4];
3044 } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 };
3045 HRESULT hres;
3046 BSTR str;
3047 int i;
3048
3049 TRACE("\n");
3050
3051 assert(1 <= args_cnt && args_cnt <= 5);
3052
3053 for (i = 1; i < args_cnt; ++i)
3054 {
3055 if (V_VT(args+i) == VT_ERROR) continue;
3057 if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres;
3058 }
3059
3060 hres = VarFormatPercent(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens,
3061 int_args.s.group, 0, &str);
3062 if (FAILED(hres)) return hres;
3063
3064 return return_bstr(res, str);
3065}
HRESULT WINAPI VarFormatPercent(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens, INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2345

◆ Global_GetLocale()

static HRESULT Global_GetLocale ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3067 of file global.c.

3068{
3069 FIXME("\n");
3070 return E_NOTIMPL;
3071}

◆ Global_GetObject()

static HRESULT Global_GetObject ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2345 of file global.c.

2346{
2347 IBindCtx *bind_ctx;
2348 IUnknown *obj_unk;
2349 IDispatch *disp;
2350 ULONG eaten = 0;
2351 IMoniker *mon;
2352 HRESULT hres;
2353
2354 TRACE("%s %s\n", args_cnt ? debugstr_variant(args) : "", args_cnt > 1 ? debugstr_variant(args+1) : "");
2355
2356 if(args_cnt != 1 || V_VT(args) != VT_BSTR) {
2357 FIXME("unsupported args\n");
2358 return E_NOTIMPL;
2359 }
2360
2361 if(This->ctx->safeopt & (INTERFACE_USES_SECURITY_MANAGER|INTERFACESAFE_FOR_UNTRUSTED_DATA)) {
2362 WARN("blocked in current safety mode\n");
2364 }
2365
2366 hres = CreateBindCtx(0, &bind_ctx);
2367 if(FAILED(hres))
2368 return hres;
2369
2370 hres = MkParseDisplayName(bind_ctx, V_BSTR(args), &eaten, &mon);
2371 if(SUCCEEDED(hres)) {
2372 hres = IMoniker_BindToObject(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&obj_unk);
2373 IMoniker_Release(mon);
2374 }else {
2375 hres = MK_E_SYNTAX;
2376 }
2377 IBindCtx_Release(bind_ctx);
2378 if(FAILED(hres))
2379 return hres;
2380
2381 hres = set_object_site(This->ctx, obj_unk);
2382 if(FAILED(hres)) {
2383 IUnknown_Release(obj_unk);
2384 return hres;
2385 }
2386
2387 hres = IUnknown_QueryInterface(obj_unk, &IID_IDispatch, (void**)&disp);
2388 if(SUCCEEDED(hres)) {
2389 if(res) {
2390 V_VT(res) = VT_DISPATCH;
2391 V_DISPATCH(res) = disp;
2392 }else {
2393 IDispatch_Release(disp);
2394 }
2395 }else {
2396 FIXME("object does not support IDispatch\n");
2397 }
2398
2399 return hres;
2400}
HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szDisplayName, LPDWORD pchEaten, LPMONIKER *ppmk)
Definition: moniker.c:838
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
Definition: bindctx.c:491
uint32_t ULONG
Definition: typedefs.h:59
#define MK_E_SYNTAX
Definition: winerror.h:3896

◆ Global_GetRef()

static HRESULT Global_GetRef ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3237 of file global.c.

3238{
3239 FIXME("\n");
3240 return E_NOTIMPL;
3241}

◆ Global_Hex()

static HRESULT Global_Hex ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 856 of file global.c.

857{
858 WCHAR buf[17], *ptr;
859 DWORD n;
861 int ret;
862
863 TRACE("%s\n", debugstr_variant(arg));
864
865 switch(V_VT(arg)) {
866 case VT_I2:
867 n = (WORD)V_I2(arg);
868 break;
869 case VT_NULL:
870 return return_null(res);
871 default:
872 hres = to_int(arg, &ret);
873 if(FAILED(hres))
874 return hres;
875 else
876 n = ret;
877 }
878
879 buf[16] = 0;
880 ptr = buf+15;
881
882 if(n) {
883 do {
884 *ptr-- = hex_char(n & 0xf);
885 n >>= 4;
886 }while(n);
887 ptr++;
888 }else {
889 *ptr = '0';
890 }
891
892 return return_string(res, ptr);
893}
unsigned short WORD
Definition: ntddk_ex.h:93
static PVOID ptr
Definition: dispmode.c:27
static WCHAR hex_char(unsigned n)
Definition: global.c:851

◆ Global_Hour()

static HRESULT Global_Hour ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2156 of file global.c.

2157{
2158 SYSTEMTIME st;
2159 HRESULT hres;
2160
2161 TRACE("(%s)\n", debugstr_variant(arg));
2162
2163 hres = to_system_time(arg, &st);
2164 return FAILED(hres) ? hres : return_short(res, st.wHour);
2165}

◆ Global_InputBox()

static HRESULT Global_InputBox ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2278 of file global.c.

2279{
2280 FIXME("\n");
2281 return E_NOTIMPL;
2282}

◆ Global_InStr()

static HRESULT Global_InStr ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1731 of file global.c.

1732{
1733 VARIANT *startv, *str1v, *str2v;
1734 BSTR str1, str2;
1735 int ret = -1, start = 0, mode = 0;
1736 HRESULT hres;
1737
1738 TRACE("args_cnt=%u\n", args_cnt);
1739
1740 assert(2 <= args_cnt && args_cnt <= 4);
1741
1742 switch(args_cnt) {
1743 case 2:
1744 startv = NULL;
1745 str1v = args;
1746 str2v = args+1;
1747 break;
1748 case 3:
1749 startv = args;
1750 str1v = args+1;
1751 str2v = args+2;
1752 break;
1753 case 4:
1754 startv = args;
1755 str1v = args+1;
1756 str2v = args+2;
1757
1758 if(V_VT(args+3) == VT_NULL)
1760
1761 hres = to_int(args+3, &mode);
1762 if(FAILED(hres))
1763 return hres;
1764
1765 if (mode != 0 && mode != 1)
1767
1768 break;
1770 }
1771
1772 if(startv) {
1773 if(V_VT(startv) == VT_NULL)
1775
1776 hres = to_int(startv, &start);
1777 if(FAILED(hres))
1778 return hres;
1779 if(--start < 0)
1781 }
1782
1783 if(V_VT(str1v) == VT_NULL || V_VT(str2v) == VT_NULL)
1784 return return_null(res);
1785
1786 if(V_VT(str1v) != VT_BSTR) {
1787 hres = to_string(str1v, &str1);
1788 if(FAILED(hres))
1789 return hres;
1790 }
1791 else
1792 str1 = V_BSTR(str1v);
1793
1794 if(V_VT(str2v) != VT_BSTR) {
1795 hres = to_string(str2v, &str2);
1796 if(FAILED(hres)){
1797 if(V_VT(str1v) != VT_BSTR)
1799 return hres;
1800 }
1801 }
1802 else
1803 str2 = V_BSTR(str2v);
1804
1805 if(start < SysStringLen(str1)) {
1808 }
1809
1810 if(V_VT(str1v) != VT_BSTR)
1812 if(V_VT(str2v) != VT_BSTR)
1814 return return_int(res, ++ret ? ret+start : 0);
1815}
INT WINAPI DECLSPEC_HOTPATCH FindStringOrdinal(DWORD flag, const WCHAR *src, INT src_size, const WCHAR *val, INT val_size, BOOL ignore_case)
Definition: locale.c:5257
GLuint start
Definition: gl.h:1545
GLenum mode
Definition: glext.h:6217
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
#define FIND_FROMSTART
Definition: winnls.h:230

◆ Global_InStrB()

static HRESULT Global_InStrB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1817 of file global.c.

1818{
1819 FIXME("\n");
1820 return E_NOTIMPL;
1821}

◆ Global_InStrRev()

static HRESULT Global_InStrRev ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2850 of file global.c.

2851{
2852 int start = -1, ret = -1, mode = 0;
2853 BSTR str1, str2;
2854 size_t len1, len2;
2855 HRESULT hres;
2856
2857 TRACE("%s %s arg_cnt=%u\n", debugstr_variant(args), debugstr_variant(args+1), args_cnt);
2858
2859 assert(2 <= args_cnt && args_cnt <= 4);
2860
2861 if(V_VT(args) == VT_NULL || V_VT(args+1) == VT_NULL || (args_cnt > 2 && V_VT(args+2) == VT_NULL)
2862 || (args_cnt == 4 && V_VT(args+3) == VT_NULL))
2864
2865 if(args_cnt == 4) {
2866 hres = to_int(args+3, &mode);
2867 if(FAILED(hres))
2868 return hres;
2869 if (mode != 0 && mode != 1)
2871 }
2872
2873 if(args_cnt >= 3) {
2874 hres = to_int(args+2, &start);
2875 if(FAILED(hres))
2876 return hres;
2877 if(!start || start < -1)
2879 }
2880
2881 if(V_VT(args) != VT_BSTR) {
2882 hres = to_string(args, &str1);
2883 if(FAILED(hres))
2884 return hres;
2885 }
2886 else
2887 str1 = V_BSTR(args);
2888
2889 if(V_VT(args+1) != VT_BSTR) {
2890 hres = to_string(args+1, &str2);
2891 if(FAILED(hres)) {
2892 if(V_VT(args) != VT_BSTR)
2894 return hres;
2895 }
2896 }
2897 else
2898 str2 = V_BSTR(args+1);
2899
2900 len1 = SysStringLen(str1);
2901 if(!len1) {
2902 ret = 0;
2903 goto end;
2904 }
2905
2906 if(start == -1)
2907 start = len1;
2908
2909 len2 = SysStringLen(str2);
2910 if(!len2) {
2911 ret = start;
2912 goto end;
2913 }
2914
2915 if(start >= len2 && start <= len1) {
2917 str2, len2, mode);
2918 }
2919 ret++;
2920
2921end:
2922 if(V_VT(args) != VT_BSTR)
2924 if(V_VT(args+1) != VT_BSTR)
2926 return return_int(res, ret);
2927}
GLuint GLuint end
Definition: gl.h:1545
#define FIND_FROMEND
Definition: winnls.h:231

◆ Global_Int()

static HRESULT Global_Int ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1987 of file global.c.

1988{
1989 HRESULT hres;
1990 VARIANT dst;
1991
1992 TRACE("(%s)\n", debugstr_variant(arg));
1993
1994 assert(args_cnt == 1);
1995
1996 hres = VarInt(arg, &dst);
1997 if(FAILED(hres))
1998 return hres;
1999
2000 if (res)
2001 *res = dst;
2002 else
2003 VariantClear(&dst);
2004
2005 return S_OK;
2006}
HRESULT WINAPI VarInt(LPVARIANT pVarIn, LPVARIANT pVarOut)
Definition: variant.c:4473

◆ Global_IsArray()

static HRESULT Global_IsArray ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 989 of file global.c.

990{
991 TRACE("(%s)\n", debugstr_variant(arg));
992
993 assert(args_cnt == 1);
994
995 return return_bool(res, V_ISARRAY(arg));
996}
#define V_ISARRAY(A)
Definition: oleauto.h:218
static HRESULT return_bool(VARIANT *res, BOOL val)
Definition: global.c:354

◆ Global_IsDate()

static HRESULT Global_IsDate ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 951 of file global.c.

952{
953 TRACE("%s\n", debugstr_variant(arg));
954
955 return return_bool(res, V_VT(arg) == VT_DATE);
956}

◆ Global_IsEmpty()

static HRESULT Global_IsEmpty ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 958 of file global.c.

959{
960 TRACE("(%s)\n", debugstr_variant(arg));
961
962 assert(args_cnt == 1);
963 return return_bool(res, V_VT(arg) == VT_EMPTY);
964}

◆ Global_IsNull()

static HRESULT Global_IsNull ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 966 of file global.c.

967{
968 TRACE("(%s)\n", debugstr_variant(arg));
969
970 assert(args_cnt == 1);
971
972 return return_bool(res, V_VT(arg) == VT_NULL);
973}

◆ Global_IsNumeric()

static HRESULT Global_IsNumeric ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 975 of file global.c.

976{
978 double d;
979
980 TRACE("(%s)\n", debugstr_variant(arg));
981
982 assert(args_cnt == 1);
983
984 hres = to_double(arg, &d);
985
986 return return_bool(res, SUCCEEDED(hres));
987}

◆ Global_IsObject()

static HRESULT Global_IsObject ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 998 of file global.c.

999{
1000 TRACE("(%s)\n", debugstr_variant(arg));
1001
1002 assert(args_cnt == 1);
1003
1004 return return_bool(res, V_VT(arg) == VT_DISPATCH);
1005}

◆ Global_Join()

static HRESULT Global_Join ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2589 of file global.c.

2590{
2591 FIXME("\n");
2592 return E_NOTIMPL;
2593}

◆ Global_LBound()

static HRESULT Global_LBound ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1174 of file global.c.

1175{
1176 SAFEARRAY *sa;
1177 HRESULT hres;
1178 LONG lbound;
1179 int dim;
1180
1181 assert(args_cnt == 1 || args_cnt == 2);
1182
1183 TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
1184
1185 switch(V_VT(arg)) {
1186 case VT_VARIANT|VT_ARRAY:
1187 sa = V_ARRAY(arg);
1188 break;
1190 sa = *V_ARRAYREF(arg);
1191 break;
1192 case VT_EMPTY:
1193 case VT_NULL:
1195 default:
1196 FIXME("arg %s not supported\n", debugstr_variant(arg));
1197 return E_NOTIMPL;
1198 }
1199
1200 if(args_cnt == 2) {
1201 hres = to_int(arg + 1, &dim);
1202 if(FAILED(hres))
1203 return hres;
1204 }else {
1205 dim = 1;
1206 }
1207
1208 hres = SafeArrayGetLBound(sa, dim, &lbound);
1209 if(FAILED(hres))
1210 return hres;
1211
1212 return return_int(res, lbound);
1213}
HRESULT WINAPI SafeArrayGetLBound(SAFEARRAY *psa, UINT nDim, LONG *plLbound)
Definition: safearray.c:1066
#define V_ARRAYREF(A)
Definition: oleauto.h:223

◆ Global_LCase()

static HRESULT Global_LCase ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1523 of file global.c.

1524{
1525 BSTR str;
1526 HRESULT hres;
1527
1528 TRACE("%s\n", debugstr_variant(arg));
1529
1530 if(V_VT(arg) == VT_NULL) {
1531 return return_null(res);
1532 }
1533
1534 hres = to_string(arg, &str);
1535 if(FAILED(hres))
1536 return hres;
1537
1538 if(res) {
1539 WCHAR *ptr;
1540
1541 for(ptr = str; *ptr; ptr++)
1542 *ptr = towlower(*ptr);
1543
1544 V_VT(res) = VT_BSTR;
1545 V_BSTR(res) = str;
1546 }else {
1548 }
1549 return S_OK;
1550}
#define towlower(c)
Definition: wctype.h:97

◆ Global_Left()

static HRESULT Global_Left ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1310 of file global.c.

1311{
1312 BSTR str, ret, conv_str = NULL;
1313 int len, str_len;
1314 HRESULT hres;
1315
1316 TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
1317
1318 if(V_VT(args) == VT_BSTR) {
1319 str = V_BSTR(args);
1320 }else {
1321 hres = to_string(args, &conv_str);
1322 if(FAILED(hres))
1323 return hres;
1324 str = conv_str;
1325 }
1326
1327 hres = to_int(args+1, &len);
1328 if(FAILED(hres))
1329 return hres;
1330
1331 if(len < 0) {
1332 FIXME("len = %d\n", len);
1333 return E_FAIL;
1334 }
1335
1337 if(len > str_len)
1338 len = str_len;
1339
1341 SysFreeString(conv_str);
1342 if(!ret)
1343 return E_OUTOFMEMORY;
1344
1345 return return_bstr(res, ret);
1346}
#define str_len
Definition: treelist.c:89

◆ Global_LeftB()

static HRESULT Global_LeftB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1348 of file global.c.

1349{
1350 FIXME("\n");
1351 return E_NOTIMPL;
1352}

◆ Global_Len()

static HRESULT Global_Len ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1278 of file global.c.

1279{
1280 DWORD len;
1281 HRESULT hres;
1282
1283 TRACE("%s\n", debugstr_variant(arg));
1284
1285 if(V_VT(arg) == VT_NULL)
1286 return return_null(res);
1287
1288 if(V_VT(arg) != VT_BSTR) {
1289 BSTR str;
1290
1291 hres = to_string(arg, &str);
1292 if(FAILED(hres))
1293 return hres;
1294
1295 len = SysStringLen(str);
1297 }else {
1299 }
1300
1301 return return_int(res, len);
1302}

◆ Global_LenB()

static HRESULT Global_LenB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1304 of file global.c.

1305{
1306 FIXME("\n");
1307 return E_NOTIMPL;
1308}

◆ Global_LoadPicture()

static HRESULT Global_LoadPicture ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2929 of file global.c.

2930{
2931 FIXME("\n");
2932 return E_NOTIMPL;
2933}

◆ Global_Log()

static HRESULT Global_Log ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1067 of file global.c.

1068{
1069 HRESULT hres;
1070 double d;
1071
1072 hres = to_double(arg, &d);
1073 if(FAILED(hres))
1074 return hres;
1075
1076 if(d <= 0)
1078 else
1079 return return_double(res, log(d));
1080}
#define log(outFile, fmt,...)
Definition: util.h:15

◆ Global_LTrim()

static HRESULT Global_LTrim ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1581 of file global.c.

1582{
1583 BSTR str, conv_str = NULL;
1584 WCHAR *ptr;
1585 HRESULT hres;
1586
1587 TRACE("%s\n", debugstr_variant(arg));
1588
1589 if(V_VT(arg) == VT_BSTR) {
1590 str = V_BSTR(arg);
1591 }else {
1592 hres = to_string(arg, &conv_str);
1593 if(FAILED(hres))
1594 return hres;
1595 str = conv_str;
1596 }
1597
1598 for(ptr = str; *ptr && iswspace(*ptr); ptr++);
1599
1601 SysFreeString(conv_str);
1602 if(!str)
1603 return E_OUTOFMEMORY;
1604
1605 return return_bstr(res, str);
1606}
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define iswspace(_c)
Definition: ctype.h:669

◆ Global_Mid()

static HRESULT Global_Mid ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1402 of file global.c.

1403{
1404 int len = -1, start, str_len;
1405 BSTR str, conv_str = NULL;
1406 HRESULT hres;
1407
1408 TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
1409
1410 assert(args_cnt == 2 || args_cnt == 3);
1411
1412 if(V_VT(args+1) == VT_NULL || (args_cnt == 3 && V_VT(args+2) == VT_NULL))
1414
1415 if(V_VT(args+1) == VT_EMPTY)
1417
1418 hres = to_int(args+1, &start);
1419 if(FAILED(hres))
1420 return hres;
1421
1422 if(start <= 0)
1424
1425 if(args_cnt == 3) {
1426 if(V_VT(args+2) == VT_EMPTY)
1428
1429 hres = to_int(args+2, &len);
1430 if(FAILED(hres))
1431 return hres;
1432
1433 if(len < 0)
1435 }
1436
1437 if(V_VT(args) == VT_EMPTY)
1438 return return_string(res, L"");
1439
1440 if(V_VT(args) == VT_NULL)
1441 return return_null(res);
1442
1443 if(V_VT(args) == VT_BSTR) {
1444 str = V_BSTR(args);
1445 }else {
1446 hres = to_string(args, &conv_str);
1447 if(FAILED(hres))
1448 return hres;
1449 str = conv_str;
1450 }
1451
1453 start--;
1454 if(start > str_len)
1455 start = str_len;
1456
1457 if(len == -1)
1458 len = str_len-start;
1459 else if(len > str_len-start)
1460 len = str_len-start;
1461
1462 if(res) {
1463 V_VT(res) = VT_BSTR;
1465 if(!V_BSTR(res))
1467 }
1468
1469 SysFreeString(conv_str);
1470
1471 return hres;
1472}

◆ Global_MidB()

static HRESULT Global_MidB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1474 of file global.c.

1475{
1476 FIXME("\n");
1477 return E_NOTIMPL;
1478}

◆ Global_Minute()

static HRESULT Global_Minute ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2167 of file global.c.

2168{
2169 SYSTEMTIME st;
2170 HRESULT hres;
2171
2172 TRACE("(%s)\n", debugstr_variant(arg));
2173
2174 hres = to_system_time(arg, &st);
2175 return FAILED(hres) ? hres : return_short(res, st.wMinute);
2176}

◆ Global_Month()

static HRESULT Global_Month ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2088 of file global.c.

2089{
2090 SYSTEMTIME st;
2091 HRESULT hres;
2092
2093 TRACE("(%s)\n", debugstr_variant(arg));
2094
2095 hres = to_system_time(arg, &st);
2096 return FAILED(hres) ? hres : return_short(res, st.wMonth);
2097}

◆ Global_MonthName()

static HRESULT Global_MonthName ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3134 of file global.c.

3135{
3136 int month, abbrev = 0;
3137 BSTR ret;
3138 HRESULT hres;
3139
3140 TRACE("\n");
3141
3142 assert(args_cnt == 1 || args_cnt == 2);
3143
3144 if(V_VT(args) == VT_NULL || (args_cnt == 2 && V_VT(args+1) == VT_NULL))
3146
3147 hres = to_int(args, &month);
3148 if(FAILED(hres))
3149 return hres;
3150
3151 if(args_cnt == 2) {
3152 hres = to_int(args+1, &abbrev);
3153 if(FAILED(hres))
3154 return hres;
3155 }
3156
3157 hres = VarMonthName(month, abbrev, 0, &ret);
3158 if(FAILED(hres))
3159 return hres;
3160
3161 return return_bstr(res, ret);
3162}
HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2517

◆ Global_MsgBox()

static HRESULT Global_MsgBox ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2284 of file global.c.

2285{
2286 BSTR prompt, title = NULL;
2287 int type = MB_OK;
2288 HRESULT hres;
2289
2290 TRACE("\n");
2291
2292 assert(1 <= args_cnt && args_cnt <= 5);
2293
2294 hres = to_string(args, &prompt);
2295 if(FAILED(hres))
2296 return hres;
2297
2298 if(args_cnt > 1)
2299 hres = to_int(args+1, &type);
2300
2301 if(SUCCEEDED(hres) && args_cnt > 2)
2302 hres = to_string(args+2, &title);
2303
2304 if(SUCCEEDED(hres) && args_cnt > 3) {
2305 FIXME("unsupported arg_cnt %d\n", args_cnt);
2306 hres = E_NOTIMPL;
2307 }
2308
2309 if(SUCCEEDED(hres))
2310 hres = show_msgbox(This->ctx, prompt, type, title, res);
2311
2312 SysFreeString(prompt);
2314 return hres;
2315}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static char title[]
Definition: ps.c:92
static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR orig_title, VARIANT *res)
Definition: global.c:580
#define MB_OK
Definition: winuser.h:801

◆ Global_Now()

static HRESULT Global_Now ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2029 of file global.c.

2030{
2031 SYSTEMTIME lt;
2032 double date;
2033
2034 TRACE("\n");
2035
2036 GetLocalTime(&lt);
2038 return return_date(res, date);
2039}
INT WINAPI SystemTimeToVariantTime(LPSYSTEMTIME lpSt, double *pDateOut)
Definition: variant.c:1286

◆ Global_Oct()

static HRESULT Global_Oct ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 895 of file global.c.

896{
898 WCHAR buf[23], *ptr;
899 DWORD n;
900 int ret;
901
902 TRACE("%s\n", debugstr_variant(arg));
903
904 switch(V_VT(arg)) {
905 case VT_I2:
906 n = (WORD)V_I2(arg);
907 break;
908 case VT_NULL:
909 return return_null(res);
910 default:
911 hres = to_int(arg, &ret);
912 if(FAILED(hres))
913 return hres;
914 else
915 n = ret;
916 }
917
918 buf[22] = 0;
919 ptr = buf + 21;
920
921 if(n) {
922 do {
923 *ptr-- = '0' + (n & 0x7);
924 n >>= 3;
925 }while(n);
926 ptr++;
927 }else {
928 *ptr = '0';
929 }
930
931 return return_string(res, ptr);
932}

◆ Global_Randomize()

static HRESULT Global_Randomize ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1102 of file global.c.

1103{
1104 union
1105 {
1106 double d;
1107 unsigned int i[2];
1108 } dtoi;
1109 unsigned int seed;
1110 HRESULT hres;
1111
1112 assert(args_cnt == 0 || args_cnt == 1);
1113 if (args_cnt == 1) {
1114 hres = to_double(arg, &dtoi.d);
1115 if (FAILED(hres))
1116 return hres;
1117 }
1118 else
1119 dtoi.d = GetTickCount() * 0.001;
1120
1121 seed = dtoi.i[1];
1122 seed ^= (seed >> 16);
1123 seed = ((seed & 0xffff) << 8) | (This->ctx->script_obj->rnd & 0xff);
1124 This->ctx->script_obj->rnd = seed;
1125
1126 return res ? DISP_E_TYPEMISMATCH : S_OK;
1127}
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:3617

◆ Global_Replace()

static HRESULT Global_Replace ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2737 of file global.c.

2738{
2740 int from = 1, cnt = -1, mode = 0;
2741 HRESULT hres = S_OK;
2742
2743 TRACE("%s %s %s %u...\n", debugstr_variant(args), debugstr_variant(args+1), debugstr_variant(args+2), args_cnt);
2744
2745 assert(3 <= args_cnt && args_cnt <= 6);
2746
2747 if(V_VT(args) == VT_NULL || V_VT(args+1) == VT_NULL || (V_VT(args+2) == VT_NULL)
2748 || (args_cnt >= 4 && V_VT(args+3) == VT_NULL) || (args_cnt >= 5 && V_VT(args+4) == VT_NULL)
2749 || (args_cnt == 6 && V_VT(args+5) == VT_NULL))
2751
2752
2753 if(V_VT(args) != VT_BSTR) {
2754 hres = to_string(args, &string);
2755 if(FAILED(hres))
2756 return hres;
2757 }else {
2758 string = V_BSTR(args);
2759 }
2760
2761 if(V_VT(args+1) != VT_BSTR) {
2762 hres = to_string(args+1, &find);
2763 if(FAILED(hres))
2764 goto error;
2765 }else {
2766 find = V_BSTR(args+1);
2767 }
2768
2769 if(V_VT(args+2) != VT_BSTR) {
2770 hres = to_string(args+2, &replace);
2771 if(FAILED(hres))
2772 goto error;
2773 }else {
2774 replace = V_BSTR(args+2);
2775 }
2776
2777 if(args_cnt >= 4) {
2778 hres = to_int(args+3, &from);
2779 if(FAILED(hres))
2780 goto error;
2781 if(from < 1) {
2783 goto error;
2784 }
2785 }
2786
2787 if(args_cnt >= 5) {
2788 hres = to_int(args+4, &cnt);
2789 if(FAILED(hres))
2790 goto error;
2791 if(cnt < -1) {
2793 goto error;
2794 }
2795 }
2796
2797 if(args_cnt == 6) {
2798 hres = to_int(args+5, &mode);
2799 if(FAILED(hres))
2800 goto error;
2801 if (mode != 0 && mode != 1) {
2803 goto error;
2804 }
2805 }
2806
2807 ret = string_replace(string, find, replace, from - 1, cnt, mode);
2808 if(!ret) {
2810 }else if(res) {
2811 V_VT(res) = VT_BSTR;
2812 V_BSTR(res) = ret;
2813 }else {
2815 }
2816
2817error:
2818 if(V_VT(args) != VT_BSTR)
2819 SysFreeString(string);
2820 if(V_VT(args+1) != VT_BSTR)
2822 if(V_VT(args+2) != VT_BSTR)
2824 return hres;
2825}
static TAGID TAGID find
Definition: db.cpp:156
#define error(str)
Definition: mkdosfs.c:1605
char string[160]
Definition: util.h:11
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:38
CardRegion * from
Definition: spigame.cpp:19
BSTR string_replace(BSTR string, BSTR find, BSTR replace, int from, int cnt, int mode)
Definition: vbregexp.c:1635
_In_ size_t cnt
Definition: wcstombs.cpp:43

◆ Global_RGB()

static HRESULT Global_RGB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1256 of file global.c.

1257{
1258 HRESULT hres;
1259 int i, color[3];
1260
1262
1263 assert(args_cnt == 3);
1264
1265 for(i = 0; i < 3; i++) {
1266 hres = to_int(arg + i, color + i);
1267 if(FAILED(hres))
1268 return hres;
1269 if(color[i] > 255)
1270 color[i] = 255;
1271 if(color[i] < 0)
1273 }
1274
1275 return return_int(res, RGB(color[0], color[1], color[2]));
1276}
#define RGB(r, g, b)
Definition: precomp.h:67
GLuint color
Definition: glext.h:6243

◆ Global_Right()

static HRESULT Global_Right ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1354 of file global.c.

1355{
1356 BSTR str, ret, conv_str = NULL;
1357 int len, str_len;
1358 HRESULT hres;
1359
1360 TRACE("(%s %s)\n", debugstr_variant(args), debugstr_variant(args+1));
1361
1362 if(V_VT(args+1) == VT_NULL)
1364
1365 hres = to_int(args+1, &len);
1366 if(FAILED(hres))
1367 return hres;
1368
1369 if(len < 0)
1371
1372 if(V_VT(args) == VT_NULL)
1373 return return_null(res);
1374
1375 if(V_VT(args) == VT_BSTR) {
1376 str = V_BSTR(args);
1377 }else {
1378 hres = to_string(args, &conv_str);
1379 if(FAILED(hres))
1380 return hres;
1381 str = conv_str;
1382 }
1383
1385 if(len > str_len)
1386 len = str_len;
1387
1389 SysFreeString(conv_str);
1390 if(!ret)
1391 return E_OUTOFMEMORY;
1392
1393 return return_bstr(res, ret);
1394}

◆ Global_RightB()

static HRESULT Global_RightB ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1396 of file global.c.

1397{
1398 FIXME("\n");
1399 return E_NOTIMPL;
1400}

◆ Global_Rnd()

static HRESULT Global_Rnd ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1129 of file global.c.

1130{
1131 static const float modulus = 16777216.0f;
1132 unsigned int value;
1133 HRESULT hres;
1134 float f;
1135
1136 assert(args_cnt == 0 || args_cnt == 1);
1137
1138 value = This->ctx->script_obj->rnd;
1139 if (args_cnt == 1)
1140 {
1141 hres = to_float(arg, &f);
1142 if (FAILED(hres))
1143 return hres;
1144
1145 if (f < 0.0f)
1146 {
1147 value = *(unsigned int *)&f;
1148 This->ctx->script_obj->rnd = value = get_next_rnd(value + (value >> 24));
1149 }
1150 else if (f == 0.0f)
1151 value = This->ctx->script_obj->rnd;
1152 else
1153 This->ctx->script_obj->rnd = value = get_next_rnd(value);
1154 }
1155 else
1156 {
1157 This->ctx->script_obj->rnd = value = get_next_rnd(value);
1158 }
1159
1160 return return_float(res, (float)value / modulus);
1161}
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
static HRESULT to_float(VARIANT *v, float *ret)
Definition: global.c:447
static HRESULT return_float(VARIANT *res, float val)
Definition: global.c:393
static unsigned int get_next_rnd(int value)
Definition: global.c:1097

◆ Global_Round()

static HRESULT Global_Round ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3164 of file global.c.

3165{
3166 int decimal_places = 0;
3167 double d;
3168 HRESULT hres;
3169
3170 TRACE("%s %s\n", debugstr_variant(args), args_cnt == 2 ? debugstr_variant(args + 1) : "0");
3171
3172 assert(args_cnt == 1 || args_cnt == 2);
3173
3174 if(!res)
3175 return S_OK;
3176
3177 if(args_cnt == 2) {
3178 if (V_VT(args + 1) != VT_ERROR) {
3179 hres = to_int(args + 1, &decimal_places);
3180 if (FAILED(hres))
3181 return hres;
3182 }
3183 }
3184
3185 switch(V_VT(args)) {
3186 case VT_I2:
3187 case VT_I4:
3188 case VT_BOOL:
3189 *res = *args;
3190 return S_OK;
3191 case VT_R8:
3192 d = V_R8(args);
3193 break;
3194 default:
3195 hres = to_double(args, &d);
3196 if(FAILED(hres))
3197 return hres;
3198 }
3199
3200 hres = VarR8Round(d, decimal_places, &d);
3201 if(FAILED(hres))
3202 return hres;
3203
3204 return return_double(res, d);
3205}
HRESULT WINAPI VarR8Round(double dblIn, int nDig, double *pDblOut)
Definition: vartype.c:3368
#define V_R8(A)
Definition: oleauto.h:262

◆ Global_RTrim()

static HRESULT Global_RTrim ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1608 of file global.c.

1609{
1610 BSTR str, conv_str = NULL;
1611 WCHAR *ptr;
1612 HRESULT hres;
1613
1614 TRACE("%s\n", debugstr_variant(arg));
1615
1616 if(V_VT(arg) == VT_BSTR) {
1617 str = V_BSTR(arg);
1618 }else {
1619 hres = to_string(arg, &conv_str);
1620 if(FAILED(hres))
1621 return hres;
1622 str = conv_str;
1623 }
1624
1625 for(ptr = str+SysStringLen(str); ptr-1 > str && iswspace(*(ptr-1)); ptr--);
1626
1628 SysFreeString(conv_str);
1629 if(!str)
1630 return E_OUTOFMEMORY;
1631
1632 return return_bstr(res, str);
1633}

◆ Global_ScriptEngine()

static HRESULT Global_ScriptEngine ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2935 of file global.c.

2936{
2937 TRACE("%s\n", debugstr_variant(arg));
2938
2939 assert(args_cnt == 0);
2940
2941 return return_string(res, L"VBScript");
2942}

◆ Global_ScriptEngineBuildVersion()

static HRESULT Global_ScriptEngineBuildVersion ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2962 of file global.c.

2963{
2964 TRACE("%s\n", debugstr_variant(arg));
2965
2966 assert(args_cnt == 0);
2967
2969}
#define VBSCRIPT_BUILD_VERSION
Definition: vbscript.h:432

◆ Global_ScriptEngineMajorVersion()

static HRESULT Global_ScriptEngineMajorVersion ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2944 of file global.c.

2945{
2946 TRACE("%s\n", debugstr_variant(arg));
2947
2948 assert(args_cnt == 0);
2949
2951}
#define VBSCRIPT_MAJOR_VERSION
Definition: vbscript.h:433

◆ Global_ScriptEngineMinorVersion()

static HRESULT Global_ScriptEngineMinorVersion ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2953 of file global.c.

2954{
2955 TRACE("%s\n", debugstr_variant(arg));
2956
2957 assert(args_cnt == 0);
2958
2960}
#define VBSCRIPT_MINOR_VERSION
Definition: vbscript.h:434

◆ Global_Second()

static HRESULT Global_Second ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2178 of file global.c.

2179{
2180 SYSTEMTIME st;
2181 HRESULT hres;
2182
2183 TRACE("(%s)\n", debugstr_variant(arg));
2184
2185 hres = to_system_time(arg, &st);
2186 return FAILED(hres) ? hres : return_short(res, st.wSecond);
2187}

◆ Global_SetLocale()

static HRESULT Global_SetLocale ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2189 of file global.c.

2190{
2191 FIXME("\n");
2192 return E_NOTIMPL;
2193}

◆ Global_Sgn()

static HRESULT Global_Sgn ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2008 of file global.c.

2009{
2010 double v;
2011 short val;
2012 HRESULT hres;
2013
2014 TRACE("(%s)\n", debugstr_variant(arg));
2015
2016 assert(args_cnt == 1);
2017
2018 if(V_VT(arg) == VT_NULL)
2020
2021 hres = to_double(arg, &v);
2022 if (FAILED(hres))
2023 return hres;
2024
2025 val = v == 0 ? 0 : (v > 0 ? 1 : -1);
2026 return return_short(res, val);
2027}

◆ Global_Sin()

static HRESULT Global_Sin ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1031 of file global.c.

1032{
1033 HRESULT hres;
1034 double d;
1035
1036 hres = to_double(arg, &d);
1037 if(FAILED(hres))
1038 return hres;
1039
1040 return return_double(res, sin(d));
1041}
_ACRTIMP double __cdecl sin(double)
Definition: sin.c:21

◆ Global_Space()

static HRESULT Global_Space ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1663 of file global.c.

1664{
1665 BSTR str;
1666 int n, i;
1667 HRESULT hres;
1668
1669 TRACE("%s\n", debugstr_variant(arg));
1670
1671 assert(args_cnt == 1);
1672
1673 if(V_VT(arg) == VT_NULL)
1675
1676 hres = to_int(arg, &n);
1677 if(FAILED(hres))
1678 return hres;
1679
1680 if(n < 0)
1682
1683 if(!res)
1684 return S_OK;
1685
1687 if(!str)
1688 return E_OUTOFMEMORY;
1689
1690 for(i=0; i<n; i++)
1691 str[i] = ' ';
1692
1693 V_VT(res) = VT_BSTR;
1694 V_BSTR(res) = str;
1695 return S_OK;
1696}

◆ Global_Split()

static HRESULT Global_Split ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2595 of file global.c.

2596{
2598 int count, max, mode, len, start, end, ret, delimiterlen = 1;
2599 int i, *indices = NULL, *new_indices, indices_max = 8;
2600 SAFEARRAYBOUND bounds;
2601 SAFEARRAY *sa = NULL;
2602 VARIANT *data;
2603 HRESULT hres = S_OK;
2604
2605 TRACE("%s %u...\n", debugstr_variant(args), args_cnt);
2606
2607 assert(1 <= args_cnt && args_cnt <= 4);
2608
2609 if(V_VT(args) == VT_NULL || (args_cnt > 1 && V_VT(args+1) == VT_NULL) || (args_cnt > 2 && V_VT(args+2) == VT_NULL)
2610 || (args_cnt == 4 && V_VT(args+3) == VT_NULL))
2612
2613 if(V_VT(args) != VT_BSTR) {
2614 hres = to_string(args, &string);
2615 if(FAILED(hres))
2616 return hres;
2617 }else {
2618 string = V_BSTR(args);
2619 }
2620
2621 if(args_cnt > 1) {
2622 if(V_VT(args+1) != VT_BSTR) {
2624 if(FAILED(hres))
2625 goto error;
2626 }else {
2627 delimiter = V_BSTR(args+1);
2628 }
2629 delimiterlen = SysStringLen(delimiter);
2630 }
2631
2632 if(args_cnt > 2) {
2633 hres = to_int(args+2, &max);
2634 if(FAILED(hres))
2635 goto error;
2636 if (max < -1) {
2638 goto error;
2639 }
2640 }else {
2641 max = -1;
2642 }
2643
2644 if(args_cnt == 4) {
2645 hres = to_int(args+3, &mode);
2646 if(FAILED(hres))
2647 goto error;
2648 if (mode != 0 && mode != 1) {
2650 goto error;
2651 }
2652 }else {
2653 mode = 0;
2654 }
2655
2656 start = 0;
2657
2658 len = SysStringLen(string);
2659 count = 0;
2660
2661 indices = malloc( indices_max * sizeof(int));
2662 if(!indices) {
2664 goto error;
2665 }
2666
2667 while(1) {
2668 ret = -1;
2669 if (delimiterlen) {
2671 delimiter ? delimiter : L" ", delimiterlen, mode);
2672 }
2673
2674 if (ret == -1) {
2675 end = len;
2676 }else {
2677 end = start + ret;
2678 }
2679
2680 if (count == indices_max) {
2681 new_indices = realloc(indices, indices_max * 2 * sizeof(int));
2682 if(!new_indices) {
2684 goto error;
2685 }
2686 indices = new_indices;
2687 indices_max *= 2;
2688 }
2689 indices[count++] = end;
2690
2691 if (ret == -1 || count == max) break;
2692 start = start + ret + delimiterlen;
2693 if (start > len) break;
2694 }
2695
2696 bounds.lLbound = 0;
2697 bounds.cElements = count;
2698 sa = SafeArrayCreate( VT_VARIANT, 1, &bounds);
2699 if (!sa) {
2701 goto error;
2702 }
2703 hres = SafeArrayAccessData(sa, (void**)&data);
2704 if(FAILED(hres)) {
2705 goto error;
2706 }
2707
2708 start = 0;
2709 for (i = 0; i < count; i++) {
2710 V_VT(&data[i]) = VT_BSTR;
2711 V_BSTR(&data[i]) = SysAllocStringLen(string + start, indices[i] - start);
2712
2713 if (!V_BSTR(&data[i])) {
2715 break;
2716 }
2717 start = indices[i]+delimiterlen;
2718 }
2720
2721error:
2722 if(SUCCEEDED(hres) && res) {
2724 V_ARRAY(res) = sa;
2725 }else {
2727 }
2728
2729 free(indices);
2730 if(V_VT(args) != VT_BSTR)
2731 SysFreeString(string);
2732 if(args_cnt > 1 && V_VT(args+1) != VT_BSTR)
2734 return hres;
2735}
#define realloc
Definition: debug_ros.c:6
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
const char * delimiter
Definition: string.c:1779

◆ Global_Sqr()

static HRESULT Global_Sqr ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1082 of file global.c.

1083{
1084 HRESULT hres;
1085 double d;
1086
1087 hres = to_double(arg, &d);
1088 if(FAILED(hres))
1089 return hres;
1090
1091 if(d < 0)
1093 else
1094 return return_double(res, sqrt(d));
1095}
_ACRTIMP double __cdecl sqrt(double)
Definition: sqrt.c:5

◆ Global_StrComp()

static HRESULT Global_StrComp ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1480 of file global.c.

1481{
1482 BSTR left, right;
1483 int mode, ret;
1484 HRESULT hres;
1485 short val;
1486
1487 TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
1488
1489 assert(args_cnt == 2 || args_cnt == 3);
1490
1491 if (args_cnt == 3) {
1492 hres = to_int(args+2, &mode);
1493 if(FAILED(hres))
1494 return hres;
1495
1496 if (mode != 0 && mode != 1) {
1497 FIXME("unknown compare mode = %d\n", mode);
1498 return E_FAIL;
1499 }
1500 }
1501 else
1502 mode = 0;
1503
1504 hres = to_string(args, &left);
1505 if(FAILED(hres))
1506 return hres;
1507
1508 hres = to_string(args+1, &right);
1509 if(FAILED(hres))
1510 {
1512 return hres;
1513 }
1514
1516 val = ret < 0 ? -1 : (ret > 0 ? 1 : 0);
1517
1520 return return_short(res, val);
1521}
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726

◆ Global_String()

static HRESULT Global_String ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1698 of file global.c.

1699{
1700 WCHAR ch;
1701 int cnt;
1702 HRESULT hres;
1703
1704 TRACE("%s %s\n", debugstr_variant(args), debugstr_variant(args + 1));
1705
1706 hres = to_int(args, &cnt);
1707 if(FAILED(hres))
1708 return hres;
1709 if(cnt < 0)
1710 return E_INVALIDARG;
1711
1712 if(V_VT(args + 1) != VT_BSTR) {
1713 FIXME("Unsupported argument %s\n", debugstr_variant(args+1));
1714 return E_NOTIMPL;
1715 }
1716 if(!SysStringLen(V_BSTR(args + 1)))
1717 return E_INVALIDARG;
1718 ch = V_BSTR(args + 1)[0];
1719
1720 if(res) {
1722 if(!str)
1723 return E_OUTOFMEMORY;
1724 wmemset(str, ch, cnt);
1725 V_VT(res) = VT_BSTR;
1726 V_BSTR(res) = str;
1727 }
1728 return S_OK;
1729}
static wchar_t *__cdecl wmemset(wchar_t *s, wchar_t c, size_t n)
Definition: wchar.h:77

◆ Global_StrReverse()

static HRESULT Global_StrReverse ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2827 of file global.c.

2828{
2829 WCHAR *ptr1, *ptr2, ch;
2830 BSTR ret;
2831 HRESULT hres;
2832
2833 TRACE("%s\n", debugstr_variant(arg));
2834
2835 hres = to_string(arg, &ret);
2836 if(FAILED(hres))
2837 return hres;
2838
2839 ptr1 = ret;
2840 ptr2 = ret + SysStringLen(ret)-1;
2841 while(ptr1 < ptr2) {
2842 ch = *ptr1;
2843 *ptr1++ = *ptr2;
2844 *ptr2-- = ch;
2845 }
2846
2847 return return_bstr(res, ret);
2848}

◆ Global_Tan()

static HRESULT Global_Tan ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1043 of file global.c.

1044{
1045 HRESULT hres;
1046 double d;
1047
1048 hres = to_double(arg, &d);
1049 if(FAILED(hres))
1050 return hres;
1051
1052 return return_double(res, tan(d));
1053}
_ACRTIMP double __cdecl tan(double)
Definition: tan.c:122

◆ Global_Time()

static HRESULT Global_Time ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2059 of file global.c.

2060{
2061 SYSTEMTIME lt;
2062 UDATE ud;
2063 DATE time;
2064 HRESULT hres;
2065
2066 TRACE("\n");
2067
2068 GetLocalTime(&lt);
2069 ud.st = lt;
2070 ud.wDayOfYear = 0;
2072 if(FAILED(hres))
2073 return hres;
2074 return return_date(res, time);
2075}
__u16 time
Definition: mkdosfs.c:8
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326

◆ Global_Timer()

static HRESULT Global_Timer ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1163 of file global.c.

1164{
1165 SYSTEMTIME lt;
1166 double sec;
1167
1168 GetLocalTime(&lt);
1169 sec = lt.wHour * 3600 + lt.wMinute * 60 + lt.wSecond + lt.wMilliseconds / 1000.0;
1170 return return_float(res, sec);
1171
1172}
WORD wMilliseconds
Definition: minwinbase.h:263

◆ Global_TimeSerial()

static HRESULT Global_TimeSerial ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2241 of file global.c.

2242{
2243 int hour, minute, second;
2244 UDATE ud = {{ 0 }};
2245 HRESULT hres;
2246 double date;
2247
2248 TRACE("\n");
2249
2250 assert(args_cnt == 3);
2251
2252 if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL || V_VT(args + 2) == VT_NULL)
2254
2255 hres = to_int(args, &hour);
2256 if (SUCCEEDED(hres))
2257 hres = to_int(args + 1, &minute);
2258 if (SUCCEEDED(hres))
2259 hres = to_int(args + 2, &second);
2260
2261 if (SUCCEEDED(hres))
2262 {
2263 ud.st.wYear = 1899;
2264 ud.st.wMonth = 12;
2265 ud.st.wDay = 30;
2266 ud.st.wHour = hour;
2267 ud.st.wMinute = minute;
2268 ud.st.wSecond = second;
2269 hres = VarDateFromUdateEx(&ud, 0, 0, &date);
2270 }
2271
2272 if (SUCCEEDED(hres))
2274
2275 return hres;
2276}

◆ Global_TimeValue()

static HRESULT Global_TimeValue ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2201 of file global.c.

2202{
2203 FIXME("\n");
2204 return E_NOTIMPL;
2205}

◆ Global_Trim()

static HRESULT Global_Trim ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1635 of file global.c.

1636{
1637 BSTR str, conv_str = NULL;
1638 WCHAR *begin_ptr, *end_ptr;
1639 HRESULT hres;
1640
1641 TRACE("%s\n", debugstr_variant(arg));
1642
1643 if(V_VT(arg) == VT_BSTR) {
1644 str = V_BSTR(arg);
1645 }else {
1646 hres = to_string(arg, &conv_str);
1647 if(FAILED(hres))
1648 return hres;
1649 str = conv_str;
1650 }
1651
1652 for(begin_ptr = str; *begin_ptr && iswspace(*begin_ptr); begin_ptr++);
1653 for(end_ptr = str+SysStringLen(str); end_ptr-1 > begin_ptr && iswspace(*(end_ptr-1)); end_ptr--);
1654
1655 str = SysAllocStringLen(begin_ptr, end_ptr-begin_ptr);
1656 SysFreeString(conv_str);
1657 if(!str)
1658 return E_OUTOFMEMORY;
1659
1660 return return_bstr(res, str);
1661}

◆ Global_TypeName()

static HRESULT Global_TypeName ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2477 of file global.c.

2478{
2480 BSTR name = NULL;
2481 HRESULT hres;
2482
2483 TRACE("(%s)\n", debugstr_variant(arg));
2484
2485 assert(args_cnt == 1);
2486
2487 if (V_ISARRAY(arg))
2488 return return_string(res, L"Variant()");
2489
2490 switch(V_VT(arg)) {
2491 case VT_UI1:
2492 return return_string(res, L"Byte");
2493 case VT_I2:
2494 return return_string(res, L"Integer");
2495 case VT_I4:
2496 return return_string(res, L"Long");
2497 case VT_R4:
2498 return return_string(res, L"Single");
2499 case VT_R8:
2500 return return_string(res, L"Double");
2501 case VT_CY:
2502 return return_string(res, L"Currency");
2503 case VT_DECIMAL:
2504 return return_string(res, L"Decimal");
2505 case VT_DATE:
2506 return return_string(res, L"Date");
2507 case VT_BSTR:
2508 return return_string(res, L"String");
2509 case VT_BOOL:
2510 return return_string(res, L"Boolean");
2511 case VT_EMPTY:
2512 return return_string(res, L"Empty");
2513 case VT_NULL:
2514 return return_string(res, L"Null");
2515 case VT_DISPATCH:
2516 if (!V_DISPATCH(arg))
2517 return return_string(res, L"Nothing");
2518 if (SUCCEEDED(IDispatch_GetTypeInfo(V_DISPATCH(arg), 0, GetUserDefaultLCID(), &typeinfo)))
2519 {
2520 hres = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &name, NULL, NULL, NULL);
2521 ITypeInfo_Release(typeinfo);
2522
2523 if (SUCCEEDED(hres) && name && *name)
2524 return return_bstr(res, name);
2525
2527 }
2528 return return_string(res, L"Object");
2529 default:
2530 FIXME("arg %s not supported\n", debugstr_variant(arg));
2531 return E_NOTIMPL;
2532 }
2533}
@ VT_DECIMAL
Definition: compat.h:2309
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
#define MEMBERID_NIL
Definition: oleauto.h:1003

◆ Global_UBound()

static HRESULT Global_UBound ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1215 of file global.c.

1216{
1217 SAFEARRAY *sa;
1218 HRESULT hres;
1219 LONG ubound;
1220 int dim;
1221
1222 assert(args_cnt == 1 || args_cnt == 2);
1223
1224 TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
1225
1226 switch(V_VT(arg)) {
1227 case VT_VARIANT|VT_ARRAY:
1228 sa = V_ARRAY(arg);
1229 break;
1231 sa = *V_ARRAYREF(arg);
1232 break;
1233 case VT_EMPTY:
1234 case VT_NULL:
1236 default:
1237 FIXME("arg %s not supported\n", debugstr_variant(arg));
1238 return E_NOTIMPL;
1239 }
1240
1241 if(args_cnt == 2) {
1242 hres = to_int(arg + 1, &dim);
1243 if(FAILED(hres))
1244 return hres;
1245 }else {
1246 dim = 1;
1247 }
1248
1249 hres = SafeArrayGetUBound(sa, dim, &ubound);
1250 if(FAILED(hres))
1251 return hres;
1252
1253 return return_int(res, ubound);
1254}
HRESULT WINAPI SafeArrayGetUBound(SAFEARRAY *psa, UINT nDim, LONG *plUbound)
Definition: safearray.c:1033

◆ Global_UCase()

static HRESULT Global_UCase ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 1552 of file global.c.

1553{
1554 BSTR str;
1555 HRESULT hres;
1556
1557 TRACE("%s\n", debugstr_variant(arg));
1558
1559 if(V_VT(arg) == VT_NULL) {
1560 return return_null(res);
1561 }
1562
1563 hres = to_string(arg, &str);
1564 if(FAILED(hres))
1565 return hres;
1566
1567 if(res) {
1568 WCHAR *ptr;
1569
1570 for(ptr = str; *ptr; ptr++)
1571 *ptr = towupper(*ptr);
1572
1573 V_VT(res) = VT_BSTR;
1574 V_BSTR(res) = str;
1575 }else {
1577 }
1578 return S_OK;
1579}
#define towupper(c)
Definition: wctype.h:99

◆ Global_Unescape()

static HRESULT Global_Unescape ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3213 of file global.c.

3214{
3215 FIXME("\n");
3216 return E_NOTIMPL;
3217}

◆ Global_VarType()

static HRESULT Global_VarType ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 934 of file global.c.

935{
936 VARTYPE vt;
937
938 TRACE("(%s)\n", debugstr_variant(arg));
939
940 assert(args_cnt == 1);
941
942 vt = V_VT(arg) & ~VT_BYREF;
943 if(vt & ~(VT_TYPEMASK | VT_ARRAY)) {
944 FIXME("not supported %s\n", debugstr_variant(arg));
945 return E_NOTIMPL;
946 }
947
948 return return_short(res, vt);
949}
unsigned short VARTYPE
Definition: compat.h:2254
@ VT_TYPEMASK
Definition: compat.h:2346

◆ Global_Weekday()

static HRESULT Global_Weekday ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2099 of file global.c.

2100{
2101 HRESULT hres = S_OK;
2102 int first_day = 0;
2103 SYSTEMTIME st;
2104
2105 TRACE("(%s)\n", debugstr_variant(args));
2106
2107 assert(args_cnt == 1 || args_cnt == 2);
2108
2109 /* [vbSunday = 1, vbSaturday = 7] -> wDayOfWeek [0, 6] */
2110 if (args_cnt == 2)
2111 {
2112 if (V_VT(args + 1) == VT_NULL)
2114
2115 hres = to_int(args + 1, &first_day);
2116 if (SUCCEEDED(hres))
2117 {
2118 if (!first_day)
2119 {
2120 /* vbUseSystemDayOfWeek */
2121 GetLocaleInfoW(This->ctx->lcid, LOCALE_RETURN_NUMBER | LOCALE_IFIRSTDAYOFWEEK, (LPWSTR)&first_day,
2122 sizeof(first_day) / sizeof(WCHAR));
2123 first_day = (first_day + 1) % 7;
2124 }
2125 else if (first_day >= 1 && first_day <= 7)
2126 {
2127 first_day--;
2128 }
2129 else
2131 }
2132 }
2133
2134 if (FAILED(hres))
2135 return hres;
2136
2137 if (V_VT(args) == VT_NULL)
2138 return return_null(res);
2139
2140 if (FAILED(hres = to_system_time(args, &st))) return hres;
2141
2142 return return_short(res, 1 + (7 - first_day + st.wDayOfWeek) % 7);
2143}
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
WORD wDayOfWeek
Definition: minwinbase.h:258
uint16_t * LPWSTR
Definition: typedefs.h:56
#define LOCALE_IFIRSTDAYOFWEEK
Definition: winnls.h:85

◆ Global_WeekdayName()

static HRESULT Global_WeekdayName ( BuiltinDisp This,
VARIANT args,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 3101 of file global.c.

3102{
3103 int weekday, first_day = 1, abbrev = 0;
3104 BSTR ret;
3105 HRESULT hres;
3106
3107 TRACE("\n");
3108
3109 assert(1 <= args_cnt && args_cnt <= 3);
3110
3111 hres = to_int(args, &weekday);
3112 if(FAILED(hres))
3113 return hres;
3114
3115 if(args_cnt > 1) {
3116 hres = to_int(args+1, &abbrev);
3117 if(FAILED(hres))
3118 return hres;
3119
3120 if(args_cnt == 3) {
3121 hres = to_int(args+2, &first_day);
3122 if(FAILED(hres))
3123 return hres;
3124 }
3125 }
3126
3127 hres = VarWeekdayName(weekday, abbrev, first_day, 0, &ret);
3128 if(FAILED(hres))
3129 return hres;
3130
3131 return return_bstr(res, ret);
3132}
HRESULT WINAPI VarWeekdayName(INT iWeekday, INT fAbbrev, INT iFirstDay, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2568

◆ Global_Year()

static HRESULT Global_Year ( BuiltinDisp This,
VARIANT arg,
unsigned  args_cnt,
VARIANT res 
)
static

Definition at line 2145 of file global.c.

2146{
2147 SYSTEMTIME st;
2148 HRESULT hres;
2149
2150 TRACE("(%s)\n", debugstr_variant(arg));
2151
2152 hres = to_system_time(arg, &st);
2153 return FAILED(hres) ? hres : return_short(res, st.wYear);
2154}

◆ hex_char()

static WCHAR hex_char ( unsigned  n)
inlinestatic

Definition at line 851 of file global.c.

852{
853 return n < 10 ? '0'+n : 'A'+n-10;
854}

Referenced by Global_Hex().

◆ impl_from_IDispatch()

static BuiltinDisp * impl_from_IDispatch ( IDispatch iface)
inlinestatic

Definition at line 61 of file global.c.

62{
63 return CONTAINING_RECORD(iface, BuiltinDisp, IDispatch_iface);
64}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by Builtin_AddRef(), Builtin_GetIDsOfNames(), Builtin_GetTypeInfo(), Builtin_GetTypeInfoCount(), Builtin_Invoke(), Builtin_QueryInterface(), and Builtin_Release().

◆ init_global()

HRESULT init_global ( script_ctx_t ctx)

Definition at line 3617 of file global.c.

3618{
3619 HRESULT hres;
3620
3622 if(FAILED(hres))
3623 return hres;
3624
3626}
static HRESULT create_builtin_dispatch(script_ctx_t *ctx, const builtin_prop_t *members, size_t member_cnt, BuiltinDisp **ret)
Definition: global.c:285
static const builtin_prop_t global_props[]
Definition: global.c:3268
static const builtin_prop_t err_props[]
Definition: global.c:3591

◆ return_bool()

static HRESULT return_bool ( VARIANT res,
BOOL  val 
)
static

Definition at line 354 of file global.c.

355{
356 if(res) {
357 V_VT(res) = VT_BOOL;
358 V_BOOL(res) = val ? VARIANT_TRUE : VARIANT_FALSE;
359 }
360 return S_OK;
361}
#define V_BOOL(A)
Definition: oleauto.h:224

Referenced by Global_IsArray(), Global_IsDate(), Global_IsEmpty(), Global_IsNull(), Global_IsNumeric(), and Global_IsObject().

◆ return_bstr()

◆ return_date()

static HRESULT return_date ( VARIANT res,
double  date 
)
inlinestatic

Definition at line 410 of file global.c.

411{
412 if(res) {
413 V_VT(res) = VT_DATE;
414 V_DATE(res) = date;
415 }
416 return S_OK;
417}
#define V_DATE(A)
Definition: oleauto.h:231

Referenced by Global_Date(), Global_DateAdd(), Global_DateSerial(), Global_Now(), Global_Time(), and Global_TimeSerial().

◆ return_double()

static HRESULT return_double ( VARIANT res,
double  val 
)
inlinestatic

Definition at line 383 of file global.c.

384{
385 if(res) {
386 V_VT(res) = VT_R8;
387 V_R8(res) = val;
388 }
389
390 return S_OK;
391}

Referenced by Global_Atn(), Global_Cos(), Global_Exp(), Global_Log(), Global_Round(), Global_Sin(), Global_Sqr(), and Global_Tan().

◆ return_float()

static HRESULT return_float ( VARIANT res,
float  val 
)
inlinestatic

Definition at line 393 of file global.c.

394{
395 if(res) {
396 V_VT(res) = VT_R4;
397 V_R4(res) = val;
398 }
399
400 return S_OK;
401}
#define V_R4(A)
Definition: oleauto.h:260

Referenced by Global_Rnd(), and Global_Timer().

◆ return_int()

◆ return_null()

static HRESULT return_null ( VARIANT res)
inlinestatic

Definition at line 403 of file global.c.

404{
405 if(res)
406 V_VT(res) = VT_NULL;
407 return S_OK;
408}

Referenced by Global_DateAdd(), Global_Hex(), Global_InStr(), Global_LCase(), Global_Len(), Global_Mid(), Global_Oct(), Global_Right(), Global_UCase(), and Global_Weekday().

◆ return_short()

static HRESULT return_short ( VARIANT res,
short  val 
)
static

Definition at line 363 of file global.c.

364{
365 if(res) {
366 V_VT(res) = VT_I2;
367 V_I2(res) = val;
368 }
369
370 return S_OK;
371}

Referenced by Global_Asc(), Global_Day(), Global_Hour(), Global_Minute(), Global_Month(), Global_Second(), Global_Sgn(), Global_StrComp(), Global_VarType(), Global_Weekday(), Global_Year(), and show_msgbox().

◆ return_string()

static HRESULT return_string ( VARIANT res,
const WCHAR str 
)
static

Definition at line 327 of file global.c.

328{
329 BSTR ret;
330
331 if(!res)
332 return S_OK;
333
335 if(!ret)
336 return E_OUTOFMEMORY;
337
338 V_VT(res) = VT_BSTR;
339 V_BSTR(res) = ret;
340 return S_OK;
341}

Referenced by err_string_prop(), Global_Hex(), Global_Mid(), Global_Oct(), Global_ScriptEngine(), and Global_TypeName().

◆ set_object_site()

static HRESULT set_object_site ( script_ctx_t ctx,
IUnknown obj 
)
static

Definition at line 488 of file global.c.

489{
490 IObjectWithSite *obj_site;
491 IUnknown *ax_site;
493
494 hres = IUnknown_QueryInterface(obj, &IID_IObjectWithSite, (void**)&obj_site);
495 if(FAILED(hres))
496 return S_OK;
497
498 ax_site = create_ax_site(ctx);
499 if(ax_site) {
500 hres = IObjectWithSite_SetSite(obj_site, ax_site);
501 IUnknown_Release(ax_site);
502 }
503 else
505 IObjectWithSite_Release(obj_site);
506 return hres;
507}
IUnknown * create_ax_site(script_ctx_t *ctx)
Definition: jscript.c:614
const IID IID_IObjectWithSite

Referenced by create_object(), and Global_GetObject().

◆ show_msgbox()

static HRESULT show_msgbox ( script_ctx_t ctx,
BSTR  prompt,
unsigned  type,
BSTR  orig_title,
VARIANT res 
)
static

Definition at line 580 of file global.c.

581{
583 IActiveScriptSiteUIControl *ui_control;
584 IActiveScriptSiteWindow *acts_window;
585 WCHAR *title_buf = NULL;
586 const WCHAR *title;
587 HWND hwnd = NULL;
588 int ret = 0;
590
591 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteUIControl, (void**)&ui_control);
592 if(SUCCEEDED(hres)) {
593 hres = IActiveScriptSiteUIControl_GetUIBehavior(ui_control, SCRIPTUICITEM_MSGBOX, &uic_handling);
594 IActiveScriptSiteUIControl_Release(ui_control);
595 if(FAILED(hres))
597 }
598
599 switch(uic_handling) {
601 break;
603 return return_short(res, 0);
604 default:
605 FIXME("blocked\n");
606 return E_FAIL;
607 }
608
609 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteWindow, (void**)&acts_window);
610 if(FAILED(hres)) {
611 FIXME("No IActiveScriptSiteWindow\n");
612 return hres;
613 }
614
615 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
616 if(orig_title && *orig_title) {
617 WCHAR *ptr;
618
619 title = title_buf = malloc(sizeof(L"VBScript") + (lstrlenW(orig_title)+2)*sizeof(WCHAR));
620 if(!title)
621 return E_OUTOFMEMORY;
622
623 memcpy(title_buf, L"VBScript", sizeof(L"VBScript"));
624 ptr = title_buf + ARRAY_SIZE(L"VBScript")-1;
625
626 *ptr++ = ':';
627 *ptr++ = ' ';
628 lstrcpyW(ptr, orig_title);
629 }else {
630 title = L"VBScript";
631 }
632 }else {
633 title = orig_title ? orig_title : L"";
634 }
635
636 hres = IActiveScriptSiteWindow_GetWindow(acts_window, &hwnd);
637 if(SUCCEEDED(hres)) {
638 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, FALSE);
639 if(SUCCEEDED(hres)) {
640 ret = MessageBoxW(hwnd, prompt, title, type);
641 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, TRUE);
642 }
643 }
644
645 free(title_buf);
646 IActiveScriptSiteWindow_Release(acts_window);
647 if(FAILED(hres)) {
648 FIXME("failed: %08lx\n", hres);
649 return hres;
650 }
651
652 return return_short(res, ret);
653}
enum tagSCRIPTUICHANDLING SCRIPTUICHANDLING
@ SCRIPTUICITEM_MSGBOX
Definition: activscp.idl:72
@ SCRIPTUICHANDLING_ALLOW
Definition: activscp.idl:76
@ SCRIPTUICHANDLING_NOUIDEFAULT
Definition: activscp.idl:78
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static SCRIPTUICHANDLING uic_handling
Definition: run.c:166
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)

Referenced by Global_MsgBox().

◆ to_double()

static HRESULT to_double ( VARIANT v,
double ret 
)
static

Definition at line 433 of file global.c.

434{
435 VARIANT dst;
437
438 V_VT(&dst) = VT_EMPTY;
440 if(FAILED(hres))
441 return hres;
442
443 *ret = V_R8(&dst);
444 return S_OK;
445}

Referenced by Global_Atn(), Global_Cos(), Global_Exp(), Global_IsNumeric(), Global_Log(), Global_Randomize(), Global_Round(), Global_Sgn(), Global_Sin(), Global_Sqr(), and Global_Tan().

◆ to_float()

static HRESULT to_float ( VARIANT v,
float ret 
)
static

Definition at line 447 of file global.c.

448{
449 VARIANT dst;
451
452 V_VT(&dst) = VT_EMPTY;
454 if(FAILED(hres))
455 return hres;
456
457 *ret = V_R4(&dst);
458 return S_OK;
459}

Referenced by Global_Rnd().

◆ to_int()

◆ to_string()

◆ to_system_time()

static HRESULT to_system_time ( VARIANT v,
SYSTEMTIME st 
)
static

Definition at line 475 of file global.c.

476{
479
480 V_VT(&date) = VT_EMPTY;
482 if(FAILED(hres))
483 return hres;
484
485 return VariantTimeToSystemTime(V_DATE(&date), st);
486}
INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
Definition: variant.c:1317

Referenced by Global_DateAdd(), Global_Day(), Global_Hour(), Global_Minute(), Global_Month(), Global_Second(), Global_Weekday(), and Global_Year().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( vbscript  )

Variable Documentation

◆ BuiltinDispVtbl

const IDispatchVtbl BuiltinDispVtbl
static
Initial value:
= {
}
static HRESULT WINAPI Builtin_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: global.c:66
static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
Definition: global.c:172
static HRESULT WINAPI Builtin_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
Definition: global.c:112
static ULONG WINAPI Builtin_Release(IDispatch *iface)
Definition: global.c:97
static HRESULT WINAPI Builtin_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: global.c:120
static HRESULT WINAPI Builtin_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, LCID lcid, DISPID *ids)
Definition: global.c:149
static ULONG WINAPI Builtin_AddRef(IDispatch *iface)
Definition: global.c:87

Definition at line 275 of file global.c.

Referenced by create_builtin_dispatch().

◆ err_props

const builtin_prop_t err_props[]
static
Initial value:
= {
{L"Clear", Err_Clear},
{L"Description", Err_Description, BP_GETPUT},
{L"HelpContext", Err_HelpContext, BP_GETPUT},
{L"HelpFile", Err_HelpFile, BP_GETPUT},
{L"Number", Err_Number, BP_GETPUT},
{L"Raise", Err_Raise, 0, 1, 5},
{L"Source", Err_Source, BP_GETPUT}
}
static HRESULT Err_Number(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3508
static HRESULT Err_HelpFile(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3502
static HRESULT Err_HelpContext(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3490
static HRESULT Err_Description(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3484
static HRESULT Err_Raise(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3537
static HRESULT Err_Source(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3523
static HRESULT Err_Clear(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3529

Definition at line 3591 of file global.c.

Referenced by init_global().

◆ global_props

const builtin_prop_t global_props[]
static

Definition at line 3268 of file global.c.

Referenced by init_global().

◆ GUID_CUSTOM_CONFIRMOBJECTSAFETY

const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
Initial value:
=
{0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}}

Definition at line 42 of file global.c.

Referenced by create_object().

◆ vbCr

const string_constant_t vbCr = {1, {'\r'}}
static

Definition at line 3258 of file global.c.

◆ vbCrLf

const string_constant_t vbCrLf = {2, {'\r','\n'}}
static

Definition at line 3259 of file global.c.

◆ vbFormFeed

const string_constant_t vbFormFeed = {1, {0xc}}
static

Definition at line 3261 of file global.c.

◆ vbLf

const string_constant_t vbLf = {1, {'\n'}}
static

Definition at line 3262 of file global.c.

◆ vbNewLine

const string_constant_t vbNewLine = {2, {'\r','\n'}}
static

Definition at line 3260 of file global.c.

◆ vbNullChar

const string_constant_t vbNullChar = {1}
static

Definition at line 3263 of file global.c.

◆ vbNullString

const string_constant_t vbNullString = {0}
static

Definition at line 3264 of file global.c.

◆ vbTab

const string_constant_t vbTab = {1, {'\t'}}
static

Definition at line 3265 of file global.c.

◆ vbVerticalTab

const string_constant_t vbVerticalTab = {1, {0xb}}
static

Definition at line 3266 of file global.c.