Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int aFuncInterface(int a);
- int aFunc(int a) { return a; }
- int bFunc(int a) { return a*2; }
- bool cFunc(int a) { return true; }
- int dFunc(fixed a) { return FixedToInt(a*3); }
- void RefTest_Func ()
- {
- funcref<aFuncInterface> someFunction = aFunc;
- someFunction = bFunc;
- //someFunction = cFunc; type error
- //someFunction = dFunc; type error
- someFunction(1);
- }
- typedef funcref<aFuncInterface> int_return_intRef;
- void RefTest_TypeDefFunc ()
- {
- int_return_intRef someFunction = bFunc;
- someFunction = aFunc;
- someFunction(1);
- }
- void RefTest_FuncArray ()
- {
- int_return_intRef[2] someFunction;
- someFunction[0] = aFunc;
- someFunction[1] = bFunc;
- someFunction[0](1);
- someFunction[1](1);
- }
- int_return_intRef RefTest_FuncReturn ()
- {
- return bFunc;
- }
- struct aStruct { int a; string b; };
- aStruct aGlobalStruct;
- struct bStruct { int a; string b; };
- bStruct bGlobalStruct;
- void RefTest_Struct ()
- {
- aStruct aLocalStruct;
- structref<aStruct> someStruct = aLocalStruct;
- someStruct = aGlobalStruct;
- //someStruct = bGlobalStruct; bulk copy error
- }
- typedef structref<aStruct> aStructRef;
- void RefTest_TypeDefStruct ()
- {
- aStruct aLocalStruct;
- aStructRef someStruct = aLocalStruct;
- someStruct = aGlobalStruct;
- }
- void RefTest_StructArray ()
- {
- aStruct aLocalStruct;
- aStructRef[2] someStruct;
- someStruct[0] = aLocalStruct;
- someStruct[1] = aGlobalStruct;
- }
- struct funcStruct { int_return_intRef method; };
- typedef structref<funcStruct> funcStructRef;
- void RefTest_StructMethod ()
- {
- funcStruct aLocalStruct;
- funcStructRef someStruct;
- someStruct.method = bFunc;
- someStruct.method(1);
- }
- void RefTest_Parameters (structref<funcStruct> a, funcref<aFuncInterface> b)
- {
- funcStructRef someStruct = a;
- someStruct.method = b;
- someStruct.method(1);
- }
- void RefTest_ParametersWithTypedef (funcStructRef a, int_return_intRef b)
- {
- RefTest_Parameters(a,b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement