Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 8352014: Minimal change to get win32 build working again. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 } 1385 }
1386 RETURN_FAILURE("Unable to find field in the class"); 1386 RETURN_FAILURE("Unable to find field in the class");
1387 } 1387 }
1388 1388
1389 1389
1390 DART_EXPORT Dart_Result Dart_GetStaticField(Dart_Handle cls, 1390 DART_EXPORT Dart_Result Dart_GetStaticField(Dart_Handle cls,
1391 Dart_Handle name) { 1391 Dart_Handle name) {
1392 Zone zone; // Setup a VM zone as we are creating some handles. 1392 Zone zone; // Setup a VM zone as we are creating some handles.
1393 HandleScope scope; // Setup a VM handle scope. 1393 HandleScope scope; // Setup a VM handle scope.
1394 Dart_Result result = LookupStaticField(cls, name, kGetter); 1394 Dart_Result result = LookupStaticField(cls, name, kGetter);
1395 if (!Dart_IsValidResult(result)) { 1395 if (!::Dart_IsValidResult(result)) {
1396 RETURN_FAILURE(Dart_GetErrorCString(result)); 1396 return result;
1397 } 1397 }
1398 Object& retval = Object::Handle(); 1398 Object& retval = Object::Handle();
1399 const Object& obj = Object::Handle(Api::UnwrapHandle(Dart_GetResult(result))); 1399 const Object& obj = Object::Handle(Api::UnwrapHandle(Dart_GetResult(result)));
1400 if (obj.IsField()) { 1400 if (obj.IsField()) {
1401 Field& fld = Field::Handle(); 1401 Field& fld = Field::Handle();
1402 fld ^= obj.raw(); 1402 fld ^= obj.raw();
1403 retval = fld.value(); 1403 retval = fld.value();
1404 RETURN_OBJECT(retval); 1404 RETURN_OBJECT(retval);
1405 } else { 1405 } else {
1406 Function& func = Function::Handle(); 1406 Function& func = Function::Handle();
1407 func ^= obj.raw(); 1407 func ^= obj.raw();
1408 GrowableArray<const Object*> args; 1408 GrowableArray<const Object*> args;
1409 InvokeStatic(func, args, &result); 1409 InvokeStatic(func, args, &result);
1410 if (Dart_IsValidResult(result)) { 1410 if (::Dart_IsValidResult(result)) {
1411 Dart_Handle result_obj = Dart_GetResult(result); 1411 Dart_Handle result_obj = Dart_GetResult(result);
1412 if (Dart_ExceptionOccurred(result_obj)) { 1412 if (Dart_ExceptionOccurred(result_obj)) {
1413 RETURN_FAILURE("An exception occurred when getting the static field"); 1413 RETURN_FAILURE("An exception occurred when getting the static field");
1414 } 1414 }
1415 } 1415 }
1416 return result; 1416 return result;
1417 } 1417 }
1418 } 1418 }
1419 1419
1420 1420
1421 // TODO(iposva): The value parameter should be documented as being an instance. 1421 // TODO(iposva): The value parameter should be documented as being an instance.
1422 DART_EXPORT Dart_Result Dart_SetStaticField(Dart_Handle cls, 1422 DART_EXPORT Dart_Result Dart_SetStaticField(Dart_Handle cls,
1423 Dart_Handle name, 1423 Dart_Handle name,
1424 Dart_Handle value) { 1424 Dart_Handle value) {
1425 Zone zone; // Setup a VM zone as we are creating some handles. 1425 Zone zone; // Setup a VM zone as we are creating some handles.
1426 HandleScope scope; // Setup a VM handle scope. 1426 HandleScope scope; // Setup a VM handle scope.
1427 Dart_Result result = LookupStaticField(cls, name, kSetter); 1427 Dart_Result result = LookupStaticField(cls, name, kSetter);
1428 if (!Dart_IsValidResult(result)) { 1428 if (!::Dart_IsValidResult(result)) {
1429 RETURN_FAILURE(Dart_GetErrorCString(result)); 1429 return result;
1430 } 1430 }
1431 Field& fld = Field::Handle(); 1431 Field& fld = Field::Handle();
1432 fld ^= Api::UnwrapHandle(Dart_GetResult(result)); 1432 fld ^= Api::UnwrapHandle(Dart_GetResult(result));
1433 if (fld.is_final()) { 1433 if (fld.is_final()) {
1434 RETURN_FAILURE("Specified field is a static final field in the class"); 1434 RETURN_FAILURE("Specified field is a static final field in the class");
1435 } 1435 }
1436 const Object& val = Object::Handle(Api::UnwrapHandle(value)); 1436 const Object& val = Object::Handle(Api::UnwrapHandle(value));
1437 Instance& instance = Instance::Handle(); 1437 Instance& instance = Instance::Handle();
1438 instance ^= val.raw(); 1438 instance ^= val.raw();
1439 fld.set_value(instance); 1439 fld.set_value(instance);
1440 RETURN_OBJECT(val); 1440 RETURN_OBJECT(val);
1441 } 1441 }
1442 1442
1443 1443
1444 DART_EXPORT Dart_Result Dart_GetInstanceField(Dart_Handle obj, 1444 DART_EXPORT Dart_Result Dart_GetInstanceField(Dart_Handle obj,
1445 Dart_Handle name) { 1445 Dart_Handle name) {
1446 Zone zone; // Setup a VM zone as we are creating some handles. 1446 Zone zone; // Setup a VM zone as we are creating some handles.
1447 HandleScope scope; // Setup a VM handle scope. 1447 HandleScope scope; // Setup a VM handle scope.
1448 const Object& param = Object::Handle(Api::UnwrapHandle(obj)); 1448 const Object& param = Object::Handle(Api::UnwrapHandle(obj));
1449 if (param.IsNull() || !param.IsInstance()) { 1449 if (param.IsNull() || !param.IsInstance()) {
1450 RETURN_FAILURE("Invalid object passed in to access instance field"); 1450 RETURN_FAILURE("Invalid object passed in to access instance field");
1451 } 1451 }
1452 Instance& object = Instance::Handle(); 1452 Instance& object = Instance::Handle();
1453 object ^= param.raw(); 1453 object ^= param.raw();
1454 Dart_Result result = LookupInstanceField(object, name, kGetter); 1454 Dart_Result result = LookupInstanceField(object, name, kGetter);
1455 if (!Dart_IsValidResult(result)) { 1455 if (!::Dart_IsValidResult(result)) {
1456 RETURN_FAILURE(Dart_GetErrorCString(result)); 1456 return result;
1457 } 1457 }
1458 Function& func = Function::Handle(); 1458 Function& func = Function::Handle();
1459 func ^= Api::UnwrapHandle(Dart_GetResult(result)); 1459 func ^= Api::UnwrapHandle(Dart_GetResult(result));
1460 GrowableArray<const Object*> arguments; 1460 GrowableArray<const Object*> arguments;
1461 InvokeDynamic(object, func, arguments, &result); 1461 InvokeDynamic(object, func, arguments, &result);
1462 if (Dart_IsValidResult(result)) { 1462 if (::Dart_IsValidResult(result)) {
1463 Dart_Handle result_obj = Dart_GetResult(result); 1463 Dart_Handle result_obj = Dart_GetResult(result);
1464 if (Dart_ExceptionOccurred(result_obj)) { 1464 if (Dart_ExceptionOccurred(result_obj)) {
1465 RETURN_FAILURE("An exception occurred when accessing the instance field"); 1465 RETURN_FAILURE("An exception occurred when accessing the instance field");
1466 } 1466 }
1467 } 1467 }
1468 return result; 1468 return result;
1469 } 1469 }
1470 1470
1471 1471
1472 DART_EXPORT Dart_Result Dart_SetInstanceField(Dart_Handle obj, 1472 DART_EXPORT Dart_Result Dart_SetInstanceField(Dart_Handle obj,
1473 Dart_Handle name, 1473 Dart_Handle name,
1474 Dart_Handle value) { 1474 Dart_Handle value) {
1475 Zone zone; // Setup a VM zone as we are creating some handles. 1475 Zone zone; // Setup a VM zone as we are creating some handles.
1476 HandleScope scope; // Setup a VM handle scope. 1476 HandleScope scope; // Setup a VM handle scope.
1477 const Object& param = Object::Handle(Api::UnwrapHandle(obj)); 1477 const Object& param = Object::Handle(Api::UnwrapHandle(obj));
1478 if (param.IsNull() || !param.IsInstance()) { 1478 if (param.IsNull() || !param.IsInstance()) {
1479 RETURN_FAILURE("Invalid object passed in to access instance field"); 1479 RETURN_FAILURE("Invalid object passed in to access instance field");
1480 } 1480 }
1481 Instance& object = Instance::Handle(); 1481 Instance& object = Instance::Handle();
1482 object ^= param.raw(); 1482 object ^= param.raw();
1483 Dart_Result result = LookupInstanceField(object, name, kSetter); 1483 Dart_Result result = LookupInstanceField(object, name, kSetter);
1484 if (!Dart_IsValidResult(result)) { 1484 if (!::Dart_IsValidResult(result)) {
1485 RETURN_FAILURE(Dart_GetErrorCString(result)); 1485 return result;
1486 } 1486 }
1487 Function& func = Function::Handle(); 1487 Function& func = Function::Handle();
1488 func ^= Api::UnwrapHandle(Dart_GetResult(result)); 1488 func ^= Api::UnwrapHandle(Dart_GetResult(result));
1489 GrowableArray<const Object*> arguments(1); 1489 GrowableArray<const Object*> arguments(1);
1490 const Object& arg = Object::Handle(Api::UnwrapHandle(value)); 1490 const Object& arg = Object::Handle(Api::UnwrapHandle(value));
1491 arguments.Add(&arg); 1491 arguments.Add(&arg);
1492 InvokeDynamic(object, func, arguments, &result); 1492 InvokeDynamic(object, func, arguments, &result);
1493 if (Dart_IsValidResult(result)) { 1493 if (::Dart_IsValidResult(result)) {
1494 Dart_Handle result_obj = Dart_GetResult(result); 1494 Dart_Handle result_obj = Dart_GetResult(result);
1495 if (Dart_ExceptionOccurred(result_obj)) { 1495 if (Dart_ExceptionOccurred(result_obj)) {
1496 RETURN_FAILURE("An exception occurred when setting the instance field"); 1496 RETURN_FAILURE("An exception occurred when setting the instance field");
1497 } 1497 }
1498 } 1498 }
1499 return result; 1499 return result;
1500 } 1500 }
1501 1501
1502 1502
1503 DART_EXPORT Dart_Result Dart_CreateNativeWrapperClass(Dart_Handle library, 1503 DART_EXPORT Dart_Result Dart_CreateNativeWrapperClass(Dart_Handle library,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 ASSERT(isolate != NULL); 1720 ASSERT(isolate != NULL);
1721 ApiState* state = isolate->api_state(); 1721 ApiState* state = isolate->api_state();
1722 ASSERT(state != NULL); 1722 ASSERT(state != NULL);
1723 ApiLocalScope* scope = state->top_scope(); 1723 ApiLocalScope* scope = state->top_scope();
1724 ASSERT(scope != NULL); 1724 ASSERT(scope != NULL);
1725 return scope->zone().Reallocate(ptr, old_size, new_size); 1725 return scope->zone().Reallocate(ptr, old_size, new_size);
1726 } 1726 }
1727 1727
1728 1728
1729 } // namespace dart 1729 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698