~davidc3/+junk/js-scopes-misc

« back to all changes in this revision

Viewing changes to src/launcher/main.cc

  • Committer: Alexandre Abreu
  • Date: 2015-07-20 21:05:06 UTC
  • mfrom: (12.1.3 latest)
  • Revision ID: alexandre.abreu@canonical.com-20150720210506-sb68o2lasi8gqu12
Fix launcher scope_id; updated JS api; start porting to better v8cpp bindings; fix scope_id

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
17
 */
18
18
 
 
19
#include "config.h"
 
20
 
19
21
#include "node.h"
20
22
 
 
23
#include "../common/config.h"
 
24
 
21
25
#include <iostream>
 
26
#include <cstdlib>
22
27
#include <cstring>
23
28
 
24
29
#include <boost/filesystem.hpp>
25
30
 
26
31
namespace {
27
 
  const char kScopeInitPathArgumentHeader[] = "--scope=";
 
32
 
 
33
const char kScopeInitPathArgumentHeader[] = "--scope=";
 
34
 
28
35
}
29
36
 
30
37
void usage() {
31
 
  std::cout << "unity-js-scopes-launcher "
 
38
  std::cout << executable_name()
 
39
            << " "
32
40
            << kScopeInitPathArgumentHeader
33
41
            << "<path-to-ini-file>"
34
42
            << std::endl;
64
72
    return EXIT_FAILURE;
65
73
  }
66
74
 
 
75
  setenv(kJavascriptUnityScopeIdEnvVarName,
 
76
         p.string().c_str(),
 
77
         true);
 
78
 
67
79
  std::string base_name = p.filename().string();
68
80
 
69
81
  boost::filesystem::path script_path = p.parent_path();
75
87
  }
76
88
 
77
89
  std::vector<std::string::value_type>
78
 
    new_args_content(script_path.string().size() + 1);
 
90
    new_args_content(
 
91
      executable_name().size() + 1
 
92
      + script_path.string().size() + 1);
 
93
 
79
94
  memcpy(&new_args_content[0],
 
95
         executable_name().c_str(),
 
96
         executable_name().size()+1);
 
97
 
 
98
  memcpy(&new_args_content[0]
 
99
         + executable_name().size()
 
100
          + 1,
80
101
         script_path.string().c_str(),
81
 
         new_args_content.size());
 
102
         script_path.string().size()+1);
82
103
 
83
104
  std::vector<std::string::value_type*>
84
105
    new_args;
85
106
  new_args.push_back(&new_args_content[0]);
 
107
  new_args.push_back(&new_args_content[0] + executable_name().size() + 1);
86
108
 
87
109
  return node::Start(
88
110
      new_args.size(),