feat: swap list insert arguments to index-first order and update all call sites
Swap the parameter order of `List.insert()` from `(item, index)` to `(index, item)`, matching the convention used by most standard libraries. Update the C implementation in `wren_core.c`, all documentation examples, and every test file to reflect the new signature. Also restructure MSVC project files to match the new `src/cli/` and `src/vm/` directory layout, add Visual Studio cache files to `.gitignore`, and fix a trailing whitespace issue in `class_supertype`.
This commit is contained in:
+4
-4
@@ -376,7 +376,7 @@ DEF_PRIMITIVE(class_supertype)
|
||||
|
||||
// Object has no superclass.
|
||||
if (classObj->superclass == NULL) RETURN_NULL;
|
||||
|
||||
|
||||
RETURN_OBJ(classObj->superclass);
|
||||
}
|
||||
|
||||
@@ -690,11 +690,11 @@ DEF_PRIMITIVE(list_insert)
|
||||
ObjList* list = AS_LIST(args[0]);
|
||||
|
||||
// count + 1 here so you can "insert" at the very end.
|
||||
int index = validateIndex(vm, args, list->count + 1, 2, "Index");
|
||||
int index = validateIndex(vm, args, list->count + 1, 1, "Index");
|
||||
if (index == -1) return PRIM_ERROR;
|
||||
|
||||
wrenListInsert(vm, list, args[1], index);
|
||||
RETURN_VAL(args[1]);
|
||||
wrenListInsert(vm, list, args[2], index);
|
||||
RETURN_VAL(args[2]);
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(list_iterate)
|
||||
|
||||
Reference in New Issue
Block a user