OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Copy of the stub test from ppapi/examples/stub/stub.c | 5 // Copy of the stub test from ppapi/examples/stub/stub.c |
6 // This is the simplest possible C Pepper plugin that does nothing. If you're | 6 // This is the simplest possible C Pepper plugin that does nothing. If you're |
7 // using C++, you will want to look at stub.cc which uses the more convenient | 7 // using C++, you will want to look at stub.cc which uses the more convenient |
8 // C++ wrappers. | 8 // C++ wrappers. |
9 | 9 |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 PP_Var* exception) { | 376 PP_Var* exception) { |
377 if (argc != 1 || | 377 if (argc != 1 || |
378 argv[0].type != PP_VARTYPE_OBJECT) { | 378 argv[0].type != PP_VARTYPE_OBJECT) { |
379 *exception = kCallFailed; | 379 *exception = kCallFailed; |
380 return kCallFailed; | 380 return kCallFailed; |
381 } | 381 } |
382 // Get the location property from the passed in object. | 382 // Get the location property from the passed in object. |
383 const char kLocation[] = "location"; | 383 const char kLocation[] = "location"; |
384 const uint32_t kLocationLength = static_cast<uint32_t>(strlen(kLocation)); | 384 const uint32_t kLocationLength = static_cast<uint32_t>(strlen(kLocation)); |
385 PP_Var location_name = | 385 PP_Var location_name = |
386 g_var_interface->VarFromUtf8(kLocation, kLocationLength); | 386 g_var_interface->VarFromUtf8(g_module_id, kLocation, kLocationLength); |
387 PP_Var location = | 387 PP_Var location = |
388 g_var_interface->GetProperty(argv[0], location_name, exception); | 388 g_var_interface->GetProperty(argv[0], location_name, exception); |
389 if (location.type != PP_VARTYPE_OBJECT || | 389 if (location.type != PP_VARTYPE_OBJECT || |
390 exception->type != PP_VARTYPE_VOID) { | 390 exception->type != PP_VARTYPE_VOID) { |
391 *exception = kCallFailed; | 391 *exception = kCallFailed; |
392 return kCallFailed; | 392 return kCallFailed; |
393 } | 393 } |
394 // Get the href property on the returned object. | 394 // Get the href property on the returned object. |
395 const char kHref[] = "href"; | 395 const char kHref[] = "href"; |
396 const uint32_t kHrefLength = static_cast<uint32_t>(strlen(kHref)); | 396 const uint32_t kHrefLength = static_cast<uint32_t>(strlen(kHref)); |
397 PP_Var href_name = g_var_interface->VarFromUtf8(kHref, kHrefLength); | 397 PP_Var href_name = |
| 398 g_var_interface->VarFromUtf8(g_module_id, kHref, kHrefLength); |
398 PP_Var href = g_var_interface->GetProperty(location, href_name, exception); | 399 PP_Var href = g_var_interface->GetProperty(location, href_name, exception); |
399 printf("window.location.href = "); | 400 printf("window.location.href = "); |
400 PrintPpVar(href); | 401 PrintPpVar(href); |
401 printf("\n"); | 402 printf("\n"); |
402 if (href.type != PP_VARTYPE_STRING || exception->type != PP_VARTYPE_VOID) { | 403 if (href.type != PP_VARTYPE_STRING || exception->type != PP_VARTYPE_VOID) { |
403 *exception = kCallFailed; | 404 *exception = kCallFailed; |
404 return kCallFailed; | 405 return kCallFailed; |
405 } | 406 } |
406 return PP_MakeBool(true); | 407 return PP_MakeBool(true); |
407 } | 408 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 printf(" arg[%"NACL_PRIu32"]: '%s' = '%s'\n", i, argn[i], argv[i]); | 474 printf(" arg[%"NACL_PRIu32"]: '%s' = '%s'\n", i, argn[i], argv[i]); |
474 } | 475 } |
475 return true; | 476 return true; |
476 } | 477 } |
477 | 478 |
478 PP_Var GetInstanceObject(PP_Instance instance) { | 479 PP_Var GetInstanceObject(PP_Instance instance) { |
479 printf("basic_object: GetInstanceObject(%"NACL_PRIu64")\n", instance); | 480 printf("basic_object: GetInstanceObject(%"NACL_PRIu64")\n", instance); |
480 printf(" g_var_interface = %p\n", | 481 printf(" g_var_interface = %p\n", |
481 reinterpret_cast<const void*>(g_var_interface)); | 482 reinterpret_cast<const void*>(g_var_interface)); |
482 PP_Var retval = | 483 PP_Var retval = |
483 g_var_interface->CreateObject(&object_class, | 484 g_var_interface->CreateObject(g_module_id, |
| 485 &object_class, |
484 static_cast<void*>(new TestObject)); | 486 static_cast<void*>(new TestObject)); |
485 return retval; | 487 return retval; |
486 } | 488 } |
487 | 489 |
488 static const void* GetInstanceInterface() { | 490 static const void* GetInstanceInterface() { |
489 static const PPP_Instance instance_class = { | 491 static const PPP_Instance instance_class = { |
490 New, | 492 New, |
491 Delete, | 493 Delete, |
492 Initialize, | 494 Initialize, |
493 NULL, | 495 NULL, |
(...skipping 28 matching lines...) Expand all Loading... |
522 printf("basic_object: PPP_ShutdownModule()\n"); | 524 printf("basic_object: PPP_ShutdownModule()\n"); |
523 } | 525 } |
524 | 526 |
525 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { | 527 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { |
526 printf("basic_object: PPP_GetInterface('%s')\n", interface_name); | 528 printf("basic_object: PPP_GetInterface('%s')\n", interface_name); |
527 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) { | 529 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) { |
528 return GetInstanceInterface(); | 530 return GetInstanceInterface(); |
529 } | 531 } |
530 return NULL; | 532 return NULL; |
531 } | 533 } |
OLD | NEW |