From 320582a55c9ba1f91d70a3f120413e305fda2962 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 3 Sep 2018 18:29:00 +0200 Subject: [PATCH] cleanup Nim's examples/ directory; closes #7725 --- examples/c++iface/irrlichtex.nim | 114 - examples/cgi/cgi_server.py | 11 - examples/cgi/cgi_stacktrace.nim | 5 - examples/cgi/example.nim | 7 - examples/cgiex.nim | 12 - examples/cross_calculator/.gitignore | 12 - .../android/AndroidManifest.xml | 18 - examples/cross_calculator/android/build.xml | 92 - .../cross_calculator/android/custom_rules.xml | 17 - .../cross_calculator/android/jni/Android.mk | 32 - .../android/jni/backend-jni.c | 42 - .../android/project.properties | 14 - examples/cross_calculator/android/readme.txt | 24 - .../android/res/layout/cross_calculator.xml | 72 - .../android/res/values/strings.xml | 4 - .../android/scripts/jnibuild.sh | 22 - .../android/scripts/nimbuild.sh | 34 - .../cross_calculator/android/scripts/tags.sh | 13 - .../crosscalculator/CrossCalculator.java | 80 - .../project.pbxproj | 337 -- examples/cross_calculator/ios/readme.txt | 13 - .../plist/cross-calculator-Info.plist | 30 - .../ios/resources/ui/NRViewController.xib | 479 -- examples/cross_calculator/ios/scripts/tags.sh | 13 - .../ios/scripts/xcode_prebuild.sh | 35 - .../cross_calculator/ios/src/AppDelegate.h | 7 - .../cross_calculator/ios/src/AppDelegate.m | 39 - .../ios/src/NRViewController.h | 11 - .../ios/src/NRViewController.m | 210 - .../ios/src/cross-calculator-Prefix.pch | 10 - examples/cross_calculator/ios/src/main.m | 13 - examples/cross_calculator/lazarus/nimlaz.lpi | 140 - examples/cross_calculator/lazarus/nimlaz.lpr | 21 - examples/cross_calculator/lazarus/nimlaz.lrs | 5222 ----------------- examples/cross_calculator/lazarus/nimlaz.rc | 6 - examples/cross_calculator/lazarus/readme.txt | 8 - examples/cross_calculator/lazarus/unit1.lfm | 46 - examples/cross_calculator/lazarus/unit1.pas | 58 - .../cross_calculator/nim_backend/backend.nim | 5 - .../cross_calculator/nim_commandline/nim.cfg | 4 - .../nim_commandline/nimcalculator.nim | 109 - .../nim_commandline/readme.txt | 10 - examples/cross_calculator/readme.txt | 13 - examples/cross_todo/nim_backend/backend.nim | 195 - examples/cross_todo/nim_backend/readme.txt | 14 - .../cross_todo/nim_backend/testbackend.nim | 74 - examples/cross_todo/nim_commandline/nim.cfg | 4 - .../cross_todo/nim_commandline/nimtodo.nim | 297 - .../cross_todo/nim_commandline/readme.txt | 19 - examples/cross_todo/readme.txt | 5 - examples/debugging.nim | 17 - ...val2.nim => extract_keyval_pairs_pegs.nim} | 0 ...keyval.nim => extract_keyval_pairs_re.nim} | 0 examples/filterex.nim | 23 - examples/fizzbuzz.nim | 14 - examples/htmlrefs.nim | 57 - examples/htmltitle.nim | 36 - examples/httpserver2.nim | 247 - examples/maximum.nim | 2 +- examples/objciface/gnustepex.nim | 40 - examples/parsecfgex.nim | 25 - examples/readme.txt | 2 +- examples/ssl/extradata.nim | 26 - examples/ssl/pskclient.nim | 16 - examples/ssl/pskserver.nim | 20 - examples/transff.nim | 8 - examples/unix_socket/client.nim | 6 - examples/unix_socket/server.nim | 14 - 68 files changed, 2 insertions(+), 8623 deletions(-) delete mode 100644 examples/c++iface/irrlichtex.nim delete mode 100644 examples/cgi/cgi_server.py delete mode 100644 examples/cgi/cgi_stacktrace.nim delete mode 100644 examples/cgi/example.nim delete mode 100644 examples/cgiex.nim delete mode 100644 examples/cross_calculator/.gitignore delete mode 100644 examples/cross_calculator/android/AndroidManifest.xml delete mode 100644 examples/cross_calculator/android/build.xml delete mode 100644 examples/cross_calculator/android/custom_rules.xml delete mode 100644 examples/cross_calculator/android/jni/Android.mk delete mode 100644 examples/cross_calculator/android/jni/backend-jni.c delete mode 100644 examples/cross_calculator/android/project.properties delete mode 100644 examples/cross_calculator/android/readme.txt delete mode 100644 examples/cross_calculator/android/res/layout/cross_calculator.xml delete mode 100644 examples/cross_calculator/android/res/values/strings.xml delete mode 100644 examples/cross_calculator/android/scripts/jnibuild.sh delete mode 100644 examples/cross_calculator/android/scripts/nimbuild.sh delete mode 100644 examples/cross_calculator/android/scripts/tags.sh delete mode 100644 examples/cross_calculator/android/src/com/github/nimrod/crosscalculator/CrossCalculator.java delete mode 100644 examples/cross_calculator/ios/cross-calculator.xcodeproj/project.pbxproj delete mode 100644 examples/cross_calculator/ios/readme.txt delete mode 100644 examples/cross_calculator/ios/resources/plist/cross-calculator-Info.plist delete mode 100644 examples/cross_calculator/ios/resources/ui/NRViewController.xib delete mode 100644 examples/cross_calculator/ios/scripts/tags.sh delete mode 100644 examples/cross_calculator/ios/scripts/xcode_prebuild.sh delete mode 100644 examples/cross_calculator/ios/src/AppDelegate.h delete mode 100644 examples/cross_calculator/ios/src/AppDelegate.m delete mode 100644 examples/cross_calculator/ios/src/NRViewController.h delete mode 100644 examples/cross_calculator/ios/src/NRViewController.m delete mode 100644 examples/cross_calculator/ios/src/cross-calculator-Prefix.pch delete mode 100644 examples/cross_calculator/ios/src/main.m delete mode 100644 examples/cross_calculator/lazarus/nimlaz.lpi delete mode 100644 examples/cross_calculator/lazarus/nimlaz.lpr delete mode 100644 examples/cross_calculator/lazarus/nimlaz.lrs delete mode 100644 examples/cross_calculator/lazarus/nimlaz.rc delete mode 100644 examples/cross_calculator/lazarus/readme.txt delete mode 100644 examples/cross_calculator/lazarus/unit1.lfm delete mode 100644 examples/cross_calculator/lazarus/unit1.pas delete mode 100644 examples/cross_calculator/nim_backend/backend.nim delete mode 100644 examples/cross_calculator/nim_commandline/nim.cfg delete mode 100644 examples/cross_calculator/nim_commandline/nimcalculator.nim delete mode 100644 examples/cross_calculator/nim_commandline/readme.txt delete mode 100644 examples/cross_calculator/readme.txt delete mode 100644 examples/cross_todo/nim_backend/backend.nim delete mode 100644 examples/cross_todo/nim_backend/readme.txt delete mode 100644 examples/cross_todo/nim_backend/testbackend.nim delete mode 100644 examples/cross_todo/nim_commandline/nim.cfg delete mode 100644 examples/cross_todo/nim_commandline/nimtodo.nim delete mode 100644 examples/cross_todo/nim_commandline/readme.txt delete mode 100644 examples/cross_todo/readme.txt delete mode 100644 examples/debugging.nim rename examples/{keyval2.nim => extract_keyval_pairs_pegs.nim} (100%) rename examples/{keyval.nim => extract_keyval_pairs_re.nim} (100%) delete mode 100644 examples/filterex.nim delete mode 100644 examples/fizzbuzz.nim delete mode 100644 examples/htmlrefs.nim delete mode 100644 examples/htmltitle.nim delete mode 100644 examples/httpserver2.nim delete mode 100644 examples/objciface/gnustepex.nim delete mode 100644 examples/parsecfgex.nim delete mode 100644 examples/ssl/extradata.nim delete mode 100644 examples/ssl/pskclient.nim delete mode 100644 examples/ssl/pskserver.nim delete mode 100644 examples/transff.nim delete mode 100644 examples/unix_socket/client.nim delete mode 100644 examples/unix_socket/server.nim diff --git a/examples/c++iface/irrlichtex.nim b/examples/c++iface/irrlichtex.nim deleted file mode 100644 index 373a78ce7..000000000 --- a/examples/c++iface/irrlichtex.nim +++ /dev/null @@ -1,114 +0,0 @@ -# Horrible example of how to interface with a C++ engine ... ;-) - -{.link: "/usr/lib/libIrrlicht.so".} - -{.emit: """ -using namespace irr; -using namespace core; -using namespace scene; -using namespace video; -using namespace io; -using namespace gui; -""".} - -const - irr = "" - -type - TDimension2d {.final, header: irr, importc: "dimension2d".} = object - Tvector3df {.final, header: irr, importc: "vector3df".} = object - TColor {.final, header: irr, importc: "SColor".} = object - - TIrrlichtDevice {.final, header: irr, importc: "IrrlichtDevice".} = object - TIVideoDriver {.final, header: irr, importc: "IVideoDriver".} = object - TISceneManager {.final, header: irr, importc: "ISceneManager".} = object - TIGUIEnvironment {.final, header: irr, importc: "IGUIEnvironment".} = object - TIAnimatedMesh {.final, header: irr, importc: "IAnimatedMesh".} = object - TIAnimatedMeshSceneNode {.final, header: irr, - importc: "IAnimatedMeshSceneNode".} = object - TITexture {.final, header: irr, importc: "ITexture".} = object - - PIrrlichtDevice = ptr TIrrlichtDevice - PIVideoDriver = ptr TIVideoDriver - PISceneManager = ptr TISceneManager - PIGUIEnvironment = ptr TIGUIEnvironment - PIAnimatedMesh = ptr TIAnimatedMesh - PIAnimatedMeshSceneNode = ptr TIAnimatedMeshSceneNode - PITexture = ptr TITexture - -proc dimension2d(x, y: cint): TDimension2d {. - header: irr, importc: "dimension2d".} -proc vector3df(x,y,z: cint): Tvector3df {. - header: irr, importc: "vector3df".} -proc SColor(r,g,b,a: cint): TColor {. - header: irr, importc: "SColor".} - -proc createDevice(): PIrrlichtDevice {. - header: irr, importc: "createDevice".} -proc run(device: PIrrlichtDevice): bool {. - header: irr, importcpp: "run".} - -proc getVideoDriver(dev: PIrrlichtDevice): PIVideoDriver {. - header: irr, importcpp: "getVideoDriver".} -proc getSceneManager(dev: PIrrlichtDevice): PISceneManager {. - header: irr, importcpp: "getSceneManager".} -proc getGUIEnvironment(dev: PIrrlichtDevice): PIGUIEnvironment {. - header: irr, importcpp: "getGUIEnvironment".} - -proc getMesh(smgr: PISceneManager, path: cstring): PIAnimatedMesh {. - header: irr, importcpp: "getMesh".} - -proc drawAll(smgr: PISceneManager) {. - header: irr, importcpp: "drawAll".} -proc drawAll(guienv: PIGUIEnvironment) {. - header: irr, importcpp: "drawAll".} - -proc drop(dev: PIrrlichtDevice) {. - header: irr, importcpp: "drop".} - -proc getTexture(driver: PIVideoDriver, path: cstring): PITexture {. - header: irr, importcpp: "getTexture".} -proc endScene(driver: PIVideoDriver) {. - header: irr, importcpp: "endScene".} -proc beginScene(driver: PIVideoDriver, a, b: bool, c: TColor) {. - header: irr, importcpp: "beginScene".} - -proc addAnimatedMeshSceneNode( - smgr: PISceneManager, mesh: PIAnimatedMesh): PIAnimatedMeshSceneNode {. - header: irr, importcpp: "addAnimatedMeshSceneNode".} - -proc setMaterialTexture(n: PIAnimatedMeshSceneNode, x: cint, t: PITexture) {. - header: irr, importcpp: "setMaterialTexture".} -proc addCameraSceneNode(smgr: PISceneManager, x: cint, a, b: TVector3df) {. - header: irr, importcpp: "addCameraSceneNode".} - - -var device = createDevice() -if device == nil: quit "device is nil" - -var driver = device.getVideoDriver() -var smgr = device.getSceneManager() -var guienv = device.getGUIEnvironment() - -var mesh = smgr.getMesh("/home/andreas/download/irrlicht-1.7.2/media/sydney.md2") -if mesh == nil: - device.drop() - quit "no mesh!" - -var node = smgr.addAnimatedMeshSceneNode(mesh) - -if node != nil: - #node->setMaterialFlag(EMF_LIGHTING, false) - #node->setMD2Animation(scene::EMAT_STAND) - node.setMaterialTexture(0, - driver.getTexture( - "/home/andreas/download/irrlicht-1.7.2/media/media/sydney.bmp")) - -smgr.addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)) -while device.run(): - driver.beginScene(true, true, SColor(255,100,101,140)) - smgr.drawAll() - guienv.drawAll() - driver.endScene() -device.drop() - diff --git a/examples/cgi/cgi_server.py b/examples/cgi/cgi_server.py deleted file mode 100644 index 1907515e8..000000000 --- a/examples/cgi/cgi_server.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python -import BaseHTTPServer -import CGIHTTPServer - -server = BaseHTTPServer.HTTPServer -handler = CGIHTTPServer.CGIHTTPRequestHandler -server_address = ('localhost', 8008) -handler.cgi_directories = ['/'] - -httpd = server(server_address, handler) -httpd.serve_forever() diff --git a/examples/cgi/cgi_stacktrace.nim b/examples/cgi/cgi_stacktrace.nim deleted file mode 100644 index e9f2f567c..000000000 --- a/examples/cgi/cgi_stacktrace.nim +++ /dev/null @@ -1,5 +0,0 @@ -import cgi -cgi.setStackTraceStdout() - -var a: string = nil -a.add "foobar" diff --git a/examples/cgi/example.nim b/examples/cgi/example.nim deleted file mode 100644 index 761197cdb..000000000 --- a/examples/cgi/example.nim +++ /dev/null @@ -1,7 +0,0 @@ -import cgi - -write(stdout, "Content-type: text/html\n\n") -write(stdout, "\n") -write(stdout, "Test\n") -write(stdout, "Hello!") -writeLine(stdout, "") diff --git a/examples/cgiex.nim b/examples/cgiex.nim deleted file mode 100644 index fb55a731a..000000000 --- a/examples/cgiex.nim +++ /dev/null @@ -1,12 +0,0 @@ -# Test/show CGI module -import strtabs, cgi - -var myData = readData() -validateData(myData, "name", "password") -writeContentType() - -write(stdout, "\n") -write(stdout, "Test\n") -writeLine(stdout, "name: " & myData["name"]) -writeLine(stdout, "password: " & myData["password"]) -writeLine(stdout, "") diff --git a/examples/cross_calculator/.gitignore b/examples/cross_calculator/.gitignore deleted file mode 100644 index e521bf338..000000000 --- a/examples/cross_calculator/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# Android specific absolute paths. -android/bin/ -android/gen/ -android/jni/backend-jni.h -android/libs/ -android/local.properties -android/obj/ -android/tags -# iOS specific absolute paths -ios/resources/ui/*.m -ios/tags - diff --git a/examples/cross_calculator/android/AndroidManifest.xml b/examples/cross_calculator/android/AndroidManifest.xml deleted file mode 100644 index 05b96fb50..000000000 --- a/examples/cross_calculator/android/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/cross_calculator/android/build.xml b/examples/cross_calculator/android/build.xml deleted file mode 100644 index d7c88432a..000000000 --- a/examples/cross_calculator/android/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cross_calculator/android/custom_rules.xml b/examples/cross_calculator/android/custom_rules.xml deleted file mode 100644 index 91783a50e..000000000 --- a/examples/cross_calculator/android/custom_rules.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/examples/cross_calculator/android/jni/Android.mk b/examples/cross_calculator/android/jni/Android.mk deleted file mode 100644 index c1a0feac3..000000000 --- a/examples/cross_calculator/android/jni/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := nimrod -LOCAL_SRC_FILES := nimcache/backend.c nimcache/system.c -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/nimcache - -include $(BUILD_STATIC_LIBRARY) - -include $(CLEAR_VARS) - -LOCAL_MODULE := backend-jni -LOCAL_SRC_FILES := backend-jni.c -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -LOCAL_STATIC_LIBRARIES := nimrod - -include $(BUILD_SHARED_LIBRARY) diff --git a/examples/cross_calculator/android/jni/backend-jni.c b/examples/cross_calculator/android/jni/backend-jni.c deleted file mode 100644 index 3d65458ec..000000000 --- a/examples/cross_calculator/android/jni/backend-jni.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#include -#include -#include "backend-jni.h" -#include "backend.h" - -#define TAG "backend-jni.c" - -jint JNICALL Java_com_github_nimrod_crosscalculator_CrossCalculator_myAdd - (JNIEnv *env, jobject thiz, jint a, jint b) -{ - char buf[256]; - const jint ret = myAdd(a, b); - // Using logging from inside the native bridge to log-debug. - sprintf(buf, "a %d + b %d = ret %d", a, b, ret); - __android_log_write(ANDROID_LOG_DEBUG, TAG, buf); - return ret; -} - -void JNICALL Java_com_github_nimrod_crosscalculator_CrossCalculator_initNimMain - (JNIEnv *env, jclass thiz) -{ - NimMain(); - __android_log_write(ANDROID_LOG_DEBUG, TAG, "Nimrod initialised"); -} - -// vim:tabstop=2 shiftwidth=2 syntax=c diff --git a/examples/cross_calculator/android/project.properties b/examples/cross_calculator/android/project.properties deleted file mode 100644 index 9fb894d9b..000000000 --- a/examples/cross_calculator/android/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-3 diff --git a/examples/cross_calculator/android/readme.txt b/examples/cross_calculator/android/readme.txt deleted file mode 100644 index 96bd403ca..000000000 --- a/examples/cross_calculator/android/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -In this directory you will find the Android platform cross-calculator sample. - -Due to the nature of Android being java and Nim generating C code, the build -process is slightly more complex because jni code has to be written to bridge -both languages. In a distant future it may be possible for Nim to generate -the whole jni bridge, but for the moment this is manual work. - -For the jni bridge to work first the java code is compiled with the Nim code -just declared as a native method which will be resolved at runtime. The scripts -nimbuild.sh and jnibuild.sh are in charge of building the Nim code and -generating the jni bridge from the java code respectively. Finally, the -ndk-build command from the android ndk tools has to be run to build the binary -library which will be installed along the final apk. - -All these steps are wrapped in the ant build script through the customization -of the -post-compile rule. If you have the android ndk tools installed and you -modify scripts/nimbuild.sh to point to the directory where you have Nim -installed on your system, you can simply run "ant debug" to build everything. - -Once the apk is built you can install it on your device or emulator with the -command "adb install bin/CrossCalculator-debug.apk". - -This example runs against the Android level 3 API, meaning devices from -Android 1.5 and above should be able to run the generated binary. diff --git a/examples/cross_calculator/android/res/layout/cross_calculator.xml b/examples/cross_calculator/android/res/layout/cross_calculator.xml deleted file mode 100644 index 11531334c..000000000 --- a/examples/cross_calculator/android/res/layout/cross_calculator.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - -