Coder Social home page Coder Social logo

manderby / nalib Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 5.0 61.5 MB

General purpose C sourcecode collection

Home Page: http://manderc.com/apps/nalib/index_en.php

License: The Unlicense

C 99.20% Objective-C 0.30% CMake 0.50%
memory-management quadtree octtree stack binary endianness buffer datetime deflate heap

nalib's Introduction

Quick Start:
------------

- Download whole package.
  git clone --recurse-submodules https://github.com/Manderby/NALib.git
  There is a submodule for testing which you only need if you are testing.
  
- To use NALib, there are two ways:
  1. Compile NALib as part of your own solution by simply dragging the whole
     code\NALib\src folder into your project.
  2. Use CMake to compile a static library of code/NALib
     Then, link to that library in your project.

- Use CMake to build any of the example projects in the code folder.



Description:
------------

NALib is a collection of source code written in the C programming language
which contain code like system-dependent macros, high-performance functions
and container structs, a small runtime system with memory pools and optional
reference counting, a GUI implementation for Mac and Windows and many helpful
comments.

Email: [email protected]
Follow on GitHub:
https://github.com/Manderby/NALib/discussions

- API is documented directly in the .h files.
- Some design principles can be read in the doc/documentation.txt file.
- NALib just needs the standard libraries.
- Compilation of the whole collection usually takes less than 5 seconds.
- The master branch contains the latest developments.
- Older release versions are available as tags.



Contribute & License:
---------------------
- Write Issues and take part in the discussions on GitHub.
- Write Emails to [email protected].

License: Public Domain



History:
--------

NALib originally started as a C++ helper code collection back in 2004 when I
was working for an electric engineering company and was enhanced with many
more helper snipplets by me over the following years during my research in a
media technology institute. It allowed me and others to quickly implement our
models, algorithms and data visualizations.

In 2009, I collected all the snipplets together and formed a first combined
version, known as MBLib. That version continued to be in use in the research
lab for another three years and allowed me to get started with projects when
I did found my own company Manderim in 2011.

There, I used MBLib in projects for the consumer market and for the industry
where it had been continuously verified in selling products. But as the
field I was working in often times required implementations which work
universally, I started to translate the whole library to plain C in 2013.
This new library was then called NALib.

NALib is short for "Not A Library". This name was chosen with the intention of
it to be primarily used as source code, not as compiled libraries. The library
was implemented so that it would build very fast but universally on multiple
systems. With that, I had to spend less time on library compatibility issues.

NALib was open to the public since the first version. After about 2 years,
all crucial functionality of MBLib was translated to NALib. Therefore I
discontinued development of MBLib and instead started to use NALib for
all projects.

Now, after some more years, the code collection did grow by quite a fair
amount of code and functionality. Unfortunately, I had to close down my
company in 2019, but still to this day, I am using NALib for my private
projects and try to advance it whenever time fits. It currently uses C99
as well as some elements of C11 combined with a modern coding style which
- hopefully - helps people value the C programming language as much as I do.

nalib's People

Contributors

herrhotzenplotz avatar manderby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nalib's Issues

Combine NAPool with NAStack

Add functionality to NAStack
Add possibility to explicitely store pointers.
Add possibility to define if pool initially is filled or empty

Solve Cocoa AppDelegate problem

After the postStartup, the NSApplication sets its application delegate in naStartApplication to the default. Desired would be to the delegate class of NALib to capture more notifications. This interfered with some other mechanisms though (don't quite remember now).

Please have a look at the following comments removed from naStartApplication to get back in the mood:

  //[NSApp setDelegate:(NA_COCOA_BRIDGE id)naGetUIElementNativePtr(app)];
  
//  SEL selector = @selector(doSomethingWithObject:afterDelay:);
//  IMP newImp = (IMP)swizzledDoSometingWithObjectAfterDelay;
//  Method method = class_getClassMethod([MyClass class], selector);
//  const char * encoding = method_getTypeEncoding(method);
//  class_replaceMethod([MyClass class], selector, newIMP, encoding);

NAImageButton image storage

Having a button without an image is certainly useful during initialization.
At the same time, review the isImage flag if there is a better solution.
Have a look at #32.

Do at least parts of Objective-C with C

There is the possiblilty to do things with plain C, see the code sniplet below which is an old comment (completely out of context, but this is just a hint where to start looking).

Idea is to move at least the NAPreferences out of the GUI code.

  // The ((id (*)(id, SEL)) part is a cast of the objc_msgSend function which
  // is requires since a later version of Objective-C
//  ( (id (*)(id, SEL)) objc_msgSend)(objc_getClass("NSApplication"), sel_registerName("sharedApplication"));

Develop UI button size default

Make Mac and Win equal.

These are some comments removed from the code. They might help:

  // OptionButton: NSBezelStyleShadowlessSquare
  // NSBezelStyleRegularSquare : 5 5 5 5
  // NSBezelStyleShadowlessSquare : 3 3 3 3
  // NSBezelStyleSmallSquare : 2 1 2 1

// Push (Text only) (24px height fixed)
// Option (Text / Image) (3px padding on all sides)
// Borderless (Image only) (0px padding on all sides)

Add detection for pointers deallocated with naDelete when they get deleted twice

Deallocation using naRelease has this built in because of the NARefCount which is checked upon calling naRelease or naRetain. But naDelete does not have the storage capacity to do that.

Would need an additional dummy-space similar to the refcount but which is only available whe NA_DEBUG is 1.

When doing this, think about adding this functionality to all structs which use naClearXXX. Maybe do something with NAPtr

Fix "source has no cache" error

When opening a file with an NABuffer, the following error is outputted:

Error in na_GetBufferSourceCache: source has no cache

Write GUI playground

Enhance the GUI Hello World application with a playground window containing all possible GUI elements and behaviours.

Speed up na_GetUINALibEquivalent

na_GetUINALibEquivalent is currently done using a list traversal which might be slow for very big UIs. It had beed tried to be done using the GWLP_USERDATA of HWND on windows and with the tag of NSView on macOS but that proved to be a maintenance catastrophy.

Optimal solution would be a a hash map. Maybe find something else.

Remove the need of naCacheBufferRange in naWriteBufferToData

Some sort of caching all of a buffer is required but it should not happen with naCacheBufferRange. The NABuffer should be self-updating.

Also have a look at other occurences in naWriteBufferBuffer, naGetStringUTF8Pointer, naNewStringWithBasenameOfPath, na_AllocPNGChunkFromBuffer

Note to Manderby: The issue can be reproduced by running Karo Graph without CACHING_ALWAYS and opening a file by double clicking.

Break benchmark when using too much memory

When running benchmarks (for example NAStack Push), a lot of memory is required. This may exceed the capabilities, especially on 32 bit systems. Find a suitable solution to capture this or break early.

Cleanup crash testing

During development, lots of code was necessary to create the arguments of the procedure call in na_ExecuteCrashProcess.
Try to store the expressions in the NATestData as NAString and try to move sysctl.h and Tlhelp32.h stuff into a separate module.

Distinguish between left and right modifier keys

Very low priority task. Following removed comments might help:

//    [event modifierFlags]; NSEventModifierFlagCapsLock;
//    let isLeftShift = event.modifierFlags.rawValue & UInt(NX_DEVICELSHIFTKEYMASK) != 0
//    let isRightShift = event.modifierFlags.rawValue & UInt(NX_DEVICERSHIFTKEYMASK) != 0

Note that distinguishing might not be possible depending on the system.

NAOpenGLSpace redraw slows down with time

See HelloWorldGUI, watch the dot for some seconds, the framerate drops constantly. Potentially due to SetTimer and KillTimer which gets calld by naCallApplicationFunctionInSeconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.