File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -553,3 +553,8 @@ pub struct lua_Callbacks {
553
553
extern "C" {
554
554
pub fn lua_callbacks ( L : * mut lua_State ) -> * mut lua_Callbacks ;
555
555
}
556
+
557
+ // Functions from customization lib
558
+ extern "C" {
559
+ pub fn luau_setfflag ( name : * const c_char , value : c_int ) -> c_int ;
560
+ }
Original file line number Diff line number Diff line change @@ -1288,6 +1288,20 @@ impl Lua {
1288
1288
unsafe { ( * self . extra . get ( ) ) . enable_jit = enable } ;
1289
1289
}
1290
1290
1291
+ /// Sets Luau feature flag (global setting).
1292
+ ///
1293
+ /// See https://github.com/luau-lang/luau/blob/master/CONTRIBUTING.md#feature-flags for details.
1294
+ #[ cfg( feature = "luau" ) ]
1295
+ #[ doc( hidden) ]
1296
+ pub fn set_fflag ( name : & str , enabled : bool ) -> StdResult < ( ) , ( ) > {
1297
+ if let Ok ( name) = CString :: new ( name) {
1298
+ if unsafe { ffi:: luau_setfflag ( name. as_ptr ( ) , enabled as c_int ) != 0 } {
1299
+ return Ok ( ( ) ) ;
1300
+ }
1301
+ }
1302
+ Err ( ( ) )
1303
+ }
1304
+
1291
1305
/// Returns Lua source code as a `Chunk` builder type.
1292
1306
///
1293
1307
/// In order to actually compile or run the resulting code, you must call [`Chunk::exec`] or
Original file line number Diff line number Diff line change @@ -484,3 +484,9 @@ fn test_buffer() -> Result<()> {
484
484
485
485
Ok ( ( ) )
486
486
}
487
+
488
+ #[ test]
489
+ fn test_fflags ( ) {
490
+ // We cannot really on any particular feature flag to be present
491
+ assert ! ( Lua :: set_fflag( "UnknownFlag" , true ) . is_err( ) ) ;
492
+ }
You can’t perform that action at this time.
0 commit comments