source: webkit/trunk/JavaScriptCore/kjs/testkjs.cpp@ 1881

Last change on this file since 1881 was 1326, checked in by darin, 23 years ago

JavaScriptCore:

Merged in changes from KDE 3.0.1.

  • kjs/collector.cpp:
  • kjs/date_object.cpp:
  • kjs/function.cpp:
  • kjs/internal.cpp:
  • kjs/lookup.h:
  • kjs/object.cpp:
  • kjs/operations.cpp:
  • kjs/regexp.cpp:
  • kjs/regexp_object.cpp:
  • kjs/regexp_object.h:
  • kjs/string_object.cpp:
  • kjs/testkjs.cpp:
  • kjs/ustring.cpp:
  • kjs/value.cpp:
  • kjs/value.h: Do the merge, and add APPLE_CHANGES as needed to make things compile.
  • kjs/date_object.lut.h: Re-generated.

WebCore:

Merged in changes from KDE 3.0.1.

  • kwq/kdecore/kurl.h:
  • kwq/KWQKURL.mm: (operator==): New, needed by some 3.0.1 code.
  • kwq/qt/qpalette.h: Add QPalette::NColorGroups and QColorGroup::NColorRoles.
  • kwq/KWQPalette.mm: Simplify by getting rid of "private" indirection. (QPalette::color): New, needed by some 3.0.1 code.
  • kwq/KWQColorGroup.mm: Simplify by getting rid of "private" indirection.
  • kwq/qt/qstring.h:
  • kwq/KWQString.mm: (QConstString::QConstString): Change parameter to const QChar * to match Qt so we compile.
  • kwq/qt/qtextedit.h:
  • kwq/KWQTextEdit.mm: (QTextEdit::setTabStopWidth): Add unimplemented placeholder, needed by some 3.0.1 code.
  • kwq/qt/qvaluelist.h:
  • kwq/KWQValueListImpl.h:
  • kwq/KWQValueListImpl.mm: Simplify implementation.
  • WebCore-tests.exp: Update for changes in QValueList implementation.
  • kwq/kdecore/klibloader.h: Add include of <kio/global.h> to make something compile.
  • kwq/khtml/java/kjavaappletcontext.h: Add JType and constructor that takes DCOPObject*.
  • kwq/kio/global.h: Add KIO::CacheControl.
  • khtml/css/css_ruleimpl.cpp:
  • khtml/css/css_ruleimpl.h:
  • khtml/css/css_stylesheetimpl.cpp:
  • khtml/css/css_stylesheetimpl.h:
  • khtml/css/css_valueimpl.cpp:
  • khtml/css/css_valueimpl.h:
  • khtml/css/cssparser.cpp:
  • khtml/css/cssparser.h:
  • khtml/css/cssstyleselector.cpp:
  • khtml/css/cssstyleselector.h:
  • khtml/css/html4.css:
  • khtml/dom/css_rule.cpp:
  • khtml/dom/css_rule.h:
  • khtml/dom/css_stylesheet.cpp:
  • khtml/dom/css_stylesheet.h:
  • khtml/dom/css_value.cpp:
  • khtml/dom/dom2_events.cpp:
  • khtml/dom/dom2_range.cpp:
  • khtml/dom/dom2_range.h:
  • khtml/dom/dom2_views.cpp:
  • khtml/dom/dom_doc.cpp:
  • khtml/dom/dom_element.cpp:
  • khtml/dom/dom_exception.h:
  • khtml/dom/dom_node.cpp:
  • khtml/dom/dom_string.cpp:
  • khtml/dom/dom_text.cpp:
  • khtml/dom/dom_xml.cpp:
  • khtml/dom/html_base.cpp:
  • khtml/dom/html_block.cpp:
  • khtml/dom/html_document.cpp:
  • khtml/dom/html_element.cpp:
  • khtml/dom/html_element.h:
  • khtml/dom/html_form.cpp:
  • khtml/dom/html_head.cpp:
  • khtml/dom/html_image.cpp:
  • khtml/dom/html_inline.cpp:
  • khtml/dom/html_list.cpp:
  • khtml/dom/html_misc.cpp:
  • khtml/dom/html_object.cpp:
  • khtml/dom/html_table.cpp:
  • khtml/ecma/kjs_html.cpp:
  • khtml/ecma/kjs_proxy.cpp:
  • khtml/ecma/kjs_traversal.cpp:
  • khtml/ecma/kjs_window.cpp:
  • khtml/html/html_baseimpl.cpp:
  • khtml/html/html_formimpl.cpp:
  • khtml/html/html_miscimpl.h:
  • khtml/html/html_objectimpl.cpp:
  • khtml/html/html_objectimpl.h:
  • khtml/html/htmlparser.cpp:
  • khtml/html/htmlparser.h:
  • khtml/html/htmltokenizer.cpp:
  • khtml/html/htmltokenizer.h:
  • khtml/khtml_part.cpp:
  • khtml/khtmlpart_p.h:
  • khtml/khtmlview.cpp:
  • khtml/misc/helper.cpp:
  • khtml/misc/khtmllayout.h:
  • khtml/misc/loader.cpp:
  • khtml/misc/loader.h:
  • khtml/misc/loader_client.h:
  • khtml/misc/shared.h: Added.
  • khtml/rendering/bidi.cpp:
  • khtml/rendering/break_lines.cpp:
  • khtml/rendering/font.cpp:
  • khtml/rendering/render_applet.cpp:
  • khtml/rendering/render_applet.h:
  • khtml/rendering/render_container.cpp:
  • khtml/rendering/render_form.cpp:
  • khtml/rendering/render_form.h:
  • khtml/rendering/render_frames.cpp:
  • khtml/rendering/render_image.cpp:
  • khtml/rendering/render_object.cpp:
  • khtml/rendering/render_object.h:
  • khtml/rendering/render_replaced.cpp:
  • khtml/rendering/render_replaced.h:
  • khtml/rendering/render_root.cpp:
  • khtml/rendering/render_style.cpp:
  • khtml/rendering/render_style.h:
  • khtml/rendering/render_table.cpp:
  • khtml/rendering/render_table.h:
  • khtml/rendering/render_text.cpp:
  • khtml/rendering/render_text.h:
  • khtml/xml/dom2_eventsimpl.h:
  • khtml/xml/dom2_rangeimpl.h:
  • khtml/xml/dom2_traversalimpl.cpp:
  • khtml/xml/dom2_traversalimpl.h:
  • khtml/xml/dom2_viewsimpl.h:
  • khtml/xml/dom_docimpl.cpp:
  • khtml/xml/dom_docimpl.h:
  • khtml/xml/dom_elementimpl.h:
  • khtml/xml/dom_nodeimpl.cpp:
  • khtml/xml/dom_nodeimpl.h:
  • khtml/xml/dom_stringimpl.cpp:
  • khtml/xml/dom_stringimpl.h:
  • khtml/xml/xml_tokenizer.h: Merge in 3.0.1 changes and add APPLE_CHANGES as necessary to get it to compile.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten ([email protected])
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 */
22
23#include <stdio.h>
24
25#include "value.h"
26#include "object.h"
27#include "types.h"
28#include "interpreter.h"
29
30using namespace KJS;
31
32class TestFunctionImp : public ObjectImp {
33public:
34 TestFunctionImp() : ObjectImp() {}
35 virtual bool implementsCall() const { return true; }
36 virtual Value call(ExecState *exec, Object &thisObj, const List &args);
37};
38
39Value TestFunctionImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
40{
41 fprintf(stderr,"--> %s\n",args[0].toString(exec).ascii());
42 return Undefined();
43}
44
45class GlobalImp : public ObjectImp {
46public:
47 virtual UString className() const { return "global"; }
48};
49
50int main(int argc, char **argv)
51{
52 // expecting a filename
53 if (argc < 2) {
54 fprintf(stderr, "You have to specify at least one filename\n");
55 return -1;
56 }
57
58 bool ret = true;
59 {
60 Object global(new GlobalImp());
61
62 // create interpreter
63 Interpreter interp(global);
64 // add debug() function
65 global.put(interp.globalExec(),"debug", Object(new TestFunctionImp()));
66 // add "print" for compatibility with the mozilla js shell
67 global.put(interp.globalExec(),"print", Object(new TestFunctionImp()));
68
69 const int BufferSize = 200000;
70 char code[BufferSize];
71
72 for (int i = 1; i < argc; i++) {
73 const char *file = argv[i];
74 FILE *f = fopen(file, "r");
75 if (!f) {
76 fprintf(stderr, "Error opening %s.\n", file);
77 return 2;
78 }
79 int num = fread(code, 1, BufferSize, f);
80 code[num] = '\0';
81 if(num >= BufferSize)
82 fprintf(stderr, "Warning: File may have been too long.\n");
83
84 // run
85 Completion comp(interp.evaluate(code));
86
87 fclose(f);
88
89 if (comp.complType() == Throw) {
90 ExecState *exec = interp.globalExec();
91 Value exVal = comp.value();
92 char *msg = exVal.toString(exec).ascii();
93 int lineno = -1;
94 if (exVal.type() == ObjectType) {
95 Value lineVal = Object::dynamicCast(exVal).get(exec,"line");
96 if (lineVal.type() == NumberType)
97 lineno = int(lineVal.toNumber(exec));
98 }
99 if (lineno != -1)
100 fprintf(stderr,"Exception, line %d: %s\n",lineno,msg);
101 else
102 fprintf(stderr,"Exception: %s\n",msg);
103 ret = false;
104 }
105 else if (comp.complType() == ReturnValue) {
106 char *msg = comp.value().toString(interp.globalExec()).ascii();
107 fprintf(stderr,"Return value: %s\n",msg);
108 }
109 }
110
111 } // end block, so that Interpreter and global get deleted
112
113 if (ret)
114 fprintf(stderr, "OK.\n");
115
116#ifdef KJS_DEBUG_MEM
117 Interpreter::finalCheck();
118#endif
119 return ret ? 0 : 1;
120}
Note: See TracBrowser for help on using the repository browser.