├── Thxgen
├── Resource Files
│ ├── TestInfQ.cpp
│ ├── Pomp.fbp
│ ├── TestInfQ.fbp
│ └── GithubSynchronization.fbp
├── Thxgen.vcxproj.user
└── Thxgen.vcxproj.filters
├── TestSubnets
├── TestSubnets.def
├── TestSubnets.vcxproj.user
├── LuaScripts
│ ├── drop.lua
│ ├── recvr.lua
│ ├── concat.lua
│ ├── repl.lua
│ ├── gen.lua
│ └── LuaScripts.vcxproj.filters
├── Subnets
│ └── InfQueue.cpp
└── Helper Code
│ └── dfs.cpp
├── TestData
└── POMPIERS.FIL
├── CppFBPCore
├── Headers
│ ├── cppfbp.h
│ ├── stdafx.h
│ ├── fbp.h
│ ├── thxanch.h
│ ├── targetver.h
│ ├── compsvcs.h
│ └── thxdef.h
├── CppFBPCore.vcxproj.user
├── stdafx.cpp
├── Services
│ ├── thzgsize.cpp
│ ├── CppSub.cpp
│ ├── CppFBP.cpp
│ ├── thzdrop.cpp
│ ├── thzdfpt.cpp
│ ├── thzpush.cpp
│ ├── thzelct.cpp
│ ├── thzcrep.cpp
│ ├── thzpop.cpp
│ ├── thzclos.cpp
│ ├── thxgatrs.cpp
│ ├── thziclos.cpp
│ └── thz.cpp
└── CppFBPCore.vcxproj.filters
├── TestNetworks
├── TryLua
│ ├── TryLua.vcxproj.user
│ ├── stdafx.cpp
│ ├── targetver.h
│ ├── stdafx.h
│ ├── trylua.fbp
│ ├── TryLua.vcxproj.filters
│ ├── TryLua.cpp
│ └── Helper Code
│ │ └── dfs.cpp
├── CopyFile
│ ├── CopyFile.vcxproj.user
│ ├── CopyFile.vcxproj.filters
│ ├── stdafx.cpp
│ └── CopyFile.cpp
├── DeadlockTest
│ ├── DeadlockTest.vcxproj.user
│ ├── stdafx.cpp
│ └── DeadlockTest.cpp
├── TimingTest1
│ ├── TimingTest1.vcxproj.user
│ ├── stdafx.cpp
│ ├── TimingTest1.vcxproj.filters
│ └── TimingTest1.cpp
├── TimingTest2
│ ├── TimingTest2.vcxproj.user
│ ├── stdafx.cpp
│ ├── TimingTest2.vcxproj.filters
│ └── TimingTest2.cpp
├── TimingTest3
│ ├── TimingTest3.vcxproj.user
│ ├── stdafx.cpp
│ ├── TimingTest3.vcxproj.filters
│ └── TimingTest3.cpp
├── TryDynSubNet
│ ├── TryDynSubNet.vcxproj.user
│ ├── stdafx.cpp
│ ├── targetver.h
│ ├── stdafx.h
│ ├── TryDynSubNet.vcxproj.filters
│ ├── TryDynSubNet.cpp
│ └── Helper Code
│ │ └── dfs.cpp
└── TryStatSubNet
│ ├── TryStatSubNet.vcxproj.user
│ ├── stdafx.cpp
│ ├── targetver.h
│ ├── stdafx.h
│ ├── TryStatSubNet.vcxproj.filters
│ ├── TryStatSubNet.cpp
│ └── Helper Code
│ └── dfs.cpp
├── DynNetworks
├── TryInfQDyn
│ ├── TryInfQDyn.vcxproj.user
│ ├── TryInfQ.fbp
│ ├── TryInfQDyn.cpp
│ └── TryInfQDyn.vcxproj.filters
├── TryLuaDyn
│ ├── TryLuaDyn.vcxproj.user
│ ├── TryLua.fbp
│ ├── TryLuaDyn.cpp
│ └── TryLuaDyn.vcxproj.filters
└── CopyFileDyn
│ ├── CopyFileDyn.vcxproj.user
│ ├── CopyFile.fbp
│ ├── CopyFileDyn.cpp
│ └── CopyFileDyn.vcxproj.filters
├── SolutionSettings
├── SolutionSettings.vcxproj.user
├── Release
│ └── SolutionSettings.tlog
│ │ └── SolutionSettings.lastbuildstate
├── SolutionSettings.vcxproj.filters
├── UserMacros.props
└── SolutionSettings.vcxproj
├── CppFBPLua
├── CppFBPLua.vcxproj.user
├── src
│ ├── lua.hpp
│ ├── lapi.h
│ ├── lundump.h
│ ├── lprefix.h
│ ├── lualib.h
│ ├── ldebug.h
│ ├── lstring.h
│ ├── lzio.c
│ ├── lzio.h
│ ├── lfunc.h
│ ├── linit.c
│ ├── ltm.h
│ ├── ltable.h
│ ├── lctype.h
│ ├── ldo.h
│ ├── lctype.c
│ ├── llex.h
│ ├── lmem.h
│ ├── lmem.c
│ ├── lcode.h
│ ├── lparser.h
│ ├── lopcodes.c
│ ├── lvm.h
│ ├── lfunc.c
│ ├── lcorolib.c
│ ├── ltm.c
│ └── lgc.h
├── targetver.h
└── stdafx.h
├── renovate.json
├── CppFBPComponents
├── CppFBPComponents.vcxproj.user
├── Components
│ ├── ThPsThru.cpp
│ ├── ThDrop.cpp
│ ├── ThCopy.cpp
│ ├── ThRevers.cpp
│ ├── ThConcatStr.cpp
│ ├── ThCopyNL.cpp
│ ├── ThReplStr.cpp
│ ├── ThGenIps.cpp
│ ├── SubOut.cpp
│ ├── SubIn.cpp
│ ├── ThFileWt.cpp
│ ├── ThFileRd.cpp
│ └── ThSort.cpp
└── Helper Code
│ └── dfs.cpp
├── LuaScripts
├── drop.lua
├── recvr.lua
├── concat.lua
├── repl.lua
├── gen.lua
└── LuaScripts.vcxproj.filters
├── .gitignore
└── .gitattributes
/Thxgen/Resource Files/TestInfQ.cpp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/TestSubnets/TestSubnets.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | InfQueue
--------------------------------------------------------------------------------
/TestData/POMPIERS.FIL:
--------------------------------------------------------------------------------
1 | 50000 Jean
2 | 20000 Jacques
3 | 120000 Pierre
4 | 90000 Yvon
5 | 150000 Patrice
6 | 70000 Gaston
--------------------------------------------------------------------------------
/CppFBPCore/Headers/cppfbp.h:
--------------------------------------------------------------------------------
1 |
2 | //#ifndef THXANCH
3 | //#define THXANCH
4 | #include "thxanch.h"
5 | //#endif
6 | #define GEN_BOOST
7 | #include "fbp.h"
8 |
9 |
--------------------------------------------------------------------------------
/TestNetworks/TryLua/TryLua.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/DynNetworks/TryInfQDyn/TryInfQDyn.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/DynNetworks/TryLuaDyn/TryLuaDyn.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SolutionSettings/SolutionSettings.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TestNetworks/CopyFile/CopyFile.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/DynNetworks/CopyFileDyn/CopyFileDyn.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TestNetworks/DeadlockTest/DeadlockTest.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest1/TimingTest1.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest2/TimingTest2.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest3/TimingTest3.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/TryDynSubNet.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/CppFBPLua/CppFBPLua.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DynNetworks/CopyFileDyn/CopyFile.fbp:
--------------------------------------------------------------------------------
1 | Read(ThFileRd)? OUT -> IN Copy(ThCopyNL)? OUT -> IN Show(ThFileWt)?,
2 | '..\\..\\TestData\\POMPIERS.FIL' -> OPT Read,
3 | '..\\..\\TestData\\output.fil' -> OPT Show;
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/TryStatSubNet.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lua.hpp:
--------------------------------------------------------------------------------
1 | // lua.hpp
2 | // Lua header files for C++
3 | // <> not supplied automatically because Lua also compiles as C++
4 |
5 | extern "C" {
6 | #include "lua.h"
7 | #include "lualib.h"
8 | #include "lauxlib.h"
9 | }
10 |
--------------------------------------------------------------------------------
/CppFBPCore/CppFBPCore.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
--------------------------------------------------------------------------------
/TestSubnets/TestSubnets.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
--------------------------------------------------------------------------------
/TestNetworks/CopyFile/CopyFile.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "config:base"
4 | ],
5 | "automerge": true,
6 | "major": {
7 | "automerge": false
8 | },
9 | "packageRules": [{
10 | "packageNames": ["boost"],
11 | "allowedVersions": "<=1.75.0"
12 | }]
13 | }
14 |
--------------------------------------------------------------------------------
/CppFBPComponents/CppFBPComponents.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
--------------------------------------------------------------------------------
/SolutionSettings/Release/SolutionSettings.tlog/SolutionSettings.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
2 | Release|Win32|C:\Users\john\Documents\GitHub\cppfbp\|
3 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 |
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/LuaScripts/drop.lua:
--------------------------------------------------------------------------------
1 |
2 | --looper version
3 |
4 | count = 0
5 | value, IPaddr, size, type = dfsrecv("IN[0]")
6 | while value == 0 do
7 | --myprint(IPaddr)
8 | count = count + 1
9 | value = dfsdrop(IPaddr)
10 | value, IPaddr, size, type = dfsrecv("IN")
11 | end
12 | print(count)
13 | return 0
14 |
--------------------------------------------------------------------------------
/TestSubnets/LuaScripts/drop.lua:
--------------------------------------------------------------------------------
1 |
2 | --looper version
3 |
4 | count = 0
5 | value, IPaddr, size, type = dfsrecv("IN[0]")
6 | while value == 0 do
7 | --myprint(IPaddr)
8 | count = count + 1
9 | value = dfsdrop(IPaddr)
10 | value, IPaddr, size, type = dfsrecv("IN")
11 | end
12 | print(count)
13 | return 0
14 |
--------------------------------------------------------------------------------
/CppFBPCore/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // ....pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/LuaScripts/recvr.lua:
--------------------------------------------------------------------------------
1 | -- Experimental non-looper
2 |
3 | --count = 0
4 | value, IPaddr, size, type = dfsrecv("IN[0]")
5 | --while value == 0 do
6 | --myprint(IPaddr)
7 | -- count = count + 1
8 | value = dfsdrop(IPaddr)
9 | -- value, IPaddr, size, type = dfsrecv("IN")
10 | --end
11 | --print(count)
12 | return 0
13 |
--------------------------------------------------------------------------------
/TestNetworks/TryLua/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // TryLua.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/TestNetworks/DeadlockTest/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // Thxgen.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest2/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // Thxgen.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest3/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // Thxgen.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/TestSubnets/LuaScripts/recvr.lua:
--------------------------------------------------------------------------------
1 | -- Experimental non-looper
2 |
3 | --count = 0
4 | value, IPaddr, size, type = dfsrecv("IN[0]")
5 | --while value == 0 do
6 | --myprint(IPaddr)
7 | -- count = count + 1
8 | value = dfsdrop(IPaddr)
9 | -- value, IPaddr, size, type = dfsrecv("IN")
10 | --end
11 | --print(count)
12 | return 0
13 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest1/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // TimingTest1.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // TryLua.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/CppFBPLua/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/TestNetworks/CopyFile/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // Thxgen.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "../CppFBPCore/stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/TestNetworks/TryLua/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/TestNetworks/TryLua/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #include
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #include
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #include
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/LuaScripts/concat.lua:
--------------------------------------------------------------------------------
1 |
2 | i = dfselct("IN"); -- get element count for port "IN"
3 |
4 | for j = 0, i - 1 do
5 | value, IPaddr, size, type = dfsrecv("IN["..j.."]") -- receive from element j of port "IN"
6 | while value == 0 do
7 | --myprint(IPaddr)
8 | value = dfssend("OUT", IPaddr) -- send IP to port "OUT"
9 | value, IPaddr, size, type = dfsrecv("IN["..j.."]") -- receive from element j of port "IN"
10 | end
11 | end
12 | return 0
--------------------------------------------------------------------------------
/DynNetworks/TryInfQDyn/TryInfQ.fbp:
--------------------------------------------------------------------------------
1 | # thxscan has been converted so .fbp notation can use commas or
2 | # end of line between "clauses"
3 | # comments follow the noflo convention
4 |
5 | '..\\..\\TestData\\POMPIERS.FIL' -> OPT Lire(ThFileRd)
6 | Lire OUT -> IN Ecrire(ThFileWt),
7 | 'c:\\temp\\infqueue.dat' -> OPT Ecrire * -> * Lire2(ThFileRd)
8 | Lire2 OUT -> IN Ecrire2(ThFileWt)
9 | '..\\..\\TestData\\autres.FIL' -> OPT Ecrire2
10 | 'c:\\temp\\infqueue.dat' -> OPT Lire2
--------------------------------------------------------------------------------
/CppFBPLua/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11 | // Windows Header Files:
12 | #include
13 |
14 |
15 |
16 | // TODO: reference additional headers your program requires here
17 |
--------------------------------------------------------------------------------
/TestSubnets/LuaScripts/concat.lua:
--------------------------------------------------------------------------------
1 |
2 | i = dfselct("IN"); -- get element count for port "IN"
3 |
4 | for j = 0, i - 1 do
5 | value, IPaddr, size, type = dfsrecv("IN["..j.."]") -- receive from element j of port "IN"
6 | while value == 0 do
7 | --myprint(IPaddr)
8 | value = dfssend("OUT", IPaddr) -- send IP to port "OUT"
9 | value, IPaddr, size, type = dfsrecv("IN["..j.."]") -- receive from element j of port "IN"
10 | end
11 | end
12 | return 0
--------------------------------------------------------------------------------
/DynNetworks/TryLuaDyn/TryLua.fbp:
--------------------------------------------------------------------------------
1 | Gen(ThLua), Gen2(ThLua),
2 | Concat(ThLua), Repl(ThLua), Drop(ThLua),
3 |
4 | Gen OUT -> IN[0] Concat, Gen2 OUT -> IN[1] Concat,
5 | Concat OUT -> IN Repl OUT -> IN Drop,
6 |
7 | '5000' -> COUNT Gen,
8 | '5000' -> COUNT Gen2,
9 | '../../LuaScripts\\gen.lua' -> PROG Gen,
10 | '../../LuaScripts\\gen.lua' -> PROG Gen2,
11 | '../../LuaScripts\\concat.lua' -> PROG Concat,
12 | '../../LuaScripts\\repl.lua' -> PROG Repl,
13 | '../../LuaScripts\\drop.lua' -> PROG Drop;
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzgsize.cpp:
--------------------------------------------------------------------------------
1 | #include "thzcbs.h"
2 | #include "cppfbp.h"
3 |
4 | long thzgsize(Process *pptr, void **ptr)
5 | {
6 | /* This service takes the data part of an IP - if info is needed from the header,
7 | you have to back up over the length of the header */
8 |
9 | //process *sptr;
10 | IPh *IPptr;
11 |
12 | long size;
13 |
14 | IPptr = (IPh *) *ptr - 1; /* back up size of header */
15 |
16 | size = IPptr->IP_size;
17 | return(size);
18 | }
19 |
--------------------------------------------------------------------------------
/LuaScripts/repl.lua:
--------------------------------------------------------------------------------
1 | -- repl.lua
2 |
3 | i = dfselct("OUT"); -- get element count for port "OUT"
4 |
5 | value, IPaddr, size, type = dfsrecv("IN")
6 |
7 | while value == 0 do
8 | string = dfsderef(IPaddr)
9 | for j = 0, i - 1 do
10 | value, IPaddr2 = dfscrep(string)
11 | --myprint(IPaddr2)
12 | value = dfssend("OUT["..j.."]", IPaddr2)
13 | end
14 | --myprint(IPaddr)
15 | value = dfsdrop(IPaddr)
16 |
17 | value, IPaddr, size, type = dfsrecv("IN")
18 | end
19 | return 0
--------------------------------------------------------------------------------
/TestNetworks/TryLua/trylua.fbp:
--------------------------------------------------------------------------------
1 | # Test of CppFBP - Lua combination
2 |
3 | Gen(ThLua), Gen2(ThLua), Concat(ThLua), Recvr(ThLua), Repl(ThLua),
4 |
5 | '../TryLua/gen.lua' -> PROG Gen,
6 | '../TryLua/gen.lua' -> PROG Gen2,
7 | '../TryLua/concat.lua' -> PROG Concat,
8 | '../TryLua/recvr.lua' -> PROG Recvr,
9 | '../TryLua/repl.lua' -> PROG Repl,
10 |
11 | '50' -> COUNT Gen,
12 | '50' -> COUNT Gen2,
13 |
14 | Gen OUT -> IN[0] Concat,
15 | Gen2 OUT -> IN[1] Concat,
16 | Concat OUT -> IN Repl,
17 | Repl OUT[0] -> IN Recvr
--------------------------------------------------------------------------------
/TestSubnets/LuaScripts/repl.lua:
--------------------------------------------------------------------------------
1 | -- repl.lua
2 |
3 | i = dfselct("OUT"); -- get element count for port "OUT"
4 |
5 | value, IPaddr, size, type = dfsrecv("IN")
6 |
7 | while value == 0 do
8 | string = dfsderef(IPaddr)
9 | for j = 0, i - 1 do
10 | value, IPaddr2 = dfscrep(string)
11 | --myprint(IPaddr2)
12 | value = dfssend("OUT["..j.."]", IPaddr2)
13 | end
14 | --myprint(IPaddr)
15 | value = dfsdrop(IPaddr)
16 |
17 | value, IPaddr, size, type = dfsrecv("IN")
18 | end
19 | return 0
--------------------------------------------------------------------------------
/CppFBPCore/Headers/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 | #define _CRT_SECURE_NO_WARNINGS
10 |
11 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
12 | // Windows Header Files:
13 | #include
14 |
15 |
16 | // TODO: reference additional headers your program requires here
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2 | hs_err_pid*
3 |
4 | *.bin
5 | *.obj
6 | *.debug
7 | *.ipch
8 |
9 |
10 | # Gradle
11 | *.gradle
12 |
13 | # Maven packages/etc
14 | *.target
15 | *.build
16 |
17 | #VC++ stuff
18 | .vs
19 | *.tlog
20 | *.log
21 | *.pch
22 | *.pdb
23 | *.suo
24 | *.sdf
25 | *.exe
26 | *.opensdf
27 | *.opendb
28 | **/Release/
29 | **/Debug/
30 |
31 | #data files
32 | */output.fil
33 | */autres.fil
34 |
35 | # System crap
36 | Thumbs.db
37 | .DS_Store
38 |
39 | *.txt
40 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest2/TimingTest2.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Source Files
6 |
7 |
8 |
9 |
10 |
11 | {82ac9afe-4ba5-459a-8291-b93cf5c7bfb1}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/CppSub.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include
3 | #if defined _WIN32
4 | #include
5 | #endif
6 |
7 | #include
8 |
9 | #include "thxdef.h"
10 | #include "thzcbs.h"
11 |
12 |
13 | void CppSub(label_ent * label_blk, bool dynam, FILE * fp, bool timereq, _anchor proc_anchor) {
14 | _anchor anch;
15 |
16 | Network * subnet = new Network;
17 | Process * mother = (Process *)proc_anchor.reserved;
18 | anch.reserved = mother;
19 | subnet->go(label_blk, dynam, fp, timereq, proc_anchor);
20 | delete subnet;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/Thxgen/Resource Files/Pomp.fbp:
--------------------------------------------------------------------------------
1 | # thxscan has been converted so .fbp notation can use commas or
2 | # end of line between "clauses" - Thxgen doesn't handle this yet...
3 | # comments follow the noflo convention
4 |
5 | 'c:\\threadn\\pompiers.fil' -> OPT Lire("../CppFBPComponents/Components/ThFileRd") OUT ->
6 | IN Select("../Pompiers/SelPomp") OUT ->
7 | IN Ecrire("../CppFBPComponents/Components/ThFileWt")
8 | Select REJECT -> IN Ecrire2("../CppFBPComponents/Components/ThFileWt")
9 | '100000' -> SAL Select
10 | 'c:\\threadn\\riches.fil' ->
11 | OPT Ecrire
12 | 'c:\\threadn\\pauvres.fil' -> OPT Ecrire2;
--------------------------------------------------------------------------------
/TestNetworks/TimingTest3/TimingTest3.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Source Files
6 |
7 |
8 | Source Files
9 |
10 |
11 |
12 |
13 | {82ac9afe-4ba5-459a-8291-b93cf5c7bfb1}
14 |
15 |
16 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 roberto Exp $
3 | ** Auxiliary functions from Lua API
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lapi_h
8 | #define lapi_h
9 |
10 |
11 | #include "llimits.h"
12 | #include "lstate.h"
13 |
14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
15 | "stack overflow");}
16 |
17 | #define adjustresults(L,nres) \
18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
19 |
20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
21 | "not enough elements in the stack")
22 |
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/LuaScripts/gen.lua:
--------------------------------------------------------------------------------
1 |
2 | -- TryLua.cpp is basically
3 |
4 | -- Gen1 -> Concat -> Repl -> Drop,
5 | -- Gen2 -> Concat
6 |
7 |
8 | -- Elapsed time - 54 secs
9 |
10 | -- so that's 1,000,000 each of "Lua" create, drop
11 | -- 3,000,000 each of send, receive
12 |
13 | -- Replacing drop.lua by recvr.lua - does the same as drop.lua, but as a non-looper,
14 | -- takes approx. 10 mins.!
15 |
16 | value, IPaddr, size, type = dfsrecv("COUNT")
17 |
18 | i = dfsderef(IPaddr)
19 | dfsdrop(IPaddr)
20 | print (i)
21 |
22 | for j = 1, i do
23 | value, IPaddr = dfscrep("string"..j)
24 | --myprint(IPaddr)
25 | value = dfssend("OUT", IPaddr)
26 | end
27 | return 0
--------------------------------------------------------------------------------
/TestSubnets/LuaScripts/gen.lua:
--------------------------------------------------------------------------------
1 |
2 | -- TryLua.cpp is basically
3 |
4 | -- Gen1 -> Concat -> Repl -> Drop,
5 | -- Gen2 -> Concat
6 |
7 |
8 | -- Elapsed time - 54 secs
9 |
10 | -- so that's 1,000,000 each of "Lua" create, drop
11 | -- 3,000,000 each of send, receive
12 |
13 | -- Replacing drop.lua by recvr.lua - does the same as drop.lua, but as a non-looper,
14 | -- takes approx. 10 mins.!
15 |
16 | value, IPaddr, size, type = dfsrecv("COUNT")
17 |
18 | i = dfsderef(IPaddr)
19 | dfsdrop(IPaddr)
20 | print (i)
21 |
22 | for j = 1, i do
23 | value, IPaddr = dfscrep("string"..j)
24 | --myprint(IPaddr)
25 | value = dfssend("OUT", IPaddr)
26 | end
27 | return 0
--------------------------------------------------------------------------------
/CppFBPCore/Headers/fbp.h:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #if defined _WIN32
4 | #include
5 | #endif
6 | #include
7 |
8 | //#ifdef _DEBUG
9 | // #ifndef DBG_NEW
10 | // #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
11 | // #define new DBG_NEW
12 | // #endif
13 | //#endif // _DEBUG
14 |
15 | #define MSG0(text) {printf(text); \
16 |
17 | #define MSG1(text,par1) {printf(text, par1); \
18 | }
19 | // Define 2-parameter macro for tracing
20 |
21 | #define MSG2(text,par1,par2) {printf(text, par1, par2); \
22 | }
23 |
24 | // Define 3-parameter macro for tracing
25 |
26 | #define MSG3(text,par1,par2,par3) { printf(text, par1, par2, par3); \
27 | }
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Thxgen/Resource Files/TestInfQ.fbp:
--------------------------------------------------------------------------------
1 | # thxscan has been converted so .fbp notation can use commas or
2 | # end of line between "strings"
3 | # comments follow the noflo convention
4 |
5 | 'c:\\threadn\\pompiers.fil' -> OPT L\ire("../CppFBPComponents/Components/ThFileRd") OUT -> IN Ecrire("../CppFBPComponents/Components/ThFileWt")
6 |
7 | 'c:\\temp\\infqueue.dat' -> OPT Ecrire * -> * Lire2("../CppFBPComponents/Components/ThFileRd")
8 | Lire2 OUT -> IN Ecrire2("../CppFBPComponents/Components/ThFileWt")
9 |
10 | Lire3 #legal process name syntax - they don't have to be connected to anything!
11 |
12 | Lire4 ,
13 | , # can have blanks on both sides of CR ,
14 | 'c:\\threadn\\riches.fil' -> OPT Ecrire2
15 | 'c:\\temp\\infqueue.dat' -> OPT Lire2
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThPsThru.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "StdAfx.h"
3 | #include "compsvcs.h"
4 | #include
5 |
6 | THRCOMP ThPsThru(_anchor proc_anchor)
7 |
8 | // This component simply sends what it receives
9 | {
10 | void *ptr;
11 | int value;
12 | long size;
13 | char *type;
14 | port_ent port_tab[2];
15 |
16 | value = dfsdfpt(proc_anchor, 2, port_tab,"IN","OUT");
17 |
18 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
19 | while (value == 0) {
20 | value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
21 |
22 | if (value != 0) {
23 | dfsdrop(proc_anchor, &ptr);
24 | return(1);
25 | }
26 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
27 | }
28 |
29 | return(0);
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/CppFBP.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | /**
4 | This is the C++FBP main-line, working from a set of linked, fixed-layout, structures encoding the relationships
5 | between processes, connections, ports and IIPs - they will be referred to as fixed-format network definitions (FFNDs).
6 |
7 | */
8 |
9 | #include "stdafx.h"
10 | #include
11 | #if defined _WIN32
12 | #include
13 | #endif
14 |
15 | #include
16 |
17 | #include "thxdef.h"
18 | #include "thzcbs.h"
19 |
20 |
21 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq) {
22 |
23 | Network * network = new Network;
24 | _anchor anch;
25 | anch.reserved = NULL;
26 | network->go(label_blk, dynam, fp, timereq, anch);
27 | delete network;
28 | }
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Thxgen/Thxgen.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | "Resource Files\TestInfQ"
6 | "Resource Files\TestInfQ"
7 | WindowsLocalDebugger
8 | WindowsLocalDebugger
9 |
10 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThDrop.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 | #include "StdAfx.h"
3 |
4 | /* THDROP drops all entities received on IN port.
5 |
6 | CALLING THDROP:
7 | input data stream -> IN destroy(THDROP);
8 |
9 | LIMITATIONS:
10 | None.
11 |
12 | DEFAULTS:
13 | None.
14 | */
15 |
16 | #include
17 | #include
18 | #include "compsvcs.h"
19 |
20 |
21 |
22 | THRCOMP ThDrop(_anchor proc_anchor)
23 | {
24 | void *ptr;
25 | int value;
26 | long size;
27 | char *type;
28 | port_ent port_tab[1];
29 |
30 | value = dfsdfpt(proc_anchor, 1, port_tab,"IN");
31 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
32 | while (value == 0) {
33 | value = dfsdrop(proc_anchor, &ptr);
34 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
35 | }
36 | return(0);
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/SolutionSettings/SolutionSettings.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThCopy.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "StdAfx.h"
3 | #include
4 | #include "compsvcs.h"
5 | // This component simply makes a shallow copy, drops the original, and sends out the copy
6 |
7 | THRCOMP ThCopy(_anchor proc_anchor)
8 | {
9 | void *ptr;
10 | void *ptr2;
11 | int value;
12 | long size;
13 | char *type;
14 | port_ent port_tab[2];
15 |
16 | value = dfsdfpt(proc_anchor, 2, port_tab, "IN", "OUT");
17 |
18 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
19 | while (value == 0) {
20 | value = dfscrep(proc_anchor, &ptr2, size, type);
21 | memcpy(ptr2, ptr, size);
22 | value = dfssend(proc_anchor, &ptr2, &port_tab[1], 0);
23 | dfsdrop(proc_anchor, &ptr);
24 | if (value != 0) {
25 | dfsdrop(proc_anchor, &ptr2);
26 | return(1);
27 | }
28 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
29 | }
30 |
31 | return(0);
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lundump.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $
3 | ** load precompiled Lua chunks
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lundump_h
8 | #define lundump_h
9 |
10 | #include "llimits.h"
11 | #include "lobject.h"
12 | #include "lzio.h"
13 |
14 |
15 | /* data to catch conversion errors */
16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n"
17 |
18 | #define LUAC_INT 0x5678
19 | #define LUAC_NUM cast_num(370.5)
20 |
21 | #define MYINT(s) (s[0]-'0')
22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
23 | #define LUAC_FORMAT 0 /* this is the official format */
24 |
25 | /* load one chunk; from lundump.c */
26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name);
27 |
28 | /* dump one chunk; from ldump.c */
29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
30 | void* data, int strip);
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThRevers.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 |
3 | #include "StdAfx.h"
4 | #include
5 | #include
6 | #include
7 | #include "compsvcs.h"
8 |
9 | THRCOMP ThRevers(_anchor proc_anchor)
10 | {
11 | void *ptr;
12 | void *optr;
13 | int value;
14 | long size;
15 | long level = 0;
16 | char *type;
17 | port_ent port_tab[2];
18 |
19 | value = dfsdfpt(proc_anchor, 2, port_tab,"IN","OUT");
20 |
21 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
22 | while (value == 0) {
23 | value = dfspush(proc_anchor, &ptr);
24 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
25 | }
26 | value = dfstest(proc_anchor);
27 | value = dfspop(proc_anchor, &optr, &size, &type);
28 | while (value == 0) {
29 | value = dfssend(proc_anchor, &optr, &port_tab[1], 0);
30 | value = dfspop(proc_anchor, &optr, &size, &type);
31 | }
32 |
33 | return(0);
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThConcatStr.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "StdAfx.h"
3 |
4 | #include "compsvcs.h"
5 |
6 | // This component receives all IPs from input port element 0, then from element 1, then from 2, and so forth...
7 |
8 | // This is totally different from the Concat's in JavaFBP, C#FBP and JSFBP - probably the name should be changed...
9 |
10 | THRCOMP ThConcatStr(_anchor proc_anchor)
11 | {
12 | void *ptr;
13 | //void *ptr2;
14 | int value;
15 | long size;
16 | char *type;
17 | port_ent port_tab[2];
18 |
19 | value = dfsdfpt(proc_anchor, 2, port_tab,"IN","OUT");
20 |
21 | int no = dfselct(proc_anchor, &port_tab[0]);
22 |
23 | for (int i = 0; i < no; i++) {
24 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], i, &size, &type);
25 | while (value == 0) {
26 |
27 | value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
28 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], i, &size, &type);
29 | }
30 |
31 | }
32 | return(0);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/CppFBPCore/Headers/thxanch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | struct _port_ent // block representing port in process's
4 | // stack storage - this relates the
5 | // name used by the component code
6 | // to the actual port control
7 | // block (cp) - set by THZDFPT
8 | //------------------------------------
9 | {
10 | char port_name[32]; // port name (from THZDFPT's parameters)
11 | // following fields are set by THZDFPT
12 | //union {
13 | //void *reserved;
14 | void *cpptr; // - pointer to actual port control block (Port)
15 | //};
16 | int elem_count; // - no. of elements in port control
17 | // block: >1 implies array port
18 | int ret_code; // - return code: 2 indicates port closed
19 | };
20 |
21 | typedef _port_ent port_ent;
22 |
23 | #include
24 | struct _anchor
25 | {
26 |
27 | int (*svc_addr) (int, void * vptr, ...);
28 | void *reserved;
29 | } ;
30 |
31 | typedef _anchor anchor;
32 |
33 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzdrop.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include "thzcbs.h"
7 | #include "cppfbp.h"
8 |
9 | int thzdrop(Process *proc, void **ptr)
10 | {
11 | IPh *IPptr;
12 | IP *tptr;
13 |
14 | if (proc->trace) MSG1("%s Drop start\n", proc -> procname);
15 | IPptr = (IPh *) *ptr - 1; /* back up size of header */
16 | tptr = (IP *) IPptr;
17 | if (tptr -> datapart[IPptr -> IP_size] != guard_value)
18 | MSG1("Guard byte corrupted - %s\n", proc->procname);
19 | if (IPptr -> owner != proc)
20 | MSG1("IP header corrupted - %s\n", proc->procname);
21 | if (IPptr -> on_stack)
22 | MSG1("IP on stack - %s\n", proc->procname);
23 |
24 | boost::lock_guard lock(proc -> network -> heapmtx);
25 | free(IPptr);
26 | //lock.~lock_guard();
27 |
28 | proc -> owned_IPs--;
29 | if (proc->trace) MSG1("%s Drop end\n",proc -> procname);
30 | *ptr = 0;
31 | return(0);
32 | }
33 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThCopyNL.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 |
3 | //#pragma comment(lib, "CppFBPCore")
4 |
5 | // This component simply makes a shallow copy, drops the original, and sends out the copy
6 | // Same as ThCopy but written as a non-looper
7 |
8 | #include "compsvcs.h"
9 | #include
10 |
11 | THRCOMP ThCopyNL(_anchor proc_anchor)
12 | {
13 | void *ptr;
14 | void *ptr2;
15 | int value;
16 | long size;
17 | char *type;
18 | port_ent port_tab[2];
19 |
20 | value = dfsdfpt(proc_anchor, 2, port_tab, "IN", "OUT");
21 |
22 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
23 | //while (value == 0) {
24 | value = dfscrep(proc_anchor, &ptr2, size, type);
25 | memcpy(ptr2, ptr, size);
26 | value = dfssend(proc_anchor, &ptr2, &port_tab[1], 0);
27 | dfsdrop(proc_anchor, &ptr);
28 | if (value != 0) {
29 | dfsdrop(proc_anchor, &ptr2);
30 | return(1);
31 | }
32 | // value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
33 | //}
34 |
35 | return(0);
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lprefix.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $
3 | ** Definitions for Lua code that must come before any other header file
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lprefix_h
8 | #define lprefix_h
9 |
10 |
11 | /*
12 | ** Allows POSIX/XSI stuff
13 | */
14 | #if !defined(LUA_USE_C89) /* { */
15 |
16 | #if !defined(_XOPEN_SOURCE)
17 | #define _XOPEN_SOURCE 600
18 | #elif _XOPEN_SOURCE == 0
19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
20 | #endif
21 |
22 | /*
23 | ** Allows manipulation of large files in gcc and some other compilers
24 | */
25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS)
26 | #define _LARGEFILE_SOURCE 1
27 | #define _FILE_OFFSET_BITS 64
28 | #endif
29 |
30 | #endif /* } */
31 |
32 |
33 | /*
34 | ** Windows stuff
35 | */
36 | #if defined(_WIN32) /* { */
37 |
38 | #if !defined(_CRT_SECURE_NO_WARNINGS)
39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
40 | #endif
41 |
42 | #endif /* } */
43 |
44 | #endif
45 |
46 |
--------------------------------------------------------------------------------
/DynNetworks/CopyFileDyn/CopyFileDyn.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "stdafx.h"
3 |
4 | #pragma comment(lib, "CppFBPCore")
5 |
6 |
7 | #pragma comment(lib, "CppFBPComponents")
8 |
9 |
10 | #include "thxdef.h"
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | //#include
18 | //#define FILE _iobuf
19 |
20 | /* This is the interpretive form of CopyFile */
21 |
22 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
23 |
24 | void main() {
25 | const char* fname = "CopyFile.fbp";
26 | FILE *f;
27 |
28 | #ifdef WIN32
29 | errno_t err;
30 | if( (err = fopen_s( &f, fname, "r" )) !=0 ) {
31 | #else
32 | if ((fp_config = fopen(configfile, "r")) == NULL) {
33 | #endif
34 | fprintf(stderr, "Cannot open source file %s!\n", fname);
35 | }
36 | if (f == NULL) {
37 | //printf("Trying to open: CopyFile.fbp\n");
38 | perror ("The following error occurred");
39 |
40 | }
41 | else
42 | CppFBP(0, DYNAM, f, TIME_REQ);
43 | system("pause"); // to see console
44 | }
45 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThReplStr.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 | #include "StdAfx.h"
3 | #include
4 | #include "compsvcs.h"
5 | // This component simply makes a shallow copy, drops the original, and sends out the copy to all elements of the output port
6 |
7 | THRCOMP ThReplStr(_anchor proc_anchor)
8 | {
9 | void *ptr;
10 | void *ptr2;
11 | int value;
12 | long size;
13 | char *type;
14 | port_ent port_tab[2];
15 |
16 | value = dfsdfpt(proc_anchor, 2, port_tab,"IN","OUT");
17 |
18 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
19 | int no = dfselct(proc_anchor, &port_tab[1]);
20 | while (value == 0) {
21 | for (int i = 0; i < no; i++) {
22 | value = dfscrep(proc_anchor, &ptr2, size, type);
23 | memcpy(ptr2,ptr,size);
24 | value = dfssend(proc_anchor, &ptr2, &port_tab[1], i);
25 | }
26 | dfsdrop(proc_anchor, &ptr);
27 | if (value != 0) {
28 | dfsdrop(proc_anchor, &ptr);
29 | return(1);
30 | }
31 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
32 | }
33 |
34 | return(0);
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/DynNetworks/TryInfQDyn/TryInfQDyn.cpp:
--------------------------------------------------------------------------------
1 | #pragma comment(lib, "CppFBPCore")
2 | #pragma comment(lib, "CppFBPComponents")
3 |
4 | // TryInfQDyn.cpp : Defines the entry point for the console application.
5 | //
6 |
7 | #include "thxdef.h"
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | //#include
15 | //#define FILE _iobuf
16 |
17 | /* This is the interpretive form of TryInfQ */
18 |
19 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
20 |
21 | void main() {
22 |
23 | const char* fname = "TryInfQ.fbp";
24 | FILE *f;
25 |
26 | #ifdef WIN32
27 | errno_t err;
28 | if( (err = fopen_s( &f, fname, "r" )) !=0 ) {
29 | #else
30 | if ((f = fopen(fname, "r")) == NULL) {
31 | #endif
32 | fprintf(stderr, "Cannot open source file %s!\n", fname);
33 | }
34 | if (f == NULL) {
35 | //printf("Trying to open: TryInfQ.fbp\n");
36 | perror ("The following error occurred");
37 |
38 | }
39 | else
40 | CppFBP(0, DYNAM, f, TIME_REQ);
41 | system("pause"); // to see console
42 | }
--------------------------------------------------------------------------------
/DynNetworks/TryLuaDyn/TryLuaDyn.cpp:
--------------------------------------------------------------------------------
1 |
2 | #pragma comment(lib, "CppFBPCore")
3 |
4 |
5 | #pragma comment(lib, "CppFBPComponents")
6 |
7 |
8 | // TryLuaDyn.cpp : Defines the entry point for the console application.
9 | //
10 |
11 | #include "thxdef.h"
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | //#include
19 | //#define FILE _iobuf
20 |
21 | /* This is the interpretive form of TryLua */
22 |
23 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
24 |
25 | void main() {
26 |
27 | const char* fname = "TryLua.fbp";
28 | FILE *f;
29 |
30 | #ifdef WIN32
31 | errno_t err;
32 | if( (err = fopen_s( &f, fname, "r" )) !=0 ) {
33 | #else
34 | if ((f = fopen(fname, "r")) == NULL) {
35 | #endif
36 | fprintf(stderr, "Cannot open source file %s!\n", fname);
37 | }
38 | if (f == NULL) {
39 | //printf("Trying to open: TryLua.fbp\n");
40 | perror ("The following error occurred");
41 |
42 | }
43 | else
44 | CppFBP(0, DYNAM, f, TIME_REQ);
45 | system("pause"); // to see console
46 | }
--------------------------------------------------------------------------------
/TestNetworks/TryLua/TryLua.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest1/TimingTest1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzdfpt.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | //#include
4 | #include
5 | #include "thzcbs.h"
6 | #include "cppfbp.h"
7 |
8 | int thzdfpt(Process *pptr, int port_count, port_ent *peptr)
9 | {
10 | Port *cpp;
11 | int i;
12 |
13 | if (pptr->trace) MSG1("%s DFPT Start\n", pptr->procname);
14 | for (i = 0; i < port_count; i++)
15 | {
16 | cpp = pptr -> in_ports;
17 | while (cpp != 0) {
18 | if (strcmp((peptr+i)-> port_name, cpp -> port_name) == 0) break;
19 | cpp = cpp -> succ;
20 | }
21 | if (cpp != 0){
22 | (peptr+i)-> cpptr = cpp;
23 | (peptr+i) -> elem_count = cpp -> elem_count;
24 | (peptr+i)-> ret_code = 0;
25 | }
26 | else {
27 | cpp = pptr -> out_ports;
28 | while (cpp != 0) {
29 |
30 | if (strcmp((peptr+i) -> port_name, cpp -> port_name) == 0) break;
31 | cpp = cpp -> succ;
32 | }
33 | if (cpp == 0)
34 | (peptr+i)-> ret_code = 2;
35 | else {
36 | (peptr+i)-> cpptr = cpp;
37 | (peptr+i)-> elem_count = cpp -> elem_count;
38 | (peptr+i)-> ret_code = 0;
39 | }
40 | }
41 | }
42 | if (pptr->trace) MSG1("%s DFPT End\n", pptr->procname);
43 |
44 | return(0);
45 | }
46 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzpush.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | //#include
4 | #include
5 | #include "thzcbs.h"
6 | #include "cppfbp.h"
7 |
8 | int thzpush(Process *pptr, void **ptr)
9 | {
10 | IPh *IPptr;
11 | //IPh *optr;
12 | // IPh *qptr;
13 | IP *tptr;
14 |
15 | if (pptr -> trace) MSG1("%s Push start\n", pptr -> procname);
16 | IPptr = (IPh *) *ptr - 1; /* back up size of header */
17 | tptr = (IP *)IPptr;
18 | if (tptr -> datapart[IPptr -> IP_size] != guard_value)
19 | MSG1("Guard byte corrupted: '%s'\n", pptr->procname);
20 | if (IPptr -> owner != pptr)
21 | MSG1("IP header corrupted: '%s'\n", pptr->procname);
22 | if (IPptr -> on_stack)
23 | MSG1("IP on stack: '%s'\n", pptr->procname);
24 | //optr = IPptr -> prev_IP;
25 | //qptr = IPptr -> next_IP;
26 | // if (optr != 0)
27 | // optr -> next_IP = qptr;
28 | // else
29 | // pptr -> first_owned_IP = qptr;
30 | // if (qptr != 0)
31 | // qptr -> prev_IP = optr;
32 | IPptr -> next_IP = pptr -> stack;
33 | pptr -> stack = IPptr;
34 | IPptr -> on_stack = TRUE;
35 | if (pptr -> trace) MSG1("%s Push end\n",pptr -> procname);
36 | *ptr = 0;
37 | pptr -> owned_IPs--;
38 | return(0);
39 | }
40 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzelct.cpp:
--------------------------------------------------------------------------------
1 | #include "thzcbs.h"
2 | #include "cppfbp.h"
3 |
4 | int thzelctc(Process *proc, char * port)
5 | {
6 | int elem_no = 0;
7 | char port_name[100];
8 | char * p = strchr(port, '[');
9 | char * q;
10 | if (p == 0)
11 | strcpy_s (port_name, port);
12 | else {
13 | q = strchr(p, ']');
14 | auto n = q - p - 1;
15 | char no[10];
16 | strncpy_s(no, p + 1, n);
17 | elem_no = atoi(no);
18 | char * r = port;
19 | strncpy_s (port_name, port, p - r);
20 | port_name[p - r] = '\0';
21 | }
22 | Port * cpp = proc -> in_ports;
23 | while (cpp != 0)
24 | {
25 |
26 | if (0 == strcmp(cpp -> port_name, port_name)){
27 | break;
28 | }
29 |
30 | cpp = cpp -> succ;
31 | }
32 | if (cpp == 0) {
33 | cpp = proc -> out_ports;
34 | while (cpp != 0)
35 | {
36 |
37 | if (0 == strcmp(cpp -> port_name, port_name)){
38 | break;
39 | }
40 |
41 | cpp = cpp -> succ;
42 | }
43 | if (cpp == 0) {
44 | MSG2 ("%s Port %s not found\n", proc -> procname, port_name);
45 | return -1;
46 | }
47 | }
48 | return cpp -> elem_count;
49 | }
50 |
51 | int thzelct(Process *proc, port_ent *peptr)
52 | {
53 | /* This service returns the no. of elements in a cpp */
54 |
55 | Port * cpp = (Port *) peptr ->cpptr;
56 | return cpp->elem_count;
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/SolutionSettings/UserMacros.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | c:\Users\Paul\Documents\GitHub\cppfbp\CppFBPLua\src
6 | C:\Users\Paul\Documents\GitHub\cppfbp\Debug\CppFBPLua.lib
7 | C:\Program Files\boost\boost_1_75_0
8 | C:\Program Files\boost\boost_1_75_0\stage\lib
9 |
10 |
11 |
12 |
13 |
14 | $(LUA_LIB)
15 | true
16 |
17 |
18 | $(LUA_INCLUDE)
19 | true
20 |
21 |
22 | $(BOOST_INCLUDE)
23 | true
24 |
25 |
26 | $(BOOST_LIB)
27 | true
28 |
29 |
30 |
--------------------------------------------------------------------------------
/LuaScripts/LuaScripts.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Resource Files
20 |
21 |
22 | Resource Files
23 |
24 |
25 | Resource Files
26 |
27 |
28 | Resource Files
29 |
30 |
31 | Resource Files
32 |
33 |
34 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/TryDynSubNet.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {b0665504-99e6-4d1e-89e1-41f9fe2ed81a}
18 |
19 |
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Helper Code
29 |
30 |
31 |
--------------------------------------------------------------------------------
/TestSubnets/LuaScripts/LuaScripts.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Resource Files
20 |
21 |
22 | Resource Files
23 |
24 |
25 | Resource Files
26 |
27 |
28 | Resource Files
29 |
30 |
31 | Resource Files
32 |
33 |
34 |
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/TryStatSubNet.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {b0665504-99e6-4d1e-89e1-41f9fe2ed81a}
18 |
19 |
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Helper Code
29 |
30 |
31 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThGenIps.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "StdAfx.h"
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "compsvcs.h"
9 |
10 |
11 | THRCOMP ThGenIps(_anchor proc_anchor)
12 | {
13 | void *ptr;
14 | char *p;
15 | char string[256];
16 | int value, i;
17 | long size, count;
18 | char *type;
19 | port_ent port_tab[3];
20 | //char buffer[256];
21 |
22 | value = dfsdfpt(proc_anchor, 3, port_tab,"COUNT","OUT","PREFIX");
23 |
24 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
25 | if (value > 0) {
26 | printf("THGENIPS: No number specified\n");
27 | // dfsputs(proc_anchor, buffer);
28 | return(8);
29 | }
30 | memcpy(string,ptr,size);
31 | string[size] = '\0';
32 | count = atol(string);
33 |
34 | value = dfsdrop(proc_anchor, &ptr);
35 |
36 | strcpy(string, "Testing ");
37 | value = dfsrecv(proc_anchor, &ptr, &port_tab[2], 0, &size, &type);
38 | if (value == 0) {
39 | memcpy(string,ptr,size);
40 | string[size] = '\0';
41 | value = dfsdrop(proc_anchor, &ptr);
42 | }
43 | // dfstest(proc_anchor);
44 | for (i = 0; i < count; i++) {
45 | value = dfscrep(proc_anchor, &ptr, 32,"G");
46 | strcpy((char *) ptr, string);
47 | p = strchr((char *) ptr, '\0');
48 | _itoa(i, p, 10);
49 | value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
50 | }
51 | return(0);
52 | }
--------------------------------------------------------------------------------
/CppFBPCore/Headers/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // The following macros define the minimum required platform. The minimum required platform
4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
5 | // your application. The macros work by enabling all features available on platform versions up to and
6 | // including the version specified.
7 |
8 | // Modify the following defines if you have to target a platform prior to the ones specified below.
9 | // Refer to MSDN for the latest info on corresponding values for different platforms.
10 | #ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
11 | #define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
12 | #endif
13 |
14 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
15 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
16 | #endif
17 |
18 | #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
19 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
20 | #endif
21 |
22 | #ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
23 | #define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
24 | #endif
25 |
26 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzcrep.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | #include
4 | #include
5 | #include "thzcbs.h"
6 | #include "cppfbp.h"
7 |
8 |
9 |
10 | int thzcrep(Process *pptr, void **ptr, long IPsize, char *type)
11 | {
12 |
13 | /* This service returns the data part of an IP - if info is needed from the header,
14 | you have to back up over the length of the header */
15 |
16 | long totsize;
17 | IPh *IPptr;
18 |
19 | IP *tptr;
20 |
21 | if (pptr->trace) MSG1("%s Crep start\n", pptr -> procname);
22 | if (IPsize > 64000 || IPsize < 0) {
23 | MSG2("Invalid IP size in CREP: %ld - %s\n", IPsize, pptr -> procname);
24 | return(8);
25 | }
26 | int i = sizeof(IPh);
27 | totsize = IPsize + i + 1; // room for guard
28 |
29 | boost::lock_guard lock(pptr -> network -> heapmtx);
30 | IPptr = (IPh *) malloc(totsize);
31 | //lock.~lock_guard();
32 |
33 | IPptr -> IP_size = IPsize;
34 | IPptr -> owner = pptr;
35 | IPptr -> type = type;
36 |
37 | IPptr -> next_IP = 0;
38 | IPptr -> prev_IP = 0;
39 | IPptr -> on_stack = FALSE;
40 | //pptr -> first_owned_IP = IPptr;
41 | tptr = (IP *) IPptr;
42 | *ptr = tptr -> datapart;
43 | tptr -> datapart[IPsize] = guard_value;
44 | pptr -> owned_IPs++;
45 | if (pptr->trace) MSG1("%s Crep end\n",pptr -> procname);
46 | return(0);
47 | }
48 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzpop.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | //#include
4 | #include
5 | #include "thzcbs.h"
6 | #include "cppfbp.h"
7 | #define FALSE 0
8 | #define TRUE 1
9 |
10 | int thzpop(Process *pptr, void **ptr, long *size, char **typep)
11 | {
12 | //process *sptr;
13 | IPh *IPptr;
14 | //IPh *optr;
15 | IP *tptr;
16 | //int value;
17 |
18 |
19 | if (pptr -> trace) MSG1("%s Pop start\n", pptr -> procname);
20 |
21 | if ((IPptr = pptr -> stack) == 0)
22 | return(2);
23 | pptr -> stack = IPptr -> next_IP;
24 | tptr = (IP *) IPptr;
25 | if (tptr -> datapart[IPptr -> IP_size] != guard_value)
26 | MSG1("Guard byte corrupted: '%s'\n", pptr -> procname);
27 | if (IPptr -> owner != pptr)
28 | MSG1("IP header corrupted: '%s'\n", pptr->procname);
29 | if (! IPptr -> on_stack)
30 | MSG1("IP not on stack: '%s'\n", pptr->procname);
31 |
32 | *ptr = tptr -> datapart;
33 | *size = IPptr -> IP_size;
34 | *typep = IPptr -> type;
35 | //if ((optr = pptr -> first_owned_IP) != 0)
36 | // optr -> prev_IP = IPptr;
37 | //IPptr -> next_IP = optr;
38 | IPptr -> next_IP = 0;
39 | IPptr -> prev_IP = 0;
40 | //pptr -> first_owned_IP = IPptr;
41 | IPptr -> owner = pptr;
42 | IPptr -> on_stack = FALSE;
43 | if (pptr -> trace) MSG1("%s Pop end\n", pptr -> procname);
44 | pptr -> owned_IPs++;
45 | return(0);
46 | }
--------------------------------------------------------------------------------
/CppFBPLua/src/lualib.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $
3 | ** Lua standard libraries
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lualib_h
9 | #define lualib_h
10 |
11 | #include "lua.h"
12 |
13 |
14 |
15 | LUAMOD_API int (luaopen_base) (lua_State *L);
16 |
17 | #define LUA_COLIBNAME "coroutine"
18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L);
19 |
20 | #define LUA_TABLIBNAME "table"
21 | LUAMOD_API int (luaopen_table) (lua_State *L);
22 |
23 | #define LUA_IOLIBNAME "io"
24 | LUAMOD_API int (luaopen_io) (lua_State *L);
25 |
26 | #define LUA_OSLIBNAME "os"
27 | LUAMOD_API int (luaopen_os) (lua_State *L);
28 |
29 | #define LUA_STRLIBNAME "string"
30 | LUAMOD_API int (luaopen_string) (lua_State *L);
31 |
32 | #define LUA_UTF8LIBNAME "utf8"
33 | LUAMOD_API int (luaopen_utf8) (lua_State *L);
34 |
35 | #define LUA_BITLIBNAME "bit32"
36 | LUAMOD_API int (luaopen_bit32) (lua_State *L);
37 |
38 | #define LUA_MATHLIBNAME "math"
39 | LUAMOD_API int (luaopen_math) (lua_State *L);
40 |
41 | #define LUA_DBLIBNAME "debug"
42 | LUAMOD_API int (luaopen_debug) (lua_State *L);
43 |
44 | #define LUA_LOADLIBNAME "package"
45 | LUAMOD_API int (luaopen_package) (lua_State *L);
46 |
47 |
48 | /* open all previous libraries */
49 | LUALIB_API void (luaL_openlibs) (lua_State *L);
50 |
51 |
52 |
53 | #if !defined(lua_assert)
54 | #define lua_assert(x) ((void)0)
55 | #endif
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/CppFBPCore/Headers/compsvcs.h:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #pragma once
5 |
6 | //#ifndef THXANCH
7 | //#define THXANCH
8 | #include "thxanch.h"
9 | //#endif
10 |
11 | //typedef int (__stdcall *LPFNDLLFUNC) (_anchor anch);
12 | typedef __declspec(dllimport) int(*LPFNDLLFUNC) (_anchor anch);
13 | //#define THRCOMP __declspec(dllexport) int __stdcall
14 | #define THRCOMP extern "C" __declspec(dllexport) int
15 |
16 | int dfscrep(_anchor proc_anchor, void **ptr, long size, char *type);
17 | int dfssend(_anchor proc_anchor, void **ptr, port_ent *peptr,
18 | int elem_no);
19 | int dfsrecv(_anchor proc_anchor, void **ptr, port_ent *peptr,
20 | int elem_no, long *size, char **type);
21 | int dfsdrop(_anchor proc_anchor, void **ptr);
22 | int dfsdfpt(_anchor proc_anchor, int port_count, port_ent *peptr, ...);
23 | int dfspush(_anchor proc_anchor, void **ptr);
24 | int dfspop(_anchor proc_anchor, void **ptr, long *size, char **type);
25 | int dfsclos(_anchor proc_anchor, port_ent *peptr,
26 | int elem_no);
27 | int dfstest(_anchor proc_anchor);
28 | long dfsgsize(_anchor proc_anchor, void **ptr);
29 | int dfselct(_anchor proc_anchor, port_ent *peptr);
30 |
31 | int dfssendc(_anchor proc_anchor, void **ptr, char * port);
32 | int dfsrecvc(_anchor proc_anchor, void **ptr, char * port, long *size, char **type);
33 |
34 | int dfsclosc(_anchor proc_anchor, char * port);
35 | int dfselctc(_anchor proc_anchor, char * port);
36 |
37 |
--------------------------------------------------------------------------------
/DynNetworks/TryLuaDyn/TryLuaDyn.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 |
26 |
27 | Resource Files
28 |
29 |
30 |
31 |
32 | Source Files
33 |
34 |
35 |
--------------------------------------------------------------------------------
/DynNetworks/TryInfQDyn/TryInfQDyn.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 |
26 |
27 | Resource Files
28 |
29 |
30 |
31 |
32 | Source Files
33 |
34 |
35 |
--------------------------------------------------------------------------------
/TestNetworks/DeadlockTest/DeadlockTest.cpp:
--------------------------------------------------------------------------------
1 | #pragma comment(lib, "CppFBPCore")
2 |
3 |
4 | #pragma comment(lib, "CppFBPComponents")
5 |
6 |
7 | #include "thxdef.h"
8 | #include
9 |
10 | /* This is not the THREADS internal structure - this
11 | is a structured representation of the free-form connection list
12 |
13 | Trying to force deadlock
14 |
15 | */
16 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
17 |
18 | THRCOMP ThGenIps(_anchor anch);
19 | THRCOMP ThReplStr(_anchor anch);
20 | THRCOMP ThConcatStr(_anchor anch);
21 | THRCOMP ThDrop(_anchor anch);
22 |
23 | proc_ent P00 = {0, "Gen", "ThGenIps", ThGenIps, 0, 0, 0, 0};
24 | proc_ent P01 = {&P00, "Repl", "ThReplStr", ThReplStr, 0, 0, 0, 0};
25 | proc_ent P02 = {&P01, "Concat", "ThConcatStr", ThConcatStr, 0, 0, 0, 0};
26 | proc_ent P03 = {&P02, "Drop", "ThDrop", ThDrop, 0, 0, 0, 0};
27 |
28 | IIP I00 = {"2000000"};
29 | cnxt_ent C00 = {0, "!", "", 0, "Gen", "COUNT", 0, &I00, 0};
30 | cnxt_ent C01 = {&C00, "Gen", "OUT", 0, "Repl", "IN", 0, 0, 50};
31 | cnxt_ent C02 = {&C01, "Repl", "OUT", 0, "Concat", "IN", 0, 0, 50};
32 | cnxt_ent C03 = {&C02, "Repl", "OUT", 1, "Concat", "IN", 1, 0, 50};
33 | cnxt_ent C04 = {&C03, "Repl", "OUT", 2, "Concat", "IN", 2, 0, 50};
34 | cnxt_ent C05 = {&C04, "Concat", "OUT", 0, "Drop", "IN", 0, 0, 50};
35 |
36 |
37 |
38 | label_ent LABELTAB = {0, " ", "", &C05, &P03, 'L'};
39 |
40 |
41 | void main() {
42 | CppFBP(&LABELTAB, 0, 0, 1); // time required
43 | }
44 |
--------------------------------------------------------------------------------
/Thxgen/Thxgen.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 | Source Files
31 |
32 |
33 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/SubOut.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 | #include "StdAfx.h"
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "compsvcs.h"
9 | #include "thzcbs.h"
10 | #define OUTPUT 1
11 |
12 | THRCOMP SubOut(_anchor proc_anchor)
13 | {
14 | void *ptr;
15 | char pname[256];
16 | int value;
17 | long size;
18 | char *type;
19 | port_ent port_tab[2];
20 |
21 | port_ent mother_port;
22 |
23 | value = dfsdfpt(proc_anchor, 2, port_tab,"NAME","IN");
24 |
25 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
26 |
27 | memcpy(pname,ptr,size);
28 | pname[size] = '\0';
29 |
30 | value = dfsdrop(proc_anchor, &ptr);
31 |
32 | Process* proc = (Process *) proc_anchor.reserved;
33 | proc = proc -> mother_proc;
34 |
35 | Port* cpp = proc -> out_ports;
36 | while (cpp != 0)
37 | {
38 | if (0 == strcmp(cpp->port_name, pname))
39 | break;
40 | cpp = cpp -> succ;
41 | }
42 |
43 | if (cpp == 0) {
44 | printf ("Port name %s not found\n",
45 | pname);
46 | return(8);
47 | }
48 |
49 | strcpy(mother_port.port_name, cpp -> port_name);
50 | //cpp -> direction = OUTPUT;
51 | mother_port.cpptr = cpp;
52 | mother_port.elem_count = cpp -> elem_count;
53 | mother_port.ret_code = 0;
54 |
55 |
56 | value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
57 | while (value == 0) {
58 | value = dfssend(proc_anchor, &ptr, &mother_port, 0);
59 | value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
60 | }
61 |
62 | return(0);
63 | }
--------------------------------------------------------------------------------
/TestSubnets/Subnets/InfQueue.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "StdAfx.h"
3 |
4 | #pragma comment(lib, "CppFBPCore")
5 |
6 |
7 | #pragma comment(lib, "CppFBPComponents")
8 |
9 |
10 |
11 | #include "thxdef.h"
12 | #include
13 | #define FILE struct _iobuf
14 |
15 | void CppSub(label_ent * label_blk, bool dynam, FILE * fp, bool timereq, _anchor proc_anchor);
16 |
17 | THRCOMP InfQueue(_anchor proc_anchor)
18 | {
19 |
20 |
21 | THRCOMP ThFileRd(anchor anch);
22 | THRCOMP ThFileWt(anchor anch);
23 | THRCOMP SubIn(anchor anch);
24 | THRCOMP SubOut(anchor anch);
25 |
26 | proc_ent P0 = {0, "SubIn", "SubIn", SubIn, 0, 0, !TRACE, 0};
27 | proc_ent P1 = {&P0, "Ecrire", "ThFileWt", ThFileWt, 0, 0, !TRACE, 0};
28 | proc_ent P2 = {&P1, "Lire", "ThFileRd", ThFileRd, 0, 0, !TRACE, 0};
29 | proc_ent P3 = {&P2, "SubOut", "SubOut", SubOut, 0, 0, !TRACE, 0};
30 |
31 |
32 | IIP I0 = {"IN"};
33 | cnxt_ent C0 = {0, "!", " ", 0, "SubIn", "NAME", 0, &I0, 0};
34 | cnxt_ent C1 = {&C0, "SubIn", "OUT", 0, "Ecrire", "IN", 0, 0, 6};
35 | IIP I1 = {"c:\\temp\\infqueue.dat"};
36 | cnxt_ent C2 = {&C1, "!", " ", 0, "Ecrire", "OPT", 0, &I1, 0};
37 |
38 | cnxt_ent C3 = {&C2, "Ecrire", "*", 0, "Lire", "*", 0, 0, 6};
39 |
40 | cnxt_ent C4 = {&C3, "!", " ", 0, "Lire", "OPT", 0, &I1, 0};
41 | IIP I2 = {"OUT"};
42 | cnxt_ent C5 = {&C4, "!", " ", 0, "SubOut", "NAME", 0, &I2, 0};
43 | cnxt_ent C6 = {&C5, "Lire", "OUT", 0, "SubOut", "IN", 0, 0, 6};
44 |
45 | label_ent LABELTAB = {0, " ", "", &C6, &P3, 'L'};
46 |
47 | //startSubnet:
48 | CppSub(&LABELTAB, 0, 0, 0, proc_anchor);
49 | return(0);
50 | }
--------------------------------------------------------------------------------
/CppFBPComponents/Components/SubIn.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "StdAfx.h"
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "compsvcs.h"
9 | #include "thzcbs.h"
10 |
11 |
12 | THRCOMP SubIn(_anchor proc_anchor)
13 | {
14 | void *ptr;
15 | char pname[256];
16 | int value;
17 | long size;
18 | char *type;
19 | port_ent port_tab[2];
20 |
21 | port_ent mother_port;
22 | #define INPUT 0
23 |
24 | value = dfsdfpt(proc_anchor, 2, port_tab, "NAME", "OUT");
25 |
26 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
27 |
28 | memcpy(pname, ptr, size);
29 | pname[size] = '\0';
30 |
31 | value = dfsdrop(proc_anchor, &ptr);
32 |
33 | Process* proc = (Process *)proc_anchor.reserved;
34 | proc = proc->mother_proc;
35 | Port* cpp = proc->in_ports;
36 | while (cpp != 0)
37 | {
38 | if (0 == strcmp(cpp->port_name, pname))
39 | break;
40 | cpp = cpp->succ;
41 | }
42 |
43 | if (cpp == 0) {
44 | printf("Port name %s not found\n",
45 | pname);
46 | return(8);
47 | }
48 |
49 | strcpy(mother_port.port_name, cpp->port_name);
50 | //cpp -> direction = INPUT;
51 | mother_port.cpptr = cpp;
52 | mother_port.elem_count = cpp->elem_count;
53 | mother_port.ret_code = 0;
54 | // make sure you handle IIP ---
55 |
56 | value = dfsrecv(proc_anchor, &ptr, &mother_port, 0, &size, &type);
57 | while (value == 0) {
58 | value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
59 | value = dfsrecv(proc_anchor, &ptr, &mother_port, 0, &size, &type);
60 | }
61 |
62 | return(0);
63 |
64 | }
--------------------------------------------------------------------------------
/DynNetworks/CopyFileDyn/CopyFileDyn.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Resource Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 |
31 |
32 | Header Files
33 |
34 |
35 | Header Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/CppFBPLua/src/ldebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $
3 | ** Auxiliary functions from Debug Interface module
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldebug_h
8 | #define ldebug_h
9 |
10 |
11 | #include "lstate.h"
12 |
13 |
14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
15 |
16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
17 |
18 | #define resethookcount(L) (L->hookcount = L->basehookcount)
19 |
20 |
21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
22 | const char *opname);
23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,
24 | const TValue *p2);
25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1,
26 | const TValue *p2,
27 | const char *msg);
28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1,
29 | const TValue *p2);
30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
31 | const TValue *p2);
32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg,
34 | TString *src, int line);
35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
36 | LUAI_FUNC void luaG_traceexec (lua_State *L);
37 |
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/TestNetworks/CopyFile/CopyFile.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "thxdef.h"
3 |
4 | #pragma comment(lib, "CppFBPCore")
5 |
6 |
7 |
8 | #pragma comment(lib, "CppFBPComponents")
9 |
10 |
11 |
12 |
13 | #include
14 | #define FILE struct _iobuf
15 |
16 | /* This is not the THREADS internal structure - this
17 | is a structured representation of the free-form connection list
18 | */
19 |
20 | void CppFBP(label_ent* label_blk, bool dynam, FILE * fp, bool timereq);
21 |
22 | //__declspec(dllimport/dllexport) keywords, combined with extern "C"
23 |
24 |
25 | THRCOMP ThFileWt(_anchor anch);
26 | THRCOMP ThCopyNL(_anchor anch);
27 | THRCOMP ThFileRd(_anchor anch);
28 |
29 | int cap = 2;
30 | int elem0 = 0;
31 |
32 |
33 | proc_ent P0 = { NULL, "Read", "ThFileRd", ThFileRd, NULL, NULL, TRACE, !COMPOS };
34 | proc_ent P1 = { &P0, "Show", "ThFileWt", ThFileWt, NULL, NULL, TRACE, !COMPOS };
35 | proc_ent P2 = { &P1, "Copy", "ThCopyNL", ThCopyNL, NULL, NULL, TRACE, !COMPOS };
36 | //proc_ent P2 = {&P1, "Copy", "ThCopy", ThCopy, NULL, NULL, !TRACE, !COMPOS;
37 |
38 | IIP I0 = { "..\\..\\TestData\\POMPIERS.FIL" };
39 | IIP I2 = { "..\\..\\TestData\\output.fil" };
40 | cnxt_ent C0 = { NULL, "!", "", 0, "Read", "OPT", elem0, &I0, 0 };
41 | cnxt_ent C1 = { &C0, "Read", "OUT", elem0, "Copy", "IN", elem0, NULL, cap };
42 | cnxt_ent C2 = { &C1, "!", "", 0, "Show", "OPT", elem0, &I2, 0 };
43 | cnxt_ent C3 = { &C2, "Copy", "OUT", elem0, "Show", "IN", elem0, NULL, cap };
44 |
45 |
46 | label_ent LABELTAB = { NULL, " ", "", &C3, &P2, 'L' };
47 |
48 |
49 | void main() {
50 | CppFBP(&LABELTAB, !DYNAM, NULL, TIME_REQ); // time required
51 | }
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/TryStatSubNet.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "stdafx.h"
3 |
4 | #pragma comment(lib, "CppFBPCore")
5 |
6 |
7 | #pragma comment(lib, "CppFBPComponents")
8 |
9 |
10 | #pragma comment(lib, "TestSubnets") /// jr dll linkage - (should be static ??
11 |
12 | #include "thxdef.h"
13 |
14 | #include
15 | #define FILE struct _iobuf
16 |
17 | /* This is not the THREADS internal structure - this
18 | is a structured representation of the free-form connection list
19 | */
20 | void CppFBP(label_ent* label_blk, bool dynam, FILE * fp, bool timereq);
21 |
22 | THRCOMP ThFileWt(_anchor anch);
23 | THRCOMP InfQueue(_anchor anch);
24 | THRCOMP ThFileRd(_anchor anch);
25 |
26 | int cap = 2;
27 | int elem0 = 0;
28 | /*
29 | This test case links to InfQueue statically, and then runs it under the "Copy" process
30 | */
31 |
32 | proc_ent P0 = {NULL, "Read", "ThFileRd", ThFileRd, NULL, NULL, !TRACE, !COMPOS};
33 | proc_ent P1 = {&P0, "Write", "ThFileWt", ThFileWt, NULL, NULL, !TRACE, !COMPOS};
34 | proc_ent P2 = {&P1, "Copy", "InfQueue", InfQueue, NULL, NULL, !TRACE, COMPOS};
35 |
36 | IIP I0 = {"..\\..\\TestData\\POMPIERS.FIL"};
37 | IIP I1 = {"..\\..\\TestData\\output.fil"};
38 | cnxt_ent C0 = {NULL, "!", "", 0, "Read", "OPT", elem0, &I0, 0};
39 | cnxt_ent C1 = {&C0, "Read", "OUT", elem0, "Copy", "IN", elem0, NULL, cap};
40 | cnxt_ent C2 = {&C1, "!", "", 0, "Write", "OPT", elem0, &I1, 0};
41 | cnxt_ent C3 = {&C2, "Copy", "OUT", elem0, "Write", "IN", elem0, NULL, cap};
42 |
43 |
44 | label_ent LABELTAB = {NULL, " ", "", &C3, &P2, 'L'};
45 |
46 |
47 | void main() {
48 | CppFBP(&LABELTAB, !DYNAM, NULL, TIME_REQ); // time required
49 | }
50 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 roberto Exp $
3 | ** String table (keep all strings handled by Lua)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lstring_h
8 | #define lstring_h
9 |
10 | #include "lgc.h"
11 | #include "lobject.h"
12 | #include "lstate.h"
13 |
14 |
15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char))
16 |
17 | #define sizeludata(l) (sizeof(union UUdata) + (l))
18 | #define sizeudata(u) sizeludata((u)->len)
19 |
20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
21 | (sizeof(s)/sizeof(char))-1))
22 |
23 |
24 | /*
25 | ** test whether a string is a reserved word
26 | */
27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
28 |
29 |
30 | /*
31 | ** equality for short strings, which are always internalized
32 | */
33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b))
34 |
35 |
36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
40 | LUAI_FUNC void luaS_clearcache (global_State *g);
41 | LUAI_FUNC void luaS_init (lua_State *L);
42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);
44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l);
47 |
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lzio.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lzio_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "llimits.h"
18 | #include "lmem.h"
19 | #include "lstate.h"
20 | #include "lzio.h"
21 |
22 |
23 | int luaZ_fill (ZIO *z) {
24 | size_t size;
25 | lua_State *L = z->L;
26 | const char *buff;
27 | lua_unlock(L);
28 | buff = z->reader(L, z->data, &size);
29 | lua_lock(L);
30 | if (buff == NULL || size == 0)
31 | return EOZ;
32 | z->n = size - 1; /* discount char being returned */
33 | z->p = buff;
34 | return cast_uchar(*(z->p++));
35 | }
36 |
37 |
38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
39 | z->L = L;
40 | z->reader = reader;
41 | z->data = data;
42 | z->n = 0;
43 | z->p = NULL;
44 | }
45 |
46 |
47 | /* --------------------------------------------------------------- read --- */
48 | size_t luaZ_read (ZIO *z, void *b, size_t n) {
49 | while (n) {
50 | size_t m;
51 | if (z->n == 0) { /* no bytes in buffer? */
52 | if (luaZ_fill(z) == EOZ) /* try to read more */
53 | return n; /* no more input; return number of missing bytes */
54 | else {
55 | z->n++; /* luaZ_fill consumed first byte; put it back */
56 | z->p--;
57 | }
58 | }
59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
60 | memcpy(b, z->p, m);
61 | z->n -= m;
62 | z->p += m;
63 | b = (char *)b + m;
64 | n -= m;
65 | }
66 | return 0;
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/TryDynSubNet.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "stdafx.h"
3 |
4 | #pragma comment(lib, "CppFBPCore")
5 | #pragma comment(lib, "CppFBPComponents")
6 |
7 |
8 | #include "thxdef.h"
9 |
10 |
11 | #define FILE struct _iobuf
12 |
13 | /* This is not the THREADS internal structure - this
14 | is a structured representation of the free-form connection list
15 | */
16 | void CppFBP(label_ent* label_blk, bool dynam, FILE * fp, bool timereq);
17 |
18 | THRCOMP ThFileWt(_anchor anch);
19 | //THRCOMP InfQueue(_anchor anch);
20 | THRCOMP ThFileRd(_anchor anch);
21 |
22 | int cap = 2;
23 | int elem0 = 0;
24 | /*
25 | This test case loads InfQueue dynamically from the TestNetworks.dll, and then runs it under the "Copy" process
26 | */
27 |
28 | proc_ent P0 = {NULL, "Read", "ThFileRd", ThFileRd, NULL, NULL, !TRACE, !COMPOS};
29 | proc_ent P1 = {&P0, "Write", "ThFileWt", ThFileWt, NULL, NULL, !TRACE, !COMPOS};
30 | proc_ent P2 = {&P1, "Copy", "InfQueue", NULL, NULL, NULL, !TRACE, COMPOS};
31 |
32 | IIP I0 = {"..\\..\\TestData\\POMPIERS.FIL"};
33 | IIP I1 = {"..\\..\\TestData\\output.fil"};
34 | cnxt_ent C0 = {NULL, "!", "", 0, "Read", "OPT", elem0, &I0, 0};
35 | cnxt_ent C1 = {&C0, "Read", "OUT", elem0, "Copy", "IN", elem0, NULL, cap};
36 | cnxt_ent C2 = {&C1, "!", "", 0, "Write", "OPT", elem0, &I1, 0};
37 | cnxt_ent C3 = {&C2, "Copy", "OUT", elem0, "Write", "IN", elem0, NULL, cap};
38 |
39 |
40 | label_ent LABELTAB = {NULL, " ", "", &C3, &P2, 'L'};
41 |
42 |
43 | void main() {
44 | CppFBP(&LABELTAB, !DYNAM, NULL, TIME_REQ); // time required
45 | //printf("Press enter\n");
46 | //char c; std::cin>>c; // to see console
47 | //system("pause"); // to see console
48 | }
49 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lzio.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lzio_h
9 | #define lzio_h
10 |
11 | #include "lua.h"
12 |
13 | #include "lmem.h"
14 |
15 |
16 | #define EOZ (-1) /* end of stream */
17 |
18 | typedef struct Zio ZIO;
19 |
20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
21 |
22 |
23 | typedef struct Mbuffer {
24 | char *buffer;
25 | size_t n;
26 | size_t buffsize;
27 | } Mbuffer;
28 |
29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
30 |
31 | #define luaZ_buffer(buff) ((buff)->buffer)
32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize)
33 | #define luaZ_bufflen(buff) ((buff)->n)
34 |
35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i))
36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0)
37 |
38 |
39 | #define luaZ_resizebuffer(L, buff, size) \
40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
41 | (buff)->buffsize, size), \
42 | (buff)->buffsize = size)
43 |
44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
45 |
46 |
47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
48 | void *data);
49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */
50 |
51 |
52 |
53 | /* --------- Private Part ------------------ */
54 |
55 | struct Zio {
56 | size_t n; /* bytes still unread */
57 | const char *p; /* current position in buffer */
58 | lua_Reader reader; /* reader function */
59 | void *data; /* additional data */
60 | lua_State *L; /* Lua state (for reader) */
61 | };
62 |
63 |
64 | LUAI_FUNC int luaZ_fill (ZIO *z);
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lfunc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $
3 | ** Auxiliary functions to manipulate prototypes and closures
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lfunc_h
8 | #define lfunc_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15 | cast(int, sizeof(TValue)*((n)-1)))
16 |
17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18 | cast(int, sizeof(TValue *)*((n)-1)))
19 |
20 |
21 | /* test whether thread is in 'twups' list */
22 | #define isintwups(L) (L->twups != L)
23 |
24 |
25 | /*
26 | ** maximum number of upvalues in a closure (both C and Lua). (Value
27 | ** must fit in a VM register.)
28 | */
29 | #define MAXUPVAL 255
30 |
31 |
32 | /*
33 | ** Upvalues for Lua closures
34 | */
35 | struct UpVal {
36 | TValue *v; /* points to stack or to its own value */
37 | lu_mem refcount; /* reference counter */
38 | union {
39 | struct { /* (when open) */
40 | UpVal *next; /* linked list */
41 | int touched; /* mark to avoid cycles with dead threads */
42 | } open;
43 | TValue value; /* the value (when closed) */
44 | } u;
45 | };
46 |
47 | #define upisopen(up) ((up)->v != &(up)->u.value)
48 |
49 |
50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L);
51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level);
56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
58 | int pc);
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThFileWt.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 |
3 | #include "StdAfx.h"
4 | #include
5 | #include "compsvcs.h"
6 | /* THFILEWT writes incoming entities to the file named on port OPT and
7 | optionally passes the entities on to an output stream.
8 | CALLING THFILEWT:
9 | "filename.ext" -> OPT write_ents(THFILEWT),
10 | input data stream -> IN write_ents [ OUT -> output data stream ];
11 | LIMITATIONS:
12 | Any special characters which cause problems for C's PUTC will not
13 | be written properly.
14 | DEFAULTS:
15 | None
16 | */
17 |
18 | //#include
19 | #include
20 |
21 |
22 | THRCOMP ThFileWt(_anchor proc_anchor) {
23 |
24 |
25 | void *ptr;
26 | char *dptr;
27 | int value, i;
28 | long size;
29 | char *type;
30 | char fname[256];
31 | int ch;
32 | port_ent port_tab[3];
33 | FILE *fp;
34 | //char buffer[256];
35 |
36 |
37 | value = dfsdfpt(proc_anchor, 3, port_tab, "OPT", "IN", "OUT");
38 |
39 | /*obtain filename parameter
40 | */
41 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
42 | memcpy(fname, ptr, size);
43 | value = dfsdrop(proc_anchor, &ptr);
44 | fname[size] = '\0';
45 | #ifdef WIN32
46 | errno_t err;
47 | if ((err = fopen_s(&fp, fname, "w")) != 0) {
48 | #else
49 | if ((f = fopen(fname, "w")) == NULL) {
50 | #endif
51 | fprintf(stderr, "Cannot open file %s!\n", fname);
52 | return(8);
53 | }
54 |
55 | value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
56 | while (value == 0)
57 | {
58 | dptr = (char *)ptr;
59 | for (i = 0; i < size; i++) {
60 | ch = (int)* (dptr + i);
61 | value = fputc(ch, fp);
62 | }
63 | value = fputc('\n', fp);
64 |
65 | value = dfssend(proc_anchor, &ptr, &port_tab[2], 0);
66 | if (value == 2)
67 | value = dfsdrop(proc_anchor, &ptr);
68 | value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
69 | }
70 | fclose(fp);
71 | return(0);
72 | }
73 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thzclos.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | #include
4 | //#include
5 | #include
6 | #include "thzcbs.h"
7 | #include "cppfbp.h"
8 | #define FALSE 0
9 | #define TRUE 1
10 | #define INPUT 0
11 | #define OUTPUT 1
12 |
13 | void extern thziclos(Process *proc, Port * cpp, int elem_no);
14 |
15 | int thzclos(Process *proc, port_ent *peptr, int elem_no);
16 |
17 | int thzclosc(Process *proc, char * port ){
18 | int elem_no = 0;
19 | char port_name[100];
20 | char * p = strchr(port, '[');
21 | char * q;
22 | port_ent pe;
23 |
24 | if (p == 0)
25 | strcpy_s (port_name, port);
26 | else {
27 | q = strchr(p, ']');
28 | auto n = q - p - 1;
29 | char no[10];
30 | strncpy_s(no, p + 1, n);
31 | elem_no = atoi(no);
32 | char * r = port;
33 | strncpy_s (port_name, port, p - r);
34 | port_name[p - r] = '\0';
35 | }
36 |
37 | //port_ent* pe = (port_ent *) malloc(sizeof(port_ent));
38 |
39 | strcpy_s(pe.port_name, port_name);
40 | Port * cpp = proc -> in_ports;
41 | while (cpp != 0)
42 | {
43 |
44 | if (0 == strcmp(cpp -> port_name, port_name)){
45 | break;
46 | }
47 |
48 | cpp = cpp -> succ;
49 | }
50 | pe.cpptr = cpp;
51 | pe.elem_count = cpp -> elem_count;
52 | pe.ret_code = 0;
53 |
54 | int value = thzclos(proc, &pe, elem_no);
55 |
56 | //free (pe);
57 | return value;
58 | }
59 |
60 | int thzclos(Process *proc, port_ent *peptr, int elem_no)
61 | {
62 | //Process *sptr;
63 | Port *cpp;
64 | //Cnxt *cnp;
65 | //IPh *IPptr;
66 | //IPh *nextIP;
67 |
68 | cpp = (Port *)peptr -> cpptr;
69 | if (peptr -> ret_code == 2)
70 | return(2);
71 |
72 | if (cpp -> elem_list[elem_no].closed)
73 | return(1);
74 |
75 | if (proc->trace) MSG1("%s Close\n",proc -> procname);
76 |
77 | thziclos(proc, cpp, elem_no);
78 |
79 |
80 | cpp -> elem_list[elem_no].closed = TRUE;
81 |
82 | if (proc->trace) MSG1("%s Close end\n", proc -> procname);
83 | return(0);
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/CppFBPLua/src/linit.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $
3 | ** Initialization of libraries for lua.c and other clients
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #define linit_c
9 | #define LUA_LIB
10 |
11 | /*
12 | ** If you embed Lua in your program and need to open the standard
13 | ** libraries, call luaL_openlibs in your program. If you need a
14 | ** different set of libraries, copy this file to your project and edit
15 | ** it to suit your needs.
16 | **
17 | ** You can also *preload* libraries, so that a later 'require' can
18 | ** open the library, which is already linked to the application.
19 | ** For that, do the following code:
20 | **
21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
22 | ** lua_pushcfunction(L, luaopen_modname);
23 | ** lua_setfield(L, -2, modname);
24 | ** lua_pop(L, 1); // remove _PRELOAD table
25 | */
26 |
27 | #include "lprefix.h"
28 |
29 |
30 | #include
31 |
32 | #include "lua.h"
33 |
34 | #include "lualib.h"
35 | #include "lauxlib.h"
36 |
37 |
38 | /*
39 | ** these libs are loaded by lua.c and are readily available to any Lua
40 | ** program
41 | */
42 | static const luaL_Reg loadedlibs[] = {
43 | {"_G", luaopen_base},
44 | {LUA_LOADLIBNAME, luaopen_package},
45 | {LUA_COLIBNAME, luaopen_coroutine},
46 | {LUA_TABLIBNAME, luaopen_table},
47 | {LUA_IOLIBNAME, luaopen_io},
48 | {LUA_OSLIBNAME, luaopen_os},
49 | {LUA_STRLIBNAME, luaopen_string},
50 | {LUA_MATHLIBNAME, luaopen_math},
51 | {LUA_UTF8LIBNAME, luaopen_utf8},
52 | {LUA_DBLIBNAME, luaopen_debug},
53 | #if defined(LUA_COMPAT_BITLIB)
54 | {LUA_BITLIBNAME, luaopen_bit32},
55 | #endif
56 | {NULL, NULL}
57 | };
58 |
59 |
60 | LUALIB_API void luaL_openlibs (lua_State *L) {
61 | const luaL_Reg *lib;
62 | /* "require" functions from 'loadedlibs' and set results to global table */
63 | for (lib = loadedlibs; lib->func; lib++) {
64 | luaL_requiref(L, lib->name, lib->func, 1);
65 | lua_pop(L, 1); /* remove lib */
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/CppFBPCore/Headers/thxdef.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | /*
4 | external control blocks - used in network definitions
5 | */
6 |
7 | //#ifndef THXANCH
8 | //#define THXANCH
9 | #include "thxanch.h"
10 | //#endif
11 |
12 |
13 | //typedef int (__stdcall *LPFNDLLFUNC) (_anchor anch);
14 | typedef __declspec(dllimport) int (*LPFNDLLFUNC) (_anchor anch);
15 | //#define THRCOMP __declspec(dllexport) int __stdcall
16 | #define THRCOMP extern "C" __declspec(dllexport) int
17 |
18 |
19 | struct _IIP
20 | {
21 | char datapart[32767];
22 | };
23 |
24 | typedef _IIP IIP;
25 |
26 |
27 | struct _proc_ent {
28 | _proc_ent *succ;
29 | char proc_name[32];
30 | char comp_name[200];
31 |
32 | //int32_t (__stdcall *faddr) (_anchor anch);
33 | LPFNDLLFUNC faddr;
34 |
35 | void *proc_block; // used as a temporary placeholder by thxbnet
36 | void * label_ptr; // points to a label for subnets
37 | bool trace;
38 | bool composite;
39 | bool must_run; // new - doesn't seem to hurt, even when CopyFile not modified!
40 | };
41 |
42 | typedef _proc_ent proc_ent;
43 |
44 | class Cnxt;
45 | struct _cnxt_ent {
46 | _cnxt_ent *succ;
47 | char upstream_name[32]; /* if 1st char is !, */
48 | char upstream_port_name[32]; /* connxn points at IIP */
49 | int upstream_elem_no;
50 | char downstream_name[32];
51 | char downstream_port_name[32];
52 | int downstream_elem_no;
53 | union cnxt_union {IIP * IIPptr; Cnxt *connxn;} gen;
54 | int capacity;
55 | bool dropOldest; // new - doesn't seem to hurt, even when CopyFile not modified!
56 | };
57 |
58 | typedef _cnxt_ent cnxt_ent;
59 |
60 | struct _label_ent {
61 | _label_ent *succ;
62 | char label[32];
63 | char file[10];
64 | _cnxt_ent *cnxt_ptr;
65 | _proc_ent *proc_ptr;
66 | char ent_type;
67 | };
68 |
69 | typedef _label_ent label_ent;
70 |
71 | #define THXDEF
72 | #define TRACE true
73 | #define COMPOS true
74 | #define DYNAM true
75 | #define TIME_REQ true
76 |
--------------------------------------------------------------------------------
/CppFBPLua/src/ltm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltm_h
8 | #define ltm_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | /*
15 | * WARNING: if you change the order of this enumeration,
16 | * grep "ORDER TM" and "ORDER OP"
17 | */
18 | typedef enum {
19 | TM_INDEX,
20 | TM_NEWINDEX,
21 | TM_GC,
22 | TM_MODE,
23 | TM_LEN,
24 | TM_EQ, /* last tag method with fast access */
25 | TM_ADD,
26 | TM_SUB,
27 | TM_MUL,
28 | TM_MOD,
29 | TM_POW,
30 | TM_DIV,
31 | TM_IDIV,
32 | TM_BAND,
33 | TM_BOR,
34 | TM_BXOR,
35 | TM_SHL,
36 | TM_SHR,
37 | TM_UNM,
38 | TM_BNOT,
39 | TM_LT,
40 | TM_LE,
41 | TM_CONCAT,
42 | TM_CALL,
43 | TM_N /* number of elements in the enum */
44 | } TMS;
45 |
46 |
47 |
48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
50 |
51 | #define fasttm(l,et,e) gfasttm(G(l), et, e)
52 |
53 | #define ttypename(x) luaT_typenames_[(x) + 1]
54 | #define objtypename(x) ttypename(ttnov(x))
55 |
56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
57 |
58 |
59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
61 | TMS event);
62 | LUAI_FUNC void luaT_init (lua_State *L);
63 |
64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
65 | const TValue *p2, TValue *p3, int hasres);
66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
67 | StkId res, TMS event);
68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
69 | StkId res, TMS event);
70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
71 | const TValue *p2, TMS event);
72 |
73 |
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/CppFBPLua/src/ltable.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 roberto Exp $
3 | ** Lua tables (hash)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltable_h
8 | #define ltable_h
9 |
10 | #include "lobject.h"
11 |
12 |
13 | #define gnode(t,i) (&(t)->node[i])
14 | #define gval(n) (&(n)->i_val)
15 | #define gnext(n) ((n)->i_key.nk.next)
16 |
17 |
18 | /* 'const' to avoid wrong writings that can mess up field 'next' */
19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk))
20 |
21 | /*
22 | ** writable version of 'gkey'; allows updates to individual fields,
23 | ** but not to the whole (which has incompatible type)
24 | */
25 | #define wgkey(n) (&(n)->i_key.nk)
26 |
27 | #define invalidateTMcache(t) ((t)->flags = 0)
28 |
29 |
30 | /* returns the key, given the value of a table entry */
31 | #define keyfromval(v) \
32 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
33 |
34 |
35 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
36 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
37 | TValue *value);
38 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
39 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
40 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
41 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
42 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
43 | LUAI_FUNC Table *luaH_new (lua_State *L);
44 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
45 | unsigned int nhsize);
46 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
47 | LUAI_FUNC void luaH_free (lua_State *L, Table *t);
48 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
49 | LUAI_FUNC int luaH_getn (Table *t);
50 |
51 |
52 | #if defined(LUA_DEBUG)
53 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
54 | LUAI_FUNC int luaH_isdummy (Node *n);
55 | #endif
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest3/TimingTest3.cpp:
--------------------------------------------------------------------------------
1 | #pragma comment(lib, "CppFBPCore")
2 | #pragma comment(lib, "CppFBPComponents")
3 |
4 | // TimingTest3.cpp : TimingTest1 with subnets
5 |
6 | #include "thxdef.h"
7 |
8 | #include
9 | #define FILE struct _iobuf
10 |
11 | /* This is not the THREADS internal structure - this
12 | is a structured representation of the free-form connection list
13 | */
14 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
15 |
16 | THRCOMP ThGenIps(_anchor anch);
17 | THRCOMP ThDrop(_anchor anch);
18 |
19 | proc_ent P00 = {0, "Gen0", "ThGenIps", ThGenIps, 0, 0, 0, 0};
20 | proc_ent P01 = {&P00, "Drop0", "ThDrop", ThDrop, 0, 0, 0, 0};
21 | IIP I00 = {"1000000"};
22 | cnxt_ent C00 = {0, "!", "", 0, "Gen0", "COUNT", 0, &I00, 0};
23 | cnxt_ent C01 = {&C00, "Gen0", "OUT", 0, "Drop0", "IN", 0, 0, 50};
24 |
25 | proc_ent P10 = {&P01, "Gen1", "ThGenIps", ThGenIps, 0, 0, 0, 0};
26 | proc_ent P11 = {&P10, "Drop1", "ThDrop", ThDrop, 0, 0, 0, 0};
27 | IIP I10 = {"1000000"};
28 | cnxt_ent C10 = {&C01, "!", "", 0, "Gen1", "COUNT", 0, &I10, 0};
29 | cnxt_ent C11 = {&C10, "Gen1", "OUT", 0, "Drop1", "IN", 0, 0, 50};
30 |
31 | proc_ent P20 = {&P11, "Gen2", "ThGenIps", ThGenIps, 0, 0, 0, 0};
32 | proc_ent P21 = {&P20, "Drop2", "ThDrop", ThDrop, 0, 0, 0, 0};
33 | IIP I20 = {"1000000"};
34 | cnxt_ent C20 = {&C11, "!", "", 0, "Gen2", "COUNT", 0, &I20, 0};
35 | cnxt_ent C21 = {&C20, "Gen2", "OUT", 0, "Drop2", "IN", 0, 0, 50};
36 |
37 | proc_ent P30 = {&P21, "Gen3", "ThGenIps", ThGenIps, 0, 0, 0, 0};
38 | proc_ent P31 = {&P30, "Drop3", "ThDrop", ThDrop, 0, 0, 0, 0};
39 | IIP I30 = {"1000000"};
40 | cnxt_ent C30 = {&C21, "!", "", 0, "Gen3", "COUNT", 0, &I30, 0};
41 | cnxt_ent C31 = {&C30, "Gen3", "OUT", 0, "Drop3", "IN", 0, 0, 50};
42 |
43 | proc_ent P40 = {&P31, "Gen4", "ThGenIps", ThGenIps, 0, 0, 0, 0};
44 | proc_ent P41 = {&P40, "Drop4", "ThDrop", ThDrop, 0, 0, 0, 0};
45 | IIP I40 = {"1000000"};
46 | cnxt_ent C40 = {&C31, "!", "", 0, "Gen4", "COUNT", 0, &I40, 0};
47 | cnxt_ent C41 = {&C40, "Gen4", "OUT", 0, "Drop4", "IN", 0, 0, 50};
48 |
49 |
50 | label_ent LABELTAB = {0, " ", "", &C41, &P41, 'L'};
51 |
52 | void main() {
53 | CppFBP(&LABELTAB, 0, 0, 1); // time required
54 | }
55 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThFileRd.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 |
3 | /* THFILERD is a DOS file reader. It accepts a filename as an input on port
4 | OPT, reads the file, and for every record puts out an entity on
5 | port OUT.
6 | CALLING THFILERD:
7 | 'FILENAME.EXT' -> OPT read_input_file OUT -> output data stream,
8 | read_input_file(THFILERD);
9 | LIMITATIONS:
10 | FILENAME is limited to 256 bytes including extension. (this is less
11 | restrictive than DOS, so will not matter.
12 | Input records must be less than 4096 bytes or they will be segmented.
13 | If they are segmented it may be difficult to re-assemble them.
14 | DEFAULTS:
15 | NONE. The filename is required. A message will be produced if it is
16 | not given.
17 | */
18 | #include "StdAfx.h"
19 |
20 | //#include
21 | #include
22 | #include
23 | #include "compsvcs.h"
24 |
25 | THRCOMP ThFileRd(_anchor proc_anchor) {
26 |
27 |
28 | void *ptr;
29 | char fname[256];
30 | char string[4096];
31 | int value;
32 | long size;
33 | char *type;
34 | size_t len;
35 | port_ent port_tab[2];
36 | FILE *fp;
37 |
38 | value = dfsdfpt(proc_anchor, 2, port_tab, "OPT", "OUT");
39 |
40 | /* read in the filename and open the input file
41 | */
42 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
43 | memcpy(fname, ptr, size);
44 | fname[size] = '\0';
45 |
46 | #ifdef WIN32
47 | errno_t err;
48 | if ((err = fopen_s(&fp, fname, "r")) != 0) {
49 | #else
50 | if ((f = fopen(fname, "r")) == NULL) {
51 | #endif
52 | fprintf(stderr, "Cannot open file %s!\n", fname);
53 | return(8);
54 | }
55 | value = dfsdrop(proc_anchor, &ptr);
56 |
57 | /* read records from the input file and create entities from them. If the
58 | input records are longer than 4096 bytes, they will be segmented and put out
59 | as a series of 4096 byte IPs.
60 | */
61 | while ((fgets(string, 4096, fp)) != NULL) {
62 | len = strlen(string);
63 | if (string[len - 1] == '\n')
64 | len = len - 1;
65 | value = dfscrep(proc_anchor, &ptr, static_cast(len), "A");
66 | memcpy(ptr, string, len);
67 | value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
68 | }
69 | fclose(fp);
70 | return(0);
71 | }
72 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lctype.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $
3 | ** 'ctype' functions for Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lctype_h
8 | #define lctype_h
9 |
10 | #include "lua.h"
11 |
12 |
13 | /*
14 | ** WARNING: the functions defined here do not necessarily correspond
15 | ** to the similar functions in the standard C ctype.h. They are
16 | ** optimized for the specific needs of Lua
17 | */
18 |
19 | #if !defined(LUA_USE_CTYPE)
20 |
21 | #if 'A' == 65 && '0' == 48
22 | /* ASCII case: can use its own tables; faster and fixed */
23 | #define LUA_USE_CTYPE 0
24 | #else
25 | /* must use standard C ctype */
26 | #define LUA_USE_CTYPE 1
27 | #endif
28 |
29 | #endif
30 |
31 |
32 | #if !LUA_USE_CTYPE /* { */
33 |
34 | #include
35 |
36 | #include "llimits.h"
37 |
38 |
39 | #define ALPHABIT 0
40 | #define DIGITBIT 1
41 | #define PRINTBIT 2
42 | #define SPACEBIT 3
43 | #define XDIGITBIT 4
44 |
45 |
46 | #define MASK(B) (1 << (B))
47 |
48 |
49 | /*
50 | ** add 1 to char to allow index -1 (EOZ)
51 | */
52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p))
53 |
54 | /*
55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
56 | */
57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT))
58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT))
60 | #define lisspace(c) testprop(c, MASK(SPACEBIT))
61 | #define lisprint(c) testprop(c, MASK(PRINTBIT))
62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
63 |
64 | /*
65 | ** this 'ltolower' only works for alphabetic characters
66 | */
67 | #define ltolower(c) ((c) | ('A' ^ 'a'))
68 |
69 |
70 | /* two more entries for 0 and -1 (EOZ) */
71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
72 |
73 |
74 | #else /* }{ */
75 |
76 | /*
77 | ** use standard C ctypes
78 | */
79 |
80 | #include
81 |
82 |
83 | #define lislalpha(c) (isalpha(c) || (c) == '_')
84 | #define lislalnum(c) (isalnum(c) || (c) == '_')
85 | #define lisdigit(c) (isdigit(c))
86 | #define lisspace(c) (isspace(c))
87 | #define lisprint(c) (isprint(c))
88 | #define lisxdigit(c) (isxdigit(c))
89 |
90 | #define ltolower(c) (tolower(c))
91 |
92 | #endif /* } */
93 |
94 | #endif
95 |
96 |
--------------------------------------------------------------------------------
/CppFBPComponents/Components/ThSort.cpp:
--------------------------------------------------------------------------------
1 | //#pragma comment(lib, "CppFBPCore")
2 | #include "StdAfx.h"
3 |
4 | /* THSORT is a simple Sort.
5 |
6 | CALLING THSORT:
7 | input data stream -> IN sort(THSORT) OUT -> output data stream ;
8 |
9 | LIMITATIONS:
10 | This component will just do a simple compare on the contents of the incoming IPs.
11 | For simplicity, it will handle a maximum of 2000 IPs.
12 | DEFAULTS:
13 | None
14 |
15 | */
16 |
17 | //#include
18 | #include
19 | #include
20 | #include "compsvcs.h"
21 |
22 | THRCOMP ThSort (_anchor proc_anchor) {
23 | void *ptr;
24 | void *dptrm, *dptr;
25 | char * cptrm, *cptr;
26 | int value, i;
27 | long size;
28 | char *type;
29 | port_ent port_tab[2];
30 | void** sort_tab;
31 | int count, lowest;
32 | bool first;
33 | bool finished = false;
34 | long m, n, k;
35 |
36 | sort_tab = new void*[2000];
37 | for (i = 0; i < 2000; i++)
38 | sort_tab[i] = 0;
39 | value = dfsdfpt(proc_anchor, 2, port_tab,"IN","OUT");
40 | i = 0;
41 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
42 | while (value == 0) {
43 | sort_tab[i] = (unsigned char *) ptr;
44 | i++;
45 | value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
46 | }
47 | count = i;
48 | value = dfstest(proc_anchor);
49 | lowest = 0;
50 | for (;;) {
51 | finished = true;
52 | first = true;
53 | for (i = 0; i < count; i++) {
54 | if (sort_tab[i] != 0) {
55 | finished = false;
56 | dptr = sort_tab[i];
57 | if (first) {
58 | dptrm = dptr;
59 | first = false;
60 | lowest = i;
61 | m = dfsgsize(proc_anchor, &dptrm);
62 | }
63 | else {
64 | n = dfsgsize(proc_anchor, &dptr);
65 | k = n;
66 | if (n > m)
67 | k = m;
68 | cptrm = (char *) dptrm;
69 | cptr = (char *) dptr;
70 | if (memcmp(dptrm, dptr, k) > 0) {
71 | dptrm = dptr;
72 | lowest = i;
73 | }
74 | else if (memcmp(dptrm, dptr, k) == 0 && m > n) {
75 | dptrm = dptr;
76 | lowest = i;
77 | }
78 | }
79 | }
80 | }
81 | if (finished)
82 | break;
83 | ptr = sort_tab[lowest];
84 | sort_tab[lowest] = 0;
85 | value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
86 | }
87 |
88 | return(0);
89 | }
--------------------------------------------------------------------------------
/CppFBPLua/src/ldo.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldo.h,v 2.28 2015/11/23 11:29:43 roberto Exp $
3 | ** Stack and Call structure of Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldo_h
8 | #define ldo_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 | #include "lzio.h"
14 |
15 |
16 | /*
17 | ** Macro to check stack size and grow stack if needed. Parameters
18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the
19 | ** stack across reallocations, doing the work only when needed.
20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation
21 | ** at every check.
22 | */
23 | #define luaD_checkstackaux(L,n,pre,pos) \
24 | if (L->stack_last - L->top <= (n)) \
25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); }
26 |
27 | /* In general, 'pre'/'pos' are empty (nothing to save) */
28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,,)
29 |
30 |
31 |
32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack)
33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
34 |
35 |
36 | /* type of protected functions, to be ran by 'runprotected' */
37 | typedef void (*Pfunc) (lua_State *L, void *ud);
38 |
39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
40 | const char *mode);
41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
46 | ptrdiff_t oldtop, ptrdiff_t ef);
47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
48 | int nres);
49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n);
51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L);
52 | LUAI_FUNC void luaD_inctop (lua_State *L);
53 |
54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
56 |
57 | #endif
58 |
59 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest1/TimingTest1.cpp:
--------------------------------------------------------------------------------
1 | #pragma comment(lib, "CppFBPCore")
2 |
3 |
4 | #pragma comment(lib, "CppFBPComponents")
5 |
6 |
7 |
8 | // TimingTest1.cpp : Defines the entry point for the console application.
9 | #include "thxdef.h"
10 |
11 | #include
12 | #define FILE struct _iobuf
13 |
14 | /*
15 | This is not the THREADS internal structure - this
16 | is a structured representation of the free-form connection list
17 | */
18 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
19 |
20 | THRCOMP ThGenIps(_anchor anch);
21 | THRCOMP ThDrop(_anchor anch);
22 |
23 | proc_ent P00 = {0, "Gen0", "ThGenIps", ThGenIps, 0, 0, !TRACE, 0};
24 | proc_ent P01 = {&P00, "Drop0", "ThDrop", ThDrop, 0, 0, !TRACE, 0};
25 | IIP I00 = {"1000000"};
26 | cnxt_ent C00 = {0, "!", "", 0, "Gen0", "COUNT", 0, &I00, 0};
27 | cnxt_ent C01 = {&C00, "Gen0", "OUT", 0, "Drop0", "IN", 0, 0, 50};
28 |
29 | proc_ent P10 = {&P01, "Gen1", "ThGenIps", ThGenIps, 0, 0, !TRACE, 0};
30 | proc_ent P11 = {&P10, "Drop1", "ThDrop", ThDrop, 0, 0, !TRACE, 0};
31 | IIP I10 = {"1000000"};
32 | cnxt_ent C10 = {&C01, "!", "", 0, "Gen1", "COUNT", 0, &I10, 0};
33 | cnxt_ent C11 = {&C10, "Gen1", "OUT", 0, "Drop1", "IN", 0, 0, 50};
34 |
35 | proc_ent P20 = {&P11, "Gen2", "ThGenIps", ThGenIps, 0, 0, !TRACE, 0};
36 | proc_ent P21 = {&P20, "Drop2", "ThDrop", ThDrop, 0, 0, !TRACE, 0};
37 | IIP I20 = {"1000000"};
38 | cnxt_ent C20 = {&C11, "!", "", 0, "Gen2", "COUNT", 0, &I20, 0};
39 | cnxt_ent C21 = {&C20, "Gen2", "OUT", 0, "Drop2", "IN", 0, 0, 50};
40 |
41 | proc_ent P30 = {&P21, "Gen3", "ThGenIps", ThGenIps, 0, 0, !TRACE, 0};
42 | proc_ent P31 = {&P30, "Drop3", "ThDrop", ThDrop, 0, 0, !TRACE, 0};
43 | IIP I30 = {"1000000"};
44 | cnxt_ent C30 = {&C21, "!", "", 0, "Gen3", "COUNT", 0, &I30, 0};
45 | cnxt_ent C31 = {&C30, "Gen3", "OUT", 0, "Drop3", "IN", 0, 0, 50};
46 |
47 | proc_ent P40 = {&P31, "Gen4", "ThGenIps", ThGenIps, 0, 0, !TRACE, 0};
48 | proc_ent P41 = {&P40, "Drop4", "ThDrop", ThDrop, 0, 0, !TRACE, 0};
49 | IIP I40 = {"1000000"};
50 | cnxt_ent C40 = {&C31, "!", "", 0, "Gen4", "COUNT", 0, &I40, 0};
51 | cnxt_ent C41 = {&C40, "Gen4", "OUT", 0, "Drop4", "IN", 0, 0, 50};
52 |
53 |
54 | label_ent LABELTAB = {0, " ", "", &C41, &P41, 'L'};
55 |
56 |
57 | void main() {
58 | CppFBP(&LABELTAB, 0, 0, 1); // time required
59 | }
60 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $
3 | ** 'ctype' functions for Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lctype_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include "lctype.h"
14 |
15 | #if !LUA_USE_CTYPE /* { */
16 |
17 | #include
18 |
19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
20 | 0x00, /* EOZ */
21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */
38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */
40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */
42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */
44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */
46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */
48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */
50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */
52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 | };
54 |
55 | #endif /* } */
56 |
--------------------------------------------------------------------------------
/CppFBPLua/src/llex.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $
3 | ** Lexical Analyzer
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef llex_h
8 | #define llex_h
9 |
10 | #include "lobject.h"
11 | #include "lzio.h"
12 |
13 |
14 | #define FIRST_RESERVED 257
15 |
16 |
17 | #if !defined(LUA_ENV)
18 | #define LUA_ENV "_ENV"
19 | #endif
20 |
21 |
22 | /*
23 | * WARNING: if you change the order of this enumeration,
24 | * grep "ORDER RESERVED"
25 | */
26 | enum RESERVED {
27 | /* terminal symbols denoted by reserved words */
28 | TK_AND = FIRST_RESERVED, TK_BREAK,
29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
32 | /* other terminal symbols */
33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE,
34 | TK_SHL, TK_SHR,
35 | TK_DBCOLON, TK_EOS,
36 | TK_FLT, TK_INT, TK_NAME, TK_STRING
37 | };
38 |
39 | /* number of reserved words */
40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
41 |
42 |
43 | typedef union {
44 | lua_Number r;
45 | lua_Integer i;
46 | TString *ts;
47 | } SemInfo; /* semantics information */
48 |
49 |
50 | typedef struct Token {
51 | int token;
52 | SemInfo seminfo;
53 | } Token;
54 |
55 |
56 | /* state of the lexer plus state of the parser when shared by all
57 | functions */
58 | typedef struct LexState {
59 | int current; /* current character (charint) */
60 | int linenumber; /* input line counter */
61 | int lastline; /* line of last token 'consumed' */
62 | Token t; /* current token */
63 | Token lookahead; /* look ahead token */
64 | struct FuncState *fs; /* current function (parser) */
65 | struct lua_State *L;
66 | ZIO *z; /* input stream */
67 | Mbuffer *buff; /* buffer for tokens */
68 | Table *h; /* to avoid collection/reuse strings */
69 | struct Dyndata *dyd; /* dynamic structures used by the parser */
70 | TString *source; /* current source name */
71 | TString *envn; /* environment variable name */
72 | char decpoint; /* locale decimal point */
73 | } LexState;
74 |
75 |
76 | LUAI_FUNC void luaX_init (lua_State *L);
77 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
78 | TString *source, int firstchar);
79 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
80 | LUAI_FUNC void luaX_next (LexState *ls);
81 | LUAI_FUNC int luaX_lookahead (LexState *ls);
82 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
83 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
84 |
85 |
86 | #endif
87 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lmem.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lmem_h
8 | #define lmem_h
9 |
10 |
11 | #include
12 |
13 | #include "llimits.h"
14 | #include "lua.h"
15 |
16 |
17 | /*
18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where
19 | ** each element has size 'e'. In case of arithmetic overflow of the
20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because
21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e).
22 | **
23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof'
24 | ** comparison avoids a runtime comparison when overflow cannot occur.
25 | ** The compiler should be able to optimize the real test by itself, but
26 | ** when it does it, it may give a warning about "comparison is always
27 | ** false due to limited range of data type"; the +1 tricks the compiler,
28 | ** avoiding this warning but also this optimization.)
29 | */
30 | #define luaM_reallocv(L,b,on,n,e) \
31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \
32 | ? luaM_toobig(L) : cast_void(0)) , \
33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
34 |
35 | /*
36 | ** Arrays of chars do not need any test
37 | */
38 | #define luaM_reallocvchar(L,b,on,n) \
39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char)))
40 |
41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)
44 |
45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s))
46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
47 | #define luaM_newvector(L,n,t) \
48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
49 |
50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s))
51 |
52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \
53 | if ((nelems)+1 > (size)) \
54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
55 |
56 | #define luaM_reallocvector(L, v,oldn,n,t) \
57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
58 |
59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L);
60 |
61 | /* not to be called directly */
62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
63 | size_t size);
64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
65 | size_t size_elem, int limit,
66 | const char *what);
67 |
68 | #endif
69 |
70 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thxgatrs.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | //#include
7 | #include "thzcbs.h"
8 | #include "cppfbp.h"
9 |
10 | #define TRUE 1
11 | #define FALSE 0
12 | //#define _CRT_SECURE_NO_WARNINGS
13 |
14 | #define TC(label,ch) if (curr_char != ch) goto label; \
15 | *o_ptr = curr_char; o_ptr++; \
16 | curr_char = getc(fp);
17 |
18 | #define TCO(label,ch) if (curr_char != ch) goto label; \
19 | curr_char = getc(fp);
20 |
21 | #define TA(label) if (!isalpha(curr_char)) goto label; \
22 | *o_ptr = curr_char; o_ptr++; \
23 | curr_char = getc(fp);
24 |
25 | #define TAO(label) if (!isalpha(curr_char)) goto label; \
26 | curr_char = getc(fp);
27 |
28 | #define TN(label) if (!isdigit(curr_char)) goto label; \
29 | *o_ptr = curr_char; o_ptr++; \
30 | curr_char = getc(fp);
31 |
32 | #define TNO(label) if (!isdigit(curr_char)) goto label; \
33 | curr_char = getc(fp);
34 |
35 | #define CC *o_ptr = curr_char; o_ptr++; \
36 | curr_char = getc(fp);
37 |
38 | #define SC curr_char = getc(fp);
39 |
40 | void scan_blanks(FILE *fp);
41 |
42 | extern char curr_char;
43 |
44 |
45 | int thxgatrs(char * comp) {
46 |
47 | char *o_ptr;
48 | char out_str[255];
49 | int atr = 0;
50 | char fname[256];
51 | FILE *fp = NULL;
52 |
53 | strcpy_s(fname,comp);
54 | strcat_s(fname,".atr");
55 | FILE* pFile;
56 | #ifdef WIN32
57 | fopen_s(&pFile, fname, "r");
58 | #else
59 | pFile = fopen(fname,"r");
60 | #endif
61 |
62 | if (pFile == NULL)
63 | return(-1);
64 |
65 | do {curr_char = getc(fp);} while (curr_char == '\n');
66 |
67 | o_ptr = out_str;
68 | scan_blanks(fp);
69 | TCO(nEOF,EOF);
70 | goto exit;
71 |
72 | nEOF: for (;;) {
73 | TA(nA);
74 | continue;
75 | nA: TN(nN);
76 | continue;
77 | nN: TC(nus,'_');
78 | continue;
79 | nus: break;
80 | }
81 | *o_ptr = '\0';
82 | if (strcmp(out_str,"MUST_RUN") == 0 ||
83 | strcmp(out_str,"Must_run") == 0 ||
84 | strcmp(out_str,"must_run") == 0)
85 | atr = TRUE;
86 | else
87 | atr = FALSE;
88 | scan_blanks(fp);
89 |
90 | exit: fclose(fp);
91 | return(atr);
92 | }
93 |
94 |
95 | void scan_blanks(FILE *fp)
96 | {
97 | for (;;) {
98 | TCO(not_blank,' ');
99 | continue;
100 | not_blank: TCO(exit,'\n');
101 | }
102 | exit: return;
103 | }
104 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thziclos.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 | #include
4 | //#include
5 | #include
6 | #include "thzcbs.h"
7 | #include "cppfbp.h"
8 | #define FALSE 0
9 | #define TRUE 1
10 | #define INPUT 0
11 | #define OUTPUT 1
12 |
13 |
14 |
15 | void thziclos(Process *pptr, Port * cpp, int elem_no)
16 | {
17 | Process *sptr;
18 | //Port *cpp;
19 | //Cnxt *cnp;
20 | IPh *IPptr;
21 | IPh *nextIP;
22 |
23 | //cpp = (cp *)peptr -> cpptr;
24 | //if (peptr -> ret_code == 2)
25 | // return(2);
26 |
27 | //if (cpp -> elem_list[elem_no].closed)
28 | // return(1);
29 |
30 | //if (pptr->trace) MSG1("%s Close\n",pptr -> procname);
31 |
32 | if (cpp -> elem_list[elem_no].is_IIP) {
33 | cpp -> elem_list[elem_no].closed = TRUE;
34 | return;
35 | }
36 |
37 | Cnxt * cnp = cpp -> elem_list[elem_no].gen.connxn;
38 |
39 | //int value = 0;
40 | boost::unique_lock lock (cnp -> mtx);
41 |
42 | if (cpp -> direction == INPUT) {
43 | // Closing an input port
44 | if (pptr->trace) MSG1("%s Close input\n",pptr -> procname);
45 | //Cnxt * cnp = cpp -> elem_list[elem_no].gen.connxn;
46 | if (cnp -> closed) {
47 | //value = 1;
48 | goto retn;
49 | }
50 |
51 | cnp -> nonterm_upstream_proc_count = 0;
52 | cnp -> closed = TRUE;
53 | //sptr = cnp -> procs_wtg_to_send;
54 | //while (sptr != 0) {
55 | //cnp -> procs_wtg_to_send = sptr -> next_proc;
56 |
57 | //sptr -> status = ACTIVE;
58 | //sptr = cnp -> procs_wtg_to_send;
59 | IPptr = cnp -> first_IPptr;
60 | while (IPptr != 0) {
61 | nextIP = IPptr -> next_IP;
62 | //thzfree(IPptr, pptr);
63 | free(IPptr);
64 | IPptr = nextIP;
65 | if (pptr -> trace)
66 | printf("%s IP discarded\n", pptr -> procname);
67 | }
68 | cnp -> first_IPptr = 0;
69 | cnp -> last_IPptr = 0;
70 | cnp -> IPcount = 0;
71 | cnp->buffer_not_full.notify_all();
72 | //}
73 |
74 | }
75 |
76 | else {
77 | // Closing an output port
78 | if (pptr->trace) MSG1("%s Close output\n",pptr -> procname);
79 | //Cnxt * cnp = cpp -> elem_list[elem_no].gen.connxn;
80 | cnp -> nonterm_upstream_proc_count--;
81 | sptr = cnp -> fed_proc;
82 | //term_now = TRUE;
83 | if (sptr -> begin_port != 0 &&
84 | sptr -> begin_port -> elem_list[0].gen.connxn == cnp) {
85 | cnp -> nonterm_upstream_proc_count = 0;
86 | //term_now = FALSE;
87 | }
88 |
89 | if (cnp -> nonterm_upstream_proc_count == 0) {
90 |
91 | cnp -> closed = TRUE;
92 | if (sptr -> status == NOT_STARTED || sptr -> status == DORMANT)
93 | sptr -> activate();
94 | else
95 | cnp->buffer_not_empty.notify_all();
96 | }
97 | }
98 |
99 | cpp -> elem_list[elem_no].closed = TRUE;
100 | lock.unlock();
101 | lock.~unique_lock();
102 | if (pptr->trace) MSG1("%s Close end\n", pptr -> procname);
103 |
104 | retn:
105 | return;
106 | }
107 |
108 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lmem.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lmem_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "ldebug.h"
18 | #include "ldo.h"
19 | #include "lgc.h"
20 | #include "lmem.h"
21 | #include "lobject.h"
22 | #include "lstate.h"
23 |
24 |
25 |
26 | /*
27 | ** About the realloc function:
28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
29 | ** ('osize' is the old size, 'nsize' is the new size)
30 | **
31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no
32 | ** matter 'x').
33 | **
34 | ** * frealloc(ud, p, x, 0) frees the block 'p'
35 | ** (in this specific case, frealloc must return NULL);
36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing
37 | ** (which is equivalent to free(NULL) in ISO C)
38 | **
39 | ** frealloc returns NULL if it cannot create or reallocate the area
40 | ** (any reallocation to an equal or smaller size cannot fail!)
41 | */
42 |
43 |
44 |
45 | #define MINSIZEARRAY 4
46 |
47 |
48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
49 | int limit, const char *what) {
50 | void *newblock;
51 | int newsize;
52 | if (*size >= limit/2) { /* cannot double it? */
53 | if (*size >= limit) /* cannot grow even a little? */
54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit);
55 | newsize = limit; /* still have at least one free place */
56 | }
57 | else {
58 | newsize = (*size)*2;
59 | if (newsize < MINSIZEARRAY)
60 | newsize = MINSIZEARRAY; /* minimum size */
61 | }
62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
63 | *size = newsize; /* update only when everything else is OK */
64 | return newblock;
65 | }
66 |
67 |
68 | l_noret luaM_toobig (lua_State *L) {
69 | luaG_runerror(L, "memory allocation error: block too big");
70 | }
71 |
72 |
73 |
74 | /*
75 | ** generic allocation routine.
76 | */
77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
78 | void *newblock;
79 | global_State *g = G(L);
80 | size_t realosize = (block) ? osize : 0;
81 | lua_assert((realosize == 0) == (block == NULL));
82 | #if defined(HARDMEMTESTS)
83 | if (nsize > realosize && g->gcrunning)
84 | luaC_fullgc(L, 1); /* force a GC whenever possible */
85 | #endif
86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize);
87 | if (newblock == NULL && nsize > 0) {
88 | lua_assert(nsize > realosize); /* cannot fail when shrinking a block */
89 | if (g->version) { /* is state fully built? */
90 | luaC_fullgc(L, 1); /* try to free some memory... */
91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
92 | }
93 | if (newblock == NULL)
94 | luaD_throw(L, LUA_ERRMEM);
95 | }
96 | lua_assert((nsize == 0) == (newblock == NULL));
97 | g->GCdebt = (g->GCdebt + nsize) - realosize;
98 | return newblock;
99 | }
100 |
101 |
--------------------------------------------------------------------------------
/TestNetworks/TimingTest2/TimingTest2.cpp:
--------------------------------------------------------------------------------
1 | #pragma comment(lib, "CppFBPCore")
2 | #pragma comment(lib, "CppFBPComponents")
3 |
4 | // TimingTest2.cpp : Defines the entry point for the console application.
5 |
6 | #include "thxdef.h"
7 | #include
8 |
9 | #define _CRTDBG_MAP_ALLOC
10 | #include
11 | #include
12 |
13 | /* This is not the THREADS internal structure - this
14 | is a structured representation of the free-form connection list
15 |
16 | Using fibres...
17 |
18 | This test case took 11 secs with 2,000,000 IPs, and connection capacity of 50;
19 | assuming create/destroy trivial, send/receive pair takes 110 nanoseconds
20 |
21 | Only uses one processor
22 |
23 | Using Boost...
24 |
25 | 25 secs - this suggests that send/receive is quite a bit slower!
26 |
27 | Uses all 4 processors
28 |
29 | However, there may be too few processes, so we will add 5 more, giving 11 processes, and see what happens...
30 | We still have 2,000,000 IPs, so 2,000,000 creates and destroys each, 10 sends and receives for each IP
31 |
32 | Took 18 secs - maybe 25 secs was bug! That seems much better - twice as many processes and not a lot more time...!
33 |
34 |
35 | */
36 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
37 |
38 | THRCOMP ThGenIps(_anchor anch);
39 | THRCOMP ThDrop(_anchor anch);
40 | THRCOMP ThPsThru(_anchor anch);
41 |
42 | bool NOTRACE = false;
43 |
44 | proc_ent P00 = {0, "Gen", "ThGenIps", ThGenIps, 0, 0, NOTRACE, 0};
45 | proc_ent P01 = {&P00, "Copy0", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0};
46 | proc_ent P02 = {&P01, "Copy1", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0};
47 | proc_ent P03 = {&P02, "Copy2", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0};
48 | proc_ent P04 = {&P03, "Copy3", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0};
49 | proc_ent P05 = {&P04, "Copy4", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0}; // added
50 | proc_ent P06 = {&P05, "Copy5", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0}; // added
51 | proc_ent P07 = {&P06, "Copy6", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0}; // added
52 | proc_ent P08 = {&P07, "Copy7", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0}; // added
53 | proc_ent P09 = {&P08, "Copy8", "ThPsThru", ThPsThru, 0, 0, NOTRACE, 0}; // added
54 | proc_ent P10 = {&P09, "Drop", "ThDrop", ThDrop, 0, 0, NOTRACE, 0};
55 | IIP I00 = {"2000000"}; // was 2000000
56 | cnxt_ent C00 = {0, "!", "", 0, "Gen", "COUNT", 0, &I00, 0};
57 | cnxt_ent C01 = {&C00, "Gen", "OUT", 0, "Copy0", "IN", 0, 0, 50};
58 | cnxt_ent C02 = {&C01, "Copy0", "OUT", 0, "Copy1", "IN", 0, 0, 50};
59 | cnxt_ent C03 = {&C02, "Copy1", "OUT", 0, "Copy2", "IN", 0, 0, 50};
60 | cnxt_ent C04 = {&C03, "Copy2", "OUT", 0, "Copy3", "IN", 0, 0, 50};
61 | cnxt_ent C05 = {&C04, "Copy3", "OUT", 0, "Copy4", "IN", 0, 0, 50};
62 | cnxt_ent C06 = {&C05, "Copy4", "OUT", 0, "Copy5", "IN", 0, 0, 50};
63 | cnxt_ent C07 = {&C06, "Copy5", "OUT", 0, "Copy6", "IN", 0, 0, 50};
64 | cnxt_ent C08 = {&C07, "Copy6", "OUT", 0, "Copy7", "IN", 0, 0, 50};
65 | cnxt_ent C09 = {&C08, "Copy7", "OUT", 0, "Copy8", "IN", 0, 0, 50};
66 | cnxt_ent C10 = {&C09, "Copy8", "OUT", 0, "Drop", "IN", 0, 0, 50};
67 |
68 |
69 | label_ent LABELTAB = {0, " ", "", &C10, &P10, 'L'};
70 |
71 |
72 | void main() {
73 | //_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)|_CRTDBG_LEAK_CHECK_DF);
74 | //_CrtSetBreakAlloc(838); // 3132 989 714
75 | CppFBP(&LABELTAB, 0, 0, 1); // time required
76 | }
77 |
--------------------------------------------------------------------------------
/TestNetworks/TryLua/TryLua.cpp:
--------------------------------------------------------------------------------
1 |
2 | // TryLua.cpp : Defines the entry point for the console application.
3 | //
4 | /*
5 |
6 | 44 secs in its present form - running on 4 processors
7 |
8 | 1,000,000 IPs running through basically 3 connections (2 in parallel, plus 2 in sequence) - so roughly 3,000,000 recevs, 3,000,000 sends,
9 | giving 14 microsecs per send/receive pair - not bad given that all app logic is in Lua! Which could probably be speeded up by compiling the Lua text...
10 |
11 | Using a non-looper (recvr.lua) in place of drop.lua multiplies the run time enormously, which is not surprising given the time required to fire up
12 | the Lua environment on every non-looper activation - so I wouldn't recommend doing that... but it works!
13 |
14 | */
15 |
16 | #include "stdafx.h"
17 |
18 | #pragma comment(lib, "CppFBPCore")
19 |
20 | #pragma comment(lib, "CppFBPComponents")
21 |
22 | //#pragma comment(lib, "lua53")
23 |
24 | #include "thxdef.h"
25 | #include
26 |
27 | #define _CRTDBG_MAP_ALLOC
28 | #include
29 | #include
30 |
31 | /* This is not the THREADS internal structure - this
32 | is a structured representation of the free-form connection list
33 |
34 | */
35 | void CppFBP(label_ent * label_blk, bool dynam, FILE * fp, bool timereq);
36 |
37 | THRCOMP ThLua(_anchor anch);
38 |
39 |
40 | proc_ent P00 = {0, "Gen", "ThLua", ThLua, 0, 0, !TRACE, 0};
41 | proc_ent P01 = {&P00, "Gen2", "ThLua", ThLua, 0, 0, !TRACE, 0};
42 | proc_ent P02 = {&P01, "Concat", "ThLua", ThLua, 0, 0, !TRACE, 0};
43 | proc_ent P03 = {&P02, "Repl", "ThLua", ThLua, 0, 0, !TRACE, 0};
44 | proc_ent P04 = {&P03, "Drop", "ThLua", ThLua, 0, 0, !TRACE, 0};
45 |
46 | cnxt_ent C00 = {0, "Gen", "OUT", 0, "Concat", "IN", 0, 0, 2};
47 | cnxt_ent C01 = {&C00, "Gen2", "OUT", 0, "Concat", "IN", 1, 0, 2};
48 | cnxt_ent C025 = {&C01, "Concat", "OUT", 0, "Repl", "IN", 0, 0, 2};
49 | cnxt_ent C02 = {&C025, "Repl", "OUT", 0, "Drop", "IN", 0, 0, 2};
50 |
51 | IIP I00 = {"5000"};
52 | IIP I01 = {"..\\..\\LuaScripts\\gen.lua"}; // creates and sends 'COUNT' IPs
53 | cnxt_ent C03 = {&C02, "!", "", 0, "Gen", "COUNT", 0, &I00, 0};
54 | cnxt_ent C04 = {&C03, "!", "", 0, "Gen", "PROG", 0, &I01, 0};
55 |
56 |
57 | IIP I02 = {"5000"};
58 | IIP I03 = {"..\\..\\LuaScripts\\gen.lua"}; // creates and sends 'COUNT' IPs
59 | cnxt_ent C05 = {&C04, "!", "", 0, "Gen2", "COUNT", 0, &I02, 0};
60 | cnxt_ent C06 = {&C05, "!", "", 0, "Gen2", "PROG", 0, &I03, 0};
61 |
62 |
63 | IIP I04 = {"..\\..\\LuaScripts\\concat.lua"}; // receives from IN[0] then IN[1], etc. sending to OUT
64 | cnxt_ent C07 = {&C06, "!", "", 0, "Concat", "PROG", 0, &I04, 0};
65 |
66 | IIP I05 = {"..\\..\\LuaScripts\\repl.lua"}; // creates copies and sends to OUT[0], OUT[1], etc. dropping original
67 | cnxt_ent C08 = {&C07, "!", "", 0, "Repl", "PROG", 0, &I05, 0};
68 |
69 | IIP I06 = {"..\\..\\LuaScripts\\drop.lua"}; // looper
70 | //IIP I06 = {"C:/Users/Paul/Documents/Business/C++Stuff/CppFBP/TestNetworks/TryLua/recvr.lua"};
71 | cnxt_ent C09 = {&C08, "!", "", 0, "Drop", "PROG", 0, &I06, 0};
72 |
73 | label_ent LABELTAB = {0, " ", "", &C09, &P04, 'L'};
74 |
75 |
76 | void main() {
77 | //_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)|_CRTDBG_LEAK_CHECK_DF);
78 | //_CrtSetBreakAlloc(838); // 3132 989 714
79 | CppFBP(&LABELTAB, 0, 0, 1); // time required
80 | }
81 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lcode.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lcode.h,v 1.63 2013/12/30 20:47:58 roberto Exp $
3 | ** Code generator for Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lcode_h
8 | #define lcode_h
9 |
10 | #include "llex.h"
11 | #include "lobject.h"
12 | #include "lopcodes.h"
13 | #include "lparser.h"
14 |
15 |
16 | /*
17 | ** Marks the end of a patch list. It is an invalid value both as an absolute
18 | ** address, and as a list link (would link an element to itself).
19 | */
20 | #define NO_JUMP (-1)
21 |
22 |
23 | /*
24 | ** grep "ORDER OPR" if you change these enums (ORDER OP)
25 | */
26 | typedef enum BinOpr {
27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW,
28 | OPR_DIV,
29 | OPR_IDIV,
30 | OPR_BAND, OPR_BOR, OPR_BXOR,
31 | OPR_SHL, OPR_SHR,
32 | OPR_CONCAT,
33 | OPR_EQ, OPR_LT, OPR_LE,
34 | OPR_NE, OPR_GT, OPR_GE,
35 | OPR_AND, OPR_OR,
36 | OPR_NOBINOPR
37 | } BinOpr;
38 |
39 |
40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
41 |
42 |
43 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info])
44 |
45 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
46 |
47 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
48 |
49 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t)
50 |
51 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
52 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
53 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k);
54 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
55 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
56 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
57 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
58 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
59 | LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n);
60 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
61 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
62 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
63 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
64 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
65 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
66 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
67 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
68 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
69 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e);
70 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
71 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
72 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
73 | LUAI_FUNC int luaK_jump (FuncState *fs);
74 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
75 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
76 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
77 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level);
78 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
79 | LUAI_FUNC int luaK_getlabel (FuncState *fs);
80 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line);
81 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
82 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1,
83 | expdesc *v2, int line);
84 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
85 |
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/SolutionSettings/SolutionSettings.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {A966924A-948A-4DFF-ABCE-2A6188345700}
15 | SolutionSettings
16 | 10.0
17 |
18 |
19 |
20 | Application
21 | true
22 | MultiByte
23 | v142
24 |
25 |
26 | Application
27 | false
28 | true
29 | MultiByte
30 | v142
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | Level3
48 | Disabled
49 |
50 |
51 | true
52 |
53 |
54 |
55 |
56 | Level3
57 | MaxSpeed
58 | true
59 | true
60 |
61 |
62 | true
63 | true
64 | true
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/CppFBPCore/Services/thz.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | //#include
3 | #include
4 | #include
5 | #include "thzcbs.h"
6 | #include "cppfbp.h"
7 |
8 |
9 | int thzsend(Process *proc, void **ptr, port_ent *peptr, int elem_no);
10 | int thzrecv(Process *proc, void **ptr, port_ent *peptr, int elem_no,
11 | long *size, char **typep);
12 | int thzcrep(Process *proc, void **ptr, long IPsize, char *type);
13 | int thzdrop(Process *proc, void **ptr);
14 | int thzdfpt(Process *proc, int port_count, port_ent *peptr);
15 | int thzpush(Process *proc, void **ptr);
16 | int thzpop(Process *proc, void **ptr, long *size, char **typep);
17 | int thzclos(Process *proc, port_ent *peptr, int elem_no);
18 | long thzgsize(Process *proc, void **ptr);
19 | int thzelct(Process * proc, port_ent *peptr);
20 |
21 | int thzsendc(Process *proc, void **ptr, char * port);
22 | int thzrecvc(Process *proc, void **ptr, char * port,
23 | long *size, char **typep);
24 | int thzclosc(Process *proc, char * port);
25 | int thzelctc(Process * proc, char * port);
26 |
27 |
28 | int thz(int code, Process *proc, ...)
29 | {
30 | va_list ap;
31 | int value = 0;
32 | int port_count, elem_no;
33 | long IPsize;
34 | long *size;
35 | char *type;
36 | char **typep;
37 | port_ent *peptr;
38 | void **ptr;
39 | char * port;
40 |
41 | va_start (ap, proc);
42 | if (code == 0)
43 | return 0;
44 | switch (code) {
45 | case 1: ptr = va_arg(ap,void **);
46 | peptr = va_arg(ap,port_ent *);
47 | elem_no = va_arg(ap,int);
48 | value = thzsend(proc, ptr, peptr, elem_no); break;
49 | case 2: ptr = va_arg(ap,void **);
50 | peptr = va_arg(ap,port_ent *);
51 | elem_no = va_arg(ap,int);
52 | size = va_arg(ap,long *);
53 | typep = va_arg(ap, char **);
54 | value = thzrecv(proc, ptr, peptr, elem_no,
55 | size, typep); break;
56 | case 3: ptr = va_arg(ap,void **);
57 | IPsize = va_arg(ap,long);
58 | type = va_arg(ap,char *);
59 | value = thzcrep(proc, ptr, IPsize, type); break;
60 | case 4: ptr = va_arg(ap,void **);
61 | value = thzdrop(proc, ptr); break;
62 | case 5: port_count = va_arg(ap,int);
63 | peptr = va_arg(ap,port_ent *);
64 | value = thzdfpt(proc, port_count, peptr); break;
65 | case 6: ptr = va_arg(ap,void **);
66 | value = thzpush(proc, ptr); break;
67 | case 7: ptr = va_arg(ap,void **);
68 | size = va_arg(ap,long *);
69 | typep = va_arg(ap, char **);
70 | value = thzpop(proc, ptr, size, typep); break;
71 | case 8: peptr = va_arg(ap,port_ent *);
72 | elem_no = va_arg(ap,int);
73 | value = thzclos(proc, peptr, elem_no); break;
74 |
75 | case 9: ptr = va_arg(ap,void **);
76 | IPsize = thzgsize(proc, ptr);
77 | return IPsize; break;
78 |
79 | case 10: //ptr = va_arg(ap,void **);
80 | peptr = va_arg(ap,port_ent *);
81 | value = thzelct(proc, peptr);
82 | break;
83 |
84 | case 11: ptr = va_arg(ap,void **);
85 | port = va_arg(ap,char *);
86 | value = thzsendc(proc, ptr, port);
87 | break;
88 | case 12: ptr = va_arg(ap,void **);
89 | port = va_arg(ap,char *);
90 | size = va_arg(ap,long *);
91 | typep = va_arg(ap, char **);
92 | value = thzrecvc(proc, ptr, port,
93 | size, typep); break;
94 | case 13: port = va_arg(ap,char *);
95 | value = thzclosc(proc, port);
96 | break;
97 | case 14: //ptr = va_arg(ap,void **);
98 | port = va_arg(ap,char *);
99 | value = thzelctc(proc, port);
100 | break;
101 | }
102 | va_end(ap);
103 | if (code < 10 && proc -> trace && value > 0)
104 | MSG2("%s: Service retcode %d\n",
105 | proc -> procname, value);
106 |
107 |
108 | return(value);
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lparser.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 roberto Exp $
3 | ** Lua Parser
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lparser_h
8 | #define lparser_h
9 |
10 | #include "llimits.h"
11 | #include "lobject.h"
12 | #include "lzio.h"
13 |
14 |
15 | /*
16 | ** Expression descriptor
17 | */
18 |
19 | typedef enum {
20 | VVOID, /* no value */
21 | VNIL,
22 | VTRUE,
23 | VFALSE,
24 | VK, /* info = index of constant in 'k' */
25 | VKFLT, /* nval = numerical float value */
26 | VKINT, /* nval = numerical integer value */
27 | VNONRELOC, /* info = result register */
28 | VLOCAL, /* info = local register */
29 | VUPVAL, /* info = index of upvalue in 'upvalues' */
30 | VINDEXED, /* t = table register/upvalue; idx = index R/K */
31 | VJMP, /* info = instruction pc */
32 | VRELOCABLE, /* info = instruction pc */
33 | VCALL, /* info = instruction pc */
34 | VVARARG /* info = instruction pc */
35 | } expkind;
36 |
37 |
38 | #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
39 | #define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
40 |
41 | typedef struct expdesc {
42 | expkind k;
43 | union {
44 | struct { /* for indexed variables (VINDEXED) */
45 | short idx; /* index (R/K) */
46 | lu_byte t; /* table (register or upvalue) */
47 | lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
48 | } ind;
49 | int info; /* for generic use */
50 | lua_Number nval; /* for VKFLT */
51 | lua_Integer ival; /* for VKINT */
52 | } u;
53 | int t; /* patch list of 'exit when true' */
54 | int f; /* patch list of 'exit when false' */
55 | } expdesc;
56 |
57 |
58 | /* description of active local variable */
59 | typedef struct Vardesc {
60 | short idx; /* variable index in stack */
61 | } Vardesc;
62 |
63 |
64 | /* description of pending goto statements and label statements */
65 | typedef struct Labeldesc {
66 | TString *name; /* label identifier */
67 | int pc; /* position in code */
68 | int line; /* line where it appeared */
69 | lu_byte nactvar; /* local level where it appears in current block */
70 | } Labeldesc;
71 |
72 |
73 | /* list of labels or gotos */
74 | typedef struct Labellist {
75 | Labeldesc *arr; /* array */
76 | int n; /* number of entries in use */
77 | int size; /* array size */
78 | } Labellist;
79 |
80 |
81 | /* dynamic structures used by the parser */
82 | typedef struct Dyndata {
83 | struct { /* list of active local variables */
84 | Vardesc *arr;
85 | int n;
86 | int size;
87 | } actvar;
88 | Labellist gt; /* list of pending gotos */
89 | Labellist label; /* list of active labels */
90 | } Dyndata;
91 |
92 |
93 | /* control of blocks */
94 | struct BlockCnt; /* defined in lparser.c */
95 |
96 |
97 | /* state needed to generate code for a given function */
98 | typedef struct FuncState {
99 | Proto *f; /* current function header */
100 | struct FuncState *prev; /* enclosing function */
101 | struct LexState *ls; /* lexical state */
102 | struct BlockCnt *bl; /* chain of current blocks */
103 | int pc; /* next position to code (equivalent to 'ncode') */
104 | int lasttarget; /* 'label' of last 'jump label' */
105 | int jpc; /* list of pending jumps to 'pc' */
106 | int nk; /* number of elements in 'k' */
107 | int np; /* number of elements in 'p' */
108 | int firstlocal; /* index of first local var (in Dyndata array) */
109 | short nlocvars; /* number of elements in 'f->locvars' */
110 | lu_byte nactvar; /* number of active local variables */
111 | lu_byte nups; /* number of upvalues */
112 | lu_byte freereg; /* first free register */
113 | } FuncState;
114 |
115 |
116 | LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
117 | Dyndata *dyd, const char *name, int firstchar);
118 |
119 |
120 | #endif
121 |
--------------------------------------------------------------------------------
/CppFBPCore/CppFBPCore.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 | Source Files
41 |
42 |
43 | Source Files
44 |
45 |
46 | Source Files
47 |
48 |
49 | Source Files
50 |
51 |
52 | Source Files
53 |
54 |
55 | Source Files
56 |
57 |
58 | Source Files
59 |
60 |
61 | Source Files
62 |
63 |
64 | Source Files
65 |
66 |
67 | Source Files
68 |
69 |
70 | Source Files
71 |
72 |
73 | Source Files
74 |
75 |
76 |
77 |
78 | Header Files
79 |
80 |
81 | Header Files
82 |
83 |
84 | Header Files
85 |
86 |
87 | Header Files
88 |
89 |
90 | Header Files
91 |
92 |
93 | Header Files
94 |
95 |
96 | Header Files
97 |
98 |
99 | Header Files
100 |
101 |
102 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lopcodes.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $
3 | ** Opcodes for Lua virtual machine
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lopcodes_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lopcodes.h"
16 |
17 |
18 | /* ORDER OP */
19 |
20 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
21 | "MOVE",
22 | "LOADK",
23 | "LOADKX",
24 | "LOADBOOL",
25 | "LOADNIL",
26 | "GETUPVAL",
27 | "GETTABUP",
28 | "GETTABLE",
29 | "SETTABUP",
30 | "SETUPVAL",
31 | "SETTABLE",
32 | "NEWTABLE",
33 | "SELF",
34 | "ADD",
35 | "SUB",
36 | "MUL",
37 | "MOD",
38 | "POW",
39 | "DIV",
40 | "IDIV",
41 | "BAND",
42 | "BOR",
43 | "BXOR",
44 | "SHL",
45 | "SHR",
46 | "UNM",
47 | "BNOT",
48 | "NOT",
49 | "LEN",
50 | "CONCAT",
51 | "JMP",
52 | "EQ",
53 | "LT",
54 | "LE",
55 | "TEST",
56 | "TESTSET",
57 | "CALL",
58 | "TAILCALL",
59 | "RETURN",
60 | "FORLOOP",
61 | "FORPREP",
62 | "TFORCALL",
63 | "TFORLOOP",
64 | "SETLIST",
65 | "CLOSURE",
66 | "VARARG",
67 | "EXTRAARG",
68 | NULL
69 | };
70 |
71 |
72 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
73 |
74 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
75 | /* T A B C mode opcode */
76 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
77 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
78 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */
79 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
80 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */
81 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
82 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */
83 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
84 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */
85 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
86 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
87 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
88 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
89 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
90 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
91 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
92 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
93 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
94 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
95 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */
96 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */
97 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */
98 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */
99 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */
100 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */
101 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
102 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */
103 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
104 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
105 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
106 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
107 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
108 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
109 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
110 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */
111 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
112 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
113 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
114 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
115 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
116 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
117 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */
118 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
119 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
120 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
121 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
122 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
123 | };
124 |
125 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lvm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lvm.h,v 2.39 2015/09/09 13:44:07 roberto Exp $
3 | ** Lua virtual machine
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lvm_h
8 | #define lvm_h
9 |
10 |
11 | #include "ldo.h"
12 | #include "lobject.h"
13 | #include "ltm.h"
14 |
15 |
16 | #if !defined(LUA_NOCVTN2S)
17 | #define cvt2str(o) ttisnumber(o)
18 | #else
19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */
20 | #endif
21 |
22 |
23 | #if !defined(LUA_NOCVTS2N)
24 | #define cvt2num(o) ttisstring(o)
25 | #else
26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */
27 | #endif
28 |
29 |
30 | /*
31 | ** You can define LUA_FLOORN2I if you want to convert floats to integers
32 | ** by flooring them (instead of raising an error if they are not
33 | ** integral values)
34 | */
35 | #if !defined(LUA_FLOORN2I)
36 | #define LUA_FLOORN2I 0
37 | #endif
38 |
39 |
40 | #define tonumber(o,n) \
41 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n))
42 |
43 | #define tointeger(o,i) \
44 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I))
45 |
46 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2))
47 |
48 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
49 |
50 |
51 | /*
52 | ** fast track for 'gettable': 1 means 'aux' points to resulted value;
53 | ** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is
54 | ** the raw get function to use.
55 | */
56 | #define luaV_fastget(L,t,k,aux,f) \
57 | (!ttistable(t) \
58 | ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \
59 | : (aux = f(hvalue(t), k), /* else, do raw access */ \
60 | !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \
61 | : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\
62 | aux != NULL ? 0 /* has metamethod? must call it */ \
63 | : (aux = luaO_nilobject, 1)))) /* else, final result is nil */
64 |
65 | /*
66 | ** standard implementation for 'gettable'
67 | */
68 | #define luaV_gettable(L,t,k,v) { const TValue *aux; \
69 | if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \
70 | else luaV_finishget(L,t,k,v,aux); }
71 |
72 |
73 | /*
74 | ** Fast track for set table. If 't' is a table and 't[k]' is not nil,
75 | ** call GC barrier, do a raw 't[k]=v', and return true; otherwise,
76 | ** return false with 'slot' equal to NULL (if 't' is not a table) or
77 | ** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro
78 | ** returns true, there is no need to 'invalidateTMcache', because the
79 | ** call is not creating a new entry.
80 | */
81 | #define luaV_fastset(L,t,k,slot,f,v) \
82 | (!ttistable(t) \
83 | ? (slot = NULL, 0) \
84 | : (slot = f(hvalue(t), k), \
85 | ttisnil(slot) ? 0 \
86 | : (luaC_barrierback(L, hvalue(t), v), \
87 | setobj2t(L, cast(TValue *,slot), v), \
88 | 1)))
89 |
90 |
91 | #define luaV_settable(L,t,k,v) { const TValue *slot; \
92 | if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \
93 | luaV_finishset(L,t,k,v,slot); }
94 |
95 |
96 |
97 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2);
98 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
99 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
100 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
101 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode);
102 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
103 | StkId val, const TValue *tm);
104 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
105 | StkId val, const TValue *oldval);
106 | LUAI_FUNC void luaV_finishOp (lua_State *L);
107 | LUAI_FUNC void luaV_execute (lua_State *L);
108 | LUAI_FUNC void luaV_concat (lua_State *L, int total);
109 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y);
110 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y);
111 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y);
112 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
113 |
114 | #endif
115 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lfunc.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp $
3 | ** Auxiliary functions to manipulate prototypes and closures
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lfunc_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "lfunc.h"
18 | #include "lgc.h"
19 | #include "lmem.h"
20 | #include "lobject.h"
21 | #include "lstate.h"
22 |
23 |
24 |
25 | CClosure *luaF_newCclosure (lua_State *L, int n) {
26 | GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n));
27 | CClosure *c = gco2ccl(o);
28 | c->nupvalues = cast_byte(n);
29 | return c;
30 | }
31 |
32 |
33 | LClosure *luaF_newLclosure (lua_State *L, int n) {
34 | GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n));
35 | LClosure *c = gco2lcl(o);
36 | c->p = NULL;
37 | c->nupvalues = cast_byte(n);
38 | while (n--) c->upvals[n] = NULL;
39 | return c;
40 | }
41 |
42 | /*
43 | ** fill a closure with new closed upvalues
44 | */
45 | void luaF_initupvals (lua_State *L, LClosure *cl) {
46 | int i;
47 | for (i = 0; i < cl->nupvalues; i++) {
48 | UpVal *uv = luaM_new(L, UpVal);
49 | uv->refcount = 1;
50 | uv->v = &uv->u.value; /* make it closed */
51 | setnilvalue(uv->v);
52 | cl->upvals[i] = uv;
53 | }
54 | }
55 |
56 |
57 | UpVal *luaF_findupval (lua_State *L, StkId level) {
58 | UpVal **pp = &L->openupval;
59 | UpVal *p;
60 | UpVal *uv;
61 | lua_assert(isintwups(L) || L->openupval == NULL);
62 | while (*pp != NULL && (p = *pp)->v >= level) {
63 | lua_assert(upisopen(p));
64 | if (p->v == level) /* found a corresponding upvalue? */
65 | return p; /* return it */
66 | pp = &p->u.open.next;
67 | }
68 | /* not found: create a new upvalue */
69 | uv = luaM_new(L, UpVal);
70 | uv->refcount = 0;
71 | uv->u.open.next = *pp; /* link it to list of open upvalues */
72 | uv->u.open.touched = 1;
73 | *pp = uv;
74 | uv->v = level; /* current value lives in the stack */
75 | if (!isintwups(L)) { /* thread not in list of threads with upvalues? */
76 | L->twups = G(L)->twups; /* link it to the list */
77 | G(L)->twups = L;
78 | }
79 | return uv;
80 | }
81 |
82 |
83 | void luaF_close (lua_State *L, StkId level) {
84 | UpVal *uv;
85 | while (L->openupval != NULL && (uv = L->openupval)->v >= level) {
86 | lua_assert(upisopen(uv));
87 | L->openupval = uv->u.open.next; /* remove from 'open' list */
88 | if (uv->refcount == 0) /* no references? */
89 | luaM_free(L, uv); /* free upvalue */
90 | else {
91 | setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */
92 | uv->v = &uv->u.value; /* now current value lives here */
93 | luaC_upvalbarrier(L, uv);
94 | }
95 | }
96 | }
97 |
98 |
99 | Proto *luaF_newproto (lua_State *L) {
100 | GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto));
101 | Proto *f = gco2p(o);
102 | f->k = NULL;
103 | f->sizek = 0;
104 | f->p = NULL;
105 | f->sizep = 0;
106 | f->code = NULL;
107 | f->cache = NULL;
108 | f->sizecode = 0;
109 | f->lineinfo = NULL;
110 | f->sizelineinfo = 0;
111 | f->upvalues = NULL;
112 | f->sizeupvalues = 0;
113 | f->numparams = 0;
114 | f->is_vararg = 0;
115 | f->maxstacksize = 0;
116 | f->locvars = NULL;
117 | f->sizelocvars = 0;
118 | f->linedefined = 0;
119 | f->lastlinedefined = 0;
120 | f->source = NULL;
121 | return f;
122 | }
123 |
124 |
125 | void luaF_freeproto (lua_State *L, Proto *f) {
126 | luaM_freearray(L, f->code, f->sizecode);
127 | luaM_freearray(L, f->p, f->sizep);
128 | luaM_freearray(L, f->k, f->sizek);
129 | luaM_freearray(L, f->lineinfo, f->sizelineinfo);
130 | luaM_freearray(L, f->locvars, f->sizelocvars);
131 | luaM_freearray(L, f->upvalues, f->sizeupvalues);
132 | luaM_free(L, f);
133 | }
134 |
135 |
136 | /*
137 | ** Look for n-th local variable at line 'line' in function 'func'.
138 | ** Returns NULL if not found.
139 | */
140 | const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
141 | int i;
142 | for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) {
143 | if (pc < f->locvars[i].endpc) { /* is variable active? */
144 | local_number--;
145 | if (local_number == 0)
146 | return getstr(f->locvars[i].varname);
147 | }
148 | }
149 | return NULL; /* not found */
150 | }
151 |
152 |
--------------------------------------------------------------------------------
/TestSubnets/Helper Code/dfs.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include
3 | #include
4 | #include
5 |
6 | #include "thxanch.h"
7 |
8 |
9 | int const ZERO = 0; // for testing
10 | int const ONE = 1; //send
11 | int const TWO = 2; //recv
12 | int const THREE = 3; //crep
13 | int const FOUR = 4; //drop
14 | int const FIVE = 5; //dfpt
15 | int const SIX = 6; //push
16 | int const SEVEN = 7; //pop
17 | int const EIGHT = 8; //close
18 | int const NINE = 9; //gsize
19 | int const TEN = 10; //elct
20 |
21 | int const ELEVEN = 11; //sendc
22 | int const TWELVE = 12; //recvc
23 | int const THIRTEEN = 13; //closc
24 | int const FOURTEEN = 14; //elctc
25 |
26 |
27 |
28 | int dfstest(_anchor proc_anchor)
29 | {
30 | int value;
31 |
32 | value = proc_anchor.svc_addr (ZERO, proc_anchor.reserved);
33 | return(value);
34 | }
35 |
36 | int dfssend(_anchor proc_anchor, void **ptr, port_ent *peptr,
37 | int elem_no)
38 | {
39 | int value;
40 |
41 | value = proc_anchor.svc_addr (ONE, proc_anchor.reserved, ptr, peptr,
42 | elem_no)
43 | ;
44 | return(value);
45 | }
46 |
47 |
48 | int dfsrecv(_anchor proc_anchor, void **ptr, port_ent *peptr,
49 | int elem_no, long *size, char **type)
50 | {
51 | int value;
52 |
53 | value = proc_anchor.svc_addr (TWO, proc_anchor.reserved, ptr, peptr,
54 | elem_no, size, type);
55 | return(value);
56 | }
57 |
58 | int dfscrep(_anchor proc_anchor, void **ptr, long size, char *type)
59 | {
60 | int value;
61 |
62 | value = proc_anchor.svc_addr (THREE, proc_anchor.reserved, ptr, size,
63 | type);
64 | return(value);
65 | }
66 |
67 | int dfsdrop(_anchor proc_anchor, void **ptr)
68 | {
69 | int value;
70 |
71 | value = proc_anchor.svc_addr (FOUR, proc_anchor.reserved, ptr);
72 | return(value);
73 | }
74 |
75 | int dfsdfpt(_anchor proc_anchor, int port_count, port_ent *peptr, ...)
76 | {
77 | va_list ap;
78 | int i;
79 | int value;
80 |
81 | va_start (ap, peptr);
82 | for (i = 0; i < port_count; i++) {
83 | strcpy((peptr+i) -> port_name, va_arg(ap, char *));
84 | //(peptr+i) -> reserved = 0;
85 | (peptr+i) -> elem_count = 0;
86 | (peptr+i) -> ret_code = 0;
87 |
88 | }
89 | va_end (ap);
90 | value = proc_anchor.svc_addr (FIVE, proc_anchor.reserved, port_count,
91 | peptr);
92 | return(value);
93 | }
94 |
95 | int dfspush(_anchor proc_anchor, void **ptr )
96 | {
97 | int value;
98 |
99 | value = proc_anchor.svc_addr (SIX, proc_anchor.reserved, ptr);
100 | return(value);
101 | }
102 |
103 |
104 | int dfspop(_anchor proc_anchor, void **ptr, long *size, char **type)
105 | {
106 | int value;
107 |
108 | value = proc_anchor.svc_addr (SEVEN, proc_anchor.reserved, ptr, size, type);
109 | return(value);
110 | }
111 |
112 | int dfsclos(_anchor proc_anchor, port_ent *peptr,
113 | int elem_no)
114 | {
115 | int value;
116 |
117 | value = proc_anchor.svc_addr (EIGHT, proc_anchor.reserved, peptr,
118 | elem_no);
119 | return(value);
120 | }
121 |
122 | long dfsgsize(_anchor proc_anchor, void **ptr) {
123 | long size;
124 |
125 | size = proc_anchor.svc_addr (NINE, proc_anchor.reserved, ptr);
126 |
127 | return(size);
128 | }
129 |
130 | int dfselct(_anchor proc_anchor, port_ent *peptr) {
131 | int ct;
132 |
133 | ct = proc_anchor.svc_addr (TEN, proc_anchor.reserved, peptr);
134 |
135 | return(ct);
136 | }
137 |
138 | int dfssendc(_anchor proc_anchor, void **ptr, char * port)
139 | {
140 | int value;
141 |
142 | value = proc_anchor.svc_addr (ELEVEN, proc_anchor.reserved, ptr, port)
143 | ;
144 | return(value);
145 | }
146 |
147 |
148 | int dfsrecvc(_anchor proc_anchor, void **ptr, char * port, long *size, char **type)
149 | {
150 | int value;
151 |
152 | value = proc_anchor.svc_addr (TWELVE, proc_anchor.reserved, ptr, port, size, type);
153 | return(value);
154 | }
155 |
156 | int dfsclosc(_anchor proc_anchor, char * port)
157 | {
158 | int value;
159 |
160 | value = proc_anchor.svc_addr (THIRTEEN, proc_anchor.reserved, port);
161 | return(value);
162 | }
163 | int dfselctc(_anchor proc_anchor, char * port) {
164 | int ct;
165 |
166 | ct = proc_anchor.svc_addr (FOURTEEN, proc_anchor.reserved, port);
167 |
168 | return(ct);
169 | }
170 |
--------------------------------------------------------------------------------
/CppFBPComponents/Helper Code/dfs.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include
3 | #include
4 | #include
5 |
6 | #include "thxanch.h"
7 |
8 |
9 | int const ZERO = 0; // for testing
10 | int const ONE = 1; //send
11 | int const TWO = 2; //recv
12 | int const THREE = 3; //crep
13 | int const FOUR = 4; //drop
14 | int const FIVE = 5; //dfpt
15 | int const SIX = 6; //push
16 | int const SEVEN = 7; //pop
17 | int const EIGHT = 8; //close
18 | int const NINE = 9; //gsize
19 | int const TEN = 10; //elct
20 |
21 | int const ELEVEN = 11; //sendc
22 | int const TWELVE = 12; //recvc
23 | int const THIRTEEN = 13; //closc
24 | int const FOURTEEN = 14; //elctc
25 |
26 |
27 |
28 | int dfstest(_anchor proc_anchor)
29 | {
30 | int value;
31 |
32 | value = proc_anchor.svc_addr (ZERO, proc_anchor.reserved);
33 | return(value);
34 | }
35 |
36 | int dfssend(_anchor proc_anchor, void **ptr, port_ent *peptr,
37 | int elem_no)
38 | {
39 | int value;
40 |
41 | value = proc_anchor.svc_addr (ONE, proc_anchor.reserved, ptr, peptr,
42 | elem_no)
43 | ;
44 | return(value);
45 | }
46 |
47 |
48 | int dfsrecv(_anchor proc_anchor, void **ptr, port_ent *peptr,
49 | int elem_no, long *size, char **type)
50 | {
51 | int value;
52 |
53 | value = proc_anchor.svc_addr (TWO, proc_anchor.reserved, ptr, peptr,
54 | elem_no, size, type);
55 | return(value);
56 | }
57 |
58 | int dfscrep(_anchor proc_anchor, void **ptr, long size, char *type)
59 | {
60 | int value;
61 |
62 | value = proc_anchor.svc_addr (THREE, proc_anchor.reserved, ptr, size,
63 | type);
64 | return(value);
65 | }
66 |
67 | int dfsdrop(_anchor proc_anchor, void **ptr)
68 | {
69 | int value;
70 |
71 | value = proc_anchor.svc_addr (FOUR, proc_anchor.reserved, ptr);
72 | return(value);
73 | }
74 |
75 | int dfsdfpt(_anchor proc_anchor, int port_count, port_ent *peptr, ...)
76 | {
77 | va_list ap;
78 | int i;
79 | int value;
80 |
81 | va_start (ap, peptr);
82 | for (i = 0; i < port_count; i++) {
83 | strcpy_s((peptr+i) -> port_name, va_arg(ap, char *));
84 | //(peptr+i) -> reserved = 0;
85 | (peptr+i) -> elem_count = 0;
86 | (peptr+i) -> ret_code = 0;
87 |
88 | }
89 | va_end (ap);
90 | value = proc_anchor.svc_addr (FIVE, proc_anchor.reserved, port_count,
91 | peptr);
92 | return(value);
93 | }
94 |
95 | int dfspush(_anchor proc_anchor, void **ptr )
96 | {
97 | int value;
98 |
99 | value = proc_anchor.svc_addr (SIX, proc_anchor.reserved, ptr);
100 | return(value);
101 | }
102 |
103 |
104 | int dfspop(_anchor proc_anchor, void **ptr, long *size, char **type)
105 | {
106 | int value;
107 |
108 | value = proc_anchor.svc_addr (SEVEN, proc_anchor.reserved, ptr, size, type);
109 | return(value);
110 | }
111 |
112 | int dfsclos(_anchor proc_anchor, port_ent *peptr,
113 | int elem_no)
114 | {
115 | int value;
116 |
117 | value = proc_anchor.svc_addr (EIGHT, proc_anchor.reserved, peptr,
118 | elem_no);
119 | return(value);
120 | }
121 |
122 | long dfsgsize(_anchor proc_anchor, void **ptr) {
123 | long size;
124 |
125 | size = proc_anchor.svc_addr (NINE, proc_anchor.reserved, ptr);
126 |
127 | return(size);
128 | }
129 |
130 | int dfselct(_anchor proc_anchor, port_ent *peptr) {
131 | int ct;
132 |
133 | ct = proc_anchor.svc_addr (TEN, proc_anchor.reserved, peptr);
134 |
135 | return(ct);
136 | }
137 |
138 | int dfssendc(_anchor proc_anchor, void **ptr, char * port)
139 | {
140 | int value;
141 |
142 | value = proc_anchor.svc_addr (ELEVEN, proc_anchor.reserved, ptr, port)
143 | ;
144 | return(value);
145 | }
146 |
147 |
148 | int dfsrecvc(_anchor proc_anchor, void **ptr, char * port, long *size, char **type)
149 | {
150 | int value;
151 |
152 | value = proc_anchor.svc_addr (TWELVE, proc_anchor.reserved, ptr, port, size, type);
153 | return(value);
154 | }
155 |
156 | int dfsclosc(_anchor proc_anchor, char * port)
157 | {
158 | int value;
159 |
160 | value = proc_anchor.svc_addr (THIRTEEN, proc_anchor.reserved, port);
161 | return(value);
162 | }
163 | int dfselctc(_anchor proc_anchor, char * port) {
164 | int ct;
165 |
166 | ct = proc_anchor.svc_addr (FOURTEEN, proc_anchor.reserved, port);
167 |
168 | return(ct);
169 | }
170 |
--------------------------------------------------------------------------------
/TestNetworks/TryDynSubNet/Helper Code/dfs.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include
3 | #include
4 | #include
5 |
6 | #include "thxanch.h"
7 |
8 |
9 | int const ZERO = 0; // for testing
10 | int const ONE = 1; //send
11 | int const TWO = 2; //recv
12 | int const THREE = 3; //crep
13 | int const FOUR = 4; //drop
14 | int const FIVE = 5; //dfpt
15 | int const SIX = 6; //push
16 | int const SEVEN = 7; //pop
17 | int const EIGHT = 8; //close
18 | int const NINE = 9; //gsize
19 | int const TEN = 10; //elct
20 |
21 | int const ELEVEN = 11; //sendc
22 | int const TWELVE = 12; //recvc
23 | int const THIRTEEN = 13; //closc
24 | int const FOURTEEN = 14; //elctc
25 |
26 |
27 |
28 | int dfstest(_anchor proc_anchor)
29 | {
30 | int value;
31 |
32 | value = proc_anchor.svc_addr (ZERO, proc_anchor.reserved);
33 | return(value);
34 | }
35 |
36 | int dfssend(_anchor proc_anchor, void **ptr, port_ent *peptr,
37 | int elem_no)
38 | {
39 | int value;
40 |
41 | value = proc_anchor.svc_addr (ONE, proc_anchor.reserved, ptr, peptr,
42 | elem_no)
43 | ;
44 | return(value);
45 | }
46 |
47 |
48 | int dfsrecv(_anchor proc_anchor, void **ptr, port_ent *peptr,
49 | int elem_no, long *size, char **type)
50 | {
51 | int value;
52 |
53 | value = proc_anchor.svc_addr (TWO, proc_anchor.reserved, ptr, peptr,
54 | elem_no, size, type);
55 | return(value);
56 | }
57 |
58 | int dfscrep(_anchor proc_anchor, void **ptr, long size, char *type)
59 | {
60 | int value;
61 |
62 | value = proc_anchor.svc_addr (THREE, proc_anchor.reserved, ptr, size,
63 | type);
64 | return(value);
65 | }
66 |
67 | int dfsdrop(_anchor proc_anchor, void **ptr)
68 | {
69 | int value;
70 |
71 | value = proc_anchor.svc_addr (FOUR, proc_anchor.reserved, ptr);
72 | return(value);
73 | }
74 |
75 | int dfsdfpt(_anchor proc_anchor, int port_count, port_ent *peptr, ...)
76 | {
77 | va_list ap;
78 | int i;
79 | int value;
80 |
81 | va_start (ap, peptr);
82 | for (i = 0; i < port_count; i++) {
83 | strcpy((peptr+i) -> port_name, va_arg(ap, char *));
84 | //(peptr+i) -> reserved = 0;
85 | (peptr+i) -> elem_count = 0;
86 | (peptr+i) -> ret_code = 0;
87 |
88 | }
89 | va_end (ap);
90 | value = proc_anchor.svc_addr (FIVE, proc_anchor.reserved, port_count,
91 | peptr);
92 | return(value);
93 | }
94 |
95 | int dfspush(_anchor proc_anchor, void **ptr )
96 | {
97 | int value;
98 |
99 | value = proc_anchor.svc_addr (SIX, proc_anchor.reserved, ptr);
100 | return(value);
101 | }
102 |
103 |
104 | int dfspop(_anchor proc_anchor, void **ptr, long *size, char **type)
105 | {
106 | int value;
107 |
108 | value = proc_anchor.svc_addr (SEVEN, proc_anchor.reserved, ptr, size, type);
109 | return(value);
110 | }
111 |
112 | int dfsclos(_anchor proc_anchor, port_ent *peptr,
113 | int elem_no)
114 | {
115 | int value;
116 |
117 | value = proc_anchor.svc_addr (EIGHT, proc_anchor.reserved, peptr,
118 | elem_no);
119 | return(value);
120 | }
121 |
122 | long dfsgsize(_anchor proc_anchor, void **ptr) {
123 | long size;
124 |
125 | size = proc_anchor.svc_addr (NINE, proc_anchor.reserved, ptr);
126 |
127 | return(size);
128 | }
129 |
130 | int dfselct(_anchor proc_anchor, port_ent *peptr) {
131 | int ct;
132 |
133 | ct = proc_anchor.svc_addr (TEN, proc_anchor.reserved, peptr);
134 |
135 | return(ct);
136 | }
137 |
138 | int dfssendc(_anchor proc_anchor, void **ptr, char * port)
139 | {
140 | int value;
141 |
142 | value = proc_anchor.svc_addr (ELEVEN, proc_anchor.reserved, ptr, port)
143 | ;
144 | return(value);
145 | }
146 |
147 |
148 | int dfsrecvc(_anchor proc_anchor, void **ptr, char * port, long *size, char **type)
149 | {
150 | int value;
151 |
152 | value = proc_anchor.svc_addr (TWELVE, proc_anchor.reserved, ptr, port, size, type);
153 | return(value);
154 | }
155 |
156 | int dfsclosc(_anchor proc_anchor, char * port)
157 | {
158 | int value;
159 |
160 | value = proc_anchor.svc_addr (THIRTEEN, proc_anchor.reserved, port);
161 | return(value);
162 | }
163 | int dfselctc(_anchor proc_anchor, char * port) {
164 | int ct;
165 |
166 | ct = proc_anchor.svc_addr (FOURTEEN, proc_anchor.reserved, port);
167 |
168 | return(ct);
169 | }
170 |
--------------------------------------------------------------------------------
/TestNetworks/TryLua/Helper Code/dfs.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include
3 | #include
4 | #include
5 |
6 | #include "thxanch.h"
7 |
8 |
9 | int const ZERO = 0; // for testing
10 | int const ONE = 1; //send
11 | int const TWO = 2; //recv
12 | int const THREE = 3; //crep
13 | int const FOUR = 4; //drop
14 | int const FIVE = 5; //dfpt
15 | int const SIX = 6; //push
16 | int const SEVEN = 7; //pop
17 | int const EIGHT = 8; //close
18 | int const NINE = 9; //gsize
19 | int const TEN = 10; //elct
20 |
21 | int const ELEVEN = 11; //sendc
22 | int const TWELVE = 12; //recvc
23 | int const THIRTEEN = 13; //closc
24 | int const FOURTEEN = 14; //elctc
25 |
26 |
27 |
28 | int dfstest(_anchor proc_anchor)
29 | {
30 | int value;
31 |
32 | value = proc_anchor.svc_addr (ZERO, proc_anchor.reserved);
33 | return(value);
34 | }
35 |
36 | int dfssend(_anchor proc_anchor, void **ptr, port_ent *peptr,
37 | int elem_no)
38 | {
39 | int value;
40 |
41 | value = proc_anchor.svc_addr (ONE, proc_anchor.reserved, ptr, peptr,
42 | elem_no)
43 | ;
44 | return(value);
45 | }
46 |
47 |
48 | int dfsrecv(_anchor proc_anchor, void **ptr, port_ent *peptr,
49 | int elem_no, long *size, char **type)
50 | {
51 | int value;
52 |
53 | value = proc_anchor.svc_addr (TWO, proc_anchor.reserved, ptr, peptr,
54 | elem_no, size, type);
55 | return(value);
56 | }
57 |
58 | int dfscrep(_anchor proc_anchor, void **ptr, long size, char *type)
59 | {
60 | int value;
61 |
62 | value = proc_anchor.svc_addr (THREE, proc_anchor.reserved, ptr, size,
63 | type);
64 | return(value);
65 | }
66 |
67 | int dfsdrop(_anchor proc_anchor, void **ptr)
68 | {
69 | int value;
70 |
71 | value = proc_anchor.svc_addr (FOUR, proc_anchor.reserved, ptr);
72 | return(value);
73 | }
74 |
75 | int dfsdfpt(_anchor proc_anchor, int port_count, port_ent *peptr, ...)
76 | {
77 | va_list ap;
78 | int i;
79 | int value;
80 |
81 | va_start (ap, peptr);
82 | for (i = 0; i < port_count; i++) {
83 | strcpy_s((peptr+i) -> port_name, va_arg(ap, char *));
84 | //(peptr+i) -> reserved = 0;
85 | (peptr+i) -> elem_count = 0;
86 | (peptr+i) -> ret_code = 0;
87 |
88 | }
89 | va_end (ap);
90 | value = proc_anchor.svc_addr (FIVE, proc_anchor.reserved, port_count,
91 | peptr);
92 | return(value);
93 | }
94 |
95 | int dfspush(_anchor proc_anchor, void **ptr )
96 | {
97 | int value;
98 |
99 | value = proc_anchor.svc_addr (SIX, proc_anchor.reserved, ptr);
100 | return(value);
101 | }
102 |
103 |
104 | int dfspop(_anchor proc_anchor, void **ptr, long *size, char **type)
105 | {
106 | int value;
107 |
108 | value = proc_anchor.svc_addr (SEVEN, proc_anchor.reserved, ptr, size, type);
109 | return(value);
110 | }
111 |
112 | int dfsclos(_anchor proc_anchor, port_ent *peptr,
113 | int elem_no)
114 | {
115 | int value;
116 |
117 | value = proc_anchor.svc_addr (EIGHT, proc_anchor.reserved, peptr,
118 | elem_no);
119 | return(value);
120 | }
121 |
122 | long dfsgsize(_anchor proc_anchor, void **ptr) {
123 | long size;
124 |
125 | size = proc_anchor.svc_addr (NINE, proc_anchor.reserved, ptr);
126 |
127 | return(size);
128 | }
129 |
130 | int dfselct(_anchor proc_anchor, port_ent *peptr) {
131 | int ct;
132 |
133 | ct = proc_anchor.svc_addr (TEN, proc_anchor.reserved, peptr);
134 |
135 | return(ct);
136 | }
137 |
138 | int dfssendc(_anchor proc_anchor, void **ptr, char * port)
139 | {
140 | int value;
141 |
142 | value = proc_anchor.svc_addr (ELEVEN, proc_anchor.reserved, ptr, port)
143 | ;
144 | return(value);
145 | }
146 |
147 |
148 | int dfsrecvc(_anchor proc_anchor, void **ptr, char * port, long *size, char **type)
149 | {
150 | int value;
151 |
152 | value = proc_anchor.svc_addr (TWELVE, proc_anchor.reserved, ptr, port, size, type);
153 | return(value);
154 | }
155 |
156 | int dfsclosc(_anchor proc_anchor, char * port)
157 | {
158 | int value;
159 |
160 | value = proc_anchor.svc_addr (THIRTEEN, proc_anchor.reserved, port);
161 | return(value);
162 | }
163 | int dfselctc(_anchor proc_anchor, char * port) {
164 | int ct;
165 |
166 | ct = proc_anchor.svc_addr (FOURTEEN, proc_anchor.reserved, port);
167 |
168 | return(ct);
169 | }
170 |
--------------------------------------------------------------------------------
/TestNetworks/TryStatSubNet/Helper Code/dfs.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include
3 | #include
4 | #include
5 |
6 | #include "thxanch.h"
7 |
8 |
9 | int const ZERO = 0; // for testing
10 | int const ONE = 1; //send
11 | int const TWO = 2; //recv
12 | int const THREE = 3; //crep
13 | int const FOUR = 4; //drop
14 | int const FIVE = 5; //dfpt
15 | int const SIX = 6; //push
16 | int const SEVEN = 7; //pop
17 | int const EIGHT = 8; //close
18 | int const NINE = 9; //gsize
19 | int const TEN = 10; //elct
20 |
21 | int const ELEVEN = 11; //sendc
22 | int const TWELVE = 12; //recvc
23 | int const THIRTEEN = 13; //closc
24 | int const FOURTEEN = 14; //elctc
25 |
26 |
27 |
28 | int dfstest(_anchor proc_anchor)
29 | {
30 | int value;
31 |
32 | value = proc_anchor.svc_addr (ZERO, proc_anchor.reserved);
33 | return(value);
34 | }
35 |
36 | int dfssend(_anchor proc_anchor, void **ptr, port_ent *peptr,
37 | int elem_no)
38 | {
39 | int value;
40 |
41 | value = proc_anchor.svc_addr (ONE, proc_anchor.reserved, ptr, peptr,
42 | elem_no)
43 | ;
44 | return(value);
45 | }
46 |
47 |
48 | int dfsrecv(_anchor proc_anchor, void **ptr, port_ent *peptr,
49 | int elem_no, long *size, char **type)
50 | {
51 | int value;
52 |
53 | value = proc_anchor.svc_addr (TWO, proc_anchor.reserved, ptr, peptr,
54 | elem_no, size, type);
55 | return(value);
56 | }
57 |
58 | int dfscrep(_anchor proc_anchor, void **ptr, long size, char *type)
59 | {
60 | int value;
61 |
62 | value = proc_anchor.svc_addr (THREE, proc_anchor.reserved, ptr, size,
63 | type);
64 | return(value);
65 | }
66 |
67 | int dfsdrop(_anchor proc_anchor, void **ptr)
68 | {
69 | int value;
70 |
71 | value = proc_anchor.svc_addr (FOUR, proc_anchor.reserved, ptr);
72 | return(value);
73 | }
74 |
75 | int dfsdfpt(_anchor proc_anchor, int port_count, port_ent *peptr, ...)
76 | {
77 | va_list ap;
78 | int i;
79 | int value;
80 |
81 | va_start (ap, peptr);
82 | for (i = 0; i < port_count; i++) {
83 | strcpy_s((peptr+i) -> port_name, va_arg(ap, char *));
84 | //(peptr+i) -> reserved = 0;
85 | (peptr+i) -> elem_count = 0;
86 | (peptr+i) -> ret_code = 0;
87 |
88 | }
89 | va_end (ap);
90 | value = proc_anchor.svc_addr (FIVE, proc_anchor.reserved, port_count,
91 | peptr);
92 | return(value);
93 | }
94 |
95 | int dfspush(_anchor proc_anchor, void **ptr )
96 | {
97 | int value;
98 |
99 | value = proc_anchor.svc_addr (SIX, proc_anchor.reserved, ptr);
100 | return(value);
101 | }
102 |
103 |
104 | int dfspop(_anchor proc_anchor, void **ptr, long *size, char **type)
105 | {
106 | int value;
107 |
108 | value = proc_anchor.svc_addr (SEVEN, proc_anchor.reserved, ptr, size, type);
109 | return(value);
110 | }
111 |
112 | int dfsclos(_anchor proc_anchor, port_ent *peptr,
113 | int elem_no)
114 | {
115 | int value;
116 |
117 | value = proc_anchor.svc_addr (EIGHT, proc_anchor.reserved, peptr,
118 | elem_no);
119 | return(value);
120 | }
121 |
122 | long dfsgsize(_anchor proc_anchor, void **ptr) {
123 | long size;
124 |
125 | size = proc_anchor.svc_addr (NINE, proc_anchor.reserved, ptr);
126 |
127 | return(size);
128 | }
129 |
130 | int dfselct(_anchor proc_anchor, port_ent *peptr) {
131 | int ct;
132 |
133 | ct = proc_anchor.svc_addr (TEN, proc_anchor.reserved, peptr);
134 |
135 | return(ct);
136 | }
137 |
138 | int dfssendc(_anchor proc_anchor, void **ptr, char * port)
139 | {
140 | int value;
141 |
142 | value = proc_anchor.svc_addr (ELEVEN, proc_anchor.reserved, ptr, port)
143 | ;
144 | return(value);
145 | }
146 |
147 |
148 | int dfsrecvc(_anchor proc_anchor, void **ptr, char * port, long *size, char **type)
149 | {
150 | int value;
151 |
152 | value = proc_anchor.svc_addr (TWELVE, proc_anchor.reserved, ptr, port, size, type);
153 | return(value);
154 | }
155 |
156 | int dfsclosc(_anchor proc_anchor, char * port)
157 | {
158 | int value;
159 |
160 | value = proc_anchor.svc_addr (THIRTEEN, proc_anchor.reserved, port);
161 | return(value);
162 | }
163 | int dfselctc(_anchor proc_anchor, char * port) {
164 | int ct;
165 |
166 | ct = proc_anchor.svc_addr (FOURTEEN, proc_anchor.reserved, port);
167 |
168 | return(ct);
169 | }
170 |
--------------------------------------------------------------------------------
/Thxgen/Resource Files/GithubSynchronization.fbp:
--------------------------------------------------------------------------------
1 | # @runtime noflo-browser
2 | # @icon github-alt
3 |
4 | INPORT=Token.IN:TOKEN
5 | INPORT=RepoToPrepare.IN:PREPARE
6 | INPORT=DoSync.IN:SYNC
7 | INPORT=PullRepo.IN:PULL
8 | OUTPORT=MergeOps.OUT:OPERATION
9 | OUTPORT=UpdatedComponent.OUT:COMPONENT
10 | OUTPORT=UpdatedGraph.OUT:GRAPH
11 | OUTPORT=UpdatedSpec.OUT:SPEC
12 | OUTPORT=BlobToEntry.PROJECT:PROJECT
13 | OUTPORT=Loading.OUT:LOADING
14 | OUTPORT=Ready.OUT:READY
15 | OUTPORT=Errors.OUT:ERROR
16 |
17 | # Preparation for sync: check local and remote situation
18 | 'repo' -> STRING SendRepoKey(strings/SendString) OUT -> KEY GetRepoToPrepare(objects/GetObjectKey)
19 | RepoToPrepare(core/Split) OUT -> IN GetRepoToPrepare
20 | RepoToPrepare OUT -> IN SendRepoKey
21 | Token(core/Repeat) OUT -> TOKEN GetReference(github/GetReference)
22 | GetRepoToPrepare OUT -> REPOSITORY GetReference
23 | GetReference REFERENCE -> REFERENCE CheckSyncState(ui/CheckSyncState)
24 | 'project' -> STRING SendProjectKey(strings/SendString) OUT -> KEY GetProject(objects/GetObjectKey)
25 | GetRepoToPrepare OBJECT -> IN GetProject OUT -> PROJECT CheckSyncState
26 | GetRepoToPrepare OBJECT -> IN SendProjectKey
27 | Token OUT -> TOKEN CheckSyncState
28 | GetReference ERROR -> IN Errors(core/Merge)
29 | CheckSyncState ERROR -> IN Errors
30 |
31 | # Different synchronization states
32 | CheckSyncState NOOP -> IN MergeOps(core/Merge)
33 | CheckSyncState LOCAL -> IN MergeOps
34 | CheckSyncState REMOTE -> IN MergeOps
35 | CheckSyncState BOTH -> IN MergeOps
36 |
37 | # Actual synchronization operation(s)
38 | # First pull changes in
39 | DoSync(core/Repeat) OUT -> IN PreparePulls(ui/PreparePulls)
40 | Token OUT -> TOKEN GetBlob(github/GetBlob)
41 | PreparePulls OUT -> OPERATION BlobToEntry(ui/BlobToEntry)
42 | PreparePulls REPOSITORY -> REPOSITORY GetBlob
43 | PreparePulls SHA -> SHA GetBlob
44 | GetBlob OUT -> IN[0] CompletePulls(flow/Race) OUT -> BLOB BlobToEntry
45 | GetBlob ERROR -> ERROR CompletePulls ERROR -> IN Errors
46 | BlobToEntry COMPONENT -> IN UpdatedComponent(core/Merge)
47 | BlobToEntry GRAPH -> IN UpdatedGraph(core/Merge)
48 | BlobToEntry SPEC -> IN UpdatedSpec(core/Merge)
49 | BlobToEntry PROJECT -> IN Ready(core/Repeat)
50 | BlobToEntry ERROR -> IN Errors
51 |
52 | # Then push local changes
53 | DoSync OUT -> IN PreparePush(ui/PreparePush)
54 | PreparePush OUT -> IN UpdateFromTree(ui/UpdateFromTree)
55 | PreparePush BASETREE -> BASE CreateTree(github/CreateTree)
56 | Token OUT -> TOKEN CreateTree
57 | PreparePush TREE -> TREE CreateTree
58 | PreparePush REPOSITORY -> REPOSITORY CreateTree
59 | CreateTree OUT -> TREE UpdateFromTree
60 | PreparePush REPOSITORY -> REPOSITORY UpdateFromTree
61 | Token OUT -> TOKEN UpdateFromTree
62 | 'sha' -> STRING SendTreeSha(strings/SendString) OUT -> KEY GetTreeSha(objects/GetObjectKey)
63 | CreateTree OUT -> IN GetTreeSha
64 | CreateTree OUT -> IN SendTreeSha
65 | GetTreeSha OUT -> TREE CreateCommit(github/CreateCommit)
66 | Token OUT -> TOKEN CreateCommit
67 | PreparePush MESSAGE -> MESSAGE CreateCommit
68 | PreparePush PARENTCOMMITS -> PARENTS CreateCommit
69 | PreparePush REPOSITORY -> REPOSITORY CreateCommit
70 |
71 | CreateCommit OUT -> COMMIT UpdateReference(github/UpdateReference)
72 | PreparePush REF -> REFERENCE UpdateReference
73 | Token OUT -> TOKEN UpdateReference
74 | PreparePush REPOSITORY -> REPOSITORY UpdateReference
75 |
76 | UpdateFromTree COMPONENT -> IN UpdatedComponent
77 | UpdateFromTree GRAPH -> IN UpdatedGraph
78 | UpdateFromTree SPEC -> IN UpdatedSpec
79 |
80 | UpdateFromTree ERROR -> IN Errors
81 | CreateTree ERROR -> IN Errors
82 | CreateCommit ERROR -> IN Errors
83 | UpdateReference ERROR -> IN Errors
84 |
85 | # Pull-only sync, no decision needed
86 | 'repo' -> STRING SendPullRepo(strings/SendString) OUT -> KEY GetPullRepo(objects/GetObjectKey)
87 | PullRepo(core/Split) OUT -> IN Loading(core/Repeat)
88 | PullRepo OUT -> IN GetPullRepo
89 | PullRepo OUT -> IN SendPullRepo
90 | Token(core/Repeat) OUT -> TOKEN GetPullReference(github/GetReference)
91 | GetPullRepo OUT -> REPOSITORY GetPullReference
92 | GetPullReference REFERENCE -> REFERENCE CheckPullState(ui/CheckSyncState)
93 | 'project' -> STRING SendPullProject(strings/SendString) OUT -> KEY GetPullProject(objects/GetObjectKey)
94 | GetPullRepo OBJECT -> IN GetPullProject OUT -> PROJECT CheckPullState
95 | GetPullRepo OBJECT -> IN SendPullProject
96 | Token OUT -> TOKEN CheckPullState
97 | GetPullReference ERROR -> IN Errors
98 | CheckPullState REMOTE -> IN DoSync
99 | CheckPullState ERROR -> IN Errors
100 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lcorolib.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lcorolib.c,v 1.9 2014/11/02 19:19:04 roberto Exp $
3 | ** Coroutine Library
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lcorolib_c
8 | #define LUA_LIB
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "lauxlib.h"
18 | #include "lualib.h"
19 |
20 |
21 | static lua_State *getco (lua_State *L) {
22 | lua_State *co = lua_tothread(L, 1);
23 | luaL_argcheck(L, co, 1, "thread expected");
24 | return co;
25 | }
26 |
27 |
28 | static int auxresume (lua_State *L, lua_State *co, int narg) {
29 | int status;
30 | if (!lua_checkstack(co, narg)) {
31 | lua_pushliteral(L, "too many arguments to resume");
32 | return -1; /* error flag */
33 | }
34 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) {
35 | lua_pushliteral(L, "cannot resume dead coroutine");
36 | return -1; /* error flag */
37 | }
38 | lua_xmove(L, co, narg);
39 | status = lua_resume(co, L, narg);
40 | if (status == LUA_OK || status == LUA_YIELD) {
41 | int nres = lua_gettop(co);
42 | if (!lua_checkstack(L, nres + 1)) {
43 | lua_pop(co, nres); /* remove results anyway */
44 | lua_pushliteral(L, "too many results to resume");
45 | return -1; /* error flag */
46 | }
47 | lua_xmove(co, L, nres); /* move yielded values */
48 | return nres;
49 | }
50 | else {
51 | lua_xmove(co, L, 1); /* move error message */
52 | return -1; /* error flag */
53 | }
54 | }
55 |
56 |
57 | static int luaB_coresume (lua_State *L) {
58 | lua_State *co = getco(L);
59 | int r;
60 | r = auxresume(L, co, lua_gettop(L) - 1);
61 | if (r < 0) {
62 | lua_pushboolean(L, 0);
63 | lua_insert(L, -2);
64 | return 2; /* return false + error message */
65 | }
66 | else {
67 | lua_pushboolean(L, 1);
68 | lua_insert(L, -(r + 1));
69 | return r + 1; /* return true + 'resume' returns */
70 | }
71 | }
72 |
73 |
74 | static int luaB_auxwrap (lua_State *L) {
75 | lua_State *co = lua_tothread(L, lua_upvalueindex(1));
76 | int r = auxresume(L, co, lua_gettop(L));
77 | if (r < 0) {
78 | if (lua_isstring(L, -1)) { /* error object is a string? */
79 | luaL_where(L, 1); /* add extra info */
80 | lua_insert(L, -2);
81 | lua_concat(L, 2);
82 | }
83 | return lua_error(L); /* propagate error */
84 | }
85 | return r;
86 | }
87 |
88 |
89 | static int luaB_cocreate (lua_State *L) {
90 | lua_State *NL;
91 | luaL_checktype(L, 1, LUA_TFUNCTION);
92 | NL = lua_newthread(L);
93 | lua_pushvalue(L, 1); /* move function to top */
94 | lua_xmove(L, NL, 1); /* move function from L to NL */
95 | return 1;
96 | }
97 |
98 |
99 | static int luaB_cowrap (lua_State *L) {
100 | luaB_cocreate(L);
101 | lua_pushcclosure(L, luaB_auxwrap, 1);
102 | return 1;
103 | }
104 |
105 |
106 | static int luaB_yield (lua_State *L) {
107 | return lua_yield(L, lua_gettop(L));
108 | }
109 |
110 |
111 | static int luaB_costatus (lua_State *L) {
112 | lua_State *co = getco(L);
113 | if (L == co) lua_pushliteral(L, "running");
114 | else {
115 | switch (lua_status(co)) {
116 | case LUA_YIELD:
117 | lua_pushliteral(L, "suspended");
118 | break;
119 | case LUA_OK: {
120 | lua_Debug ar;
121 | if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
122 | lua_pushliteral(L, "normal"); /* it is running */
123 | else if (lua_gettop(co) == 0)
124 | lua_pushliteral(L, "dead");
125 | else
126 | lua_pushliteral(L, "suspended"); /* initial state */
127 | break;
128 | }
129 | default: /* some error occurred */
130 | lua_pushliteral(L, "dead");
131 | break;
132 | }
133 | }
134 | return 1;
135 | }
136 |
137 |
138 | static int luaB_yieldable (lua_State *L) {
139 | lua_pushboolean(L, lua_isyieldable(L));
140 | return 1;
141 | }
142 |
143 |
144 | static int luaB_corunning (lua_State *L) {
145 | int ismain = lua_pushthread(L);
146 | lua_pushboolean(L, ismain);
147 | return 2;
148 | }
149 |
150 |
151 | static const luaL_Reg co_funcs[] = {
152 | {"create", luaB_cocreate},
153 | {"resume", luaB_coresume},
154 | {"running", luaB_corunning},
155 | {"status", luaB_costatus},
156 | {"wrap", luaB_cowrap},
157 | {"yield", luaB_yield},
158 | {"isyieldable", luaB_yieldable},
159 | {NULL, NULL}
160 | };
161 |
162 |
163 |
164 | LUAMOD_API int luaopen_coroutine (lua_State *L) {
165 | luaL_newlib(L, co_funcs);
166 | return 1;
167 | }
168 |
169 |
--------------------------------------------------------------------------------
/CppFBPLua/src/ltm.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.c,v 2.36 2015/11/03 15:47:30 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define ltm_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "ldebug.h"
18 | #include "ldo.h"
19 | #include "lobject.h"
20 | #include "lstate.h"
21 | #include "lstring.h"
22 | #include "ltable.h"
23 | #include "ltm.h"
24 | #include "lvm.h"
25 |
26 |
27 | static const char udatatypename[] = "userdata";
28 |
29 | LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = {
30 | "no value",
31 | "nil", "boolean", udatatypename, "number",
32 | "string", "table", "function", udatatypename, "thread",
33 | "proto" /* this last case is used for tests only */
34 | };
35 |
36 |
37 | void luaT_init (lua_State *L) {
38 | static const char *const luaT_eventname[] = { /* ORDER TM */
39 | "__index", "__newindex",
40 | "__gc", "__mode", "__len", "__eq",
41 | "__add", "__sub", "__mul", "__mod", "__pow",
42 | "__div", "__idiv",
43 | "__band", "__bor", "__bxor", "__shl", "__shr",
44 | "__unm", "__bnot", "__lt", "__le",
45 | "__concat", "__call"
46 | };
47 | int i;
48 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]);
50 | luaC_fix(L, obj2gco(G(L)->tmname[i])); /* never collect these names */
51 | }
52 | }
53 |
54 |
55 | /*
56 | ** function to be used with macro "fasttm": optimized for absence of
57 | ** tag methods
58 | */
59 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
60 | const TValue *tm = luaH_getshortstr(events, ename);
61 | lua_assert(event <= TM_EQ);
62 | if (ttisnil(tm)) { /* no tag method? */
63 | events->flags |= cast_byte(1u<metatable;
75 | break;
76 | case LUA_TUSERDATA:
77 | mt = uvalue(o)->metatable;
78 | break;
79 | default:
80 | mt = G(L)->mt[ttnov(o)];
81 | }
82 | return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : luaO_nilobject);
83 | }
84 |
85 |
86 | void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
87 | const TValue *p2, TValue *p3, int hasres) {
88 | ptrdiff_t result = savestack(L, p3);
89 | StkId func = L->top;
90 | setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */
91 | setobj2s(L, func + 1, p1); /* 1st argument */
92 | setobj2s(L, func + 2, p2); /* 2nd argument */
93 | L->top += 3;
94 | if (!hasres) /* no result? 'p3' is third argument */
95 | setobj2s(L, L->top++, p3); /* 3rd argument */
96 | /* metamethod may yield only when called from Lua code */
97 | if (isLua(L->ci))
98 | luaD_call(L, func, hasres);
99 | else
100 | luaD_callnoyield(L, func, hasres);
101 | if (hasres) { /* if has result, move it to its place */
102 | p3 = restorestack(L, result);
103 | setobjs2s(L, p3, --L->top);
104 | }
105 | }
106 |
107 |
108 | int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
109 | StkId res, TMS event) {
110 | const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
111 | if (ttisnil(tm))
112 | tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
113 | if (ttisnil(tm)) return 0;
114 | luaT_callTM(L, tm, p1, p2, res, 1);
115 | return 1;
116 | }
117 |
118 |
119 | void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
120 | StkId res, TMS event) {
121 | if (!luaT_callbinTM(L, p1, p2, res, event)) {
122 | switch (event) {
123 | case TM_CONCAT:
124 | luaG_concaterror(L, p1, p2);
125 | /* call never returns, but to avoid warnings: *//* FALLTHROUGH */
126 | case TM_BAND: case TM_BOR: case TM_BXOR:
127 | case TM_SHL: case TM_SHR: case TM_BNOT: {
128 | lua_Number dummy;
129 | if (tonumber(p1, &dummy) && tonumber(p2, &dummy))
130 | luaG_tointerror(L, p1, p2);
131 | else
132 | luaG_opinterror(L, p1, p2, "perform bitwise operation on");
133 | }
134 | /* calls never return, but to avoid warnings: *//* FALLTHROUGH */
135 | default:
136 | luaG_opinterror(L, p1, p2, "perform arithmetic on");
137 | }
138 | }
139 | }
140 |
141 |
142 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
143 | TMS event) {
144 | if (!luaT_callbinTM(L, p1, p2, L->top, event))
145 | return -1; /* no metamethod */
146 | else
147 | return !l_isfalse(L->top);
148 | }
149 |
150 |
--------------------------------------------------------------------------------
/CppFBPLua/src/lgc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lgc.h,v 2.90 2015/10/21 18:15:15 roberto Exp $
3 | ** Garbage Collector
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lgc_h
8 | #define lgc_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 |
14 | /*
15 | ** Collectable objects may have one of three colors: white, which
16 | ** means the object is not marked; gray, which means the
17 | ** object is marked, but its references may be not marked; and
18 | ** black, which means that the object and all its references are marked.
19 | ** The main invariant of the garbage collector, while marking objects,
20 | ** is that a black object can never point to a white one. Moreover,
21 | ** any gray object must be in a "gray list" (gray, grayagain, weak,
22 | ** allweak, ephemeron) so that it can be visited again before finishing
23 | ** the collection cycle. These lists have no meaning when the invariant
24 | ** is not being enforced (e.g., sweep phase).
25 | */
26 |
27 |
28 |
29 | /* how much to allocate before next GC step */
30 | #if !defined(GCSTEPSIZE)
31 | /* ~100 small strings */
32 | #define GCSTEPSIZE (cast_int(100 * sizeof(TString)))
33 | #endif
34 |
35 |
36 | /*
37 | ** Possible states of the Garbage Collector
38 | */
39 | #define GCSpropagate 0
40 | #define GCSatomic 1
41 | #define GCSswpallgc 2
42 | #define GCSswpfinobj 3
43 | #define GCSswptobefnz 4
44 | #define GCSswpend 5
45 | #define GCScallfin 6
46 | #define GCSpause 7
47 |
48 |
49 | #define issweepphase(g) \
50 | (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)
51 |
52 |
53 | /*
54 | ** macro to tell when main invariant (white objects cannot point to black
55 | ** ones) must be kept. During a collection, the sweep
56 | ** phase may break the invariant, as objects turned white may point to
57 | ** still-black objects. The invariant is restored when sweep ends and
58 | ** all objects are white again.
59 | */
60 |
61 | #define keepinvariant(g) ((g)->gcstate <= GCSatomic)
62 |
63 |
64 | /*
65 | ** some useful bit tricks
66 | */
67 | #define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
68 | #define setbits(x,m) ((x) |= (m))
69 | #define testbits(x,m) ((x) & (m))
70 | #define bitmask(b) (1<<(b))
71 | #define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
72 | #define l_setbit(x,b) setbits(x, bitmask(b))
73 | #define resetbit(x,b) resetbits(x, bitmask(b))
74 | #define testbit(x,b) testbits(x, bitmask(b))
75 |
76 |
77 | /* Layout for bit use in 'marked' field: */
78 | #define WHITE0BIT 0 /* object is white (type 0) */
79 | #define WHITE1BIT 1 /* object is white (type 1) */
80 | #define BLACKBIT 2 /* object is black */
81 | #define FINALIZEDBIT 3 /* object has been marked for finalization */
82 | /* bit 7 is currently used by tests (luaL_checkmemory) */
83 |
84 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
85 |
86 |
87 | #define iswhite(x) testbits((x)->marked, WHITEBITS)
88 | #define isblack(x) testbit((x)->marked, BLACKBIT)
89 | #define isgray(x) /* neither white nor black */ \
90 | (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT)))
91 |
92 | #define tofinalize(x) testbit((x)->marked, FINALIZEDBIT)
93 |
94 | #define otherwhite(g) ((g)->currentwhite ^ WHITEBITS)
95 | #define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow)))
96 | #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked)
97 |
98 | #define changewhite(x) ((x)->marked ^= WHITEBITS)
99 | #define gray2black(x) l_setbit((x)->marked, BLACKBIT)
100 |
101 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
102 |
103 |
104 | /*
105 | ** Does one step of collection when debt becomes positive. 'pre'/'pos'
106 | ** allows some adjustments to be done only when needed. macro
107 | ** 'condchangemem' is used only for heavy tests (forcing a full
108 | ** GC cycle on every opportunity)
109 | */
110 | #define luaC_condGC(L,pre,pos) \
111 | { if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \
112 | condchangemem(L,pre,pos); }
113 |
114 | /* more often than not, 'pre'/'pos' are empty */
115 | #define luaC_checkGC(L) luaC_condGC(L,,)
116 |
117 |
118 | #define luaC_barrier(L,p,v) ( \
119 | (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
120 | luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0))
121 |
122 | #define luaC_barrierback(L,p,v) ( \
123 | (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
124 | luaC_barrierback_(L,p) : cast_void(0))
125 |
126 | #define luaC_objbarrier(L,p,o) ( \
127 | (isblack(p) && iswhite(o)) ? \
128 | luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
129 |
130 | #define luaC_upvalbarrier(L,uv) ( \
131 | (iscollectable((uv)->v) && !upisopen(uv)) ? \
132 | luaC_upvalbarrier_(L,uv) : cast_void(0))
133 |
134 | LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
135 | LUAI_FUNC void luaC_freeallobjects (lua_State *L);
136 | LUAI_FUNC void luaC_step (lua_State *L);
137 | LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask);
138 | LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency);
139 | LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz);
140 | LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v);
141 | LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o);
142 | LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv);
143 | LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt);
144 | LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv);
145 |
146 |
147 | #endif
148 |
--------------------------------------------------------------------------------