/// <summary> /// Creates a lua function for a delegate and binds a field of this container /// with the function. /// </summary> /// <param name="key">Key of the field to bind.</param> /// <param name="d">.Net delegate to bind the field to.</param> internal void BindWithFunction(string key, Delegate d) { // Creates a LuaFunction for the delegate. LuaFunction lf = _luaState.SafeProtectFunctionFromGC(_luaState.SafeCreateFunction(d)); // Sets the field with the function. _luaState.SafeSetField(_luaTable, key, lf); }
private FriendLuaDataProvider CreateProviderCore(LuaFunction native, LuaTable self = null, bool protectFromGC = false) { // Protects the function from garbage collection if needed. if (protectFromGC) { native = _luaState.SafeProtectFunctionFromGC(native); } // Creates a new provider. FriendLuaDataProvider ldp = new FriendLuaDataProvider(native, _luaState, this, self); // Returns the provider. return(ldp); }