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

Side by Side Diff: experimental/c_salt/integration_tests/method_tester.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Ginsu Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "c_salt/integration_tests/method_tester.h"
6
7 #include <cstdio>
8
9 #include "c_salt/scripting_bridge.h"
10
11 void MethodTester::InitializeMethods(c_salt::ScriptingBridge* bridge) {
12 bridge->AddMethodNamed("appendStrings",
13 this,
14 &MethodTester::AppendStrings);
15 bridge->AddMethodNamed("addDoubles",
16 this,
17 &MethodTester::AddDoubles);
18 bridge->AddMethodNamed("addInts",
19 this,
20 &MethodTester::AddInts);
21 bridge->AddMethodNamed("andBools",
22 this,
23 &MethodTester::AndBools);
24 bridge->AddMethodNamed("callMethodOnScriptObject",
25 this,
26 &MethodTester::CallMethodOnScriptObject);
27 bridge->AddMethodNamed("callAnonymousFunction",
28 this,
29 &MethodTester::CallAnonymousFunction);
30 }
31
32 void MethodTester::InitializeProperties(c_salt::ScriptingBridge* bridge) {
33 // No properties in this class.
34 }
35
36 std::string MethodTester::AppendStrings(const std::string& s1,
37 std::string s2) {
38 return s1 + s2;
39 }
40
41 double MethodTester::AddDoubles(const double& d1, double d2) {
42 return d1 + d2;
43 }
44
45 int32_t MethodTester::AddInts(const int32_t& i1, int32_t i2) {
46 return i1 + i2;
47 }
48
49 bool MethodTester::AndBools(const bool& b1, bool b2) {
50 return b1 && b2;
51 }
52
53 // TODO(dmichael): We could easily support returning boost::shared_ptr<Variant>
54 // too. For now, we just return by-value.
55 c_salt::Variant MethodTester::CallMethodOnScriptObject(
56 const std::string& method_name,
57 boost::shared_ptr<c_salt::ScriptingInterface> script_object,
58 const c_salt::SharedVariant& parameter) {
59 c_salt::SharedVariant return_value;
60 if (script_object->HasScriptMethod(method_name)) {
61 std::printf("Invoking method %s, param is %s\n",
62 method_name.c_str(),
63 c_salt::Variant(script_object).StringValue().c_str());
64 script_object->InvokeScriptMethod(method_name,
65 &parameter,
66 (&parameter) + 1u,
67 &return_value);
68 }
69 return *return_value;
70 }
71
72 c_salt::Variant MethodTester::CallAnonymousFunction(
73 boost::shared_ptr<c_salt::ScriptingInterface> script_object,
74 const c_salt::SharedVariant& parameter) {
75 c_salt::SharedVariant return_value;
76 script_object->InvokeScriptMethod("",
77 &parameter,
78 &parameter + 1u,
79 &return_value);
80 return *return_value;
81 }
OLDNEW
« no previous file with comments | « experimental/c_salt/integration_tests/method_tester.h ('k') | experimental/c_salt/integration_tests/property_tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698