JavaScript:SpiderMonkey:RegExp API: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
m (Adding some junk that already exists. And some constness questions/changes)
m (the already-defined routines don't offer "flat" param, so ditch it)
Line 8: Line 8:


==Routines==
==Routines==
<dt>JSObject * JS_NewRegExpObjectFromString(JSContext *cx, <i>const?</i> JSString *str, uintN flags, JSBool flat)</dt>
<dt>JSObject * JS_NewRegExpObjectFromString(JSContext *cx, <i>const?</i> JSString *str, uintN flags)</dt>
<dd>Used to build a JSObject which holds a precompiled regular expression to be used in future routines.<br><i>I also am not entirely clear on what "flat" does, can someone explain it to me? --[[User:Crowder|Crowder]] 09:15, 31 August 2006 (PDT)</i></dd>
<dd>Used to build a JSObject which holds a precompiled regular expression to be used in future routines.<br><i>I also am not entirely clear on what "flat" does, can someone explain it to me? --[[User:Crowder|Crowder]] 09:15, 31 August 2006 (PDT)</i></dd>



Revision as of 23:11, 29 September 2006

JavaScript Regular Expression API

The purpose of this addition to the JS API is to make ECMA-262 compliant regular expression APIs available to C/C++ users. As with other JS API routines, clients are required to provide a properly initialized execution context (JSContext), and the API has the potential to throw JS exceptions, just as a script might.

Structures

JSObject
Used to track a JSRegExp, the structure of which we do not expose publically.

Routines

JSObject * JS_NewRegExpObjectFromString(JSContext *cx, const? JSString *str, uintN flags)
Used to build a JSObject which holds a precompiled regular expression to be used in future routines.
I also am not entirely clear on what "flat" does, can someone explain it to me? --Crowder 09:15, 31 August 2006 (PDT)
JSObject * JS_CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *parent)
Do we need this?
void JS_DestroyRegExpObject(JSContext *cx, JSObject *obj)
Used to destroy the object built with JS_NewRegExpObject.
JSBool JS_ExecuteRegExp(JSContext *cx, JSObject *re, const? JSString *input, JSBool test, jsval *rval)
Executes the expression compiled into re against input. test is a flag which dictates whether or not we're actually interested in results beyond whether the expression matches or not (ie., for parenthesized parts of the expression, $1, $2, and so on). The results returned in rval are with JSVAL_NULL, JS_TRUE (if we're only testing), or a JSArray object containing the discovered result strings. If rval is an array, the 0-index value contains the results of any substitutions that occurred.
JSObject * JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags)
Already exists.
Wonder why bytes is not const? --Crowder 09:15, 31 August 2006 (PDT)
JSObject * JS_NewUCRegExpObject(JSContext *cx, jschar *chars, size_t length, uintN flags)
Already exists.
void JS_SetRegExpInput(JSContext *cx, JSString *input, JSBool multiline)
Already exists.
void JS_ClearRegExpStatics(JSContext *cx)
Already exists.
void JS_ClearRegExpRoots(JSContext *cx)
Already exists.