2011-07-18 14:57:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-02 11:16:27 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "ole2.h"
|
2011-09-05 09:14:14 +00:00
|
|
|
#include "dispex.h"
|
2011-07-18 14:57:27 +00:00
|
|
|
#include "activscp.h"
|
2011-09-02 11:16:27 +00:00
|
|
|
|
2011-07-18 14:57:27 +00:00
|
|
|
#include "vbscript_classes.h"
|
|
|
|
|
2011-09-05 09:14:55 +00:00
|
|
|
#include "wine/list.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2011-09-12 10:29:14 +00:00
|
|
|
typedef struct {
|
|
|
|
void **blocks;
|
|
|
|
DWORD block_cnt;
|
|
|
|
DWORD last_block;
|
|
|
|
DWORD offset;
|
|
|
|
struct list custom_blocks;
|
|
|
|
} vbsheap_t;
|
|
|
|
|
|
|
|
void vbsheap_init(vbsheap_t*) DECLSPEC_HIDDEN;
|
|
|
|
void *vbsheap_alloc(vbsheap_t*,size_t) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
|
|
|
|
void vbsheap_free(vbsheap_t*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-09-07 12:07:12 +00:00
|
|
|
typedef struct _function_t function_t;
|
|
|
|
typedef struct _vbscode_t vbscode_t;
|
2011-09-08 12:54:37 +00:00
|
|
|
typedef struct _script_ctx_t script_ctx_t;
|
2011-09-19 12:08:38 +00:00
|
|
|
typedef struct _vbdisp_t vbdisp_t;
|
2011-09-07 12:07:12 +00:00
|
|
|
|
2011-09-05 09:14:55 +00:00
|
|
|
typedef struct named_item_t {
|
|
|
|
IDispatch *disp;
|
|
|
|
DWORD flags;
|
|
|
|
LPWSTR name;
|
|
|
|
|
|
|
|
struct list entry;
|
|
|
|
} named_item_t;
|
|
|
|
|
2011-09-15 12:20:46 +00:00
|
|
|
typedef enum {
|
|
|
|
VBDISP_CALLGET,
|
|
|
|
VBDISP_LET,
|
|
|
|
VBDISP_SET,
|
|
|
|
VBDISP_ANY
|
|
|
|
} vbdisp_invoke_type_t;
|
|
|
|
|
2011-09-16 11:27:22 +00:00
|
|
|
typedef struct {
|
|
|
|
BOOL is_public;
|
|
|
|
const WCHAR *name;
|
|
|
|
} vbdisp_prop_desc_t;
|
|
|
|
|
2011-09-15 12:20:46 +00:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL is_public;
|
|
|
|
function_t *entries[VBDISP_ANY];
|
|
|
|
} vbdisp_funcprop_desc_t;
|
|
|
|
|
2011-09-19 12:08:38 +00:00
|
|
|
#define BP_GET 1
|
|
|
|
#define BP_GETPUT 2
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DISPID id;
|
|
|
|
HRESULT (*proc)(vbdisp_t*,VARIANT*,unsigned,VARIANT*);
|
|
|
|
DWORD flags;
|
|
|
|
unsigned min_args;
|
|
|
|
unsigned max_args;
|
|
|
|
} builtin_prop_t;
|
|
|
|
|
2011-09-15 12:17:17 +00:00
|
|
|
typedef struct _class_desc_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
script_ctx_t *ctx;
|
2011-09-19 12:08:38 +00:00
|
|
|
|
2011-09-16 11:29:25 +00:00
|
|
|
unsigned class_initialize_id;
|
2011-09-16 11:29:37 +00:00
|
|
|
unsigned class_terminate_id;
|
2011-09-15 12:20:46 +00:00
|
|
|
unsigned func_cnt;
|
|
|
|
vbdisp_funcprop_desc_t *funcs;
|
2011-09-19 12:08:38 +00:00
|
|
|
|
2011-09-16 11:27:22 +00:00
|
|
|
unsigned prop_cnt;
|
|
|
|
vbdisp_prop_desc_t *props;
|
2011-09-19 12:08:38 +00:00
|
|
|
|
|
|
|
unsigned builtin_prop_cnt;
|
|
|
|
const builtin_prop_t *builtin_props;
|
|
|
|
ITypeInfo *typeinfo;
|
2012-09-06 09:57:33 +00:00
|
|
|
function_t *value_func;
|
2011-09-19 12:08:38 +00:00
|
|
|
|
2011-09-15 12:17:17 +00:00
|
|
|
struct _class_desc_t *next;
|
|
|
|
} class_desc_t;
|
|
|
|
|
2011-09-19 12:08:38 +00:00
|
|
|
struct _vbdisp_t {
|
2011-09-05 09:14:14 +00:00
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
2011-09-16 11:29:37 +00:00
|
|
|
BOOL terminator_ran;
|
2011-09-16 11:29:47 +00:00
|
|
|
struct list entry;
|
2011-09-15 12:18:43 +00:00
|
|
|
|
|
|
|
const class_desc_t *desc;
|
2011-09-16 11:27:48 +00:00
|
|
|
VARIANT props[1];
|
2011-09-19 12:08:38 +00:00
|
|
|
};
|
2011-09-05 09:14:14 +00:00
|
|
|
|
2012-09-07 13:09:59 +00:00
|
|
|
typedef struct _ident_map_t ident_map_t;
|
|
|
|
|
2012-09-07 13:09:34 +00:00
|
|
|
typedef struct {
|
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
LONG ref;
|
2012-09-07 13:09:59 +00:00
|
|
|
|
|
|
|
ident_map_t *ident_map;
|
|
|
|
unsigned ident_map_cnt;
|
|
|
|
unsigned ident_map_size;
|
|
|
|
|
2012-09-07 13:09:34 +00:00
|
|
|
script_ctx_t *ctx;
|
|
|
|
} ScriptDisp;
|
|
|
|
|
2011-10-03 11:28:46 +00:00
|
|
|
HRESULT create_vbdisp(const class_desc_t*,vbdisp_t**) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT disp_get_id(IDispatch*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT vbdisp_get_id(vbdisp_t*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
2012-03-26 09:53:41 +00:00
|
|
|
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
|
2011-10-03 11:28:46 +00:00
|
|
|
void collect_objects(script_ctx_t*) DECLSPEC_HIDDEN;
|
2012-09-06 09:57:33 +00:00
|
|
|
HRESULT create_procedure_disp(script_ctx_t*,vbscode_t*,IDispatch**) DECLSPEC_HIDDEN;
|
2012-09-07 13:09:34 +00:00
|
|
|
HRESULT create_script_disp(script_ctx_t*,ScriptDisp**) DECLSPEC_HIDDEN;
|
2011-09-08 12:54:37 +00:00
|
|
|
|
2011-09-14 10:56:01 +00:00
|
|
|
static inline unsigned arg_cnt(const DISPPARAMS *dp)
|
|
|
|
{
|
|
|
|
return dp->cArgs - dp->cNamedArgs;
|
|
|
|
}
|
|
|
|
|
2011-09-14 10:56:45 +00:00
|
|
|
static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
|
|
|
|
{
|
|
|
|
return dp->rgvarg + dp->cArgs-i-1;
|
|
|
|
}
|
|
|
|
|
2011-09-13 09:36:47 +00:00
|
|
|
typedef struct _dynamic_var_t {
|
|
|
|
struct _dynamic_var_t *next;
|
|
|
|
VARIANT v;
|
|
|
|
const WCHAR *name;
|
2011-09-21 12:04:16 +00:00
|
|
|
BOOL is_const;
|
2011-09-13 09:36:47 +00:00
|
|
|
} dynamic_var_t;
|
|
|
|
|
2011-09-08 12:54:37 +00:00
|
|
|
struct _script_ctx_t {
|
2011-08-31 09:22:05 +00:00
|
|
|
IActiveScriptSite *site;
|
|
|
|
LCID lcid;
|
2011-09-05 09:14:14 +00:00
|
|
|
|
2011-09-22 12:25:27 +00:00
|
|
|
IInternetHostSecurityManager *secmgr;
|
|
|
|
DWORD safeopt;
|
|
|
|
|
2011-09-05 09:14:55 +00:00
|
|
|
IDispatch *host_global;
|
|
|
|
|
2012-09-07 13:09:34 +00:00
|
|
|
ScriptDisp *script_obj;
|
2011-09-05 09:14:55 +00:00
|
|
|
|
2011-09-19 12:08:38 +00:00
|
|
|
class_desc_t global_desc;
|
|
|
|
vbdisp_t *global_obj;
|
|
|
|
|
2011-09-19 12:09:21 +00:00
|
|
|
class_desc_t err_desc;
|
|
|
|
vbdisp_t *err_obj;
|
|
|
|
|
2011-09-13 09:36:47 +00:00
|
|
|
dynamic_var_t *global_vars;
|
2011-09-14 10:55:32 +00:00
|
|
|
function_t *global_funcs;
|
2011-09-15 12:17:17 +00:00
|
|
|
class_desc_t *classes;
|
2012-09-06 09:57:33 +00:00
|
|
|
class_desc_t *procs;
|
2011-09-13 09:36:47 +00:00
|
|
|
|
2011-09-20 12:59:53 +00:00
|
|
|
vbsheap_t heap;
|
|
|
|
|
2011-09-16 11:29:47 +00:00
|
|
|
struct list objects;
|
2011-09-07 12:07:12 +00:00
|
|
|
struct list code_list;
|
2011-09-05 09:14:55 +00:00
|
|
|
struct list named_items;
|
2011-09-08 12:54:37 +00:00
|
|
|
};
|
2011-08-31 09:22:05 +00:00
|
|
|
|
2011-10-03 11:28:46 +00:00
|
|
|
HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT init_err(script_ctx_t*) DECLSPEC_HIDDEN;
|
2011-09-05 09:14:14 +00:00
|
|
|
|
2011-09-22 12:25:50 +00:00
|
|
|
IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-09-07 12:08:47 +00:00
|
|
|
typedef enum {
|
|
|
|
ARG_NONE = 0,
|
2011-09-08 12:54:23 +00:00
|
|
|
ARG_STR,
|
2011-09-08 12:57:16 +00:00
|
|
|
ARG_BSTR,
|
|
|
|
ARG_INT,
|
2011-09-12 10:30:11 +00:00
|
|
|
ARG_UINT,
|
2011-09-13 09:38:38 +00:00
|
|
|
ARG_ADDR,
|
2011-09-12 10:30:11 +00:00
|
|
|
ARG_DOUBLE
|
2011-09-07 12:08:47 +00:00
|
|
|
} instr_arg_type_t;
|
|
|
|
|
|
|
|
#define OP_LIST \
|
2011-09-12 10:31:58 +00:00
|
|
|
X(add, 1, 0, 0) \
|
2011-09-14 10:59:02 +00:00
|
|
|
X(and, 1, 0, 0) \
|
2011-12-27 15:17:21 +00:00
|
|
|
X(assign_ident, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(assign_member, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 12:57:16 +00:00
|
|
|
X(bool, 1, ARG_INT, 0) \
|
2012-07-20 14:28:45 +00:00
|
|
|
X(case, 0, ARG_ADDR, 0) \
|
2011-09-12 10:30:47 +00:00
|
|
|
X(concat, 1, 0, 0) \
|
2011-09-21 12:03:38 +00:00
|
|
|
X(const, 1, ARG_BSTR, 0) \
|
2011-09-13 09:40:39 +00:00
|
|
|
X(div, 1, 0, 0) \
|
2011-09-12 10:30:11 +00:00
|
|
|
X(double, 1, ARG_DOUBLE, 0) \
|
2011-09-09 12:49:26 +00:00
|
|
|
X(empty, 1, 0, 0) \
|
2012-07-03 15:05:32 +00:00
|
|
|
X(enumnext, 0, ARG_ADDR, ARG_BSTR) \
|
2011-09-09 12:48:25 +00:00
|
|
|
X(equal, 1, 0, 0) \
|
2011-09-19 12:10:19 +00:00
|
|
|
X(errmode, 1, ARG_INT, 0) \
|
2011-09-14 10:59:49 +00:00
|
|
|
X(eqv, 1, 0, 0) \
|
2011-09-13 09:41:15 +00:00
|
|
|
X(exp, 1, 0, 0) \
|
2011-09-19 12:07:12 +00:00
|
|
|
X(gt, 1, 0, 0) \
|
|
|
|
X(gteq, 1, 0, 0) \
|
2011-09-09 12:48:48 +00:00
|
|
|
X(icall, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 12:57:16 +00:00
|
|
|
X(icallv, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-13 09:40:14 +00:00
|
|
|
X(idiv, 1, 0, 0) \
|
2011-09-14 10:59:49 +00:00
|
|
|
X(imp, 1, 0, 0) \
|
2011-09-22 12:23:10 +00:00
|
|
|
X(incc, 1, ARG_BSTR, 0) \
|
2011-09-19 12:08:02 +00:00
|
|
|
X(is, 1, 0, 0) \
|
2011-09-13 09:38:38 +00:00
|
|
|
X(jmp, 0, ARG_ADDR, 0) \
|
|
|
|
X(jmp_false, 0, ARG_ADDR, 0) \
|
2011-09-16 11:30:31 +00:00
|
|
|
X(jmp_true, 0, ARG_ADDR, 0) \
|
2011-09-12 10:30:11 +00:00
|
|
|
X(long, 1, ARG_INT, 0) \
|
2011-09-19 12:07:12 +00:00
|
|
|
X(lt, 1, 0, 0) \
|
|
|
|
X(lteq, 1, 0, 0) \
|
2011-09-15 12:19:41 +00:00
|
|
|
X(mcall, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(mcallv, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-19 12:09:57 +00:00
|
|
|
X(me, 1, 0, 0) \
|
2011-09-13 09:39:53 +00:00
|
|
|
X(mod, 1, 0, 0) \
|
2011-09-13 09:40:39 +00:00
|
|
|
X(mul, 1, 0, 0) \
|
2011-09-12 10:31:37 +00:00
|
|
|
X(neg, 1, 0, 0) \
|
2011-09-12 10:32:27 +00:00
|
|
|
X(nequal, 1, 0, 0) \
|
2011-09-15 12:18:12 +00:00
|
|
|
X(new, 1, ARG_STR, 0) \
|
2012-07-03 15:05:32 +00:00
|
|
|
X(newenum, 1, 0, 0) \
|
2011-09-09 12:47:45 +00:00
|
|
|
X(not, 1, 0, 0) \
|
2011-09-15 12:18:56 +00:00
|
|
|
X(nothing, 1, 0, 0) \
|
2011-09-09 12:49:36 +00:00
|
|
|
X(null, 1, 0, 0) \
|
2011-09-14 10:59:26 +00:00
|
|
|
X(or, 1, 0, 0) \
|
2011-09-22 12:23:10 +00:00
|
|
|
X(pop, 1, ARG_UINT, 0) \
|
2011-09-08 12:57:31 +00:00
|
|
|
X(ret, 0, 0, 0) \
|
2011-12-27 15:17:21 +00:00
|
|
|
X(set_ident, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(set_member, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-12 10:30:11 +00:00
|
|
|
X(short, 1, ARG_INT, 0) \
|
2011-09-22 12:23:10 +00:00
|
|
|
X(step, 0, ARG_ADDR, ARG_BSTR) \
|
2011-09-15 12:22:27 +00:00
|
|
|
X(stop, 1, 0, 0) \
|
2011-09-12 10:31:58 +00:00
|
|
|
X(string, 1, ARG_STR, 0) \
|
2011-09-14 10:59:49 +00:00
|
|
|
X(sub, 1, 0, 0) \
|
2011-09-22 12:23:10 +00:00
|
|
|
X(val, 1, 0, 0) \
|
2011-09-14 10:59:49 +00:00
|
|
|
X(xor, 1, 0, 0)
|
2011-09-07 12:07:12 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2011-09-07 12:08:47 +00:00
|
|
|
#define X(x,n,a,b) OP_##x,
|
2011-09-07 12:07:12 +00:00
|
|
|
OP_LIST
|
|
|
|
#undef X
|
|
|
|
OP_LAST
|
|
|
|
} vbsop_t;
|
|
|
|
|
2011-09-07 12:08:47 +00:00
|
|
|
typedef union {
|
|
|
|
const WCHAR *str;
|
2011-09-08 12:54:23 +00:00
|
|
|
BSTR bstr;
|
2011-09-08 12:57:16 +00:00
|
|
|
unsigned uint;
|
|
|
|
LONG lng;
|
2011-09-12 10:30:11 +00:00
|
|
|
double *dbl;
|
2011-09-07 12:08:47 +00:00
|
|
|
} instr_arg_t;
|
|
|
|
|
2011-09-07 12:07:12 +00:00
|
|
|
typedef struct {
|
|
|
|
vbsop_t op;
|
2011-09-07 12:08:47 +00:00
|
|
|
instr_arg_t arg1;
|
|
|
|
instr_arg_t arg2;
|
2011-09-07 12:07:12 +00:00
|
|
|
} instr_t;
|
|
|
|
|
2011-09-14 11:55:57 +00:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL by_ref;
|
|
|
|
} arg_desc_t;
|
|
|
|
|
2011-09-14 10:54:50 +00:00
|
|
|
typedef enum {
|
|
|
|
FUNC_GLOBAL,
|
2011-09-14 14:55:51 +00:00
|
|
|
FUNC_FUNCTION,
|
2011-09-16 11:28:00 +00:00
|
|
|
FUNC_SUB,
|
|
|
|
FUNC_PROPGET,
|
|
|
|
FUNC_PROPLET,
|
2011-09-16 11:28:52 +00:00
|
|
|
FUNC_PROPSET,
|
|
|
|
FUNC_DEFGET
|
2011-09-14 10:54:50 +00:00
|
|
|
} function_type_t;
|
|
|
|
|
2011-09-14 10:57:37 +00:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
} var_desc_t;
|
|
|
|
|
2011-09-07 12:07:12 +00:00
|
|
|
struct _function_t {
|
2011-09-14 10:55:07 +00:00
|
|
|
function_type_t type;
|
|
|
|
const WCHAR *name;
|
2011-09-15 12:20:05 +00:00
|
|
|
BOOL is_public;
|
2011-09-14 11:55:57 +00:00
|
|
|
arg_desc_t *args;
|
|
|
|
unsigned arg_cnt;
|
2011-09-14 10:57:37 +00:00
|
|
|
var_desc_t *vars;
|
|
|
|
unsigned var_cnt;
|
2011-09-07 12:07:12 +00:00
|
|
|
unsigned code_off;
|
|
|
|
vbscode_t *code_ctx;
|
2011-09-14 10:55:07 +00:00
|
|
|
function_t *next;
|
2011-09-07 12:07:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _vbscode_t {
|
|
|
|
instr_t *instrs;
|
|
|
|
WCHAR *source;
|
|
|
|
|
2011-09-09 12:47:00 +00:00
|
|
|
BOOL option_explicit;
|
|
|
|
|
2012-09-06 09:57:15 +00:00
|
|
|
BOOL pending_exec;
|
|
|
|
function_t main_code;
|
2011-09-07 12:07:12 +00:00
|
|
|
|
2011-09-08 12:54:23 +00:00
|
|
|
BSTR *bstr_pool;
|
|
|
|
unsigned bstr_pool_size;
|
|
|
|
unsigned bstr_cnt;
|
2011-09-12 10:29:14 +00:00
|
|
|
vbsheap_t heap;
|
2011-09-08 12:54:23 +00:00
|
|
|
|
2011-09-07 12:07:12 +00:00
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT compile_script(script_ctx_t*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN;
|
2011-09-15 12:21:58 +00:00
|
|
|
HRESULT exec_script(script_ctx_t*,function_t*,IDispatch*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
2011-10-14 14:22:18 +00:00
|
|
|
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
|
2011-09-07 12:07:12 +00:00
|
|
|
|
2011-09-19 12:08:38 +00:00
|
|
|
#define TID_LIST \
|
|
|
|
XDIID(ErrObj) \
|
|
|
|
XDIID(GlobalObj)
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
#define XDIID(iface) iface ## _tid,
|
|
|
|
TID_LIST
|
|
|
|
#undef XDIID
|
|
|
|
LAST_tid
|
|
|
|
} tid_t;
|
|
|
|
|
2011-10-03 11:28:46 +00:00
|
|
|
HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
|
2011-09-19 12:08:38 +00:00
|
|
|
|
2012-09-26 12:36:15 +00:00
|
|
|
#ifndef INT32_MIN
|
|
|
|
#define INT32_MIN (-2147483647-1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INT32_MAX
|
|
|
|
#define INT32_MAX (2147483647)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline BOOL is_int32(double d)
|
|
|
|
{
|
|
|
|
return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
|
|
|
|
}
|
|
|
|
|
2011-10-03 11:28:46 +00:00
|
|
|
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
2011-07-18 14:57:27 +00:00
|
|
|
|
2011-09-13 09:35:50 +00:00
|
|
|
const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-07-18 14:57:27 +00:00
|
|
|
static inline void *heap_alloc(size_t len)
|
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *heap_alloc_zero(size_t len)
|
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
|
|
|
}
|
|
|
|
|
2011-09-07 12:07:12 +00:00
|
|
|
static inline void *heap_realloc(void *mem, size_t len)
|
|
|
|
{
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
|
|
|
|
}
|
|
|
|
|
2011-07-18 14:57:27 +00:00
|
|
|
static inline BOOL heap_free(void *mem)
|
|
|
|
{
|
|
|
|
return HeapFree(GetProcessHeap(), 0, mem);
|
|
|
|
}
|
2011-09-05 09:14:55 +00:00
|
|
|
|
|
|
|
static inline LPWSTR heap_strdupW(LPCWSTR str)
|
|
|
|
{
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
|
|
|
|
if(str) {
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
size = (strlenW(str)+1)*sizeof(WCHAR);
|
|
|
|
ret = heap_alloc(size);
|
|
|
|
if(ret)
|
|
|
|
memcpy(ret, str, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|