Skip to content
This repository has been archived by the owner on Apr 25, 2018. It is now read-only.

Cleaned code, removed smc.h, fixed typos #4

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

perfaram
Copy link
Contributor

List :

  • Cleaned code (by removing smc.h and transferring missing typedefs into SMCWrapper.h, by wiping useless macros, by reordering typedefs, by having all includes in the same place - the header, by normalising carriage returns and indentation)
  • Corrected some silly mistakes (SMCWrapper.m includes its header, fixed a segfaulting typo that took me an hour to find)
  • stringRepresentationForBytes:...:toNSString now actually returns a value
  • Added methods to request raw hex values (e.g. 68 65 6c 6c 6f) from SMCVals
  • Added FAILURE_REPRESENTING_STRUCT in SMCState enum, to be used when the SMCVal couldn't be represented (through stringRepresentation... methods). (NOT YET IN USE)

And moved #includes to header
I SPENT ONE FUCKING HOUR TRYING TO UNDERSTAND WHY MY CODE SEGFAULTED.
Someone will be hung for that… 😡
* stringRawRepresentationForBytes:withSize:ofType:toNSString
* stringRawRepresentationForBytes:withSize:ofType:inBuffer
* stringRawRepresentationOfVal:inBuffer
* stringRawRepresentationOfVal:toNSString

Also added comments for readKey:intoVal
@perfaram
Copy link
Contributor Author

perfaram commented Apr 2, 2015

Bump ?

@perfaram
Copy link
Contributor Author

perfaram commented Apr 2, 2015

Take a look at the 'SMCWrapper' branch in http://github.com/perfaram/xline, this is where most improvements I made here come from.

Standardised argument for NSStrings passed ‘by reference’
Added -(BOOL) typeOfVal:(SMCVal_t)val intoString:(NSString **)str;
stringRep methods now properly return true/false values (made a mistake
yesterday)
@perfaram
Copy link
Contributor Author

perfaram commented Apr 2, 2015

Just asking, why are we passing NSStrings by reference anyways ? Couldn't we just return the NSString (which is usually easier for the programmer who uses SMCWrapper) and have the error passed by ref ?
Or have a @Property for errors, making the whole thing very much easier, especially knowing that we are going to have more detailed errors ?

Cleaner list of options, in which Error stands either for NSError** or SMCState_t * :

  1. -(BOOL) readKey:(NSString *)key intoString:(NSString **)str; (current)
  2. -(NSString*) readKey:(NSString *)key withError:(Error **)err; (passing byref)
  3. -(NSString*) readKey:(NSString *)key; (setting @Property in method)

I vote for the last one.

Was calling stringRep… instead of stringRawRep
@perfaram
Copy link
Contributor Author

perfaram commented May 3, 2015

After working a bit on other projects, I changed my mind. The current version seems good. BUT, to have more precision, we could also have a @property [...] error, so that it doesn't break with current version, but we can have additional data for debugging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant