{"id":21320372,"url":"https://github.com/turkeymcmac/pig2","last_synced_at":"2025-07-27T21:36:12.556Z","repository":{"id":114506770,"uuid":"349277701","full_name":"TurkeyMcMac/pig2","owner":"TurkeyMcMac","description":"A pretty simple object system for C.","archived":false,"fork":false,"pushed_at":"2021-04-09T13:42:01.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T22:31:48.794Z","etag":null,"topics":["c","library","oop"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TurkeyMcMac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-19T02:31:33.000Z","updated_at":"2021-04-09T13:42:04.000Z","dependencies_parsed_at":"2023-05-17T11:45:10.390Z","dependency_job_id":null,"html_url":"https://github.com/TurkeyMcMac/pig2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TurkeyMcMac/pig2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Fpig2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Fpig2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Fpig2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Fpig2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TurkeyMcMac","download_url":"https://codeload.github.com/TurkeyMcMac/pig2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Fpig2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267428302,"owners_count":24085723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","library","oop"],"created_at":"2024-11-21T19:47:18.478Z","updated_at":"2025-07-27T21:36:12.537Z","avatar_url":"https://github.com/TurkeyMcMac.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pig2\n\nThis is the second version of a previous project of mine called \"pig\" (which is\ndefective.) pig2 lets you use runtime polymorphism in C (89 and onward) with a\nmanageable amount of boilerplate and few macros. pig2 is more of a concept than\na library, so you don't technically need to include `pig2.h` at all.\n\n## How It Works\n\nA pig2 object pointer is essentially a pointer to a function pointer. Some code\nusing an object pointer calls the function pointer, passing in another pointer\nused purely to identify a certain interface uniquely. The function returns yet\nanother pointer, which the caller casts to the type corresponding to the\ninterface ID they used. This type is a user-defined struct representing an\ninterface implementation and containing function pointers and stuff. The\nfunction pointers in the implementation are methods which the caller can call on\nthe original object for as long as they want.\n\nThe system is very simple. It doesn't require you to register anything at\nruntime, since the linker ensures all interfaces have unique IDs. It's also\npretty flexible. For example, you can implement inheritance, an example of which\nis in `examples/ui`.\n\nThere's some more documentation in `pig2.h`.\n\n## Examples\n\nRight now, the only example is in `examples/ui`. It's pretty sizeable, though.\nYou can read more about it in its root directory.\n\n## Limitations\n\nRight now, the getter functions have no context. This would make it hard to use\npig2 in scripting languages without generating code, for example. I could add a\nsecond getter parameter pointing to the object containing the getter, thus\nproviding some context. I could also have objects contain pointers to some list\ndata structure rather than a function, but this would be less flexible in some\nways. I don't know how it would compare speed-wise.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturkeymcmac%2Fpig2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturkeymcmac%2Fpig2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturkeymcmac%2Fpig2/lists"}