コード例 #1
0
ファイル: repl.c プロジェクト: TravisBarryDick/julia
int main(int argc, char *argv[])
{
#else
int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
    int i;
    for (i=0; i<argc; i++) { // write the command line to UTF8
        wchar_t *warg = argv[i];
        size_t wlen = wcslen(warg)+1;
        size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, wlen, NULL, 0, NULL, NULL);
        if (!len) return 1;
        char *arg = (char*)alloca(len);
        if (!WideCharToMultiByte(CP_UTF8, 0, warg, wlen, arg, len, NULL, NULL)) return 1;
        argv[i] = (wchar_t*)arg;
    }
#endif
    libsupport_init();
    parse_opts(&argc, (char***)&argv);
    if (lisp_prompt) {
        jl_lisp_prompt();
        return 0;
    }
    julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME);
    int ret = true_main(argc, (char**)argv);
    jl_atexit_hook();
    julia_save();
    return ret;
}
コード例 #2
0
ファイル: repl.c プロジェクト: Blisse/julia
int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
    int i;
    lock_low32();
    for (i=0; i<argc; i++) { // write the command line to UTF8
        wchar_t *warg = argv[i];
        size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, -1, NULL, 0, NULL, NULL);
        if (!len) return 1;
        char *arg = (char*)alloca(len);
        if (!WideCharToMultiByte(CP_UTF8, 0, warg, -1, arg, len, NULL, NULL)) return 1;
        argv[i] = (wchar_t*)arg;
    }
#endif
#ifdef JULIA_ENABLE_THREADING
    // We need to make sure this function is called before any reference to
    // TLS variables. Since the compiler is free to move calls to
    // `jl_get_ptls_states()` around, we should avoid referencing TLS
    // variables in this function. (Mark `true_main` as noinline for this
    // reason).
    jl_set_ptls_states_getter(jl_get_ptls_states_static);
#endif
    libsupport_init();
    parse_opts(&argc, (char***)&argv);
    if (lisp_prompt) {
        jl_lisp_prompt();
        return 0;
    }
    julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME);
    int ret = true_main(argc, (char**)argv);
    jl_atexit_hook(ret);
    return ret;
}
コード例 #3
0
ファイル: repl.c プロジェクト: CBaader/julia
int main(int argc, char *argv[])
{
#else
int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
    int i;
    for (i=0; i<argc; i++) { // write the command line to UTF8
        wchar_t *warg = argv[i];
        size_t wlen = wcslen(warg)+1;
        size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, wlen, NULL, 0, NULL, NULL);
        if (!len) return 1;
        char *arg = (char*)alloca(len);
        if (!WideCharToMultiByte(CP_UTF8, 0, warg, wlen, arg, len, NULL, NULL)) return 1;
        argv[i] = (wchar_t*)arg;
    }
#endif
    libsupport_init();
    parse_opts(&argc, (char***)&argv);
    if (lisp_prompt) {
        jl_lisp_prompt();
        return 0;
    }
    julia_init(lisp_prompt ? NULL : image_file);
    return julia_trampoline(argc, (char**)argv, true_main);
}
コード例 #4
0
ファイル: repl.c プロジェクト: ChappedSky/julia
int main(int argc, char *argv[])
{
    libsupport_init();
    parse_opts(&argc, &argv);
    julia_init(lisp_prompt ? NULL : image_file);
    return julia_trampoline(argc, argv, true_main);
}
コード例 #5
0
ファイル: jlapi.c プロジェクト: agoddard/julia
// argument is the usr/lib directory where libjulia is, or NULL to guess.
// if that doesn't work, try the full path to the "lib" directory that
// contains lib/julia/sys.ji
DLLEXPORT void jl_init(char *julia_home_dir)
{
    libsupport_init();
    char *image_file = jl_locate_sysimg(julia_home_dir);
    julia_init(image_file);
    jl_set_const(jl_core_module, jl_symbol("JULIA_HOME"),
                 jl_cstr_to_string(julia_home));
    jl_module_export(jl_core_module, jl_symbol("JULIA_HOME"));
}
コード例 #6
0
ファイル: jlapi.c プロジェクト: JosefMontag/julia
// First argument is the usr/lib directory where libjulia is, or NULL to guess.
// if that doesn't work, try the full path to the "lib" directory that
// contains lib/julia/sys.ji
// Second argument is the path of a system image file (*.ji) relative to the
// first argument path, or relative to the default julia home dir. The default
// is something like ../lib/julia/sys.ji
DLLEXPORT void jl_init_with_image(const char *julia_home_dir, const char *image_relative_path)
{
    if (jl_is_initialized()) return;
    libsupport_init();
    jl_options.julia_home = julia_home_dir;
    if (image_relative_path != NULL)
        jl_options.image_file = image_relative_path;
    julia_init(JL_IMAGE_JULIA_HOME);
    jl_exception_clear();
}
コード例 #7
0
ファイル: repl.c プロジェクト: TimmyLiu/julia
int main(int argc, char *argv[])
{
    libsupport_init();
    parse_opts(&argc, &argv);
    if (lisp_prompt) {
        jl_init_frontend();
        jl_lisp_prompt();
        return 0;
    }
    julia_init(lisp_prompt ? NULL : image_file, build_mode!=NULL);
    return julia_trampoline(argc, argv, true_main, build_mode);
}
コード例 #8
0
ファイル: jlapi.c プロジェクト: HarlanH/julia
// argument is the usr/lib directory where libjulia is, or NULL to guess.
// if that doesn't work, try the full path to the "lib" directory that
// contains lib/julia/sys.ji
DLLEXPORT void jl_init(char *julia_home_dir)
{
    libsupport_init();
    char *image_file = jl_locate_sysimg(julia_home_dir);
    julia_init(image_file);
    jl_set_const(jl_core_module, jl_symbol("JULIA_HOME"),
                 jl_cstr_to_string(julia_home));
    jl_module_export(jl_core_module, jl_symbol("JULIA_HOME"));
    jl_eval_string("Base.reinit_stdio()");
    jl_eval_string("Base.librandom_init()");
    jl_eval_string("Base.init_sched()");
    jl_eval_string("Base.init_head_sched()");
    jl_eval_string("Base.init_load_path()");
}
コード例 #9
0
ファイル: jlapi.c プロジェクト: dhiltonp/julia
// argument is the usr/lib directory where libjulia is, or NULL to guess.
// if that doesn't work, try the full path to the "lib" directory that
// contains lib/julia/sys.ji
DLLEXPORT void jl_init(char *julia_home_dir)
{
    if (jl_is_initialized()) return;
    libsupport_init();
    char *image_file = jl_locate_sysimg(julia_home_dir, JL_SYSTEM_IMAGE_PATH);
    julia_init(image_file);
    jl_set_const(jl_core_module, jl_symbol("JULIA_HOME"),
                 jl_cstr_to_string(julia_home));
    jl_module_export(jl_core_module, jl_symbol("JULIA_HOME"));
    jl_eval_string("Base.reinit_stdio()");
    jl_eval_string("Base.Random.librandom_init()");
    jl_eval_string("Base.init_sched()");
    jl_eval_string("Base.init_head_sched()");
    jl_eval_string("Base.init_load_path()");
}
コード例 #10
0
ファイル: jlapi.c プロジェクト: rened/julia
// First argument is the usr/lib directory where libjulia is, or NULL to guess.
// if that doesn't work, try the full path to the "lib" directory that
// contains lib/julia/sys.ji
// Second argument is the path of a system image file (*.ji) relative to the
// first argument path, or relative to the default julia home dir. The default
// is something like ../lib/julia/sys.ji
DLLEXPORT void jl_init_with_image(const char *julia_home_dir, const char *image_relative_path)
{
    if (jl_is_initialized()) return;
    libsupport_init();
    jl_compileropts.julia_home = julia_home_dir;
    if (image_relative_path != NULL)
        jl_compileropts.image_file = image_relative_path;
    julia_init(JL_IMAGE_JULIA_HOME);
    //TODO: these should be part of Multi.__init__()
    //currently, we have them here since we may not want them
    //getting unconditionally set from Base.__init__()
    jl_eval_string("Base.init_parallel()");
    jl_eval_string("Base.init_bind_addr(ARGS)");
    jl_eval_string("Base.init_head_sched()");
    jl_exception_clear();
}
コード例 #11
0
ファイル: jlapi.c プロジェクト: 5tivi/julia
// First argument is the usr/lib directory where libjulia is, or NULL to guess.
// if that doesn't work, try the full path to the "lib" directory that
// contains lib/julia/sys.ji
// Second argument is the path of a system image file (*.ji) relative to the
// first argument path, or relative to the default julia home dir. The default
// is something like ../lib/julia/sys.ji
DLLEXPORT void jl_init_with_image(char *julia_home_dir, char *image_relative_path)
{
    if (jl_is_initialized()) return;
    libsupport_init();
    if (image_relative_path == NULL)
        image_relative_path = JL_SYSTEM_IMAGE_PATH;
    char *image_file = jl_locate_sysimg(julia_home_dir, image_relative_path);
    julia_init(image_file);
    jl_set_const(jl_core_module, jl_symbol("JULIA_HOME"),
                 jl_cstr_to_string(julia_home));
    jl_module_export(jl_core_module, jl_symbol("JULIA_HOME"));
    jl_eval_string("Base.early_init()");
    jl_eval_string("Base.init_head_sched()");
    jl_eval_string("Base.init_load_path()");
    jl_exception_clear();
}
コード例 #12
0
ファイル: julia-api.c プロジェクト: rcqls/julia-api4rcqls
//-|  mode=="rcqls" is for rcqls development, mode="tty" is for initialization of STDOUT, STDERR with C API)
//-|  other value of mode mean standard jlapi.c
DLLEXPORT void jlapi_init(char *julia_home_dir, char* mode) {
  libsupport_init();
  char *image_file = jl_locate_sysimg(julia_home_dir);
  printf("image-file=%s\n",image_file);
  julia_init(image_file);
  jlapi_mode=mode;

  jl_set_const(jl_core_module, jl_symbol("JULIA_HOME"),
               jl_cstr_to_string(julia_home));
  jl_module_export(jl_core_module, jl_symbol("JULIA_HOME"));
  //-| This avoid LD_PRELOAD on linux since shared objects not exported
  //-| Maybe fix this in a better way with options compilation.
  char julia_api_libname[512];
#if defined(_OS_WINDOWS_)
  const char *shlib_ext=".dll";
  const char *sep="\\";
#elif defined(__APPLE__)
  const char *shlib_ext=".dylib";
  const char *sep="/";
#else
  const char *shlib_ext=".so";
  const char *sep="/";
#endif

  snprintf(julia_api_libname, sizeof(julia_api_libname), "%s%s%s%s%s%s",
          julia_home_dir, sep,"julia",sep,"libjulia-api",shlib_ext);
  load_library_permanently(julia_api_libname);
  if(strcmp(mode,"rcqls")<=0) { // cqls, rcqls
    //-| Called first to fix the DL_LOAD_PATH needed to (dl)open library (libpcre for example)
    //-| Replacement of Base.init_load_path()
    //-| Update 01/08/2013: No need to set DL_LOAD_PATH, just push 
    //-| jl_set_global(jl_base_module,jl_symbol("DL_LOAD_PATH"),jl_eval_string("ByteString[join([JULIA_HOME,\"..\",\"lib\",\"julia\"],Base.path_separator)]"));
    jl_eval_string("Base.push!(DL_LOAD_PATH,join([JULIA_HOME,\"..\",\"lib\",\"julia\"],Base.path_separator))");
    //-| DL_LOAD_PATH is a global constant already defined before and then not overloaded by julia
    //-| Only LOAD_PATH would be initialized (needs libpcre because of abspath)!
    jl_eval_string("vers = \"v$(VERSION.major).$(VERSION.minor)\"");
    jl_set_global(jl_base_module,jl_symbol("LOAD_PATH"),jl_eval_string("ByteString[abspath(JULIA_HOME,\"..\",\"local\",\"share\",\"julia\",\"site\",vers),abspath(JULIA_HOME,\"..\",\"share\",\"julia\",\"site\",vers)]")); 
  } else jl_eval_string("Base.init_load_path()");
  if(strcmp(mode,"tty")==0) {
    jl_eval_string("Base.reinit_stdio()");
    jl_set_global(jl_base_module,jl_symbol("STDIN"),jl_eval_string("Base.init_stdio(ccall(:jl_stdin_stream ,Ptr{Void},()),0)"));
    //-| 2 next lines fails even it is if no more necessary
    //-| Update 27/07/13: no more crash but stuck when print.
    jl_set_global(jl_base_module,jl_symbol("STDOUT"),jl_eval_string("Base.init_stdio(ccall(:jl_stdout_stream,Ptr{Void},()),1)"));
    jl_set_global(jl_base_module,jl_symbol("STDERR"),jl_eval_string("Base.init_stdio(ccall(:jl_stderr_stream,Ptr{Void},()),2)"));
  } else if(strcmp(mode,"rcqls")<=0) { //cqls, rcqls
    jl_eval_string("Base.reinit_stdio()");
    //-| STDIN, STDOUT and STDERR not properly loaded
    //-| I prefer redirection of STDOUT and STDERR in IOBuffer (maybe STDIN ???)
      jl_set_global(jl_base_module,jl_symbol("STDIN"),jl_eval_string("Base.init_stdio(ccall(:jl_stdin_stream ,Ptr{Void},()),0)"));
      //jl_set_global(jl_base_module,jl_symbol("STDIN"),jl_eval_string("IOBuffer()"));
      jl_set_global(jl_base_module,jl_symbol("STDOUT"),jl_eval_string("IOBuffer()"));
      jl_set_global(jl_base_module,jl_symbol("STDERR"),jl_eval_string("IOBuffer()"));
  } else jl_eval_string("Base.reinit_stdio()");
  jl_eval_string("Base.fdwatcher_reinit()");
  jl_eval_string("Base.Random.librandom_init()");
  jl_eval_string("Base.check_blas()");
  jl_eval_string("LinAlg.init()");
  jl_eval_string("Sys.init()");
  jl_eval_string("Base.init_sched()");
  jl_eval_string("Base.init_head_sched()");
  jl_eval_string("Base.try_include(abspath(ENV[\"HOME\"],\".juliarc.jl\"))");
  if(strcmp(mode,"rcqls")==0) { 
    jl_eval_string("println(\"Julia initialized!\")");
    jlapi_print_stdout();
  }
}