ReactOS  0.4.14-dev-293-g2b39b42
regexp.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #pragma once
20 
21 /*
22  * Code in this file is based on files:
23  * js/src/jsregexp.h
24  * js/src/jsregexp.c
25  * from Mozilla project, released under LGPL 2.1 or later.
26  *
27  * The Original Code is Mozilla Communicator client code, released
28  * March 31, 1998.
29  *
30  * The Initial Developer of the Original Code is
31  * Netscape Communications Corporation.
32  * Portions created by the Initial Developer are Copyright (C) 1998
33  * the Initial Developer. All Rights Reserved.
34  */
35 
36 #define REG_FOLD 0x01 /* fold uppercase to lowercase */
37 #define REG_GLOB 0x02 /* global exec, creates array of matches */
38 #define REG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */
39 #define REG_STICKY 0x08 /* only match starting at lastIndex */
40 
41 typedef struct RECapture {
42  ptrdiff_t index; /* start of contents, -1 for empty */
43  size_t length; /* length of capture */
44 } RECapture;
45 
46 typedef struct match_state_t {
47  const WCHAR *cp;
49 
53 
54 typedef BYTE jsbytecode;
55 
56 typedef struct regexp_t {
57  WORD flags; /* flags, see jsapi.h's REG_* defines */
58  size_t parenCount; /* number of parenthesized submatches */
59  size_t classCount; /* count [...] bitmaps */
60  struct RECharSet *classList; /* list of [...] bitmaps */
61  const WCHAR *source; /* locked source string, sans // */
63  jsbytecode program[1]; /* regular expression bytecode */
64 } regexp_t;
65 
70 
71 static inline match_state_t* alloc_match_state(regexp_t *regexp,
72  heap_pool_t *pool, const WCHAR *pos)
73 {
74  size_t size = offsetof(match_state_t, parens) + regexp->parenCount*sizeof(RECapture);
76 
78  if(!ret)
79  return NULL;
80 
81  ret->cp = pos;
82  return ret;
83 }
struct RECapture RECapture
BYTE jsbytecode
Definition: regexp.h:54
static match_state_t * alloc_match_state(regexp_t *regexp, heap_pool_t *pool, const WCHAR *pos)
Definition: regexp.h:71
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:77
void regexp_destroy(regexp_t *) DECLSPEC_HIDDEN
Definition: regexp.c:3181
WORD flags
Definition: regexp.h:57
DWORD source_len
Definition: regexp.h:62
size_t length
Definition: regexp.h:43
HRESULT regexp_execute(regexp_t *, void *, heap_pool_t *, const WCHAR *, DWORD, match_state_t *) DECLSPEC_HIDDEN
Definition: regexp.c:3140
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
size_t parenCount
Definition: regexp.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
struct regexp_t regexp_t
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
const WCHAR * source
Definition: regexp.h:61
unsigned char BYTE
Definition: mem.h:68
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
const WCHAR * cp
Definition: regexp.h:47
GLuint program
Definition: glext.h:6723
DWORD match_len
Definition: regexp.h:48
DWORD paren_count
Definition: regexp.h:50
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
regexp_t * regexp_new(void *, heap_pool_t *, const WCHAR *, DWORD, WORD, BOOL) DECLSPEC_HIDDEN
Definition: regexp.c:3195
ptrdiff_t index
Definition: regexp.h:42
size_t classCount
Definition: regexp.h:59
struct match_state_t match_state_t
RECapture parens[1]
Definition: regexp.h:51
struct RECharSet * classList
Definition: regexp.h:60