@@ -727,6 +727,8 @@ pub const Lua = opaque {
727
727
///
728
728
/// See https://www.lua.org/manual/5.4/manual.html#lua_atpanic
729
729
pub fn atPanic (lua : * Lua , panic_fn : CFn ) ? CFn {
730
+ if (lang == .luau ) @compileError (@src ().fn_name ++ " is not implemented in Luau." );
731
+
730
732
return c .lua_atpanic (@ptrCast (lua ), panic_fn );
731
733
}
732
734
@@ -964,6 +966,7 @@ pub const Lua = opaque {
964
966
pub const dump = switch (lang ) {
965
967
.lua53 , .lua54 = > dump53 ,
966
968
else = > dump51 ,
969
+ .luau = > @compileError ("Not implemented in Luau." ),
967
970
};
968
971
969
972
/// Returns `true` if the two values in acceptable indices `index1` and `index2` are equal, following the semantics of the Lua `==`
@@ -1296,11 +1299,13 @@ pub const Lua = opaque {
1296
1299
1297
1300
/// Only available in Luau
1298
1301
pub fn setReadonly (lua : * Lua , idx : i32 , enabled : bool ) void {
1302
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
1299
1303
c .lua_setreadonly (@ptrCast (lua ), idx , @intFromBool (enabled ));
1300
1304
}
1301
1305
1302
1306
/// Only available in Luau
1303
1307
pub fn getReadonly (lua : * Lua , idx : i32 ) bool {
1308
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
1304
1309
return c .lua_getreadonly (@ptrCast (lua ), idx ) != 0 ;
1305
1310
}
1306
1311
@@ -1470,6 +1475,7 @@ pub const Lua = opaque {
1470
1475
/// * Errors: `never`
1471
1476
///
1472
1477
pub fn isVector (lua : * Lua , index : i32 ) bool {
1478
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
1473
1479
return c .lua_isvector (@as (* LuaState , @ptrCast (lua )), index );
1474
1480
}
1475
1481
@@ -1891,6 +1897,7 @@ pub const Lua = opaque {
1891
1897
///
1892
1898
/// See https://www.lua.org/manual/5.4/manual.html#lua_pushcclosure
1893
1899
pub fn pushClosureNamed (lua : * Lua , c_fn : CFn , debugname : [:0 ]const u8 , n : i32 ) void {
1900
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
1894
1901
c .lua_pushcclosurek (@ptrCast (lua ), c_fn , debugname , n , null );
1895
1902
}
1896
1903
@@ -1914,6 +1921,7 @@ pub const Lua = opaque {
1914
1921
///
1915
1922
/// See https://www.lua.org/manual/5.4/manual.html#lua_pushcfunction
1916
1923
pub fn pushFunctionNamed (lua : * Lua , c_fn : CFn , debugname : [:0 ]const u8 ) void {
1924
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
1917
1925
c .lua_pushcclosurek (@ptrCast (lua ), c_fn , debugname , 0 , null );
1918
1926
}
1919
1927
@@ -2103,7 +2111,10 @@ pub const Lua = opaque {
2103
2111
/// Pushes a floating point 3-vector (or 4-vector if configured) `v` onto the stack
2104
2112
///
2105
2113
/// Only available in Luau
2106
- pub const pushVector = if (luau_vector_size == 3 ) pushVector3 else pushVector4 ;
2114
+ pub const pushVector = switch (lang ) {
2115
+ .luau = > if (luau_vector_size == 3 ) pushVector3 else pushVector4 ,
2116
+ else = > @compileError ("pushVector is only available in Luau." ),
2117
+ };
2107
2118
2108
2119
/// Returns true if the two values in indices `index1` and `index2` are primitively equal
2109
2120
/// (that is, equal without calling the `__eq` metamethod). Otherwise returns false.
@@ -2483,6 +2494,7 @@ pub const Lua = opaque {
2483
2494
///
2484
2495
/// Only available in Luau
2485
2496
pub fn setUserdataTag (lua : * Lua , index : i32 , tag : i32 ) void {
2497
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
2486
2498
std .debug .assert ((tag >= 0 and tag < c .LUA_UTAG_LIMIT )); // Luau will do the same assert, this is easier to debug
2487
2499
c .lua_setuserdatatag (@ptrCast (lua ), index , tag );
2488
2500
}
@@ -2734,6 +2746,7 @@ pub const Lua = opaque {
2734
2746
2735
2747
/// Only available in Luau
2736
2748
pub fn toUserdataTagged (lua : * Lua , comptime T : type , index : i32 , tag : i32 ) ! * T {
2749
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
2737
2750
if (c .lua_touserdatatagged (@ptrCast (lua ), index , tag )) | ptr | return @ptrCast (@alignCast (ptr ));
2738
2751
return error .LuaError ;
2739
2752
}
@@ -2743,6 +2756,7 @@ pub const Lua = opaque {
2743
2756
///
2744
2757
/// Only available in Luau
2745
2758
pub fn toVector (lua : * Lua , index : i32 ) ! [luau_vector_size ]f32 {
2759
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
2746
2760
const res = c .lua_tovector (@ptrCast (lua ), index );
2747
2761
if (res ) | r | {
2748
2762
switch (luau_vector_size ) {
@@ -2759,6 +2773,7 @@ pub const Lua = opaque {
2759
2773
///
2760
2774
/// Only available in Luau
2761
2775
pub fn toStringAtom (lua : * Lua , index : i32 ) ! struct { i32 , [:0 ]const u8 } {
2776
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
2762
2777
var atom : c_int = undefined ;
2763
2778
if (c .lua_tostringatom (@ptrCast (lua ), index , & atom )) | ptr | {
2764
2779
return .{ atom , std .mem .span (ptr ) };
@@ -2771,6 +2786,7 @@ pub const Lua = opaque {
2771
2786
///
2772
2787
/// Only available in Luau
2773
2788
pub fn namecallAtom (lua : * Lua ) ! struct { i32 , [:0 ]const u8 } {
2789
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
2774
2790
var atom : c_int = undefined ;
2775
2791
if (c .lua_namecallatom (@ptrCast (lua ), & atom )) | ptr | {
2776
2792
return .{ atom , std .mem .span (ptr ) };
@@ -3200,13 +3216,15 @@ pub const Lua = opaque {
3200
3216
3201
3217
/// Only available in Luau
3202
3218
pub fn setInterruptCallbackFn (lua : * Lua , cb : ? CInterruptCallbackFn ) void {
3219
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
3203
3220
if (c .lua_callbacks (@ptrCast (lua ))) | cb_struct | {
3204
3221
cb_struct .* .interrupt = cb ;
3205
3222
}
3206
3223
}
3207
3224
3208
3225
/// Only available in Luau
3209
3226
pub fn setUserAtomCallbackFn (lua : * Lua , cb : CUserAtomCallbackFn ) void {
3227
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
3210
3228
if (c .lua_callbacks (@ptrCast (lua ))) | cb_struct | {
3211
3229
cb_struct .* .useratom = cb ;
3212
3230
}
@@ -3471,6 +3489,7 @@ pub const Lua = opaque {
3471
3489
///
3472
3490
/// Only available in Luau
3473
3491
pub fn checkVector (lua : * Lua , arg : i32 ) [luau_vector_size ]f32 {
3492
+ if (lang != .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
3474
3493
const vec = lua .toVector (arg ) catch {
3475
3494
lua .typeError (arg , lua .typeName (LuaType .vector ));
3476
3495
};
@@ -3550,7 +3569,7 @@ pub const Lua = opaque {
3550
3569
///
3551
3570
/// Only available in Luau
3552
3571
pub fn raiseInterruptErrorStr (lua : * Lua , fmt : [:0 ]const u8 , args : anytype ) noreturn {
3553
- if (lang != .luau ) return ;
3572
+ if (lang != .luau ) @compileError ( @src (). fn_name ++ " is only available in Luau." ) ;
3554
3573
c .lua_rawcheckstack (@ptrCast (lua ), 1 );
3555
3574
lua .raiseErrorStr (fmt , args );
3556
3575
unreachable ;
@@ -3644,6 +3663,7 @@ pub const Lua = opaque {
3644
3663
///
3645
3664
/// See https://www.lua.org/manual/5.4/manual.html#luaL_gsub
3646
3665
pub fn globalSub (lua : * Lua , str : [:0 ]const u8 , pat : [:0 ]const u8 , rep : [:0 ]const u8 ) []const u8 {
3666
+ if (lang == .luau ) @compileError (@src ().fn_name ++ " is not available in Luau." );
3647
3667
const s = c .luaL_gsub (@ptrCast (lua ), str .ptr , pat .ptr , rep .ptr );
3648
3668
const l = lua .rawLen (-1 );
3649
3669
return s [0.. l ];
@@ -4205,6 +4225,7 @@ pub const Lua = opaque {
4205
4225
/// * Pushes: `0`
4206
4226
/// * Errors: `other`
4207
4227
pub fn openPackage (lua : * Lua ) void {
4228
+ if (lang == .luau ) @compileError (@src ().fn_name ++ " is not available in Luau." );
4208
4229
lua .requireF (c .LUA_LOADLIBNAME , c .luaopen_package , true );
4209
4230
if (lang == .lua52 or lang == .lua53 or lang == .lua54 ) lua .pop (1 );
4210
4231
}
@@ -4259,6 +4280,7 @@ pub const Lua = opaque {
4259
4280
/// * Pushes: `0`
4260
4281
/// * Errors: `other`
4261
4282
pub fn openIO (lua : * Lua ) void {
4283
+ if (lang == .luau ) @compileError (@src ().fn_name ++ " is not available in Luau." );
4262
4284
lua .requireF (c .LUA_IOLIBNAME , c .luaopen_io , true );
4263
4285
if (lang == .lua52 or lang == .lua53 or lang == .lua54 ) lua .pop (1 );
4264
4286
}
@@ -4301,6 +4323,7 @@ pub const Lua = opaque {
4301
4323
/// * Pushes: `0`
4302
4324
/// * Errors: `other`
4303
4325
pub fn openVector (lua : * Lua ) void {
4326
+ if (lang == .luau ) @compileError (@src ().fn_name ++ " is only available in Luau." );
4304
4327
lua .requireF (c .LUA_VECLIBNAME , c .luaopen_vector , true );
4305
4328
if (lang == .lua52 or lang == .lua53 or lang == .lua54 ) lua .pop (1 );
4306
4329
}
0 commit comments