From 4926cf271a8f3e02bd51cb0c3abd669b3cb88790 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 30 Jan 2004 07:02:35 +0000 Subject: [PATCH] 2003/06/28 06:57:08 darcs-hash:20040130070235-aa32f-08520db8de4e09999a0d9de99fe73c24d87a7f2e.gz --- src/org/xwt/XWT.java | 4 +-- src/org/xwt/js/CompiledFunctionImpl.java | 42 ++++++++++-------------------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/org/xwt/XWT.java b/src/org/xwt/XWT.java index 015255b..b73a1fb 100644 --- a/src/org/xwt/XWT.java +++ b/src/org/xwt/XWT.java @@ -109,9 +109,7 @@ public final class XWT extends JS.Obj { }}); super.put("regexp", new JS.Callable() { public Object call(JS.Array args) throws JS.Exn { - //throw new Error("not implemented"); - Log.log(XWT.class, "regexp not implemented"); - return null; + return new Regexp(args); }}); super.put("listfonts", new JS.Callable() { public Object call(JS.Array args) throws JS.Exn { diff --git a/src/org/xwt/js/CompiledFunctionImpl.java b/src/org/xwt/js/CompiledFunctionImpl.java index 366ff8c..c31c84e 100644 --- a/src/org/xwt/js/CompiledFunctionImpl.java +++ b/src/org/xwt/js/CompiledFunctionImpl.java @@ -380,35 +380,21 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { if (args.length() != 1) return null; return new Integer(((String)o).indexOf(args.elementAt(0).toString())); } }; - // This is just a quick and dirty split implementation. its could be optimized a lot and it doesn't - // do regexps yet. this will need to be rewritten when we get regexp support anyway - else if (v.equals("split")) return new JS.Callable() { + else if(v.equals("match")) return new JS.Callable() { public Object call(JS.Array args) { - String sep; - int limit, s,p,matches=0; - int seplen; - JS.Array ret; - - if(args.length() > 1) limit = JS.toNumber(args.elementAt(1)).intValue(); - else limit = 0; - if(args.length() > 0) sep = args.elementAt(0).toString(); - else sep = null; - - seplen = sep!=null ? sep.length() : 0; - - // special case sep == null, split up chars - if(seplen == 0) { - ret = new JS.Array(o.length()); - for(int i=0;i