Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinmeiners/c-foundation
An implementation of an ANSI C class system similar to Apple's Core Foundation. (Retain/release, autorelease, mutable/immutable, etc)
https://github.com/justinmeiners/c-foundation
apple autorelease c cocoa foundation reference-counting
Last synced: 17 days ago
JSON representation
An implementation of an ANSI C class system similar to Apple's Core Foundation. (Retain/release, autorelease, mutable/immutable, etc)
- Host: GitHub
- URL: https://github.com/justinmeiners/c-foundation
- Owner: justinmeiners
- Created: 2013-05-10T15:58:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-07-11T19:23:27.000Z (over 7 years ago)
- Last Synced: 2023-04-05T16:26:25.117Z (over 1 year ago)
- Topics: apple, autorelease, c, cocoa, foundation, reference-counting
- Language: C
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# c-foundation
## About
This project provides a basic implementation of the C Object/Class system (think CGImageRef) found in Apple's Core Foundation and Core Graphics frameworks.
The object system used in these frameworks offers several key features that can be a big help in building a great C API.
* Memory management with reference counting.
* Full object encapsulation. (Clean headers!)
* Mutable and immutable objects.
* Polymorphic methods for core operations (retain, release, autorelease, copy, etc).## Example
A simplified string and array class are included to demonstrate the object system.
```C
// Create a mutable object
ISMutableStringRef mutable = ISStringCreateMutable("a mutable string", ISASCIIStringEncoding);
ISStringRef string = ISStringCreate("a static string", ISASCIIStringEncoding);// functions work on both mutable and nonmutable objects
int stringLength = ISStringLength(string);int length = ISStringLength(mutable);
// certain functions only work on mutable objects
ISStringReplaceCharacters(mutable, 's', 'q');// release
ISRelease(string);```
## Project License
MIT License
Copyright (c) 2017 Justin Meiners
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.