October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | Another converting problem.. not sure if this one can be solved with D. #define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName)) I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself. Here's my conversion attempt template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) { REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, void function(char *input, int numberOfBitsOfData, PlayerID sender) functionName) { networkObject.RegisterAsRemoteProcedureCall(uniqueID , functionName); // line 480 } } but I get raknet/networktypes.d(480): found 'networkObject' when expecting ')' raknet/networktypes.d(480): no identifier for declarator REGISTER_AS_REMOTE_PROCEDURE_CALL raknet/networktypes.d(480): semicolon expected, not 'char' raknet/networktypes.d(480): no identifier for declarator char* raknet/networktypes.d(480): semicolon expected, not 'void' raknet/networktypes.d(480): semicolon expected, not ')' raknet/networktypes.d(480): Declaration expected, not ')' raknet/networktypes.d(484): unrecognized declaration |
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | On Sun, 30 Oct 2005 22:53:51 -0500, clayasaurus wrote: > Another converting problem.. not sure if this one can be solved with D. > > #define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName)) > > I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself. > > Here's my conversion attempt > > template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) > { > REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, > void function(char *input, int numberOfBitsOfData, PlayerID sender) , // <<<< NEEDS A COMMA ? > functionName) > { > networkObject.RegisterAsRemoteProcedureCall(uniqueID , > functionName); // line 480 > } > } -- Derek (skype: derek.j.parnell) Melbourne, Australia 31/10/2005 2:58:53 PM |
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > On Sun, 30 Oct 2005 22:53:51 -0500, clayasaurus wrote: > > >>Another converting problem.. not sure if this one can be solved with D. >> >>#define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName)) >> >>I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself. >> >>Here's my conversion attempt >> >>template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) >>{ >> REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, >>void function(char *input, int numberOfBitsOfData, PlayerID sender) > > > > , // <<<< NEEDS A COMMA ? from the function pointer docs http://www.digitalmars.com/d/type.html , it uses int function(int) fp; // fp is pointer to a function from there i assume void function(char *input, int numberOfBitsOfData, PlayerID sender) functionName; is valid. my logic then thinks the following should work... void somefunc(void function(char *input, int numberOfBitsOfData, PlayerID sender) fp) { fp(); // call fp } or should i try typedef void function(char *input, int numberOfBitsOfData, PlayerID sender) fp; void somefunc(fp funcName) { funcName(); } but I don't understand why I would need void somefunc(void function(char *input, int numberOfBitsOfData, PlayerID sender), fp) { fp(); } *confused* > > >>functionName) >> { >> networkObject.RegisterAsRemoteProcedureCall(uniqueID , >>functionName); // line 480 >> } >>} > > > |
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | On Mon, 31 Oct 2005 14:59:39 +1100, Derek Parnell wrote: > On Sun, 30 Oct 2005 22:53:51 -0500, clayasaurus wrote: > >> Another converting problem.. not sure if this one can be solved with D. >> >> #define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName)) >> >> I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself. >> >> Here's my conversion attempt >> >> template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) >> { >> REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, >> void function(char *input, int numberOfBitsOfData, PlayerID sender) > > , // <<<< NEEDS A COMMA ? > Sorry, I wasn't thinking ;-) The function called "REGISTER_AS_REMOTE_PROCEDURE_CALL", inside the template of the same name, needs to specify it return type. For example, this compiles ... template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) { void REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, void function(char *input, int numberOfBitsOfData, PlayerID sender) functionName) { networkObject.RegisterAsRemoteProcedureCall(uniqueID , functionName); // line 480 } } -- Derek (skype: derek.j.parnell) Melbourne, Australia 31/10/2005 3:14:18 PM |
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > On Mon, 31 Oct 2005 14:59:39 +1100, Derek Parnell wrote: > > >>On Sun, 30 Oct 2005 22:53:51 -0500, clayasaurus wrote: >> >> >>>Another converting problem.. not sure if this one can be solved with D. >>> >>>#define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName)) >>> >>>I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself. >>> >>>Here's my conversion attempt >>> >>>template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) >>>{ >>> REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, >>>void function(char *input, int numberOfBitsOfData, PlayerID sender) >> >>, // <<<< NEEDS A COMMA ? >> > > > Sorry, I wasn't thinking ;-) > No prob. > The function called "REGISTER_AS_REMOTE_PROCEDURE_CALL", inside the > template of the same name, needs to specify it return type. > > For example, this compiles ... > > template REGISTER_AS_REMOTE_PROCEDURE_CALL(T) > { > void REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, > void function(char *input, int numberOfBitsOfData, PlayerID sender) > functionName) > { > networkObject.RegisterAsRemoteProcedureCall(uniqueID , functionName); // line 480 > } > } > Ahh.. thanks. It is amazing how that got away from me. I meticulously plan and read docs and I forget a void *doh* |
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote:
> On Mon, 31 Oct 2005 14:59:39 +1100, Derek Parnell wrote:
>
>
>>On Sun, 30 Oct 2005 22:53:51 -0500, clayasaurus wrote:
>>
>>
>>>Another converting problem.. not sure if this one can be solved with D.
>>>
>>>#define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName))
>>>
>>>I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself.
>>>
>>>Here's my conversion attempt
>>>
>>>template REGISTER_AS_REMOTE_PROCEDURE_CALL(T)
>>>{
>>> REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID,
>>>void function(char *input, int numberOfBitsOfData, PlayerID sender)
>>
>>, // <<<< NEEDS A COMMA ?
>>
>
>
> Sorry, I wasn't thinking ;-)
>
> The function called "REGISTER_AS_REMOTE_PROCEDURE_CALL", inside the
> template of the same name, needs to specify it return type.
>
> For example, this compiles ...
>
> template REGISTER_AS_REMOTE_PROCEDURE_CALL(T)
> {
> void REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID,
> void function(char *input, int numberOfBitsOfData, PlayerID sender)
> functionName)
> {
> networkObject.RegisterAsRemoteProcedureCall(uniqueID , functionName); // line 480
> }
> }
>
I might as well ask this longshot question while I'm at it.
Is it possible to convert functionName into a character string of the actual function name it is pointing to?
|
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | It also appears that the = operator in D is not overloadable. Should I settle with a function called 'deepCopy()' ? |
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | clayasaurus wrote:
> Derek Parnell wrote:
>
>> On Mon, 31 Oct 2005 14:59:39 +1100, Derek Parnell wrote:
>>
>>
>>> On Sun, 30 Oct 2005 22:53:51 -0500, clayasaurus wrote:
>>>
>>>
>>>> Another converting problem.. not sure if this one can be solved with D.
>>>>
>>>> #define REGISTER_AS_REMOTE_PROCEDURE_CALL(networkObject, functionName) (networkObject)->RegisterAsRemoteProcedureCall((#functionName),(functionName))
>>>>
>>>>
>>>> I'm pretty sure #functionName turns it into a char*, while functionName is the function pointer itself.
>>>>
>>>> Here's my conversion attempt
>>>>
>>>> template REGISTER_AS_REMOTE_PROCEDURE_CALL(T)
>>>> {
>>>> REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID, void function(char *input, int numberOfBitsOfData, PlayerID sender)
>>>
>>>
>>> , // <<<< NEEDS A COMMA ?
>>>
>>
>>
>> Sorry, I wasn't thinking ;-)
>>
>> The function called "REGISTER_AS_REMOTE_PROCEDURE_CALL", inside the
>> template of the same name, needs to specify it return type.
>>
>> For example, this compiles ...
>>
>> template REGISTER_AS_REMOTE_PROCEDURE_CALL(T)
>> {
>> void REGISTER_AS_REMOTE_PROCEDURE_CALL(T networkObject, char* uniqueID,
>> void function(char *input, int numberOfBitsOfData, PlayerID sender)
>> functionName)
>> {
>> networkObject.RegisterAsRemoteProcedureCall(uniqueID , functionName); // line 480
>> }
>> }
>>
>
> I might as well ask this longshot question while I'm at it.
>
> Is it possible to convert functionName into a character string of the actual function name it is pointing to?
>
>
In an obvious fashion... no, not that I know of. Although it would be a killer feature. Yet another argument in favor of a (standard) reflection mechanism for D.
-- Chris Sauls
|
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | On Mon, 31 Oct 2005 00:30:17 -0500, clayasaurus <clayasaurus@gmail.com> wrote:
> It also appears that the = operator in D is not overloadable. Should I settle with a function called 'deepCopy()' ?
I would call it "dup" as that is what arrays use for a deep copy.
Regan
|
October 31, 2005 Re: a slew of questions about D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote: > On Mon, 31 Oct 2005 00:30:17 -0500, clayasaurus <clayasaurus@gmail.com> wrote: > >> It also appears that the = operator in D is not overloadable. Should I settle with a function called 'deepCopy()' ? > > > I would call it "dup" as that is what arrays use for a deep copy. > > Regan Arrays don't have the two concepts of shallow copy or deep copy, only of simple copy/duplication, which, if compared to object cloning/copying, would be 'equivalent' to shallow copying, not deep copying (but such comparision should not be made in the first place). -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
Copyright © 1999-2021 by the D Language Foundation