A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/b87867e69e94d9784468a126f21c721446f080de below:

add proper support of luv threads · neovim/neovim@b87867e · GitHub

File tree Expand file treeCollapse file tree 13 files changed

+992

-196

lines changed

Filter options

Expand file treeCollapse file tree 13 files changed

+992

-196

lines changed Original file line number Diff line number Diff line change

@@ -0,0 +1,48 @@

1 +

-- prevents luacheck from making lints for setting things on vim

2 +

local vim = assert(vim)

3 + 4 +

local pathtrails = {}

5 +

vim._so_trails = {}

6 +

for s in (package.cpath..';'):gmatch('[^;]*;') do

7 +

s = s:sub(1, -2) -- Strip trailing semicolon

8 +

-- Find out path patterns. pathtrail should contain something like

9 +

-- /?.so, \?.dll. This allows not to bother determining what correct

10 +

-- suffixes are.

11 +

local pathtrail = s:match('[/\\][^/\\]*%?.*$')

12 +

if pathtrail and not pathtrails[pathtrail] then

13 +

pathtrails[pathtrail] = true

14 +

table.insert(vim._so_trails, pathtrail)

15 +

end

16 +

end

17 + 18 +

function vim._load_package(name)

19 +

local basename = name:gsub('%.', '/')

20 +

local paths = {"lua/"..basename..".lua", "lua/"..basename.."/init.lua"}

21 +

local found = vim.api.nvim__get_runtime(paths, false, {is_lua=true})

22 +

if #found > 0 then

23 +

local f, err = loadfile(found[1])

24 +

return f or error(err)

25 +

end

26 + 27 +

local so_paths = {}

28 +

for _,trail in ipairs(vim._so_trails) do

29 +

local path = "lua"..trail:gsub('?', basename) -- so_trails contains a leading slash

30 +

table.insert(so_paths, path)

31 +

end

32 + 33 +

found = vim.api.nvim__get_runtime(so_paths, false, {is_lua=true})

34 +

if #found > 0 then

35 +

-- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is

36 +

-- a) strip prefix up to and including the first dash, if any

37 +

-- b) replace all dots by underscores

38 +

-- c) prepend "luaopen_"

39 +

-- So "foo-bar.baz" should result in "luaopen_bar_baz"

40 +

local dash = name:find("-", 1, true)

41 +

local modname = dash and name:sub(dash + 1) or name

42 +

local f, err = package.loadlib(found[1], "luaopen_"..modname:gsub("%.", "_"))

43 +

return f or error(err)

44 +

end

45 +

return nil

46 +

end

47 + 48 +

table.insert(package.loaders, 1, vim._load_package)

Original file line number Diff line number Diff line change

@@ -776,7 +776,7 @@ static void json_append_data(lua_State *l, json_config_t *cfg,

776 776 777 777

if (has_metatable) {

778 778 779 -

nlua_pushref(l, nlua_empty_dict_ref);

779 +

nlua_pushref(l, nlua_get_empty_dict_ref(l));

780 780

if (lua_rawequal(l, -2, -1)) {

781 781

as_empty_dict = true;

782 782

} else {

@@ -822,7 +822,7 @@ static void json_append_data(lua_State *l, json_config_t *cfg,

822 822

}

823 823

break;

824 824

case LUA_TUSERDATA:

825 -

nlua_pushref(l, nlua_nil_ref);

825 +

nlua_pushref(l, nlua_get_nil_ref(l));

826 826

bool is_nil = lua_rawequal(l, -2, -1);

827 827

lua_pop(l, 1);

828 828

if (is_nil) {

@@ -1285,7 +1285,7 @@ static void json_parse_object_context(lua_State *l, json_parse_t *json)

1285 1285 1286 1286

/* Handle empty objects */

1287 1287

if (token.type == T_OBJ_END) {

1288 -

nlua_pushref(l, nlua_empty_dict_ref); \

1288 +

nlua_pushref(l, nlua_get_empty_dict_ref(l)); \

1289 1289

lua_setmetatable(l, -2); \

1290 1290

json_decode_ascend(json);

1291 1291

return;

@@ -1392,7 +1392,7 @@ static void json_process_value(lua_State *l, json_parse_t *json,

1392 1392

if (use_luanil) {

1393 1393

lua_pushnil(l);

1394 1394

} else {

1395 -

nlua_pushref(l, nlua_nil_ref);

1395 +

nlua_pushref(l, nlua_get_nil_ref(l));

1396 1396

}

1397 1397

break;;

1398 1398

default:

@@ -1549,7 +1549,15 @@ int lua_cjson_new(lua_State *l)

1549 1549

};

1550 1550 1551 1551

/* Initialise number conversions */

1552 -

fpconv_init();

1552 +

lua_getfield(l, LUA_REGISTRYINDEX, "nvim.thread");

1553 +

bool is_thread = lua_toboolean(l, -1);

1554 +

lua_pop(l, 1);

1555 + 1556 +

// Since fpconv_init does not need to be called multiple times and is not

1557 +

// thread safe, it should only be called in the main thread.

1558 +

if (!is_thread) {

1559 +

fpconv_init();

1560 +

}

1553 1561 1554 1562

/* Test if array metatables are in registry */

1555 1563

lua_pushlightuserdata(l, json_lightudata_mask(&json_empty_array));

@@ -1582,7 +1590,7 @@ int lua_cjson_new(lua_State *l)

1582 1590

compat_luaL_setfuncs(l, reg, 1);

1583 1591 1584 1592

/* Set cjson.null */

1585 -

nlua_pushref(l, nlua_nil_ref);

1593 +

nlua_pushref(l, nlua_get_nil_ref(l));

1586 1594

lua_setfield(l, -2, "null");

1587 1595 1588 1596

/* Set cjson.empty_array_mt */

Original file line number Diff line number Diff line change

@@ -63,6 +63,7 @@ set(LUA_INSPECT_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/inspect.lua)

63 63

set(LUA_F_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/F.lua)

64 64

set(LUA_META_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/_meta.lua)

65 65

set(LUA_FILETYPE_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/filetype.lua)

66 +

set(LUA_LOAD_PACKAGE_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/_load_package.lua)

66 67

set(CHAR_BLOB_GENERATOR ${GENERATOR_DIR}/gen_char_blob.lua)

67 68

set(LINT_SUPPRESS_FILE ${PROJECT_BINARY_DIR}/errors.json)

68 69

set(LINT_SUPPRESS_URL_BASE "https://raw.githubusercontent.com/neovim/doc/gh-pages/reports/clint")

@@ -336,6 +337,7 @@ add_custom_command(

336 337

${LUA_F_MODULE_SOURCE} lua_F_module

337 338

${LUA_META_MODULE_SOURCE} lua_meta_module

338 339

${LUA_FILETYPE_MODULE_SOURCE} lua_filetype_module

340 +

${LUA_LOAD_PACKAGE_MODULE_SOURCE} lua_load_package_module

339 341

DEPENDS

340 342

${CHAR_BLOB_GENERATOR}

341 343

${LUA_VIM_MODULE_SOURCE}

@@ -344,6 +346,7 @@ add_custom_command(

344 346

${LUA_F_MODULE_SOURCE}

345 347

${LUA_META_MODULE_SOURCE}

346 348

${LUA_FILETYPE_MODULE_SOURCE}

349 +

${LUA_LOAD_PACKAGE_MODULE_SOURCE}

347 350

VERBATIM

348 351

)

349 352 Original file line number Diff line number Diff line change

@@ -1955,7 +1955,7 @@ Dictionary nvim__stats(void)

1955 1955

Dictionary rv = ARRAY_DICT_INIT;

1956 1956

PUT(rv, "fsync", INTEGER_OBJ(g_stats.fsync));

1957 1957

PUT(rv, "redraw", INTEGER_OBJ(g_stats.redraw));

1958 -

PUT(rv, "lua_refcount", INTEGER_OBJ(nlua_refcount));

1958 +

PUT(rv, "lua_refcount", INTEGER_OBJ(nlua_get_global_ref_count()));

1959 1959

return rv;

1960 1960

}

1961 1961 Original file line number Diff line number Diff line change

@@ -156,7 +156,7 @@ static LuaTableProps nlua_traverse_table(lua_State *const lstate)

156 156

&& ret.string_keys_num == 0)) {

157 157

ret.type = kObjectTypeArray;

158 158

if (tsize == 0 && lua_getmetatable(lstate, -1)) {

159 -

nlua_pushref(lstate, nlua_empty_dict_ref);

159 +

nlua_pushref(lstate, nlua_get_empty_dict_ref(lstate));

160 160

if (lua_rawequal(lstate, -2, -1)) {

161 161

ret.type = kObjectTypeDictionary;

162 162

}

@@ -401,7 +401,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv)

401 401

}

402 402

case LUA_TUSERDATA: {

403 403

// TODO(bfredl): check mt.__call and convert to function?

404 -

nlua_pushref(lstate, nlua_nil_ref);

404 +

nlua_pushref(lstate, nlua_get_nil_ref(lstate));

405 405

bool is_nil = lua_rawequal(lstate, -2, -1);

406 406

lua_pop(lstate, 1);

407 407

if (is_nil) {

@@ -445,7 +445,7 @@ static bool typval_conv_special = false;

445 445

if (typval_conv_special) { \

446 446

lua_pushnil(lstate); \

447 447

} else { \

448 -

nlua_pushref(lstate, nlua_nil_ref); \

448 +

nlua_pushref(lstate, nlua_get_nil_ref(lstate)); \

449 449

} \

450 450

} while (0)

451 451

@@ -495,7 +495,7 @@ static bool typval_conv_special = false;

495 495

nlua_create_typed_table(lstate, 0, 0, kObjectTypeDictionary); \

496 496

} else { \

497 497

lua_createtable(lstate, 0, 0); \

498 -

nlua_pushref(lstate, nlua_empty_dict_ref); \

498 +

nlua_pushref(lstate, nlua_get_empty_dict_ref(lstate)); \

499 499

lua_setmetatable(lstate, -2); \

500 500

} \

501 501

} while (0)

@@ -734,7 +734,7 @@ void nlua_push_Dictionary(lua_State *lstate, const Dictionary dict, bool special

734 734

} else {

735 735

lua_createtable(lstate, 0, (int)dict.size);

736 736

if (dict.size == 0 && !special) {

737 -

nlua_pushref(lstate, nlua_empty_dict_ref);

737 +

nlua_pushref(lstate, nlua_get_empty_dict_ref(lstate));

738 738

lua_setmetatable(lstate, -2);

739 739

}

740 740

}

@@ -782,7 +782,7 @@ void nlua_push_Object(lua_State *lstate, const Object obj, bool special)

782 782

if (special) {

783 783

lua_pushnil(lstate);

784 784

} else {

785 -

nlua_pushref(lstate, nlua_nil_ref);

785 +

nlua_pushref(lstate, nlua_get_nil_ref(lstate));

786 786

}

787 787

break;

788 788

case kObjectTypeLuaRef: {

@@ -1206,7 +1206,7 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Error *const err)

1206 1206

break;

1207 1207 1208 1208

case LUA_TUSERDATA: {

1209 -

nlua_pushref(lstate, nlua_nil_ref);

1209 +

nlua_pushref(lstate, nlua_get_nil_ref(lstate));

1210 1210

bool is_nil = lua_rawequal(lstate, -2, -1);

1211 1211

lua_pop(lstate, 1);

1212 1212

if (is_nil) {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4