Commit ef6aa241 authored by feng@chromium.org's avatar feng@chromium.org

Add v8::jscre namespace around jscre functions to avoid link errors with jsc pcre files in Chrome.

Review URL: http://codereview.chromium.org/12496

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@849 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d7e5f97b
...@@ -378,23 +378,23 @@ static inline Object* DoCompile(String* pattern, ...@@ -378,23 +378,23 @@ static inline Object* DoCompile(String* pattern,
JSRegExp::Flags flags, JSRegExp::Flags flags,
unsigned* number_of_captures, unsigned* number_of_captures,
const char** error_message, const char** error_message,
JscreRegExp** code) { v8::jscre::JscreRegExp** code) {
JSRegExpIgnoreCaseOption case_option = flags.is_ignore_case() v8::jscre::JSRegExpIgnoreCaseOption case_option = flags.is_ignore_case()
? JSRegExpIgnoreCase ? v8::jscre::JSRegExpIgnoreCase
: JSRegExpDoNotIgnoreCase; : v8::jscre::JSRegExpDoNotIgnoreCase;
JSRegExpMultilineOption multiline_option = flags.is_multiline() v8::jscre::JSRegExpMultilineOption multiline_option = flags.is_multiline()
? JSRegExpMultiline ? v8::jscre::JSRegExpMultiline
: JSRegExpSingleLine; : v8::jscre::JSRegExpSingleLine;
*error_message = NULL; *error_message = NULL;
malloc_failure = Failure::Exception(); malloc_failure = Failure::Exception();
*code = jsRegExpCompile(pattern->GetTwoByteData(), *code = v8::jscre::jsRegExpCompile(pattern->GetTwoByteData(),
pattern->length(), pattern->length(),
case_option, case_option,
multiline_option, multiline_option,
number_of_captures, number_of_captures,
error_message, error_message,
&JSREMalloc, &JSREMalloc,
&JSREFree); &JSREFree);
if (*code == NULL && (malloc_failure->IsRetryAfterGC() || if (*code == NULL && (malloc_failure->IsRetryAfterGC() ||
malloc_failure->IsOutOfMemoryFailure())) { malloc_failure->IsOutOfMemoryFailure())) {
return malloc_failure; return malloc_failure;
...@@ -411,7 +411,7 @@ void CompileWithRetryAfterGC(Handle<String> pattern, ...@@ -411,7 +411,7 @@ void CompileWithRetryAfterGC(Handle<String> pattern,
JSRegExp::Flags flags, JSRegExp::Flags flags,
unsigned* number_of_captures, unsigned* number_of_captures,
const char** error_message, const char** error_message,
JscreRegExp** code) { v8::jscre::JscreRegExp** code) {
CALL_HEAP_FUNCTION_VOID(DoCompile(*pattern, CALL_HEAP_FUNCTION_VOID(DoCompile(*pattern,
flags, flags,
number_of_captures, number_of_captures,
...@@ -432,7 +432,7 @@ Handle<Object> RegExpImpl::JscreCompile(Handle<JSRegExp> re) { ...@@ -432,7 +432,7 @@ Handle<Object> RegExpImpl::JscreCompile(Handle<JSRegExp> re) {
unsigned number_of_captures; unsigned number_of_captures;
const char* error_message = NULL; const char* error_message = NULL;
JscreRegExp* code = NULL; v8::jscre::JscreRegExp* code = NULL;
FlattenString(pattern); FlattenString(pattern);
CompileWithRetryAfterGC(two_byte_pattern, CompileWithRetryAfterGC(two_byte_pattern,
...@@ -560,23 +560,24 @@ Handle<Object> RegExpImpl::JscreExecOnce(Handle<JSRegExp> regexp, ...@@ -560,23 +560,24 @@ Handle<Object> RegExpImpl::JscreExecOnce(Handle<JSRegExp> regexp,
{ {
AssertNoAllocation a; AssertNoAllocation a;
ByteArray* internal = JscreInternal(regexp); ByteArray* internal = JscreInternal(regexp);
const JscreRegExp* js_regexp = const v8::jscre::JscreRegExp* js_regexp =
reinterpret_cast<JscreRegExp*>(internal->GetDataStartAddress()); reinterpret_cast<v8::jscre::JscreRegExp*>(
internal->GetDataStartAddress());
LOG(RegExpExecEvent(regexp, previous_index, subject)); LOG(RegExpExecEvent(regexp, previous_index, subject));
rc = jsRegExpExecute(js_regexp, rc = v8::jscre::jsRegExpExecute(js_regexp,
two_byte_subject, two_byte_subject,
subject->length(), subject->length(),
previous_index, previous_index,
offsets_vector, offsets_vector,
offsets_vector_length); offsets_vector_length);
} }
// The KJS JavaScript engine returns null (ie, a failed match) when // The KJS JavaScript engine returns null (ie, a failed match) when
// JSRE's internal match limit is exceeded. We duplicate that behavior here. // JSRE's internal match limit is exceeded. We duplicate that behavior here.
if (rc == JSRegExpErrorNoMatch if (rc == v8::jscre::JSRegExpErrorNoMatch
|| rc == JSRegExpErrorHitLimit) { || rc == v8::jscre::JSRegExpErrorHitLimit) {
return Factory::null_value(); return Factory::null_value();
} }
......
...@@ -49,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -49,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE.
// we allow DEBUG to be set and undef it manually. // we allow DEBUG to be set and undef it manually.
#undef DEBUG #undef DEBUG
namespace v8 { namespace jscre {
typedef uint16_t UChar; typedef uint16_t UChar;
struct JSRegExp; struct JSRegExp;
...@@ -77,4 +79,6 @@ int jsRegExpExecute(const JSRegExp*, ...@@ -77,4 +79,6 @@ int jsRegExpExecute(const JSRegExp*,
void jsRegExpFree(JSRegExp*); void jsRegExpFree(JSRegExp*);
} } // namespace v8::jscre
#endif #endif
...@@ -65,6 +65,8 @@ compile time. */ ...@@ -65,6 +65,8 @@ compile time. */
#define BRASTACK_SIZE 200 #define BRASTACK_SIZE 200
namespace v8 { namespace jscre {
/* Table for handling escaped characters in the range '0'-'z'. Positive returns /* Table for handling escaped characters in the range '0'-'z'. Positive returns
are simple data values; negative values are for special things like \d and so are simple data values; negative values are for special things like \d and so
on. Zero means further processing is needed (for things like \x), or the escape on. Zero means further processing is needed (for things like \x), or the escape
...@@ -2671,3 +2673,5 @@ void jsRegExpFree(JSRegExp* re, free_t* free_function) ...@@ -2671,3 +2673,5 @@ void jsRegExpFree(JSRegExp* re, free_t* free_function)
{ {
(*free_function)(reinterpret_cast<void*>(re)); (*free_function)(reinterpret_cast<void*>(re));
} }
} } // namespace v8::jscre
...@@ -61,6 +61,8 @@ the JavaScript specification. There are also some supporting functions. */ ...@@ -61,6 +61,8 @@ the JavaScript specification. There are also some supporting functions. */
#undef min #undef min
#undef max #undef max
namespace v8 { namespace jscre {
#ifndef USE_COMPUTED_GOTO_FOR_MATCH_RECURSION #ifndef USE_COMPUTED_GOTO_FOR_MATCH_RECURSION
typedef int ReturnLocation; typedef int ReturnLocation;
#else #else
...@@ -2079,3 +2081,5 @@ int jsRegExpExecute(const JSRegExp* re, ...@@ -2079,3 +2081,5 @@ int jsRegExpExecute(const JSRegExp* re,
DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n")); DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));
return JSRegExpErrorNoMatch; return JSRegExpErrorNoMatch;
} }
} } // namespace v8::jscre
...@@ -103,6 +103,8 @@ all, it had only been about 10 years then... */ ...@@ -103,6 +103,8 @@ all, it had only been about 10 years then... */
#define DPRINTF(p) /*nothing*/ #define DPRINTF(p) /*nothing*/
#endif #endif
namespace v8 { namespace jscre {
/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored /* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
in big-endian order) by default. These are used, for example, to link from the in big-endian order) by default. These are used, for example, to link from the
start of a subpattern to its alternatives and its end. The use of 2 bytes per start of a subpattern to its alternatives and its end. The use of 2 bytes per
...@@ -416,6 +418,7 @@ but are not part of the public API and so not exported from the library. */ ...@@ -416,6 +418,7 @@ but are not part of the public API and so not exported from the library. */
extern int kjs_pcre_ucp_othercase(unsigned); extern int kjs_pcre_ucp_othercase(unsigned);
extern bool kjs_pcre_xclass(int, const unsigned char*); extern bool kjs_pcre_xclass(int, const unsigned char*);
} } // namespace v8::jscre
#endif #endif
#endif #endif
......
...@@ -42,6 +42,8 @@ PCRE code modules. */ ...@@ -42,6 +42,8 @@ PCRE code modules. */
#include "pcre_internal.h" #include "pcre_internal.h"
namespace v8 { namespace jscre {
/************************************************* /*************************************************
* Tables for UTF-8 support * * Tables for UTF-8 support *
*************************************************/ *************************************************/
...@@ -69,3 +71,5 @@ const unsigned char kjs_pcre_utf8_table4[0x40] = { ...@@ -69,3 +71,5 @@ const unsigned char kjs_pcre_utf8_table4[0x40] = {
3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 }; 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
#include "pcre_chartables.c" #include "pcre_chartables.c"
} } // namespace v8::jscre
...@@ -46,6 +46,8 @@ properties. */ ...@@ -46,6 +46,8 @@ properties. */
#include "ucpinternal.h" /* Internal table details */ #include "ucpinternal.h" /* Internal table details */
#include "ucptable.cpp" /* The table itself */ #include "ucptable.cpp" /* The table itself */
namespace v8 { namespace jscre {
/************************************************* /*************************************************
* Search table and return other case * * Search table and return other case *
*************************************************/ *************************************************/
...@@ -96,3 +98,5 @@ int kjs_pcre_ucp_othercase(unsigned c) ...@@ -96,3 +98,5 @@ int kjs_pcre_ucp_othercase(unsigned c)
offset |= f1_caseneg; offset |= f1_caseneg;
return !offset ? -1 : c + offset; return !offset ? -1 : c + offset;
} }
} } // namespace v8::jscre
...@@ -42,6 +42,8 @@ class (one that contains characters whose values are > 255). */ ...@@ -42,6 +42,8 @@ class (one that contains characters whose values are > 255). */
#include "pcre_internal.h" #include "pcre_internal.h"
namespace v8 { namespace jscre {
/************************************************* /*************************************************
* Match character against an XCLASS * * Match character against an XCLASS *
*************************************************/ *************************************************/
...@@ -112,3 +114,5 @@ bool kjs_pcre_xclass(int c, const unsigned char* data) ...@@ -112,3 +114,5 @@ bool kjs_pcre_xclass(int c, const unsigned char* data)
return negated; /* char did not match */ return negated; /* char did not match */
} }
} } // namespace v8::jscre
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment