jscript: Rename JSREG_* defines to REG_*.
[wine.git] / dlls / jscript / regexp.h
bloba882878411d69396390da650f2b76df4f6173e82
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Code in this file is based on files:
21 * js/src/jsregexp.h
22 * js/src/jsregexp.c
23 * from Mozilla project, released under LGPL 2.1 or later.
25 * The Original Code is Mozilla Communicator client code, released
26 * March 31, 1998.
28 * The Initial Developer of the Original Code is
29 * Netscape Communications Corporation.
30 * Portions created by the Initial Developer are Copyright (C) 1998
31 * the Initial Developer. All Rights Reserved.
34 #define REG_FOLD 0x01 /* fold uppercase to lowercase */
35 #define REG_GLOB 0x02 /* global exec, creates array of matches */
36 #define REG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */
37 #define REG_STICKY 0x08 /* only match starting at lastIndex */
39 typedef struct RECapture {
40 ptrdiff_t index; /* start of contents, -1 for empty */
41 size_t length; /* length of capture */
42 } RECapture;
44 typedef struct REMatchState {
45 const WCHAR *cp;
46 RECapture parens[1]; /* first of 're->parenCount' captures,
47 allocated at end of this struct */
48 } REMatchState;
51 typedef BYTE JSPackedBool;
52 typedef BYTE jsbytecode;
55 * This struct holds a bitmap representation of a class from a regexp.
56 * There's a list of these referenced by the classList field in the JSRegExp
57 * struct below. The initial state has startIndex set to the offset in the
58 * original regexp source of the beginning of the class contents. The first
59 * use of the class converts the source representation into a bitmap.
62 typedef struct RECharSet {
63 JSPackedBool converted;
64 JSPackedBool sense;
65 WORD length;
66 union {
67 BYTE *bits;
68 struct {
69 size_t startIndex;
70 size_t length;
71 } src;
72 } u;
73 } RECharSet;
75 typedef struct JSRegExp {
76 WORD flags; /* flags, see jsapi.h's REG_* defines */
77 size_t parenCount; /* number of parenthesized submatches */
78 size_t classCount; /* count [...] bitmaps */
79 RECharSet *classList; /* list of [...] bitmaps */
80 const WCHAR *source; /* locked source string, sans // */
81 DWORD source_len;
82 jsbytecode program[1]; /* regular expression bytecode */
83 } JSRegExp;
85 JSRegExp* js_NewRegExp(void *cx, heap_pool_t *pool, const WCHAR *str,
86 DWORD str_len, UINT flags, BOOL flat) DECLSPEC_HIDDEN;
87 void js_DestroyRegExp(JSRegExp *re) DECLSPEC_HIDDEN;
88 HRESULT MatchRegExpNext(JSRegExp *jsregexp, const WCHAR *str,
89 DWORD str_len, const WCHAR **cp, heap_pool_t *pool,
90 REMatchState **result, DWORD *matchlen) DECLSPEC_HIDDEN;