Ticket #437: parrot_libloading.patch

File parrot_libloading.patch, 3.4 KB (added by wayland, 13 years ago)
  • parrot/src/library.c

     
    710710} 
    711711 
    712712/* 
     713=item C<STRING* Parrot_path_str> 
    713714 
     715Returns a STRING that contains the specified path, separated by colons (:).   
     716 
     717The C<enum_runtime_ft type> is one or more of the types defined in 
     718F<include/parrot/library.h>. 
     719 
     720=cut 
     721 
     722*/ 
     723 
     724PARROT_EXPORT 
     725PARROT_WARN_UNUSED_RESULT 
     726PARROT_CAN_RETURN_NULL 
     727STRING* 
     728Parrot_path_str(PARROT_INTERP, enum_runtime_ft type) 
     729{ 
     730    ASSERT_ARGS(Parrot_path_str) 
     731    STRING *prefix; 
     732    STRING *full_path; 
     733    PMC    *paths; 
     734    INTVAL  i, n; 
     735 
     736/* TODO: Get the real separator, not this hacked-together stuff */ 
     737#ifdef WIN32 
     738    STRING * const envpathsep = CONST_STRING(interp, ";");  
     739#else 
     740    STRING * const envpathsep = CONST_STRING(interp, ":"); 
     741#endif 
     742 
     743    if (type & PARROT_RUNTIME_FT_DYNEXT) 
     744        paths = get_search_paths(interp, PARROT_LIB_PATH_DYNEXT); 
     745    else if (type & (PARROT_RUNTIME_FT_PBC | PARROT_RUNTIME_FT_SOURCE)) 
     746        paths = get_search_paths(interp, PARROT_LIB_PATH_LIBRARY); 
     747    else 
     748        paths = get_search_paths(interp, PARROT_LIB_PATH_INCLUDE); 
     749 
     750    prefix = Parrot_get_runtime_path(interp); 
     751    n = VTABLE_elements(interp, paths); 
     752 
     753    for (i = 0; i < n; ++i) { 
     754        STRING * const path = VTABLE_get_string_keyed_int(interp, paths, i); 
     755        STRING *found_name; 
     756 
     757        if ( 0 == i ) { 
     758            full_path = Parrot_str_copy(interp, path); 
     759        } else { 
     760            if(path) { 
     761                full_path = Parrot_str_append(interp, full_path, envpathsep); 
     762                full_path = Parrot_str_append(interp, full_path, path); 
     763            } 
     764        } 
     765    } 
     766 
     767    return full_path; 
     768} 
     769 
     770/* 
     771 
    714772=item C<char* Parrot_get_runtime_prefix> 
    715773 
    716774Return a malloced C-string for the runtime prefix.  The calling function 
  • parrot/src/dynext.c

     
    615615        /* 
    616616         * XXX Parrot_ex_throw_from_c_args? return PMCNULL? 
    617617         * PMC Undef seems convenient, because it can be queried with get_bool() 
     618         * -- 
     619         * Changed to Parrot_ex_throw_from_c_args because silently continuing and 
     620         * giving weird errors later is not a cool look - wayland/Tim Nelson 
    618621         */ 
    619         return pmc_new(interp, enum_class_Undef); 
     622        /* return pmc_new(interp, enum_class_Undef); */ 
     623 
     624        path = Parrot_path_str(interp, PARROT_RUNTIME_FT_DYNEXT); 
     625 
     626        Parrot_ex_throw_from_c_args(interp, NULL, 
     627                EXCEPTION_LIBRARY_ERROR, 
     628                "Parrot VM: Can't load library '%s'; searched path %s\n",  
     629                wo_ext->strstart, path->strstart); 
    620630    } 
    621631 
    622632    return run_init_lib(interp, handle, lib_name, wo_ext); 
  • parrot/include/parrot/library.h

     
    7474        __attribute__nonnull__(2) 
    7575        FUNC_MODIFIES(*file); 
    7676 
     77PARROT_EXPORT 
     78PARROT_WARN_UNUSED_RESULT 
     79PARROT_CAN_RETURN_NULL 
     80STRING* Parrot_path_str(PARROT_INTERP, 
     81    enum_runtime_ft type) 
     82        __attribute__nonnull__(1); 
     83 
    7784void parrot_init_library_paths(PARROT_INTERP) 
    7885        __attribute__nonnull__(1); 
    7986