diff options
author | Mike Pall <mike> | 2012-11-15 00:21:01 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2012-11-15 00:26:34 +0100 |
commit | 16f23458bce22958e27176ca64f8df57c985cb1a (patch) | |
tree | 39b7f69943ccc81201c5c97ae6d5c939d050888e /src | |
parent | 2689f32453eb891847d538a880c8adb6fbe2c5b5 (diff) | |
download | luajit-16f23458bce22958e27176ca64f8df57c985cb1a.tar.gz luajit-16f23458bce22958e27176ca64f8df57c985cb1a.tar.bz2 luajit-16f23458bce22958e27176ca64f8df57c985cb1a.zip |
FFI: Change priority of table initializer variants for structs.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_cconv.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lj_cconv.c b/src/lj_cconv.c index b81b4e90..7b32e35d 100644 --- a/src/lj_cconv.c +++ b/src/lj_cconv.c | |||
@@ -493,17 +493,19 @@ static void cconv_substruct_tab(CTState *cts, CType *d, uint8_t *dp, | |||
493 | id = df->sib; | 493 | id = df->sib; |
494 | if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { | 494 | if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { |
495 | TValue *tv; | 495 | TValue *tv; |
496 | int32_t i = *ip; | 496 | int32_t i = *ip, iz = i; |
497 | if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ | 497 | if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ |
498 | if (i >= 0) { | 498 | if (i >= 0) { |
499 | retry: | 499 | retry: |
500 | tv = (TValue *)lj_tab_getint(t, i); | 500 | tv = (TValue *)lj_tab_getint(t, i); |
501 | if (!tv || tvisnil(tv)) { | 501 | if (!tv || tvisnil(tv)) { |
502 | if (i == 0) { i = 1; goto retry; } /* 1-based tables. */ | 502 | if (i == 0) { i = 1; goto retry; } /* 1-based tables. */ |
503 | if (iz == 0) { *ip = i = -1; goto tryname; } /* Init named fields. */ | ||
503 | break; /* Stop at first nil. */ | 504 | break; /* Stop at first nil. */ |
504 | } | 505 | } |
505 | *ip = i + 1; | 506 | *ip = i + 1; |
506 | } else { | 507 | } else { |
508 | tryname: | ||
507 | tv = (TValue *)lj_tab_getstr(t, gco2str(gcref(df->name))); | 509 | tv = (TValue *)lj_tab_getstr(t, gco2str(gcref(df->name))); |
508 | if (!tv || tvisnil(tv)) continue; | 510 | if (!tv || tvisnil(tv)) continue; |
509 | } | 511 | } |
@@ -524,7 +526,6 @@ static void cconv_struct_tab(CTState *cts, CType *d, | |||
524 | { | 526 | { |
525 | int32_t i = 0; | 527 | int32_t i = 0; |
526 | memset(dp, 0, d->size); /* Much simpler to clear the struct first. */ | 528 | memset(dp, 0, d->size); /* Much simpler to clear the struct first. */ |
527 | if (t->hmask) i = -1; else if (t->asize == 0) return; /* Fast exit. */ | ||
528 | cconv_substruct_tab(cts, d, dp, t, &i, flags); | 529 | cconv_substruct_tab(cts, d, dp, t, &i, flags); |
529 | } | 530 | } |
530 | 531 | ||