~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/c/ffi.d

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-06-21 09:21:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060621092121-txz1f21lj0wh0f67
Tags: 0.9h-20060617-1
* New upstream version
* Updated standards version without real changes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
}
87
87
 
88
88
char *
89
 
ecl_string_pointer_safe(cl_object f)
 
89
ecl_base_string_pointer_safe(cl_object f)
90
90
{
91
91
        cl_index l;
92
92
        unsigned char *s;
93
 
        assert_type_string(f);
94
 
        s = f->string.self;
95
 
        if (f->string.hasfillp && s[f->string.fillp] != 0) {
 
93
        assert_type_base_string(f);
 
94
        s = f->base_string.self;
 
95
        if (f->base_string.hasfillp && s[f->base_string.fillp] != 0) {
96
96
                FEerror("Cannot coerce a string with fill pointer to (char *)", 0);
97
97
        }
98
98
        return (char *)s;
99
99
}
100
100
 
101
101
cl_object
102
 
ecl_null_terminated_string(cl_object f)
 
102
ecl_null_terminated_base_string(cl_object f)
103
103
{
104
 
        assert_type_string(f);
105
 
        if (f->string.hasfillp && f->string.self[f->string.fillp] != 0) {
 
104
        assert_type_base_string(f);
 
105
        if (f->base_string.hasfillp && f->base_string.self[f->base_string.fillp] != 0) {
106
106
                return cl_copy_seq(f);
107
107
        } else {
108
108
                return f;
282
282
        case ECL_FFI_POINTER_VOID:
283
283
                return ecl_make_foreign_data(@':pointer-void', 0, *(void **)p);
284
284
        case ECL_FFI_CSTRING:
285
 
                return *(char **)p ? make_simple_string(*(char **)p) : Cnil;
 
285
                return *(char **)p ? make_simple_base_string(*(char **)p) : Cnil;
286
286
        case ECL_FFI_OBJECT:
287
287
                return *(cl_object *)p;
288
288
        case ECL_FFI_FLOAT:
332
332
                *(void **)p = ecl_foreign_data_pointer_safe(value);
333
333
                break;
334
334
        case ECL_FFI_CSTRING:
335
 
                *(char **)p = value == Cnil ? NULL : value->string.self;
 
335
                *(char **)p = value == Cnil ? NULL : value->base_string.self;
336
336
                break;
337
337
        case ECL_FFI_OBJECT:
338
338
                *(cl_object *)p = value;
459
459
        void *sym;
460
460
 
461
461
        block = (module == @':default' ? module : si_load_foreign_module(module));
462
 
        var = ecl_null_terminated_string(var);
463
 
        sym = ecl_library_symbol(block, var->string.self, 1);
 
462
        var = ecl_null_terminated_base_string(var);
 
463
        sym = ecl_library_symbol(block, var->base_string.self, 1);
464
464
        if (sym == NULL) {
465
465
                if (block != @':default')
466
466
                        output = ecl_library_error(block);
542
542
                }
543
543
                type = ecl_foreign_type_code(CAR(arg_types));
544
544
                if (type == ECL_FFI_CSTRING) {
545
 
                        object = ecl_null_terminated_string(CAR(args));
 
545
                        object = ecl_null_terminated_base_string(CAR(args));
546
546
                        if (CAR(args) != object)
547
547
                                fficall->cstring =
548
548
                                        CONS(object, fficall->cstring);