2011-07-18 16:57:27 +02: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 13:16:27 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "ole2.h"
|
2011-09-05 11:14:14 +02:00
|
|
|
#include "dispex.h"
|
2011-07-18 16:57:27 +02:00
|
|
|
#include "activscp.h"
|
2011-09-02 13:16:27 +02:00
|
|
|
|
2011-07-18 16:57:27 +02:00
|
|
|
#include "vbscript_classes.h"
|
|
|
|
|
2011-09-05 11:14:55 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2011-09-12 12:29:14 +02: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 14:07:12 +02:00
|
|
|
typedef struct _function_t function_t;
|
|
|
|
typedef struct _vbscode_t vbscode_t;
|
2011-09-08 14:54:37 +02:00
|
|
|
typedef struct _script_ctx_t script_ctx_t;
|
2011-09-19 14:08:38 +02:00
|
|
|
typedef struct _vbdisp_t vbdisp_t;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2011-09-05 11:14:55 +02:00
|
|
|
typedef struct named_item_t {
|
|
|
|
IDispatch *disp;
|
|
|
|
DWORD flags;
|
|
|
|
LPWSTR name;
|
|
|
|
|
|
|
|
struct list entry;
|
|
|
|
} named_item_t;
|
|
|
|
|
2011-09-15 14:20:46 +02:00
|
|
|
typedef enum {
|
|
|
|
VBDISP_CALLGET,
|
|
|
|
VBDISP_LET,
|
|
|
|
VBDISP_SET,
|
|
|
|
VBDISP_ANY
|
|
|
|
} vbdisp_invoke_type_t;
|
|
|
|
|
2011-09-16 13:27:22 +02:00
|
|
|
typedef struct {
|
|
|
|
BOOL is_public;
|
|
|
|
const WCHAR *name;
|
|
|
|
} vbdisp_prop_desc_t;
|
|
|
|
|
2011-09-15 14:20:46 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL is_public;
|
|
|
|
function_t *entries[VBDISP_ANY];
|
|
|
|
} vbdisp_funcprop_desc_t;
|
|
|
|
|
2011-09-19 14:08:38 +02: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 14:17:17 +02:00
|
|
|
typedef struct _class_desc_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
script_ctx_t *ctx;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2011-09-16 13:29:25 +02:00
|
|
|
unsigned class_initialize_id;
|
2011-09-16 13:29:37 +02:00
|
|
|
unsigned class_terminate_id;
|
2011-09-15 14:20:46 +02:00
|
|
|
unsigned func_cnt;
|
|
|
|
vbdisp_funcprop_desc_t *funcs;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2011-09-16 13:27:22 +02:00
|
|
|
unsigned prop_cnt;
|
|
|
|
vbdisp_prop_desc_t *props;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
|
|
|
unsigned builtin_prop_cnt;
|
|
|
|
const builtin_prop_t *builtin_props;
|
|
|
|
ITypeInfo *typeinfo;
|
2012-09-06 11:57:33 +02:00
|
|
|
function_t *value_func;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2011-09-15 14:17:17 +02:00
|
|
|
struct _class_desc_t *next;
|
|
|
|
} class_desc_t;
|
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
struct _vbdisp_t {
|
2011-09-05 11:14:14 +02:00
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
2011-09-16 13:29:37 +02:00
|
|
|
BOOL terminator_ran;
|
2011-09-16 13:29:47 +02:00
|
|
|
struct list entry;
|
2011-09-15 14:18:43 +02:00
|
|
|
|
|
|
|
const class_desc_t *desc;
|
2011-09-16 13:27:48 +02:00
|
|
|
VARIANT props[1];
|
2011-09-19 14:08:38 +02:00
|
|
|
};
|
2011-09-05 11:14:14 +02:00
|
|
|
|
2012-09-07 15:09:59 +02:00
|
|
|
typedef struct _ident_map_t ident_map_t;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
typedef struct {
|
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
LONG ref;
|
2012-09-07 15:09:59 +02:00
|
|
|
|
|
|
|
ident_map_t *ident_map;
|
|
|
|
unsigned ident_map_cnt;
|
|
|
|
unsigned ident_map_size;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
script_ctx_t *ctx;
|
|
|
|
} ScriptDisp;
|
|
|
|
|
2011-10-03 13:28:46 +02: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 11:53:41 +02:00
|
|
|
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
|
2011-10-03 13:28:46 +02:00
|
|
|
void collect_objects(script_ctx_t*) DECLSPEC_HIDDEN;
|
2012-09-06 11:57:33 +02:00
|
|
|
HRESULT create_procedure_disp(script_ctx_t*,vbscode_t*,IDispatch**) DECLSPEC_HIDDEN;
|
2012-09-07 15:09:34 +02:00
|
|
|
HRESULT create_script_disp(script_ctx_t*,ScriptDisp**) DECLSPEC_HIDDEN;
|
2011-09-08 14:54:37 +02:00
|
|
|
|
2011-09-14 12:56:01 +02:00
|
|
|
static inline unsigned arg_cnt(const DISPPARAMS *dp)
|
|
|
|
{
|
|
|
|
return dp->cArgs - dp->cNamedArgs;
|
|
|
|
}
|
|
|
|
|
2011-09-14 12:56:45 +02:00
|
|
|
static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
|
|
|
|
{
|
|
|
|
return dp->rgvarg + dp->cArgs-i-1;
|
|
|
|
}
|
|
|
|
|
2011-09-13 11:36:47 +02:00
|
|
|
typedef struct _dynamic_var_t {
|
|
|
|
struct _dynamic_var_t *next;
|
|
|
|
VARIANT v;
|
|
|
|
const WCHAR *name;
|
2011-09-21 14:04:16 +02:00
|
|
|
BOOL is_const;
|
2011-09-13 11:36:47 +02:00
|
|
|
} dynamic_var_t;
|
|
|
|
|
2011-09-08 14:54:37 +02:00
|
|
|
struct _script_ctx_t {
|
2011-08-31 11:22:05 +02:00
|
|
|
IActiveScriptSite *site;
|
|
|
|
LCID lcid;
|
2011-09-05 11:14:14 +02:00
|
|
|
|
2011-09-22 14:25:27 +02:00
|
|
|
IInternetHostSecurityManager *secmgr;
|
|
|
|
DWORD safeopt;
|
|
|
|
|
2011-09-05 11:14:55 +02:00
|
|
|
IDispatch *host_global;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
ScriptDisp *script_obj;
|
2011-09-05 11:14:55 +02:00
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
class_desc_t global_desc;
|
|
|
|
vbdisp_t *global_obj;
|
|
|
|
|
2011-09-19 14:09:21 +02:00
|
|
|
class_desc_t err_desc;
|
|
|
|
vbdisp_t *err_obj;
|
|
|
|
|
2011-09-13 11:36:47 +02:00
|
|
|
dynamic_var_t *global_vars;
|
2011-09-14 12:55:32 +02:00
|
|
|
function_t *global_funcs;
|
2011-09-15 14:17:17 +02:00
|
|
|
class_desc_t *classes;
|
2012-09-06 11:57:33 +02:00
|
|
|
class_desc_t *procs;
|
2011-09-13 11:36:47 +02:00
|
|
|
|
2011-09-20 14:59:53 +02:00
|
|
|
vbsheap_t heap;
|
|
|
|
|
2011-09-16 13:29:47 +02:00
|
|
|
struct list objects;
|
2011-09-07 14:07:12 +02:00
|
|
|
struct list code_list;
|
2011-09-05 11:14:55 +02:00
|
|
|
struct list named_items;
|
2011-09-08 14:54:37 +02:00
|
|
|
};
|
2011-08-31 11:22:05 +02:00
|
|
|
|
2011-10-03 13:28:46 +02:00
|
|
|
HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT init_err(script_ctx_t*) DECLSPEC_HIDDEN;
|
2011-09-05 11:14:14 +02:00
|
|
|
|
2011-09-22 14:25:50 +02:00
|
|
|
IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-09-07 14:08:47 +02:00
|
|
|
typedef enum {
|
|
|
|
ARG_NONE = 0,
|
2011-09-08 14:54:23 +02:00
|
|
|
ARG_STR,
|
2011-09-08 14:57:16 +02:00
|
|
|
ARG_BSTR,
|
|
|
|
ARG_INT,
|
2011-09-12 12:30:11 +02:00
|
|
|
ARG_UINT,
|
2011-09-13 11:38:38 +02:00
|
|
|
ARG_ADDR,
|
2011-09-12 12:30:11 +02:00
|
|
|
ARG_DOUBLE
|
2011-09-07 14:08:47 +02:00
|
|
|
} instr_arg_type_t;
|
|
|
|
|
|
|
|
#define OP_LIST \
|
2011-09-12 12:31:58 +02:00
|
|
|
X(add, 1, 0, 0) \
|
2011-09-14 12:59:02 +02:00
|
|
|
X(and, 1, 0, 0) \
|
2011-12-27 16:17:21 +01:00
|
|
|
X(assign_ident, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(assign_member, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 14:57:16 +02:00
|
|
|
X(bool, 1, ARG_INT, 0) \
|
2012-07-20 16:28:45 +02:00
|
|
|
X(case, 0, ARG_ADDR, 0) \
|
2011-09-12 12:30:47 +02:00
|
|
|
X(concat, 1, 0, 0) \
|
2011-09-21 14:03:38 +02:00
|
|
|
X(const, 1, ARG_BSTR, 0) \
|
2011-09-13 11:40:39 +02:00
|
|
|
X(div, 1, 0, 0) \
|
2011-09-12 12:30:11 +02:00
|
|
|
X(double, 1, ARG_DOUBLE, 0) \
|
2011-09-09 14:49:26 +02:00
|
|
|
X(empty, 1, 0, 0) \
|
2012-07-03 17:05:32 +02:00
|
|
|
X(enumnext, 0, ARG_ADDR, ARG_BSTR) \
|
2011-09-09 14:48:25 +02:00
|
|
|
X(equal, 1, 0, 0) \
|
2011-09-19 14:10:19 +02:00
|
|
|
X(errmode, 1, ARG_INT, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(eqv, 1, 0, 0) \
|
2011-09-13 11:41:15 +02:00
|
|
|
X(exp, 1, 0, 0) \
|
2011-09-19 14:07:12 +02:00
|
|
|
X(gt, 1, 0, 0) \
|
|
|
|
X(gteq, 1, 0, 0) \
|
2011-09-09 14:48:48 +02:00
|
|
|
X(icall, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 14:57:16 +02:00
|
|
|
X(icallv, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-13 11:40:14 +02:00
|
|
|
X(idiv, 1, 0, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(imp, 1, 0, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(incc, 1, ARG_BSTR, 0) \
|
2011-09-19 14:08:02 +02:00
|
|
|
X(is, 1, 0, 0) \
|
2011-09-13 11:38:38 +02:00
|
|
|
X(jmp, 0, ARG_ADDR, 0) \
|
|
|
|
X(jmp_false, 0, ARG_ADDR, 0) \
|
2011-09-16 13:30:31 +02:00
|
|
|
X(jmp_true, 0, ARG_ADDR, 0) \
|
2011-09-12 12:30:11 +02:00
|
|
|
X(long, 1, ARG_INT, 0) \
|
2011-09-19 14:07:12 +02:00
|
|
|
X(lt, 1, 0, 0) \
|
|
|
|
X(lteq, 1, 0, 0) \
|
2011-09-15 14:19:41 +02:00
|
|
|
X(mcall, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(mcallv, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-19 14:09:57 +02:00
|
|
|
X(me, 1, 0, 0) \
|
2011-09-13 11:39:53 +02:00
|
|
|
X(mod, 1, 0, 0) \
|
2011-09-13 11:40:39 +02:00
|
|
|
X(mul, 1, 0, 0) \
|
2011-09-12 12:31:37 +02:00
|
|
|
X(neg, 1, 0, 0) \
|
2011-09-12 12:32:27 +02:00
|
|
|
X(nequal, 1, 0, 0) \
|
2011-09-15 14:18:12 +02:00
|
|
|
X(new, 1, ARG_STR, 0) \
|
2012-07-03 17:05:32 +02:00
|
|
|
X(newenum, 1, 0, 0) \
|
2011-09-09 14:47:45 +02:00
|
|
|
X(not, 1, 0, 0) \
|
2011-09-15 14:18:56 +02:00
|
|
|
X(nothing, 1, 0, 0) \
|
2011-09-09 14:49:36 +02:00
|
|
|
X(null, 1, 0, 0) \
|
2011-09-14 12:59:26 +02:00
|
|
|
X(or, 1, 0, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(pop, 1, ARG_UINT, 0) \
|
2011-09-08 14:57:31 +02:00
|
|
|
X(ret, 0, 0, 0) \
|
2011-12-27 16:17:21 +01:00
|
|
|
X(set_ident, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(set_member, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-12 12:30:11 +02:00
|
|
|
X(short, 1, ARG_INT, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(step, 0, ARG_ADDR, ARG_BSTR) \
|
2011-09-15 14:22:27 +02:00
|
|
|
X(stop, 1, 0, 0) \
|
2011-09-12 12:31:58 +02:00
|
|
|
X(string, 1, ARG_STR, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(sub, 1, 0, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(val, 1, 0, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(xor, 1, 0, 0)
|
2011-09-07 14:07:12 +02:00
|
|
|
|
|
|
|
typedef enum {
|
2011-09-07 14:08:47 +02:00
|
|
|
#define X(x,n,a,b) OP_##x,
|
2011-09-07 14:07:12 +02:00
|
|
|
OP_LIST
|
|
|
|
#undef X
|
|
|
|
OP_LAST
|
|
|
|
} vbsop_t;
|
|
|
|
|
2011-09-07 14:08:47 +02:00
|
|
|
typedef union {
|
|
|
|
const WCHAR *str;
|
2011-09-08 14:54:23 +02:00
|
|
|
BSTR bstr;
|
2011-09-08 14:57:16 +02:00
|
|
|
unsigned uint;
|
|
|
|
LONG lng;
|
2011-09-12 12:30:11 +02:00
|
|
|
double *dbl;
|
2011-09-07 14:08:47 +02:00
|
|
|
} instr_arg_t;
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
typedef struct {
|
|
|
|
vbsop_t op;
|
2011-09-07 14:08:47 +02:00
|
|
|
instr_arg_t arg1;
|
|
|
|
instr_arg_t arg2;
|
2011-09-07 14:07:12 +02:00
|
|
|
} instr_t;
|
|
|
|
|
2011-09-14 13:55:57 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL by_ref;
|
|
|
|
} arg_desc_t;
|
|
|
|
|
2011-09-14 12:54:50 +02:00
|
|
|
typedef enum {
|
|
|
|
FUNC_GLOBAL,
|
2011-09-14 16:55:51 +02:00
|
|
|
FUNC_FUNCTION,
|
2011-09-16 13:28:00 +02:00
|
|
|
FUNC_SUB,
|
|
|
|
FUNC_PROPGET,
|
|
|
|
FUNC_PROPLET,
|
2011-09-16 13:28:52 +02:00
|
|
|
FUNC_PROPSET,
|
|
|
|
FUNC_DEFGET
|
2011-09-14 12:54:50 +02:00
|
|
|
} function_type_t;
|
|
|
|
|
2011-09-14 12:57:37 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
} var_desc_t;
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
struct _function_t {
|
2011-09-14 12:55:07 +02:00
|
|
|
function_type_t type;
|
|
|
|
const WCHAR *name;
|
2011-09-15 14:20:05 +02:00
|
|
|
BOOL is_public;
|
2011-09-14 13:55:57 +02:00
|
|
|
arg_desc_t *args;
|
|
|
|
unsigned arg_cnt;
|
2011-09-14 12:57:37 +02:00
|
|
|
var_desc_t *vars;
|
|
|
|
unsigned var_cnt;
|
2011-09-07 14:07:12 +02:00
|
|
|
unsigned code_off;
|
|
|
|
vbscode_t *code_ctx;
|
2011-09-14 12:55:07 +02:00
|
|
|
function_t *next;
|
2011-09-07 14:07:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _vbscode_t {
|
|
|
|
instr_t *instrs;
|
|
|
|
WCHAR *source;
|
|
|
|
|
2011-09-09 14:47:00 +02:00
|
|
|
BOOL option_explicit;
|
|
|
|
|
2012-09-06 11:57:15 +02:00
|
|
|
BOOL pending_exec;
|
|
|
|
function_t main_code;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2011-09-08 14:54:23 +02:00
|
|
|
BSTR *bstr_pool;
|
|
|
|
unsigned bstr_pool_size;
|
|
|
|
unsigned bstr_cnt;
|
2011-09-12 12:29:14 +02:00
|
|
|
vbsheap_t heap;
|
2011-09-08 14:54:23 +02:00
|
|
|
|
2011-09-07 14:07:12 +02: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 14:21:58 +02:00
|
|
|
HRESULT exec_script(script_ctx_t*,function_t*,IDispatch*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
2011-10-14 16:22:18 +02:00
|
|
|
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2011-09-19 14:08:38 +02: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 13:28:46 +02:00
|
|
|
HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2012-09-26 14:36:15 +02: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 13:28:46 +02:00
|
|
|
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
2011-07-18 16:57:27 +02:00
|
|
|
|
2011-09-13 11:35:50 +02:00
|
|
|
const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-07-18 16:57:27 +02: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 14:07:12 +02:00
|
|
|
static inline void *heap_realloc(void *mem, size_t len)
|
|
|
|
{
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
|
|
|
|
}
|
|
|
|
|
2011-07-18 16:57:27 +02:00
|
|
|
static inline BOOL heap_free(void *mem)
|
|
|
|
{
|
|
|
|
return HeapFree(GetProcessHeap(), 0, mem);
|
|
|
|
}
|
2011-09-05 11:14:55 +02: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;
|
|
|
|
}
|