Skip to content

tiny-express/native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,077 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Native Library

Build Status  Support Platform  License

Native Library provides low-level optimization and productivity for C/C++ application.

Beside standard library, we would like to have a greater customization with important goals:

  • Blazing fast performance with small footprint and low-level access with GAS & C
  • Powerful structured programming in C++ for scalability
  • Awesome syntactically enhancement with C++ customization
  • Java standard packages for productivity & maintainability
  • Reduce memory leak via automatic storage and object oriented instead of pointer
  • Support third-party services for business features

This project is also useful for new developers in practical programming.

Optimization

  • This library is originally developed in C/C++ so we can make classes go faster by optimizing in GAS for Linux amd64
  • C version of every function should be delivered first

Useful resources

Getting started

Prerequisites

  • CMake ~ 2.8
  • GCC ~ 4.8.1
  • Python ~ 2.7
  • OpenSSL
  • Zlib

Installation

OS X & Linux

$ git clone https://github.com/foodtiny/native.git
$ cmake . && make
$ sudo make install

Test Driven Development

Install & run mock server for third-party services

$ sudo apt-get install python-pip
$ sudo pip install -r misc/requirements.txt
$ make server

Open another terminal & debug with unit test

$ cmake . && make unit-test -j8

Usages (for Java/C++ Developers)

public class Main {
    public static void main(String[] args) {
        String text = "Native Library: ";
        byte[] bytes = { 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 };
        for (byte number : bytes) {
            text += (char) number;
        }
        System.out.println(text);
    }
}
#include <native/library.hpp>

int main() {
    String text = "Native Library: ";
    Array<byte> bytes = { 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 };
    for (byte number : bytes) {
        text += (char) number;
    }
    System::out::println(text);
    return 0;
}
$ g++ -c -o test.o ./test.cpp
$ gcc -static -o native test.o -L/usr/local/lib libnative_static.a -lstdc++
$ ./native

Mock Server

To test third parties we need to setup a server to mock http request from them. By running make server, it will serve in http://localhost:9999. You will see Hi guys! in there. Please keep this terminal running during your development.

$ make server

Memory Leak

Valgrind helps us in checking memory leak, you've just need to run

$ cmake . && make native_test && make leak

It will tell you issues relate to memory.

Unit Test with C-Unit

#define CTEST_MAIN
#define CTEST_SEGFAULT
#include <native/unit_test.h>

int main(int argc, const char *argv[]) {
   int result = ctest_main(argc, argv);
   return result;
}

TEST(YourTestSuite, YourTestCase) {
    ASSERT_STR("me", "you");
}

Contributors

  • This library must be followed Oracle Java 8 Documentation for standardization
  • Make sure that your commits must be passed before you create pull request
  • At least one contributor in this project reviews your commits (except you) before merging
  • Best practices guidelines in CONTRIBUTION.md

Copyright & license

Copyright © 2014-2016 Food Tiny. All rights reserved, except as follows. Code is released under the Apache 2.0 license. You may obtain a duplicate copy of the same license, titled CC-BY-SA-4.0, at http://creativecommons.org/licenses/by/4.0/. Terms and conditions set forth in the file LICENSE.docs.

Documentation

Differences

This library provides Java classes in C++ so its syntax is friendly for both programming languges but we still have some issues :

  • Namespace - Package
// Java
System.out.println("Java");
// C++
System::out::println("C++");
  • Array
// Java
byte[] byes = {};
// C++
Array<byte> bytes = {};
  • Interface
Comming soon
  • Runtime
Comming soon
  • Garbage Collection
Comming soon

Data Types

All data types are implemented and ready to use in C++ Application

  • char - Java.Lang.Character
  • byte - Java.Lang.Byte (equivalent with unsigned char)
  • string - Java.Lang.String (equivalent with char*, Java does not have data type string)
  • short - Java.Lang.Short
  • int - Java.Lang.Integer
  • long - Java.Lang.Long
  • float - Java.Lang.Float
  • double - Java.Lang.Double
  • boolean - Java.Lang.Boolean (equivalent with bool)
  • enum - Java.Lang.Enum

Java Standard Packages

All Java packages are in transformation so we can have a general look about road map

Java.Lang
  • Java.Lang.Appendable
  • Java.Lang.Autocloseable
  • Java.Lang.Boolean
  • Java.Lang.Byte
  • Java.Lang.Character
  • Java.Lang.CharSequence
  • Java.Lang.Cloneable
  • Java.Lang.Comparable
  • Java.Lang.Double
  • Java.Lang.Enum
  • Java.Lang.Error
  • Java.Lang.Exception
  • Java.Lang.Float
  • Java.Lang.Integer
  • Java.Lang.Iterable
  • Java.Lang.Long
  • Java.Lang.Math
  • Java.Lang.Number
  • Java.Lang.Object
  • Java.Lang.Process
  • Java.Lang.Readable
  • Java.Lang.Runnable
  • Java.Lang.Runtime
  • Java.Lang.Short
  • Java.Lang.String
  • Java.Lang.System
  • Java.Lang.Throwable
  • Java.Lang.Thread
Java.IO
  • Java.Lang.BufferedReader
  • Java.Lang.BufferedWriter
  • Java.Lang.CharArrayWriter
  • Java.Lang.Console
  • Java.Lang.FileDescriptor
  • Java.Lang.FileFilter
  • Java.Lang.FileWriter
  • Java.Lang.Flushable
  • Java.Lang.InputStream
  • Java.Lang.IOError
  • Java.Lang.IOException
  • Java.Lang.ObjectInput
  • Java.Lang.ObjectOutput
  • Java.Lang.OutputStream
  • Java.Lang.OutputStreamWriter
  • Java.Lang.PipedWriter
  • Java.Lang.PrintWriter
  • Java.Lang.Reader
  • Java.Lang.Serializable
  • Java.Lang.StreamTokenizer
  • Java.Lang.Writer
Java.Util
  • Java.Util.AbstractCollection
  • Java.Util.AbstractList
  • Java.Util.AbstractMap
  • Java.Util.AbstractSet
  • Java.Util.ArrayList
  • Java.Util.Arrays
  • Java.Util.BitSet
  • Java.Util.Base64
  • Java.Util.Calendar
  • Java.Util.Collection
  • Java.Util.Collections
  • Java.Util.Currency
  • Java.Util.Date
  • Java.Util.EnumMap
  • Java.Util.EnumSet
  • Java.Util.HashMap
  • Java.Util.HashSet
  • Java.Util.Iterator
  • Java.Util.LinkedListHashSet
  • Java.Util.LinkedList
  • Java.Util.List
  • Java.Util.Map
  • Java.Util.Observable
  • Java.Util.PriorityQueue
  • Java.Util.Queue
  • Java.Util.Random
  • Java.Util.Scanner
  • Java.Util.Set
  • Java.Util.SimpleTimeZone
  • Java.Util.Stack
  • Java.Util.Timer
  • Java.Util.TimerTask
  • Java.Util.TimeZone
  • Java.Util.TreeSet
  • Java.Util.UUID
  • Java.Util.Vector
Java.Security
  • Java.Security.Certificate
  • Java.Security.KeyFactory
  • Java.Security.KeyStore
  • Java.Security.MessageDigest
Java.Net
  • Java.Net.HttpURLConnection
  • Java.Net.URL
  • Java.Net.URLEncoder
  • Java.Net.URLDecoder

Additional features outside Java packages

  • Java.Lang.Array
  • Java.Vendor.AbstractVendor
  • Java.Vendor.ElasticSearch
  • Java.Vendor.Etcd
  • Java.Vendor.Firebase
  • Java.Vendor.SendGrid
  • Java.Vendor.Twilio

About

Native Library - Brings Java productivity into C++ program

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages