a26d2b7e31cf60c6d104dafdeff1a91fd8e8d25d
[WebKit-https.git] / JavaScriptCore / ChangeLog
1 2004-06-04  Darin Adler  <darin@apple.com>
2
3         * kjs/testkjs.cpp: (main): Fix build breakage by adding URL and line number parameters.
4
5 2004-06-04  Kevin Decker  <kdecker@apple.com>
6
7         Reviewed by Dave.
8
9         - ObjC bindings do not (yet) pass along sourceurl or line numbers
10         - we don't have a way as of yet to accomidate line numbers and urls for dynamic javascript
11         - changed the wording of an error message
12         - the lexer, parser, and interpreter have been made "sourceURL aware"
13         - stored the url into Error
14          
15         * bindings/NP_jsobject.cpp:
16         (NPN_Evaluate):
17         * bindings/jni/jni_jsobject.cpp:
18         (JSObject::eval):
19         * bindings/objc/WebScriptObject.mm:
20         (-[WebScriptObject evaluateWebScript:]):
21         * kjs/function.cpp:
22         (GlobalFuncImp::call):
23         * kjs/function_object.cpp:
24         (FunctionObjectImp::construct):
25         * kjs/internal.cpp:
26         (Parser::parse):
27         (InterpreterImp::checkSyntax):
28         (InterpreterImp::evaluate):
29         * kjs/internal.h:
30         * kjs/interpreter.cpp:
31         (Interpreter::evaluate):
32         * kjs/interpreter.h:
33         * kjs/lexer.cpp:
34         (Lexer::setCode):
35         * kjs/lexer.h:
36         (KJS::Lexer::sourceURL):
37         * kjs/nodes.cpp:
38         (Node::Node):
39         (Node::throwError):
40         (FunctionCallNode::evaluate):
41         * kjs/nodes.h:
42         * kjs/object.cpp:
43         (KJS::Error::create):
44         * kjs/object.h:
45
46 2004-06-04  Richard Williamson   <rjw@apple.com>
47
48         Fixed crash when attempting to access properties on nil
49         object.
50         
51         Reviewed by John.
52
53         * bindings/objc/objc_instance.mm:
54         (ObjcInstance::getClass):
55         * bindings/runtime_object.cpp:
56         (RuntimeObjectImp::get):
57         * bindings/testM.js:
58         * bindings/testbindings.mm:
59         (-[MyFirstInterface getString]):
60
61 2004-05-27  Kevin Decker  <kdecker@apple.com>
62
63         Reviewed by Ken.
64
65         -revised generated error message content
66         
67         * kjs/error_object.cpp:
68         (ErrorProtoFuncImp::call):
69         * kjs/internal.cpp:
70         (Parser::parse):
71         * kjs/object.cpp:
72         (KJS::Error::create):
73
74 === Safari-142 ===
75
76 2004-05-27  Richard Williamson   <rjw@apple.com>
77
78         Renamed WebScriptMethods to WebScripting based on feedback
79         from Nancy.
80
81         Reviewed by Chris.
82
83         * bindings/objc/WebScriptObject.h:
84
85 2004-05-27  Darin Adler  <darin@apple.com>
86
87         Reviewed by Maciej.
88
89         - moved to new symlink technique for embedding frameworks
90
91         * JavaScriptCore.pbproj/project.pbxproj: Get rid of embed-frameworks build step
92         because we don't need it any more.
93
94 2004-05-24  Richard Williamson   <rjw@apple.com>
95
96         Changed RuntimeArrayImp to inherit from ArrayInstanceImp and
97         fixed ClassInfo to correctly reflect inheritance.  This is required
98         because of the runtime checks in JSC for arrays, i.e. in
99         the Function objects apply method.
100
101         Reviewed by Ken.
102
103         * bindings/jni/jni_runtime.cpp:
104         (JavaArray::convertJObjectToArray):
105         * bindings/objc/objc_utility.mm:
106         (KJS::Bindings::convertObjcValueToValue):
107         * bindings/runtime_array.cpp:
108         (RuntimeArrayImp::RuntimeArrayImp):
109         * bindings/runtime_array.h:
110         * bindings/testM.js: Added.
111         * bindings/testbindings.mm:
112         (+[MyFirstInterface webScriptNameForSelector:]):
113         (-[MyFirstInterface logMessages:]):
114         (-[MyFirstInterface logMessage:prefix:]):
115         (-[MyFirstInterface callJSObject::]):
116
117 2004-05-22  Darin Adler  <darin@apple.com>
118
119         Reviewed by Maciej.
120
121         - fixed <rdar://problem/3664260>: (JS needs to listen to timezone change notifications)
122
123         * kjs/date_object.cpp: (CopyLocalTimeZone): As per Chris Kane and Jordan Hubbard, use <notify.h>
124         with a hardcoded string of "com.apple.system.timezone", and do CFTimeZoneResetSystem since
125         CoreFoundation doesn't do this itself. Turns out this affects the default time zone as long as
126         it hasn't been set explicitly.
127
128 === Safari-141 ===
129
130 2004-05-20  Richard Williamson   <rjw@apple.com>
131
132         Implemented WebScriptObject/DOM wrapper voodoo.  DOM wrappers
133         can now be referenced like any other WebScriptObject, meaning
134         you can do JS operations on them.
135
136         All added implementation of finalizeForWebScript.
137
138         Reviewed by Ken.
139
140         * bindings/objc/WebScriptObject.h:
141         * bindings/objc/WebScriptObject.mm:
142         (-[WebScriptObject _initializeWithObjectImp:KJS::root:Bindings::]):
143         (-[WebScriptObject _initWithObjectImp:KJS::root:Bindings::]):
144         (-[WebScriptObject KJS::]):
145         (-[WebScriptObject dealloc]):
146         (-[WebScriptObject callWebScriptMethod:withArguments:]):
147         (-[WebScriptObject evaluateWebScript:]):
148         (-[WebScriptObject setValue:forKey:]):
149         (-[WebScriptObject valueForKey:]):
150         (-[WebScriptObject stringRepresentation]):
151         * bindings/objc/WebScriptObjectPrivate.h:
152         * bindings/objc/objc_instance.mm:
153         (ObjcInstance::~ObjcInstance):
154
155 2004-05-19  Richard Williamson   <rjw@apple.com>
156
157         Removed extraneous tabs that were added (by XCode?).
158
159         * bindings/objc/WebScriptObject.h:
160
161 2004-05-19  Darin Adler  <darin@apple.com>
162
163         - fixed headers with licenses mangled by Xcode auto-indenting
164
165         * bindings/jni/jni_jsobject.cpp:
166         * bindings/jni/jni_jsobject.h:
167         * bindings/runtime_array.h:
168         * bindings/runtime_root.cpp:
169         * bindings/runtime_root.h:
170
171 2004-05-18  Richard Williamson   <rjw@apple.com>
172
173         Added exception logging.  Also check for exception and
174         set results as appropriate.
175
176         Reviewed by Maciej (partially reviewed).
177
178         * bindings/objc/WebScriptObject.mm:
179         (-[WebScriptObject callWebScriptMethod:withArguments:]):
180         (-[WebScriptObject evaluateWebScript:]):
181         (-[WebScriptObject setValue:forKey:]):
182         (-[WebScriptObject valueForKey:]):
183
184 2004-05-18  Richard Williamson   <rjw@apple.com>
185
186         Finsished implementing support for windowScriptObject.
187         Had to make WebScriptObjectPrivate.h accessible from
188         WebCore.
189
190         Reviewed by Maciej.
191
192         * JavaScriptCore.pbproj/project.pbxproj:
193         * bindings/objc/WebScriptObjectPrivate.h:
194
195 2004-05-18  Richard Williamson   <rjw@apple.com>
196
197         Use KVC to set/get values instead of directly accessing
198         ivars.
199
200         Reviewed by Maciej.
201
202         * bindings/objc/WebScriptObject.mm:
203         (-[WebScriptObject callWebScriptMethod:withArguments:]):
204         (+[WebScriptObject _convertValueToObjcValue:KJS::root:Bindings::]):
205         * bindings/objc/objc_runtime.mm:
206         (ObjcField::valueFromInstance):
207         (convertValueToObjcObject):
208         (ObjcField::setValueToInstance):
209
210 2004-05-17  Richard Williamson   <rjw@apple.com>
211
212         Implemented new API for WebScriptObject.
213
214         Fixed <rdar://problem/3657145>: (objc to javascript method calls do not cause updates.)
215         Fixed <rdar://problem/3654887>: (Update to JSC to refer to new JSObject LiveConnect object)  (w/ help from Vicki)
216
217         Reviewed by Hyatt.
218
219         * JavaScriptCore.pbproj/project.pbxproj:
220         * bindings/c/c_instance.cpp:
221         (CInstance::invokeMethod):
222         * bindings/jni/jni_instance.cpp:
223         (JavaInstance::invokeMethod):
224         * bindings/jni/jni_jsobject.cpp:
225         (JSObject::convertValueToJObject):
226         * bindings/jni/jni_utility.cpp:
227         (KJS::Bindings::getJNIField):
228         * bindings/objc/WebScriptObject.mm:
229         (_didExecute):
230         (-[WebScriptObject _initWithObjectImp:KJS::root:Bindings::]):
231         (-[WebScriptObject KJS::]):
232         (-[WebScriptObject dealloc]):
233         (+[WebScriptObject throwException:]):
234         (listFromNSArray):
235         (-[WebScriptObject callWebScriptMethod:withArguments:]):
236         (-[WebScriptObject evaluateWebScript:]):
237         (-[WebScriptObject setValue:forKey:]):
238         (-[WebScriptObject valueForKey:]):
239         (-[WebScriptObject stringRepresentation]):
240         (+[WebScriptObject _convertValueToObjcValue:KJS::root:Bindings::]):
241         (+[WebUndefined undefined]):
242         (-[WebUndefined initWithCoder:]):
243         (-[WebUndefined encodeWithCoder:]):
244         (-[WebUndefined copyWithZone:]):
245         (-[WebUndefined retain]):
246         (-[WebUndefined release]):
247         (-[WebUndefined retainCount]):
248         (-[WebUndefined autorelease]):
249         (-[WebUndefined dealloc]):
250         (-[WebUndefined copy]):
251         (-[WebUndefined replacementObjectForPortCoder:]):
252         * bindings/objc/WebScriptObjectPrivate.h: Added.
253         * bindings/objc/objc_class.mm:
254         (ObjcClass::methodsNamed):
255         (ObjcClass::fieldNamed):
256         * bindings/objc/objc_instance.mm:
257         (ObjcInstance::invokeMethod):
258         * bindings/objc/objc_jsobject.h:
259         * bindings/objc/objc_jsobject.mm:
260         * bindings/objc/objc_runtime.mm:
261         (ObjcField::valueFromInstance):
262         * bindings/objc/objc_utility.mm:
263         (KJS::Bindings::JSMethodNameToObjCMethodName):
264         (KJS::Bindings::convertValueToObjcValue):
265         (KJS::Bindings::convertObjcValueToValue):
266         * bindings/runtime.cpp:
267         (Instance::setDidExecuteFunction):
268         (Instance::didExecuteFunction):
269         (Instance::setValueOfField):
270         * bindings/runtime.h:
271         * bindings/testbindings.mm:
272         (+[MyFirstInterface webScriptNameForSelector:]):
273         (-[MyFirstInterface callJSObject::]):
274
275 2004-05-14  Vicki Murley  <vicki@apple.com>
276
277         Reviewed by mjs.
278  
279         <rdar://problem/3642427>: framework marketing number should be 2.0 for DoubleBarrel release
280
281         * JavaScriptCore.pbproj/project.pbxproj: change CFBundleShortVersionString to 2.0
282
283 === Safari-140 ===
284
285 2004-05-13  Richard Williamson   <rjw@apple.com>
286
287         Fixed indentation.
288
289         Reviewed by Chris.
290
291         * ChangeLog:
292         * bindings/objc/WebScriptObject.h:
293
294 2004-05-13  Richard Williamson   <rjw@apple.com>
295
296         Approved API changes.  Currently unimplemented.
297
298         Reviewed by Chris.
299
300         * ChangeLog:
301         * JavaScriptCore.pbproj/project.pbxproj:
302         * bindings/objc/WebScriptObject.h: Added.
303         * bindings/objc/WebScriptObject.mm: Added.
304         (+[WebScriptObject throwException:]):
305         (-[WebScriptObject callWebScriptMethod:withArguments:]):
306         (-[WebScriptObject evaluateWebScript:]):
307         (-[WebScriptObject stringRepresentation]):
308         (+[WebUndefined undefined]):
309         (-[WebUndefined initWithCoder:]):
310         (-[WebUndefined encodeWithCoder:]):
311         (-[WebUndefined copyWithZone:]):
312
313 2004-05-07  Vicki Murley  <vicki@apple.com>
314
315         Reviewed by darin.
316
317         Turn off GC since it uses ppc only instructions (which breaks 
318         the B&I build).   
319     
320         * kjs/value.h: set USE_CONSERVATIVE_GC to 0
321
322 === Safari-139 ===
323
324 2004-05-07  Maciej Stachowiak  <mjs@apple.com>
325
326         Reviewed by Darin.
327
328         - add -funroll-loops=16 compiler option for approx .5% speedup on
329         HTML iBench and .5-1% speedup on JS iBench.
330         
331         * JavaScriptCore.pbproj/project.pbxproj:
332
333 2004-04-25  Maciej Stachowiak  <mjs@apple.com>
334
335         Reviewed by Darin.
336
337         Enable full conservative GC mode in addition to test mode. When
338         conservative GC is enabled, we now get an 11% speed improvement on
339         the iBench. Also fix some spots I missed before.
340
341         Specific noteworth changes:
342         
343         * kjs/collector.cpp:
344         (KJS::Collector::markStackObjectsConservatively): Check possible
345         cell pointers for 8-byte aligment and verify they are not 0.
346
347         * kjs/protected_values.cpp:
348         (KJS::ProtectedValues::increaseProtectCount): Move null-tolerance from here...
349         (KJS::ProtectedValues::decreaseProtectCount): ...and here...
350         * kjs/protect.h:
351         (KJS::gcProtectNullTolerant): ...to here...
352         (KJS::gcUnprotectNullTolerant): ...and here, because not all callers need the null
353         tolerance, and doing the check is expensive.
354
355         * kjs/protected_values.cpp:
356         (KJS::ProtectedValues::computeHash): Replace hash function with a much faster one
357         that is still very good.
358
359         * kjs/protect.h:
360         (KJS::gcProtect):
361         (KJS::gcUnprotect):
362         (KJS::ProtectedValue::ProtectedValue):
363         (KJS::ProtectedValue::~ProtectedValue):
364         (KJS::ProtectedValue::operator=):
365         (KJS::ProtectedObject::ProtectedObject):
366         (KJS::ProtectedObject::~ProtectedObject):
367         (KJS::ProtectedObject::operator=):
368         (KJS::ProtectedReference::ProtectedReference):
369         (KJS::ProtectedReference::~ProtectedReference):
370         (KJS::ProtectedReference::operator=):
371         * kjs/protected_values.cpp:
372         (KJS::ProtectedValues::getProtectCount):
373         (KJS::ProtectedValues::increaseProtectCount):
374         (KJS::ProtectedValues::decreaseProtectCount):
375         (KJS::ProtectedValues::computeHash):
376         * bindings/runtime_root.cpp:
377         (KJS::Bindings::addNativeReference):
378         (KJS::Bindings::removeNativeReference):
379         (RootObject::removeAllNativeReferences):
380         * bindings/runtime_root.h:
381         (KJS::Bindings::RootObject::~RootObject):
382         (KJS::Bindings::RootObject::setRootObjectImp):
383         * kjs/collector.cpp:
384         (KJS::Collector::allocate):
385         (KJS::Collector::collect):
386         * kjs/collector.h:
387         * kjs/internal.cpp:
388         (NumberImp::create):
389         (InterpreterImp::globalInit):
390         (InterpreterImp::globalClear):
391         (InterpreterImp::mark):
392         * kjs/list.cpp:
393         (KJS::List::derefValues):
394         (KJS::List::refValues):
395         (KJS::List::append):
396         * kjs/object.cpp:
397         (KJS::ObjectImp::setInternalValue):
398         (KJS::ObjectImp::putDirect):
399         * kjs/value.cpp:
400         (ValueImp::mark):
401         (ValueImp::marked):
402         * kjs/value.h:
403         (KJS::ValueImp::ValueImp):
404         (KJS::ValueImp::~ValueImp):
405         (KJS::ValueImp::):
406         (KJS::Value::Value):
407         (KJS::Value::~Value):
408         (KJS::Value::operator=):
409
410 2004-04-30  Richard Williamson   <rjw@apple.com>
411
412         Asking an NSInvocation for it's return value when return type
413         is void throws an exception.  Added check for void return types
414         to avoid this exception.
415
416         Reviewed by Ken.
417
418         * bindings/objc/objc_instance.mm:
419         (ObjcInstance::invokeMethod):
420
421 2004-04-29  Richard Williamson   <rjw@apple.com>
422
423         Fixed several bad problems with the ObjC bindings.  In particular, conversion
424         to/from JavaScriptObject (soon to be WebScriptObject) was completely broken.
425
426         Reviewed by Chris.
427
428         * bindings/objc/objc_jsobject.h:
429         * bindings/objc/objc_jsobject.mm:
430         (-[JavaScriptObject initWithObjectImp:KJS::root:Bindings::]):
431         (-[JavaScriptObject KJS::]):
432         (+[JavaScriptObject _convertValueToObjcValue:KJS::root:Bindings::]):
433         (-[JavaScriptObject call:arguments:]):
434         (-[JavaScriptObject evaluate:]):
435         (-[JavaScriptObject getMember:]):
436         (-[JavaScriptObject getSlot:]):
437         * bindings/objc/objc_runtime.mm:
438         (ObjcField::valueFromInstance):
439         (ObjcField::setValueToInstance):
440         * bindings/objc/objc_utility.mm:
441         (KJS::Bindings::convertValueToObjcValue):
442         (KJS::Bindings::convertObjcValueToValue):
443         * bindings/runtime.h:
444         * bindings/runtime_root.cpp:
445         (KJS::Bindings::rootForInterpreter):
446         (KJS::Bindings::addNativeReference):
447         (KJS::Bindings::removeNativeReference):
448         * bindings/runtime_root.h:
449         * bindings/testbindings.mm:
450         (-[MyFirstInterface logMessage:]):
451         (-[MyFirstInterface setJSObject:]):
452         (-[MyFirstInterface callJSObject::]):
453
454 2004-04-24  Darin Adler  <darin@apple.com>
455
456         Reviewed by Dave.
457
458         * kjs/ustring.cpp: (KJS::UString::append): Fix one case that was allocating a buffer
459         that is 2x too big.
460
461 2004-04-23  Maciej Stachowiak  <mjs@apple.com>
462
463         Reviewed by Darin.
464
465         Implementation of conservative GC, based partly on code from
466         Darin. It's turned off for now, so it shouldn't have any effect on
467         the normal build.
468         
469         * JavaScriptCore.pbproj/project.pbxproj:
470         * kjs/collector.cpp:
471         (KJS::Collector::markStackObjectsConservatively):
472         (KJS::Collector::markProtectedObjects):
473         (KJS::Collector::collect):
474         * kjs/collector.h:
475         * kjs/protect.h:
476         (KJS::gcProtect):
477         (KJS::gcUnprotect):
478         * kjs/protected_values.cpp: Added.
479         (KJS::ProtectedValues::getProtectCount):
480         (KJS::ProtectedValues::increaseProtectCount):
481         (KJS::ProtectedValues::insert):
482         (KJS::ProtectedValues::decreaseProtectCount):
483         (KJS::ProtectedValues::expand):
484         (KJS::ProtectedValues::shrink):
485         (KJS::ProtectedValues::rehash):
486         (KJS::ProtectedValues::computeHash):
487         * kjs/protected_values.h: Added.
488         * kjs/value.cpp:
489         (ValueImp::useConservativeMark):
490         (ValueImp::mark):
491         (ValueImp::marked):
492         * kjs/value.h:
493         (KJS::ValueImp::):
494
495 === Safari-138 ===
496
497 2004-04-22  Richard Williamson   <rjw@apple.com>
498
499         Fixed build snafu (re-declaration of NPBool in npruntime.h and
500         npapi.h).
501
502         * bindings/npruntime.h:
503
504 2004-04-22  Richard Williamson   <rjw@apple.com>
505
506         Updated plugin binding API to reflect latest revision from
507         working group.
508         
509         Biggest change is the introduction of NPVariant used to represent
510         value types.  NPVariant replaces the use of NPObject for the
511         exchange of values between scripting environment and native code.
512
513         Reviewed by John.
514
515         * JavaScriptCore.pbproj/project.pbxproj:
516         * bindings/NP_jsobject.cpp:
517         (identiferFromNPIdentifier):
518         (NPN_Call):
519         (NPN_Evaluate):
520         (NPN_GetProperty):
521         (NPN_SetProperty):
522         (NPN_ToString):
523         (NPN_GetPropertyAtIndex):
524         (NPN_SetPropertyAtIndex):
525         * bindings/c/c_class.cpp:
526         (CClass::methodsNamed):
527         (CClass::fieldNamed):
528         * bindings/c/c_instance.cpp:
529         (CInstance::invokeMethod):
530         (CInstance::defaultValue):
531         * bindings/c/c_runtime.cpp:
532         (CField::valueFromInstance):
533         (CField::setValueToInstance):
534         * bindings/c/c_utility.cpp:
535         (convertNPStringToUTF16):
536         (convertUTF8ToUTF16):
537         (coerceValueToNPVariantStringType):
538         (convertValueToNPVariant):
539         (convertNPVariantToValue):
540         * bindings/c/c_utility.h:
541         * bindings/npruntime.cpp:
542         (NPN_GetIdentifier):
543         (NPN_GetIdentifiers):
544         (NPN_UTF8FromIdentifier):
545         (NPN_VariantIsVoid):
546         (NPN_VariantIsNull):
547         (NPN_VariantIsUndefined):
548         (NPN_VariantIsBool):
549         (NPN_VariantIsInt32):
550         (NPN_VariantIsDouble):
551         (NPN_VariantIsString):
552         (NPN_VariantIsObject):
553         (NPN_VariantToBool):
554         (NPN_VariantToString):
555         (NPN_VariantToInt32):
556         (NPN_VariantToDouble):
557         (NPN_VariantToObject):
558         (NPN_InitializeVariantAsVoid):
559         (NPN_InitializeVariantAsNull):
560         (NPN_InitializeVariantAsUndefined):
561         (NPN_InitializeVariantWithBool):
562         (NPN_InitializeVariantWithInt32):
563         (NPN_InitializeVariantWithDouble):
564         (NPN_InitializeVariantWithString):
565         (NPN_InitializeVariantWithStringCopy):
566         (NPN_InitializeVariantWithObject):
567         (NPN_InitializeVariantWithVariant):
568         (NPN_ReleaseVariantValue):
569         (NPN_CreateObject):
570         (NPN_RetainObject):
571         (NPN_ReleaseObject):
572         (NPN_IsKindOfClass):
573         (NPN_SetExceptionWithUTF8):
574         (NPN_SetException):
575         * bindings/npruntime.h:
576         (_NPString::):
577         (_NPString::_NPVariant::):
578         * bindings/testbindings.cpp:
579         (logMessage):
580         (setDoubleValue):
581         (setIntValue):
582         (setStringValue):
583         (setBooleanValue):
584         (getDoubleValue):
585         (getIntValue):
586         (getStringValue):
587         (getBooleanValue):
588         (myGetProperty):
589         (mySetProperty):
590         (myInvoke):
591         (myAllocate):
592
593 2004-04-22  Darin Adler  <darin@apple.com>
594
595         Reviewed by Maciej.
596
597         - fixed <rdar://problem/3627473>: "REGRESSION (125-137): memory trasher in UString::append, causing many different crashes"
598
599         * kjs/ustring.cpp:
600         (KJS::UString::expandCapacity): Fix sizeof(UChar *) that should be sizeof(UChar).
601         Was resulting in a buffer 2x the needed size.
602         (KJS::UString::expandPreCapacity): Ditto.
603         (KJS::UString::append): Fix malloc that is missing a sizeof(UChar).
604
605 2004-04-21  Maciej Stachowiak  <mjs@apple.com>
606
607         Reviewed by Darin.
608
609         Preliminary change for conservative GC. Create "protected"
610         subclasses to GC-protect objects when on heap, since we will soon
611         remove the built-in refcounting of the normal wrapper classes. Use
612         them where needed.
613         
614         * JavaScriptCore.pbproj/project.pbxproj:
615         * kjs/context.h:
616         * kjs/internal.h:
617         (KJS::InterpreterImp::globalObject):
618         * kjs/interpreter.h:
619         * kjs/property_map.cpp:
620         * kjs/reference.h:
621         * kjs/reference_list.cpp:
622
623 2004-04-19  Maciej Stachowiak  <mjs@apple.com>
624
625         Reviewed by Dave.
626
627         Optimize prepend using the shared substring optimization. Also,
628         limit the applicability of shared append and shared prepend. If
629         you overdo it, it does more harm than good, because you create a
630         bunch of strings that are disqualified from future shared
631         append/prepend, for not much immediate savings in allocate/copy
632         expense.
633         
634         * kjs/ustring.cpp:
635         (KJS::):
636         (KJS::UString::Rep::create):
637         (KJS::UString::expandedSize):
638         (KJS::UString::usedPreCapacity):
639         (KJS::UString::expandCapacity):
640         (KJS::UString::expandPreCapacity):
641         (KJS::UString::UString):
642         (KJS::UString::append):
643         (KJS::UString::operator=):
644         * kjs/ustring.h:
645         (KJS::UString::Rep::data):
646
647 2004-04-16  Maciej Stachowiak  <mjs@apple.com>
648         Reviewed by Richard.
649
650         No more need for Completion or Reference to privately inherit from
651         Value, none of the superclass functionality is used.
652
653         * kjs/completion.h:
654         * kjs/reference.h:
655
656 === Safari-137 ===
657
658 2004-04-16  Richard Williamson   <rjw@apple.com>
659
660         Added interpreter lock protection around object creation.
661
662         Reviewed by Chris.
663
664         * bindings/runtime.cpp:
665         (Instance::createRuntimeObject):
666
667 2004-04-16  Maciej Stachowiak  <mjs@apple.com>
668
669         Reviewed by Ken.
670
671         Another JavaScript speed improvement: use the mechanism from
672         string append optimization to make taking a substring fast, again
673         sharing the buffer.
674
675         A further 22% improvement on the 24fun string speed test.
676         
677         * kjs/ustring.cpp:
678         (KJS::):
679         (KJS::UString::Rep::create):
680         (KJS::UString::UString):
681         (KJS::UString::append):
682         (KJS::UString::operator=):
683         (KJS::UString::substr):
684         * kjs/ustring.h:
685         (KJS::UString::Rep::data):
686
687 2004-04-13  Maciej Stachowiak  <mjs@apple.com>
688
689         Reviewed by Darin.
690
691         - fixed <rdar://problem/3600695>: String manipulation in JavaScript 24fun test is very slow (slow)
692         - fixed <rdar://problem/3600691>: Table generation test is really slow
693         - fixed <rdar://problem/3600661>: 24fun date test is really slow
694
695         80% speedup on the string test, lesser speedups on the other two.
696         
697         Two different optimizations here:
698
699         1) Avoid large overhead of scanning strings to see if they are all
700         ASCII before numeric conversion.
701         
702         * kjs/nodes.cpp:
703         (AssignNode::evaluate): Don't convert to integer until we know for
704         sure the operation will need it. Attempting to convert strings to
705         numbers is a waste when they are being appended with +=.
706
707         2) Avoid huge cost of appending strings.
708
709         This is done by allowing multiple strings to share a buffer but
710         actually use different ranges of it. The first time a string is
711         appended to, we start leaving at least 10% extra space in the
712         buffer, so doing N appends to the same string takes O(log N)
713         mallocs instead of O(N).
714         
715         * kjs/identifier.cpp:
716         (KJS::Identifier::equal):
717         (KJS::Identifier::add):
718         * kjs/ustring.cpp:
719         (KJS::):
720         (KJS::UCharReference::operator=):
721         (KJS::UCharReference::ref):
722         (KJS::UString::Rep::create):
723         (KJS::UString::Rep::destroy):
724         (KJS::UString::expandedSize):
725         (KJS::UString::usedCapacity):
726         (KJS::UString::expandCapacity):
727         (KJS::UString::UString):
728         (KJS::UString::null):
729         (KJS::UString::append):
730         (KJS::UString::operator=):
731         (KJS::UString::toStrictUInt32):
732         (KJS::UString::detach):
733         (KJS::KJS::operator==):
734         * kjs/ustring.h:
735         (KJS::UString::Rep::data):
736         (KJS::UString::Rep::hash):
737
738 2004-04-09  Maciej Stachowiak  <mjs@apple.com>
739
740         Reviewed by John.
741
742         - fix deployment build by avoiding deployment-only warning.
743
744         * kjs/scope_chain.cpp:
745         (KJS::ScopeChain::bottom):
746
747 2004-04-09  Maciej Stachowiak  <mjs@apple.com>
748
749         Reviewed by John.
750
751         Changed things so that newly created objects get a prototype based
752         on the scope chain of the current function, rather than the
753         interpreter that started execution. This fixes the following bugs:
754         
755         <rdar://problem/3368523>: ARCH: wrong prototype used to create new objects (hang on lookup.atomica.com)
756         <rdar://problem/3559173>: ARCH: Cannot scan using a HP Jetdirect product (JS object prototypes bind incorrectly)
757
758         * JavaScriptCore.pbproj/project.pbxproj:
759         * kjs/array_object.cpp:
760         (CompareWithCompareFunctionArguments::CompareWithCompareFunctionArguments):
761         (ArrayProtoFuncImp::ArrayProtoFuncImp):
762         (ArrayProtoFuncImp::call):
763         (ArrayObjectImp::construct):
764         * kjs/bool_object.cpp:
765         (BooleanObjectImp::construct):
766         * kjs/date_object.cpp:
767         (DateProtoFuncImp::DateProtoFuncImp):
768         (DateProtoFuncImp::call):
769         (DateObjectImp::construct):
770         * kjs/error_object.cpp:
771         (ErrorObjectImp::construct):
772         * kjs/function.cpp:
773         (FunctionImp::FunctionImp):
774         (FunctionImp::call):
775         (DeclaredFunctionImp::construct):
776         (ArgumentsImp::ArgumentsImp):
777         (GlobalFuncImp::call):
778         * kjs/function_object.cpp:
779         (FunctionProtoFuncImp::call):
780         (FunctionObjectImp::construct):
781         * kjs/internal.cpp:
782         (BooleanImp::toObject):
783         (StringImp::toObject):
784         (NumberImp::toObject):
785         (InterpreterImp::InterpreterImp):
786         (InterpreterImp::clear):
787         (InterpreterImp::interpreterWithGlobalObject):
788         * kjs/internal.h:
789         * kjs/interpreter.cpp:
790         (ExecState::lexicalInterpreter):
791         * kjs/interpreter.h:
792         (KJS::ExecState::dynamicInterpreter):
793         (KJS::ExecState::interpreter):
794         * kjs/math_object.cpp:
795         (MathFuncImp::MathFuncImp):
796         * kjs/nodes.cpp:
797         (StatementNode::hitStatement):
798         (StatementNode::abortStatement):
799         (RegExpNode::evaluate):
800         (ElementNode::evaluate):
801         (ArrayNode::evaluate):
802         (ObjectLiteralNode::evaluate):
803         (PropertyValueNode::evaluate):
804         (FunctionCallNode::evaluate):
805         (FuncDeclNode::processFuncDecl):
806         (FuncExprNode::evaluate):
807         * kjs/number_object.cpp:
808         (NumberObjectImp::construct):
809         * kjs/object.cpp:
810         (KJS::ObjectImp::defaultValue):
811         (KJS::Error::create):
812         * kjs/object_object.cpp:
813         (ObjectObjectImp::construct):
814         * kjs/reference.cpp:
815         (Reference::putValue):
816         * kjs/regexp_object.cpp:
817         (RegExpProtoFuncImp::call):
818         (RegExpObjectImp::arrayOfMatches):
819         (RegExpObjectImp::construct):
820         * kjs/scope_chain.cpp:
821         (KJS::ScopeChain::bottom):
822         * kjs/scope_chain.h:
823         * kjs/string_object.cpp:
824         (StringProtoFuncImp::StringProtoFuncImp):
825         (StringProtoFuncImp::call):
826         (StringObjectImp::construct):
827
828 === Safari-136 ===
829
830 === Safari-135 ===
831
832 2004-03-31  Richard Williamson   <rjw@apple.com>
833
834         Tedious renames based on feedback from plugin-futures list.
835         NP_ functions are renamed with NPN_ prefix.
836         Types prefix renamed from NP_ to NP.
837         NPN_CreateStringWithUTF8 and NPN_SetExceptionWithUTF8 now take a length, optionally -1 if string is null terminated. 
838         
839         No review because this was just a renaming patch.
840
841         * bindings/NP_jsobject.cpp:
842         (listFromNPArray):
843         (jsAllocate):
844         (identiferFromNPIdentifier):
845         (NPN_Call):
846         (NPN_Evaluate):
847         (NPN_GetProperty):
848         (NPN_SetProperty):
849         (NPN_RemoveProperty):
850         (NPN_ToString):
851         (NPN_GetPropertyAtIndex):
852         (NPN_SetPropertyAtIndex):
853         * bindings/NP_jsobject.h:
854         * bindings/c/c_class.cpp:
855         (CClass::_commonInit):
856         (CClass::classForIsA):
857         (CClass::CClass):
858         (CClass::methodsNamed):
859         (CClass::fieldNamed):
860         * bindings/c/c_class.h:
861         * bindings/c/c_instance.cpp:
862         (CInstance::CInstance):
863         (CInstance::~CInstance):
864         (CInstance::operator=):
865         (CInstance::invokeMethod):
866         (CInstance::defaultValue):
867         * bindings/c/c_instance.h:
868         (KJS::Bindings::CInstance::getObject):
869         * bindings/c/c_runtime.cpp:
870         (CField::valueFromInstance):
871         (CField::setValueToInstance):
872         * bindings/c/c_runtime.h:
873         (KJS::Bindings::CField::CField):
874         (KJS::Bindings::CField::name):
875         (KJS::Bindings::CMethod::CMethod):
876         (KJS::Bindings::CMethod::name):
877         * bindings/c/c_utility.cpp:
878         (coerceValueToNPString):
879         (convertValueToNPValueType):
880         (convertNPValueTypeToValue):
881         * bindings/c/c_utility.h:
882         * bindings/npruntime.cpp:
883         (NPN_IdentifierFromUTF8):
884         (NPN_IsValidIdentifier):
885         (NPN_GetIdentifiers):
886         (NPN_UTF8FromIdentifier):
887         (NPN_CreateObject):
888         (NPN_RetainObject):
889         (NPN_ReleaseObject):
890         (NPN_IsKindOfClass):
891         (NPN_SetExceptionWithUTF8):
892         (NPN_SetException):
893         (numberAllocate):
894         (NPN_CreateNumberWithInt):
895         (NPN_CreateNumberWithFloat):
896         (NPN_CreateNumberWithDouble):
897         (NPN_IntFromNumber):
898         (NPN_FloatFromNumber):
899         (NPN_DoubleFromNumber):
900         (stringAllocate):
901         (NPN_CreateStringWithUTF8):
902         (NPN_CreateStringWithUTF16):
903         (NPN_DeallocateUTF8):
904         (NPN_UTF8FromString):
905         (NPN_UTF16FromString):
906         (NPN_StringLength):
907         (booleanAllocate):
908         (NPN_CreateBoolean):
909         (NPN_BoolFromBoolean):
910         (nullAllocate):
911         (NPN_GetNull):
912         (undefinedAllocate):
913         (NPN_GetUndefined):
914         (arrayAllocate):
915         (arrayDeallocate):
916         (NPN_CreateArray):
917         (NPN_CreateArrayV):
918         (NPN_ObjectAtIndex):
919         * bindings/npruntime.h:
920         * bindings/runtime.cpp:
921         (Instance::createBindingForLanguageInstance):
922         * bindings/testbindings.cpp:
923         (initializeIdentifiers):
924         (myHasProperty):
925         (myHasMethod):
926         (myGetProperty):
927         (mySetProperty):
928         (logMessage):
929         (setDoubleValue):
930         (setIntValue):
931         (setStringValue):
932         (setBooleanValue):
933         (getDoubleValue):
934         (getIntValue):
935         (getStringValue):
936         (getBooleanValue):
937         (myInvoke):
938         (myAllocate):
939         (myInvalidate):
940         (myDeallocate):
941         (main):
942
943 2004-03-31  Richard Williamson   <rjw@apple.com>
944
945         Changed references to NP_runtime.h to npruntime.h
946         
947         * JavaScriptCore.pbproj/project.pbxproj:
948         * bindings/NP_jsobject.h:
949         * bindings/c/c_class.h:
950         * bindings/c/c_instance.h:
951         * bindings/c/c_runtime.h:
952         * bindings/c/c_utility.h:
953         * bindings/npruntime.cpp:
954
955 2004-03-31  Richard Williamson   <rjw@apple.com>
956
957         Renamed NP_runtime.h to npruntime.h to match Netscape SDK.
958
959         * JavaScriptCore.pbproj/project.pbxproj:
960         * bindings/NP_jsobject.h:
961         * bindings/npruntime.cpp:
962
963 === Safari-134 ===
964
965 2004-03-23  Richard Williamson   <rjw@apple.com>
966
967         Added implementation of KJS::Value <-> NP_Object conversion functions.
968         Augmented test program for 'C' bindings.
969         Added asserts and parameter checking to all public API. 
970
971         Reviewed by Ken.
972
973         * JavaScriptCore.pbproj/project.pbxproj:
974         * bindings/NP_jsobject.cpp:
975         (NP_ToString):
976         * bindings/NP_jsobject.h: Added.
977         * bindings/NP_runtime.cpp:
978         (NP_IdentifierFromUTF8):
979         (NP_IsValidIdentifier):
980         (NP_GetIdentifiers):
981         (NP_CreateObject):
982         (NP_RetainObject):
983         (NP_ReleaseObject):
984         (NP_IsKindOfClass):
985         (NP_SetExceptionWithUTF8):
986         (NP_SetException):
987         (NP_IntFromNumber):
988         (NP_FloatFromNumber):
989         (NP_DoubleFromNumber):
990         (NP_CreateStringWithUTF8):
991         (NP_CreateStringWithUTF16):
992         (NP_DeallocateUTF8):
993         (NP_UTF8FromString):
994         (NP_UTF16FromString):
995         (NP_StringLength):
996         (NP_BoolFromBoolean):
997         * bindings/NP_runtime.h:
998         * bindings/c/c_instance.cpp:
999         (CInstance::invokeMethod):
1000         * bindings/c/c_utility.cpp:
1001         (coerceValueToNPString):
1002         (convertValueToNPValueType):
1003         (convertNPValueTypeToValue):
1004         * bindings/c/c_utility.h:
1005         * bindings/test.js:
1006         * bindings/testC.js: Added.
1007         * bindings/testbindings.cpp:
1008         (logMessage):
1009         (setDoubleValue):
1010         (setIntValue):
1011         (setStringValue):
1012         (setBooleanValue):
1013         (getDoubleValue):
1014         (getIntValue):
1015         (getStringValue):
1016         (getBooleanValue):
1017         (myInterfaceInvoke):
1018         (myInterfaceAllocate):
1019
1020 === Safari-133 ===
1021
1022 2004-03-19  Darin Adler  <darin@apple.com>
1023
1024         Reviewed by Ken.
1025
1026         - fixed problem with methods like setUTCHour
1027
1028         * kjs/date_object.cpp: (DateProtoFuncImp::call): Fix conversion back to time_t to use the appropriate
1029         GMT vs. local time function based on the utc flag.
1030
1031 2004-03-17  Richard Williamson   <rjw@apple.com>
1032
1033         Added a context parameter to result callbacks use by JavaScriptObject functions.  This was a change requested by Eric Carlson on the QT plugin team.
1034
1035         Reviewed by Ken.
1036
1037         * bindings/NP_jsobject.cpp:
1038         (NP_Call):
1039         (NP_Evaluate):
1040         (NP_GetProperty):
1041         (NP_ToString):
1042         (NP_GetPropertyAtIndex):
1043         * bindings/NP_runtime.h:
1044
1045 2004-03-16  Richard Williamson   <rjw@apple.com>
1046
1047         Fixed 3590169.  Regression (crash) caused by the switch to MethodLists.  Crash when attempting to invoke a method from JavaScript to Java that is not implemented.
1048
1049         Reviewed by John.
1050
1051         * bindings/jni/jni_class.cpp:
1052         (JavaClass::methodsNamed):
1053
1054 2004-03-15  Richard Williamson   <rjw@apple.com>
1055
1056         Fixed 3570854.  Don't attempt to convert Null to strings.  We
1057         were incorrectly converting to "Null".
1058
1059         Actually fixed by Scott Kovatch.
1060
1061         Reviewed by Richard.
1062
1063         * bindings/jni/jni_utility.cpp:
1064         (KJS::Bindings::convertValueToJValue):
1065
1066 === Safari-132 ===
1067
1068 2004-03-11  Richard Williamson   <rjw@apple.com>
1069
1070         Stitched together the NP stuff to our language independent
1071         JavaScript binding stuff.  Very close to being done.
1072         
1073         Added program to test C bindings (and NP stuff).  Just tests
1074         properties.  Will add methods and JavaScript access, etc.
1075
1076         Updated Makefile.am to account for new bindings/c directory.
1077
1078         Change NP_UTF8 from "const char *" to "char" to allow for
1079         declarations like "const NP_UTF8 *" and "NP_UTF8 *".  Ditto
1080         for NP_UTF16.
1081
1082         Added NP_IsValidIdentifier().
1083
1084         Reviewed by Chris.
1085
1086         * JavaScriptCore.pbproj/project.pbxproj:
1087         * Makefile.am:
1088         * bindings/NP_jsobject.cpp:
1089         (identiferFromNPIdentifier):
1090         (NP_Evaluate):
1091         * bindings/NP_runtime.cpp:
1092         (NP_IdentifierFromUTF8):
1093         (NP_IsValidIdentifier):
1094         (NP_GetIdentifiers):
1095         (NP_UTF8FromIdentifier):
1096         (NP_SetExceptionWithUTF8):
1097         (NP_SetException):
1098         (NP_CreateStringWithUTF8):
1099         (NP_CreateStringWithUTF16):
1100         (NP_UTF8FromString):
1101         (NP_UTF16FromString):
1102         * bindings/NP_runtime.h:
1103         * bindings/c/c_class.cpp: Added.
1104         (CClass::_commonDelete):
1105         (CClass::_commonCopy):
1106         (CClass::_commonInit):
1107         (_createClassesByIsAIfNecessary):
1108         (CClass::classForIsA):
1109         (CClass::CClass):
1110         (CClass::name):
1111         (CClass::methodsNamed):
1112         (CClass::fieldNamed):
1113         * bindings/c/c_class.h: Added.
1114         (KJS::Bindings::CClass::~CClass):
1115         (KJS::Bindings::CClass::CClass):
1116         (KJS::Bindings::CClass::operator=):
1117         (KJS::Bindings::CClass::constructorAt):
1118         (KJS::Bindings::CClass::numConstructors):
1119         * bindings/c/c_instance.cpp: Added.
1120         (CInstance::CInstance):
1121         (CInstance::~CInstance):
1122         (CInstance::operator=):
1123         (CInstance::getClass):
1124         (CInstance::begin):
1125         (CInstance::end):
1126         (CInstance::invokeMethod):
1127         (CInstance::defaultValue):
1128         (CInstance::stringValue):
1129         (CInstance::numberValue):
1130         (CInstance::booleanValue):
1131         (CInstance::valueOf):
1132         * bindings/c/c_instance.h: Added.
1133         (KJS::Bindings::CInstance::getObject):
1134         * bindings/c/c_runtime.cpp: Added.
1135         (CField::valueFromInstance):
1136         (CField::setValueToInstance):
1137         * bindings/c/c_runtime.h: Added.
1138         (KJS::Bindings::CField::CField):
1139         (KJS::Bindings::CField::name):
1140         (KJS::Bindings::CField::type):
1141         (KJS::Bindings::CMethod::CMethod):
1142         (KJS::Bindings::CMethod::name):
1143         (KJS::Bindings::CMethod::numParameters):
1144         * bindings/c/c_utility.cpp: Added.
1145         (coerceValueToNPValueType):
1146         (convertValueToNPValueType):
1147         (convertNPValueTypeToValue):
1148         * bindings/c/c_utility.h: Added.
1149         * bindings/make_testbindings:
1150         * bindings/runtime.cpp:
1151         (Instance::createBindingForLanguageInstance):
1152         * bindings/runtime.h:
1153         (KJS::Bindings::Instance::):
1154         * bindings/testbindings.cpp: Added.
1155         (initializeIdentifiers):
1156         (myInterfaceHasProperty):
1157         (myInterfaceHasMethod):
1158         (myInterfaceGetProperty):
1159         (myInterfaceSetProperty):
1160         (myInterfaceInvoke):
1161         (myInterfaceAllocate):
1162         (myInterfaceInvalidate):
1163         (myInterfaceDeallocate):
1164         (GlobalImp::className):
1165         (readJavaScriptFromFile):
1166         (main):
1167
1168 2004-03-10  Richard Williamson   <rjw@apple.com>
1169
1170         Made changes to support new asychronous approach to calls from
1171         plugin to JavaScript
1172
1173         Reviewed by Chris.
1174
1175         * bindings/NP_jsobject.cpp:
1176         (NP_Call):
1177         (NP_Evaluate):
1178         (NP_GetProperty):
1179         (NP_ToString):
1180         (NP_GetPropertyAtIndex):
1181         * bindings/NP_runtime.h:
1182         * bindings/make_testbindings:
1183         * bindings/runtime.cpp:
1184         (Instance::createBindingForLanguageInstance):
1185
1186 2004-03-10  Richard Williamson   <rjw@apple.com>
1187
1188         Updated header to include proposed changes from
1189         plugin-futures list.  Calls from plugin to JavaScript
1190         are now asynchronous.
1191
1192         Reviewed by Chris.
1193
1194         * bindings/NP_runtime.h:
1195
1196 === Safari-131 ===
1197
1198 2004-03-04  Richard Williamson   <rjw@apple.com>
1199
1200         Implementation of NP_JavaScriptObject.  This is the 'C' class
1201         that wraps a JavaScript object.
1202
1203         Reviewed by Chris.
1204
1205         * JavaScriptCore.pbproj/project.pbxproj:
1206         * bindings/NP_jsobject.cpp: Added.
1207         (coerceValueToNPValueType):
1208         (convertValueToNPValueType):
1209         (convertNPValueTypeToValue):
1210         (listFromNPArray):
1211         (jsAllocate):
1212         (jsDeallocate):
1213         (identiferFromNPIdentifier):
1214         (NP_Call):
1215         (NP_Evaluate):
1216         (NP_GetProperty):
1217         (NP_SetProperty):
1218         (NP_RemoveProperty):
1219         (NP_ToString):
1220         (NP_GetPropertyAtIndex):
1221         (NP_SetPropertyAtIndex):
1222         * bindings/NP_runtime.cpp:
1223         (NP_ObjectAtIndex):
1224         * bindings/NP_runtime.h:
1225         * bindings/runtime_object.h:
1226
1227 2004-03-04  Richard Williamson   <rjw@apple.com>
1228
1229         Added NP_Array implementation.  
1230
1231         Changed NP_Boolean to just depend on two static instances, no
1232         space is required for values.
1233
1234         Reviewed by Chris.
1235
1236         * bindings/NP_runtime.cpp:
1237         (NP_CreateBoolean):
1238         (NP_BoolFromBoolean):
1239         (arrayAllocate):
1240         (arrayDeallocate):
1241         (NP_CreateArray):
1242         (NP_CreateArrayV):
1243         (NP_ObjectAtIndex):
1244         * bindings/NP_runtime.h:
1245
1246 2004-03-03  Darin Adler  <darin@apple.com>
1247
1248         Reviewed by Vicki.
1249
1250         * English.lproj/InfoPlist.strings: Removed. No need to localize the version and
1251         copyright string, and that's all that was in here.
1252         * JavaScriptCore.pbproj/project.pbxproj: Removed InfoPlist.strings from build.
1253
1254 2004-03-03  Richard Williamson   <rjw@apple.com>
1255
1256         More 'C' binding implementation.  Fleshed out all the
1257         'primitive' data types.
1258
1259         Reviewed by Chris.
1260
1261         * bindings/NP_runtime.cpp:
1262         (NP_ReleaseObject):
1263         (numberAllocate):
1264         (stringAllocate):
1265         (stringDeallocate):
1266         (NP_CreateStringWithUTF8):
1267         (NP_CreateStringWithUTF16):
1268         (NP_UTF8FromString):
1269         (NP_UTF16FromString):
1270         (NP_StringLength):
1271         (booleanAllocate):
1272         (booleanDeallocate):
1273         (NP_CreateBoolean):
1274         (NP_BoolFromBoolean):
1275         (nullAllocate):
1276         (nullDeallocate):
1277         (NP_GetNull):
1278         (undefinedAllocate):
1279         (undefinedDeallocate):
1280         (NP_GetUndefined):
1281         * bindings/NP_runtime.h:
1282
1283 2004-03-03  Richard Williamson   <rjw@apple.com>
1284
1285         More 'C' binding implementation.
1286
1287         Reviewed by Chris.
1288
1289         * bindings/NP_runtime.cpp:
1290         (identifierEqual):
1291         (identifierHash):
1292         (getIdentifierDictionary):
1293         (NP_IdentifierFromUTF8):
1294         (NP_UTF8FromIdentifier):
1295         (NP_CreateObject):
1296         (NP_ReleaseObject):
1297         (NP_IsKindOfClass):
1298         (numberCreate):
1299         (NP_CreateNumberWithInt):
1300         (NP_CreateNumberWithFloat):
1301         (NP_CreateNumberWithDouble):
1302         (NP_IntFromNumber):
1303         (NP_FloatFromNumber):
1304         (NP_DoubleFromNumber):
1305         * bindings/NP_runtime.h:
1306
1307 2004-03-02  Richard Williamson   <rjw@apple.com>
1308
1309         Removed retain/release from NP_Class.  Classes will not be allowed to implement their
1310         own customer retain/release scheme.
1311
1312         Reviewed by Chris.
1313
1314         * bindings/NP_runtime.cpp:
1315         (NP_RetainObject):
1316         (NP_ReleaseObject):
1317         * bindings/NP_runtime.h:
1318
1319 2004-03-02  Richard Williamson   <rjw@apple.com>
1320
1321         C binding API.  Partial implementation.
1322
1323         Completed ObjectiveC bindings (not based on the C API).  These will re-implemented over the C binding API, but I wanted to get this code in the tree.
1324
1325         Factored root object reference counting scheme.  It is now useful independent
1326         of LiveConnect.
1327
1328         Reviewed by Chris.
1329
1330         * JavaScriptCore.pbproj/project.pbxproj:
1331         * bindings/NP_runtime.cpp: Added.
1332         (NP_IdentifierFromUTF8):
1333         (NP_GetIdentifiers):
1334         (NP_UTF8FromIdentifier):
1335         (NP_CreateObject):
1336         (NP_RetainObject):
1337         (NP_ReleaseObject):
1338         (NP_IsKindOfClass):
1339         (NP_SetException):
1340         (NP_Call):
1341         (NP_Evaluate):
1342         (NP_GetProperty):
1343         (NP_SetProperty):
1344         (NP_RemoveProperty):
1345         (NP_ToString):
1346         (NP_GetPropertyAtIndex):
1347         (NP_SetPropertyAtIndex):
1348         (NP_CreateNumberWithInt):
1349         (NP_CreateNumberWithFloat):
1350         (NP_CreateNumberWithDouble):
1351         (NP_IntFromNumber):
1352         (NP_FloatFromNumber):
1353         (NP_DoubleFromNumber):
1354         (NP_CreateStringWithUTF8):
1355         (NP_CreateStringWithUTF16):
1356         (NP_UTF8FromString):
1357         (NP_UTF16FromString):
1358         (NP_CreateBoolean):
1359         (NP_BoolFromBoolean):
1360         (NP_GetNull):
1361         (NP_GetUndefined):
1362         (NP_CreateArray):
1363         (NP_CreateArrayV):
1364         (NP_ObjectAtIndex):
1365         * bindings/NP_runtime.h: Added.
1366         * bindings/jni/jni_jsobject.cpp:
1367         (JSObject::invoke):
1368         (JSObject::finalize):
1369         (JSObject::createNative):
1370         (JSObject::convertValueToJObject):
1371         * bindings/jni/jni_jsobject.h:
1372         * bindings/objc/objc_jsobject.h:
1373         * bindings/objc/objc_jsobject.mm:
1374         (rootForView):
1375         (windowJavaScriptObject):
1376         (-[JavaScriptObject initWithObjectImp:KJS::root:Bindings::]):
1377         (-[JavaScriptObject dealloc]):
1378         (-[JavaScriptObject _convertValueToObjcValue:KJS::]):
1379         (-[JavaScriptObject call:arguments:]):
1380         (-[JavaScriptObject evaluate:]):
1381         (-[JavaScriptObject getMember:]):
1382         (-[JavaScriptObject setMember:value:]):
1383         (-[JavaScriptObject removeMember:]):
1384         (-[JavaScriptObject toString]):
1385         (-[JavaScriptObject getSlot:]):
1386         (-[JavaScriptObject setSlot:value:]):
1387         * bindings/objc/objc_utility.h:
1388         * bindings/objc/objc_utility.mm:
1389         (KJS::Bindings::convertValueToObjcValue):
1390         * bindings/runtime_root.cpp: Added.
1391         (getReferencesByRootDictionary):
1392         (getReferencesDictionary):
1393         (KJS::Bindings::findReferenceDictionary):
1394         (KJS::Bindings::rootForImp):
1395         (KJS::Bindings::addNativeReference):
1396         (KJS::Bindings::removeNativeReference):
1397         (completedJavaScriptAccess):
1398         (initializeJavaScriptAccessLock):
1399         (lockJavaScriptAccess):
1400         (unlockJavaScriptAccess):
1401         (RootObject::dispatchToJavaScriptThread):
1402         (performJavaScriptAccess):
1403         (RootObject::setFindRootObjectForNativeHandleFunction):
1404         (RootObject::removeAllNativeReferences):
1405         * bindings/runtime_root.h: Added.
1406         (KJS::Bindings::RootObject::RootObject):
1407         (KJS::Bindings::RootObject::~RootObject):
1408         (KJS::Bindings::RootObject::setRootObjectImp):
1409         (KJS::Bindings::RootObject::rootObjectImp):
1410         (KJS::Bindings::RootObject::setInterpreter):
1411         (KJS::Bindings::RootObject::interpreter):
1412         (KJS::Bindings::RootObject::findRootObjectForNativeHandleFunction):
1413         (KJS::Bindings::RootObject::runLoop):
1414         (KJS::Bindings::RootObject::performJavaScriptSource):
1415
1416 === Safari-130 ===
1417
1418 === Safari-129 ===
1419
1420 2004-02-18  Richard Williamson   <rjw@apple.com>
1421
1422         Added NSNumber/Number conversion.
1423
1424         Removed some unnecessary KJS:: namespace specifiers.
1425
1426         Reviewed by Ken.
1427
1428         * bindings/objc/objc_utility.mm:
1429         (KJS::Bindings::convertValueToObjcValue):
1430         (KJS::Bindings::convertObjcValueToValue):
1431         * bindings/runtime_array.h:
1432
1433 2004-02-18  Richard Williamson   <rjw@apple.com>
1434
1435         Added support for export NSArrays.
1436
1437         Updated valueAt() to take an ExecState so we can throw
1438         JS exceptions.
1439
1440         Implemented excludeSelectorFromJavaScript: in ObjcClass.  This allows
1441         ObjectiveC classes to control the visibility of their methods in 
1442         JavaScript.
1443
1444         Reviewed by Ken.
1445
1446         * bindings/jni/jni_runtime.cpp:
1447         (JavaField::valueFromInstance):
1448         (JavaArray::valueAt):
1449         * bindings/jni/jni_runtime.h:
1450         * bindings/objc/objc_class.mm:
1451         (ObjcClass::methodsNamed):
1452         * bindings/objc/objc_runtime.h:
1453         (KJS::Bindings::ObjcArray::getObjcArray):
1454         * bindings/objc/objc_runtime.mm:
1455         (ObjcField::valueFromInstance):
1456         (ObjcField::setValueToInstance):
1457         (ObjcArray::ObjcArray):
1458         (ObjcArray::~ObjcArray):
1459         (ObjcArray::operator=):
1460         (ObjcArray::setValueAt):
1461         (ObjcArray::valueAt):
1462         (ObjcArray::getLength):
1463         * bindings/objc/objc_utility.mm:
1464         (KJS::Bindings::convertValueToObjcValue):
1465         (KJS::Bindings::convertObjcValueToValue):
1466         * bindings/runtime.cpp:
1467         (Instance::getValueOfField):
1468         * bindings/runtime.h:
1469         * bindings/runtime_array.cpp:
1470         (RuntimeArrayImp::get):
1471         * bindings/runtime_object.cpp:
1472         (RuntimeObjectImp::get):
1473
1474 2004-02-17  Richard Williamson   <rjw@apple.com>
1475
1476         Added String <-> NSString conversion.
1477         Added tests of String <-> NSString conversion to test program.
1478
1479         Reviewed by Chris.
1480
1481         * bindings/objc/objc_utility.mm:
1482         (KJS::Bindings::convertValueToObjcValue):
1483         (KJS::Bindings::convertObjcValueToValue):
1484         * bindings/test.js:
1485         * bindings/testbindings.mm:
1486         (-[MyFirstInterface getString]):
1487
1488 2004-02-15  Darin Adler  <darin@apple.com>
1489
1490         Reviewed by Dave.
1491
1492         * JavaScriptCore.pbproj/project.pbxproj: Tweak build styles a bit, fixing OptimizedWithSymbols,
1493         and removing redundant settings of things that match defaults in other build styles.
1494
1495 2004-02-13  Richard Williamson   <rjw@apple.com>
1496
1497         Work towards the JavaScript ObjC bindings.  The bindings now work for 
1498         simple scalar types.  testbindings.mm is an illustration of how the 
1499         bindings work.
1500
1501         Reviewed by Ken.
1502
1503         * JavaScriptCore.pbproj/project.pbxproj:
1504         * Makefile.am:
1505         * bindings/jni/jni_class.cpp:
1506         (JavaClass::methodsNamed):
1507         * bindings/jni/jni_class.h:
1508         * bindings/jni/jni_instance.cpp:
1509         (JavaInstance::invokeMethod):
1510         * bindings/jni/jni_instance.h:
1511         * bindings/jni/jni_runtime.h:
1512         (KJS::Bindings::JavaMethod::returnType):
1513         * bindings/make_testbindings: Added.
1514         * bindings/objc/objc_class.h: Added.
1515         (KJS::Bindings::ObjcClass::~ObjcClass):
1516         (KJS::Bindings::ObjcClass::ObjcClass):
1517         (KJS::Bindings::ObjcClass::operator=):
1518         (KJS::Bindings::ObjcClass::constructorAt):
1519         (KJS::Bindings::ObjcClass::numConstructors):
1520         * bindings/objc/objc_class.mm: Added.
1521         (ObjcClass::_commonDelete):
1522         (ObjcClass::_commonCopy):
1523         (ObjcClass::_commonInit):
1524         (_createClassesByIsAIfNecessary):
1525         (ObjcClass::classForIsA):
1526         (ObjcClass::ObjcClass):
1527         (ObjcClass::name):
1528         (ObjcClass::methodsNamed):
1529         (ObjcClass::fieldNamed):
1530         * bindings/objc/objc_header.h: Added.
1531         * bindings/objc/objc_instance.h: Added.
1532         (KJS::Bindings::ObjcInstance::getObject):
1533         * bindings/objc/objc_instance.mm: Added.
1534         (ObjcInstance::ObjcInstance):
1535         (ObjcInstance::~ObjcInstance):
1536         (ObjcInstance::operator=):
1537         (ObjcInstance::begin):
1538         (ObjcInstance::end):
1539         (ObjcInstance::getClass):
1540         (ObjcInstance::invokeMethod):
1541         (ObjcInstance::defaultValue):
1542         (ObjcInstance::stringValue):
1543         (ObjcInstance::numberValue):
1544         (ObjcInstance::booleanValue):
1545         (ObjcInstance::valueOf):
1546         * bindings/objc/objc_jsobject.h: Added.
1547         * bindings/objc/objc_jsobject.mm: Added.
1548         * bindings/objc/objc_runtime.h:
1549         (KJS::Bindings::ObjcField::~ObjcField):
1550         (KJS::Bindings::ObjcField::ObjcField):
1551         (KJS::Bindings::ObjcField::operator=):
1552         (KJS::Bindings::ObjcMethod::ObjcMethod):
1553         (KJS::Bindings::ObjcMethod::~ObjcMethod):
1554         (KJS::Bindings::ObjcMethod::operator=):
1555         * bindings/objc/objc_runtime.mm: Added.
1556         (ObjcMethod::ObjcMethod):
1557         (ObjcMethod::name):
1558         (ObjcMethod::numParameters):
1559         (ObjcMethod::getMethodSignature):
1560         (ObjcField::ObjcField):
1561         (ObjcField::name):
1562         (ObjcField::type):
1563         (ObjcField::valueFromInstance):
1564         (ObjcField::setValueToInstance):
1565         * bindings/objc/objc_utility.h: Added.
1566         (KJS::Bindings::):
1567         * bindings/objc/objc_utility.mm: Added.
1568         (KJS::Bindings::JSMethodNameToObjCMethodName):
1569         (KJS::Bindings::convertValueToObjcValue):
1570         (KJS::Bindings::convertObjcValueToValue):
1571         (KJS::Bindings::objcValueTypeForType):
1572         * bindings/runtime.cpp:
1573         (MethodList::MethodList):
1574         (MethodList::operator=):
1575         (Instance::setValueOfField):
1576         (Instance::createBindingForLanguageInstance):
1577         (Instance::createRuntimeObject):
1578         * bindings/runtime.h:
1579         * bindings/runtime_method.cpp:
1580         (RuntimeMethodImp::RuntimeMethodImp):
1581         (RuntimeMethodImp::get):
1582         (RuntimeMethodImp::call):
1583         * bindings/runtime_method.h:
1584         * bindings/runtime_object.cpp:
1585         (RuntimeObjectImp::get):
1586         (RuntimeObjectImp::hasProperty):
1587         * bindings/test.js: Added.
1588         * bindings/testbindings.mm: Added.
1589         (-[MySecondInterface init]):
1590         (-[MyFirstInterface init]):
1591         (-[MyFirstInterface dealloc]):
1592         (+[MyFirstInterface JavaScriptNameForSelector:]):
1593         (-[MyFirstInterface getInt]):
1594         (-[MyFirstInterface setInt:]):
1595         (-[MyFirstInterface getMySecondInterface]):
1596         (-[MyFirstInterface logMessage:]):
1597         (GlobalImp::className):
1598         (readJavaScriptFromFile):
1599         (main):
1600
1601 === Safari-128 ===
1602
1603 2004-02-08  Darin Adler  <darin@apple.com>
1604
1605         Reviewed by Dave.
1606
1607         - fixed things seen in the profile, for a total speedup of 4% on cvs-base (including changes across all projects)
1608
1609         * JavaScriptCorePrefix.h: Add a workaround for a bug in our system headers that prevents the <ctype.h>
1610         macros from working right in C++ code that uses the <cctype> header.
1611
1612         * kjs/ustring.cpp:
1613         (KJS::inlineUTF8SequenceLengthNonASCII): Added.
1614         (KJS::UTF8SequenceLengthNonASCII): Added.
1615         (KJS::inlineUTF8SequenceLength): Added.
1616         (KJS::UTF8SequenceLength): Calls inlineUTF8SequenceLengthNonASCII now.
1617         (KJS::decodeUTF8Sequence): Use new inlineUTF8SequenceLengthNonASCII; faster for ASCII.
1618         (KJS::createSortedOffsetsArray): Add special case for 1, 2, and 3 offsets, so we don't do qsort for those.
1619         (KJS::convertUTF16OffsetsToUTF8Offsets): Use new inlineUTF8SequenceLengthNonASCII; faster for ASCII.
1620         (KJS::convertUTF8OffsetsToUTF16Offsets): Use new inlineUTF8SequenceLengthNonASCII; faster for ASCII.
1621
1622         - fixed the test program so it won't hit the interpreter lock assertion
1623
1624         * kjs/testkjs.cpp: (main): Just lock around the whole thing, since the test is singly threaded.
1625
1626 === Safari-127 ===
1627
1628 2004-02-06  Richard Williamson   <rjw@apple.com>
1629
1630         Fixed 3550242 and 3546977.  The first diff prevents an assert from firing.  The second diff prevents a JavaScript exception, caused be an invalid conversion, which has a downstream consequence of preventing a valid conversion.
1631
1632         Reviewed by John.
1633
1634         * bindings/jni/jni_jsobject.cpp:
1635         (JSObject::toString):
1636         * bindings/jni/jni_utility.cpp:
1637         (KJS::Bindings::convertValueToJValue):
1638
1639 2004-02-02  Darin Adler  <darin@apple.com>
1640
1641         Reviewed by Maciej.
1642
1643         - fixed <rdar://problem/3546613>: array of negative size leads to crash (test page at oscar.the-rileys.net)
1644
1645         * kjs/array_object.cpp:
1646         (ArrayInstanceImp::ArrayInstanceImp): If the length is greater than 10,000, don't allocate an array until
1647         we start putting values in. This prevents new Array(2147483647) from causing trouble.
1648         (ArrayObjectImp::construct): Check number as described in specification, and raise a range error if the
1649         number is out of range. This prevents new Array(-1) from causing trouble.
1650
1651         - fixed <rdar://problem/3545756>: Math.round screws up on numbers bigger than 2^31 (incorrect results on HP-35 calculator page)
1652
1653         * kjs/math_object.cpp: (MathFuncImp::call): Change implementation to be much simpler and not involve
1654         casting to int. Results now match those in other browsers.
1655
1656 2004-02-02  Darin Adler  <darin@apple.com>
1657
1658         Reviewed by Maciej.
1659
1660         - fixed <rdar://problem/3519285>: integer operations on large negative numbers yield bad results (discovered with "HTMLCrypt")
1661         - fixed other related overflow issues
1662
1663         * kjs/value.h: Changed return types of toInteger, toInt32, toUInt32, and toUInt16.
1664         * kjs/value.cpp:
1665         (ValueImp::toInteger): Change to return a double, since this operation, from the ECMA specification,
1666         must not restrict values to the range of a particular integer type.
1667         (ValueImp::toInt32): Used a sized integer type for the result of this function, and also added
1668         proper handling for negative results from fmod.
1669         (ValueImp::toUInt32): Ditto.
1670         (ValueImp::toUInt16): Ditto.
1671         (ValueImp::dispatchToUInt32): Changed result type from unsigned to uint32_t.
1672
1673         * kjs/array_object.cpp: (ArrayProtoFuncImp::call): Use a double instead of an int to handle
1674         out-of-integer-range values better in the slice function.
1675         * kjs/internal.cpp: (KJS::roundValue): Streamline the function, handling NAN and infinity properly.
1676         * kjs/number_object.cpp: (NumberProtoFuncImp::call): Use a double instead of an int to handle
1677         out-of-integer-range values better in the toString function.
1678         * kjs/string_object.cpp: (StringProtoFuncImp::call): Use a double instead of an int to handle
1679         out-of-integer-range values better in the charAt, charCodeAt, indexOf, lastIndexOf, slice,
1680         and substr functions.
1681
1682 === Safari-126 ===
1683
1684 2004-01-30  Richard Williamson   <rjw@apple.com>
1685
1686         Fixed 3542044.  Create KJS::String using UString constructor instead of passing UTF8 string to char* constructor.
1687
1688         Reviewed by Darin.
1689
1690         * bindings/jni/jni_instance.cpp:
1691         (JavaInstance::stringValue):
1692
1693 2004-01-26  Darin Adler  <darin@apple.com>
1694
1695         * Makefile.am: Switch from pbxbuild to xcodebuild.
1696
1697 2004-01-22  Richard Williamson   <rjw@apple.com>
1698
1699         Added stubs for ObjC language binding to JavaScript.
1700
1701         * JavaScriptCore.pbproj/project.pbxproj:
1702         * bindings/jni/jni_runtime.h:
1703         * bindings/objc/objc_runtime.h: Added.
1704         (KJS::Bindings::ObjcParameter::ObjcParameter):
1705         (KJS::Bindings::ObjcParameter::~ObjcParameter):
1706         (KJS::Bindings::ObjcParameter::operator=):
1707         (KJS::Bindings::ObjcParameter::type):
1708         (KJS::Bindings::ObjcConstructor::ObjcConstructor):
1709         (KJS::Bindings::ObjcConstructor::~ObjcConstructor):
1710         (KJS::Bindings::ObjcConstructor::_commonCopy):
1711         (KJS::Bindings::ObjcConstructor::operator=):
1712         (KJS::Bindings::ObjcConstructor::value):
1713         (KJS::Bindings::ObjcConstructor::parameterAt):
1714         (KJS::Bindings::ObjcConstructor::numParameters):
1715         (KJS::Bindings::ObjcField::ObjcField):
1716         (KJS::Bindings::ObjcField::~ObjcField):
1717         * bindings/runtime.h:
1718
1719 2004-01-22  Richard Williamson   <rjw@apple.com>
1720
1721         Simplified JavaString by using UString as backing store.  This
1722         revealed a bug in CString's assignment operator which I fixed.
1723
1724         Removed some dead code.
1725  
1726         Reviewed by John.
1727
1728         * bindings/jni/jni_runtime.h:
1729         (KJS::Bindings::JavaString::JavaString):
1730         (KJS::Bindings::JavaString::_commonInit):
1731         (KJS::Bindings::JavaString::UTF8String):
1732         (KJS::Bindings::JavaString::uchars):
1733         (KJS::Bindings::JavaString::length):
1734         (KJS::Bindings::JavaString::ustring):
1735         * bindings/runtime_object.cpp:
1736         (RuntimeObjectImp::RuntimeObjectImp):
1737         * bindings/runtime_object.h:
1738         * kjs/ustring.cpp:
1739         (KJS::CString::CString):
1740         (KJS::CString::operator=):
1741
1742 === Safari-125 ===
1743
1744 === Safari-124 ===
1745
1746 2004-01-16  Richard Williamson   <rjw@apple.com>
1747
1748         Fixed 3525853.  We weren't handling mapping to overloaded Java
1749         methods very well.  Even though this is undefined the other
1750         browsers support it.  Also fixed a bug with returning arrays
1751         from Java functions.
1752
1753         Reviewed by John.
1754
1755         * bindings/jni/jni_class.cpp:
1756         (JavaClass::_commonInit):
1757         (JavaClass::methodsNamed):
1758         * bindings/jni/jni_class.h:
1759         * bindings/jni/jni_instance.cpp:
1760         (JavaInstance::invokeMethod):
1761         * bindings/jni/jni_instance.h:
1762         * bindings/jni/jni_runtime.cpp:
1763         (JavaArray::convertJObjectToArray):
1764         (JavaField::valueFromInstance):
1765         (JavaMethod::signature):
1766         (JavaArray::valueAt):
1767         * bindings/jni/jni_runtime.h:
1768         * bindings/jni_jsobject.cpp:
1769         (JSObject::call):
1770         (JSObject::convertJObjectToValue):
1771         * bindings/runtime.cpp:
1772         (MethodList::addMethod):
1773         (MethodList::length):
1774         (MethodList::methodAt):
1775         (MethodList::~MethodList):
1776         * bindings/runtime.h:
1777         (KJS::Bindings::MethodList::MethodList):
1778         * bindings/runtime_method.cpp:
1779         (RuntimeMethodImp::RuntimeMethodImp):
1780         (RuntimeMethodImp::get):
1781         (RuntimeMethodImp::call):
1782         * bindings/runtime_method.h:
1783         * bindings/runtime_object.cpp:
1784         (RuntimeObjectImp::get):
1785         (RuntimeObjectImp::hasProperty):
1786
1787 2004-01-16  Richard Williamson   <rjw@apple.com>
1788
1789         Fixed 3531229.  Another place that needs the  Push/PopLocalFrame
1790         protection implemented for 3530401.
1791
1792         Reviewed by John.
1793
1794         * bindings/runtime_method.cpp:
1795         (RuntimeMethodImp::call):
1796
1797 2004-01-15  Richard Williamson   <rjw@apple.com>
1798
1799         Fixed 3530401.  JNI doesn't cleanup local refs created on the
1800         main thread.   IMO this is a bad bug in our JMI implementation.
1801
1802         To work-around the problem I explicitly delete all local refs.
1803         Further, I've added Push/PopLocalFrame calls to catch any refs
1804         that I may have missed.  This will guarantee that we don't leak
1805         any Java references.
1806
1807         Reviewed by John.
1808
1809         * bindings/jni/jni_class.cpp:
1810         (JavaClass::_commonInit):
1811         (JavaClass::JavaClass):
1812         * bindings/jni/jni_instance.cpp:
1813         (JavaInstance::begin):
1814         (JavaInstance::end):
1815         * bindings/jni/jni_instance.h:
1816         * bindings/jni/jni_runtime.cpp:
1817         (JavaConstructor::JavaConstructor):
1818         (JavaMethod::JavaMethod):
1819         * bindings/jni_jsobject.cpp:
1820         (JSObject::listFromJArray):
1821         * bindings/runtime.h:
1822         (KJS::Bindings::Instance::begin):
1823         (KJS::Bindings::Instance::end):
1824         * bindings/runtime_object.cpp:
1825         (RuntimeObjectImp::get):
1826         (RuntimeObjectImp::put):
1827         (RuntimeObjectImp::canPut):
1828         (RuntimeObjectImp::hasProperty):
1829         (RuntimeObjectImp::defaultValue):
1830
1831 2004-01-15  Vicki Murley  <vicki@apple.com>
1832
1833         Reviewed by Darin.
1834
1835         * JavaScriptCore.pbproj/project.pbxproj: Update copyright date to 2004.
1836
1837 2004-01-14  Richard Williamson   <rjw@apple.com>
1838         
1839         Fixed 3529466.  With recent changes to Java plugin we must no
1840         longer call DeleteLocalRef().  Not a problem, it was an optimization anyway.
1841
1842         Reviewed by John.
1843
1844         * bindings/jni/jni_instance.cpp:
1845         (JObjectWrapper::JObjectWrapper):
1846
1847 === Safari-122 ===
1848
1849 2004-01-14  Richard Williamson   <rjw@apple.com>
1850
1851         Fixed 3529010.
1852
1853         Finalize may be called on an JSObject after we've already remove all our references.  The assert in this case is firing because we've received a finalize call from Java for an instance that we no longer know about.  The fix is to check in finalize that we're getting a call on an instance that we still care about.
1854
1855         Reviewed by John.
1856
1857         * bindings/jni_jsobject.cpp:
1858         (addJavaReference):
1859         (removeJavaReference):
1860         (RootObject::removeAllJavaReferencesForRoot):
1861         (JSObject::invoke):
1862
1863 2004-01-13  Richard Williamson   <rjw@apple.com>
1864
1865         Fixed 3528324. 
1866
1867         The run loop that is used to execute JavaScript (in practice, always the main run loop) is held in a class variable.  It is set and retained once and should not be released.  Unfortunately is it being released when the 'root' object on a LiveConnect applet is released.  This has the symptom of eventually causing an deallocation of the main run loop!  Usually after about 5 instantiations/destructions of a LiveConnect applet.  The CFRelease of the run loop was removed.
1868
1869         Reviewed by Hyatt.
1870
1871         * bindings/jni_jsobject.h:
1872         (KJS::Bindings::RootObject::~RootObject):
1873
1874 === Safari-121 ===
1875
1876 === Safari-120 ===
1877
1878 2004-01-06  Richard Williamson   <rjw@apple.com>
1879
1880         Fixed 3521814.  Finalize messages weren't being dispatched!
1881
1882         Reviewed by John.
1883
1884         * bindings/jni_jsobject.cpp:
1885         (JSObject::invoke):
1886
1887 2004-01-05  Richard Williamson   <rjw@apple.com>
1888
1889         Added cache of JNI method IDs to minimize allocations.  This mitigates the problem
1890         described by 3515579.
1891
1892         Also cleanup up logging of Java exceptions.
1893
1894         Reviewed by John.
1895
1896         * bindings/jni/jni_class.cpp:
1897         (JavaClass::classForInstance):
1898         * bindings/jni/jni_instance.cpp:
1899         (JavaInstance::JavaInstance):
1900         (JavaInstance::getClass):
1901         (JavaInstance::invokeMethod):
1902         (JObjectWrapper::JObjectWrapper):
1903         (JObjectWrapper::~JObjectWrapper):
1904         * bindings/jni/jni_instance.h:
1905         (KJS::Bindings::JavaInstance::operator=):
1906         * bindings/jni/jni_runtime.cpp:
1907         (JavaMethod::JavaMethod):
1908         (JavaMethod::methodID):
1909         * bindings/jni/jni_runtime.h:
1910         (KJS::Bindings::JavaMethod::JavaMethod):
1911         * bindings/jni/jni_utility.cpp:
1912         (callJNIMethod):
1913         (callJNIMethodIDA):
1914         (callJNIMethodA):
1915         (KJS::Bindings::getMethodID):
1916         (KJS::Bindings::callJNIVoidMethodIDA):
1917         (KJS::Bindings::callJNIObjectMethodIDA):
1918         (KJS::Bindings::callJNIByteMethodIDA):
1919         (KJS::Bindings::callJNICharMethodIDA):
1920         (KJS::Bindings::callJNIShortMethodIDA):
1921         (KJS::Bindings::callJNIIntMethodIDA):
1922         (KJS::Bindings::callJNILongMethodIDA):
1923         (KJS::Bindings::callJNIFloatMethodIDA):
1924         (KJS::Bindings::callJNIDoubleMethodIDA):
1925         (KJS::Bindings::callJNIBooleanMethodIDA):
1926         (KJS::Bindings::getCharactersFromJStringInEnv):
1927         (KJS::Bindings::getUCharactersFromJStringInEnv):
1928         (KJS::Bindings::getJNIField):
1929         * bindings/jni/jni_utility.h:
1930
1931 l2003-12-23  John Sullivan  <sullivan@apple.com>
1932
1933         * JavaScriptCore.pbproj/project.pbxproj:
1934         Xcode version wars, harmless
1935
1936 2003-12-23  Darin Adler  <darin@apple.com>
1937
1938         Reviewed by John (concept, not code, which is just the old code coming back).
1939
1940         - fixed 3518092: REGRESSION (100-119): getting NaN instead of HH:MM times
1941
1942         * kjs/date_object.cpp: Added back our CF-based implementations of gmtime, localtime,
1943         mktime, timegm, and time, because mktime, at least, won't handle a year of 0.
1944
1945 2003-12-19  Richard Williamson   <rjw@apple.com>
1946
1947         Fixed 3515597.  When an error occurs we need
1948         to make sure result values are zeroed.
1949
1950         Cleaned up logs by adding a newline.
1951
1952         Reviewed by John.
1953
1954         * bindings/jni/jni_utility.cpp:
1955         (KJS::Bindings::getJavaVM):
1956         (KJS::Bindings::getJNIEnv):
1957         (callJNIMethod):
1958         (callJNIMethodA):
1959         (KJS::Bindings::getJNIField):
1960         * bindings/jni_jsobject.cpp:
1961         (JSObject::convertValueToJObject):
1962
1963 === Safari-119 ===
1964
1965 2003-12-17  Richard Williamson   <rjw@apple.com>
1966
1967         Ensure that all the symbols we export are in the KJS
1968         namespace (3512245).
1969
1970         Also renamed JavaString.characters() to JavaString.UTF8String()
1971         for enhanced clarity.
1972
1973         Added some sanity checking to constructor of JObjectWrapper.
1974
1975         Reviewed by Dave.
1976
1977         * ChangeLog:
1978         * bindings/jni/jni_class.cpp:
1979         * bindings/jni/jni_class.h:
1980         * bindings/jni/jni_instance.cpp:
1981         (JavaInstance::invokeMethod):
1982         (JObjectWrapper::JObjectWrapper):
1983         * bindings/jni/jni_instance.h:
1984         * bindings/jni/jni_runtime.cpp:
1985         (JavaParameter::JavaParameter):
1986         (JavaField::JavaField):
1987         (JavaMethod::JavaMethod):
1988         (JavaMethod::signature):
1989         * bindings/jni/jni_runtime.h:
1990         (KJS::Bindings::JavaString::ascii):
1991         (KJS::Bindings::JavaString::UTF8String):
1992         (KJS::Bindings::JavaString::JavaString):
1993         (KJS::Bindings::JavaString::_commonInit):
1994         (KJS::Bindings::JavaString::uchars):
1995         (KJS::Bindings::JavaString::length):
1996         (KJS::Bindings::JavaString::ustring):
1997         (KJS::Bindings::JavaParameter::type):
1998         (KJS::Bindings::JavaField::name):
1999         (KJS::Bindings::JavaField::type):
2000         (KJS::Bindings::JavaMethod::name):
2001         (KJS::Bindings::JavaMethod::returnType):
2002         * bindings/jni/jni_utility.cpp:
2003         (KJS::Bindings::getJavaVM):
2004         (KJS::Bindings::getJNIEnv):
2005         (KJS::Bindings::callJNIVoidMethod):
2006         (KJS::Bindings::callJNIObjectMethod):
2007         (KJS::Bindings::callJNIBooleanMethod):
2008         (KJS::Bindings::callJNIByteMethod):
2009         (KJS::Bindings::callJNICharMethod):
2010         (KJS::Bindings::callJNIShortMethod):
2011         (KJS::Bindings::callJNIIntMethod):
2012         (KJS::Bindings::callJNILongMethod):
2013         (KJS::Bindings::callJNIFloatMethod):
2014         (KJS::Bindings::callJNIDoubleMethod):
2015         (KJS::Bindings::callJNIVoidMethodA):
2016         (KJS::Bindings::callJNIObjectMethodA):
2017         (KJS::Bindings::callJNIByteMethodA):
2018         (KJS::Bindings::callJNICharMethodA):
2019         (KJS::Bindings::callJNIShortMethodA):
2020         (KJS::Bindings::callJNIIntMethodA):
2021         (KJS::Bindings::callJNILongMethodA):
2022         (KJS::Bindings::callJNIFloatMethodA):
2023         (KJS::Bindings::callJNIDoubleMethodA):
2024         (KJS::Bindings::callJNIBooleanMethodA):
2025         (KJS::Bindings::getCharactersFromJString):
2026         (KJS::Bindings::releaseCharactersForJString):
2027         (KJS::Bindings::getCharactersFromJStringInEnv):
2028         (KJS::Bindings::releaseCharactersForJStringInEnv):
2029         (KJS::Bindings::getUCharactersFromJStringInEnv):
2030         (KJS::Bindings::releaseUCharactersForJStringInEnv):
2031         (KJS::Bindings::JNITypeFromClassName):
2032         (KJS::Bindings::signatureFromPrimitiveType):
2033         (KJS::Bindings::JNITypeFromPrimitiveType):
2034         (KJS::Bindings::getJNIField):
2035         (KJS::Bindings::convertValueToJValue):
2036         * bindings/jni/jni_utility.h:
2037         * bindings/jni_jsobject.cpp:
2038         (KJS::Bindings::JSObject::invoke):
2039         (KJS::Bindings::JSObject::JSObject):
2040         (KJS::Bindings::JSObject::call):
2041         (KJS::Bindings::JSObject::eval):
2042         (KJS::Bindings::JSObject::getMember):
2043         (KJS::Bindings::JSObject::setMember):
2044         (KJS::Bindings::JSObject::removeMember):
2045         (KJS::Bindings::JSObject::getSlot):
2046         (KJS::Bindings::JSObject::setSlot):
2047         (KJS::Bindings::JSObject::toString):
2048         (KJS::Bindings::JSObject::finalize):
2049         (KJS::Bindings::JSObject::createNative):
2050         (KJS::Bindings::JSObject::convertValueToJObject):
2051         (KJS::Bindings::JSObject::convertJObjectToValue):
2052         (KJS::Bindings::JSObject::listFromJArray):
2053         * bindings/jni_jsobject.h:
2054         * bindings/runtime.cpp:
2055         * bindings/runtime.h:
2056         * bindings/runtime_method.cpp:
2057         * bindings/runtime_method.h:
2058
2059 === Safari-118 ===
2060
2061 2003-12-16  Richard Williamson   <rjw@apple.com>
2062
2063         Ack!  More assertions.  Lock ALL entry points into the interpreter!
2064         (3511733).
2065
2066         Reviewed by Ken.
2067
2068         * bindings/jni_jsobject.cpp:
2069         (Bindings::JSObject::call):
2070         (Bindings::JSObject::eval):
2071         (Bindings::JSObject::getMember):
2072         (Bindings::JSObject::setMember):
2073         (Bindings::JSObject::removeMember):
2074         (Bindings::JSObject::getSlot):
2075         (Bindings::JSObject::setSlot):
2076         (Bindings::JSObject::convertJObjectToValue):
2077
2078 2003-12-15  Richard Williamson   <rjw@apple.com>
2079
2080         Fixed a couple of snafus and removed some logging.
2081
2082         Reviewed by Maciej.
2083
2084         * bindings/jni_jsobject.cpp:
2085         (Bindings::performJavaScriptAccess):
2086         (Bindings::completedJavaScriptAccess):
2087         (Bindings::dispatchToJavaScriptThread):
2088         Removed some annoying JS_LOG clutter.
2089
2090         (Bindings::RootObject::removeAllJavaReferencesForRoot):
2091         Fixed allocation of key buffer that was called after it was needed.
2092
2093         (Bindings::JSObject::invoke):
2094         (Bindings::JSObject::JSObject):
2095         (Bindings::JSObject::getMember):
2096         (Bindings::JSObject::getSlot):
2097         Added additional interpreter locks around getMember and getSlot. 
2098         These functions may cause allocation of JS impls.  
2099
2100 2003-12-15  Richard Williamson   <rjw@apple.com>
2101
2102         args weren't passed to 'call' invocation.  d'oh.
2103         lock interpreter when we create instances of JS impls.  
2104
2105         Reviewed by Maciej.
2106
2107         * bindings/jni_jsobject.cpp:
2108         (Bindings::JSObject::call):
2109         (Bindings::JSObject::eval):
2110         (Bindings::JSObject::getMember):
2111         (Bindings::JSObject::setMember):
2112         (Bindings::JSObject::getSlot):
2113         (Bindings::JSObject::convertValueToJObject):
2114         (Bindings::JSObject::convertJObjectToValue):
2115         (Bindings::JSObject::listFromJArray):
2116         * bindings/jni_jsobject.h:
2117
2118 2003-12-15  Richard Williamson   <rjw@apple.com>
2119
2120         Last piece of LiveConnect!  This checkin adds implementation
2121         of the Java to JavaScript object conversion functions.
2122
2123         Reviewed by John.
2124
2125         * bindings/jni/jni_instance.cpp:
2126         (JavaInstance::invokeMethod):
2127         * bindings/jni/jni_utility.cpp:
2128         * bindings/jni/jni_utility.h:
2129         * bindings/jni_jsobject.cpp:
2130         (Bindings::JSObject::invoke):
2131         (Bindings::JSObject::call):
2132         (Bindings::JSObject::eval):
2133         (Bindings::JSObject::getMember):
2134         (Bindings::JSObject::setMember):
2135         (Bindings::JSObject::getSlot):
2136         (Bindings::JSObject::setSlot):
2137         (Bindings::JSObject::createNative):
2138         (Bindings::JSObject::convertValueToJObject):
2139         (Bindings::JSObject::convertJObjectToValue):
2140         (Bindings::JSObject::listFromJArray):
2141         * bindings/jni_jsobject.h:
2142         (Bindings::):
2143         * bindings/runtime_method.cpp:
2144         (RuntimeMethodImp::get):
2145         (RuntimeMethodImp::codeType):
2146         (RuntimeMethodImp::execute):
2147
2148 2003-12-12  Richard Williamson   <rjw@apple.com>
2149
2150         Added implementation of stubs in JSObject.  All that
2151         remains is a couple of simple conversion functions stubs and
2152         we're done with LiveConnect.  Also, changed string passing to
2153         JS to use uchars instead of chars.  
2154
2155         Reviewed by Maciej.
2156
2157         * bindings/jni/jni_runtime.h:
2158         (Bindings::JavaString::JavaString):
2159         (Bindings::JavaString::_commonInit):
2160         (Bindings::JavaString::_commonCopy):
2161         (Bindings::JavaString::_commonDelete):
2162         (Bindings::JavaString::~JavaString):
2163         (Bindings::JavaString::operator=):
2164         (Bindings::JavaString::uchars):
2165         (Bindings::JavaString::length):
2166         (Bindings::JavaString::ustring):
2167         * bindings/jni/jni_utility.cpp:
2168         (getUCharactersFromJStringInEnv):
2169         (releaseUCharactersForJStringInEnv):
2170         (convertValueToJObject):
2171         (convertJObjectToValue):
2172         * bindings/jni/jni_utility.h:
2173         * bindings/jni_jsobject.cpp:
2174         (Bindings::JSObject::invoke):
2175         (Bindings::JSObject::call):
2176         (Bindings::JSObject::eval):
2177         (Bindings::JSObject::getMember):
2178         (Bindings::JSObject::setMember):
2179         (Bindings::JSObject::removeMember):
2180         (Bindings::JSObject::getSlot):
2181         (Bindings::JSObject::setSlot):
2182         * bindings/jni_jsobject.h:
2183
2184 2003-12-12  Richard Williamson   <rjw@apple.com>
2185
2186         Ensure that all calls from Java into JavaScript are
2187         performed on a designated thread (the main thread).
2188
2189         Reviewed by Ken.
2190
2191         * bindings/jni_jsobject.cpp:
2192         (isJavaScriptThread):
2193         (rootForImp):
2194         (Bindings::performJavaScriptAccess):
2195         (Bindings::completedJavaScriptAccess):
2196         (Bindings::initializeJavaScriptAccessLock):
2197         (Bindings::lockJavaScriptAccess):
2198         (Bindings::unlockJavaScriptAccess):
2199         (Bindings::dispatchToJavaScriptThread):
2200         (Bindings::RootObject::setFindRootObjectForNativeHandleFunction):
2201         (Bindings::RootObject::removeAllJavaReferencesForRoot):
2202         (Bindings::JSObject::invoke):
2203         (Bindings::JSObject::JSObject):
2204         (Bindings::JSObject::call):
2205         (Bindings::JSObject::eval):
2206         (Bindings::JSObject::getMember):
2207         (Bindings::JSObject::setMember):
2208         (Bindings::JSObject::removeMember):
2209         (Bindings::JSObject::getSlot):
2210         (Bindings::JSObject::setSlot):
2211         (Bindings::JSObject::toString):
2212         (Bindings::JSObject::finalize):
2213         (Bindings::JSObject::getWindow):
2214         * bindings/jni_jsobject.h:
2215         (Bindings::RootObject::~RootObject):
2216         (Bindings::RootObject::findRootObjectForNativeHandleFunction):
2217         (Bindings::RootObject::runLoop):
2218         (Bindings::RootObject::performJavaScriptSource):
2219         (Bindings::):
2220
2221 2003-12-11  Richard Williamson   <rjw@apple.com>
2222
2223         Added support for calling a JavaScript function from
2224         Java.  Right now this only works for void func(void)
2225         functions, but the conversion of args and return values
2226         will come shortly.
2227
2228         Cleaned up and verified reference counting scheme, and
2229         dereferencing of vended JavaScript objects when applet is
2230         destroyed (actually when part is destroyed).
2231         
2232         Removed link hack for testkjs now that the Java folks think
2233         they have a solution for the 1.4.2 JavaVM link problem.  Although
2234         Greg B. thinks his solution may cause problems for the 1.3.1
2235         version of the VM!?!
2236
2237         Reviewed by Ken.
2238
2239         * Makefile.am:
2240         * bindings/jni/jni_runtime.h:
2241         (Bindings::JavaString::JavaString):
2242         * bindings/jni/jni_utility.cpp:
2243         (convertValueToJValue):
2244         (convertValueToJObject):
2245         (listFromJArray):
2246         * bindings/jni/jni_utility.h:
2247         * bindings/jni_jsobject.cpp:
2248         (KJS_setFindRootObjectForNativeHandleFunction):
2249         (KJS_findRootObjectForNativeHandleFunction):
2250         (getReferencesByRootDictionary):
2251         (getReferencesDictionary):
2252         (findReferenceDictionary):
2253         (rootForImp):
2254         (addJavaReference):
2255         (removeJavaReference):
2256         * bindings/jni_jsobject.h:
2257         (Bindings::RootObject::RootObject):
2258         (Bindings::RootObject::~RootObject):
2259         (Bindings::RootObject::setRootObjectImp):
2260         (Bindings::RootObject::rootObjectImp):
2261         (Bindings::RootObject::setInterpreter):
2262         (Bindings::RootObject::interpreter):
2263
2264 === Safari-117 ===
2265
2266 2003-12-10  Darin Adler  <darin@apple.com>
2267
2268         Reviewed by Maciej.
2269
2270         - fixed regression in JavaScript tests reported by the KDE guys
2271         - fixed 3506345: REGRESSION (115-116): VIP: chordfind.com no longer displays chords
2272
2273         * kjs/ustring.h: Add tolerateEmptyString parameter to toDouble and toULong.
2274         * kjs/ustring.cpp:
2275         (KJS::UString::toDouble): Separate the "tolerant" parameter into two separate ones:
2276         tolerateTrailingJunk and tolerateEmptyString. Add new overloads; better for code size
2277         and binary compatibility than default parameter values.
2278         (KJS::UString::toULong): Pass tolerateEmptyString down to toDouble. Add new overload.
2279
2280         * kjs/string_object.cpp: (StringProtoFuncImp::call): Pass false for the new
2281         "tolerate empty string" parameter.
2282
2283 2003-12-10  Richard Williamson   <rjw@apple.com>
2284
2285         Added code to manage reference counting of JavaScript
2286         objects passed to Java.   Also added implementation of
2287         KJS_JSCreateNativeJSObject.  This is the function that
2288         provides the root object to Java (KJS::Window).
2289
2290         Reviewed by Hyatt.
2291
2292         * JavaScriptCore.pbproj/project.pbxproj:
2293         * bindings/jni_jsobject.cpp:
2294         (KJS_setFindObjectForNativeHandleFunction):
2295         (KJS_findObjectForNativeHandleFunction):
2296         (getReferencesByOwnerDictionary):
2297         (getReferencesDictionary):
2298         (findReferenceDictionary):
2299         (addJavaReference):
2300         (removeJavaReference):
2301         (removeAllJavaReferencesForOwner):
2302         * bindings/jni_jsobject.h:
2303
2304 2003-12-09  Richard Williamson   <rjw@apple.com>
2305
2306         LiveConnect stubs that correspond to the native methods
2307         on JSObject.  These will be called from the new Java plugin
2308         when an instance of JSObject is instantiated and messaged.
2309         When these are implemented the Java will be able to originate
2310         calls into JavaScript.
2311
2312         Also a temporary work-around added to Makefile.am to solve
2313         a link problem.  The 1.4.2 JavaVM accidentally links against
2314         libobjc.  This call a failure linking testkjs.  Mike Hay is
2315         working with someone to fix the problem (3505587).
2316
2317         Reviewed by Chris.
2318
2319         * JavaScriptCore.pbproj/project.pbxproj:
2320         * Makefile.am:
2321         * bindings/jni_jsobject.cpp: Added.
2322         (KJS_JSCreateNativeJSObject):
2323         (KJS_JSObject_JSFinalize):
2324         (KJS_JSObject_JSObjectCall):
2325         (KJS_JSObject_JSObjectEval):
2326         (KJS_JSObject_JSObjectGetMember):
2327         (KJS_JSObject_JSObjectSetMember):
2328         (KJS_JSObject_JSObjectRemoveMember):
2329         (KJS_JSObject_JSObjectGetSlot):
2330         (KJS_JSObject_JSObjectSetSlot):
2331         (KJS_JSObject_JSObjectToString):
2332         * bindings/jni_jsobject.h: Added.
2333
2334 2003-12-09  Maciej Stachowiak  <mjs@apple.com>
2335
2336         Reviewed by John.
2337
2338         <rdar://problem/3505183>: JavaScriptCore should assert that interpreter is locked in collector
2339
2340         * kjs/collector.cpp:
2341         (KJS::Collector::allocate): Assert that interpreter lock count is not 0.
2342         (KJS::Collector::collect): likewise
2343
2344 2003-12-08  Richard Williamson   <rjw@apple.com>
2345
2346         LiveConnect:  The last piece of the JavaScript side of the
2347         LiveConnect implementation.  This change adds support for
2348         setting/getting values from Java arrays in JavaScript.
2349
2350         Reviewed by John.
2351
2352         * bindings/jni/jni_instance.h:
2353         * bindings/jni/jni_runtime.cpp:
2354         (JavaField::JavaField):
2355         (convertJObjectToArray):
2356         (JavaArray::JavaArray):
2357         (JavaArray::~JavaArray):
2358         (JavaArray::setValueAt):
2359         (JavaArray::valueAt):
2360         (JavaArray::getLength):
2361         * bindings/jni/jni_runtime.h:
2362         (Bindings::JavaArray::operator=):
2363         (Bindings::JavaArray::javaArray):
2364         * bindings/jni/jni_utility.cpp:
2365         (JNITypeFromPrimitiveType):
2366         (convertValueToJValue):
2367         * bindings/jni/jni_utility.h:
2368         * bindings/runtime.h:
2369         * bindings/runtime_array.cpp:
2370         (RuntimeArrayImp::RuntimeArrayImp):
2371         (RuntimeArrayImp::~RuntimeArrayImp):
2372         (RuntimeArrayImp::get):
2373         (RuntimeArrayImp::put):
2374         (RuntimeArrayImp::hasProperty):
2375         * bindings/runtime_array.h:
2376         (KJS::RuntimeArrayImp::getLength):
2377         (KJS::RuntimeArrayImp::getConcreteArray):
2378         * bindings/runtime_object.cpp:
2379         (RuntimeObjectImp::get):
2380         (RuntimeObjectImp::canPut):
2381         (RuntimeObjectImp::hasProperty):
2382
2383 2003-12-05  Richard Williamson   <rjw@apple.com>
2384
2385         LiveConnect:  Part 1 of supporting JS bindings to
2386         native language arrays.
2387
2388         Reviewed by Chris.
2389
2390         * JavaScriptCore.pbproj/project.pbxproj:
2391         * bindings/jni/jni_runtime.cpp:
2392         (JavaField::JavaField):
2393         (convertJObjectToArray):
2394         (JavaField::valueFromInstance):
2395         (JavaField::setValueToInstance):
2396         * bindings/jni/jni_runtime.h:
2397         * bindings/runtime.cpp:
2398         (Instance::setValueOfField):
2399         * bindings/runtime.h:
2400         (Bindings::Array::~Array):
2401
2402 2003-12-04  Richard Williamson   <rjw@apple.com>
2403
2404         LiveConnect:  Moved defaultValue into concrete implementation because
2405         more intelligent conversion can be perform with knowledge
2406         of the class of the original instance.
2407
2408         Reviewed by Chris.
2409
2410         * bindings/jni/jni_class.cpp:
2411         (JavaClass::isNumberClass):
2412         (JavaClass::isBooleanClass):
2413         (JavaClass::isStringClass):
2414         * bindings/jni/jni_class.h:
2415         * bindings/jni/jni_instance.cpp:
2416         (JavaInstance::defaultValue):
2417         (JavaInstance::valueOf):
2418         * bindings/jni/jni_instance.h:
2419         (Bindings::JavaInstance::javaInstance):
2420         * bindings/runtime.h:
2421         * bindings/runtime_object.cpp:
2422         (RuntimeObjectImp::defaultValue):
2423
2424 2003-12-04  Richard Williamson   <rjw@apple.com>
2425
2426         LiveConnect:  Added support for setting the value of Java
2427         fields.
2428
2429         Reviewed by Chris.
2430
2431         * bindings/jni/jni_instance.cpp:
2432         (JavaInstance::invokeMethod):
2433         * bindings/jni/jni_runtime.cpp:
2434         (JavaParameter::JavaParameter):
2435         (JavaField::JavaField):
2436         (JavaField::valueFromInstance):
2437         (JavaField::setValueToInstance):
2438         (JavaMethod::JavaMethod):
2439         * bindings/jni/jni_runtime.h:
2440         (Bindings::JavaField::getJNIType):
2441         * bindings/jni/jni_utility.cpp:
2442         (JNITypeFromClassName):
2443         (convertValueToJValue):
2444         * bindings/jni/jni_utility.h:
2445         * bindings/runtime.cpp:
2446         (Instance::setValueOfField):
2447         * bindings/runtime.h:
2448         * bindings/runtime_object.cpp:
2449         (RuntimeObjectImp::get):
2450         (RuntimeObjectImp::put):
2451         (RuntimeObjectImp::defaultValue):
2452
2453 2003-12-04  Richard Williamson   <rjw@apple.com>
2454
2455         Added support for string conversions.
2456         Changed various JavaString member variables to be inline.
2457         Implemented defaultValue for context relevant type coercion.
2458
2459         Reviewed by Chris.
2460
2461         * bindings/jni/jni_class.cpp:
2462         (JavaClass::JavaClass):
2463         (JavaClass::setClassName):
2464         (JavaClass::classForInstance):
2465         * bindings/jni/jni_class.h:
2466         * bindings/jni/jni_instance.cpp:
2467         (JavaInstance::stringValue):
2468         (JavaInstance::numberValue):
2469         (JavaInstance::booleanValue):
2470         (JavaInstance::invokeMethod):
2471         * bindings/jni/jni_instance.h:
2472         * bindings/jni/jni_runtime.cpp:
2473         (JavaParameter::JavaParameter):
2474         (JavaField::JavaField):
2475         (JavaMethod::JavaMethod):
2476         (appendClassName):
2477         (JavaMethod::signature):
2478         * bindings/jni/jni_runtime.h:
2479         (Bindings::JavaString::JavaString):
2480         (Bindings::JavaString::~JavaString):
2481         (Bindings::JavaString::operator=):
2482         (Bindings::JavaString::characters):
2483         (Bindings::JavaParameter::JavaParameter):
2484         (Bindings::JavaParameter::~JavaParameter):
2485         (Bindings::JavaParameter::operator=):
2486         (Bindings::JavaParameter::type):
2487         (Bindings::JavaField::JavaField):
2488         (Bindings::JavaField::~JavaField):
2489         (Bindings::JavaField::operator=):
2490         (Bindings::JavaField::name):
2491         (Bindings::JavaField::type):
2492         (Bindings::JavaMethod::JavaMethod):
2493         (Bindings::JavaMethod::_commonDelete):
2494         (Bindings::JavaMethod::name):
2495         (Bindings::JavaMethod::returnType):
2496         * bindings/jni/jni_utility.cpp:
2497         (convertValueToJValue):
2498         * bindings/runtime.h:
2499         (Bindings::Instance::valueOf):
2500         * bindings/runtime_method.cpp:
2501         (RuntimeMethodImp::call):
2502         * bindings/runtime_object.cpp:
2503         (RuntimeObjectImp::RuntimeObjectImp):
2504         (RuntimeObjectImp::get):
2505         (RuntimeObjectImp::defaultValue):
2506         * bindings/runtime_object.h:
2507         (KJS::RuntimeObjectImp::classInfo):
2508
2509 === Safari-116 ===
2510
2511 2003-12-03  Richard Williamson   <rjw@apple.com>
2512
2513         LiveConnect:  Added support for parameter passing to Java and conversion
2514         of return values.
2515
2516         Reviewed by Chris.
2517
2518         * bindings/jni/jni_instance.cpp:
2519         (JavaInstance::invokeMethod):
2520         * bindings/jni/jni_instance.h:
2521         * bindings/jni/jni_runtime.cpp:
2522         (JavaParameter::JavaParameter):
2523         (JavaMethod::JavaMethod):
2524         (JavaMethod::signature):
2525         * bindings/jni/jni_runtime.h:
2526         (Bindings::JavaParameter::JavaParameter):
2527         (Bindings::JavaParameter::operator=):
2528         (Bindings::JavaParameter::getJNIType):
2529         * bindings/jni/jni_utility.cpp:
2530         (callJNIBooleanMethodA):
2531         (convertValueToJValue):
2532         * bindings/jni/jni_utility.h:
2533         * bindings/runtime.h:
2534         * bindings/runtime_method.cpp:
2535         (RuntimeMethodImp::call):
2536         * bindings/runtime_object.cpp:
2537         (RuntimeObjectImp::get):
2538
2539 2003-12-02  Richard Williamson   <rjw@apple.com>
2540
2541         Added support for calling simple methods in Java from JavaScript.
2542         (void return and no parameters).  Yay, LiveConnect lives.
2543
2544         Still need write argument and return value conversion code.
2545
2546         Reviewed by Chris.
2547
2548         * JavaScriptCore.pbproj/project.pbxproj:
2549         * bindings/jni/jni_instance.cpp:
2550         (JavaInstance::getClass):
2551         (JavaInstance::invokeMethod):
2552         * bindings/jni/jni_instance.h:
2553         * bindings/jni/jni_runtime.cpp:
2554         (JavaMethod::JavaMethod):
2555         (JavaMethod::signature):
2556         (JavaMethod::JNIReturnType):
2557         * bindings/jni/jni_runtime.h:
2558         (Bindings::JavaMethod::_commonDelete):
2559         (Bindings::JavaMethod::_commonCopy):
2560         (Bindings::JavaMethod::name):
2561         * bindings/jni/jni_utility.cpp:
2562         (signatureFromPrimitiveType):
2563         * bindings/jni/jni_utility.h:
2564         * bindings/runtime.h:
2565         * bindings/runtime_method.cpp: Added.
2566         (RuntimeMethodImp::RuntimeMethodImp):
2567         (RuntimeMethodImp::~RuntimeMethodImp):
2568         (RuntimeMethodImp::get):
2569         (RuntimeMethodImp::implementsCall):
2570         (RuntimeMethodImp::call):
2571         (RuntimeMethodImp::codeType):
2572         (RuntimeMethodImp::execute):
2573         * bindings/runtime_method.h: Added.
2574         * bindings/runtime_object.cpp:
2575         (RuntimeObjectImp::RuntimeObjectImp):
2576         (RuntimeObjectImp::get):
2577         * bindings/runtime_object.h:
2578         * kjs/function.cpp:
2579         (FunctionImp::FunctionImp):
2580         * kjs/interpreter.h:
2581
2582 2003-12-01  Darin Adler  <darin@apple.com>
2583
2584         Reviewed by Maciej.
2585
2586         - fixed 3493799: JavaScript string.replace expands $ if it's the last character in replacement string
2587
2588         * kjs/ustring.cpp: (KJS::UString::toDouble): Fix backwards handling of the "tolerant" boolean.
2589         This indirectly caused the string.replace bug.
2590
2591 2003-12-02  Maciej Stachowiak  <mjs@apple.com>
2592
2593         Merged patches from Harri Porten and David Faure to fix:
2594
2595         <rdar://problem/3497643>: reproducible crash printing self-referential array
2596         
2597         * kjs/array_object.cpp:
2598         (ArrayProtoFuncImp::call): Break out of the loop if an exception was thrown.
2599         * kjs/nodes.cpp:
2600         (FunctionCallNode::evaluate): Move function call depth check from here...
2601         * kjs/object.cpp:
2602         (KJS::Object::call): ...to here.
2603         * kjs/object.h: Un-inline Object::call now that it does more.
2604
2605 2003-12-01  Richard Williamson   <rjw@apple.com>
2606
2607         Fixed mistake in method signatures used to get boolean and integer fields.
2608
2609         Reviewed by Chris.
2610
2611         * bindings/jni/jni_runtime.cpp:
2612         (JavaField::valueFromInstance):
2613
2614 2003-12-01  Richard Williamson   <rjw@apple.com>
2615
2616 Fixed parameter passing to applet.  Child elements are NOT valid in setStyle().  So we now create the widget before needed with createWidgetIfNecessary.  This either happens when doing the first layout, or when JavaScript first references the applet element.
2617
2618 Fixed early delete of the the main applet instance.  When the JS collector cleaned up the last JS object referring to the applet instance we were deleting the java instance.  This caused the applet instance cached on the applet element to be invalid.  The applet instance is the only Java object not to be cleaned up by the JS collector.
2619
2620 Added support for getting at Java object fields.
2621
2622         Reviewed by Chris.
2623
2624         * JavaScriptCore.pbproj/project.pbxproj:
2625         * Makefile.am:
2626         * bindings/jni/jni_instance.cpp:
2627         (JObjectWrapper::JObjectWrapper):
2628         * bindings/jni/jni_instance.h:
2629         (Bindings::JObjectWrapper::~JObjectWrapper):
2630         * bindings/jni/jni_runtime.cpp:
2631         (JavaField::valueFromInstance):
2632         * bindings/runtime_object.cpp:
2633         (RuntimeObjectImp::~RuntimeObjectImp):
2634         (RuntimeObjectImp::RuntimeObjectImp):
2635         (RuntimeObjectImp::get):
2636         (RuntimeObjectImp::deleteProperty):
2637         * bindings/runtime_object.h:
2638
2639 === Safari-115 ===
2640
2641 2003-11-21  Maciej Stachowiak  <mjs@apple.com>
2642
2643         Patch from Harri Porten, reviewed by me.
2644
2645         - fixed 3491712 - String slice with negative arguments does not offset from end of string
2646         
2647         * kjs/string_object.cpp:
2648         (StringProtoFuncImp::call): Handle negative arguments as offsets from end by
2649         adding length and clamping to [0,length-1].
2650
2651 2003-11-21  Maciej Stachowiak  <mjs@apple.com>
2652
2653         Patch from Harri Porten, reviewed by me.
2654
2655         - fixed 3491709 - using Function.apply with a primitive type as the arg list causes crash
2656         
2657         * kjs/function_object.cpp:
2658         (FunctionProtoFuncImp::call): Nest parentheses properly.
2659
2660 2003-11-20  Richard Williamson   <rjw@apple.com>
2661
2662         More LiveConnect stuff.  Primitive Java fields are now
2663         accessible from JavaScript!  Yay!
2664
2665         Reviewed by Maciej.
2666
2667         * bindings/jni/jni_class.cpp:
2668         (JavaClass::methodNamed):
2669         (JavaClass::fieldNamed):
2670         * bindings/jni/jni_class.h:
2671         (Bindings::JavaClass::_commonDelete):
2672         * bindings/jni/jni_instance.cpp:
2673         (JavaInstance::JavaInstance):
2674         (JavaInstance::~JavaInstance):
2675         (JavaInstance::getClass):
2676         * bindings/jni/jni_instance.h:
2677         (Bindings::JavaInstance::javaInstance):
2678         * bindings/jni/jni_runtime.cpp:
2679         (JavaField::JavaField):
2680         (JavaField::valueFromInstance):
2681         * bindings/jni/jni_runtime.h:
2682         (Bindings::JavaField::JavaField):
2683         (Bindings::JavaField::~JavaField):
2684         (Bindings::JavaField::operator=):
2685         * bindings/jni/jni_utility.cpp:
2686         (callJNIMethod):
2687         (callJNIMethodA):
2688         (callJNIVoidMethod):
2689         (callJNIObjectMethod):
2690         (callJNIBooleanMethod):
2691         (callJNIByteMethod):
2692         (callJNICharMethod):
2693         (callJNIShortMethod):
2694         (callJNIIntMethod):
2695         (callJNILongMethod):
2696         (callJNIFloatMethod):
2697         (callJNIDoubleMethod):
2698         (callJNIVoidMethodA):
2699         (callJNIObjectMethodA):
2700         (callJNIByteMethodA):
2701         (callJNICharMethodA):
2702         (callJNIShortMethodA):
2703         (callJNIIntMethodA):
2704         (callJNILongMethodA):
2705         (callJNIFloatMethodA):
2706         (callJNIDoubleMethodA):
2707         (releaseCharactersForJStringInEnv):
2708         (primitiveTypeFromClassName):
2709         (getJNIField):
2710         * bindings/jni/jni_utility.h:
2711         * bindings/runtime.cpp:
2712         (Instance::createBindingForLanguageInstance):
2713         (Instance::getValueOfField):
2714         * bindings/runtime.h:
2715         * bindings/runtime_object.cpp:
2716         (RuntimeObjectImp::get):
2717
2718 2003-11-20  Richard Williamson   <rjw@apple.com>
2719
2720         More LiveConnect stuff.
2721
2722         Reviewed by Chris.
2723
2724         * bindings/jni/jni_class.cpp:
2725         (JavaClass::classForName):
2726         (JavaClass::classForInstance):
2727         * bindings/jni/jni_instance.cpp:
2728         (JavaInstance::getValueOfField):
2729         * bindings/jni/jni_instance.h:
2730         (Bindings::JObjectWrapper::JObjectWrapper):
2731         * bindings/jni/jni_runtime.h:
2732         (Bindings::JavaConstructor::~JavaConstructor):
2733         (Bindings::JavaConstructor::operator=):
2734         (Bindings::JavaMethod::JavaMethod):
2735         (Bindings::JavaMethod::_commonDelete):
2736         (Bindings::JavaMethod::signature):
2737         * bindings/jni/jni_utility.cpp:
2738         (getJNIEnv):
2739         (attachToJavaVM):
2740         * bindings/jni/jni_utility.h:
2741         * bindings/runtime.h:
2742         * bindings/runtime_object.cpp:
2743         (RuntimeObjectImp::~RuntimeObjectImp):
2744         (RuntimeObjectImp::get):
2745         * bindings/runtime_object.h:
2746
2747 2003-11-19  Richard Williamson   <rjw@apple.com>
2748
2749         More LiveConnect stuff.
2750
2751         Reviewed by Ken.
2752
2753         * JavaScriptCore.pbproj/project.pbxproj:
2754         * bindings/jni/jni_class.cpp: Added.
2755         (JavaClass::_commonInit):
2756         (JavaClass::JavaClass):
2757         (_createClassesByNameIfNecessary):
2758         (JavaClass::classForName):
2759         (JavaClass::classForInstance):
2760         (JavaClass::methodNamed):
2761         (JavaClass::fieldNamed):
2762         * bindings/jni/jni_class.h: Added.
2763         (Bindings::JavaClass::_commonDelete):
2764         (Bindings::JavaClass::~JavaClass):
2765         (Bindings::JavaClass::_commonCopy):
2766         (Bindings::JavaClass::JavaClass):
2767         (Bindings::JavaClass::operator=):
2768         (Bindings::JavaClass::name):
2769         (Bindings::JavaClass::constructorAt):
2770         (Bindings::JavaClass::numConstructors):
2771         * bindings/jni/jni_instance.cpp: Added.
2772         (JavaInstance::JavaInstance):
2773         (JavaInstance::~JavaInstance):
2774         * bindings/jni/jni_instance.h: Added.
2775         (Bindings::JObjectWrapper::JObjectWrapper):
2776         (Bindings::JObjectWrapper::~JObjectWrapper):
2777         (Bindings::JObjectWrapper::ref):
2778         (Bindings::JObjectWrapper::deref):
2779         (Bindings::JavaInstance::getClass):
2780         (Bindings::JavaInstance::operator=):
2781         * bindings/jni/jni_runtime.cpp:
2782         (JavaMethod::JavaMethod):
2783         * bindings/jni/jni_runtime.h:
2784         (Bindings::JavaString::JavaString):
2785         (Bindings::JavaString::~JavaString):
2786         (Bindings::JavaString::operator=):
2787         * bindings/jni/jni_utility.cpp:
2788         (getJavaVM):
2789         (getJNIEnv):
2790         (getCharactersFromJString):
2791         (releaseCharactersForJString):
2792         (getCharactersFromJStringInEnv):
2793         (releaseCharactersForJStringInEnv):
2794         * bindings/jni/jni_utility.h:
2795         * bindings/runtime.cpp:
2796         (Instance::createBindingForLanguageInstance):
2797         * bindings/runtime.h:
2798         (Bindings::Instance::):
2799
2800 2003-11-18  Richard Williamson   <rjw@apple.com>
2801
2802         More live connect stubs.  We're getting close.
2803
2804         Reviewed by Chris.
2805
2806         * JavaScriptCore.pbproj/project.pbxproj:
2807         * bindings/jni/jni_runtime.cpp:
2808         (JavaClass::JavaClass):
2809         (JavaInstance::JavaInstance):
2810         (JavaInstance::~JavaInstance):
2811         * bindings/jni/jni_runtime.h:
2812         (Bindings::JavaConstructor::value):
2813         (Bindings::JavaField::value):
2814         (Bindings::JavaMethod::value):
2815         (Bindings::JavaClass::_commonDelete):
2816         (Bindings::JavaClass::_commonCopy):
2817         (Bindings::JavaClass::methodNamed):
2818         (Bindings::JavaClass::fieldNamed):
2819         (Bindings::JavaInstance::getClass):
2820         * bindings/runtime.cpp: Added.
2821         * bindings/runtime.h:
2822         (Bindings::Instance::~Instance):
2823         * bindings/runtime_object.cpp: Added.
2824         (RuntimeObjectImp::classInfo):
2825         (RuntimeObjectImp::RuntimeObjectImp):
2826         (RuntimeObjectImp::get):
2827         (RuntimeObjectImp::put):
2828         (RuntimeObjectImp::canPut):
2829         (RuntimeObjectImp::hasProperty):
2830         (RuntimeObjectImp::deleteProperty):
2831         (RuntimeObjectImp::defaultValue):
2832         (RuntimeObjectImp::_initializeClassInfoFromInstance):
2833         * bindings/runtime_object.h: Added.
2834         (KJS::RuntimeObjectImp::setInternalInstance):
2835         (KJS::RuntimeObjectImp::getInternalInstance):
2836         * kjs/object.cpp:
2837         (KJS::ObjectImp::get):
2838         (KJS::ObjectImp::hasProperty):
2839         * kjs/value.h:
2840         (KJS::):
2841
2842 2003-11-17  Maciej Stachowiak  <mjs@apple.com>
2843
2844         Patch from Harri, reviewed by me.
2845
2846         - fixed 3487375 - backwards array slice causes infinite loop
2847         
2848         * kjs/array_object.cpp:
2849         (ArrayProtoFuncImp::call):
2850
2851 2003-11-17  Maciej Stachowiak  <mjs@apple.com>
2852
2853         Patch from Harri Porten reviewed by me.
2854
2855         - fixed 3487371 - operator precedence for bitwise or, xor and and is wrong
2856
2857         * kjs/grammar.y: Correct the precedence.
2858
2859 2003-11-16  Maciej Stachowiak  <mjs@apple.com>
2860
2861         Reviewed by John.
2862
2863         - fixed 3483829 - JavaScriptCore needs workaround to compile on Merlot
2864         
2865         * JavaScriptCore.pbproj/project.pbxproj: Add -Wno-long-double to
2866         warning flags.
2867
2868 === Safari-114 ===
2869
2870 2003-11-13  Richard Williamson   <rjw@apple.com>
2871
2872         Factored common code between copy constructor and assignment operator.
2873
2874         Reviewed by Chris.
2875
2876         * ChangeLog:
2877         * bindings/jni/jni_runtime.h:
2878         (Bindings::JavaConstructor::_commonCopy):
2879         (Bindings::JavaConstructor::JavaConstructor):
2880         (Bindings::JavaConstructor::operator=):
2881         (Bindings::JavaField::type):
2882         * bindings/runtime.h:
2883
2884 2003-11-13  Richard Williamson   <rjw@apple.com>
2885
2886         More LiveConnect stuff.  This checkin adds abstract classes to model
2887         language runtimes and a JNI based set of concrete implementations for
2888         Java.
2889
2890         Reviewed by Chris.
2891
2892         * JavaScriptCore.pbproj/project.pbxproj:
2893         * Makefile.am:
2894         * bindings/Makefile.am: Removed.
2895         * bindings/jni/Makefile.am: Removed.
2896         * bindings/jni/jni_runtime.cpp: Added.
2897         (JavaField::JavaField):
2898         (JavaConstructor::JavaConstructor):
2899         (JavaMethod::JavaMethod):
2900         (JavaClass::JavaClass):
2901         * bindings/jni/jni_runtime.h: Added.
2902         (Bindings::JavaString::JavaString):
2903         (Bindings::JavaString::~JavaString):
2904         (Bindings::JavaString::operator=):
2905         (Bindings::JavaString::characters):
2906         (Bindings::JavaParameter::JavaParameter):
2907         (Bindings::JavaParameter::~JavaParameter):
2908         (Bindings::JavaParameter::operator=):
2909         (Bindings::JavaParameter::type):
2910         (Bindings::JavaConstructor::JavaConstructor):
2911         (Bindings::JavaConstructor::~JavaConstructor):
2912         (Bindings::JavaConstructor::operator=):
2913         (Bindings::JavaConstructor::parameterAt):
2914         (Bindings::JavaConstructor::numParameters):
2915         (Bindings::JavaField::JavaField):
2916         (Bindings::JavaField::~JavaField):
2917         (Bindings::JavaField::operator=):
2918         (Bindings::JavaField::name):
2919         (Bindings::JavaField::type):
2920         (Bindings::JavaMethod::JavaMethod):
2921         (Bindings::JavaMethod::_commonDelete):
2922         (Bindings::JavaMethod::~JavaMethod):
2923         (Bindings::JavaMethod::_commonCopy):
2924         (Bindings::JavaMethod::operator=):
2925         (Bindings::JavaMethod::name):
2926         (Bindings::JavaMethod::returnType):
2927         (Bindings::JavaMethod::parameterAt):
2928         (Bindings::JavaMethod::numParameters):
2929         (Bindings::JavaClass::_commonDelete):
2930         (Bindings::JavaClass::~JavaClass):
2931         (Bindings::JavaClass::_commonCopy):
2932         (Bindings::JavaClass::JavaClass):
2933         (Bindings::JavaClass::operator=):
2934         (Bindings::JavaClass::name):
2935         (Bindings::JavaClass::methodAt):
2936         (Bindings::JavaClass::numMethods):
2937         (Bindings::JavaClass::constructorAt):
2938         (Bindings::JavaClass::numConstructors):
2939         (Bindings::JavaClass::fieldAt):
2940         (Bindings::JavaClass::numFields):
2941         * bindings/jni/jni_utility.cpp:
2942         (callJNIMethod):
2943         (callJNIMethodA):
2944         (callJNIObjectMethod):
2945         (callJNIByteMethod):
2946         (callJNICharMethod):
2947         (callJNIShortMethod):
2948         (callJNIIntMethod):
2949         (callJNILongMethod):
2950         (callJNIFloatMethod):
2951         (callJNIDoubleMethod):
2952         (callJNIVoidMethodA):
2953         (callJNIObjectMethodA):
2954         (callJNIByteMethodA):
2955         (callJNICharMethodA):
2956         (callJNIShortMethodA):
2957         (callJNIIntMethodA):
2958         (callJNILongMethodA):
2959         (callJNIFloatMethodA):
2960         (callJNIDoubleMethodA):
2961         (getCharactersFromJString):
2962         (releaseCharactersForJString):
2963         * bindings/jni/jni_utility.h:
2964         * bindings/objc/Makefile.am: Removed.
2965         * bindings/runtime.h: Added.
2966         (Bindings::Parameter::~Parameter):
2967         (Bindings::Constructor::~Constructor):
2968         (Bindings::Field::~Field):
2969         (Bindings::Method::~Method):
2970         (Bindings::Class::~Class):
2971
2972 2003-11-13  Maciej Stachowiak  <mjs@apple.com>
2973
2974         Reviewed by John.
2975
2976         - fixed 3472562 - Null or Undefined variables passed to IN operator cause javascript exceptions
2977         
2978         * kjs/nodes.cpp:
2979         (ForInNode::execute): If the in value is null or undefined, bail
2980         out early, since attempting to iterate its properties will throw
2981         an exception.
2982
2983 2003-11-12  Darin Adler  <darin@apple.com>
2984
2985         - fixed the build
2986
2987         * Makefile.am: Fix the build by removing the bindings directory from SUBDIRS.
2988         Later, we can either add this back and add the Makefile.am files to the top
2989         level configure.in or leave it out and remove the Makefile.am files.
2990
2991 2003-11-12  Richard Williamson   <rjw@apple.com>
2992
2993         Added utility functions for calling JNI methods.
2994
2995         Reviewed by Chris.
2996
2997         * JavaScriptCore.pbproj/project.pbxproj:
2998         * Makefile.am:
2999         * bindings/Makefile.am: Added.
3000         * bindings/jni/Makefile.am: Added.
3001         * bindings/jni/jni_utility.cpp: Added.
3002         (attachToJavaVM):
3003         (callJNIMethod):
3004         (callJNIVoidMethod):
3005         (callJNIObjectMethod):
3006         (callJNIByteMethod):
3007         (callJNICharMethod):
3008         (callJNIShortMethod):
3009         (callJNIIntMethod):
3010         (callJNILongMethod):
3011         (callJNIFloatMethod):
3012         (callJNIDoubleMethod):
3013         * bindings/jni/jni_utility.h: Added.
3014         * bindings/objc/Makefile.am: Added.
3015
3016 2003-11-08  Darin Adler  <darin@apple.com>
3017
3018         Reviewed by John.
3019
3020         - fixed 3477528 -- array.sort(function) fails if the function returns a non-zero value that rounds to zero
3021
3022         * kjs/array_object.cpp:
3023         (compareByStringForQSort): Added checks for undefined values to match what the specification calls for.
3024         (compareWithCompareFunctionForQSort): Added checks for undefined values as above, and also changed the
3025         code that looks at the compare function result to look at the number returned without rounding to an integer.
3026         (ArrayProtoFuncImp::call): Changed the code that looks at the compare function result to look at the number
3027         returned without rounding to an integer.
3028
3029 === Safari-113 ===
3030
3031 2003-11-03  Vicki Murley <vicki@apple.com>
3032
3033         Reviewed by kocienda.
3034
3035         - fixed <rdar://problem/3471096>: non-B&I builds should not use order files, because they cause false "regressions" in perf.
3036
3037         * JavaScriptCore.pbproj/project.pbxproj: added empty SECTORDER_FLAGS variables to the Development and Deployment build styles
3038
3039 2003-11-02  Darin Adler  <darin@apple.com>
3040
3041         Reviewed by Maciej.
3042
3043         - changed list manipulation to use Harri Porten's idea of a circular
3044           linked list that is built from head to tail rather than building the
3045           list backwards and reversing the list when done
3046
3047         * kjs/grammar.y: Handle CatchNode and FinallyNode in a type-safe way.
3048         Change many places that passed 0L to pass nothing at all, or to pass 0.
3049
3050         * kjs/nodes.h:
3051         (KJS::ElementNode::ElementNode): Build a circular list instead of a 0-terminated
3052         backwards list.
3053         (KJS::ArrayNode::ArrayNode): Break the circular list instead of reversing the list.
3054         (KJS::PropertyValueNode::PropertyValueNode): Moved before ObjectLiteralNode so the
3055         inline code in ObjectLiteralNode works. Build a circular list instead of a 0-terminated
3056         backwards list. Made the case for the first node separate so we don't need a nil check.
3057         (KJS::ObjectLiteralNode::ObjectLiteralNode): Break the circular list instead of
3058         reversing the list.
3059         (KJS::ArgumentListNode::ArgumentListNode): Build a circular list instead of a 0-terminated
3060         backwards list. Also, made the constructors inline (moved here from .cpp file).
3061         (KJS::ArgumentsNode::ArgumentsNode): Break the circular list instead of
3062         reversing the list.
3063         (KJS::NewExprNode::NewExprNode): Changed a 0L to 0.
3064         (KJS::StatListNode::StatListNode): Make this constructor no longer inline (moved into
3065         .cpp file). The one in the .cpp file builds a circular list instead of a 0-terminated
3066         backwards list.
3067         (KJS::VarDeclListNode::VarDeclListNode): Build a circular list instead of a 0-terminated
3068         backwards list.
3069         (KJS::VarStatementNode::VarStatementNode): Break the circular list instead of reversing
3070         the list.
3071         (KJS::BlockNode::BlockNode): Make this constructor no longer inline (moved into .cpp file).
3072         The one in the .cpp file breaks the list instead of reversing it.
3073         (KJS::ForNode::ForNode): Break the circular list instead of reversing the list.
3074         (KJS::CaseClauseNode::CaseClauseNode): Break the circular list instead of reversing the
3075         list.
3076         (KJS::ClauseListNode::ClauseListNode): Build a circular list instead of a 0-terminated
3077         backwards list.
3078         (KJS::CaseBlockNode::CaseBlockNode): Make this constructor no longer inline (moved into
3079         .cpp file). The one in the .cpp file breaks the list instead of reversing it.
3080         (KJS::TryNode::TryNode): Changed constructor to take typed parameters for the catch and
3081         finally nodes rather than just Node.
3082         (KJS::ParameterNode::ParameterNode): Build a circular list instead of a 0-terminated
3083         backwards list.
3084         (KJS::FuncDeclNode::FuncDeclNode): Break the circular list instead of reversing the
3085         list.
3086         (KJS::FuncExprNode::FuncExprNode): Break the circular list instead of reversing the
3087         list.
3088
3089         * kjs/nodes.cpp:
3090         (StatListNode::StatListNode): Moved this constructor here, no longer inline.
3091         Did the "break circular list" thing instead of the "reverse list" thing.
3092         Added setLoc calls to match KJS in the KDE tree; since we don't currently
3093         use the JavaScript debugging support, it's unclear whether there's any benefit, but
3094         later we might be using it and it's good to be as close as possible.
3095         (BlockNode::BlockNode): Moved this constructor here, no longer inline.
3096         Did the "break circular list" thing instead of the "reverse list" thing.
3097         Added setLoc calls.
3098         (CaseBlockNode::CaseBlockNode): Moved this constructor here, no longer inline.
3099         Did the "break circular list" thing instead of the "reverse list" thing.
3100         (SourceElementsNode::SourceElementsNode): Moved this constructor here, no longer inline.
3101         Did the "break circular list" thing instead of the "reverse list" thing.
3102         Added setLoc calls.
3103
3104         * kjs/grammar.cpp: Regenerated.
3105         * kjs/grammar.cpp.h: Regenerated.
3106         * kjs/grammar.h: Regenerated.
3107
3108 === Safari-112 ===
3109
3110 2003-10-30  Maciej Stachowiak  <mjs@apple.com>
3111
3112         Reviewed by Ken.
3113
3114         - fixed 3427069 - browsing mp3.com causes leaks (KJS)
3115         
3116         * kjs/string_object.cpp:
3117         (StringProtoFuncImp::call): Don't do an early return, since that
3118         could leak a temporary regexp.
3119
3120 2003-10-29  Maciej Stachowiak  <mjs@apple.com>
3121
3122         Reviewed by Darin.
3123
3124         - fixed 3426076 - Leak of JS lexer data visiting http://www.ebay.com
3125         
3126         * kjs/grammar.cpp:
3127         (yyerror): Updated the commented code.
3128         * kjs/grammar.y: Don't delete string and identifier tokens when done
3129         with them any more, they'll get cleaned up by the lexer now.
3130         * kjs/internal.cpp:
3131         (Parser::parse): Tell lexer when done parsing.
3132         * kjs/lexer.cpp:
3133         (Lexer::Lexer): Initialize new data members.
3134         (Lexer::lex): Use new methods to make strings and identifiers, and
3135         save them.
3136         (Lexer::makeIdentifier): Make a new Identifier and save it in an
3137         auto-growing array.
3138         (Lexer::makeUString): Likewise for UStrings.
3139         (Lexer::doneParsing): Clean up arrays of Ifentifiers and UStrings.
3140         * kjs/lexer.h:
3141
3142 2003-10-28  Maciej Stachowiak  <mjs@apple.com>
3143
3144         Reviewed by Ken.
3145
3146         - fixed 3413962 -  malicious web pages can kill all future JavaScript execution by breaking recursion limit check
3147         
3148         * kjs/nodes.cpp:
3149         (FunctionCallNode::evaluate): If we're going to return early due
3150         to breaking the recursion limit, make sure to lower it again, or
3151         it will creep up by one each time it's exceeded.
3152
3153 2003-10-26  Darin Adler  <darin@apple.com>
3154
3155         * JavaScriptCorePrefix.h: Added a C case to the NULL definition since we use C as well
3156         as C++ in this project.
3157
3158 2003-10-26  Darin Adler  <darin@apple.com>
3159
3160         - rolled in some CString changes Harri Porten did on the KDE side
3161
3162         * kjs/ustring.cpp:
3163         (KJS::CString::CString): Use memcpy instead of strcpy for speed. Fix an off by one error
3164         in the copy constructor.
3165         (KJS::CString::operator=): Use memcpy instead of strcpy for speed.
3166
3167         * JavaScriptCorePrefix.h: Add a definition of NULL here that takes advantage of the GNU
3168         __null feature even if the system C library doesn't.
3169
3170 == Rolled over to ChangeLog-2003-10-25 ==