| OLD | NEW |
| 1 | 1 |
| 2 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 3 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
| 4 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 4 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
| 5 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 5 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
| 6 # Copyright (C) 2006 Apple Computer, Inc. | 6 # Copyright (C) 2006 Apple Computer, Inc. |
| 7 # Copyright (C) 2007, 2008, 2009 Google Inc. | 7 # Copyright (C) 2007, 2008, 2009 Google Inc. |
| 8 # | 8 # |
| 9 # This file is part of the KDE project | 9 # This file is part of the KDE project |
| 10 # | 10 # |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional; | 308 push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional; |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 sub GenerateSetDOMException | 312 sub GenerateSetDOMException |
| 313 { | 313 { |
| 314 my $indent = shift; | 314 my $indent = shift; |
| 315 my $result = ""; | 315 my $result = ""; |
| 316 | 316 |
| 317 $result .= $indent . "if (ec) {\n"; | 317 $result .= $indent . "if (ec) {\n"; |
| 318 $result .= $indent . " V8Proxy::SetDOMException(ec);\n"; | 318 $result .= $indent . " V8Proxy::setDOMException(ec);\n"; |
| 319 $result .= $indent . " return v8::Handle<v8::Value>();\n"; | 319 $result .= $indent . " return v8::Handle<v8::Value>();\n"; |
| 320 $result .= $indent . "}\n"; | 320 $result .= $indent . "}\n"; |
| 321 | 321 |
| 322 return $result; | 322 return $result; |
| 323 } | 323 } |
| 324 | 324 |
| 325 sub IsNodeSubType | 325 sub IsNodeSubType |
| 326 { | 326 { |
| 327 my $dataNode = shift; | 327 my $dataNode = shift; |
| 328 return 1 if ($dataNode->name eq "Node"); | 328 return 1 if ($dataNode->name eq "Node"); |
| 329 foreach (@allParents) { | 329 foreach (@allParents) { |
| 330 my $parent = $codeGenerator->StripModule($_); | 330 my $parent = $codeGenerator->StripModule($_); |
| 331 return 1 if $parent eq "Node"; | 331 return 1 if $parent eq "Node"; |
| 332 } | 332 } |
| 333 return 0; | 333 return 0; |
| 334 } | 334 } |
| 335 | 335 |
| 336 sub HolderToNative | 336 sub HolderToNative |
| 337 { | 337 { |
| 338 my $dataNode = shift; | 338 my $dataNode = shift; |
| 339 my $implClassName = shift; | 339 my $implClassName = shift; |
| 340 my $classIndex = shift; | 340 my $classIndex = shift; |
| 341 | 341 |
| 342 if (IsNodeSubType($dataNode)) { | 342 if (IsNodeSubType($dataNode)) { |
| 343 push(@implContentDecls, <<END); | 343 push(@implContentDecls, <<END); |
| 344 $implClassName* imp = V8Proxy::DOMWrapperToNode<$implClassName>(holder); | 344 $implClassName* imp = V8Proxy::convertDOMWrapperToNode<$implClassName>(holde
r); |
| 345 END | 345 END |
| 346 | 346 |
| 347 } else { | 347 } else { |
| 348 push(@implContentDecls, <<END); | 348 push(@implContentDecls, <<END); |
| 349 $implClassName* imp = V8Proxy::ToNativeObject<$implClassName>(V8ClassIndex::
$classIndex, holder); | 349 $implClassName* imp = V8Proxy::convertToNativeObject<$implClassName>(V8Class
Index::$classIndex, holder); |
| 350 END | 350 END |
| 351 | 351 |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 sub GenerateDomainSafeFunctionGetter | 355 sub GenerateDomainSafeFunctionGetter |
| 356 { | 356 { |
| 357 my $function = shift; | 357 my $function = shift; |
| 358 my $dataNode = shift; | 358 my $dataNode = shift; |
| 359 my $classIndex = shift; | 359 my $classIndex = shift; |
| 360 my $implClassName = shift; | 360 my $implClassName = shift; |
| 361 | 361 |
| 362 my $className = "V8" . $dataNode->name; | 362 my $className = "V8" . $dataNode->name; |
| 363 my $funcName = $function->signature->name; | 363 my $funcName = $function->signature->name; |
| 364 | 364 |
| 365 my $signature = "v8::Signature::New(" . $className . "::GetRawTemplate())"; | 365 my $signature = "v8::Signature::New(" . $className . "::GetRawTemplate())"; |
| 366 if ($function->signature->extendedAttributes->{"V8DoNotCheckSignature"}) { | 366 if ($function->signature->extendedAttributes->{"V8DoNotCheckSignature"}) { |
| 367 $signature = "v8::Local<v8::Signature>()"; | 367 $signature = "v8::Local<v8::Signature>()"; |
| 368 } | 368 } |
| 369 | 369 |
| 370 my $newTemplateString = GenerateNewFunctionTemplate($function, $dataNode, $sig
nature); | 370 my $newTemplateString = GenerateNewFunctionTemplate($function, $dataNode, $sig
nature); |
| 371 | 371 |
| 372 $implIncludes{"v8_proxy.h"} = 1; | 372 $implIncludes{"V8Proxy.h"} = 1; |
| 373 | 373 |
| 374 push(@implContentDecls, <<END); | 374 push(@implContentDecls, <<END); |
| 375 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name,
const v8::AccessorInfo& info) { | 375 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name,
const v8::AccessorInfo& info) { |
| 376 INC_STATS(\"DOM.$implClassName.$funcName._get\"); | 376 INC_STATS(\"DOM.$implClassName.$funcName._get\"); |
| 377 static v8::Persistent<v8::FunctionTemplate> private_template = | 377 static v8::Persistent<v8::FunctionTemplate> private_template = |
| 378 v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); | 378 v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); |
| 379 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::$cla
ssIndex, info.This()); | 379 v8::Handle<v8::Object> holder = V8Proxy::lookupDOMWrapper(V8ClassIndex::$cla
ssIndex, info.This()); |
| 380 if (holder.IsEmpty()) { | 380 if (holder.IsEmpty()) { |
| 381 // can only reach here by 'object.__proto__.func', and it should passed | 381 // can only reach here by 'object.__proto__.func', and it should passed |
| 382 // domain security check already | 382 // domain security check already |
| 383 | 383 |
| 384 return private_template->GetFunction(); | 384 return private_template->GetFunction(); |
| 385 } | 385 } |
| 386 END | 386 END |
| 387 | 387 |
| 388 HolderToNative($dataNode, $implClassName, $classIndex); | 388 HolderToNative($dataNode, $implClassName, $classIndex); |
| 389 | 389 |
| 390 push(@implContentDecls, <<END); | 390 push(@implContentDecls, <<END); |
| 391 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { | 391 if (!V8Proxy::canAccessFrame(imp->frame(), false)) { |
| 392 static v8::Persistent<v8::FunctionTemplate> shared_template = | 392 static v8::Persistent<v8::FunctionTemplate> shared_template = |
| 393 v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); | 393 v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); |
| 394 return shared_template->GetFunction(); | 394 return shared_template->GetFunction(); |
| 395 | 395 |
| 396 } else { | 396 } else { |
| 397 return private_template->GetFunction(); | 397 return private_template->GetFunction(); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 END | 401 END |
| 402 } | 402 } |
| 403 | 403 |
| 404 sub GenerateConstructorGetter | 404 sub GenerateConstructorGetter |
| 405 { | 405 { |
| 406 my $implClassName = shift; | 406 my $implClassName = shift; |
| 407 my $classIndex = shift; | 407 my $classIndex = shift; |
| 408 | 408 |
| 409 push(@implContentDecls, <<END); | 409 push(@implContentDecls, <<END); |
| 410 static v8::Handle<v8::Value> ${implClassName}ConstructorGetter(v8::Local<v8::S
tring> name, const v8::AccessorInfo& info) { | 410 static v8::Handle<v8::Value> ${implClassName}ConstructorGetter(v8::Local<v8::S
tring> name, const v8::AccessorInfo& info) { |
| 411 INC_STATS(\"DOM.$implClassName.constructors._get\"); | 411 INC_STATS(\"DOM.$implClassName.constructors._get\"); |
| 412 v8::Handle<v8::Value> data = info.Data(); | 412 v8::Handle<v8::Value> data = info.Data(); |
| 413 ASSERT(data->IsNumber()); | 413 ASSERT(data->IsNumber()); |
| 414 V8ClassIndex::V8WrapperType type = V8ClassIndex::FromInt(data->Int32Value())
; | 414 V8ClassIndex::V8WrapperType type = V8ClassIndex::FromInt(data->Int32Value())
; |
| 415 END | 415 END |
| 416 | 416 |
| 417 if ($classIndex eq "DOMWINDOW") { | 417 if ($classIndex eq "DOMWINDOW") { |
| 418 push(@implContentDecls, <<END); | 418 push(@implContentDecls, <<END); |
| 419 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWIND
OW, info.Holder()); | 419 DOMWindow* window = V8Proxy::convertToNativeObject<DOMWindow>(V8ClassIndex::
DOMWINDOW, info.Holder()); |
| 420 Frame* frame = window->frame(); | 420 Frame* frame = window->frame(); |
| 421 if (frame) { | 421 if (frame) { |
| 422 // Get the proxy corresponding to the DOMWindow if possible to | 422 // Get the proxy corresponding to the DOMWindow if possible to |
| 423 // make sure that the constructor function is constructed in the | 423 // make sure that the constructor function is constructed in the |
| 424 // context of the DOMWindow and not in the context of the caller. | 424 // context of the DOMWindow and not in the context of the caller. |
| 425 return V8Proxy::retrieve(frame)->GetConstructor(type); | 425 return V8Proxy::retrieve(frame)->getConstructor(type); |
| 426 } | 426 } |
| 427 END | 427 END |
| 428 } | 428 } |
| 429 | 429 |
| 430 if ($classIndex eq "WORKERCONTEXT") { | 430 if ($classIndex eq "WORKERCONTEXT") { |
| 431 $implIncludes{"WorkerContextExecutionProxy.h"} = 1; | 431 $implIncludes{"WorkerContextExecutionProxy.h"} = 1; |
| 432 push(@implContentDecls, <<END); | 432 push(@implContentDecls, <<END); |
| 433 return WorkerContextExecutionProxy::retrieve()->GetConstructor(type); | 433 return WorkerContextExecutionProxy::retrieve()->GetConstructor(type); |
| 434 END | 434 END |
| 435 } else { | 435 } else { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 446 sub GenerateNormalAttrGetter | 446 sub GenerateNormalAttrGetter |
| 447 { | 447 { |
| 448 my $attribute = shift; | 448 my $attribute = shift; |
| 449 my $dataNode = shift; | 449 my $dataNode = shift; |
| 450 my $classIndex = shift; | 450 my $classIndex = shift; |
| 451 my $implClassName = shift; | 451 my $implClassName = shift; |
| 452 | 452 |
| 453 my $attrExt = $attribute->signature->extendedAttributes; | 453 my $attrExt = $attribute->signature->extendedAttributes; |
| 454 | 454 |
| 455 my $attrName = $attribute->signature->name; | 455 my $attrName = $attribute->signature->name; |
| 456 $implIncludes{"v8_proxy.h"} = 1; | 456 $implIncludes{"V8Proxy.h"} = 1; |
| 457 | 457 |
| 458 my $attrType = $codeGenerator->StripModule($attribute->signature->type); | 458 my $attrType = $codeGenerator->StripModule($attribute->signature->type); |
| 459 my $attrIsPodType = $codeGenerator->IsPodType($attrType); | 459 my $attrIsPodType = $codeGenerator->IsPodType($attrType); |
| 460 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); | 460 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); |
| 461 my $isPodType = $codeGenerator->IsPodType($implClassName); | 461 my $isPodType = $codeGenerator->IsPodType($implClassName); |
| 462 my $skipContext = 0; | 462 my $skipContext = 0; |
| 463 | 463 |
| 464 | 464 |
| 465 if ($isPodType) { | 465 if ($isPodType) { |
| 466 $implClassName = GetNativeType($implClassName); | 466 $implClassName = GetNativeType($implClassName); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 487 my $getterStringUsesImp = $implClassName ne "double"; | 487 my $getterStringUsesImp = $implClassName ne "double"; |
| 488 | 488 |
| 489 # Getter | 489 # Getter |
| 490 push(@implContentDecls, <<END); | 490 push(@implContentDecls, <<END); |
| 491 static v8::Handle<v8::Value> ${attrName}AttrGetter(v8::Local<v8::String> name,
const v8::AccessorInfo& info) { | 491 static v8::Handle<v8::Value> ${attrName}AttrGetter(v8::Local<v8::String> name,
const v8::AccessorInfo& info) { |
| 492 INC_STATS(\"DOM.$implClassName.$attrName._get\"); | 492 INC_STATS(\"DOM.$implClassName.$attrName._get\"); |
| 493 END | 493 END |
| 494 | 494 |
| 495 if ($isPodType) { | 495 if ($isPodType) { |
| 496 push(@implContentDecls, <<END); | 496 push(@implContentDecls, <<END); |
| 497 V8SVGPODTypeWrapper<$implClassName>* imp_wrapper = V8Proxy::ToNativeObject<V
8SVGPODTypeWrapper<$implClassName> >(V8ClassIndex::$classIndex, info.Holder()); | 497 V8SVGPODTypeWrapper<$implClassName>* imp_wrapper = V8Proxy::convertToNativeO
bject<V8SVGPODTypeWrapper<$implClassName> >(V8ClassIndex::$classIndex, info.Hold
er()); |
| 498 $implClassName imp_instance = *imp_wrapper; | 498 $implClassName imp_instance = *imp_wrapper; |
| 499 END | 499 END |
| 500 if ($getterStringUsesImp) { | 500 if ($getterStringUsesImp) { |
| 501 push(@implContentDecls, <<END); | 501 push(@implContentDecls, <<END); |
| 502 $implClassName* imp = &imp_instance; | 502 $implClassName* imp = &imp_instance; |
| 503 END | 503 END |
| 504 } | 504 } |
| 505 | 505 |
| 506 } elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) { | 506 } elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) { |
| 507 # perform lookup first | 507 # perform lookup first |
| 508 push(@implContentDecls, <<END); | 508 push(@implContentDecls, <<END); |
| 509 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::$cla
ssIndex, info.This()); | 509 v8::Handle<v8::Object> holder = V8Proxy::lookupDOMWrapper(V8ClassIndex::$cla
ssIndex, info.This()); |
| 510 if (holder.IsEmpty()) return v8::Undefined(); | 510 if (holder.IsEmpty()) return v8::Undefined(); |
| 511 END | 511 END |
| 512 HolderToNative($dataNode, $implClassName, $classIndex); | 512 HolderToNative($dataNode, $implClassName, $classIndex); |
| 513 } else { | 513 } else { |
| 514 push(@implContentDecls, <<END); | 514 push(@implContentDecls, <<END); |
| 515 v8::Handle<v8::Object> holder = info.Holder(); | 515 v8::Handle<v8::Object> holder = info.Holder(); |
| 516 END | 516 END |
| 517 HolderToNative($dataNode, $implClassName, $classIndex); | 517 HolderToNative($dataNode, $implClassName, $classIndex); |
| 518 } | 518 } |
| 519 | 519 |
| 520 # Generate security checks if necessary | 520 # Generate security checks if necessary |
| 521 if ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { | 521 if ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { |
| 522 push(@implContentDecls, " if (!V8Proxy::CheckNodeSecurity(imp->$attrName(
))) return v8::Undefined();\n\n"); | 522 push(@implContentDecls, " if (!V8Proxy::checkNodeSecurity(imp->$attrName(
))) return v8::Undefined();\n\n"); |
| 523 } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { | 523 } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { |
| 524 push(@implContentDecls, " if (!V8Proxy::CheckNodeSecurity(imp->contentDoc
ument())) return v8::Undefined();\n\n"); | 524 push(@implContentDecls, " if (!V8Proxy::checkNodeSecurity(imp->contentDoc
ument())) return v8::Undefined();\n\n"); |
| 525 } | 525 } |
| 526 | 526 |
| 527 my $useExceptions = 1 if @{$attribute->getterExceptions} and !($isPodType); | 527 my $useExceptions = 1 if @{$attribute->getterExceptions} and !($isPodType); |
| 528 if ($useExceptions) { | 528 if ($useExceptions) { |
| 529 $implIncludes{"ExceptionCode.h"} = 1; | 529 $implIncludes{"ExceptionCode.h"} = 1; |
| 530 push(@implContentDecls, " ExceptionCode ec = 0;\n"); | 530 push(@implContentDecls, " ExceptionCode ec = 0;\n"); |
| 531 } | 531 } |
| 532 | 532 |
| 533 if ($attribute->signature->extendedAttributes->{"v8referenceattr"}) { | 533 if ($attribute->signature->extendedAttributes->{"v8referenceattr"}) { |
| 534 $attrName = $attribute->signature->extendedAttributes->{"v8referenceattr"}; | 534 $attrName = $attribute->signature->extendedAttributes->{"v8referenceattr"}; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 my $resultObject = $result; | 611 my $resultObject = $result; |
| 612 if ($attrIsPodType) { | 612 if ($attrIsPodType) { |
| 613 $resultObject = "wrapper"; | 613 $resultObject = "wrapper"; |
| 614 } | 614 } |
| 615 | 615 |
| 616 push(@implContentDecls, GenerateSVGContextAssignment($implClassName, $result
Object, " ")); | 616 push(@implContentDecls, GenerateSVGContextAssignment($implClassName, $result
Object, " ")); |
| 617 } | 617 } |
| 618 | 618 |
| 619 if ($attrIsPodType) { | 619 if ($attrIsPodType) { |
| 620 my $classIndex = uc($attrType); | 620 my $classIndex = uc($attrType); |
| 621 push(@implContentDecls, " return V8Proxy::ToV8Object(V8ClassIndex::$class
Index, wrapper);\n"); | 621 push(@implContentDecls, " return V8Proxy::convertToV8Object(V8ClassIndex:
:$classIndex, wrapper);\n"); |
| 622 } else { | 622 } else { |
| 623 push(@implContentDecls, " return " . NativeToJSValue($attribute->signatur
e, $result). ";\n"); | 623 push(@implContentDecls, " return " . NativeToJSValue($attribute->signatur
e, $result). ";\n"); |
| 624 } | 624 } |
| 625 | 625 |
| 626 push(@implContentDecls, " }\n\n"); # end of getter | 626 push(@implContentDecls, " }\n\n"); # end of getter |
| 627 } | 627 } |
| 628 | 628 |
| 629 | 629 |
| 630 sub GenerateReplaceableAttrSetter | 630 sub GenerateReplaceableAttrSetter |
| 631 { | 631 { |
| 632 my $implClassName = shift; | 632 my $implClassName = shift; |
| 633 | 633 |
| 634 $implIncludes{"v8_proxy.h"} = 1; | 634 $implIncludes{"V8Proxy.h"} = 1; |
| 635 | 635 |
| 636 push(@implContentDecls, | 636 push(@implContentDecls, |
| 637 " static void ${attrName}AttrSetter(v8::Local<v8::String> name," . | 637 " static void ${attrName}AttrSetter(v8::Local<v8::String> name," . |
| 638 " v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n"); | 638 " v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n"); |
| 639 | 639 |
| 640 push(@implContentDecls, " INC_STATS(\"DOM.$implClassName.$attrName._set\");
\n"); | 640 push(@implContentDecls, " INC_STATS(\"DOM.$implClassName.$attrName._set\");
\n"); |
| 641 | 641 |
| 642 push(@implContentDecls, " v8::Local<v8::String> ${attrName}_string = v8::St
ring::New(\"${attrName}\");\n"); | 642 push(@implContentDecls, " v8::Local<v8::String> ${attrName}_string = v8::St
ring::New(\"${attrName}\");\n"); |
| 643 push(@implContentDecls, " info.Holder()->Delete(${attrName}_string);\n"); | 643 push(@implContentDecls, " info.Holder()->Delete(${attrName}_string);\n"); |
| 644 push(@implContentDecls, " info.This()->Set(${attrName}_string, value);\n"); | 644 push(@implContentDecls, " info.This()->Set(${attrName}_string, value);\n"); |
| 645 push(@implContentDecls, " }\n\n"); | 645 push(@implContentDecls, " }\n\n"); |
| 646 } | 646 } |
| 647 | 647 |
| 648 | 648 |
| 649 sub GenerateNormalAttrSetter | 649 sub GenerateNormalAttrSetter |
| 650 { | 650 { |
| 651 my $attribute = shift; | 651 my $attribute = shift; |
| 652 my $dataNode = shift; | 652 my $dataNode = shift; |
| 653 my $classIndex = shift; | 653 my $classIndex = shift; |
| 654 my $implClassName = shift; | 654 my $implClassName = shift; |
| 655 | 655 |
| 656 my $attrExt = $attribute->signature->extendedAttributes; | 656 my $attrExt = $attribute->signature->extendedAttributes; |
| 657 | 657 |
| 658 $implIncludes{"v8_proxy.h"} = 1; | 658 $implIncludes{"V8Proxy.h"} = 1; |
| 659 | 659 |
| 660 push(@implContentDecls, | 660 push(@implContentDecls, |
| 661 " static void ${attrName}AttrSetter(v8::Local<v8::String> name," . | 661 " static void ${attrName}AttrSetter(v8::Local<v8::String> name," . |
| 662 " v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n"); | 662 " v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n"); |
| 663 | 663 |
| 664 push(@implContentDecls, " INC_STATS(\"DOM.$implClassName.$attrName._set\");
\n"); | 664 push(@implContentDecls, " INC_STATS(\"DOM.$implClassName.$attrName._set\");
\n"); |
| 665 | 665 |
| 666 my $isPodType = $codeGenerator->IsPodType($implClassName); | 666 my $isPodType = $codeGenerator->IsPodType($implClassName); |
| 667 | 667 |
| 668 if ($isPodType) { | 668 if ($isPodType) { |
| 669 $implClassName = GetNativeType($implClassName); | 669 $implClassName = GetNativeType($implClassName); |
| 670 $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; | 670 $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; |
| 671 push(@implContentDecls, " V8SVGPODTypeWrapper<$implClassName>* wrapper =
V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<$implClassName> >(V8ClassIndex::$cla
ssIndex, info.Holder());\n"); | 671 push(@implContentDecls, " V8SVGPODTypeWrapper<$implClassName>* wrapper =
V8Proxy::convertToNativeObject<V8SVGPODTypeWrapper<$implClassName> >(V8ClassInde
x::$classIndex, info.Holder());\n"); |
| 672 push(@implContentDecls, " $implClassName imp_instance = *wrapper;\n"); | 672 push(@implContentDecls, " $implClassName imp_instance = *wrapper;\n"); |
| 673 push(@implContentDecls, " $implClassName* imp = &imp_instance;\n"); | 673 push(@implContentDecls, " $implClassName* imp = &imp_instance;\n"); |
| 674 | 674 |
| 675 } elsif ($attrExt->{"v8OnProto"}) { | 675 } elsif ($attrExt->{"v8OnProto"}) { |
| 676 # perform lookup first | 676 # perform lookup first |
| 677 push(@implContentDecls, <<END); | 677 push(@implContentDecls, <<END); |
| 678 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::$cla
ssIndex, info.This()); | 678 v8::Handle<v8::Object> holder = V8Proxy::lookupDOMWrapper(V8ClassIndex::$cla
ssIndex, info.This()); |
| 679 if (holder.IsEmpty()) return v8::Undefined(); | 679 if (holder.IsEmpty()) return v8::Undefined(); |
| 680 END | 680 END |
| 681 HolderToNative($dataNode, $implClassName, $classIndex); | 681 HolderToNative($dataNode, $implClassName, $classIndex); |
| 682 } else { | 682 } else { |
| 683 push(@implContentDecls, <<END); | 683 push(@implContentDecls, <<END); |
| 684 v8::Handle<v8::Object> holder = info.Holder(); | 684 v8::Handle<v8::Object> holder = info.Holder(); |
| 685 END | 685 END |
| 686 HolderToNative($dataNode, $implClassName, $classIndex); | 686 HolderToNative($dataNode, $implClassName, $classIndex); |
| 687 } | 687 } |
| 688 | 688 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 711 | 711 |
| 712 if ($implClassName eq "double") { | 712 if ($implClassName eq "double") { |
| 713 push(@implContentDecls, " *imp = $result;\n"); | 713 push(@implContentDecls, " *imp = $result;\n"); |
| 714 } else { | 714 } else { |
| 715 push(@implContentDecls, " imp->set" . WK_ucfirst($attrName) . "(" . $resu
lt); | 715 push(@implContentDecls, " imp->set" . WK_ucfirst($attrName) . "(" . $resu
lt); |
| 716 push(@implContentDecls, ", ec") if $useExceptions; | 716 push(@implContentDecls, ", ec") if $useExceptions; |
| 717 push(@implContentDecls, ");\n"); | 717 push(@implContentDecls, ");\n"); |
| 718 } | 718 } |
| 719 | 719 |
| 720 if ($useExceptions) { | 720 if ($useExceptions) { |
| 721 push(@implContentDecls, " V8Proxy::SetDOMException(ec);\n"); | 721 push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); |
| 722 } | 722 } |
| 723 | 723 |
| 724 if ($isPodType) { | 724 if ($isPodType) { |
| 725 push(@implContentDecls, " wrapper->commitChange(*imp, V8Proxy::GetSVGCont
ext(wrapper));\n"); | 725 push(@implContentDecls, " wrapper->commitChange(*imp, V8Proxy::svgContext
(wrapper));\n"); |
| 726 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { | 726 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { |
| 727 $implIncludes{"SVGElement.h"} = 1; | 727 $implIncludes{"SVGElement.h"} = 1; |
| 728 | 728 |
| 729 my $currentObject = "imp"; | 729 my $currentObject = "imp"; |
| 730 if ($isPodType) { | 730 if ($isPodType) { |
| 731 $currentObject = "wrapper"; | 731 $currentObject = "wrapper"; |
| 732 } | 732 } |
| 733 | 733 |
| 734 push(@implContentDecls, " if (SVGElement* context = V8Proxy::GetSVGContex
t($currentObject)) {\n"); | 734 push(@implContentDecls, " if (SVGElement* context = V8Proxy::svgContext($
currentObject)) {\n"); |
| 735 push(@implContentDecls, " context->svgAttributeChanged(imp->associate
dAttributeName());\n"); | 735 push(@implContentDecls, " context->svgAttributeChanged(imp->associate
dAttributeName());\n"); |
| 736 push(@implContentDecls, " }\n"); | 736 push(@implContentDecls, " }\n"); |
| 737 } | 737 } |
| 738 | 738 |
| 739 push(@implContentDecls, " return;\n"); | 739 push(@implContentDecls, " return;\n"); |
| 740 push(@implContentDecls, " }\n\n"); # end of setter | 740 push(@implContentDecls, " }\n\n"); # end of setter |
| 741 } | 741 } |
| 742 | 742 |
| 743 | 743 |
| 744 sub GenerateNewFunctionTemplate | 744 sub GenerateNewFunctionTemplate |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 784 |
| 785 my $numParameters = @{$function->parameters}; | 785 my $numParameters = @{$function->parameters}; |
| 786 | 786 |
| 787 if ($function->signature->extendedAttributes->{"RequiresAllArguments"}) { | 787 if ($function->signature->extendedAttributes->{"RequiresAllArguments"}) { |
| 788 push(@implContentDecls, | 788 push(@implContentDecls, |
| 789 " if (args.Length() < $numParameters) return v8::Undefined();\n"); | 789 " if (args.Length() < $numParameters) return v8::Undefined();\n"); |
| 790 } | 790 } |
| 791 | 791 |
| 792 if ($codeGenerator->IsPodType($implClassName)) { | 792 if ($codeGenerator->IsPodType($implClassName)) { |
| 793 my $nativeClassName = GetNativeType($implClassName); | 793 my $nativeClassName = GetNativeType($implClassName); |
| 794 push(@implContentDecls, " V8SVGPODTypeWrapper<$nativeClassName>* imp_wrap
per = V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<$nativeClassName> >(V8ClassInd
ex::$classIndex, args.Holder());\n"); | 794 push(@implContentDecls, " V8SVGPODTypeWrapper<$nativeClassName>* imp_wrap
per = V8Proxy::convertToNativeObject<V8SVGPODTypeWrapper<$nativeClassName> >(V8C
lassIndex::$classIndex, args.Holder());\n"); |
| 795 push(@implContentDecls, " $nativeClassName imp_instance = *imp_wrapper;\n
"); | 795 push(@implContentDecls, " $nativeClassName imp_instance = *imp_wrapper;\n
"); |
| 796 push(@implContentDecls, " $nativeClassName* imp = &imp_instance;\n"); | 796 push(@implContentDecls, " $nativeClassName* imp = &imp_instance;\n"); |
| 797 } else { | 797 } else { |
| 798 push(@implContentDecls, <<END); | 798 push(@implContentDecls, <<END); |
| 799 v8::Handle<v8::Value> holder = args.Holder(); | 799 v8::Handle<v8::Value> holder = args.Holder(); |
| 800 END | 800 END |
| 801 HolderToNative($dataNode, $implClassName, $classIndex); | 801 HolderToNative($dataNode, $implClassName, $classIndex); |
| 802 } | 802 } |
| 803 | 803 |
| 804 # Check domain security if needed | 804 # Check domain security if needed |
| 805 if (($dataNode->extendedAttributes->{"CheckDomainSecurity"} | 805 if (($dataNode->extendedAttributes->{"CheckDomainSecurity"} |
| 806 || $interfaceName eq "DOMWindow") | 806 || $interfaceName eq "DOMWindow") |
| 807 && !$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"})
{ | 807 && !$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"})
{ |
| 808 # We have not find real use cases yet. | 808 # We have not find real use cases yet. |
| 809 push(@implContentDecls, | 809 push(@implContentDecls, |
| 810 " if (!V8Proxy::CanAccessFrame(imp->frame(), true)) {\n". | 810 " if (!V8Proxy::canAccessFrame(imp->frame(), true)) {\n". |
| 811 " return v8::Undefined();\n" . | 811 " return v8::Undefined();\n" . |
| 812 " }\n"); | 812 " }\n"); |
| 813 } | 813 } |
| 814 | 814 |
| 815 | 815 |
| 816 if (@{$function->raisesExceptions}) { | 816 if (@{$function->raisesExceptions}) { |
| 817 $implIncludes{"ExceptionCode.h"} = 1; | 817 $implIncludes{"ExceptionCode.h"} = 1; |
| 818 push(@implContentDecls, " ExceptionCode ec = 0;\n"); | 818 push(@implContentDecls, " ExceptionCode ec = 0;\n"); |
| 819 } | 819 } |
| 820 | 820 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 842 } | 842 } |
| 843 | 843 |
| 844 push(@implContentDecls, " " . GetNativeTypeFromSignature($parameter, 1) .
" $parameterName = "); | 844 push(@implContentDecls, " " . GetNativeTypeFromSignature($parameter, 1) .
" $parameterName = "); |
| 845 push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", | 845 push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", |
| 846 BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : unde
f) . ";\n"); | 846 BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : unde
f) . ";\n"); |
| 847 | 847 |
| 848 if (TypeCanFailConversion($parameter)) { | 848 if (TypeCanFailConversion($parameter)) { |
| 849 $implIncludes{"ExceptionCode.h"} = 1; | 849 $implIncludes{"ExceptionCode.h"} = 1; |
| 850 push(@implContentDecls, | 850 push(@implContentDecls, |
| 851 " if (!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "")
. ") {\n" . | 851 " if (!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "")
. ") {\n" . |
| 852 " V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);\n" . | 852 " V8Proxy::setDOMException(TYPE_MISMATCH_ERR);\n" . |
| 853 " return v8::Handle<v8::Value>();\n" . | 853 " return v8::Handle<v8::Value>();\n" . |
| 854 " }\n"); | 854 " }\n"); |
| 855 } | 855 } |
| 856 | 856 |
| 857 if ($parameter->extendedAttributes->{"IsIndex"}) { | 857 if ($parameter->extendedAttributes->{"IsIndex"}) { |
| 858 $implIncludes{"ExceptionCode.h"} = 1; | 858 $implIncludes{"ExceptionCode.h"} = 1; |
| 859 push(@implContentDecls, | 859 push(@implContentDecls, |
| 860 " if ($parameterName < 0) {\n" . | 860 " if ($parameterName < 0) {\n" . |
| 861 " V8Proxy::SetDOMException(INDEX_SIZE_ERR);\n" . | 861 " V8Proxy::setDOMException(INDEX_SIZE_ERR);\n" . |
| 862 " return v8::Handle<v8::Value>();\n" . | 862 " return v8::Handle<v8::Value>();\n" . |
| 863 " }\n"); | 863 " }\n"); |
| 864 } | 864 } |
| 865 | 865 |
| 866 $paramIndex++; | 866 $paramIndex++; |
| 867 } | 867 } |
| 868 | 868 |
| 869 # Build the function call string. | 869 # Build the function call string. |
| 870 my $callString = GenerateFunctionCallString($function, $paramIndex, " ", $i
mplClassName); | 870 my $callString = GenerateFunctionCallString($function, $paramIndex, " ", $i
mplClassName); |
| 871 push(@implContentDecls, "$callString"); | 871 push(@implContentDecls, "$callString"); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; | 1043 my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; |
| 1044 my $conditional = $dataNode->extendedAttributes->{"Conditional"}; | 1044 my $conditional = $dataNode->extendedAttributes->{"Conditional"}; |
| 1045 | 1045 |
| 1046 @allParents = $codeGenerator->FindParentsRecursively($dataNode); | 1046 @allParents = $codeGenerator->FindParentsRecursively($dataNode); |
| 1047 | 1047 |
| 1048 # - Add default header template | 1048 # - Add default header template |
| 1049 @implContentHeader = split("\r", $headerTemplate); | 1049 @implContentHeader = split("\r", $headerTemplate); |
| 1050 | 1050 |
| 1051 push(@implFixedHeader, | 1051 push(@implFixedHeader, |
| 1052 "#include \"config.h\"\n" . | 1052 "#include \"config.h\"\n" . |
| 1053 "#include \"v8_proxy.h\"\n" . | 1053 "#include \"V8Proxy.h\"\n" . |
| 1054 "#include \"v8_binding.h\"\n\n" . | 1054 "#include \"v8_binding.h\"\n\n" . |
| 1055 "#undef LOG\n\n"); | 1055 "#undef LOG\n\n"); |
| 1056 | 1056 |
| 1057 my $conditionalString; | 1057 my $conditionalString; |
| 1058 if ($conditional) { | 1058 if ($conditional) { |
| 1059 $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $condit
ional)) . ")"; | 1059 $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $condit
ional)) . ")"; |
| 1060 push(@implFixedHeader, "\n#if ${conditionalString}\n\n"); | 1060 push(@implFixedHeader, "\n#if ${conditionalString}\n\n"); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 if ($className =~ /^V8SVGAnimated/) { | 1063 if ($className =~ /^V8SVGAnimated/) { |
| 1064 AddIncludesForSVGAnimatedType($interfaceName); | 1064 AddIncludesForSVGAnimatedType($interfaceName); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 $implIncludes{"${className}.h"} = 1; | 1067 $implIncludes{"${className}.h"} = 1; |
| 1068 | 1068 |
| 1069 AddIncludesForType($interfaceName); | 1069 AddIncludesForType($interfaceName); |
| 1070 $implIncludes{"v8_proxy.h"} = 1; | 1070 $implIncludes{"V8Proxy.h"} = 1; |
| 1071 | 1071 |
| 1072 push(@implContentDecls, "namespace WebCore {\n"); | 1072 push(@implContentDecls, "namespace WebCore {\n"); |
| 1073 push(@implContentDecls, "namespace ${interfaceName}Internal {\n\n"); | 1073 push(@implContentDecls, "namespace ${interfaceName}Internal {\n\n"); |
| 1074 push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n"); | 1074 push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n"); |
| 1075 | 1075 |
| 1076 my $hasConstructors = 0; | 1076 my $hasConstructors = 0; |
| 1077 | 1077 |
| 1078 # Generate property accessors for attributes. | 1078 # Generate property accessors for attributes. |
| 1079 for ($index = 0; $index < @{$dataNode->attributes}; $index++) { | 1079 for ($index = 0; $index < @{$dataNode->attributes}; $index++) { |
| 1080 $attribute = @{$dataNode->attributes}[$index]; | 1080 $attribute = @{$dataNode->attributes}[$index]; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && | 1210 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && |
| 1211 !($interfaceName eq "DOMWindow")) { | 1211 !($interfaceName eq "DOMWindow")) { |
| 1212 $access_check = "instance->SetAccessCheckCallbacks(V8Custom::v8${interface
Name}NamedSecurityCheck, V8Custom::v8${interfaceName}IndexedSecurityCheck, v8::I
nteger::New(V8ClassIndex::ToInt(V8ClassIndex::${classIndex})));"; | 1212 $access_check = "instance->SetAccessCheckCallbacks(V8Custom::v8${interface
Name}NamedSecurityCheck, V8Custom::v8${interfaceName}IndexedSecurityCheck, v8::I
nteger::New(V8ClassIndex::ToInt(V8ClassIndex::${classIndex})));"; |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 # For the DOMWindow interface, generate the shadow object template | 1215 # For the DOMWindow interface, generate the shadow object template |
| 1216 # configuration method. | 1216 # configuration method. |
| 1217 if ($implClassName eq "DOMWindow") { | 1217 if ($implClassName eq "DOMWindow") { |
| 1218 push(@implContent, <<END); | 1218 push(@implContent, <<END); |
| 1219 static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers
istent<v8::ObjectTemplate> templ) { | 1219 static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers
istent<v8::ObjectTemplate> templ) { |
| 1220 BatchConfigureAttributes(templ, | 1220 batchConfigureAttributes(templ, |
| 1221 v8::Handle<v8::ObjectTemplate>(), | 1221 v8::Handle<v8::ObjectTemplate>(), |
| 1222 shadow_attrs, | 1222 shadow_attrs, |
| 1223 sizeof(shadow_attrs)/sizeof(*shadow_attrs)); | 1223 sizeof(shadow_attrs)/sizeof(*shadow_attrs)); |
| 1224 return templ; | 1224 return templ; |
| 1225 } | 1225 } |
| 1226 END | 1226 END |
| 1227 } | 1227 } |
| 1228 | 1228 |
| 1229 # Generate the template configuration method | 1229 # Generate the template configuration method |
| 1230 push(@implContent, <<END); | 1230 push(@implContent, <<END); |
| 1231 static v8::Persistent<v8::FunctionTemplate> Configure${className}Template(v8::Pe
rsistent<v8::FunctionTemplate> desc) { | 1231 static v8::Persistent<v8::FunctionTemplate> Configure${className}Template(v8::Pe
rsistent<v8::FunctionTemplate> desc) { |
| 1232 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 1232 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
| 1233 instance->SetInternalFieldCount(2); | 1233 instance->SetInternalFieldCount(2); |
| 1234 v8::Local<v8::Signature> default_signature = v8::Signature::New(desc); | 1234 v8::Local<v8::Signature> default_signature = v8::Signature::New(desc); |
| 1235 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 1235 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
| 1236 $access_check | 1236 $access_check |
| 1237 END | 1237 END |
| 1238 | 1238 |
| 1239 | 1239 |
| 1240 # Set up our attributes if we have them | 1240 # Set up our attributes if we have them |
| 1241 if ($has_attributes) { | 1241 if ($has_attributes) { |
| 1242 push(@implContent, <<END); | 1242 push(@implContent, <<END); |
| 1243 BatchConfigureAttributes(instance, proto, attrs, sizeof(attrs)/sizeof(*attrs))
; | 1243 batchConfigureAttributes(instance, proto, attrs, sizeof(attrs)/sizeof(*attrs))
; |
| 1244 END | 1244 END |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 # Define our functions with Set() or SetAccessor() | 1247 # Define our functions with Set() or SetAccessor() |
| 1248 foreach my $function (@{$dataNode->functions}) { | 1248 foreach my $function (@{$dataNode->functions}) { |
| 1249 my $attrExt = $function->signature->extendedAttributes; | 1249 my $attrExt = $function->signature->extendedAttributes; |
| 1250 my $name = $function->signature->name; | 1250 my $name = $function->signature->name; |
| 1251 | 1251 |
| 1252 my $property_attributes = "v8::DontDelete"; | 1252 my $property_attributes = "v8::DontDelete"; |
| 1253 if ($attrExt->{"DontEnum"}) { | 1253 if ($attrExt->{"DontEnum"}) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 static_cast<v8::PropertyAttribute>($property_attributes)); | 1318 static_cast<v8::PropertyAttribute>($property_attributes)); |
| 1319 END | 1319 END |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 # set the super descriptor | 1322 # set the super descriptor |
| 1323 foreach (@{$dataNode->parents}) { | 1323 foreach (@{$dataNode->parents}) { |
| 1324 my $parent = $codeGenerator->StripModule($_); | 1324 my $parent = $codeGenerator->StripModule($_); |
| 1325 if ($parent eq "EventTarget") { next; } | 1325 if ($parent eq "EventTarget") { next; } |
| 1326 $implIncludes{"V8${parent}.h"} = 1; | 1326 $implIncludes{"V8${parent}.h"} = 1; |
| 1327 my $parentClassIndex = uc($codeGenerator->StripModule($parent)); | 1327 my $parentClassIndex = uc($codeGenerator->StripModule($parent)); |
| 1328 push(@implContent, " desc->Inherit(V8Proxy::GetTemplate(V8ClassIndex::${p
arentClassIndex}));\n"); | 1328 push(@implContent, " desc->Inherit(V8Proxy::getTemplate(V8ClassIndex::${p
arentClassIndex}));\n"); |
| 1329 last; | 1329 last; |
| 1330 } | 1330 } |
| 1331 | 1331 |
| 1332 # Set the class name. This is used when printing objects. | 1332 # Set the class name. This is used when printing objects. |
| 1333 push(@implContent, " desc->SetClassName(v8::String::New(\"" . GetClassName(
${interfaceName}) . "\"));\n"); | 1333 push(@implContent, " desc->SetClassName(v8::String::New(\"" . GetClassName(
${interfaceName}) . "\"));\n"); |
| 1334 | 1334 |
| 1335 if ($has_constants) { | 1335 if ($has_constants) { |
| 1336 push(@implContent, <<END); | 1336 push(@implContent, <<END); |
| 1337 BatchConfigureConstants(desc, proto, consts, sizeof(consts)/sizeof(*consts)); | 1337 batchConfigureConstants(desc, proto, consts, sizeof(consts)/sizeof(*consts)); |
| 1338 END | 1338 END |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 push(@implContent, <<END); | 1341 push(@implContent, <<END); |
| 1342 return desc; | 1342 return desc; |
| 1343 } | 1343 } |
| 1344 | 1344 |
| 1345 v8::Persistent<v8::FunctionTemplate> ${className}::GetRawTemplate() { | 1345 v8::Persistent<v8::FunctionTemplate> ${className}::GetRawTemplate() { |
| 1346 static v8::Persistent<v8::FunctionTemplate> ${className}_raw_cache_; | 1346 static v8::Persistent<v8::FunctionTemplate> ${className}_raw_cache_; |
| 1347 if (${className}_raw_cache_.IsEmpty()) { | 1347 if (${className}_raw_cache_.IsEmpty()) { |
| 1348 v8::HandleScope scope; | 1348 v8::HandleScope scope; |
| 1349 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(V8Proxy::
CheckNewLegal); | 1349 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(V8Proxy::
checkNewLegal); |
| 1350 ${className}_raw_cache_ = v8::Persistent<v8::FunctionTemplate>::New(result); | 1350 ${className}_raw_cache_ = v8::Persistent<v8::FunctionTemplate>::New(result); |
| 1351 } | 1351 } |
| 1352 return ${className}_raw_cache_; | 1352 return ${className}_raw_cache_; |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() { | 1355 v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() { |
| 1356 static v8::Persistent<v8::FunctionTemplate> ${className}_cache_; | 1356 static v8::Persistent<v8::FunctionTemplate> ${className}_cache_; |
| 1357 if (${className}_cache_.IsEmpty()) | 1357 if (${className}_cache_.IsEmpty()) |
| 1358 ${className}_cache_ = Configure${className}Template(GetRawTemplate()); | 1358 ${className}_cache_ = Configure${className}Template(GetRawTemplate()); |
| 1359 return ${className}_cache_; | 1359 return ${className}_cache_; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 | 1482 |
| 1483 if ($nodeToReturn) { | 1483 if ($nodeToReturn) { |
| 1484 # Special case for insertBefore, replaceChild, removeChild and | 1484 # Special case for insertBefore, replaceChild, removeChild and |
| 1485 # appendChild functions from Node. | 1485 # appendChild functions from Node. |
| 1486 $result .= $indent . "bool success = $functionString;\n"; | 1486 $result .= $indent . "bool success = $functionString;\n"; |
| 1487 if (@{$function->raisesExceptions}) { | 1487 if (@{$function->raisesExceptions}) { |
| 1488 $result .= GenerateSetDOMException($indent); | 1488 $result .= GenerateSetDOMException($indent); |
| 1489 } | 1489 } |
| 1490 $result .= $indent . "if (success)\n"; | 1490 $result .= $indent . "if (success)\n"; |
| 1491 $result .= $indent . " " . | 1491 $result .= $indent . " " . |
| 1492 "return V8Proxy::NodeToV8Object($nodeToReturn);\n"; | 1492 "return V8Proxy::convertNodeToV8Object($nodeToReturn);\n"; |
| 1493 $result .= $indent . "return v8::Null();\n"; | 1493 $result .= $indent . "return v8::Null();\n"; |
| 1494 return $result; | 1494 return $result; |
| 1495 } elsif ($returnType eq "void") { | 1495 } elsif ($returnType eq "void") { |
| 1496 $result .= $indent . "$functionString;\n"; | 1496 $result .= $indent . "$functionString;\n"; |
| 1497 } elsif ($copyFirst) { | 1497 } elsif ($copyFirst) { |
| 1498 $result .= | 1498 $result .= |
| 1499 $indent . GetNativeType($returnType, 0) . " result = *imp;\n" . | 1499 $indent . GetNativeType($returnType, 0) . " result = *imp;\n" . |
| 1500 $indent . "$functionString;\n"; | 1500 $indent . "$functionString;\n"; |
| 1501 } elsif ($returnsListItemPodType) { | 1501 } elsif ($returnsListItemPodType) { |
| 1502 $result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $f
unctionString;\n"; | 1502 $result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $f
unctionString;\n"; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 if (!$generatedSVGContextRetrieval) { | 1547 if (!$generatedSVGContextRetrieval) { |
| 1548 $result .= GenerateSVGContextRetrieval($implClassName, $indent); | 1548 $result .= GenerateSVGContextRetrieval($implClassName, $indent); |
| 1549 $generatedSVGContextRetrieval = 1; | 1549 $generatedSVGContextRetrieval = 1; |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 $result .= $indent . "imp_wrapper->commitChange(imp_instance, context);\n"; | 1552 $result .= $indent . "imp_wrapper->commitChange(imp_instance, context);\n"; |
| 1553 } | 1553 } |
| 1554 | 1554 |
| 1555 if ($returnsPodType) { | 1555 if ($returnsPodType) { |
| 1556 my $classIndex = uc($returnType); | 1556 my $classIndex = uc($returnType); |
| 1557 $result .= $indent . "return V8Proxy::ToV8Object(V8ClassIndex::$classIndex,
wrapper);\n"; | 1557 $result .= $indent . "return V8Proxy::convertToV8Object(V8ClassIndex::$class
Index, wrapper);\n"; |
| 1558 } else { | 1558 } else { |
| 1559 $result .= $indent . "return " . NativeToJSValue($function->signature, $retu
rn) . ";\n"; | 1559 $result .= $indent . "return " . NativeToJSValue($function->signature, $retu
rn) . ";\n"; |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 return $result; | 1562 return $result; |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 | 1565 |
| 1566 # Get the class name used for printing javascript DOM-object wrappers. | 1566 # Get the class name used for printing javascript DOM-object wrappers. |
| 1567 sub GetClassName | 1567 sub GetClassName |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())
" if $type eq "SVGPaintType"; | 1811 return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())
" if $type eq "SVGPaintType"; |
| 1812 | 1812 |
| 1813 return "ToWebCoreString($value)" if $type eq "AtomicString" or $type eq "DOM
UserData"; | 1813 return "ToWebCoreString($value)" if $type eq "AtomicString" or $type eq "DOM
UserData"; |
| 1814 if ($type eq "DOMString") { | 1814 if ($type eq "DOMString") { |
| 1815 return "valueToStringWithNullCheck($value)" if $signature->extendedAttri
butes->{"ConvertNullToNullString"}; | 1815 return "valueToStringWithNullCheck($value)" if $signature->extendedAttri
butes->{"ConvertNullToNullString"}; |
| 1816 return "valueToStringWithNullOrUndefinedCheck($value)" if $signature->ex
tendedAttributes->{"ConvertUndefinedOrNullToNullString"}; | 1816 return "valueToStringWithNullOrUndefinedCheck($value)" if $signature->ex
tendedAttributes->{"ConvertUndefinedOrNullToNullString"}; |
| 1817 return "ToWebCoreString($value)"; | 1817 return "ToWebCoreString($value)"; |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 if ($type eq "NodeFilter") { | 1820 if ($type eq "NodeFilter") { |
| 1821 return "V8Proxy::ToNativeNodeFilter($value)"; | 1821 return "V8Proxy::wrapNativeNodeFilter($value)"; |
| 1822 } | 1822 } |
| 1823 | 1823 |
| 1824 if ($type eq "SVGRect") { | 1824 if ($type eq "SVGRect") { |
| 1825 $implIncludes{"FloatRect.h"} = 1; | 1825 $implIncludes{"FloatRect.h"} = 1; |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 1828 if ($type eq "SVGPoint") { | 1828 if ($type eq "SVGPoint") { |
| 1829 $implIncludes{"FloatPoint.h"} = 1; | 1829 $implIncludes{"FloatPoint.h"} = 1; |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 # Default, assume autogenerated type conversion routines | 1832 # Default, assume autogenerated type conversion routines |
| 1833 $implIncludes{"v8_proxy.h"} = 1; | 1833 $implIncludes{"V8Proxy.h"} = 1; |
| 1834 if ($type eq "EventTarget") { | 1834 if ($type eq "EventTarget") { |
| 1835 $implIncludes{"V8Node.h"} = 1; | 1835 $implIncludes{"V8Node.h"} = 1; |
| 1836 | 1836 |
| 1837 # EventTarget is not in DOM hierarchy, but all Nodes are EventTarget. | 1837 # EventTarget is not in DOM hierarchy, but all Nodes are EventTarget. |
| 1838 return "V8Node::HasInstance($value) ? V8Proxy::DOMWrapperToNode<Node>($val
ue) : 0"; | 1838 return "V8Node::HasInstance($value) ? V8Proxy::convertDOMWrapperToNode<Nod
e>($value) : 0"; |
| 1839 } | 1839 } |
| 1840 | 1840 |
| 1841 AddIncludesForType($type); | 1841 AddIncludesForType($type); |
| 1842 # $implIncludes{"$type.h"} = 1 unless AvoidInclusionOfType($type); | 1842 # $implIncludes{"$type.h"} = 1 unless AvoidInclusionOfType($type); |
| 1843 | 1843 |
| 1844 if (IsDOMNodeType($type)) { | 1844 if (IsDOMNodeType($type)) { |
| 1845 $implIncludes{"V8${type}.h"} = 1; | 1845 $implIncludes{"V8${type}.h"} = 1; |
| 1846 | 1846 |
| 1847 # Perform type checks on the parameter, if it is expected Node type, | 1847 # Perform type checks on the parameter, if it is expected Node type, |
| 1848 # return NULL. | 1848 # return NULL. |
| 1849 return "V8${type}::HasInstance($value) ? V8Proxy::DOMWrapperToNode<${type}
>($value) : 0"; | 1849 return "V8${type}::HasInstance($value) ? V8Proxy::convertDOMWrapperToNode<
${type}>($value) : 0"; |
| 1850 | 1850 |
| 1851 } else { | 1851 } else { |
| 1852 # TODO: Temporary to avoid Window name conflict. | 1852 # TODO: Temporary to avoid Window name conflict. |
| 1853 my $classIndex = uc($type); | 1853 my $classIndex = uc($type); |
| 1854 my $implClassName = ${type}; | 1854 my $implClassName = ${type}; |
| 1855 | 1855 |
| 1856 $implIncludes{"V8$type.h"} = 1; | 1856 $implIncludes{"V8$type.h"} = 1; |
| 1857 | 1857 |
| 1858 if ($codeGenerator->IsPodType($type)) { | 1858 if ($codeGenerator->IsPodType($type)) { |
| 1859 my $nativeType = GetNativeType($type); | 1859 my $nativeType = GetNativeType($type); |
| 1860 $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; | 1860 $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; |
| 1861 | 1861 |
| 1862 return "V8SVGPODTypeUtil::ToSVGPODType<${nativeType}>(V8ClassIndex::${cl
assIndex}, $value${maybeOkParam})" | 1862 return "V8SVGPODTypeUtil::ToSVGPODType<${nativeType}>(V8ClassIndex::${cl
assIndex}, $value${maybeOkParam})" |
| 1863 } | 1863 } |
| 1864 | 1864 |
| 1865 $implIncludes{"V8${type}.h"} = 1; | 1865 $implIncludes{"V8${type}.h"} = 1; |
| 1866 | 1866 |
| 1867 # Perform type checks on the parameter, if it is expected Node type, | 1867 # Perform type checks on the parameter, if it is expected Node type, |
| 1868 # return NULL. | 1868 # return NULL. |
| 1869 return "V8${type}::HasInstance($value) ? V8Proxy::ToNativeObject<${implCla
ssName}>(V8ClassIndex::${classIndex}, $value) : 0"; | 1869 return "V8${type}::HasInstance($value) ? V8Proxy::convertToNativeObject<${
implClassName}>(V8ClassIndex::${classIndex}, $value) : 0"; |
| 1870 } | 1870 } |
| 1871 } | 1871 } |
| 1872 | 1872 |
| 1873 | 1873 |
| 1874 sub GetV8HeaderName | 1874 sub GetV8HeaderName |
| 1875 { | 1875 { |
| 1876 my $type = shift; | 1876 my $type = shift; |
| 1877 return "V8" . GetImplementationFileName($type); | 1877 return "V8" . GetImplementationFileName($type); |
| 1878 } | 1878 } |
| 1879 | 1879 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 return "v8String($value)"; | 2013 return "v8String($value)"; |
| 2014 } | 2014 } |
| 2015 | 2015 |
| 2016 # V8 specific. | 2016 # V8 specific. |
| 2017 my $implClassName = $type; | 2017 my $implClassName = $type; |
| 2018 AddIncludesForType($type); | 2018 AddIncludesForType($type); |
| 2019 # $implIncludes{GetImplementationFileName($type)} = 1 unless AvoidInclusionO
fType($type); | 2019 # $implIncludes{GetImplementationFileName($type)} = 1 unless AvoidInclusionO
fType($type); |
| 2020 | 2020 |
| 2021 # special case for non-DOM node interfaces | 2021 # special case for non-DOM node interfaces |
| 2022 if (IsDOMNodeType($type)) { | 2022 if (IsDOMNodeType($type)) { |
| 2023 return "V8Proxy::NodeToV8Object($value)"; | 2023 return "V8Proxy::convertNodeToV8Object($value)"; |
| 2024 } | 2024 } |
| 2025 | 2025 |
| 2026 if ($type eq "EventTarget" or $type eq "SVGElementInstance") { | 2026 if ($type eq "EventTarget" or $type eq "SVGElementInstance") { |
| 2027 return "V8Proxy::EventTargetToV8Object($value)"; | 2027 return "V8Proxy::convertEventTargetToV8Object($value)"; |
| 2028 } | 2028 } |
| 2029 | 2029 |
| 2030 if ($type eq "Event") { | 2030 if ($type eq "Event") { |
| 2031 return "V8Proxy::EventToV8Object($value)"; | 2031 return "V8Proxy::convertEventToV8Object($value)"; |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 if ($type eq "EventListener") { | 2034 if ($type eq "EventListener") { |
| 2035 return "V8Proxy::EventListenerToV8Object($value)"; | 2035 return "V8Proxy::convertEventListenerToV8Object($value)"; |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 if ($type eq "RGBColor") { | 2038 if ($type eq "RGBColor") { |
| 2039 return "V8Proxy::ToV8Object(V8ClassIndex::RGBCOLOR, new RGBColor($value))"
; | 2039 return "V8Proxy::convertToV8Object(V8ClassIndex::RGBCOLOR, new RGBColor($v
alue))"; |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 if ($type eq "WorkerContext" or $type eq "WorkerLocation" or $type eq "Worke
rNavigator") { | 2042 if ($type eq "WorkerContext" or $type eq "WorkerLocation" or $type eq "Worke
rNavigator") { |
| 2043 $implIncludes{"WorkerContextExecutionProxy.h"} = 1; | 2043 $implIncludes{"WorkerContextExecutionProxy.h"} = 1; |
| 2044 my $classIndex = uc($type); | 2044 my $classIndex = uc($type); |
| 2045 | 2045 |
| 2046 return "WorkerContextExecutionProxy::ToV8Object(V8ClassIndex::$classIndex,
$value)"; | 2046 return "WorkerContextExecutionProxy::ToV8Object(V8ClassIndex::$classIndex,
$value)"; |
| 2047 } | 2047 } |
| 2048 | 2048 |
| 2049 else { | 2049 else { |
| 2050 $implIncludes{"wtf/RefCounted.h"} = 1; | 2050 $implIncludes{"wtf/RefCounted.h"} = 1; |
| 2051 $implIncludes{"wtf/RefPtr.h"} = 1; | 2051 $implIncludes{"wtf/RefPtr.h"} = 1; |
| 2052 my $classIndex = uc($type); | 2052 my $classIndex = uc($type); |
| 2053 | 2053 |
| 2054 if ($codeGenerator->IsPodType($type)) { | 2054 if ($codeGenerator->IsPodType($type)) { |
| 2055 $value = GenerateSVGStaticPodTypeWrapper($type, $value); | 2055 $value = GenerateSVGStaticPodTypeWrapper($type, $value); |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 return "V8Proxy::ToV8Object(V8ClassIndex::$classIndex, $value)"; | 2058 return "V8Proxy::convertToV8Object(V8ClassIndex::$classIndex, $value)"; |
| 2059 } | 2059 } |
| 2060 } | 2060 } |
| 2061 | 2061 |
| 2062 sub GenerateSVGStaticPodTypeWrapper { | 2062 sub GenerateSVGStaticPodTypeWrapper { |
| 2063 my $type = shift; | 2063 my $type = shift; |
| 2064 my $value = shift; | 2064 my $value = shift; |
| 2065 | 2065 |
| 2066 $implIncludes{"V8$type.h"}=1; | 2066 $implIncludes{"V8$type.h"}=1; |
| 2067 $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; | 2067 $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; |
| 2068 | 2068 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 return 0; | 2120 return 0; |
| 2121 } | 2121 } |
| 2122 | 2122 |
| 2123 sub GenerateSVGContextAssignment | 2123 sub GenerateSVGContextAssignment |
| 2124 { | 2124 { |
| 2125 my $srcType = shift; | 2125 my $srcType = shift; |
| 2126 my $value = shift; | 2126 my $value = shift; |
| 2127 my $indent = shift; | 2127 my $indent = shift; |
| 2128 | 2128 |
| 2129 $result = GenerateSVGContextRetrieval($srcType, $indent); | 2129 $result = GenerateSVGContextRetrieval($srcType, $indent); |
| 2130 $result .= $indent . "V8Proxy::SetSVGContext($value, context);\n"; | 2130 $result .= $indent . "V8Proxy::setSVGContext($value, context);\n"; |
| 2131 | 2131 |
| 2132 return $result; | 2132 return $result; |
| 2133 } | 2133 } |
| 2134 | 2134 |
| 2135 sub GenerateSVGContextRetrieval | 2135 sub GenerateSVGContextRetrieval |
| 2136 { | 2136 { |
| 2137 my $srcType = shift; | 2137 my $srcType = shift; |
| 2138 my $indent = shift; | 2138 my $indent = shift; |
| 2139 | 2139 |
| 2140 my $srcIsPodType = $codeGenerator->IsPodType($srcType); | 2140 my $srcIsPodType = $codeGenerator->IsPodType($srcType); |
| 2141 | 2141 |
| 2142 my $srcObject = "imp"; | 2142 my $srcObject = "imp"; |
| 2143 if ($srcIsPodType) { | 2143 if ($srcIsPodType) { |
| 2144 $srcObject = "imp_wrapper"; | 2144 $srcObject = "imp_wrapper"; |
| 2145 } | 2145 } |
| 2146 | 2146 |
| 2147 my $contextDecl; | 2147 my $contextDecl; |
| 2148 | 2148 |
| 2149 if (IsSVGTypeNeedingContextParameter($srcType)) { | 2149 if (IsSVGTypeNeedingContextParameter($srcType)) { |
| 2150 $contextDecl = "V8Proxy::GetSVGContext($srcObject)"; | 2150 $contextDecl = "V8Proxy::svgContext($srcObject)"; |
| 2151 } else { | 2151 } else { |
| 2152 $contextDecl = $srcObject; | 2152 $contextDecl = $srcObject; |
| 2153 } | 2153 } |
| 2154 | 2154 |
| 2155 return $indent . "SVGElement* context = $contextDecl;\n"; | 2155 return $indent . "SVGElement* context = $contextDecl;\n"; |
| 2156 } | 2156 } |
| 2157 | 2157 |
| 2158 sub IsSVGListMutator | 2158 sub IsSVGListMutator |
| 2159 { | 2159 { |
| 2160 my $functionName = shift; | 2160 my $functionName = shift; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2190 return 0; | 2190 return 0; |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 sub DebugPrint | 2193 sub DebugPrint |
| 2194 { | 2194 { |
| 2195 my $output = shift; | 2195 my $output = shift; |
| 2196 | 2196 |
| 2197 print $output; | 2197 print $output; |
| 2198 print "\n"; | 2198 print "\n"; |
| 2199 } | 2199 } |
| OLD | NEW |