ReactOS  0.4.13-dev-66-gc714b7f
string.c File Reference
#include "config.h"
#include "wine/port.h"
#include "jscript.h"
#include "regexp.h"
#include "wine/debug.h"
Include dependency graph for string.c:

Go to the source code of this file.

Classes

struct  StringInstance
 
struct  strbuf_t
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static StringInstancestring_from_jsdisp (jsdisp_t *jsdisp)
 
static StringInstancestring_from_vdisp (vdisp_t *vdisp)
 
static StringInstancestring_this (vdisp_t *jsthis)
 
static HRESULT get_string_val (script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
 
static HRESULT get_string_flat_val (script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **jsval, const WCHAR **val)
 
static HRESULT String_get_length (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static HRESULT stringobj_to_string (vdisp_t *jsthis, jsval_t *r)
 
static HRESULT String_toString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_valueOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT do_attributeless_tag_format (script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
 
static HRESULT do_attribute_tag_format (script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, const WCHAR *tagname, const WCHAR *attrname)
 
static HRESULT String_anchor (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_big (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_blink (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_bold (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_charAt (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_charCodeAt (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_concat (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_fixed (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_fontcolor (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_fontsize (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_indexOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_italics (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_lastIndexOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_link (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_match (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static BOOL strbuf_ensure_size (strbuf_t *buf, unsigned len)
 
static HRESULT strbuf_append (strbuf_t *buf, const WCHAR *str, DWORD len)
 
static HRESULT strbuf_append_jsstr (strbuf_t *buf, jsstr_t *str)
 
static HRESULT rep_call (script_ctx_t *ctx, jsdisp_t *func, jsstr_t *jsstr, const WCHAR *str, match_state_t *match, jsstr_t **ret)
 
static HRESULT String_replace (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_search (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_slice (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_small (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_split (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_strike (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_sub (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_substring (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_substr (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_sup (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_toLowerCase (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_toUpperCase (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_toLocaleLowerCase (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_toLocaleUpperCase (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_trim (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_localeCompare (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT String_get_value (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static void String_destructor (jsdisp_t *dispex)
 
static unsigned String_idx_length (jsdisp_t *jsdisp)
 
static HRESULT String_idx_get (jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
 
static HRESULT StringConstr_fromCharCode (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT StringConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT string_alloc (script_ctx_t *ctx, jsdisp_t *object_prototype, jsstr_t *str, StringInstance **ret)
 
HRESULT create_string_constr (script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
 
HRESULT create_string (script_ctx_t *ctx, jsstr_t *str, jsdisp_t **ret)
 

Variables

static const WCHAR lengthW [] = {'l','e','n','g','t','h',0}
 
static const WCHAR toStringW [] = {'t','o','S','t','r','i','n','g',0}
 
static const WCHAR valueOfW [] = {'v','a','l','u','e','O','f',0}
 
static const WCHAR anchorW [] = {'a','n','c','h','o','r',0}
 
static const WCHAR bigW [] = {'b','i','g',0}
 
static const WCHAR blinkW [] = {'b','l','i','n','k',0}
 
static const WCHAR boldW [] = {'b','o','l','d',0}
 
static const WCHAR charAtW [] = {'c','h','a','r','A','t',0}
 
static const WCHAR charCodeAtW [] = {'c','h','a','r','C','o','d','e','A','t',0}
 
static const WCHAR concatW [] = {'c','o','n','c','a','t',0}
 
static const WCHAR fixedW [] = {'f','i','x','e','d',0}
 
static const WCHAR fontcolorW [] = {'f','o','n','t','c','o','l','o','r',0}
 
static const WCHAR fontsizeW [] = {'f','o','n','t','s','i','z','e',0}
 
static const WCHAR indexOfW [] = {'i','n','d','e','x','O','f',0}
 
static const WCHAR italicsW [] = {'i','t','a','l','i','c','s',0}
 
static const WCHAR lastIndexOfW [] = {'l','a','s','t','I','n','d','e','x','O','f',0}
 
static const WCHAR linkW [] = {'l','i','n','k',0}
 
static const WCHAR matchW [] = {'m','a','t','c','h',0}
 
static const WCHAR replaceW [] = {'r','e','p','l','a','c','e',0}
 
static const WCHAR searchW [] = {'s','e','a','r','c','h',0}
 
static const WCHAR sliceW [] = {'s','l','i','c','e',0}
 
static const WCHAR smallW [] = {'s','m','a','l','l',0}
 
static const WCHAR splitW [] = {'s','p','l','i','t',0}
 
static const WCHAR strikeW [] = {'s','t','r','i','k','e',0}
 
static const WCHAR subW [] = {'s','u','b',0}
 
static const WCHAR substringW [] = {'s','u','b','s','t','r','i','n','g',0}
 
static const WCHAR substrW [] = {'s','u','b','s','t','r',0}
 
static const WCHAR supW [] = {'s','u','p',0}
 
static const WCHAR toLowerCaseW [] = {'t','o','L','o','w','e','r','C','a','s','e',0}
 
static const WCHAR toUpperCaseW [] = {'t','o','U','p','p','e','r','C','a','s','e',0}
 
static const WCHAR toLocaleLowerCaseW [] = {'t','o','L','o','c','a','l','e','L','o','w','e','r','C','a','s','e',0}
 
static const WCHAR toLocaleUpperCaseW [] = {'t','o','L','o','c','a','l','e','U','p','p','e','r','C','a','s','e',0}
 
static const WCHAR trimW [] = {'t','r','i','m',0}
 
static const WCHAR localeCompareW [] = {'l','o','c','a','l','e','C','o','m','p','a','r','e',0}
 
static const WCHAR fromCharCodeW [] = {'f','r','o','m','C','h','a','r','C','o','d','e',0}
 
static const builtin_prop_t String_props []
 
static const builtin_info_t String_info
 
static const builtin_prop_t StringInst_props []
 
static const builtin_info_t StringInst_info
 
static const builtin_prop_t StringConstr_props []
 
static const builtin_info_t StringConstr_info
 

Function Documentation

◆ create_string()

HRESULT create_string ( script_ctx_t ctx,
jsstr_t str,
jsdisp_t **  ret 
)

Definition at line 1768 of file string.c.

1769 {
1771  HRESULT hres;
1772 
1773  hres = string_alloc(ctx, NULL, str, &string);
1774  if(FAILED(hres))
1775  return hres;
1776 
1777  *ret = &string->dispex;
1778  return S_OK;
1779 
1780 }
const char * string
Definition: string.c:1522
static HRESULT string_alloc(script_ctx_t *ctx, jsdisp_t *object_prototype, jsstr_t *str, StringInstance **ret)
Definition: string.c:1714
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
#define S_OK
Definition: intsafe.h:59

Referenced by StringConstr_value(), and to_object().

◆ create_string_constr()

HRESULT create_string_constr ( script_ctx_t ctx,
jsdisp_t object_prototype,
jsdisp_t **  ret 
)

Definition at line 1750 of file string.c.

1751 {
1753  HRESULT hres;
1754 
1755  static const WCHAR StringW[] = {'S','t','r','i','n','g',0};
1756 
1757  hres = string_alloc(ctx, object_prototype, jsstr_empty(), &string);
1758  if(FAILED(hres))
1759  return hres;
1760 
1762  PROPF_CONSTR|1, &string->dispex, ret);
1763 
1764  jsdisp_release(&string->dispex);
1765  return hres;
1766 }
const char * string
Definition: string.c:1522
static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: string.c:1666
#define PROPF_CONSTR
Definition: jscript.h:95
HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:679
static HRESULT string_alloc(script_ctx_t *ctx, jsdisp_t *object_prototype, jsstr_t *str, StringInstance **ret)
Definition: string.c:1714
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
static const builtin_info_t StringConstr_info
Definition: string.c:1741
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
static const WCHAR StringW[]
Definition: global.c:47
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264

Referenced by init_constructors().

◆ do_attribute_tag_format()

static HRESULT do_attribute_tag_format ( script_ctx_t ctx,
vdisp_t jsthis,
unsigned  argc,
jsval_t argv,
jsval_t r,
const WCHAR tagname,
const WCHAR attrname 
)
static

Definition at line 197 of file string.c.

199 {
200  jsstr_t *str, *attr_value = NULL;
201  HRESULT hres;
202 
203  hres = get_string_val(ctx, jsthis, &str);
204  if(FAILED(hres))
205  return hres;
206 
207  if(argc) {
208  hres = to_string(ctx, argv[0], &attr_value);
209  if(FAILED(hres)) {
211  return hres;
212  }
213  }else {
214  attr_value = jsstr_undefined();
215  }
216 
217  if(r) {
218  unsigned attrname_len = strlenW(attrname);
219  unsigned tagname_len = strlenW(tagname);
220  jsstr_t *ret;
221  WCHAR *ptr;
222 
223  ret = jsstr_alloc_buf(2*tagname_len + attrname_len + jsstr_length(attr_value) + jsstr_length(str) + 9, &ptr);
224  if(ret) {
225  *ptr++ = '<';
226  memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
227  ptr += tagname_len;
228  *ptr++ = ' ';
229  memcpy(ptr, attrname, attrname_len*sizeof(WCHAR));
230  ptr += attrname_len;
231  *ptr++ = '=';
232  *ptr++ = '"';
233  ptr += jsstr_flush(attr_value, ptr);
234  *ptr++ = '"';
235  *ptr++ = '>';
236  ptr += jsstr_flush(str, ptr);
237 
238  *ptr++ = '<';
239  *ptr++ = '/';
240  memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
241  ptr += tagname_len;
242  *ptr = '>';
243 
244  *r = jsval_string(ret);
245  }else {
247  }
248  }
249 
250  jsstr_release(attr_value);
252  return hres;
253 }
static int argc
Definition: ServiceArgs.c:12
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static char tagname[200]
Definition: rgenstat.c:63
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69

Referenced by String_anchor(), String_fontcolor(), String_fontsize(), and String_link().

◆ do_attributeless_tag_format()

static HRESULT do_attributeless_tag_format ( script_ctx_t ctx,
vdisp_t jsthis,
jsval_t r,
const WCHAR tagname 
)
static

Definition at line 155 of file string.c.

156 {
157  unsigned tagname_len;
158  jsstr_t *str, *ret;
159  WCHAR *ptr;
160  HRESULT hres;
161 
162  hres = get_string_val(ctx, jsthis, &str);
163  if(FAILED(hres))
164  return hres;
165 
166  if(!r) {
168  return S_OK;
169  }
170 
171  tagname_len = strlenW(tagname);
172 
173  ret = jsstr_alloc_buf(jsstr_length(str) + 2*tagname_len + 5, &ptr);
174  if(!ret) {
176  return E_OUTOFMEMORY;
177  }
178 
179  *ptr++ = '<';
180  memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
181  ptr += tagname_len;
182  *ptr++ = '>';
183 
184  ptr += jsstr_flush(str, ptr);
186 
187  *ptr++ = '<';
188  *ptr++ = '/';
189  memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
190  ptr += tagname_len;
191  *ptr = '>';
192 
193  *r = jsval_string(ret);
194  return S_OK;
195 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static char tagname[200]
Definition: rgenstat.c:63
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69

Referenced by String_big(), String_blink(), String_bold(), String_fixed(), String_italics(), String_small(), String_strike(), String_sub(), and String_sup().

◆ get_string_flat_val()

static HRESULT get_string_flat_val ( script_ctx_t ctx,
vdisp_t jsthis,
jsstr_t **  jsval,
const WCHAR **  val 
)
static

Definition at line 97 of file string.c.

98 {
99  HRESULT hres;
100 
101  hres = get_string_val(ctx, jsthis, jsval);
102  if(FAILED(hres))
103  return hres;
104 
105  *val = jsstr_flatten(*jsval);
106  if(*val)
107  return S_OK;
108 
110  return E_OUTOFMEMORY;
111 }
static const WCHAR * jsstr_flatten(jsstr_t *str)
Definition: jsstr.h:139
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
uint64_t jsval
Definition: nsiface.idl:211
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59

Referenced by String_indexOf(), String_lastIndexOf(), String_replace(), String_search(), and String_split().

◆ get_string_val()

static HRESULT get_string_val ( script_ctx_t ctx,
vdisp_t jsthis,
jsstr_t **  val 
)
static

Definition at line 85 of file string.c.

86 {
88 
89  if((string = string_this(jsthis))) {
90  *val = jsstr_addref(string->str);
91  return S_OK;
92  }
93 
94  return to_string(ctx, jsval_disp(jsthis->u.disp), val);
95 }
const char * string
Definition: string.c:1522
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
union vdisp_t::@418 u
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
GLuint GLfloat * val
Definition: glext.h:7180
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
IDispatch * disp
Definition: jscript.h:138
#define S_OK
Definition: intsafe.h:59
static StringInstance * string_this(vdisp_t *jsthis)
Definition: string.c:80

Referenced by do_attribute_tag_format(), do_attributeless_tag_format(), get_string_flat_val(), String_charAt(), String_charCodeAt(), String_concat(), String_match(), String_slice(), String_substr(), String_substring(), String_toLowerCase(), and String_toUpperCase().

◆ rep_call()

static HRESULT rep_call ( script_ctx_t ctx,
jsdisp_t func,
jsstr_t jsstr,
const WCHAR str,
match_state_t match,
jsstr_t **  ret 
)
static

Definition at line 719 of file string.c.

721 {
722  jsval_t *argv;
723  unsigned argc;
724  jsval_t val;
725  jsstr_t *tmp_str;
726  DWORD i;
727  HRESULT hres = S_OK;
728 
729  argc = match->paren_count+3;
730  argv = heap_alloc_zero(sizeof(*argv)*argc);
731  if(!argv)
732  return E_OUTOFMEMORY;
733 
734  tmp_str = jsstr_alloc_len(match->cp-match->match_len, match->match_len);
735  if(!tmp_str)
737  argv[0] = jsval_string(tmp_str);
738 
739  if(SUCCEEDED(hres)) {
740  for(i=0; i < match->paren_count; i++) {
741  if(match->parens[i].index != -1)
742  tmp_str = jsstr_substr(jsstr, match->parens[i].index, match->parens[i].length);
743  else
744  tmp_str = jsstr_empty();
745  if(!tmp_str) {
747  break;
748  }
749  argv[i+1] = jsval_string(tmp_str);
750  }
751  }
752 
753  if(SUCCEEDED(hres)) {
754  argv[match->paren_count+1] = jsval_number(match->cp-str - match->match_len);
755  argv[match->paren_count+2] = jsval_string(jsstr);
756  }
757 
758  if(SUCCEEDED(hres))
760 
761  for(i=0; i <= match->paren_count; i++)
763  heap_free(argv);
764 
765  if(FAILED(hres))
766  return hres;
767 
768  hres = to_string(ctx, val, ret);
770  return hres;
771 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
Definition: jsval.h:54
GLenum func
Definition: glext.h:6028
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static jsstr_t * jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
Definition: jsstr.h:163
Definition: jsstr.h:39
Definition: match.c:28
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define DISPATCH_METHOD
Definition: oleauto.h:1006
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static jsstr_t * get_string(jsval_t v)
Definition: jsval.h:229
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1110
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by String_replace().

◆ strbuf_append()

static HRESULT strbuf_append ( strbuf_t buf,
const WCHAR str,
DWORD  len 
)
static

Definition at line 696 of file string.c.

697 {
698  if(!len)
699  return S_OK;
700 
701  if(!strbuf_ensure_size(buf, buf->len+len))
702  return E_OUTOFMEMORY;
703 
704  memcpy(buf->buf+buf->len, str, len*sizeof(WCHAR));
705  buf->len += len;
706  return S_OK;
707 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static BOOL strbuf_ensure_size(strbuf_t *buf, unsigned len)
Definition: string.c:673
__wchar_t WCHAR
Definition: xmlstorage.h:180
static size_t len
Definition: string.c:60
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59

Referenced by String_replace().

◆ strbuf_append_jsstr()

static HRESULT strbuf_append_jsstr ( strbuf_t buf,
jsstr_t str 
)
static

Definition at line 709 of file string.c.

710 {
712  return E_OUTOFMEMORY;
713 
714  jsstr_flush(str, buf->buf+buf->len);
715  buf->len += jsstr_length(str);
716  return S_OK;
717 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static BOOL strbuf_ensure_size(strbuf_t *buf, unsigned len)
Definition: string.c:673
#define S_OK
Definition: intsafe.h:59

Referenced by String_replace().

◆ strbuf_ensure_size()

static BOOL strbuf_ensure_size ( strbuf_t buf,
unsigned  len 
)
static

Definition at line 673 of file string.c.

674 {
675  WCHAR *new_buf;
676  DWORD new_size;
677 
678  if(len <= buf->size)
679  return TRUE;
680 
681  new_size = buf->size ? buf->size<<1 : 16;
682  if(new_size < len)
683  new_size = len;
684  if(buf->buf)
685  new_buf = heap_realloc(buf->buf, new_size*sizeof(WCHAR));
686  else
687  new_buf = heap_alloc(new_size*sizeof(WCHAR));
688  if(!new_buf)
689  return FALSE;
690 
691  buf->buf = new_buf;
692  buf->size = new_size;
693  return TRUE;
694 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static size_t len
Definition: string.c:60
GLenum GLsizei len
Definition: glext.h:6722

Referenced by strbuf_append(), and strbuf_append_jsstr().

◆ string_alloc()

static HRESULT string_alloc ( script_ctx_t ctx,
jsdisp_t object_prototype,
jsstr_t str,
StringInstance **  ret 
)
static

Definition at line 1714 of file string.c.

1715 {
1717  HRESULT hres;
1718 
1719  string = heap_alloc_zero(sizeof(StringInstance));
1720  if(!string)
1721  return E_OUTOFMEMORY;
1722 
1723  if(object_prototype)
1724  hres = init_dispex(&string->dispex, ctx, &String_info, object_prototype);
1725  else
1727  if(FAILED(hres)) {
1728  heap_free(string);
1729  return hres;
1730  }
1731 
1732  string->str = jsstr_addref(str);
1733  *ret = string;
1734  return S_OK;
1735 }
const char * string
Definition: string.c:1522
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
jsdisp_t * string_constr
Definition: jscript.h:452
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
#define S_OK
Definition: intsafe.h:59
static const builtin_info_t StringInst_info
Definition: string.c:1623
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:940
static const builtin_info_t String_info
Definition: string.c:1610
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1051
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_string(), and create_string_constr().

◆ String_anchor()

static HRESULT String_anchor ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 255 of file string.c.

257 {
258  static const WCHAR fontW[] = {'A',0};
259  static const WCHAR colorW[] = {'N','A','M','E',0};
260 
261  return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
262 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR fontW[]
Definition: editor.c:78
static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, const WCHAR *tagname, const WCHAR *attrname)
Definition: string.c:197

◆ String_big()

static HRESULT String_big ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 264 of file string.c.

266 {
267  static const WCHAR bigtagW[] = {'B','I','G',0};
268  return do_attributeless_tag_format(ctx, jsthis, r, bigtagW);
269 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_blink()

static HRESULT String_blink ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 271 of file string.c.

273 {
274  static const WCHAR blinktagW[] = {'B','L','I','N','K',0};
275  return do_attributeless_tag_format(ctx, jsthis, r, blinktagW);
276 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_bold()

static HRESULT String_bold ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 278 of file string.c.

280 {
281  static const WCHAR boldtagW[] = {'B',0};
282  return do_attributeless_tag_format(ctx, jsthis, r, boldtagW);
283 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_charAt()

static HRESULT String_charAt ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 286 of file string.c.

288 {
289  jsstr_t *str, *ret;
290  INT pos = 0;
291  HRESULT hres;
292 
293  TRACE("\n");
294 
295  hres = get_string_val(ctx, jsthis, &str);
296  if(FAILED(hres))
297  return hres;
298 
299  if(argc) {
300  double d;
301 
302  hres = to_integer(ctx, argv[0], &d);
303  if(FAILED(hres)) {
305  return hres;
306  }
307  pos = is_int32(d) ? d : -1;
308  }
309 
310  if(!r) {
312  return S_OK;
313  }
314 
315  if(0 <= pos && pos < jsstr_length(str)) {
316  ret = jsstr_substr(str, pos, 1);
317  if(!ret)
318  return E_OUTOFMEMORY;
319  }else {
320  ret = jsstr_empty();
321  }
322 
323  *r = jsval_string(ret);
324  return S_OK;
325 }
static int argc
Definition: ServiceArgs.c:12
static jsstr_t * jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
Definition: jsstr.h:163
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
int ret
#define S_OK
Definition: intsafe.h:59
static BOOL is_int32(double d)
Definition: jscript.h:515

◆ String_charCodeAt()

static HRESULT String_charCodeAt ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 328 of file string.c.

330 {
331  jsstr_t *str;
332  DWORD idx = 0;
333  HRESULT hres;
334 
335  TRACE("\n");
336 
337  hres = get_string_val(ctx, jsthis, &str);
338  if(FAILED(hres))
339  return hres;
340 
341  if(argc > 0) {
342  double d;
343 
344  hres = to_integer(ctx, argv[0], &d);
345  if(FAILED(hres)) {
347  return hres;
348  }
349 
350  if(!is_int32(d) || d < 0 || d >= jsstr_length(str)) {
352  if(r)
353  *r = jsval_number(NAN);
354  return S_OK;
355  }
356 
357  idx = d;
358  }
359 
360  if(r) {
361  WCHAR c;
362  jsstr_extract(str, idx, 1, &c);
363  *r = jsval_number(c);
364  }
365 
367  return S_OK;
368 }
static int argc
Definition: ServiceArgs.c:12
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
unsigned int idx
Definition: utils.c:41
const WCHAR * str
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NAN
Definition: misc.c:46
#define S_OK
Definition: intsafe.h:59
void jsstr_extract(jsstr_t *str, unsigned off, unsigned len, WCHAR *buf)
Definition: jsstr.c:113
#define c
Definition: ke_i.h:80
static BOOL is_int32(double d)
Definition: jscript.h:515
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ String_concat()

static HRESULT String_concat ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 371 of file string.c.

373 {
374  jsstr_t *ret = NULL, *str;
375  HRESULT hres;
376 
377  TRACE("\n");
378 
379  hres = get_string_val(ctx, jsthis, &str);
380  if(FAILED(hres))
381  return hres;
382 
383  switch(argc) {
384  case 0:
385  ret = str;
386  break;
387  case 1: {
388  jsstr_t *arg_str;
389 
390  hres = to_string(ctx, argv[0], &arg_str);
391  if(FAILED(hres)) {
393  return hres;
394  }
395 
396  ret = jsstr_concat(str, arg_str);
398  if(!ret)
399  return E_OUTOFMEMORY;
400  break;
401  }
402  default: {
403  const unsigned str_cnt = argc+1;
404  unsigned len = 0, i;
405  jsstr_t **strs;
406  WCHAR *ptr;
407 
408  strs = heap_alloc_zero(str_cnt * sizeof(*strs));
409  if(!strs) {
411  return E_OUTOFMEMORY;
412  }
413 
414  strs[0] = str;
415  for(i=0; i < argc; i++) {
416  hres = to_string(ctx, argv[i], strs+i+1);
417  if(FAILED(hres))
418  break;
419  }
420 
421  if(SUCCEEDED(hres)) {
422  for(i=0; i < str_cnt; i++) {
423  len += jsstr_length(strs[i]);
424  if(len > JSSTR_MAX_LENGTH) {
426  break;
427  }
428  }
429 
430  if(SUCCEEDED(hres)) {
431  ret = jsstr_alloc_buf(len, &ptr);
432  if(ret) {
433  for(i=0; i < str_cnt; i++)
434  ptr += jsstr_flush(strs[i], ptr);
435  }else {
437  }
438  }
439  }
440 
441  while(i--)
442  jsstr_release(strs[i]);
443  heap_free(strs);
444  if(FAILED(hres))
445  return hres;
446  }
447  }
448 
449  if(r)
450  *r = jsval_string(ret);
451  else
453  return S_OK;
454 }
static int argc
Definition: ServiceArgs.c:12
jsstr_t * jsstr_concat(jsstr_t *str1, jsstr_t *str2)
Definition: jsstr.c:211
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
#define JSSTR_MAX_LENGTH
Definition: jsstr.h:45
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ String_destructor()

static void String_destructor ( jsdisp_t dispex)
static

Definition at line 1536 of file string.c.

1537 {
1539 
1540  jsstr_release(This->str);
1541  heap_free(This);
1542 }
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
static StringInstance * string_from_jsdisp(jsdisp_t *jsdisp)
Definition: string.c:70
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ String_fixed()

static HRESULT String_fixed ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 456 of file string.c.

458 {
459  static const WCHAR fixedtagW[] = {'T','T',0};
460  return do_attributeless_tag_format(ctx, jsthis, r, fixedtagW);
461 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_fontcolor()

static HRESULT String_fontcolor ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 463 of file string.c.

465 {
466  static const WCHAR fontW[] = {'F','O','N','T',0};
467  static const WCHAR colorW[] = {'C','O','L','O','R',0};
468 
469  return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
470 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR fontW[]
Definition: editor.c:78
static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, const WCHAR *tagname, const WCHAR *attrname)
Definition: string.c:197

◆ String_fontsize()

static HRESULT String_fontsize ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 472 of file string.c.

474 {
475  static const WCHAR fontW[] = {'F','O','N','T',0};
476  static const WCHAR colorW[] = {'S','I','Z','E',0};
477 
478  return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
479 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR fontW[]
Definition: editor.c:78
static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, const WCHAR *tagname, const WCHAR *attrname)
Definition: string.c:197

◆ string_from_jsdisp()

static StringInstance* string_from_jsdisp ( jsdisp_t jsdisp)
inlinestatic

Definition at line 70 of file string.c.

71 {
72  return CONTAINING_RECORD(jsdisp, StringInstance, dispex);
73 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by String_destructor(), string_from_vdisp(), String_get_length(), String_get_value(), String_idx_get(), and String_idx_length().

◆ string_from_vdisp()

static StringInstance* string_from_vdisp ( vdisp_t vdisp)
inlinestatic

Definition at line 75 of file string.c.

76 {
77  return string_from_jsdisp(vdisp->u.jsdisp);
78 }
union vdisp_t::@418 u
jsdisp_t * jsdisp
Definition: jscript.h:140
static StringInstance * string_from_jsdisp(jsdisp_t *jsdisp)
Definition: string.c:70

Referenced by string_this().

◆ String_get_length()

static HRESULT String_get_length ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 113 of file string.c.

114 {
115  StringInstance *string = string_from_jsdisp(jsthis);
116 
117  TRACE("%p\n", jsthis);
118 
119  *r = jsval_number(jsstr_length(string->str));
120  return S_OK;
121 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
#define TRACE(s)
Definition: solgame.cpp:4
static StringInstance * string_from_jsdisp(jsdisp_t *jsdisp)
Definition: string.c:70
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ String_get_value()

static HRESULT String_get_value ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 1526 of file string.c.

1527 {
1529 
1530  TRACE("\n");
1531 
1532  *r = jsval_string(jsstr_addref(This->str));
1533  return S_OK;
1534 }
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
static StringInstance * string_from_jsdisp(jsdisp_t *jsdisp)
Definition: string.c:70
#define S_OK
Definition: intsafe.h:59

◆ String_idx_get()

static HRESULT String_idx_get ( jsdisp_t jsdisp,
unsigned  idx,
jsval_t r 
)
static

Definition at line 1558 of file string.c.

1559 {
1560  StringInstance *string = string_from_jsdisp(jsdisp);
1561  jsstr_t *ret;
1562 
1563  ret = jsstr_substr(string->str, idx, 1);
1564  if(!ret)
1565  return E_OUTOFMEMORY;
1566 
1567  TRACE("%p[%u] = %s\n", string, idx, debugstr_jsstr(ret));
1568 
1569  *r = jsval_string(ret);
1570  return S_OK;
1571 }
static jsstr_t * jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
Definition: jsstr.h:163
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int idx
Definition: utils.c:41
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
static StringInstance * string_from_jsdisp(jsdisp_t *jsdisp)
Definition: string.c:70
int ret
#define S_OK
Definition: intsafe.h:59

◆ String_idx_length()

static unsigned String_idx_length ( jsdisp_t jsdisp)
static

Definition at line 1544 of file string.c.

1545 {
1546  StringInstance *string = string_from_jsdisp(jsdisp);
1547 
1548  /*
1549  * NOTE: For invoke version < 2, indexed array is not implemented at all.
1550  * Newer jscript.dll versions implement it on string type, not class,
1551  * which is not how it should work according to spec. IE9 implements it
1552  * properly, but it uses its own JavaScript engine inside MSHTML. We
1553  * implement it here, but in the way IE9 and spec work.
1554  */
1555  return string->dispex.ctx->version < 2 ? 0 : jsstr_length(string->str);
1556 }
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static StringInstance * string_from_jsdisp(jsdisp_t *jsdisp)
Definition: string.c:70

◆ String_indexOf()

static HRESULT String_indexOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 481 of file string.c.

483 {
484  unsigned pos = 0, search_len, length;
485  jsstr_t *search_jsstr, *jsstr;
486  const WCHAR *search_str, *str;
487  INT ret = -1;
488  HRESULT hres;
489 
490  TRACE("\n");
491 
492  hres = get_string_flat_val(ctx, jsthis, &jsstr, &str);
493  if(FAILED(hres))
494  return hres;
495 
496  if(!argc) {
497  if(r)
498  *r = jsval_number(-1);
499  jsstr_release(jsstr);
500  return S_OK;
501  }
502 
503  hres = to_flat_string(ctx, argv[0], &search_jsstr, &search_str);
504  if(FAILED(hres)) {
505  jsstr_release(jsstr);
506  return hres;
507  }
508 
509  search_len = jsstr_length(search_jsstr);
510  length = jsstr_length(jsstr);
511 
512  if(argc >= 2) {
513  double d;
514 
515  hres = to_integer(ctx, argv[1], &d);
516  if(SUCCEEDED(hres) && d > 0.0)
517  pos = is_int32(d) ? min(length, d) : length;
518  }
519 
520  if(SUCCEEDED(hres) && length >= search_len) {
521  const WCHAR *end = str+length-search_len;
522  const WCHAR *ptr;
523 
524  for(ptr = str+pos; ptr <= end; ptr++) {
525  if(!memcmp(ptr, search_str, search_len*sizeof(WCHAR))) {
526  ret = ptr-str;
527  break;
528  }
529  }
530  }
531 
532  jsstr_release(search_jsstr);
533  jsstr_release(jsstr);
534  if(FAILED(hres))
535  return hres;
536 
537  if(r)
538  *r = jsval_number(ret);
539  return S_OK;
540 }
static int argc
Definition: ServiceArgs.c:12
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **jsval, const WCHAR **val)
Definition: string.c:97
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
GLuint GLuint end
Definition: gl.h:1545
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int ret
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55
static BOOL is_int32(double d)
Definition: jscript.h:515
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ String_italics()

static HRESULT String_italics ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 542 of file string.c.

544 {
545  static const WCHAR italicstagW[] = {'I',0};
546  return do_attributeless_tag_format(ctx, jsthis, r, italicstagW);
547 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_lastIndexOf()

static HRESULT String_lastIndexOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 550 of file string.c.

552 {
553  unsigned pos = 0, search_len, length;
554  jsstr_t *search_jsstr, *jsstr;
555  const WCHAR *search_str, *str;
556  INT ret = -1;
557  HRESULT hres;
558 
559  TRACE("\n");
560 
561  hres = get_string_flat_val(ctx, jsthis, &jsstr, &str);
562  if(FAILED(hres))
563  return hres;
564 
565  if(!argc) {
566  if(r)
567  *r = jsval_number(-1);
568  jsstr_release(jsstr);
569  return S_OK;
570  }
571 
572  hres = to_flat_string(ctx, argv[0], &search_jsstr, &search_str);
573  if(FAILED(hres)) {
574  jsstr_release(jsstr);
575  return hres;
576  }
577 
578  search_len = jsstr_length(search_jsstr);
579  length = jsstr_length(jsstr);
580 
581  if(argc >= 2) {
582  double d;
583 
584  hres = to_integer(ctx, argv[1], &d);
585  if(SUCCEEDED(hres) && d > 0)
586  pos = is_int32(d) ? min(length, d) : length;
587  }else {
588  pos = length;
589  }
590 
591  if(SUCCEEDED(hres) && length >= search_len) {
592  const WCHAR *ptr;
593 
594  for(ptr = str+min(pos, length-search_len); ptr >= str; ptr--) {
595  if(!memcmp(ptr, search_str, search_len*sizeof(WCHAR))) {
596  ret = ptr-str;
597  break;
598  }
599  }
600  }
601 
602  jsstr_release(search_jsstr);
603  jsstr_release(jsstr);
604  if(FAILED(hres))
605  return hres;
606 
607  if(r)
608  *r = jsval_number(ret);
609  return S_OK;
610 }
static int argc
Definition: ServiceArgs.c:12
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **jsval, const WCHAR **val)
Definition: string.c:97
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int ret
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55
static BOOL is_int32(double d)
Definition: jscript.h:515
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ String_link()

static HRESULT String_link ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 612 of file string.c.

614 {
615  static const WCHAR fontW[] = {'A',0};
616  static const WCHAR colorW[] = {'H','R','E','F',0};
617 
618  return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
619 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR fontW[]
Definition: editor.c:78
static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, const WCHAR *tagname, const WCHAR *attrname)
Definition: string.c:197

◆ String_localeCompare()

static HRESULT String_localeCompare ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1519 of file string.c.

1521 {
1522  FIXME("\n");
1523  return E_NOTIMPL;
1524 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ String_match()

static HRESULT String_match ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 622 of file string.c.

624 {
625  jsdisp_t *regexp = NULL;
626  jsstr_t *str;
627  HRESULT hres;
628 
629  TRACE("\n");
630 
631  if(!argc) {
632  if(r)
633  *r = jsval_null();
634  return S_OK;
635  }
636 
637  if(is_object_instance(argv[0])) {
638  regexp = iface_to_jsdisp(get_object(argv[0]));
639  if(regexp && !is_class(regexp, JSCLASS_REGEXP)) {
640  jsdisp_release(regexp);
641  regexp = NULL;
642  }
643  }
644 
645  if(!regexp) {
646  jsstr_t *match_str;
647 
648  hres = to_string(ctx, argv[0], &match_str);
649  if(FAILED(hres))
650  return hres;
651 
652  hres = create_regexp(ctx, match_str, 0, &regexp);
653  jsstr_release(match_str);
654  if(FAILED(hres))
655  return hres;
656  }
657 
658  hres = get_string_val(ctx, jsthis, &str);
659  if(SUCCEEDED(hres))
660  hres = regexp_string_match(ctx, regexp, str, r);
661 
662  jsdisp_release(regexp);
664  return hres;
665 }
static int argc
Definition: ServiceArgs.c:12
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
static jsval_t jsval_null(void)
Definition: jsval.h:130
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
HRESULT create_regexp(script_ctx_t *, jsstr_t *, DWORD, jsdisp_t **) DECLSPEC_HIDDEN
Definition: jsregexp.c:644
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT regexp_string_match(script_ctx_t *, jsdisp_t *, jsstr_t *, jsval_t *) DECLSPEC_HIDDEN
Definition: jsregexp.c:727
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ String_replace()

static HRESULT String_replace ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 774 of file string.c.

776 {
777  const WCHAR *str, *match_str = NULL, *rep_str = NULL;
778  jsstr_t *rep_jsstr, *match_jsstr, *jsstr;
779  jsdisp_t *rep_func = NULL, *regexp = NULL;
780  match_state_t *match = NULL, last_match = {0};
781  strbuf_t ret = {NULL,0,0};
783  DWORD rep_len=0;
784  HRESULT hres = S_OK;
785 
786  TRACE("\n");
787 
788  hres = get_string_flat_val(ctx, jsthis, &jsstr, &str);
789  if(FAILED(hres))
790  return hres;
791 
792  if(!argc) {
793  if(r)
794  *r = jsval_string(jsstr);
795  else
796  jsstr_release(jsstr);
797  return S_OK;
798  }
799 
800  if(is_object_instance(argv[0])) {
801  regexp = iface_to_jsdisp(get_object(argv[0]));
802  if(regexp && !is_class(regexp, JSCLASS_REGEXP)) {
803  jsdisp_release(regexp);
804  regexp = NULL;
805  }
806  }
807 
808  if(!regexp) {
809  hres = to_flat_string(ctx, argv[0], &match_jsstr, &match_str);
810  if(FAILED(hres)) {
811  jsstr_release(jsstr);
812  return hres;
813  }
814  }
815 
816  if(argc >= 2) {
817  if(is_object_instance(argv[1])) {
818  rep_func = iface_to_jsdisp(get_object(argv[1]));
819  if(rep_func && !is_class(rep_func, JSCLASS_FUNCTION)) {
820  jsdisp_release(rep_func);
821  rep_func = NULL;
822  }
823  }
824 
825  if(!rep_func) {
826  hres = to_flat_string(ctx, argv[1], &rep_jsstr, &rep_str);
827  if(SUCCEEDED(hres))
828  rep_len = jsstr_length(rep_jsstr);
829  }
830  }
831 
832  if(SUCCEEDED(hres)) {
833  const WCHAR *ecp = str;
834 
835  while(1) {
836  if(regexp) {
837  hres = regexp_match_next(ctx, regexp, re_flags, jsstr, &match);
838  re_flags = (re_flags | REM_CHECK_GLOBAL) & (~REM_ALLOC_RESULT);
839 
840  if(hres == S_FALSE) {
841  hres = S_OK;
842  break;
843  }
844  if(FAILED(hres))
845  break;
846 
847  last_match.cp = match->cp;
848  last_match.match_len = match->match_len;
849  }else {
850  if(re_flags & REM_ALLOC_RESULT) {
851  re_flags &= ~REM_ALLOC_RESULT;
852  match = &last_match;
853  match->cp = str;
854  }
855 
856  match->cp = strstrW(match->cp, match_str);
857  if(!match->cp)
858  break;
859  match->match_len = jsstr_length(match_jsstr);
860  match->cp += match->match_len;
861  }
862 
863  hres = strbuf_append(&ret, ecp, match->cp-ecp-match->match_len);
864  ecp = match->cp;
865  if(FAILED(hres))
866  break;
867 
868  if(rep_func) {
869  jsstr_t *cstr;
870 
871  hres = rep_call(ctx, rep_func, jsstr, str, match, &cstr);
872  if(FAILED(hres))
873  break;
874 
875  hres = strbuf_append_jsstr(&ret, cstr);
876  jsstr_release(cstr);
877  if(FAILED(hres))
878  break;
879  }else if(rep_str && regexp) {
880  const WCHAR *ptr = rep_str, *ptr2;
881 
882  while((ptr2 = strchrW(ptr, '$'))) {
883  hres = strbuf_append(&ret, ptr, ptr2-ptr);
884  if(FAILED(hres))
885  break;
886 
887  switch(ptr2[1]) {
888  case '$':
889  hres = strbuf_append(&ret, ptr2, 1);
890  ptr = ptr2+2;
891  break;
892  case '&':
893  hres = strbuf_append(&ret, match->cp-match->match_len, match->match_len);
894  ptr = ptr2+2;
895  break;
896  case '`':
897  hres = strbuf_append(&ret, str, match->cp-str-match->match_len);
898  ptr = ptr2+2;
899  break;
900  case '\'':
901  hres = strbuf_append(&ret, ecp, (str+jsstr_length(jsstr))-ecp);
902  ptr = ptr2+2;
903  break;
904  default: {
905  DWORD idx;
906 
907  if(!isdigitW(ptr2[1])) {
908  hres = strbuf_append(&ret, ptr2, 1);
909  ptr = ptr2+1;
910  break;
911  }
912 
913  idx = ptr2[1] - '0';
914  if(isdigitW(ptr2[2]) && idx*10 + (ptr2[2]-'0') <= match->paren_count) {
915  idx = idx*10 + (ptr[2]-'0');
916  ptr = ptr2+3;
917  }else if(idx && idx <= match->paren_count) {
918  ptr = ptr2+2;
919  }else {
920  hres = strbuf_append(&ret, ptr2, 1);
921  ptr = ptr2+1;
922  break;
923  }
924 
925  if(match->parens[idx-1].index != -1)
926  hres = strbuf_append(&ret, str+match->parens[idx-1].index,
927  match->parens[idx-1].length);
928  }
929  }
930 
931  if(FAILED(hres))
932  break;
933  }
934 
935  if(SUCCEEDED(hres))
936  hres = strbuf_append(&ret, ptr, (rep_str+rep_len)-ptr);
937  if(FAILED(hres))
938  break;
939  }else if(rep_str) {
940  hres = strbuf_append(&ret, rep_str, rep_len);
941  if(FAILED(hres))
942  break;
943  }else {
944  static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d'};
945 
947  if(FAILED(hres))
948  break;
949  }
950 
951  if(!regexp)
952  break;
953  else if(!match->match_len)
954  match->cp++;
955  }
956 
957  if(SUCCEEDED(hres))
958  hres = strbuf_append(&ret, ecp, str+jsstr_length(jsstr)-ecp);
959  }
960 
961  if(rep_func)
962  jsdisp_release(rep_func);
963  if(rep_str)
964  jsstr_release(rep_jsstr);
965  if(match_str)
966  jsstr_release(match_jsstr);
967  if(regexp)
968  heap_free(match);
969 
970  if(SUCCEEDED(hres) && last_match.cp && regexp) {
972  ctx->last_match = jsstr_addref(jsstr);
973  ctx->last_match_index = last_match.cp-str-last_match.match_len;
974  ctx->last_match_length = last_match.match_len;
975  }
976 
977  if(regexp)
978  jsdisp_release(regexp);
979  jsstr_release(jsstr);
980 
981  if(SUCCEEDED(hres) && r) {
982  jsstr_t *ret_str;
983 
984  ret_str = jsstr_alloc_len(ret.buf, ret.len);
985  if(!ret_str)
986  return E_OUTOFMEMORY;
987 
988  TRACE("= %s\n", debugstr_jsstr(ret_str));
989  *r = jsval_string(ret_str);
990  }
991 
992  heap_free(ret.buf);
993  return hres;
994 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
static int argc
Definition: ServiceArgs.c:12
jsstr_t * last_match
Definition: jscript.h:431
#define REM_ALLOC_RESULT
Definition: jscript.h:485
Definition: jsstr.h:39
Definition: match.c:28
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **jsval, const WCHAR **val)
Definition: string.c:97
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const WCHAR undefinedW[]
Definition: engine.c:37
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
#define REM_NO_CTX_UPDATE
Definition: jscript.h:484
static PVOID ptr
Definition: dispmode.c:27
unsigned int idx
Definition: utils.c:41
#define S_FALSE
Definition: winerror.h:2357
static HRESULT strbuf_append(strbuf_t *buf, const WCHAR *str, DWORD len)
Definition: string.c:696
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT regexp_match_next(script_ctx_t *, jsdisp_t *, DWORD, jsstr_t *, struct match_state_t **) DECLSPEC_HIDDEN
Definition: jsregexp.c:125
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, jsstr_t *jsstr, const WCHAR *str, match_state_t *match, jsstr_t **ret)
Definition: string.c:719
#define REM_CHECK_GLOBAL
Definition: jscript.h:482
#define TRACE(s)
Definition: solgame.cpp:4
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
DWORD last_match_index
Definition: jscript.h:433
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static HRESULT strbuf_append_jsstr(strbuf_t *buf, jsstr_t *str)
Definition: string.c:709
WCHAR * strstrW(const WCHAR *str, const WCHAR *sub)
Definition: string.c:60
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
DWORD last_match_length
Definition: jscript.h:434
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ String_search()

static HRESULT String_search ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 996 of file string.c.

998 {
999  jsdisp_t *regexp = NULL;
1000  const WCHAR *str;
1001  jsstr_t *jsstr;
1002  match_state_t match, *match_ptr = &match;
1003  HRESULT hres;
1004 
1005  TRACE("\n");
1006 
1007  hres = get_string_flat_val(ctx, jsthis, &jsstr, &str);
1008  if(FAILED(hres))
1009  return hres;
1010 
1011  if(!argc) {
1012  if(r)
1013  *r = jsval_null();
1014  jsstr_release(jsstr);
1015  return S_OK;
1016  }
1017 
1018  if(is_object_instance(argv[0])) {
1019  regexp = iface_to_jsdisp(get_object(argv[0]));
1020  if(regexp && !is_class(regexp, JSCLASS_REGEXP)) {
1021  jsdisp_release(regexp);
1022  regexp = NULL;
1023  }
1024  }
1025 
1026  if(!regexp) {
1027  hres = create_regexp_var(ctx, argv[0], NULL, &regexp);
1028  if(FAILED(hres)) {
1029  jsstr_release(jsstr);
1030  return hres;
1031  }
1032  }
1033 
1034  match.cp = str;
1035  hres = regexp_match_next(ctx, regexp, REM_RESET_INDEX|REM_NO_PARENS, jsstr, &match_ptr);
1036  jsstr_release(jsstr);
1037  jsdisp_release(regexp);
1038  if(FAILED(hres))
1039  return hres;
1040 
1041  if(r)
1042  *r = jsval_number(hres == S_OK ? match.cp-match.match_len-str : -1);
1043  return S_OK;
1044 }
static int argc
Definition: ServiceArgs.c:12
Definition: jsstr.h:39
Definition: match.c:28
static jsval_t jsval_null(void)
Definition: jsval.h:130
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **jsval, const WCHAR **val)
Definition: string.c:97
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT regexp_match_next(script_ctx_t *, jsdisp_t *, DWORD, jsstr_t *, struct match_state_t **) DECLSPEC_HIDDEN
Definition: jsregexp.c:125
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
struct match match
Definition: match.c:33
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define REM_NO_PARENS
Definition: jscript.h:486
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define REM_RESET_INDEX
Definition: jscript.h:483
HRESULT create_regexp_var(script_ctx_t *, jsval_t, jsval_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: jsregexp.c:674
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ String_slice()

static HRESULT String_slice ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1047 of file string.c.

1049 {
1050  int start=0, end, length;
1051  jsstr_t *str;
1052  double d;
1053  HRESULT hres;
1054 
1055  TRACE("\n");
1056 
1057  hres = get_string_val(ctx, jsthis, &str);
1058  if(FAILED(hres))
1059  return hres;
1060 
1061  length = jsstr_length(str);
1062  if(argc) {
1063  hres = to_integer(ctx, argv[0], &d);
1064  if(FAILED(hres)) {
1065  jsstr_release(str);
1066  return hres;
1067  }
1068 
1069  if(is_int32(d)) {
1070  start = d;
1071  if(start < 0) {
1072  start = length + start;
1073  if(start < 0)
1074  start = 0;
1075  }else if(start > length) {
1076  start = length;
1077  }
1078  }else if(d > 0) {
1079  start = length;
1080  }
1081  }
1082 
1083  if(argc >= 2) {
1084  hres = to_integer(ctx, argv[1], &d);
1085  if(FAILED(hres)) {
1086  jsstr_release(str);
1087  return hres;
1088  }
1089 
1090  if(is_int32(d)) {
1091  end = d;
1092  if(end < 0) {
1093  end = length + end;
1094  if(end < 0)
1095  end = 0;
1096  }else if(end > length) {
1097  end = length;
1098  }
1099  }else {
1100  end = d < 0.0 ? 0 : length;
1101  }
1102  }else {
1103  end = length;
1104  }
1105 
1106  if(end < start)
1107  end = start;
1108 
1109  if(r) {
1110  jsstr_t *retstr = jsstr_substr(str, start, end-start);
1111  if(!retstr) {
1112  jsstr_release(str);
1113  return E_OUTOFMEMORY;
1114  }
1115 
1116  *r = jsval_string(retstr);
1117  }
1118 
1119  jsstr_release(str);
1120  return S_OK;
1121 }
static int argc
Definition: ServiceArgs.c:12
static jsstr_t * jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
Definition: jsstr.h:163
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
GLuint GLuint end
Definition: gl.h:1545
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define S_OK
Definition: intsafe.h:59
GLuint start
Definition: gl.h:1545
static BOOL is_int32(double d)
Definition: jscript.h:515

◆ String_small()

static HRESULT String_small ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1123 of file string.c.

1125 {
1126  static const WCHAR smalltagW[] = {'S','M','A','L','L',0};
1127  return do_attributeless_tag_format(ctx, jsthis, r, smalltagW);
1128 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_split()

static HRESULT String_split ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1130 of file string.c.

1132 {
1133  match_state_t match_result, *match_ptr = &match_result;
1134  DWORD length, i, match_len = 0;
1135  const WCHAR *ptr, *ptr2, *str, *match_str = NULL;
1136  unsigned limit = ~0u;
1137  jsdisp_t *array, *regexp = NULL;
1138  jsstr_t *jsstr, *match_jsstr, *tmp_str;
1139  HRESULT hres;
1140 
1141  TRACE("\n");
1142 
1143  hres = get_string_flat_val(ctx, jsthis, &jsstr, &str);
1144  if(FAILED(hres))
1145  return hres;
1146 
1147  length = jsstr_length(jsstr);
1148 
1149  if(!argc || (is_undefined(argv[0]) && ctx->version >= SCRIPTLANGUAGEVERSION_ES5)) {
1150  if(!r)
1151  return S_OK;
1152 
1153  hres = create_array(ctx, 0, &array);
1154  if(FAILED(hres))
1155  return hres;
1156 
1157  /* NOTE: according to spec, we should respect limit argument here (if provided).
1158  * We have a test showing that it's broken in native IE. */
1159  hres = jsdisp_propput_idx(array, 0, jsval_string(jsstr));
1160  if(FAILED(hres)) {
1162  return hres;
1163  }
1164 
1165  *r = jsval_obj(array);
1166  return S_OK;
1167  }
1168 
1169  if(argc > 1 && !is_undefined(argv[1])) {
1170  hres = to_uint32(ctx, argv[1], &limit);
1171  if(FAILED(hres)) {
1172  jsstr_release(jsstr);
1173  return hres;
1174  }
1175  }
1176 
1177  if(is_object_instance(argv[0])) {
1178  regexp = iface_to_jsdisp(get_object(argv[0]));
1179  if(regexp) {
1180  if(!is_class(regexp, JSCLASS_REGEXP)) {
1181  jsdisp_release(regexp);
1182  regexp = NULL;
1183  }
1184  }
1185  }
1186 
1187  if(!regexp) {
1188  hres = to_flat_string(ctx, argv[0], &match_jsstr, &match_str);
1189  if(FAILED(hres)) {
1190  jsstr_release(jsstr);
1191  return hres;
1192  }
1193 
1194  match_len = jsstr_length(match_jsstr);
1195  if(!match_len) {
1196  jsstr_release(match_jsstr);
1197  match_str = NULL;
1198  }
1199  }
1200 
1201  hres = create_array(ctx, 0, &array);
1202 
1203  if(SUCCEEDED(hres)) {
1204  ptr = str;
1205  match_result.cp = str;
1206  for(i=0; i<limit; i++) {
1207  if(regexp) {
1208  hres = regexp_match_next(ctx, regexp, REM_NO_PARENS, jsstr, &match_ptr);
1209  if(hres != S_OK)
1210  break;
1211  ptr2 = match_result.cp - match_result.match_len;
1212  }else if(match_str) {
1213  ptr2 = strstrW(ptr, match_str);
1214  if(!ptr2)
1215  break;
1216  }else {
1217  if(!*ptr)
1218  break;
1219  ptr2 = ptr+1;
1220  }
1221 
1222  tmp_str = jsstr_alloc_len(ptr, ptr2-ptr);
1223  if(!tmp_str) {
1224  hres = E_OUTOFMEMORY;
1225  break;
1226  }
1227 
1228  hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str));
1229  jsstr_release(tmp_str);
1230  if(FAILED(hres))
1231  break;
1232 
1233  if(regexp)
1234  ptr = match_result.cp;
1235  else if(match_str)
1236  ptr = ptr2 + match_len;
1237  else
1238  ptr++;
1239  }
1240  }
1241 
1242  if(SUCCEEDED(hres) && (match_str || regexp) && i<limit) {
1243  DWORD len = (str+length) - ptr;
1244 
1245  if(len || match_str) {
1246  tmp_str = jsstr_alloc_len(ptr, len);
1247 
1248  if(tmp_str) {
1249  hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str));
1250  jsstr_release(tmp_str);
1251  }else {
1252  hres = E_OUTOFMEMORY;
1253  }
1254  }
1255  }
1256 
1257  if(regexp)
1258  jsdisp_release(regexp);
1259  if(match_str)
1260  jsstr_release(match_jsstr);
1261  jsstr_release(jsstr);
1262 
1263  if(SUCCEEDED(hres) && r)
1264  *r = jsval_obj(array);
1265  else
1267 
1268  return hres;
1269 }
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 * u
Definition: glfuncs.h:240
HRESULT to_uint32(script_ctx_t *, jsval_t, UINT32 *) DECLSPEC_HIDDEN
Definition: jsutils.c:678
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
static int argc
Definition: ServiceArgs.c:12
Definition: jsstr.h:39
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **jsval, const WCHAR **val)
Definition: string.c:97
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
GLint limit
Definition: glext.h:10326
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT regexp_match_next(script_ctx_t *, jsdisp_t *, DWORD, jsstr_t *, struct match_state_t **) DECLSPEC_HIDDEN
Definition: jsregexp.c:125
DWORD version
Definition: jscript.h:415
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define REM_NO_PARENS
Definition: jscript.h:486
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SCRIPTLANGUAGEVERSION_ES5
Definition: jscript.h:49
GLenum GLsizei len
Definition: glext.h:6722
WCHAR * strstrW(const WCHAR *str, const WCHAR *sub)
Definition: string.c:60
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
const WCHAR * cp
Definition: regexp.h:47
DWORD match_len
Definition: regexp.h:48
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1310
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#define SUCCEEDED(hr)
Definition: intsafe.h:57
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320

◆ String_strike()

static HRESULT String_strike ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1271 of file string.c.

1273 {
1274  static const WCHAR striketagW[] = {'S','T','R','I','K','E',0};
1275  return do_attributeless_tag_format(ctx, jsthis, r, striketagW);
1276 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_sub()

static HRESULT String_sub ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1278 of file string.c.

1280 {
1281  static const WCHAR subtagW[] = {'S','U','B',0};
1282  return do_attributeless_tag_format(ctx, jsthis, r, subtagW);
1283 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ String_substr()

static HRESULT String_substr ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1345 of file string.c.

1347 {
1348  int start=0, len, length;
1349  jsstr_t *str;
1350  double d;
1351  HRESULT hres;
1352 
1353  TRACE("\n");
1354 
1355  hres = get_string_val(ctx, jsthis, &str);
1356  if(FAILED(hres))
1357  return hres;
1358 
1359  length = jsstr_length(str);
1360  if(argc >= 1) {
1361  hres = to_integer(ctx, argv[0], &d);
1362  if(FAILED(hres)) {
1363  jsstr_release(str);
1364  return hres;
1365  }
1366 
1367  if(d >= 0)
1368  start = is_int32(d) ? min(length, d) : length;
1369  }
1370 
1371  if(argc >= 2) {
1372  hres = to_integer(ctx, argv[1], &d);
1373  if(FAILED(hres)) {
1374  jsstr_release(str);
1375  return hres;
1376  }
1377 
1378  if(d >= 0.0)
1379  len = is_int32(d) ? min(length-start, d) : length-start;
1380  else
1381  len = 0;
1382  }else {
1383  len = length-start;
1384  }
1385 
1386  hres = S_OK;
1387  if(r) {
1389  if(ret)
1390  *r = jsval_string(ret);
1391  else
1392  hres = E_OUTOFMEMORY;
1393  }
1394 
1395  jsstr_release(str);
1396  return hres;
1397 }
static int argc
Definition: ServiceArgs.c:12
static jsstr_t * jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
Definition: jsstr.h:163
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static size_t len
Definition: string.c:60
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
GLuint start
Definition: gl.h:1545
#define min(a, b)
Definition: monoChain.cc:55
static BOOL is_int32(double d)
Definition: jscript.h:515

◆ String_substring()

static HRESULT String_substring ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1286 of file string.c.

1288 {
1289  INT start=0, end, length;
1290  jsstr_t *str;
1291  double d;
1292  HRESULT hres;
1293 
1294  TRACE("\n");
1295 
1296  hres = get_string_val(ctx, jsthis, &str);
1297  if(FAILED(hres))
1298  return hres;
1299 
1300  length = jsstr_length(str);
1301  if(argc >= 1) {
1302  hres = to_integer(ctx, argv[0], &d);
1303  if(FAILED(hres)) {
1304  jsstr_release(str);
1305  return hres;
1306  }
1307 
1308  if(d >= 0)
1309  start = is_int32(d) ? min(length, d) : length;
1310  }
1311 
1312  if(argc >= 2) {
1313  hres = to_integer(ctx, argv[1], &d);
1314  if(FAILED(hres)) {
1315  jsstr_release(str);
1316  return hres;
1317  }
1318 
1319  if(d >= 0)
1320  end = is_int32(d) ? min(length, d) : length;
1321  else
1322  end = 0;
1323  }else {
1324  end = length;
1325  }
1326 
1327  if(start > end) {
1328  INT tmp = start;
1329  start = end;
1330  end = tmp;
1331  }
1332 
1333  if(r) {
1335  if(ret)
1336  *r = jsval_string(ret);
1337  else
1338  hres = E_OUTOFMEMORY;
1339  }
1340  jsstr_release(str);
1341  return hres;
1342 }
static int argc
Definition: ServiceArgs.c:12
static jsstr_t * jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
Definition: jsstr.h:163
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
GLuint GLuint end
Definition: gl.h:1545
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int ret
GLuint start
Definition: gl.h:1545
#define min(a, b)
Definition: monoChain.cc:55
static BOOL is_int32(double d)
Definition: jscript.h:515

◆ String_sup()

static HRESULT String_sup ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1399 of file string.c.

1401 {
1402  static const WCHAR suptagW[] = {'S','U','P',0};
1403  return do_attributeless_tag_format(ctx, jsthis, r, suptagW);
1404 }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
Definition: string.c:155
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ string_this()

static StringInstance* string_this ( vdisp_t jsthis)
inlinestatic

Definition at line 80 of file string.c.

81 {
82  return is_vclass(jsthis, JSCLASS_STRING) ? string_from_vdisp(jsthis) : NULL;
83 }
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
Definition: jscript.h:502
static StringInstance * string_from_vdisp(vdisp_t *vdisp)
Definition: string.c:75

Referenced by get_string_val(), and stringobj_to_string().

◆ String_toLocaleLowerCase()

static HRESULT String_toLocaleLowerCase ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1470 of file string.c.

1472 {
1473  FIXME("\n");
1474  return E_NOTIMPL;
1475 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ String_toLocaleUpperCase()

static HRESULT String_toLocaleUpperCase ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1477 of file string.c.

1479 {
1480  FIXME("\n");
1481  return E_NOTIMPL;
1482 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ String_toLowerCase()

static HRESULT String_toLowerCase ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1406 of file string.c.

1408 {
1409  jsstr_t *str;
1410  HRESULT hres;
1411 
1412  TRACE("\n");
1413 
1414  hres = get_string_val(ctx, jsthis, &str);
1415  if(FAILED(hres))
1416  return hres;
1417 
1418  if(r) {
1419  unsigned len = jsstr_length(str);
1420  jsstr_t *ret;
1421  WCHAR *buf;
1422 
1423  ret = jsstr_alloc_buf(len, &buf);
1424  if(!ret) {
1425  jsstr_release(str);
1426  return E_OUTOFMEMORY;
1427  }
1428 
1429  jsstr_flush(str, buf);
1430  for (; len--; buf++) *buf = tolowerW(*buf);
1431 
1432  *r = jsval_string(ret);
1433  }
1434  jsstr_release(str);
1435  return S_OK;
1436 }
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69

◆ String_toString()

static HRESULT String_toString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 138 of file string.c.

140 {
141  TRACE("\n");
142 
143  return stringobj_to_string(jsthis, r);
144 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT stringobj_to_string(vdisp_t *jsthis, jsval_t *r)
Definition: string.c:123

◆ String_toUpperCase()

static HRESULT String_toUpperCase ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1438 of file string.c.

1440 {
1441  jsstr_t *str;
1442  HRESULT hres;
1443 
1444  TRACE("\n");
1445 
1446  hres = get_string_val(ctx, jsthis, &str);
1447  if(FAILED(hres))
1448  return hres;
1449 
1450  if(r) {
1451  unsigned len = jsstr_length(str);
1452  jsstr_t *ret;
1453  WCHAR *buf;
1454 
1455  ret = jsstr_alloc_buf(len, &buf);
1456  if(!ret) {
1457  jsstr_release(str);
1458  return E_OUTOFMEMORY;
1459  }
1460 
1461  jsstr_flush(str, buf);
1462  for (; len--; buf++) *buf = toupperW(*buf);
1463 
1464  *r = jsval_string(ret);
1465  }
1466  jsstr_release(str);
1467  return S_OK;
1468 }
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t **val)
Definition: string.c:85
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
WINE_UNICODE_INLINE WCHAR toupperW(WCHAR ch)
Definition: unicode.h:141
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69

◆ String_trim()

static HRESULT String_trim ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1484 of file string.c.

1486 {
1487  const WCHAR *str, *begin, *end;
1488  jsstr_t *jsstr;
1489  unsigned len;
1490  HRESULT hres;
1491 
1492  hres = to_flat_string(ctx, jsval_disp(jsthis->u.disp), &jsstr, &str);
1493  if(FAILED(hres)) {
1494  WARN("to_flat_string failed: %08x\n", hres);
1495  return hres;
1496  }
1497  len = jsstr_length(jsstr);
1498  TRACE("%s\n", debugstr_wn(str, len));
1499 
1500  for(begin = str, end = str + len; begin < end && isspaceW(*begin); begin++);
1501  while(end > begin + 1 && isspaceW(*(end-1))) end--;
1502 
1503  if(r) {
1504  jsstr_t *ret;
1505 
1506  if(begin == str && end == str + len)
1507  ret = jsstr_addref(jsstr);
1508  else
1510  if(ret)
1511  *r = jsval_string(ret);
1512  else
1513  hres = E_OUTOFMEMORY;
1514  }
1515  jsstr_release(jsstr);
1516  return hres;
1517 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
Definition: jsstr.h:39
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
#define WARN(fmt,...)
Definition: debug.h:111
union vdisp_t::@418 u
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
GLuint GLuint end
Definition: gl.h:1545
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
static clock_t begin
Definition: xmllint.c:466
#define TRACE(s)
Definition: solgame.cpp:4
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
IDispatch * disp
Definition: jscript.h:138
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static size_t len
Definition: string.c:60
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_wn
Definition: kernel32.h:33
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790

◆ String_valueOf()

static HRESULT String_valueOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 147 of file string.c.

149 {
150  TRACE("\n");
151 
152  return stringobj_to_string(jsthis, r);
153 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT stringobj_to_string(vdisp_t *jsthis, jsval_t *r)
Definition: string.c:123

◆ StringConstr_fromCharCode()

static HRESULT StringConstr_fromCharCode ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1635 of file string.c.

1637 {
1638  WCHAR *ret_str;
1639  DWORD i, code;
1640  jsstr_t *ret;
1641  HRESULT hres;
1642 
1643  TRACE("\n");
1644 
1645  ret = jsstr_alloc_buf(argc, &ret_str);
1646  if(!ret)
1647  return E_OUTOFMEMORY;
1648 
1649  for(i=0; i<argc; i++) {
1650  hres = to_uint32(ctx, argv[i], &code);
1651  if(FAILED(hres)) {
1652  jsstr_release(ret);
1653  return hres;
1654  }
1655 
1656  ret_str[i] = code;
1657  }
1658 
1659  if(r)
1660  *r = jsval_string(ret);
1661  else
1662  jsstr_release(ret);
1663  return S_OK;
1664 }
HRESULT to_uint32(script_ctx_t *, jsval_t, UINT32 *) DECLSPEC_HIDDEN
Definition: jsutils.c:678
static int argc
Definition: ServiceArgs.c:12
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
int code
Definition: i386-dis.c:3591
#define S_OK
Definition: intsafe.h:59
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69

◆ StringConstr_value()

static HRESULT StringConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1666 of file string.c.

1668 {
1669  HRESULT hres;
1670 
1671  TRACE("\n");
1672 
1673  switch(flags) {
1674  case INVOKE_FUNC: {
1675  jsstr_t *str;
1676 
1677  if(argc) {
1678  hres = to_string(ctx, argv[0], &str);
1679  if(FAILED(hres))
1680  return hres;
1681  }else {
1682  str = jsstr_empty();
1683  }
1684 
1685  *r = jsval_string(str);
1686  break;
1687  }
1688  case DISPATCH_CONSTRUCT: {
1689  jsstr_t *str;
1690  jsdisp_t *ret;
1691 
1692  if(argc) {
1693  hres = to_string(ctx, argv[0], &str);
1694  if(FAILED(hres))
1695  return hres;
1696  }else {
1697  str = jsstr_empty();
1698  }
1699 
1700  hres = create_string(ctx, str, &ret);
1701  if (SUCCEEDED(hres)) *r = jsval_obj(ret);
1702  jsstr_release(str);
1703  return hres;
1704  }
1705 
1706  default:
1707  FIXME("unimplemented flags: %x\n", flags);
1708  return E_NOTIMPL;
1709  }
1710 
1711  return S_OK;
1712 }
static int argc
Definition: ServiceArgs.c:12
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define FIXME(fmt,...)
Definition: debug.h:110
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
HRESULT create_string(script_ctx_t *ctx, jsstr_t *str, jsdisp_t **ret)
Definition: string.c:1768
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
int ret
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by create_string_constr().

◆ stringobj_to_string()

static HRESULT stringobj_to_string ( vdisp_t jsthis,
jsval_t r 
)
static

Definition at line 123 of file string.c.

124 {
126 
127  if(!(string = string_this(jsthis))) {
128  WARN("this is not a string object\n");
129  return E_FAIL;
130  }
131 
132  if(r)
133  *r = jsval_string(jsstr_addref(string->str));
134  return S_OK;
135 }
const char * string
Definition: string.c:1522
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define S_OK
Definition: intsafe.h:59
static StringInstance * string_this(vdisp_t *jsthis)
Definition: string.c:80

Referenced by String_toString(), and String_valueOf().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ anchorW

const WCHAR anchorW[] = {'a','n','c','h','o','r',0}
static

Definition at line 37 of file string.c.

◆ bigW

const WCHAR bigW[] = {'b','i','g',0}
static

Definition at line 38 of file string.c.

Referenced by test_multiple_reads().

◆ blinkW

const WCHAR blinkW[] = {'b','l','i','n','k',0}
static

Definition at line 39 of file string.c.

◆ boldW

const WCHAR boldW[] = {'b','o','l','d',0}
static

Definition at line 40 of file string.c.

Referenced by test_font_events_disp().

◆ charAtW

const WCHAR charAtW[] = {'c','h','a','r','A','t',0}
static

Definition at line 41 of file string.c.

◆ charCodeAtW

const WCHAR charCodeAtW[] = {'c','h','a','r','C','o','d','e','A','t',0}
static

Definition at line 42 of file string.c.

◆ concatW

const WCHAR concatW[] = {'c','o','n','c','a','t',0}
static

Definition at line 43 of file string.c.

◆ fixedW

const WCHAR fixedW[] = {'f','i','x','e','d',0}
static

Definition at line 44 of file string.c.

◆ fontcolorW

const WCHAR fontcolorW[] = {'f','o','n','t','c','o','l','o','r',0}
static

Definition at line 45 of file string.c.

◆ fontsizeW

const WCHAR fontsizeW[] = {'f','o','n','t','s','i','z','e',0}
static

Definition at line 46 of file string.c.

◆ fromCharCodeW

const WCHAR fromCharCodeW[] = {'f','r','o','m','C','h','a','r','C','o','d','e',0}
static

Definition at line 68 of file string.c.

◆ indexOfW

const WCHAR indexOfW[] = {'i','n','d','e','x','O','f',0}
static

Definition at line 47 of file string.c.

◆ italicsW

const WCHAR italicsW[] = {'i','t','a','l','i','c','s',0}
static

Definition at line 48 of file string.c.

◆ lastIndexOfW

const WCHAR lastIndexOfW[] = {'l','a','s','t','I','n','d','e','x','O','f',0}
static

Definition at line 49 of file string.c.

◆ lengthW

const WCHAR lengthW[] = {'l','e','n','g','t','h',0}
static

Definition at line 34 of file string.c.

◆ linkW

const WCHAR linkW[] = {'l','i','n','k',0}
static

Definition at line 50 of file string.c.

Referenced by create_syslink(), test_propertystore(), and test_symlinks().

◆ localeCompareW

const WCHAR localeCompareW[] = {'l','o','c','a','l','e','C','o','m','p','a','r','e',0}
static

Definition at line 67 of file string.c.

◆ matchW

const WCHAR matchW[] = {'m','a','t','c','h',0}
static

Definition at line 51 of file string.c.

◆ replaceW

const WCHAR replaceW[] = {'r','e','p','l','a','c','e',0}
static

Definition at line 52 of file string.c.

◆ searchW

const WCHAR searchW[] = {'s','e','a','r','c','h',0}
static

Definition at line 53 of file string.c.

◆ sliceW

const WCHAR sliceW[] = {'s','l','i','c','e',0}
static

Definition at line 54 of file string.c.

◆ smallW

const WCHAR smallW[] = {'s','m','a','l','l',0}
static

Definition at line 55 of file string.c.

◆ splitW

const WCHAR splitW[] = {'s','p','l','i','t',0}
static

Definition at line 56 of file string.c.

◆ strikeW

const WCHAR strikeW[] = {'s','t','r','i','k','e',0}
static

Definition at line 57 of file string.c.

Referenced by test_font_events_disp().

◆ String_info

const builtin_info_t String_info
static
Initial value:
= {
}
static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: string.c:1526
smooth NULL
Definition: ftsmooth.c:416
static void String_destructor(jsdisp_t *dispex)
Definition: string.c:1536
#define ARRAY_SIZE(a)
Definition: main.h:24
static const builtin_prop_t String_props[]
Definition: string.c:1573

Definition at line 1610 of file string.c.

Referenced by string_alloc().

◆ String_props

const builtin_prop_t String_props[]
static

Definition at line 1573 of file string.c.

◆ StringConstr_info

const builtin_info_t StringConstr_info
static
Initial value:
= {
}
static const builtin_prop_t StringConstr_props[]
Definition: string.c:1737
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_FUNCTION_VALUE
Definition: jscript.h:310
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 1741 of file string.c.

Referenced by create_string_constr().

◆ StringConstr_props

const builtin_prop_t StringConstr_props[]
static
Initial value:
= {
}
static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: string.c:1635
static const WCHAR fromCharCodeW[]
Definition: string.c:68
#define PROPF_METHOD
Definition: jscript.h:94

Definition at line 1737 of file string.c.

◆ StringInst_info

const builtin_info_t StringInst_info
static
Initial value:
= {
}
static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: string.c:1526
smooth NULL
Definition: ftsmooth.c:416
static void String_destructor(jsdisp_t *dispex)
Definition: string.c:1536
#define ARRAY_SIZE(a)
Definition: main.h:24
static const builtin_prop_t StringInst_props[]
Definition: string.c:1619
static unsigned String_idx_length(jsdisp_t *jsdisp)
Definition: string.c:1544
static HRESULT String_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
Definition: string.c:1558

Definition at line 1623 of file string.c.

Referenced by string_alloc().

◆ StringInst_props

const builtin_prop_t StringInst_props[]
static
Initial value:
= {
}
smooth NULL
Definition: ftsmooth.c:416
static HRESULT String_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: string.c:113
static const WCHAR lengthW[]
Definition: string.c:34

Definition at line 1619 of file string.c.

◆ substringW

const WCHAR substringW[] = {'s','u','b','s','t','r','i','n','g',0}
static

Definition at line 59 of file string.c.

◆ substrW

const WCHAR substrW[] = {'s','u','b','s','t','r',0}
static

Definition at line 60 of file string.c.

Referenced by delete_component_path().

◆ subW

const WCHAR subW[] = {'s','u','b',0}
static

Definition at line 58 of file string.c.

◆ supW

const WCHAR supW[] = {'s','u','p',0}
static

Definition at line 61 of file string.c.

◆ toLocaleLowerCaseW

const WCHAR toLocaleLowerCaseW[] = {'t','o','L','o','c','a','l','e','L','o','w','e','r','C','a','s','e',0}
static

Definition at line 64 of file string.c.

◆ toLocaleUpperCaseW

const WCHAR toLocaleUpperCaseW[] = {'t','o','L','o','c','a','l','e','U','p','p','e','r','C','a','s','e',0}
static

Definition at line 65 of file string.c.

◆ toLowerCaseW

const WCHAR toLowerCaseW[] = {'t','o','L','o','w','e','r','C','a','s','e',0}
static

Definition at line 62 of file string.c.

◆ toStringW

const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}
static

Definition at line 35 of file string.c.

◆ toUpperCaseW

const WCHAR toUpperCaseW[] = {'t','o','U','p','p','e','r','C','a','s','e',0}
static

Definition at line 63 of file string.c.

◆ trimW

const WCHAR trimW[] = {'t','r','i','m',0}
static

Definition at line 66 of file string.c.

◆ valueOfW

const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',0}
static

Definition at line 36 of file string.c.