Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default value for CBA_fnc_serializeNamespace #1044

Merged
merged 2 commits into from
Jan 18, 2019
Merged

add default value for CBA_fnc_serializeNamespace #1044

merged 2 commits into from
Jan 18, 2019

Conversation

xetra11
Copy link
Contributor

@xetra11 xetra11 commented Jan 5, 2019

When merged this pull request will:

  • Will add a default value parameter for fnc_serializeVariable

I needed this for my mod project since I use this function but was missing the defaultValue I was used to when using fnc_hashCreate

@commy2
Copy link
Contributor

commy2 commented Jan 5, 2019

I can't test this ingame, but my brain debugger tells me, that this will error in scheduled environment if no or nil default value is proved.

0 spawn {
    objNull call CBA_fnc_serializeNamespace;
};

-> error undefined variable in expression.

This should not error before this PR.

@xetra11
Copy link
Contributor Author

xetra11 commented Jan 5, 2019

Where can I download this brain debugger!?
Will check for errors now

@xetra11
Copy link
Contributor Author

xetra11 commented Jan 5, 2019

@commy2 any suggestions? Having a [] as fallback/default value kinda does not feel good in my opinion since people using this function already might test for any (which is the actual behaviour without the defaultValue parameter).

Don't wanna break the legacy here

@commy2
Copy link
Contributor

commy2 commented Jan 5, 2019

Replace _defaultValue with RETNIL(_defaultValue) in L28.

Where can I download this brain debugger!?

Years of pain and suffering through these exact same issues.

@commy2
Copy link
Contributor

commy2 commented Jan 5, 2019

lgtm now

@commy2
Copy link
Contributor

commy2 commented Jan 18, 2019

0 spawn {
    a = [] call CBA_fnc_createNamespace; 
    a setVariable ["a", 1]; 
    a = a call CBA_fnc_serializeNamespace; 
    a = [a] call CBA_fnc_deserializeNamespace; 
    private _a = a getVariable "a"; 
    a call CBA_fnc_deleteNamespace; 
    hint str [a, _a] // [No location,1]
};

works

@commy2
Copy link
Contributor

commy2 commented Jan 18, 2019

0 spawn {
    a = [] call CBA_fnc_createNamespace; 
    a setVariable ["a", 1]; 
    a = [a, 0] call CBA_fnc_serializeNamespace; 
 
    _a = [a, "a"] call CBA_fnc_hashGet;
    _b = [a, "b"] call CBA_fnc_hashGet;
    _c = [a, "c", -1] call CBA_fnc_hashGet;
    hint str [_a, _b, _c]; // [1,0,-1]
};

works

@commy2
Copy link
Contributor

commy2 commented Jan 18, 2019

execVM "\x\cba\addons\hashes\test_hashes.sqf"

13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_hashCreate is defined) x\cba\addons\hashes\test_hashes.sqf:14
13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_hashGet is defined) x\cba\addons\hashes\test_hashes.sqf:15
13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_hashSet is defined) x\cba\addons\hashes\test_hashes.sqf:16
13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_hashHasKey is defined) x\cba\addons\hashes\test_hashes.sqf:17
13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_isHash is defined) x\cba\addons\hashes\test_hashes.sqf:18
13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_hashSize is defined) x\cba\addons\hashes\test_hashes.sqf:19
13:25:49 [CBA] (hashes) Test OK: (CBA_fnc_hashKeys is defined) x\cba\addons\hashes\test_hashes.sqf:20
13:25:49 [CBA] (hashes) Test OK: (not ([[]] call CBA_fnc_isHash)) x\cba\addons\hashes\test_hashes.sqf:22
13:25:49 [CBA] (hashes) Test OK: (not ([_hash] call CBA_fnc_isHash)) x\cba\addons\hashes\test_hashes.sqf:24
13:25:49 [CBA] (hashes) Test OK: (not ([5] call CBA_fnc_isHash)) x\cba\addons\hashes\test_hashes.sqf:25
13:25:49 [CBA] (hashes) Test OK: (_hash is defined) x\cba\addons\hashes\test_hashes.sqf:29
13:25:49 [CBA] (hashes) Test OK: ([_hash] call CBA_fnc_isHash) x\cba\addons\hashes\test_hashes.sqf:30
13:25:49 [CBA] (hashes) Test OK: (not (_result)) x\cba\addons\hashes\test_hashes.sqf:33
13:25:49 [CBA] (hashes) Test OK: ([_hash] call CBA_fnc_isHash) x\cba\addons\hashes\test_hashes.sqf:36
13:25:49 [CBA] (hashes) Test OK: (_result == 12) x\cba\addons\hashes\test_hashes.sqf:39
13:25:49 [CBA] (hashes) Test OK: (_result) x\cba\addons\hashes\test_hashes.sqf:42
13:25:49 [CBA] (hashes) Test OK: (not (_result)) x\cba\addons\hashes\test_hashes.sqf:45
13:25:49 [CBA] (hashes) Test OK: (isNil "_result") x\cba\addons\hashes\test_hashes.sqf:51
13:25:49 [CBA] (hashes) Test OK: (isNil "_result") x\cba\addons\hashes\test_hashes.sqf:58
13:25:49 [CBA] (hashes) Test OK: (isNil "_result") x\cba\addons\hashes\test_hashes.sqf:62
13:25:49 [CBA] (hashes) Test OK: ([_hash] call CBA_fnc_isHash) x\cba\addons\hashes\test_hashes.sqf:66
13:25:49 [CBA] (hashes) Test OK: (_result is defined) x\cba\addons\hashes\test_hashes.sqf:69
13:25:49 [CBA] (hashes) Test OK: (_result == 99) x\cba\addons\hashes\test_hashes.sqf:70
13:25:49 [CBA] (hashes) Test OK: ([_hash] call CBA_fnc_isHash) x\cba\addons\hashes\test_hashes.sqf:74
13:25:49 [CBA] (hashes) Test OK: (_result is defined) x\cba\addons\hashes\test_hashes.sqf:77
13:25:49 [CBA] (hashes) Test OK: (_result == -8) x\cba\addons\hashes\test_hashes.sqf:78
13:25:49 [CBA] (hashes) Test OK: (_result is defined) x\cba\addons\hashes\test_hashes.sqf:81
13:25:49 [CBA] (hashes) Test OK: (_result == 0) x\cba\addons\hashes\test_hashes.sqf:82
13:25:49 [CBA] (hashes) Test OK: (_result is defined) x\cba\addons\hashes\test_hashes.sqf:86
13:25:49 [CBA] (hashes) Test OK: (_result == 1) x\cba\addons\hashes\test_hashes.sqf:87
13:25:49 [CBA] (hashes) Test OK: (isNil "_result") x\cba\addons\hashes\test_hashes.sqf:91
13:25:49 [CBA] (hashes) Test OK: (_size == 0) x\cba\addons\hashes\test_hashes.sqf:96
13:25:49 [CBA] (hashes) Test OK: (_size == 1) x\cba\addons\hashes\test_hashes.sqf:101
13:25:49 [CBA] (hashes) Test OK: (_size == 3) x\cba\addons\hashes\test_hashes.sqf:107
13:25:49 [CBA] (hashes) Test OK: (_size == 2) x\cba\addons\hashes\test_hashes.sqf:112
13:25:49 [CBA] (hashes) Test OK: (_size == -1) x\cba\addons\hashes\test_hashes.sqf:117
13:25:49 [CBA] (hashes) Test OK: (_keys isEqualTo []) x\cba\addons\hashes\test_hashes.sqf:122
13:25:49 [CBA] (hashes) Test OK: (_keys isEqualTo ["123", "124", 125]) x\cba\addons\hashes\test_hashes.sqf:129

works

@commy2 commy2 added this to the 3.10 milestone Jan 18, 2019
@commy2 commy2 self-assigned this Jan 18, 2019
@commy2 commy2 merged commit b75f68b into CBATeam:master Jan 18, 2019
@commy2 commy2 changed the title add default value for serializedNamespace add default value for CBA_fnc_serializeNamespace Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants