+2002-04-15 Darin Adler <darin@apple.com>
+
+ * kjs/internal.cpp:
+ * kjs/property_map.cpp:
+ * kjs/ustring.h:
+ Removed some unneeded <config.h> includes so we are more similar
+ to the real KDE sources.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from KDE 3.0 final and did some build fixes.
+
+ * JavaScriptCore.pbproj/project.pbxproj: Added nodes2string.cpp.
+
+ * kjs/grammar.*: Regenerated.
+ * kjs/*.lut.h: Regenerated.
+
2002-04-08 Darin Adler <darin@apple.com>
Reviwed by: Maciej Stachowiak <mjs@apple.com>
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * kjs/internal.cpp:
+ * kjs/property_map.cpp:
+ * kjs/ustring.h:
+ Removed some unneeded <config.h> includes so we are more similar
+ to the real KDE sources.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from KDE 3.0 final and did some build fixes.
+
+ * JavaScriptCore.pbproj/project.pbxproj: Added nodes2string.cpp.
+
+ * kjs/grammar.*: Regenerated.
+ * kjs/*.lut.h: Regenerated.
+
2002-04-08 Darin Adler <darin@apple.com>
Reviwed by: Maciej Stachowiak <mjs@apple.com>
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * kjs/internal.cpp:
+ * kjs/property_map.cpp:
+ * kjs/ustring.h:
+ Removed some unneeded <config.h> includes so we are more similar
+ to the real KDE sources.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from KDE 3.0 final and did some build fixes.
+
+ * JavaScriptCore.pbproj/project.pbxproj: Added nodes2string.cpp.
+
+ * kjs/grammar.*: Regenerated.
+ * kjs/*.lut.h: Regenerated.
+
2002-04-08 Darin Adler <darin@apple.com>
Reviwed by: Maciej Stachowiak <mjs@apple.com>
F692A8C10255597D01FF60F7,
F692A8C30255597D01FF60F7,
F692A8CB02555BA201FF60F7,
+ F5FFE657026B47A6018635CA,
);
isa = PBXSourcesBuildPhase;
};
F692A86C0255597D01FF60F7,
F692A86D0255597D01FF60F7,
F692A86E0255597D01FF60F7,
+ F5FFE656026B47A6018635CA,
F692A8700255597D01FF60F7,
F692A8710255597D01FF60F7,
F692A8720255597D01FF60F7,
isa = PBXBuildStyle;
name = Unoptimized;
};
+ F5FFE656026B47A6018635CA = {
+ isa = PBXFileReference;
+ name = nodes2string.cpp;
+ path = kjs/nodes2string.cpp;
+ refType = 4;
+ };
+ F5FFE657026B47A6018635CA = {
+ fileRef = F5FFE656026B47A6018635CA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
//F50
//F51
//F52
// shrink array
for (unsigned int u = newLen; u < oldLen; u++) {
UString p = UString::from(u);
- if (hasProperty(exec, p, false))
+ if (hasOwnProperty(exec, p))
deleteProperty(exec, p);
}
ObjectImp::put(exec, "length", Number(newLen), DontEnum | DontDelete);
return;
// do we need to update/create the length property ?
- if (hasProperty(exec, "length", false)) {
+ if (hasOwnProperty(exec, "length")) {
Value len = get(exec, "length");
if (idx < len.toUInt32(exec))
return;
{
ObjectImp::put(exec,propertyName,value,attr);
}
+
+bool ArrayInstanceImp::hasOwnProperty(ExecState *exec,
+ const UString &propertyName)
+{
+ // disable this object's prototype temporarily for the hasProperty() call
+ Value protoBackup = prototype();
+ setPrototype(Undefined());
+ bool b = hasProperty(exec, propertyName);
+ setPrototype(protoBackup);
+ return b;
+}
+
// ------------------------------ ArrayPrototypeImp ----------------------------
const ClassInfo ArrayPrototypeImp::info = {"Array", &ArrayInstanceImp::info, &arrayTable, 0};
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _ARRAY_OBJECT_H_
virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
virtual void putDirect(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
+ /**
+ * A shallow hasProperty() variant that doesn't look at the prototype's
+ * properties.
+ */
+ virtual bool hasOwnProperty(ExecState *exec, const UString &propertyName);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _BOOL_OBJECT_H_
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include "collector.h"
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _KJSCOLLECTOR_H_
static bool outOfMemory() { return memLimitReached; }
#ifdef KJS_DEBUG_MEM
- /** Check that nothing is left when the last interpreter gets deleted */
+ /**
+ * Check that nothing is left when the last interpreter gets deleted
+ */
static void finalCheck();
/**
* @internal
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifdef HAVE_CONFIG_H
UString s;
const int bufsize=100;
char timebuffer[bufsize];
- char *oldlocale = setlocale(LC_TIME,NULL);
- if (!oldlocale)
+ CString oldlocale = setlocale(LC_TIME,NULL);
+ if (!oldlocale.c_str())
oldlocale = setlocale(LC_ALL, NULL);
Value v = thisObj.internalValue();
double milli = v.toNumber(exec);
t = gmtime(&tv);
strftime(timebuffer, bufsize, "%a, %d-%b-%y %H:%M:%S %Z", t);
}
- setlocale(LC_TIME,oldlocale);
+ setlocale(LC_TIME,oldlocale.c_str());
result = String(timebuffer);
break;
case ToLocaleString:
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _DATE_OBJECT_H_
#include "internal.h"
#include "function_object.h"
+#include <sys/time.h>
+
namespace KJS {
class DateInstanceImp : public ObjectImp {
// helper functions
Value parseDate(const String &s);
- time_t KRFCDate_parseDate(const UString &_date);
+ time_t KRFCDate_parseDate(const UString &_date);
Value timeClip(const Value &t);
}; // namespace
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include "debugger.h"
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _KJSDEBUGGER_H_
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _ERROR_OBJECT_H_
{
Value protect(this);
argStack = new ListImp();
+ Value protectArgStack( argStack ); // this also calls setGcAllowed on argStack
+ //fprintf(stderr,"FunctionImp::FunctionImp this=%p argStack=%p\n");
put(exec,"arguments",Null(),ReadOnly|DontDelete|DontEnum);
}
FunctionImp::~FunctionImp()
{
- argStack->setGcAllowed();
// The function shouldn't be deleted while it is still executed; argStack
// should be set to 0 by the last call to popArgs()
- assert(argStack->isEmpty());
+ //assert(argStack->isEmpty());
+ // Accessing argStack from here is a problem though.
+ // When the function isn't used anymore, it's not marked, and neither is the
+ // argStack, so both can be deleted - in any order!
delete param;
}
*p = new Parameter(n);
}
+UString FunctionImp::parameterString() const
+{
+ UString s;
+ const Parameter * const *p = ¶m;
+ while (*p) {
+ if (!s.isEmpty())
+ s += ", ";
+ s += (*p)->name;
+ p = &(*p)->next;
+ }
+
+ return s;
+}
+
// ECMA 10.1.3q
void FunctionImp::processParameters(ExecState *exec, const List &args)
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _KJS_FUNCTION_H_
virtual Value call(ExecState *exec, Object &thisObj, const List &args);
void addParameter(const UString &n);
+ // parameters in string representation, e.g. (a, b, c)
+ UString parameterString() const;
virtual CodeType codeType() const = 0;
virtual Completion execute(ExecState *exec) = 0;
switch (id) {
case ToString: {
// ### also make this work for internal functions
- // ### return the text of the function body (see 15.3.4.2)
if (thisObj.isNull() || !thisObj.inherits(&InternalFunctionImp::info)) {
#ifndef NDEBUG
fprintf(stderr,"attempted toString() call on null or non-function object\n");
exec->setException(err);
return err;
}
- if (thisObj.inherits(&FunctionImp::info) &&
+ if (thisObj.inherits(&DeclaredFunctionImp::info)) {
+ DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>
+ (thisObj.imp());
+ return String("function " + fi->name() + "(" +
+ fi->parameterString() + ") " + fi->body->toString());
+ } else if (thisObj.inherits(&FunctionImp::info) &&
!static_cast<FunctionImp*>(thisObj.imp())->name().isNull()) {
result = String("function " + static_cast<FunctionImp*>(thisObj.imp())->name() + "()");
}
Object argArrayObj = Object::dynamicCast(argArray);
unsigned int length = argArrayObj.get(exec,"length").toUInt32(exec);
- for (uint i = 0; i < length; i++)
+ for (unsigned int i = 0; i < length; i++)
applyArgs.append(argArrayObj.get(exec,UString::from(i)));
}
else {
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _FUNCTION_OBJECT_H_
160, 162, 163, 164, 165, 166, 169, 175, 177, 179,
180, 181, 182, 183, 186, 188, 189, 192, 194, 198,
200, 203, 205, 208, 210, 214, 217, 218, 221, 223,
- 224, 225, 227, 230, 232, 235, 237, 238, 239, 242,
- 244, 247, 249, 252, 254, 257, 259, 260, 263, 265,
- 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
- 278, 280, 281, 282, 285, 287, 288, 291, 293, 294,
- 295, 298, 300, 302, 304, 306, 308, 310, 314, 316,
- 317, 318, 319, 322, 324, 327, 329, 332, 334, 337,
- 339, 343, 345, 349, 351, 355, 357, 361, 363, 364,
- 365, 366, 367, 368, 369, 370, 371, 372, 373, 376,
- 378, 381, 383, 384, 385, 386, 387, 388, 389, 390,
- 391, 392, 393, 394, 395, 398, 400, 403, 405, 408,
- 411, 420, 422, 426, 428, 431, 435, 439, 442, 449,
- 451, 455, 457, 458, 461, 464, 467, 471, 477, 479,
- 482, 484, 488, 490, 497, 499, 503, 505, 513, 515,
- 519, 520, 526, 531, 536, 538, 542, 544, 547, 549,
- 552, 554, 557, 559, 562, 568, 572, 574, 575, 578,
- 582, 586, 589, 593, 595, 600, 602, 606, 609, 613,
- 616, 620, 622, 625, 627
+ 224, 225, 227, 230, 232, 235, 237, 238, 239, 243,
+ 245, 248, 250, 253, 255, 258, 260, 261, 264, 266,
+ 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
+ 279, 281, 282, 283, 286, 288, 289, 292, 294, 295,
+ 296, 299, 301, 303, 305, 307, 309, 311, 315, 317,
+ 318, 319, 320, 323, 325, 328, 330, 333, 335, 338,
+ 340, 344, 346, 350, 352, 356, 358, 362, 364, 365,
+ 366, 367, 368, 369, 370, 371, 372, 373, 374, 377,
+ 379, 382, 384, 385, 386, 387, 388, 389, 390, 391,
+ 392, 393, 394, 395, 396, 399, 401, 404, 406, 409,
+ 412, 421, 423, 427, 429, 432, 436, 440, 443, 450,
+ 452, 456, 458, 459, 462, 465, 468, 472, 478, 480,
+ 483, 485, 489, 491, 498, 500, 504, 506, 514, 516,
+ 520, 521, 527, 532, 537, 539, 543, 545, 548, 550,
+ 553, 555, 558, 560, 563, 569, 573, 575, 576, 579,
+ 583, 587, 590, 594, 596, 601, 603, 607, 610, 614,
+ 617, 621, 623, 626, 628
};
#endif
break;}
case 39:
#line 239 "grammar.y"
-{ yyval.node = new AccessorNode2(yyvsp[-2].node, yyvsp[0].ustr); ;
+{ yyval.node = new AccessorNode2(yyvsp[-2].node, yyvsp[0].ustr);
+ delete yyvsp[0].ustr; ;
break;}
case 40:
-#line 243 "grammar.y"
+#line 244 "grammar.y"
{ yyval.args = new ArgumentsNode(0L); ;
break;}
case 41:
-#line 244 "grammar.y"
+#line 245 "grammar.y"
{ yyval.args = new ArgumentsNode(yyvsp[-1].alist); ;
break;}
case 42:
-#line 248 "grammar.y"
+#line 249 "grammar.y"
{ yyval.alist = new ArgumentListNode(yyvsp[0].node); ;
break;}
case 43:
-#line 249 "grammar.y"
+#line 250 "grammar.y"
{ yyval.alist = new ArgumentListNode(yyvsp[-2].alist, yyvsp[0].node); ;
break;}
case 47:
-#line 259 "grammar.y"
+#line 260 "grammar.y"
{ yyval.node = new PostfixNode(yyvsp[-1].node, OpPlusPlus); ;
break;}
case 48:
-#line 260 "grammar.y"
+#line 261 "grammar.y"
{ yyval.node = new PostfixNode(yyvsp[-1].node, OpMinusMinus); ;
break;}
case 50:
-#line 265 "grammar.y"
+#line 266 "grammar.y"
{ yyval.node = new DeleteNode(yyvsp[0].node); ;
break;}
case 51:
-#line 266 "grammar.y"
+#line 267 "grammar.y"
{ yyval.node = new VoidNode(yyvsp[0].node); ;
break;}
case 52:
-#line 267 "grammar.y"
+#line 268 "grammar.y"
{ yyval.node = new TypeOfNode(yyvsp[0].node); ;
break;}
case 53:
-#line 268 "grammar.y"
+#line 269 "grammar.y"
{ yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ;
break;}
case 54:
-#line 269 "grammar.y"
+#line 270 "grammar.y"
{ yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ;
break;}
case 55:
-#line 270 "grammar.y"
+#line 271 "grammar.y"
{ yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ;
break;}
case 56:
-#line 271 "grammar.y"
+#line 272 "grammar.y"
{ yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ;
break;}
case 57:
-#line 272 "grammar.y"
+#line 273 "grammar.y"
{ yyval.node = new UnaryPlusNode(yyvsp[0].node); ;
break;}
case 58:
-#line 273 "grammar.y"
+#line 274 "grammar.y"
{ yyval.node = new NegateNode(yyvsp[0].node); ;
break;}
case 59:
-#line 274 "grammar.y"
+#line 275 "grammar.y"
{ yyval.node = new BitwiseNotNode(yyvsp[0].node); ;
break;}
case 60:
-#line 275 "grammar.y"
+#line 276 "grammar.y"
{ yyval.node = new LogicalNotNode(yyvsp[0].node); ;
break;}
case 62:
-#line 280 "grammar.y"
+#line 281 "grammar.y"
{ yyval.node = new MultNode(yyvsp[-2].node, yyvsp[0].node, '*'); ;
break;}
case 63:
-#line 281 "grammar.y"
+#line 282 "grammar.y"
{ yyval.node = new MultNode(yyvsp[-2].node, yyvsp[0].node, '/'); ;
break;}
case 64:
-#line 282 "grammar.y"
+#line 283 "grammar.y"
{ yyval.node = new MultNode(yyvsp[-2].node,yyvsp[0].node,'%'); ;
break;}
case 66:
-#line 287 "grammar.y"
+#line 288 "grammar.y"
{ yyval.node = new AddNode(yyvsp[-2].node, yyvsp[0].node, '+'); ;
break;}
case 67:
-#line 288 "grammar.y"
+#line 289 "grammar.y"
{ yyval.node = new AddNode(yyvsp[-2].node, yyvsp[0].node, '-'); ;
break;}
case 69:
-#line 293 "grammar.y"
+#line 294 "grammar.y"
{ yyval.node = new ShiftNode(yyvsp[-2].node, OpLShift, yyvsp[0].node); ;
break;}
case 70:
-#line 294 "grammar.y"
+#line 295 "grammar.y"
{ yyval.node = new ShiftNode(yyvsp[-2].node, OpRShift, yyvsp[0].node); ;
break;}
case 71:
-#line 295 "grammar.y"
+#line 296 "grammar.y"
{ yyval.node = new ShiftNode(yyvsp[-2].node, OpURShift, yyvsp[0].node); ;
break;}
case 73:
-#line 301 "grammar.y"
+#line 302 "grammar.y"
{ yyval.node = new RelationalNode(yyvsp[-2].node, OpLess, yyvsp[0].node); ;
break;}
case 74:
-#line 303 "grammar.y"
+#line 304 "grammar.y"
{ yyval.node = new RelationalNode(yyvsp[-2].node, OpGreater, yyvsp[0].node); ;
break;}
case 75:
-#line 305 "grammar.y"
+#line 306 "grammar.y"
{ yyval.node = new RelationalNode(yyvsp[-2].node, OpLessEq, yyvsp[0].node); ;
break;}
case 76:
-#line 307 "grammar.y"
+#line 308 "grammar.y"
{ yyval.node = new RelationalNode(yyvsp[-2].node, OpGreaterEq, yyvsp[0].node); ;
break;}
case 77:
-#line 309 "grammar.y"
+#line 310 "grammar.y"
{ yyval.node = new RelationalNode(yyvsp[-2].node, OpInstanceOf, yyvsp[0].node); ;
break;}
case 78:
-#line 311 "grammar.y"
+#line 312 "grammar.y"
{ yyval.node = new RelationalNode(yyvsp[-2].node, OpIn, yyvsp[0].node); ;
break;}
case 80:
-#line 316 "grammar.y"
+#line 317 "grammar.y"
{ yyval.node = new EqualNode(yyvsp[-2].node, OpEqEq, yyvsp[0].node); ;
break;}
case 81:
-#line 317 "grammar.y"
+#line 318 "grammar.y"
{ yyval.node = new EqualNode(yyvsp[-2].node, OpNotEq, yyvsp[0].node); ;
break;}
case 82:
-#line 318 "grammar.y"
+#line 319 "grammar.y"
{ yyval.node = new EqualNode(yyvsp[-2].node, OpStrEq, yyvsp[0].node); ;
break;}
case 83:
-#line 319 "grammar.y"
+#line 320 "grammar.y"
{ yyval.node = new EqualNode(yyvsp[-2].node, OpStrNEq, yyvsp[0].node);;
break;}
case 85:
-#line 324 "grammar.y"
+#line 325 "grammar.y"
{ yyval.node = new BitOperNode(yyvsp[-2].node, OpBitAnd, yyvsp[0].node); ;
break;}
case 87:
-#line 329 "grammar.y"
+#line 330 "grammar.y"
{ yyval.node = new BitOperNode(yyvsp[-2].node, OpBitXOr, yyvsp[0].node); ;
break;}
case 89:
-#line 334 "grammar.y"
+#line 335 "grammar.y"
{ yyval.node = new BitOperNode(yyvsp[-2].node, OpBitOr, yyvsp[0].node); ;
break;}
case 91:
-#line 340 "grammar.y"
+#line 341 "grammar.y"
{ yyval.node = new BinaryLogicalNode(yyvsp[-2].node, OpAnd, yyvsp[0].node); ;
break;}
case 93:
-#line 346 "grammar.y"
+#line 347 "grammar.y"
{ yyval.node = new BinaryLogicalNode(yyvsp[-2].node, OpOr, yyvsp[0].node); ;
break;}
case 95:
-#line 352 "grammar.y"
+#line 353 "grammar.y"
{ yyval.node = new ConditionalNode(yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
break;}
case 97:
-#line 358 "grammar.y"
+#line 359 "grammar.y"
{ yyval.node = new AssignNode(yyvsp[-2].node, yyvsp[-1].op, yyvsp[0].node);;
break;}
case 98:
-#line 362 "grammar.y"
+#line 363 "grammar.y"
{ yyval.op = OpEqual; ;
break;}
case 99:
-#line 363 "grammar.y"
+#line 364 "grammar.y"
{ yyval.op = OpPlusEq; ;
break;}
case 100:
-#line 364 "grammar.y"
+#line 365 "grammar.y"
{ yyval.op = OpMinusEq; ;
break;}
case 101:
-#line 365 "grammar.y"
+#line 366 "grammar.y"
{ yyval.op = OpMultEq; ;
break;}
case 102:
-#line 366 "grammar.y"
+#line 367 "grammar.y"
{ yyval.op = OpDivEq; ;
break;}
case 103:
-#line 367 "grammar.y"
+#line 368 "grammar.y"
{ yyval.op = OpLShift; ;
break;}
case 104:
-#line 368 "grammar.y"
+#line 369 "grammar.y"
{ yyval.op = OpRShift; ;
break;}
case 105:
-#line 369 "grammar.y"
+#line 370 "grammar.y"
{ yyval.op = OpURShift; ;
break;}
case 106:
-#line 370 "grammar.y"
+#line 371 "grammar.y"
{ yyval.op = OpAndEq; ;
break;}
case 107:
-#line 371 "grammar.y"
+#line 372 "grammar.y"
{ yyval.op = OpXOrEq; ;
break;}
case 108:
-#line 372 "grammar.y"
+#line 373 "grammar.y"
{ yyval.op = OpOrEq; ;
break;}
case 109:
-#line 373 "grammar.y"
+#line 374 "grammar.y"
{ yyval.op = OpModEq; ;
break;}
case 111:
-#line 378 "grammar.y"
+#line 379 "grammar.y"
{ yyval.node = new CommaNode(yyvsp[-2].node, yyvsp[0].node); ;
break;}
case 126:
-#line 399 "grammar.y"
+#line 400 "grammar.y"
{ yyval.stat = new BlockNode(0L); DBG(yyval.stat, yylsp[0], yylsp[0]); ;
break;}
case 127:
-#line 400 "grammar.y"
+#line 401 "grammar.y"
{ yyval.stat = new BlockNode(yyvsp[-1].srcs); DBG(yyval.stat, yylsp[0], yylsp[0]); ;
break;}
case 128:
-#line 404 "grammar.y"
+#line 405 "grammar.y"
{ yyval.slist = new StatListNode(yyvsp[0].stat); ;
break;}
case 129:
-#line 405 "grammar.y"
+#line 406 "grammar.y"
{ yyval.slist = new StatListNode(yyvsp[-1].slist, yyvsp[0].stat); ;
break;}
case 130:
-#line 409 "grammar.y"
+#line 410 "grammar.y"
{ yyval.stat = new VarStatementNode(yyvsp[-1].vlist);
DBG(yyval.stat, yylsp[-2], yylsp[0]); ;
break;}
case 131:
-#line 411 "grammar.y"
+#line 412 "grammar.y"
{ if (automatic()) {
yyval.stat = new VarStatementNode(yyvsp[-1].vlist);
DBG(yyval.stat, yylsp[-2], yylsp[-1]);
;
break;}
case 132:
-#line 421 "grammar.y"
+#line 422 "grammar.y"
{ yyval.vlist = new VarDeclListNode(yyvsp[0].decl); ;
break;}
case 133:
-#line 423 "grammar.y"
+#line 424 "grammar.y"
{ yyval.vlist = new VarDeclListNode(yyvsp[-2].vlist, yyvsp[0].decl); ;
break;}
case 134:
-#line 427 "grammar.y"
+#line 428 "grammar.y"
{ yyval.decl = new VarDeclNode(yyvsp[0].ustr, 0); delete yyvsp[0].ustr; ;
break;}
case 135:
-#line 428 "grammar.y"
+#line 429 "grammar.y"
{ yyval.decl = new VarDeclNode(yyvsp[-1].ustr, yyvsp[0].init); delete yyvsp[-1].ustr; ;
break;}
case 136:
-#line 432 "grammar.y"
+#line 433 "grammar.y"
{ yyval.init = new AssignExprNode(yyvsp[0].node); ;
break;}
case 137:
-#line 436 "grammar.y"
+#line 437 "grammar.y"
{ yyval.stat = new EmptyStatementNode(); ;
break;}
case 138:
-#line 440 "grammar.y"
+#line 441 "grammar.y"
{ yyval.stat = new ExprStatementNode(yyvsp[-1].node);
DBG(yyval.stat, yylsp[-1], yylsp[0]); ;
break;}
case 139:
-#line 442 "grammar.y"
+#line 443 "grammar.y"
{ if (automatic()) {
yyval.stat = new ExprStatementNode(yyvsp[-1].node);
DBG(yyval.stat, yylsp[-1], yylsp[-1]);
YYABORT; ;
break;}
case 140:
-#line 450 "grammar.y"
+#line 451 "grammar.y"
{ yyval.stat = new IfNode(yyvsp[-2].node,yyvsp[0].stat,0L);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ;
break;}
case 141:
-#line 452 "grammar.y"
+#line 453 "grammar.y"
{ yyval.stat = new IfNode(yyvsp[-4].node,yyvsp[-2].stat,yyvsp[0].stat);DBG(yyval.stat,yylsp[-6],yylsp[-3]); ;
break;}
case 142:
-#line 456 "grammar.y"
+#line 457 "grammar.y"
{ yyval.stat=new DoWhileNode(yyvsp[-4].stat,yyvsp[-1].node);DBG(yyval.stat,yylsp[-5],yylsp[-3]);;
break;}
case 143:
-#line 457 "grammar.y"
+#line 458 "grammar.y"
{ yyval.stat = new WhileNode(yyvsp[-2].node,yyvsp[0].stat);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ;
break;}
case 144:
-#line 459 "grammar.y"
+#line 460 "grammar.y"
{ yyval.stat = new ForNode(yyvsp[-6].node,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].stat);
DBG(yyval.stat,yylsp[-8],yylsp[-1]); ;
break;}
case 145:
-#line 462 "grammar.y"
+#line 463 "grammar.y"
{ yyval.stat = new ForNode(yyvsp[-6].vlist,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].stat);
DBG(yyval.stat,yylsp[-9],yylsp[-1]); ;
break;}
case 146:
-#line 465 "grammar.y"
+#line 466 "grammar.y"
{ yyval.stat = new ForInNode(yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].stat);
DBG(yyval.stat,yylsp[-6],yylsp[-1]); ;
break;}
case 147:
-#line 468 "grammar.y"
+#line 469 "grammar.y"
{ yyval.stat = new ForInNode(yyvsp[-4].ustr,0L,yyvsp[-2].node,yyvsp[0].stat);
DBG(yyval.stat,yylsp[-7],yylsp[-1]);
delete yyvsp[-4].ustr; ;
break;}
case 148:
-#line 472 "grammar.y"
+#line 473 "grammar.y"
{ yyval.stat = new ForInNode(yyvsp[-5].ustr,yyvsp[-4].init,yyvsp[-2].node,yyvsp[0].stat);
DBG(yyval.stat,yylsp[-8],yylsp[-1]);
delete yyvsp[-5].ustr; ;
break;}
case 149:
-#line 478 "grammar.y"
+#line 479 "grammar.y"
{ yyval.node = 0L; ;
break;}
case 151:
-#line 483 "grammar.y"
+#line 484 "grammar.y"
{ yyval.stat = new ContinueNode(); DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
break;}
case 152:
-#line 484 "grammar.y"
+#line 485 "grammar.y"
{ if (automatic()) {
yyval.stat = new ContinueNode(); DBG(yyval.stat,yylsp[-1],yylsp[0]);
} else
YYABORT; ;
break;}
case 153:
-#line 488 "grammar.y"
+#line 489 "grammar.y"
{ yyval.stat = new ContinueNode(yyvsp[-1].ustr); DBG(yyval.stat,yylsp[-2],yylsp[0]);
delete yyvsp[-1].ustr; ;
break;}
case 154:
-#line 490 "grammar.y"
+#line 491 "grammar.y"
{ if (automatic()) {
yyval.stat = new ContinueNode(yyvsp[-1].ustr);DBG(yyval.stat,yylsp[-2],yylsp[-1]);
delete yyvsp[-1].ustr;
YYABORT; ;
break;}
case 155:
-#line 498 "grammar.y"
+#line 499 "grammar.y"
{ yyval.stat = new BreakNode();DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
break;}
case 156:
-#line 499 "grammar.y"
+#line 500 "grammar.y"
{ if (automatic()) {
yyval.stat = new BreakNode(); DBG(yyval.stat,yylsp[-1],yylsp[-1]);
} else
YYABORT; ;
break;}
case 157:
-#line 503 "grammar.y"
+#line 504 "grammar.y"
{ yyval.stat = new BreakNode(yyvsp[-1].ustr); DBG(yyval.stat,yylsp[-2],yylsp[0]);
delete yyvsp[-1].ustr; ;
break;}
case 158:
-#line 505 "grammar.y"
+#line 506 "grammar.y"
{ if (automatic()) {
yyval.stat = new BreakNode(yyvsp[-1].ustr); DBG(yyval.stat,yylsp[-2],yylsp[-1]);
delete yyvsp[-1].ustr;
;
break;}
case 159:
-#line 514 "grammar.y"
+#line 515 "grammar.y"
{ yyval.stat = new ReturnNode(0L); DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
break;}
case 160:
-#line 515 "grammar.y"
+#line 516 "grammar.y"
{ if (automatic()) {
yyval.stat = new ReturnNode(0L); DBG(yyval.stat,yylsp[-1],yylsp[-1]);
} else
YYABORT; ;
break;}
case 161:
-#line 519 "grammar.y"
+#line 520 "grammar.y"
{ yyval.stat = new ReturnNode(yyvsp[-1].node); ;
break;}
case 162:
-#line 520 "grammar.y"
+#line 521 "grammar.y"
{ if (automatic())
yyval.stat = new ReturnNode(yyvsp[-1].node);
else
YYABORT; ;
break;}
case 163:
-#line 527 "grammar.y"
+#line 528 "grammar.y"
{ yyval.stat = new WithNode(yyvsp[-2].node,yyvsp[0].stat);
DBG(yyval.stat, yylsp[-4], yylsp[-1]); ;
break;}
case 164:
-#line 532 "grammar.y"
+#line 533 "grammar.y"
{ yyval.stat = new SwitchNode(yyvsp[-2].node, yyvsp[0].cblk);
DBG(yyval.stat, yylsp[-4], yylsp[-1]); ;
break;}
case 165:
-#line 537 "grammar.y"
+#line 538 "grammar.y"
{ yyval.cblk = new CaseBlockNode(yyvsp[-1].clist, 0L, 0L); ;
break;}
case 166:
-#line 539 "grammar.y"
+#line 540 "grammar.y"
{ yyval.cblk = new CaseBlockNode(yyvsp[-3].clist, yyvsp[-2].ccl, yyvsp[-1].clist); ;
break;}
case 167:
-#line 543 "grammar.y"
+#line 544 "grammar.y"
{ yyval.clist = 0L; ;
break;}
case 169:
-#line 548 "grammar.y"
+#line 549 "grammar.y"
{ yyval.clist = new ClauseListNode(yyvsp[0].ccl); ;
break;}
case 170:
-#line 549 "grammar.y"
+#line 550 "grammar.y"
{ yyval.clist = yyvsp[-1].clist->append(yyvsp[0].ccl); ;
break;}
case 171:
-#line 553 "grammar.y"
+#line 554 "grammar.y"
{ yyval.ccl = new CaseClauseNode(yyvsp[-1].node, 0L); ;
break;}
case 172:
-#line 554 "grammar.y"
+#line 555 "grammar.y"
{ yyval.ccl = new CaseClauseNode(yyvsp[-2].node, yyvsp[0].slist); ;
break;}
case 173:
-#line 558 "grammar.y"
+#line 559 "grammar.y"
{ yyval.ccl = new CaseClauseNode(0L, 0L);; ;
break;}
case 174:
-#line 559 "grammar.y"
+#line 560 "grammar.y"
{ yyval.ccl = new CaseClauseNode(0L, yyvsp[0].slist); ;
break;}
case 175:
-#line 563 "grammar.y"
+#line 564 "grammar.y"
{ yyvsp[0].stat->pushLabel(yyvsp[-2].ustr);
yyval.stat = new LabelNode(yyvsp[-2].ustr, yyvsp[0].stat);
delete yyvsp[-2].ustr; ;
break;}
case 176:
-#line 569 "grammar.y"
+#line 570 "grammar.y"
{ yyval.stat = new ThrowNode(yyvsp[-1].node); ;
break;}
case 177:
-#line 573 "grammar.y"
+#line 574 "grammar.y"
{ yyval.stat = new TryNode(yyvsp[-1].stat, yyvsp[0].node); ;
break;}
case 178:
-#line 574 "grammar.y"
+#line 575 "grammar.y"
{ yyval.stat = new TryNode(yyvsp[-1].stat, 0L, yyvsp[0].node); ;
break;}
case 179:
-#line 575 "grammar.y"
+#line 576 "grammar.y"
{ yyval.stat = new TryNode(yyvsp[-2].stat, yyvsp[-1].node, yyvsp[0].node); ;
break;}
case 180:
-#line 579 "grammar.y"
+#line 580 "grammar.y"
{ yyval.node = new CatchNode(yyvsp[-2].ustr, yyvsp[0].stat); delete yyvsp[-2].ustr; ;
break;}
case 181:
-#line 583 "grammar.y"
+#line 584 "grammar.y"
{ yyval.node = new FinallyNode(yyvsp[0].stat); ;
break;}
case 182:
-#line 587 "grammar.y"
+#line 588 "grammar.y"
{ yyval.func = new FuncDeclNode(yyvsp[-3].ustr, 0L, yyvsp[0].body);
delete yyvsp[-3].ustr; ;
break;}
case 183:
-#line 590 "grammar.y"
+#line 591 "grammar.y"
{ yyval.func = new FuncDeclNode(yyvsp[-4].ustr, yyvsp[-2].param, yyvsp[0].body);
delete yyvsp[-4].ustr; ;
break;}
case 184:
-#line 594 "grammar.y"
+#line 595 "grammar.y"
{ yyval.node = new FuncExprNode(0L, yyvsp[0].body); ;
break;}
case 185:
-#line 596 "grammar.y"
+#line 597 "grammar.y"
{ yyval.node = new FuncExprNode(yyvsp[-2].param, yyvsp[0].body); ;
break;}
case 186:
-#line 601 "grammar.y"
+#line 602 "grammar.y"
{ yyval.param = new ParameterNode(yyvsp[0].ustr); delete yyvsp[0].ustr; ;
break;}
case 187:
-#line 602 "grammar.y"
+#line 603 "grammar.y"
{ yyval.param = yyvsp[-2].param->append(yyvsp[0].ustr);
delete yyvsp[0].ustr; ;
break;}
case 188:
-#line 607 "grammar.y"
+#line 608 "grammar.y"
{ yyval.body = new FunctionBodyNode(0L);
DBG(yyval.body, yylsp[-1], yylsp[0]);;
break;}
case 189:
-#line 609 "grammar.y"
+#line 610 "grammar.y"
{ yyval.body = new FunctionBodyNode(yyvsp[-1].srcs);
DBG(yyval.body, yylsp[-2], yylsp[0]);;
break;}
case 190:
-#line 614 "grammar.y"
+#line 615 "grammar.y"
{ yyval.prog = new ProgramNode(0L);
Parser::progNode = yyval.prog; ;
break;}
case 191:
-#line 616 "grammar.y"
+#line 617 "grammar.y"
{ yyval.prog = new ProgramNode(yyvsp[0].srcs);
Parser::progNode = yyval.prog; ;
break;}
case 192:
-#line 621 "grammar.y"
+#line 622 "grammar.y"
{ yyval.srcs = new SourceElementsNode(yyvsp[0].src); ;
break;}
case 193:
-#line 622 "grammar.y"
+#line 623 "grammar.y"
{ yyval.srcs = new SourceElementsNode(yyvsp[-1].srcs, yyvsp[0].src); ;
break;}
case 194:
-#line 626 "grammar.y"
+#line 627 "grammar.y"
{ yyval.src = new SourceElementNode(yyvsp[0].stat); ;
break;}
case 195:
-#line 627 "grammar.y"
+#line 628 "grammar.y"
{ yyval.src = new SourceElementNode(yyvsp[0].func); ;
break;}
}
}
return 1;
}
-#line 630 "grammar.y"
+#line 631 "grammar.y"
int yyerror (const char *) /* Called by yyparse on error */
MemberExpr Arguments { $$ = new FunctionCallNode($1, $2); }
| CallExpr Arguments { $$ = new FunctionCallNode($1, $2); }
| CallExpr '[' Expr ']' { $$ = new AccessorNode1($1, $3); }
- | CallExpr '.' IDENT { $$ = new AccessorNode2($1, $3); }
+ | CallExpr '.' IDENT { $$ = new AccessorNode2($1, $3);
+ delete $3; }
;
Arguments:
*
*/
-#include <config.h>
-
#include <stdio.h>
#include <math.h>
#include <assert.h>
clear();
delete hook;
+
+ if ( emptyList == this )
+ emptyList = 0L;
}
void ListImp::mark()
BooleanImp::staticFalse->deref();
BooleanImp::staticFalse->setGcAllowed();
BooleanImp::staticFalse = 0L;
-#ifdef APPLE_CHANGES
- ListImp::emptyList->setGcAllowed();
- ListImp::emptyList->deref();
- ListImp::emptyList = 0;
-#endif
}
InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
m_compatMode = Interpreter::NativeMode;
// initialize properties of the global object
+ initGlobalObject();
+ recursion = 0;
+}
+
+void InterpreterImp::initGlobalObject()
+{
// Contructor prototype objects (Object.prototype, Array.prototype etc)
FunctionPrototypeImp *funcProto = new FunctionPrototypeImp(globExec);
// built-in objects
global.put(globExec,"Math", Object(new MathObjectImp(globExec,objProto)), DontEnum);
-
- recursion = 0;
}
InterpreterImp::~InterpreterImp()
Object globalObject() const { return global; }
Interpreter* interpreter() const { return m_interpreter; }
+ void initGlobalObject();
+
void mark();
ExecState *globalExec() { return globExec; }
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include "value.h"
return rep->globalObject();
}
+void Interpreter::initGlobalObject()
+{
+ rep->initGlobalObject();
+}
+
ExecState *Interpreter::globalExec()
{
return rep->globalExec();
rep = new ExecStateImp(interp,con);
}
+void Interpreter::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _KJS_INTERPRETER_H_
* Interpreter objects can be used to evaluate ECMAScript code. Each
* interpreter has a global object which is used for the purposes of code
* evaluation, and also provides access to built-in properties such as
- " Object" and "Number".
+ * " Object" and "Number".
*/
class Interpreter {
public:
*/
Object globalObject() const;
+ void initGlobalObject();
+
/**
* Returns the execution state object which can be used to execute
* scripts using this interpreter at a the "global" level, i.e. one
*/
Object builtinObject() const;
- /** Returns the builtin "Function" object. */
+ /**
+ * Returns the builtin "Function" object.
+ */
Object builtinFunction() const;
- /** Returns the builtin "Array" object. */
+ /**
+ * Returns the builtin "Array" object.
+ */
Object builtinArray() const;
- /** Returns the builtin "Boolean" object. */
+ /**
+ * Returns the builtin "Boolean" object.
+ */
Object builtinBoolean() const;
- /** Returns the builtin "String" object. */
+ /**
+ * Returns the builtin "String" object.
+ */
Object builtinString() const;
- /** Returns the builtin "Number" object. */
+ /**
+ * Returns the builtin "Number" object.
+ */
Object builtinNumber() const;
- /** Returns the builtin "Date" object. */
+ /**
+ * Returns the builtin "Date" object.
+ */
Object builtinDate() const;
- /** Returns the builtin "RegExp" object. */
+ /**
+ * Returns the builtin "RegExp" object.
+ */
Object builtinRegExp() const;
- /** Returns the builtin "Error" object. */
+ /**
+ * Returns the builtin "Error" object.
+ */
Object builtinError() const;
- /** Returns the builtin "Object.prototype" object. */
+ /**
+ * Returns the builtin "Object.prototype" object.
+ */
Object builtinObjectPrototype() const;
- /** Returns the builtin "Function.prototype" object. */
+ /**
+ * Returns the builtin "Function.prototype" object.
+ */
Object builtinFunctionPrototype() const;
- /** Returns the builtin "Array.prototype" object. */
+ /**
+ * Returns the builtin "Array.prototype" object.
+ */
Object builtinArrayPrototype() const;
- /** Returns the builtin "Boolean.prototype" object. */
+ /**
+ * Returns the builtin "Boolean.prototype" object.
+ */
Object builtinBooleanPrototype() const;
- /** Returns the builtin "String.prototype" object. */
+ /**
+ * Returns the builtin "String.prototype" object.
+ */
Object builtinStringPrototype() const;
- /** Returns the builtin "Number.prototype" object. */
+ /**
+ * Returns the builtin "Number.prototype" object.
+ */
Object builtinNumberPrototype() const;
- /** Returns the builtin "Date.prototype" object. */
+ /**
+ * Returns the builtin "Date.prototype" object.
+ */
Object builtinDatePrototype() const;
- /** Returns the builtin "RegExp.prototype" object. */
+ /**
+ * Returns the builtin "RegExp.prototype" object.
+ */
Object builtinRegExpPrototype() const;
- /** Returns the builtin "Error.prototype" object. */
+ /**
+ * Returns the builtin "Error.prototype" object.
+ */
Object builtinErrorPrototype() const;
- /** The initial value of "Error" global property */
+ /**
+ * The initial value of "Error" global property
+ */
Object builtinEvalError() const;
Object builtinRangeError() const;
Object builtinReferenceError() const;
* interpreter instance instead.
*/
Interpreter operator=(const Interpreter&);
+ protected:
+ virtual void virtual_hook( int id, void* data );
};
/**
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifdef HAVE_CONFIG_H
#include "lexer.lut.h"
-extern YYLTYPE yylloc; // global bison variable holding token info
+extern YYLTYPE yylloc; // global bison variable holding token info
// a bridge for yacc from the C world to C++
int kjsyylex()
}
Lexer::Lexer()
- : yylineno(0),
+ : yylineno(1),
size8(128), size16(128), restrKeyword(false),
eatNextIdentifier(false), stackToken(-1), lastToken(-1), pos(0),
code(0), length(0),
void Lexer::setCode(const UChar *c, unsigned int len)
{
- yylineno = 0;
+ yylineno = 1;
restrKeyword = false;
delimited = false;
eatNextIdentifier = false;
}
}
+// called on each new line
+void Lexer::nextLine()
+{
+ yylineno++;
+#ifndef KJS_PURE_ECMA
+ bol = true;
+#endif
+}
+
void Lexer::setDone(State s)
{
state = s;
switch (state) {
case Start:
if (isWhiteSpace()) {
- // do nothing
+ // do nothing
} else if (current == '/' && next1 == '/') {
- shift(1);
- state = InSingleLineComment;
+ shift(1);
+ state = InSingleLineComment;
} else if (current == '/' && next1 == '*') {
- shift(1);
- state = InMultiLineComment;
+ shift(1);
+ state = InMultiLineComment;
} else if (current == 0) {
- if (!terminator && !delimited) {
- // automatic semicolon insertion if program incomplete
- token = ';';
- stackToken = 0;
- setDone(Other);
- } else
- setDone(Eof);
+ if (!terminator && !delimited) {
+ // automatic semicolon insertion if program incomplete
+ token = ';';
+ stackToken = 0;
+ setDone(Other);
+ } else
+ setDone(Eof);
} else if (isLineTerminator()) {
- yylineno++;
-#ifndef KJS_PURE_ECMA
- bol = true;
-#endif
- terminator = true;
- if (restrKeyword) {
- token = ';';
- setDone(Other);
- }
+ nextLine();
+ terminator = true;
+ if (restrKeyword) {
+ token = ';';
+ setDone(Other);
+ }
} else if (current == '"' || current == '\'') {
- state = InString;
- stringType = current;
+ state = InString;
+ stringType = current;
} else if (isIdentLetter(current)) {
- record16(current);
- state = InIdentifier;
+ record16(current);
+ state = InIdentifier;
} else if (current == '0') {
- record8(current);
- state = InNum0;
+ record8(current);
+ state = InNum0;
} else if (isDecimalDigit(current)) {
- record8(current);
- state = InNum;
+ record8(current);
+ state = InNum;
} else if (current == '.' && isDecimalDigit(next1)) {
- record8(current);
- state = InDecimal;
+ record8(current);
+ state = InDecimal;
#ifndef KJS_PURE_ECMA
- // <!-- marks the beginning of a line comment (for www usage)
- } else if (bol && current == '<' && next1 == '!' &&
- next2 == '-' && next3 == '-') {
- shift(3);
- state = InSingleLineComment;
- // same of -->
+ // <!-- marks the beginning of a line comment (for www usage)
+ } else if (current == '<' && next1 == '!' &&
+ next2 == '-' && next3 == '-') {
+ shift(3);
+ state = InSingleLineComment;
+ // same for -->
} else if (bol && current == '-' && next1 == '-' && next2 == '>') {
- shift(2);
- state = InSingleLineComment;
+ shift(2);
+ state = InSingleLineComment;
#endif
} else {
- token = matchPunctuator(current, next1, next2, next3);
- if (token != -1) {
- setDone(Other);
- } else {
- // cerr << "encountered unknown character" << endl;
- setDone(Bad);
- }
+ token = matchPunctuator(current, next1, next2, next3);
+ if (token != -1) {
+ setDone(Other);
+ } else {
+ // cerr << "encountered unknown character" << endl;
+ setDone(Bad);
+ }
}
break;
case InString:
if (current == stringType) {
- shift(1);
- setDone(String);
+ shift(1);
+ setDone(String);
} else if (current == 0 || isLineTerminator()) {
- setDone(Bad);
+ setDone(Bad);
} else if (current == '\\') {
- state = InEscapeSequence;
+ state = InEscapeSequence;
} else {
- record16(current);
+ record16(current);
}
break;
// Escape Sequences inside of strings
case InEscapeSequence:
if (isOctalDigit(current)) {
- if (current >= '0' && current <= '3' &&
- isOctalDigit(next1) && isOctalDigit(next2)) {
- record16(convertOctal(current, next1, next2));
- shift(2);
- state = InString;
- } else if (isOctalDigit(current) && isOctalDigit(next1)) {
- record16(convertOctal('0', current, next1));
- shift(1);
- state = InString;
- } else if (isOctalDigit(current)) {
- record16(convertOctal('0', '0', current));
- state = InString;
- } else {
- setDone(Bad);
- }
+ if (current >= '0' && current <= '3' &&
+ isOctalDigit(next1) && isOctalDigit(next2)) {
+ record16(convertOctal(current, next1, next2));
+ shift(2);
+ state = InString;
+ } else if (isOctalDigit(current) && isOctalDigit(next1)) {
+ record16(convertOctal('0', current, next1));
+ shift(1);
+ state = InString;
+ } else if (isOctalDigit(current)) {
+ record16(convertOctal('0', '0', current));
+ state = InString;
+ } else {
+ setDone(Bad);
+ }
} else if (current == 'x')
- state = InHexEscape;
+ state = InHexEscape;
else if (current == 'u')
- state = InUnicodeEscape;
+ state = InUnicodeEscape;
else {
- record16(singleEscape(current));
- state = InString;
+ record16(singleEscape(current));
+ state = InString;
}
break;
case InHexEscape:
if (isHexDigit(current) && isHexDigit(next1)) {
- state = InString;
- record16(convertHex(current, next1));
- shift(1);
+ state = InString;
+ record16(convertHex(current, next1));
+ shift(1);
} else if (current == stringType) {
- record16('x');
- shift(1);
- setDone(String);
+ record16('x');
+ shift(1);
+ setDone(String);
} else {
- record16('x');
- record16(current);
- state = InString;
+ record16('x');
+ record16(current);
+ state = InString;
}
break;
case InUnicodeEscape:
if (isHexDigit(current) && isHexDigit(next1) &&
- isHexDigit(next2) && isHexDigit(next3)) {
- record16(convertUnicode(current, next1, next2, next3));
- shift(3);
- state = InString;
+ isHexDigit(next2) && isHexDigit(next3)) {
+ record16(convertUnicode(current, next1, next2, next3));
+ shift(3);
+ state = InString;
} else if (current == stringType) {
- record16('u');
- shift(1);
- setDone(String);
+ record16('u');
+ shift(1);
+ setDone(String);
} else {
- setDone(Bad);
+ setDone(Bad);
}
break;
case InSingleLineComment:
if (isLineTerminator()) {
- yylineno++;
- terminator = true;
-#ifndef KJS_PURE_ECMA
- bol = true;
-#endif
- if (restrKeyword) {
- token = ';';
- setDone(Other);
- } else
- state = Start;
+ nextLine();
+ terminator = true;
+ if (restrKeyword) {
+ token = ';';
+ setDone(Other);
+ } else
+ state = Start;
} else if (current == 0) {
- setDone(Eof);
+ setDone(Eof);
}
break;
case InMultiLineComment:
if (current == 0) {
- setDone(Bad);
+ setDone(Bad);
} else if (isLineTerminator()) {
- yylineno++;
+ nextLine();
} else if (current == '*' && next1 == '/') {
- state = Start;
- shift(1);
+ state = Start;
+ shift(1);
}
break;
case InIdentifier:
if (isIdentLetter(current) || isDecimalDigit(current)) {
- record16(current);
- break;
+ record16(current);
+ break;
}
setDone(Identifier);
break;
case InNum0:
if (current == 'x' || current == 'X') {
- record8(current);
- state = InHex;
+ record8(current);
+ state = InHex;
} else if (current == '.') {
- record8(current);
- state = InDecimal;
+ record8(current);
+ state = InDecimal;
} else if (current == 'e' || current == 'E') {
- record8(current);
- state = InExponentIndicator;
+ record8(current);
+ state = InExponentIndicator;
} else if (isOctalDigit(current)) {
- record8(current);
- state = InOctal;
+ record8(current);
+ state = InOctal;
} else if (isDecimalDigit(current)) {
record8(current);
state = InDecimal;
} else {
- setDone(Number);
+ setDone(Number);
}
break;
case InHex:
if (isHexDigit(current)) {
- record8(current);
+ record8(current);
} else {
- setDone(Hex);
+ setDone(Hex);
}
break;
case InOctal:
if (isOctalDigit(current)) {
- record8(current);
+ record8(current);
}
else if (isDecimalDigit(current)) {
record8(current);
state = InDecimal;
} else
- setDone(Octal);
+ setDone(Octal);
break;
case InNum:
if (isDecimalDigit(current)) {
- record8(current);
+ record8(current);
} else if (current == '.') {
- record8(current);
- state = InDecimal;
+ record8(current);
+ state = InDecimal;
} else if (current == 'e' || current == 'E') {
- record8(current);
- state = InExponentIndicator;
+ record8(current);
+ state = InExponentIndicator;
} else
- setDone(Number);
+ setDone(Number);
break;
case InDecimal:
if (isDecimalDigit(current)) {
- record8(current);
+ record8(current);
} else if (current == 'e' || current == 'E') {
- record8(current);
- state = InExponentIndicator;
+ record8(current);
+ state = InExponentIndicator;
} else
- setDone(Number);
+ setDone(Number);
break;
case InExponentIndicator:
if (current == '+' || current == '-') {
- record8(current);
+ record8(current);
} else if (isDecimalDigit(current)) {
- record8(current);
- state = InExponent;
+ record8(current);
+ state = InExponent;
} else
- setDone(Bad);
+ setDone(Bad);
break;
case InExponent:
if (isDecimalDigit(current)) {
- record8(current);
+ record8(current);
} else
- setDone(Number);
+ setDone(Number);
break;
default:
assert(!"Unhandled state in switch statement");
eatNextIdentifier = true;
if (token == CONTINUE || token == BREAK ||
- token == RETURN || token == THROW)
+ token == RETURN || token == THROW)
restrKeyword = true;
break;
case String:
bool Lexer::isWhiteSpace() const
{
return (current == ' ' || current == '\t' ||
- current == 0x0b || current == 0x0c);
+ current == 0x0b || current == 0x0c);
}
bool Lexer::isLineTerminator()
{
/* TODO: allow other legitimate unicode chars */
return (c >= 'a' && c <= 'z' ||
- c >= 'A' && c <= 'Z' ||
- c == '$' || c == '_');
+ c >= 'A' && c <= 'Z' ||
+ c == '$' || c == '_');
}
bool Lexer::isDecimalDigit(unsigned short c)
bool Lexer::isHexDigit(unsigned short c) const
{
return (c >= '0' && c <= '9' ||
- c >= 'a' && c <= 'f' ||
- c >= 'A' && c <= 'F');
+ c >= 'a' && c <= 'f' ||
+ c >= 'A' && c <= 'F');
}
bool Lexer::isOctalDigit(unsigned short c) const
}
int Lexer::matchPunctuator(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4)
+ unsigned short c3, unsigned short c4)
{
if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') {
shift(4);
unsigned short c3, unsigned short c4)
{
return UChar((convertHex(c1) << 4) + convertHex(c2),
- (convertHex(c3) << 4) + convertHex(c4));
+ (convertHex(c3) << 4) + convertHex(c4));
}
void Lexer::record8(unsigned short c)
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _KJSLEXER_H_
bool prevTerminator() const { return terminator; }
enum State { Start,
- Identifier,
- InIdentifier,
- InSingleLineComment,
- InMultiLineComment,
- InNum,
- InNum0,
- InHex,
- InOctal,
- InDecimal,
- InExponentIndicator,
- InExponent,
- Hex,
- Octal,
- Number,
- String,
- Eof,
- InString,
- InEscapeSequence,
- InHexEscape,
- InUnicodeEscape,
- Other,
- Bad };
+ Identifier,
+ InIdentifier,
+ InSingleLineComment,
+ InMultiLineComment,
+ InNum,
+ InNum0,
+ InHex,
+ InOctal,
+ InDecimal,
+ InExponentIndicator,
+ InExponent,
+ Hex,
+ Octal,
+ Number,
+ String,
+ Eof,
+ InString,
+ InEscapeSequence,
+ InHexEscape,
+ InUnicodeEscape,
+ Other,
+ Bad };
bool scanRegExp();
UString pattern, flags;
void setDone(State s);
unsigned int pos;
void shift(unsigned int p);
+ void nextLine();
int lookupKeyword(const char *);
bool isWhiteSpace() const;
bool isOctalDigit(unsigned short c) const;
int matchPunctuator(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4);
+ unsigned short c3, unsigned short c4);
unsigned short singleEscape(unsigned short c) const;
unsigned short convertOctal(unsigned short c1, unsigned short c2,
unsigned short c3) const;
static unsigned char convertHex(unsigned short c1);
static unsigned char convertHex(unsigned short c1, unsigned short c2);
static UChar convertUnicode(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4);
+ unsigned short c3, unsigned short c4);
static bool isIdentLetter(unsigned short c);
static bool isDecimalDigit(unsigned short c);
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include <stdio.h>
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _KJSLOOKUP_H_
* An entry in a hash table.
*/
struct HashEntry {
- /** s is the key (e.g. a property name) */
+ /**
+ * s is the key (e.g. a property name)
+ */
const char *s;
- /** value is the result value (usually an enum value) */
+ /**
+ * value is the result value (usually an enum value)
+ */
int value;
- /** attr is a set for flags (e.g. the property flags, see object.h) */
+ /**
+ * attr is a set for flags (e.g. the property flags, see object.h)
+ */
short int attr;
- /** params is another number. For property hashtables, it is used to
- denote the number of argument of the function */
+ /**
+ * params is another number. For property hashtables, it is used to
+ * denote the number of argument of the function
+ */
short int params;
- /** next is the pointer to the next entry for the same hash value */
+ /**
+ * next is the pointer to the next entry for the same hash value
+ */
const HashEntry *next;
};
* and links overflow entries between them.
*/
struct HashTable {
- /** type is a version number. Currently always 2 */
+ /**
+ * type is a version number. Currently always 2
+ */
int type;
- /** size is the total number of entries in the hashtable, including the null entries,
+ /**
+ * size is the total number of entries in the hashtable, including the null entries,
* i.e. the size of the "entries" array.
- * Used to iterate over all entries in the table */
+ * Used to iterate over all entries in the table
+ */
int size;
- /** pointer to the array of entries
- * Mind that some entries in the array are null (0,0,0,0). */
+ /**
+ * pointer to the array of entries
+ * Mind that some entries in the array are null (0,0,0,0).
+ */
const HashEntry *entries;
- /** the maximum value for the hash. Always smaller than size. */
+ /**
+ * the maximum value for the hash. Always smaller than size.
+ */
int hashSize;
};
*/
class Lookup {
public:
- /** Find an entry in the table, and return its value (i.e. the value field of HashEntry) */
+ /**
+ * Find an entry in the table, and return its value (i.e. the value field of HashEntry)
+ */
static int find(const struct HashTable *table, const UString &s);
static int find(const struct HashTable *table,
const UChar *c, unsigned int len);
static const HashEntry* findEntry(const struct HashTable *table,
const UChar *c, unsigned int len);
- /** Calculate the hash value for a given key */
+ /**
+ * Calculate the hash value for a given key
+ */
static unsigned int hash(const UString &key);
static unsigned int hash(const UChar *c, unsigned int len);
static unsigned int hash(const char *s);
class ExecState;
class UString;
- /** @internal
- * Helper for lookupFunction and lookupValueOrFunction */
+ /**
+ * @internal
+ * Helper for lookupFunction and lookupValueOrFunction
+ */
template <class FuncImp>
inline Value lookupOrCreateFunction(ExecState *exec, const UString &propertyName,
const ObjectImp *thisObj, int token, int params, int attr)
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include <math.h>
#include "math_object.lut.h"
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif /* M_PI */
+
using namespace KJS;
// ------------------------------ MathObjectImp --------------------------------
/* Source for math_object.lut.h
@begin mathTable 21
- E MathObjectImp::Euler DontEnum
- LN2 MathObjectImp::Ln2 DontEnum
- LN10 MathObjectImp::Ln10 DontEnum
- LOG2E MathObjectImp::Log2E DontEnum
- LOG10E MathObjectImp::Log10E DontEnum
- PI MathObjectImp::Pi DontEnum
- SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum
- SQRT2 MathObjectImp::Sqrt2 DontEnum
- abs MathObjectImp::Abs DontEnum|Function 1
- acos MathObjectImp::ACos DontEnum|Function 1
- asin MathObjectImp::ASin DontEnum|Function 1
- atan MathObjectImp::ATan DontEnum|Function 1
- atan2 MathObjectImp::ATan2 DontEnum|Function 2
- ceil MathObjectImp::Ceil DontEnum|Function 1
- cos MathObjectImp::Cos DontEnum|Function 1
- exp MathObjectImp::Exp DontEnum|Function 1
- floor MathObjectImp::Floor DontEnum|Function 1
- log MathObjectImp::Log DontEnum|Function 1
- max MathObjectImp::Max DontEnum|Function 2
- min MathObjectImp::Min DontEnum|Function 2
- pow MathObjectImp::Pow DontEnum|Function 2
- random MathObjectImp::Random DontEnum|Function 0
- round MathObjectImp::Round DontEnum|Function 1
- sin MathObjectImp::Sin DontEnum|Function 1
- sqrt MathObjectImp::Sqrt DontEnum|Function 1
- tan MathObjectImp::Tan DontEnum|Function 1
+ E MathObjectImp::Euler DontEnum|DontDelete|ReadOnly
+ LN2 MathObjectImp::Ln2 DontEnum|DontDelete|ReadOnly
+ LN10 MathObjectImp::Ln10 DontEnum|DontDelete|ReadOnly
+ LOG2E MathObjectImp::Log2E DontEnum|DontDelete|ReadOnly
+ LOG10E MathObjectImp::Log10E DontEnum|DontDelete|ReadOnly
+ PI MathObjectImp::Pi DontEnum|DontDelete|ReadOnly
+ SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum|DontDelete|ReadOnly
+ SQRT2 MathObjectImp::Sqrt2 DontEnum|DontDelete|ReadOnly
+ abs MathObjectImp::Abs DontEnum|Function 1
+ acos MathObjectImp::ACos DontEnum|Function 1
+ asin MathObjectImp::ASin DontEnum|Function 1
+ atan MathObjectImp::ATan DontEnum|Function 1
+ atan2 MathObjectImp::ATan2 DontEnum|Function 2
+ ceil MathObjectImp::Ceil DontEnum|Function 1
+ cos MathObjectImp::Cos DontEnum|Function 1
+ exp MathObjectImp::Exp DontEnum|Function 1
+ floor MathObjectImp::Floor DontEnum|Function 1
+ log MathObjectImp::Log DontEnum|Function 1
+ max MathObjectImp::Max DontEnum|Function 2
+ min MathObjectImp::Min DontEnum|Function 2
+ pow MathObjectImp::Pow DontEnum|Function 2
+ random MathObjectImp::Random DontEnum|Function 0
+ round MathObjectImp::Round DontEnum|Function 1
+ sin MathObjectImp::Sin DontEnum|Function 1
+ sqrt MathObjectImp::Sqrt DontEnum|Function 1
+ tan MathObjectImp::Tan DontEnum|Function 1
@end
*/
d = 1.0/log(10.0);
break;
case Pi:
- d = 2.0 * asin(1.0);
+ d = M_PI;
break;
case Sqrt1_2:
d = sqrt(0.5);
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _MATH_OBJECT_H_
const struct HashEntry mathTableEntries[] = {
{ "atan", MathObjectImp::ATan, DontEnum|Function, 1, &mathTableEntries[25] },
{ 0, 0, 0, 0, 0 },
- { "SQRT2", MathObjectImp::Sqrt2, DontEnum, 0, &mathTableEntries[23] },
+ { "SQRT2", MathObjectImp::Sqrt2, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[23] },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
- { "E", MathObjectImp::Euler, DontEnum, 0, &mathTableEntries[21] },
+ { "E", MathObjectImp::Euler, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[21] },
{ "asin", MathObjectImp::ASin, DontEnum|Function, 1, &mathTableEntries[26] },
{ "atan2", MathObjectImp::ATan2, DontEnum|Function, 2, &mathTableEntries[32] },
- { "LOG2E", MathObjectImp::Log2E, DontEnum, 0, &mathTableEntries[27] },
+ { "LOG2E", MathObjectImp::Log2E, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[27] },
{ "cos", MathObjectImp::Cos, DontEnum|Function, 1, 0 },
{ "max", MathObjectImp::Max, DontEnum|Function, 2, &mathTableEntries[29] },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
- { "LOG10E", MathObjectImp::Log10E, DontEnum, 0, &mathTableEntries[24] },
- { "LN2", MathObjectImp::Ln2, DontEnum, 0, &mathTableEntries[31] },
+ { "LOG10E", MathObjectImp::Log10E, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[24] },
+ { "LN2", MathObjectImp::Ln2, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[31] },
{ "abs", MathObjectImp::Abs, DontEnum|Function, 1, 0 },
{ "sqrt", MathObjectImp::Sqrt, DontEnum|Function, 1, 0 },
{ "exp", MathObjectImp::Exp, DontEnum|Function, 1, 0 },
{ 0, 0, 0, 0, 0 },
- { "LN10", MathObjectImp::Ln10, DontEnum, 0, &mathTableEntries[22] },
- { "PI", MathObjectImp::Pi, DontEnum, 0, &mathTableEntries[28] },
- { "SQRT1_2", MathObjectImp::Sqrt1_2, DontEnum, 0, 0 },
+ { "LN10", MathObjectImp::Ln10, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[22] },
+ { "PI", MathObjectImp::Pi, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[28] },
+ { "SQRT1_2", MathObjectImp::Sqrt1_2, DontEnum|DontDelete|ReadOnly, 0, 0 },
{ "acos", MathObjectImp::ACos, DontEnum|Function, 1, 0 },
{ "ceil", MathObjectImp::Ceil, DontEnum|Function, 1, 0 },
{ "floor", MathObjectImp::Floor, DontEnum|Function, 1, 0 },
#include "nodes.h"
-#include <assert.h>
-#ifdef APPLE_CHANGES
-#include <iostream>
-#else
-#include <iostream.h>
-#endif
+//#include <iostream>
#include <math.h>
-#include <stdio.h>
+#include <assert.h>
#ifdef KJS_DEBUG_MEM
+#include <stdio.h>
#include <typeinfo>
#endif
ClauseListNode *a = list1, *b = list2;
CaseClauseNode *clause;
- if (a) {
while (a) {
clause = a->clause();
a = a->next();
break;
}
}
- }
while (b) {
clause = b->clause();
{
/* TODO: workaround for empty body which I don't see covered by the spec */
if (!source)
- return Completion(ReturnValue, Undefined());
+ return Completion(Normal);
source->processFuncDecl(exec);
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _NODES_H_
class RegExp;
class SourceElementsNode;
class ProgramNode;
+ class SourceStream;
enum Operator { OpEqual,
OpEqEq,
Node();
virtual ~Node();
virtual Value evaluate(ExecState *exec) = 0;
+ UString toString() const;
+ virtual void streamTo(SourceStream &s) const = 0;
virtual void processVarDecls(ExecState */*exec*/) {}
int lineNo() const { return line; }
public:
NullNode() {}
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
};
class BooleanNode : public Node {
public:
BooleanNode(bool v) : value(v) {}
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
bool value;
};
public:
NumberNode(double v) : value(v) { }
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
double value;
};
public:
StringNode(const UString *v) { value = *v; }
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString value;
};
RegExpNode(const UString &p, const UString &f)
: pattern(p), flags(f) { }
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString pattern, flags;
};
public:
ThisNode() {}
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
};
class ResolveNode : public Node {
public:
ResolveNode(const UString *s) : ident(*s) { }
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
};
virtual bool deref();
virtual ~GroupNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const { group->streamTo(s); }
private:
Node *group;
};
virtual bool deref();
virtual ~ElisionNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ElisionNode *elision;
};
class ElementNode : public Node {
public:
- ElementNode(ElisionNode *e, Node *n) : list(0l), elision(e), node(n) { }
+ ElementNode(ElisionNode *e, Node *n) : list(0L), elision(e), node(n) { }
ElementNode(ElementNode *l, ElisionNode *e, Node *n)
: list(l), elision(e), node(n) { }
virtual void ref();
virtual bool deref();
virtual ~ElementNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ElementNode *list;
ElisionNode *elision;
virtual bool deref();
virtual ~ArrayNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ElementNode *element;
ElisionNode *elision;
virtual bool deref();
virtual ~ObjectLiteralNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *list;
};
virtual bool deref();
virtual ~PropertyValueNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *name, *assign, *list;
};
PropertyNode(double d) : numeric(d) { }
PropertyNode(const UString *s) : str(*s) { }
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
double numeric;
UString str;
virtual bool deref();
virtual ~AccessorNode1();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1;
Node *expr2;
virtual bool deref();
virtual ~AccessorNode2();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
UString ident;
virtual ~ArgumentListNode();
Value evaluate(ExecState *exec);
List evaluateList(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ArgumentListNode *list;
Node *expr;
virtual ~ArgumentsNode();
Value evaluate(ExecState *exec);
List evaluateList(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ArgumentListNode *list;
};
virtual bool deref();
virtual ~NewExprNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
ArgumentsNode *args;
virtual bool deref();
virtual ~FunctionCallNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
ArgumentsNode *args;
virtual bool deref();
virtual ~PostfixNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
Operator oper;
virtual bool deref();
virtual ~DeleteNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~VoidNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~TypeOfNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~PrefixNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Operator oper;
Node *expr;
virtual bool deref();
virtual ~UnaryPlusNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~NegateNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~BitwiseNotNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~LogicalNotNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual bool deref();
virtual ~MultNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *term1, *term2;
char oper;
virtual bool deref();
virtual ~AddNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *term1, *term2;
char oper;
virtual bool deref();
virtual ~ShiftNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *term1, *term2;
Operator oper;
virtual bool deref();
virtual ~RelationalNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
Operator oper;
virtual bool deref();
virtual ~EqualNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
Operator oper;
virtual bool deref();
virtual ~BitOperNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
Operator oper;
};
- /** expr1 && expr2, expr1 || expr2 */
+ /**
+ * expr1 && expr2, expr1 || expr2
+ */
class BinaryLogicalNode : public Node {
public:
BinaryLogicalNode(Node *e1, Operator o, Node *e2) :
virtual bool deref();
virtual ~BinaryLogicalNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
Operator oper;
};
- /** The ternary operator, "logical ? expr1 : expr2" */
+ /**
+ * The ternary operator, "logical ? expr1 : expr2"
+ */
class ConditionalNode : public Node {
public:
ConditionalNode(Node *l, Node *e1, Node *e2) :
virtual bool deref();
virtual ~ConditionalNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *logical, *expr1, *expr2;
};
virtual bool deref();
virtual ~AssignNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *left;
Operator oper;
virtual bool deref();
virtual ~CommaNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
};
virtual ~StatListNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
StatementNode *statement;
StatListNode *list;
virtual bool deref();
virtual ~AssignExprNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual ~VarDeclNode();
Value evaluate(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
AssignExprNode *init;
virtual ~VarDeclListNode();
Value evaluate(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *list;
VarDeclNode *var;
virtual ~VarStatementNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
VarDeclListNode *list;
};
virtual ~BlockNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
SourceElementsNode *source;
};
public:
EmptyStatementNode() { } // debug
virtual Completion execute(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
};
class ExprStatementNode : public StatementNode {
virtual bool deref();
virtual ~ExprStatementNode();
virtual Completion execute(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual ~IfNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
StatementNode *statement1, *statement2;
virtual ~DoWhileNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
StatementNode *statement;
Node *expr;
virtual ~WhileNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
StatementNode *statement;
virtual ~ForNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2, *expr3;
StatementNode *statement;
virtual ~ForInNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
AssignExprNode *init;
ContinueNode() { }
ContinueNode(const UString *i) : ident(*i) { }
virtual Completion execute(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
};
BreakNode() { }
BreakNode(const UString *i) : ident(*i) { }
virtual Completion execute(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
};
virtual bool deref();
virtual ~ReturnNode();
virtual Completion execute(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *value;
};
virtual ~WithNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
StatementNode *statement;
Value evaluate(ExecState *exec);
Completion evalStatements(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
StatListNode *list;
CaseClauseNode *clause() const { return cl; }
ClauseListNode *next() const { return nx; }
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
CaseClauseNode *cl;
ClauseListNode *nx;
Value evaluate(ExecState *exec);
Completion evalBlock(ExecState *exec, const Value& input);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ClauseListNode *list1;
CaseClauseNode *def;
virtual ~SwitchNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
CaseBlockNode *block;
virtual ~LabelNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString label;
StatementNode *statement;
virtual bool deref();
virtual ~ThrowNode();
virtual Completion execute(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
};
virtual Completion execute(ExecState *exec);
Completion execute(ExecState *exec, const Value &arg);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
StatementNode *block;
virtual ~FinallyNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
StatementNode *block;
};
virtual ~TryNode();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
StatementNode *block;
CatchNode *_catch;
Value evaluate(ExecState *exec);
UString ident() { return id; }
ParameterNode *nextParam() { return next; }
+ virtual void streamTo(SourceStream &s) const;
private:
UString id;
ParameterNode *next;
Completion execute(ExecState *exec);
virtual void processFuncDecl(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ void streamTo(SourceStream &s) const;
protected:
SourceElementsNode *source;
};
Completion execute(ExecState */*exec*/)
{ /* empty */ return Completion(); }
void processFuncDecl(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
UString ident;
ParameterNode *param;
virtual bool deref();
virtual ~FuncExprNode();
Value evaluate(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
ParameterNode *param;
FunctionBodyNode *body;
class SourceElementNode : public StatementNode {
public:
- SourceElementNode(StatementNode *s) { statement = s; function = 0L; }
- SourceElementNode(FuncDeclNode *f) { function = f; statement = 0L;}
+ SourceElementNode(StatementNode *s) : statement(s), function(0L) { }
+ SourceElementNode(FuncDeclNode *f) : statement(0L), function(f) { }
virtual void ref();
virtual bool deref();
virtual ~SourceElementNode();
Completion execute(ExecState *exec);
virtual void processFuncDecl(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
StatementNode *statement;
FuncDeclNode *function;
Completion execute(ExecState *exec);
virtual void processFuncDecl(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
+ virtual void streamTo(SourceStream &s) const;
private:
SourceElementNode *element; // 'this' element
SourceElementsNode *elements; // pointer to next
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include "value.h"
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _NUMBER_OBJECT_H_
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include "value.h"
return static_cast<ObjectImp*>(rep)->canPut(exec,propertyName);
}
-bool Object::hasProperty(ExecState *exec, const UString &propertyName, bool recursive) const
+bool Object::hasProperty(ExecState *exec, const UString &propertyName) const
{
- return static_cast<ObjectImp*>(rep)->hasProperty(exec,propertyName,recursive);
+ return static_cast<ObjectImp*>(rep)->hasProperty(exec, propertyName);
}
bool Object::deleteProperty(ExecState *exec, const UString &propertyName)
ObjectImp::ObjectImp(const Object &proto)
: _prop(0), _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(0)
{
- //fprintf(stderr,"ObjectImp::ObjectImp %p %s\n",(void*)this);
+ //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
_scope = ListImp::empty();
_prop = new PropertyMap();
}
ObjectImp::ObjectImp()
{
- //fprintf(stderr,"ObjectImp::ObjectImp %p %s\n",(void*)this);
+ //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
_prop = 0;
_proto = NullImp::staticNull;
_internalValue = 0L;
}
// ECMA 8.6.2.4
-bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName, bool recursive) const
+bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName) const
{
if (propertyName == "__proto__")
return true;
// Look in the prototype
Object proto = Object::dynamicCast(prototype());
- if (proto.isNull() || !recursive)
- return false;
-
- return proto.hasProperty(exec,propertyName);
+ return !proto.isNull() && proto.hasProperty(exec,propertyName);
}
// ECMA 8.6.2.5
}
// Look in the static hashtable of properties
- if (findPropertyHashEntry(propertyName))
- return false; // No builtin property can be deleted
+ const HashEntry* entry = findPropertyHashEntry(propertyName);
+ if (entry && entry->attr & DontDelete)
+ return false; // this builtin property can't be deleted
return true;
}
// ECMA 262-3 8.6.1
// Attributes (only applicable to the Object type)
enum Attribute { None = 0,
- ReadOnly = 1 << 1, // property can be only read, not written
- DontEnum = 1 << 2, // property doesn't appear in (for .. in ..)
- DontDelete = 1 << 3, // property can't be deleted
- Internal = 1 << 4, // an internal property, set to by pass checks
- Function = 1 << 5 }; // property is a function - only used by static hashtables
+ ReadOnly = 1 << 1, // property can be only read, not written
+ DontEnum = 1 << 2, // property doesn't appear in (for .. in ..)
+ DontDelete = 1 << 3, // property can't be deleted
+ Internal = 1 << 4, // an internal property, set to by pass checks
+ Function = 1 << 5 }; // property is a function - only used by static hashtables
/**
* Class Information
* @param propertyName The name of the property to check for
* @return true if the object has the property, otherwise false
*/
- bool hasProperty(ExecState *exec, const UString &propertyName,
- bool recursive = true) const;
+ bool hasProperty(ExecState *exec, const UString &propertyName) const;
/**
* Removes the specified property from the object.
*
* @see Object::hasProperty()
*/
- virtual bool hasProperty(ExecState *exec, const UString &propertyName,
- bool recursive = true) const;
+ virtual bool hasProperty(ExecState *exec,
+ const UString &propertyName) const;
/**
* Implementation of the [[Delete]] internal property (implemented by all
* should be used.
*/
enum ErrorType { GeneralError = 0,
- EvalError = 1,
- RangeError = 2,
- ReferenceError = 3,
- SyntaxError = 4,
- TypeError = 5,
- URIError = 6};
+ EvalError = 1,
+ RangeError = 2,
+ ReferenceError = 3,
+ SyntaxError = 4,
+ TypeError = 5,
+ URIError = 6};
/**
* @short Factory methods for error objects.
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include "value.h"
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _OBJECT_OBJECT_H_
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _KJS_OPERATIONS_H_
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include "property_map.h"
-#include <config.h>
-
#include <string.h>
#include <assert.h>
#include <stdio.h>
PropertyMap::~PropertyMap()
{
-#ifdef APPLE_CHANGES
clear();
-#endif
}
void PropertyMap::put(const UString &name, ValueImp *value, int attr)
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include <stdio.h>
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _KJS_REGEXP_H_
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#include <stdio.h>
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _REGEXP_OBJECT_H_
RegExpImp* imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
reg = imp->regExp();
}
- else if (a0.isA(StringType))
- {
- reg = new RegExp(a0.toString(exec), RegExp::None);
- }
else
- {
-#ifndef NDEBUG
- printf("KJS: Match/Search. Argument is not a RegExp nor a String - returning Undefined\n");
-#endif
- result = Undefined();
- break;
+ { /*
+ * ECMA 15.5.4.12 String.prototype.search (regexp)
+ * If regexp is not an object whose [[Class]] property is "RegExp", it is
+ * replaced with the result of the expression new RegExp(regexp).
+ */
+ reg = new RegExp(a0.toString(exec), RegExp::None);
}
RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp());
int **ovector = regExpObj->registerRegexp( reg, u );
global = true;
RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp());
- int **ovector = regExpObj->registerRegexp( reg, u );
int lastIndex = 0;
u3 = a1.toString(exec); // replacement string
// This is either a loop (if global is set) or a one-way (if not).
do {
+ int **ovector = regExpObj->registerRegexp( reg, u );
UString mstr = reg->match(u, lastIndex, &pos, ovector);
len = mstr.size();
- lastIndex = pos + u3.size();
+ UString rstr(u3);
+ bool ok;
+ // check if u3 matches $1 or $2 etc
+ for (int i = 0; (i = rstr.find(UString("$"), i)) != -1; i++) {
+ if (i+1<rstr.size() && rstr[i+1] == '$') { // "$$" -> "$"
+ rstr = rstr.substr(0,i) + "$" + rstr.substr(i+2);
+ continue;
+ }
+ // Assume number part is one char exactly
+ unsigned long pos = rstr.substr(i+1,1).toULong(&ok);
+ if (ok && pos <= (unsigned)reg->subPatterns()) {
+ rstr = rstr.substr(0,i)
+ + u.substr((*ovector)[2*pos],
+ (*ovector)[2*pos+1]-(*ovector)[2*pos])
+ + rstr.substr(i+2);
+ i += (*ovector)[2*pos+1]-(*ovector)[2*pos] - 1; // -1 offsets i++
+ }
+ }
+ lastIndex = pos + rstr.size();
if ( pos != -1 )
- u = u.substr(0, pos) + u3 + u.substr(pos + len);
+ u = u.substr(0, pos) + rstr + u.substr(pos + len);
//fprintf(stderr,"pos=%d,len=%d,lastIndex=%d,u=%s\n",pos,len,lastIndex,u.ascii());
} while ( global && pos != -1 );
i++;
}
}
- delete ovector;
+ delete [] ovector;
} else if (a0.type() != UndefinedType) {
u2 = a0.toString(exec);
if (u2.isEmpty()) {
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
*/
#ifndef _STRING_OBJECT_H_
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include <stdio.h>
// create interpreter
Interpreter interp(global);
+ // add debug() function
global.put(interp.globalExec(),"debug", Object(new TestFunctionImp()));
// add "print" for compatibility with the mozilla js shell
global.put(interp.globalExec(),"print", Object(new TestFunctionImp()));
- // add debug() function
- // kjs->enableDebug();
-
const int BufferSize = 200000;
char code[BufferSize];
FILE *f = fopen(file, "r");
if (!f) {
fprintf(stderr, "Error opening %s.\n", file);
- return -1;
+ return 2;
}
int num = fread(code, 1, BufferSize, f);
code[num] = '\0';
}
}
- // delete kjs;
} // end block, so that Interpreter and global get deleted
if (ret)
#ifdef KJS_DEBUG_MEM
Interpreter::finalCheck();
#endif
- return ret;
+ return ret ? 0 : 1;
}
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include "value.h"
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _KJS_TYPES_H_
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifdef HAVE_CONFIG_H
UString::UString(char c)
{
- rep = Rep::create(new UChar(0, c), 1);
+ UChar *d = new UChar[1];
+ d[0] = UChar(0, c);
+ rep = Rep::create(d, 1);
}
UString::UString(const char *c)
bool KJS::operator<(const UString& s1, const UString& s2)
{
- int l1 = s1.size();
- int l2 = s2.size();
+ const int l1 = s1.size();
+ const int l2 = s2.size();
+ const int lmin = l1 < l2 ? l1 : l2;
const UChar *c1 = s1.data();
const UChar *c2 = s2.data();
int l = 0;
- int le = l1 < l2 ? l1 : l2;
- while (l < le && *c1 == *c2) {
+ while (l < lmin && *c1 == *c2) {
c1++;
c2++;
l++;
}
- if (l != le)
+ if (l < lmin)
return (c1->unicode() < c2->unicode());
- return (l1 < l2 && !(*c1 == *c2));
+ return (l1 < l2);
}
UString KJS::operator+(const UString& s1, const UString& s2)
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _KJS_USTRING_H_
#define _KJS_USTRING_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef APPLE_CHANGES
#ifndef KWQ_UNSIGNED_TYPES_DEFINED
#define KWQ_UNSIGNED_TYPES_DEFINED
friend bool operator==(const UString& s1, const char *s2);
friend bool operator<(const UString& s1, const UString& s2);
- ushort uc;
+ unsigned short uc;
};
inline UChar::UChar() : uc(0) { }
// ------------------------------ ValueImp -------------------------------------
-ValueImp::ValueImp() : refcount(0), _flags(0)
-{
+ValueImp::ValueImp() :
+ refcount(0),
// Tell the garbage collector that this memory block corresponds to a real object now
- _flags |= VI_CREATED;
+ _flags(VI_CREATED)
+{
//fprintf(stderr,"ValueImp::ValueImp %p\n",(void*)this);
}
void ValueImp::setGcAllowed()
{
+ //fprintf(stderr,"ValueImp::setGcAllowed %p\n",(void*)this);
_flags |= VI_GCALLOWED;
}
#endif
-#include "ustring.h"
+#include <stdlib.h> // Needed for size_t
-#if APPLE_CHANGES
-#include <stdlib.h>
-#endif
+#include "ustring.h"
// Primitive data types
/**
* Performs the ToUint32 type conversion operation on this value (ECMA 9.6)
*/
- uint toUInt32(ExecState *exec) const;
+ unsigned int toUInt32(ExecState *exec) const;
/**
* Performs the ToUint16 type conversion operation on this value (ECMA 9.7)
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ Remove some minor gratuitous diffs vs. KDE.
+
+2002-04-15 Richard Williamson <rjw@apple.com>
+
+ Updated to reflect changes in KDE.
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/css/css_valueimpl.cpp:
+ (FontFamilyValueImpl::FontFamilyValueImpl): Fix comment.
+ * src/kdelibs/khtml/css/cssstyleselector.cpp: Remove some gratuitous diffs vs. KDE.
+ * src/kdelibs/khtml/html/html_objectimpl.cpp:
+ (HTMLEmbedElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
+ * src/kdelibs/khtml/html/html_tableimpl.cpp:
+ (HTMLTableElementImpl::parseAttribute),
+ (HTMLTablePartElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
+ * src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::processToken): Redo the
+ APPLE_CHANGES ifdef here.
+ * src/kdelibs/khtml/khtmlpart_p.h: Update to latest kde.
+ * src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::KHTMLView): Add ifdef APPLE_CHANGES.
+ (KHTMLView::~KHTMLView): Add ifdef APPLE_CHANGES.
+ (KHTMLView::print): Remove code left in here during merge process.
+ * src/kwq/KWQKHTMLPart.mm: Remove unused setFontSizes(), fontSizes(), and
+ resetFontSizes(). After the merge is landed, remove more.
+ * src/libwebcore.exp: Export updateStyleSelector() for WebKit.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Fix text to it displays at the right font size.
+
+ * src/kdelibs/khtml/css/cssstyleselector.cpp:
+ (CSSStyleSelector::computeFontSizes): Apply the same SCREEN_RESOLUTION hack here
+ that we do elsewhere.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::width): Use kMin instead of max (oops).
+ (Font::update): Turn off font database chicanery.
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::zoomFactor): Use zoom factor 100, not 1.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ More fixes so text displays (still at wrong font size).
+
+ * src/kdelibs/khtml/rendering/font.cpp: (max): New helper.
+ (Font::drawText): Simplified implementation for now.
+ (Font::width): Simplified implementation for now.
+ * src/kwq/KWQColorGroup.mm: Reinstated QCOLOR_GROUP_SIZE.
+
+ * src/kwq/qt/qfontmetrics.h: Removed charWidth and changed _width to take QChar *.
+ * src/kwq/KWQFontMetrics.mm: Removed charWidth and changed _width to take QChar *.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from KDE 3.0 final. Other fixes to get things compiling.
+
+ * src/kdelibs/khtml/css/css_valueimpl.cpp:
+ (CSSStyleDeclarationImpl::setProperty): Fix unused variable.
+ * src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::contentsContextMenuEvent):
+ Fix unused variable.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::drawText), (Font::width),
+ (Font::update): Disable special "nsbp" logic for now. We can reenable it
+ if necessary.
+ * src/kdelibs/khtml/rendering/render_replaced.cpp: Fix mismerge.
+ * src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::nodeAtPoint):
+ Fix unused variable.
+ * src/kwq/KWQApplication.mm: (QDesktopWidget::width), (QApplication::desktop):
+ Fix mismerge.
+ * src/kwq/KWQColorGroup.mm: Fix QCOLOR_GROUP_SIZE.
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::lineSpacing): New.
+ (QFontMetrics::width): Remove unused optimization.
+ * src/kwq/qt/qfontmetrics.h: Add lineSpacing().
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from previous merge pass.
+
+ 2002-03-25 Darin Adler <darin@apple.com>
+
+ Last bit of making stuff compile and link. Probably will drop the merge now
+ and take it up again when it's time to merge in KDE 3.0 final.
+
+ * src/kwq/KWQEvent.mm: (QFocusEvent::reason): New.
+ * src/kwq/KWQPainter.mm: (QPainter::drawText): New overload.
+
+ 2002-03-25 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::width): Make it call _width so we
+ don't lose the optimization.
+
+ * src/kwq/KWQApplication.mm: (QDesktopWidget::screenNumber): New.
+ (QDesktopWidget::screenGeometry): New.
+ (QApplication::style): New.
+ * src/kwq/KWQColorGroup.mm: (QColorGroup::highlight): New.
+ (QColorGroup::highlightedText): New.
+ * src/kwq/KWQFont.mm: (QFont::setPixelSize): New.
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::charWidth): New.
+ * src/kwq/KWQKGlobal.mm: (KGlobal::locale): Implement.
+ (KLocale::KLocale): New.
+ (KLocale::languageList): New.
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::sheetUsed): New.
+ (KHTMLPart::setSheetUsed): New.
+ (KHTMLPart::zoomFactor): New.
+ * src/kwq/KWQKHTMLSettings.mm: (KHTMLSettings::mediumFontSize): New.
+ * src/kwq/KWQScrollView.mm: (QScrollView::childX): New.
+ (QScrollView::childY): New.
+
+ * src/kwq/qt/qapplication.h: style() returns a QStyle &.
+ * src/kwq/qt/qpalette.h: Add Highlight and HighlightedText.
+
+ 2002-03-24 Darin Adler <darin@apple.com>
+
+ More compiling. Still won't link.
+
+ * src/kdelibs/khtml/khtmlview.cpp: Disable printing and drag and drop code.
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ Temporarily turn off our smarter underlining since it relies on access to the
+ string, and TextSlave doesn't have that any more.
+ (RenderText::nodeAtPoint): Get rid of a workaround we don't need any more for
+ a bug that was fixed by KDE folks.
+ * src/kwq/KWQApplication.mm: (QApplication::desktop): Make the desktop be a
+ QDesktopWidget.
+ * src/kwq/qt/qnamespace.h: Add MetaButton.
+ * src/kwq/qt/qtooltip.h: Add a maybeTip virtual function member and a virtual
+ destructor.
+
+ 2002-03-24 Darin Adler <darin@apple.com>
+
+ Some fixes to get more stuff to compile.
+
+ * src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMDocument::getValueProperty):
+ Don't try to look at the private m_bComplete to display "complete". Just do
+ "loading" and "loaded".
+ * src/kdelibs/khtml/khtmlpart_p.h: #ifdef this all out for APPLE_CHANGES.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::update): Add an explicit cast to
+ int to avoid float -> int warning.
+ * src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcColMinMax):
+ Add an explicit cast to int to avoid uint compared with int warning.
+ * src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyleSelector):
+ Use sheetUsed() and setSheetUsed() functions on KHTMLPart intead of getting
+ at private fields the way the real KDE code does.
+
+ * src/kwq/KWQKHTMLPart.h: Declare zoomFactor(), sheetUsed(), and setSheetUsed().
+ * src/kwq/KWQStyle.h: Add PM_DefaultFramWidth as another metric.
+ * src/kwq/kdecore/klocale.h: Add languageList().
+ * src/kwq/khtml/khtml_settings.h: Add mediumFontSize().
+ * src/kwq/qt/qapplication.h: Add style() and QDesktopWidget.
+ * src/kwq/qt/qevent.h: Add reason().
+ * src/kwq/qt/qfont.h: Add setPixelSize(int).
+ * src/kwq/qt/qfontmetrics.h: Add charWidth() and _charWidth() functions.
+ * src/kwq/qt/qpainter.h: Add drawText() overload with position parameter.
+ * src/kwq/qt/qpalette.h: Add highlight() and highlightedText().
+ * src/kwq/qt/qscrollview.h: Add childX() and childY().
+
+ * src/kwq/KWQApplication.mm: Change KWQDesktopWidget to QDesktopWidget.
+
2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
Added a symbol for WCPluginDatabase.
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ Remove some minor gratuitous diffs vs. KDE.
+
+2002-04-15 Richard Williamson <rjw@apple.com>
+
+ Updated to reflect changes in KDE.
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/css/css_valueimpl.cpp:
+ (FontFamilyValueImpl::FontFamilyValueImpl): Fix comment.
+ * src/kdelibs/khtml/css/cssstyleselector.cpp: Remove some gratuitous diffs vs. KDE.
+ * src/kdelibs/khtml/html/html_objectimpl.cpp:
+ (HTMLEmbedElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
+ * src/kdelibs/khtml/html/html_tableimpl.cpp:
+ (HTMLTableElementImpl::parseAttribute),
+ (HTMLTablePartElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
+ * src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::processToken): Redo the
+ APPLE_CHANGES ifdef here.
+ * src/kdelibs/khtml/khtmlpart_p.h: Update to latest kde.
+ * src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::KHTMLView): Add ifdef APPLE_CHANGES.
+ (KHTMLView::~KHTMLView): Add ifdef APPLE_CHANGES.
+ (KHTMLView::print): Remove code left in here during merge process.
+ * src/kwq/KWQKHTMLPart.mm: Remove unused setFontSizes(), fontSizes(), and
+ resetFontSizes(). After the merge is landed, remove more.
+ * src/libwebcore.exp: Export updateStyleSelector() for WebKit.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Fix text to it displays at the right font size.
+
+ * src/kdelibs/khtml/css/cssstyleselector.cpp:
+ (CSSStyleSelector::computeFontSizes): Apply the same SCREEN_RESOLUTION hack here
+ that we do elsewhere.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::width): Use kMin instead of max (oops).
+ (Font::update): Turn off font database chicanery.
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::zoomFactor): Use zoom factor 100, not 1.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ More fixes so text displays (still at wrong font size).
+
+ * src/kdelibs/khtml/rendering/font.cpp: (max): New helper.
+ (Font::drawText): Simplified implementation for now.
+ (Font::width): Simplified implementation for now.
+ * src/kwq/KWQColorGroup.mm: Reinstated QCOLOR_GROUP_SIZE.
+
+ * src/kwq/qt/qfontmetrics.h: Removed charWidth and changed _width to take QChar *.
+ * src/kwq/KWQFontMetrics.mm: Removed charWidth and changed _width to take QChar *.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from KDE 3.0 final. Other fixes to get things compiling.
+
+ * src/kdelibs/khtml/css/css_valueimpl.cpp:
+ (CSSStyleDeclarationImpl::setProperty): Fix unused variable.
+ * src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::contentsContextMenuEvent):
+ Fix unused variable.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::drawText), (Font::width),
+ (Font::update): Disable special "nsbp" logic for now. We can reenable it
+ if necessary.
+ * src/kdelibs/khtml/rendering/render_replaced.cpp: Fix mismerge.
+ * src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::nodeAtPoint):
+ Fix unused variable.
+ * src/kwq/KWQApplication.mm: (QDesktopWidget::width), (QApplication::desktop):
+ Fix mismerge.
+ * src/kwq/KWQColorGroup.mm: Fix QCOLOR_GROUP_SIZE.
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::lineSpacing): New.
+ (QFontMetrics::width): Remove unused optimization.
+ * src/kwq/qt/qfontmetrics.h: Add lineSpacing().
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from previous merge pass.
+
+ 2002-03-25 Darin Adler <darin@apple.com>
+
+ Last bit of making stuff compile and link. Probably will drop the merge now
+ and take it up again when it's time to merge in KDE 3.0 final.
+
+ * src/kwq/KWQEvent.mm: (QFocusEvent::reason): New.
+ * src/kwq/KWQPainter.mm: (QPainter::drawText): New overload.
+
+ 2002-03-25 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::width): Make it call _width so we
+ don't lose the optimization.
+
+ * src/kwq/KWQApplication.mm: (QDesktopWidget::screenNumber): New.
+ (QDesktopWidget::screenGeometry): New.
+ (QApplication::style): New.
+ * src/kwq/KWQColorGroup.mm: (QColorGroup::highlight): New.
+ (QColorGroup::highlightedText): New.
+ * src/kwq/KWQFont.mm: (QFont::setPixelSize): New.
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::charWidth): New.
+ * src/kwq/KWQKGlobal.mm: (KGlobal::locale): Implement.
+ (KLocale::KLocale): New.
+ (KLocale::languageList): New.
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::sheetUsed): New.
+ (KHTMLPart::setSheetUsed): New.
+ (KHTMLPart::zoomFactor): New.
+ * src/kwq/KWQKHTMLSettings.mm: (KHTMLSettings::mediumFontSize): New.
+ * src/kwq/KWQScrollView.mm: (QScrollView::childX): New.
+ (QScrollView::childY): New.
+
+ * src/kwq/qt/qapplication.h: style() returns a QStyle &.
+ * src/kwq/qt/qpalette.h: Add Highlight and HighlightedText.
+
+ 2002-03-24 Darin Adler <darin@apple.com>
+
+ More compiling. Still won't link.
+
+ * src/kdelibs/khtml/khtmlview.cpp: Disable printing and drag and drop code.
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ Temporarily turn off our smarter underlining since it relies on access to the
+ string, and TextSlave doesn't have that any more.
+ (RenderText::nodeAtPoint): Get rid of a workaround we don't need any more for
+ a bug that was fixed by KDE folks.
+ * src/kwq/KWQApplication.mm: (QApplication::desktop): Make the desktop be a
+ QDesktopWidget.
+ * src/kwq/qt/qnamespace.h: Add MetaButton.
+ * src/kwq/qt/qtooltip.h: Add a maybeTip virtual function member and a virtual
+ destructor.
+
+ 2002-03-24 Darin Adler <darin@apple.com>
+
+ Some fixes to get more stuff to compile.
+
+ * src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMDocument::getValueProperty):
+ Don't try to look at the private m_bComplete to display "complete". Just do
+ "loading" and "loaded".
+ * src/kdelibs/khtml/khtmlpart_p.h: #ifdef this all out for APPLE_CHANGES.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::update): Add an explicit cast to
+ int to avoid float -> int warning.
+ * src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcColMinMax):
+ Add an explicit cast to int to avoid uint compared with int warning.
+ * src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyleSelector):
+ Use sheetUsed() and setSheetUsed() functions on KHTMLPart intead of getting
+ at private fields the way the real KDE code does.
+
+ * src/kwq/KWQKHTMLPart.h: Declare zoomFactor(), sheetUsed(), and setSheetUsed().
+ * src/kwq/KWQStyle.h: Add PM_DefaultFramWidth as another metric.
+ * src/kwq/kdecore/klocale.h: Add languageList().
+ * src/kwq/khtml/khtml_settings.h: Add mediumFontSize().
+ * src/kwq/qt/qapplication.h: Add style() and QDesktopWidget.
+ * src/kwq/qt/qevent.h: Add reason().
+ * src/kwq/qt/qfont.h: Add setPixelSize(int).
+ * src/kwq/qt/qfontmetrics.h: Add charWidth() and _charWidth() functions.
+ * src/kwq/qt/qpainter.h: Add drawText() overload with position parameter.
+ * src/kwq/qt/qpalette.h: Add highlight() and highlightedText().
+ * src/kwq/qt/qscrollview.h: Add childX() and childY().
+
+ * src/kwq/KWQApplication.mm: Change KWQDesktopWidget to QDesktopWidget.
+
2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
Added a symbol for WCPluginDatabase.
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ Remove some minor gratuitous diffs vs. KDE.
+
+2002-04-15 Richard Williamson <rjw@apple.com>
+
+ Updated to reflect changes in KDE.
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/css/css_valueimpl.cpp:
+ (FontFamilyValueImpl::FontFamilyValueImpl): Fix comment.
+ * src/kdelibs/khtml/css/cssstyleselector.cpp: Remove some gratuitous diffs vs. KDE.
+ * src/kdelibs/khtml/html/html_objectimpl.cpp:
+ (HTMLEmbedElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
+ * src/kdelibs/khtml/html/html_tableimpl.cpp:
+ (HTMLTableElementImpl::parseAttribute),
+ (HTMLTablePartElementImpl::parseAttribute): Remove unneeded copy from KWQ's early days.
+ * src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::processToken): Redo the
+ APPLE_CHANGES ifdef here.
+ * src/kdelibs/khtml/khtmlpart_p.h: Update to latest kde.
+ * src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::KHTMLView): Add ifdef APPLE_CHANGES.
+ (KHTMLView::~KHTMLView): Add ifdef APPLE_CHANGES.
+ (KHTMLView::print): Remove code left in here during merge process.
+ * src/kwq/KWQKHTMLPart.mm: Remove unused setFontSizes(), fontSizes(), and
+ resetFontSizes(). After the merge is landed, remove more.
+ * src/libwebcore.exp: Export updateStyleSelector() for WebKit.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Fix text to it displays at the right font size.
+
+ * src/kdelibs/khtml/css/cssstyleselector.cpp:
+ (CSSStyleSelector::computeFontSizes): Apply the same SCREEN_RESOLUTION hack here
+ that we do elsewhere.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::width): Use kMin instead of max (oops).
+ (Font::update): Turn off font database chicanery.
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::zoomFactor): Use zoom factor 100, not 1.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ More fixes so text displays (still at wrong font size).
+
+ * src/kdelibs/khtml/rendering/font.cpp: (max): New helper.
+ (Font::drawText): Simplified implementation for now.
+ (Font::width): Simplified implementation for now.
+ * src/kwq/KWQColorGroup.mm: Reinstated QCOLOR_GROUP_SIZE.
+
+ * src/kwq/qt/qfontmetrics.h: Removed charWidth and changed _width to take QChar *.
+ * src/kwq/KWQFontMetrics.mm: Removed charWidth and changed _width to take QChar *.
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from KDE 3.0 final. Other fixes to get things compiling.
+
+ * src/kdelibs/khtml/css/css_valueimpl.cpp:
+ (CSSStyleDeclarationImpl::setProperty): Fix unused variable.
+ * src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::contentsContextMenuEvent):
+ Fix unused variable.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::drawText), (Font::width),
+ (Font::update): Disable special "nsbp" logic for now. We can reenable it
+ if necessary.
+ * src/kdelibs/khtml/rendering/render_replaced.cpp: Fix mismerge.
+ * src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::nodeAtPoint):
+ Fix unused variable.
+ * src/kwq/KWQApplication.mm: (QDesktopWidget::width), (QApplication::desktop):
+ Fix mismerge.
+ * src/kwq/KWQColorGroup.mm: Fix QCOLOR_GROUP_SIZE.
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::lineSpacing): New.
+ (QFontMetrics::width): Remove unused optimization.
+ * src/kwq/qt/qfontmetrics.h: Add lineSpacing().
+
+2002-04-15 Darin Adler <darin@apple.com>
+
+ Merged changes from previous merge pass.
+
+ 2002-03-25 Darin Adler <darin@apple.com>
+
+ Last bit of making stuff compile and link. Probably will drop the merge now
+ and take it up again when it's time to merge in KDE 3.0 final.
+
+ * src/kwq/KWQEvent.mm: (QFocusEvent::reason): New.
+ * src/kwq/KWQPainter.mm: (QPainter::drawText): New overload.
+
+ 2002-03-25 Darin Adler <darin@apple.com>
+
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::width): Make it call _width so we
+ don't lose the optimization.
+
+ * src/kwq/KWQApplication.mm: (QDesktopWidget::screenNumber): New.
+ (QDesktopWidget::screenGeometry): New.
+ (QApplication::style): New.
+ * src/kwq/KWQColorGroup.mm: (QColorGroup::highlight): New.
+ (QColorGroup::highlightedText): New.
+ * src/kwq/KWQFont.mm: (QFont::setPixelSize): New.
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::charWidth): New.
+ * src/kwq/KWQKGlobal.mm: (KGlobal::locale): Implement.
+ (KLocale::KLocale): New.
+ (KLocale::languageList): New.
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::sheetUsed): New.
+ (KHTMLPart::setSheetUsed): New.
+ (KHTMLPart::zoomFactor): New.
+ * src/kwq/KWQKHTMLSettings.mm: (KHTMLSettings::mediumFontSize): New.
+ * src/kwq/KWQScrollView.mm: (QScrollView::childX): New.
+ (QScrollView::childY): New.
+
+ * src/kwq/qt/qapplication.h: style() returns a QStyle &.
+ * src/kwq/qt/qpalette.h: Add Highlight and HighlightedText.
+
+ 2002-03-24 Darin Adler <darin@apple.com>
+
+ More compiling. Still won't link.
+
+ * src/kdelibs/khtml/khtmlview.cpp: Disable printing and drag and drop code.
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ Temporarily turn off our smarter underlining since it relies on access to the
+ string, and TextSlave doesn't have that any more.
+ (RenderText::nodeAtPoint): Get rid of a workaround we don't need any more for
+ a bug that was fixed by KDE folks.
+ * src/kwq/KWQApplication.mm: (QApplication::desktop): Make the desktop be a
+ QDesktopWidget.
+ * src/kwq/qt/qnamespace.h: Add MetaButton.
+ * src/kwq/qt/qtooltip.h: Add a maybeTip virtual function member and a virtual
+ destructor.
+
+ 2002-03-24 Darin Adler <darin@apple.com>
+
+ Some fixes to get more stuff to compile.
+
+ * src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMDocument::getValueProperty):
+ Don't try to look at the private m_bComplete to display "complete". Just do
+ "loading" and "loaded".
+ * src/kdelibs/khtml/khtmlpart_p.h: #ifdef this all out for APPLE_CHANGES.
+ * src/kdelibs/khtml/rendering/font.cpp: (Font::update): Add an explicit cast to
+ int to avoid float -> int warning.
+ * src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcColMinMax):
+ Add an explicit cast to int to avoid uint compared with int warning.
+ * src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyleSelector):
+ Use sheetUsed() and setSheetUsed() functions on KHTMLPart intead of getting
+ at private fields the way the real KDE code does.
+
+ * src/kwq/KWQKHTMLPart.h: Declare zoomFactor(), sheetUsed(), and setSheetUsed().
+ * src/kwq/KWQStyle.h: Add PM_DefaultFramWidth as another metric.
+ * src/kwq/kdecore/klocale.h: Add languageList().
+ * src/kwq/khtml/khtml_settings.h: Add mediumFontSize().
+ * src/kwq/qt/qapplication.h: Add style() and QDesktopWidget.
+ * src/kwq/qt/qevent.h: Add reason().
+ * src/kwq/qt/qfont.h: Add setPixelSize(int).
+ * src/kwq/qt/qfontmetrics.h: Add charWidth() and _charWidth() functions.
+ * src/kwq/qt/qpainter.h: Add drawText() overload with position parameter.
+ * src/kwq/qt/qpalette.h: Add highlight() and highlightedText().
+ * src/kwq/qt/qscrollview.h: Add childX() and childY().
+
+ * src/kwq/KWQApplication.mm: Change KWQDesktopWidget to QDesktopWidget.
+
2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
Added a symbol for WCPluginDatabase.
CSSMediaRuleImpl::~CSSMediaRuleImpl()
{
- if( m_lstMedia )
+ if( m_lstMedia ) {
+ m_lstMedia->setParent( 0 );
m_lstMedia->deref();
+ }
m_lstCSSRules->deref();
}
DOM::DOMString CSSStyleRuleImpl::selectorText() const
{
- if ( m_selector ) {
+ if ( m_selector && m_selector->first() ) {
// ### m_selector will be a single selector hopefully. so ->first() will disappear
CSSSelector* cs = m_selector->first();
- DOMString str;
- if ( cs->tag == -1 && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
- {
- str = "#";
- str += cs->value;
- }
- else if ( cs->tag == -1 && cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
- {
- str = ".";
- str += cs->value;
- }
- else if ( cs->tag == -1 && cs->match == CSSSelector::Pseudo )
- {
- str = ":";
- str += cs->value;
- }
- else
- {
- if ( cs->tag == -1 )
- str = "*";
- else
- str = getTagName( cs->tag );
- // optional attribute
- if ( cs->attr ) {
- DOMString attrName = getAttrName( cs->attr );
- str += "[";
- str += attrName;
- switch (cs->match) {
- case CSSSelector::Exact:
- str += "=";
- break;
- case CSSSelector::Set:
- str += " "; /// ## correct?
- break;
- case CSSSelector::List:
- str += "~=";
- break;
- case CSSSelector::Hyphen:
- str += "|=";
- break;
- case CSSSelector::Begin:
- str += "^=";
- break;
- case CSSSelector::End:
- str += "$=";
- break;
- case CSSSelector::Contain:
- str += "*=";
- break;
- default:
- kdWarning(6080) << "Unhandled case in CSSStyleRuleImpl::selectorText : match=" << cs->match << endl;
- }
- str += "\"";
- str += cs->value;
- str += "\"]";
- }
- }
+ cs->print(); // debug
+ DOMString str = cs->selectorText();
return str;
}
return DOMString();
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _CSS_css_ruleimpl_h_
#define _CSS_css_ruleimpl_h_
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
//#define CSS_STYLESHEET_DEBUG
StyleSheetImpl::~StyleSheetImpl()
{
- if(m_media) m_media->deref();
+ if(m_media) {
+ m_media->setParent( 0 );
+ m_media->deref();
+ }
}
bool StyleSheetImpl::deleteMe()
void StyleSheetImpl::setMedia( MediaListImpl *media )
{
+ if( media )
+ media->ref();
if( m_media )
- m_media->deref();
+ m_media->deref();
m_media = media;
- if( m_media )
- m_media->ref();
}
// -----------------------------------------------------------------------
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _CSS_css_stylesheetimpl_h_
#define _CSS_css_stylesheetimpl_h_
#include "css/cssvalues.h"
#include "xml/dom_stringimpl.h"
-#include "xml/dom_nodeimpl.h"
+#include "xml/dom_docimpl.h"
#include "misc/loader.h"
+#include "rendering/render_style.h"
+
#include <kdebug.h>
#include <qregexp.h>
+#include <qpaintdevice.h>
+#include <qpaintdevicemetrics.h>
// Hack for debugging purposes
extern DOM::DOMString getPropertyName(unsigned short id);
m_node = 0;
}
+CSSStyleDeclarationImpl& CSSStyleDeclarationImpl::operator= (const CSSStyleDeclarationImpl& o)
+{
+ // don't attach it to the same node, just leave the current m_node value
+ delete m_lstValues;
+ m_lstValues = 0;
+ if (o.m_lstValues) {
+ m_lstValues = new QPtrList<CSSProperty>;
+ m_lstValues->setAutoDelete( true );
+
+ QPtrListIterator<CSSProperty> lstValuesIt(*o.m_lstValues);
+ for (lstValuesIt.toFirst(); lstValuesIt.current(); ++lstValuesIt)
+ m_lstValues->append(new CSSProperty(*lstValuesIt.current()));
+ }
+
+ return *this;
+}
+
CSSStyleDeclarationImpl::~CSSStyleDeclarationImpl()
{
delete m_lstValues;
for (lstValuesIt.toLast(); lstValuesIt.current(); --lstValuesIt)
if (lstValuesIt.current()->m_id == propertyID && !lstValuesIt.current()->nonCSSHint)
return lstValuesIt.current()->value();
-#if APPLE_CHANGES
return 0;
-#endif
}
DOMString CSSStyleDeclarationImpl::removeProperty( int propertyID, bool NonCSSHint )
if (lstValuesIt.current()->m_id == propertyID && NonCSSHint == lstValuesIt.current()->nonCSSHint) {
value = lstValuesIt.current()->value()->cssText();
m_lstValues->removeRef(lstValuesIt.current());
- if (m_node)
- m_node->setChanged(true);
+ setChanged();
+
return value;
}
return value;
}
+void CSSStyleDeclarationImpl::setChanged()
+{
+ if (m_node) {
+ m_node->setChanged();
+ return;
+ }
+
+ // ### quick&dirty hack for KDE 3.0... make this MUCH better! (Dirk)
+ for (StyleBaseImpl* stylesheet = this; stylesheet; stylesheet = stylesheet->parent())
+ if (stylesheet->isCSSStyleSheet()) {
+ static_cast<CSSStyleSheetImpl*>(stylesheet)->doc()->updateStyleSelector();
+ break;
+ }
+}
+
bool CSSStyleDeclarationImpl::getPropertyPriority( int propertyID )
{
if(!m_lstValues) return false;
if(!success)
kdDebug( 6080 ) << "CSSStyleDeclarationImpl::setProperty invalid property: [" << getPropertyName(id).string()
<< "] value: [" << value.string() << "]"<< endl;
- if (m_node)
- m_node->setChanged(true);
+ else
+ setChanged();
}
void CSSStyleDeclarationImpl::setProperty(int id, int value, bool important, bool nonCSSHint)
CSSValueImpl * cssValue = new CSSPrimitiveValueImpl(value);
setParsedValue(id, cssValue, important, nonCSSHint, m_lstValues);
-
- if (m_node)
- m_node->setChanged(true);
+ setChanged();
}
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
props->setAutoDelete(false);
+#ifndef APPLE_CHANGES
unsigned int i = 0;
+#endif
if(!m_lstValues) {
m_lstValues = new QPtrList<CSSProperty>;
m_lstValues->setAutoDelete( true );
}
- while(i < props->count())
- {
+
+ for (unsigned int i = 0; i < props->count(); ++i) {
//kdDebug( 6080 ) << "setting property" << endl;
CSSProperty *prop = props->at(i);
removeProperty(prop->m_id, false);
m_lstValues->append(prop);
- i++;
}
delete props;
- if (m_node)
- m_node->setChanged(true);
+ setChanged();
}
void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint)
m_type = 0;
}
+int CSSPrimitiveValueImpl::computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics )
+{
+ return ( int ) computeLengthFloat( style, devMetrics );
+}
+
+float CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics )
+{
+ unsigned short type = primitiveType();
+
+ float dpiY = 72.; // fallback
+ if ( devMetrics )
+ dpiY = devMetrics->logicalDpiY();
+#ifdef APPLE_CHANGES
+ // FIXME: SCREEN_RESOLUTION hack good enough to keep?
+ if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
+ dpiY = SCREEN_RESOLUTION;
+#else /* APPLE_CHANGES not defined */
+ if ( !khtml::printpainter && dpiY < 96 )
+ dpiY = 96.;
+#endif /* APPLE_CHANGES not defined */
+
+ float factor = 1.;
+ switch(type)
+ {
+ case CSSPrimitiveValue::CSS_EMS:
+ factor = style->font().pixelSize();
+ break;
+ case CSSPrimitiveValue::CSS_EXS:
+ {
+ QFontMetrics fm = style->fontMetrics();
+ QRect b = fm.boundingRect('x');
+ factor = b.height();
+ break;
+ }
+ case CSSPrimitiveValue::CSS_PX:
+ break;
+ case CSSPrimitiveValue::CSS_CM:
+ factor = dpiY/2.54; //72dpi/(2.54 cm/in)
+ break;
+ case CSSPrimitiveValue::CSS_MM:
+ factor = dpiY/25.4;
+ break;
+ case CSSPrimitiveValue::CSS_IN:
+ factor = dpiY;
+ break;
+ case CSSPrimitiveValue::CSS_PT:
+ factor = dpiY/72.;
+ break;
+ case CSSPrimitiveValue::CSS_PC:
+ // 1 pc == 12 pt
+ factor = dpiY*12./72.;
+ break;
+ default:
+ return -1;
+ }
+ return getFloatValue(type)*factor;
+}
+
void CSSPrimitiveValueImpl::setFloatValue( unsigned short unitType, float floatValue, int &exceptioncode )
{
exceptioncode = 0;
{
#ifdef APPLE_CHANGES
parsedFontName = string;
+ // a language tag is often added in braces at the end. Remove it.
parsedFontName.replace(QRegExp(" \\(.*\\)$"), "");
+ // remove [Xft] qualifiers
+ parsedFontName.replace(QRegExp(" \\[.*\\]$"), "");
#else
const QString &available = KHTMLSettings::availableFamilies();
QString face = string.lower();
// a languge tag is often added in braces at the end. Remove it.
face = face.replace(QRegExp(" \\(.*\\)$"), "");
- parsedFontName = face;
+ // remove [Xft] qualifiers
+ face = face.replace(QRegExp(" \\[.*\\]$"), "");
//kdDebug(0) << "searching for face '" << face << "'" << endl;
if(face == "serif" ||
face == "sans-serif" ||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef _CSS_css_valueimpl_h_
#define _CSS_css_valueimpl_h_
#include <qintdict.h>
namespace khtml {
+ class RenderStyle;
class CachedImage;
};
public:
CSSStyleDeclarationImpl(CSSRuleImpl *parentRule);
CSSStyleDeclarationImpl(CSSRuleImpl *parentRule, QPtrList<CSSProperty> *lstValues);
-
virtual ~CSSStyleDeclarationImpl();
+ CSSStyleDeclarationImpl& operator=( const CSSStyleDeclarationImpl&);
+
unsigned long length() const;
CSSRuleImpl *parentRule() const;
DOM::DOMString removeProperty( int propertyID, bool NonCSSHints = false );
QPtrList<CSSProperty> *values() { return m_lstValues; }
void setNode(NodeImpl *_node) { m_node = _node; }
+ void setChanged();
+
protected:
QPtrList<CSSProperty> *m_lstValues;
NodeImpl *m_node;
+
+private:
+ // currently not needed - make sure its not used
+ CSSStyleDeclarationImpl(const CSSStyleDeclarationImpl& o);
};
class CSSValueImpl : public StyleBaseImpl
return m_type;
}
+ /*
+ * computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
+ * the fontinfo in case val is defined in em or ex.
+ *
+ * The metrics have to be a bit different for screen and printer output.
+ * For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
+ *
+ * this is screen/printer dependent, so we probably need a config option for this,
+ * and some tool to calibrate.
+ */
+ int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
+
+ float computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
+
+
// use with care!!!
void setPrimitiveType(unsigned short type) { m_type = type; }
void setFloatValue ( unsigned short unitType, float floatValue, int &exceptioncode );
CSSProperty()
{
m_id = -1;
- m_value = 0;
m_bImportant = false;
nonCSSHint = false;
+ m_value = 0;
+ }
+ CSSProperty(const CSSProperty& o)
+ {
+ m_id = o.m_id;
+ m_bImportant = o.m_bImportant;
+ nonCSSHint = o.nonCSSHint;
+ m_value = o.m_value;
+ if (m_value) m_value->ref();
}
~CSSProperty() {
if(m_value) m_value->deref();
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include "csshelper.h"
using namespace DOM;
using namespace khtml;
-int khtml::computeLength(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics )
-{
- return ( int ) computeLengthFloat( val, style, devMetrics );
-}
-
-float khtml::computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics )
-{
- unsigned short type = val->primitiveType();
-
- float dpiY = 72.; // fallback
- if ( devMetrics )
- dpiY = devMetrics->logicalDpiY();
-#ifdef APPLE_CHANGES
- // FIXME: SCREEN_RESOLUTION hack good enough to keep?
- if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
- dpiY = SCREEN_RESOLUTION;
-#else /* APPLE_CHANGES not defined */
- if ( !khtml::printpainter && dpiY < 96 )
- dpiY = 96.;
-#endif /* APPLE_CHANGES not defined */
-
- float factor = 1.;
- switch(type)
- {
- case CSSPrimitiveValue::CSS_EMS:
- factor = style->font().pixelSize();
- break;
- case CSSPrimitiveValue::CSS_EXS:
- {
- QFontMetrics fm = style->fontMetrics();
- QRect b = fm.boundingRect('x');
- factor = b.height();
- break;
- }
- case CSSPrimitiveValue::CSS_PX:
- break;
- case CSSPrimitiveValue::CSS_CM:
- factor = dpiY/2.54; //72dpi/(2.54 cm/in)
- break;
- case CSSPrimitiveValue::CSS_MM:
- factor = dpiY/25.4;
- break;
- case CSSPrimitiveValue::CSS_IN:
- factor = dpiY;
- break;
- case CSSPrimitiveValue::CSS_PT:
- factor = dpiY/72.;
- break;
- case CSSPrimitiveValue::CSS_PC:
- // 1 pc == 12 pt
- factor = dpiY*12./72.;
- break;
- default:
- return -1;
- }
- return val->getFloatValue(type)*factor;
-}
DOMString khtml::parseURL(const DOMString &url)
{
return j;
}
-
-
-void khtml::setFontSize( QFont &f, int pixelsize, const KHTMLSettings *s, QPaintDeviceMetrics *devMetrics )
-{
-#ifndef APPLE_CHANGES
- QFontDatabase db;
-#endif /* APPLE_CHANGES not defined */
-
- float size = pixelsize;
-
-#ifndef APPLE_CHANGES
- float toPix = devMetrics->logicalDpiY()/72.;
-
- // ok, now some magic to get a nice unscaled font
- // ### all other font properties should be set before this one!!!!
- // ####### make it use the charset needed!!!!
-
- if( !db.isSmoothlyScalable(f.family(), db.styleString(f)) )
- {
- QValueList<int> pointSizes = db.smoothSizes(f.family(), db.styleString(f));
- // lets see if we find a nice looking font, which is not too far away
- // from the requested one.
- //kdDebug(6080) << "khtml::setFontSize family = " << f.family() << " size requested=" << size << endl;
-
- QValueList<int>::Iterator it;
- float diff = 1; // ### 100% deviation
- float bestSize = 0;
- for( it = pointSizes.begin(); it != pointSizes.end(); ++it )
- {
- float newDiff = ((*it)*toPix - size)/size;
- //kdDebug( 6080 ) << "smooth font size: " << *it << " diff=" << newDiff << endl;
- if(newDiff < 0) newDiff = -newDiff;
- if(newDiff < diff)
- {
- diff = newDiff;
- bestSize = *it;
- }
- }
- //kdDebug( 6080 ) << "best smooth font size: " << bestSize << " diff=" << diff << endl;
- if ( bestSize != 0 && diff < 0.2 ) // 20% deviation, otherwise we use a scaled font...
- size = bestSize*toPix;
-// else if ( size > 4 && size < 16 )
-// size = float( int( ( size + 1 ) / 2 )*2 );
- }
-#endif /* APPLE_CHANGES not defined */
-
- //qDebug(" -->>> using %f pixel font", size);
-
- f.setPixelSizeFloat( size );
-}
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#ifndef css_helper_h
#define css_helper_h
{
class RenderStyle;
- /*
- * computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
- * the fontinfo in case val is defined in em or ex.
- *
- * The metrics have to be a bit different for screen and printer output.
- * For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
- *
- * this is screen/printer dependent, so we probably need a config option for this,
- * and some tool to calibrate.
- */
- int computeLength(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics );
-
- float computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics );
-
/*
* mostly just removes the url("...") brace
*/
DOM::DOMString parseURL(const DOM::DOMString &url);
- /*
- Sets the font to the size closest to the requested one while trying not to use a scaled bitmap font
- */
- void setFontSize( QFont &f, int pixelSize, const KHTMLSettings *s, QPaintDeviceMetrics *devMetrics );
-
};
last = false;
const QChar *nextP = curP;
bool ignoreSpace = false;
- while(nextP <= endP) {
+ while(nextP < endP) {
if ( *nextP == '(' ) {
ignoreSpace = true;
} else if ( *nextP == ')' ) {
ignoreSpace = false;
}
- if ( *nextP == ' ' && !ignoreSpace ) {
- if (nextP == endP) {
- last = true;
- }
- break;
- }
- if ( *nextP == ';' || nextP == endP ) {
- last = true;
- break;
- }
+ if ( *nextP == ' ' && !ignoreSpace )
+ return nextP;
+ if ( *nextP == ';')
+ break;
nextP++;
}
+ last = true;
return nextP;
}
// ------------------- begin font property ---------------------
{
if (cssval) {
int id = cssval->id;
- if (id >= CSS_VAL_LEFT && id <= CSS_VAL__KONQ_CENTER) {
+ if (id >= CSS_VAL__KONQ_AUTO && id <= CSS_VAL__KONQ_CENTER) {
parsedValue = new CSSPrimitiveValueImpl(id);
break;
}
} else {
const QString str(value.stripWhiteSpace()); // ### Optimize
if (str.left(4).lower() == "url(") {
- DOMString value(curP, endP - curP);
- value = khtml::parseURL(value);
- parsedValue = new CSSImageValueImpl(value, this);
+ DOMString value(curP, endP - curP);
+ value = khtml::parseURL(value);
+ if (!value.isEmpty())
+ parsedValue = new CSSImageValueImpl(DOMString(KURL(baseURL().string(), value.string()).url()), this);
#ifdef CSS_DEBUG
kdDebug( 6080 ) << "image, url=" << value.string() << " base=" << baseURL().string() << endl;
#endif
case CSS_PROP_TEXT_DECORATION:
// none | [ underline || overline || line-through || blink ] | inherit
{
- if (cssval) {
- if (cssval->id == CSS_VAL_NONE) {
+ if (cssval && cssval->id == CSS_VAL_NONE) {
parsedValue = new CSSPrimitiveValueImpl(cssval->id);
} else {
CSSValueListImpl *list = new CSSValueListImpl;
value.simplifyWhiteSpace();
- //kdDebug( 6080 ) << "text-decoration: '" << str << "'" << endl;
+ //kdDebug( 6080 ) << "text-decoration: '" << value << "'" << endl;
int pos=0, pos2;
while( 1 )
{
delete list;
}
}
- }
break;
}
case CSS_PROP__KONQ_FLOW_MODE:
} else {
DOMString value(curP, endP - curP);
value = khtml::parseURL(value);
- parsedValue = new CSSPrimitiveValueImpl(value, CSSPrimitiveValue::CSS_URI);
+ parsedValue = new CSSPrimitiveValueImpl(
+ DOMString(KURL(baseURL(), value).url()),
+ CSSPrimitiveValue::CSS_URI);
}
break;
}
m_propList->append(prop);
#ifdef CSS_DEBUG
kdDebug( 6080 ) << "added property: " << getPropertyName(propId).string()
- << ", value: " << parsedValue->cssText().string()
+ // non implemented yet << ", value: " << parsedValue->cssText().string()
<< " important: " << prop->m_bImportant
<< " nonCSS: " << prop->nonCSSHint << endl;
#endif
fnd[i] = false;
#ifdef CSS_DEBUG
- kdDebug(6080) << "PSH: parsing \"" << QString(curP, endP - curP) << "\"" << endl;
+ kdDebug(6080) << "PSH: parsing \"" << QString(curP, endP - curP) << "\" num=" << num << endl;
#endif
for (int j = 0; j < num; ++j) {
for (int propIndex = 0; propIndex < num; ++propIndex) {
if (!fnd[propIndex]) {
// We have to tread this seperately
+ //kdDebug(6080) << "LOOKING FOR: " << getPropertyName(properties[propIndex]).string() << endl;
bool found = false;
if (!isLast && properties[propIndex] == CSS_PROP_BACKGROUND_POSITION)
found = parseBackgroundPosition(curP, nextP, endP);
// We have not found a pair of Background-Positions, see if we have a single value
//kdDebug(6080) << "BKCGR: Single: \"" << QString(curP, nextP - curP) << "\"" << endl;
- found = parseValue(curP, bckgrNextP, CSS_PROP_BACKGROUND_POSITION);
+ found = parseValue(curP, nextP, CSS_PROP_BACKGROUND_POSITION);
} else {
// Moving on
nextP = bckgrNextP;
CSSValueImpl* StyleBaseImpl::parseContent(const QChar *curP, const QChar *endP)
{
CSSValueListImpl* values = new CSSValueListImpl();
-
+
QPtrList<QChar> list = splitContent(curP, endP);
-#if APPLE_CHANGES
- for(unsigned n=0; n<list.count(); n+=2)
-#else
- for(int n=0; n<list.count(); n+=2)
-#endif
+ for(uint n=0; n<list.count(); n+=2)
{
QString str(list.at(n), list.at(n+1)-list.at(n));
CSSValueImpl* parsedValue=0;
// url
DOMString value(curP, endP - curP);
value = khtml::parseURL(value);
- parsedValue = new CSSImageValueImpl(value, this);
+ parsedValue = new CSSImageValueImpl(
+ DOMString(KURL(baseURL().string(), value.string()).url()), this);
#ifdef CSS_DEBUG
kdDebug( 6080 ) << "content, url=" << value.string() << " base=" << baseURL().string() << endl;
#endif
else if (str.left(5) == "attr(")
{
// attr
- }
+ }
else if (str.left(8) == "counter(")
{
// counter
- }
+ }
else if (str == "open-quote")
{
// open-quote
- }
+ }
else if (str == "close-quote")
{
// open-quote
- }
+ }
else if (str == "no-open-quote")
{
// no-open-quote
- }
- else if (str == "no-close-quote")
+ }
+ else if (str == "no-close-quote")
{
// no-close-quote
- }
+ }
else
{
// string
}
return values;
-}
-
+}
+
QPtrList<QChar> StyleBaseImpl::splitContent(const QChar *curP, const QChar *endP)
while(!last) {
const QChar *nextP = curP;
bool q = false;
- bool dq = false;
+ bool dq = false;
if(*nextP=='\'')
q=true;
else if (*nextP=='\"')
dq=true;
- while(!(nextP->isSpace()) || q || dq) {
+ while(!(nextP->isSpace()) || q || dq) {
nextP++;
if(nextP >= endP){
last = true;
nextP++;
if(nextP >= endP) last= true;
break;
- }
+ }
}
-
+
list.append(curP+((q||dq)?1:0));
list.append(nextP-((q||dq)?1:0));
-
+
if ( last ) break;
while(nextP->isSpace()) { // skip over WS between tokens
nextP++;
kdDebug( 6080 ) << "parse rule: current = " << curP->latin1() << endl;
#endif
- if (*curP == '@' )
+ if (*curP == '@' && curP != endP && ( (curP+1)->isLetter() || (curP+1)->unicode() > 0xa0 ) )
{
rule = parseAtRule(curP, endP);
}
bool dq = false; // Within double quote
bool bracket = false; // Within brackets, e.g. url(ThisIsStupid)
bool comment = false; // Within comment
+ bool skipgarbage = !justOneRule; // skip <!-- and ---> only in specifc places
bool firstChar = false; // Beginning of comment either /* or */
bool space = true; // Last token was space
int curlyBracket = 0; // Within curlyBrackets -> lower
kdDebug(6080) << "Length: " << orgLength << endl;
#endif
- if (!(justOneRule)) {
- /* Remove start of SGML Comment which hides CSS from 3.0 Browsers */
- while((ch < last) && (ch->isSpace())) { ++ch; }
- if ((*ch == '<') && ((ch+4) < last) &&
- (*(ch+1) == '!') && (*(ch+2) == '-') && (*(ch+3) == '-')) {
- ch = ch+4; //skip '<!--'
- }
-
- /* Remove end of SGML Comment which hides CSS from 3.0 Browsers */
- while ((last > ch) && ((last-1)->isSpace())) { --last; }
- if ((*(last-1) == '>') && ((last-3) > ch) &&
- (*(last-2) == '-') && (*(last-3) == '-')) {
- last = last-3; //skip '-->'
- }
- }
-
while(ch < last) {
+// qDebug("current: *%s*, sq=%d dq=%d b=%d c=%d fC=%d space=%d cB=%d sg=%d",
+// QConstString(ch, kMin(last-ch, 10)).string().latin1(), sq, dq, bracket, comment, firstChar, space, curlyBracket, skipgarbage);
if( !comment && !sq && *ch == '"' ) {
dq = !dq;
processed += *ch;
- space = false;
+ space = skipgarbage = false;
} else if ( !comment && !dq && *ch == '\'') {
+ skipgarbage = sq;
sq = !sq;
processed += *ch;
space = false;
bracket = true;
processed += *ch;
space = true; // Explictly true
+ skipgarbage = false;
} else if ( !comment && !dq && !sq && *ch == ')') {
bracket = false;
processed += *ch;
processed += QChar(' '); // Adding a space after this token
space = true;
+ skipgarbage = false;
} else if ( !comment && !dq && !sq && *ch == '{') {
++curlyBracket;
processed += *ch;
space = true; // Explictly true
+ skipgarbage = true;
} else if ( !comment && !dq && !sq && *ch == '}') {
--curlyBracket;
processed += *ch;
processed += QChar(' '); // Adding a space after this token
space = true;
+ skipgarbage = true;
+ } else if ( !comment && skipgarbage && !dq && !sq && (*ch == '-') && ((ch+2) < last) /* SGML Comment */
+ && (*(ch+1) == '-') && (*(ch+2) == '>')) {
+ ch += 2; // skip -->
+ } else if ( !comment && skipgarbage && !dq && !sq && (*ch == '<') && ((ch+3) < last) /* SGML Comment */
+ && (*(ch+1) == '!') && (*(ch+2) == '-') && (*(ch+3) == '-')) {
+ ch += 3; // skip <!--