Changeset 1324 for js


Ignore:
Timestamp:
08/14/24 00:56:06 (4 months ago)
Author:
Maciej Komosinski
Message:

Updated for current SDK sources and current Emscripten

Location:
js/sdk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • js/sdk/Makefile-SDK-Emscripten.mak

    r865 r1324  
    11#
    22# Framsticks SDK makefile for Emscripten builds
     3#
     4# Before 2020, this makefile could be used natively under Windows as well (see history if needed).
     5# However, now that the Windows Subsystem for Linux (WSL) exists, this file only supports Linux.
    36#
    47
    58include frams/Makefile-SDK-files
    69
     10# set this path based on the project directory structure
    711JS_PATH=../js/sdk
    8 
    9 #Note: CURDIR needed because on linux, Emscripten does not differentiate between relative and absolute path, which causes shutil to raise Error("%s and %s are the same file" % (src, dst))
    10 ifeq ($(OS),Windows_NT)
    11         CACHE_DIR=cache-tmp
    12 else
    13         CACHE_DIR=$(CURDIR)/cache-tmp
    14 endif
    1512
    1613SDK_JS=$(JS_PATH)/frams-sdk.js
     
    2522
    2623# same as in cpp/frams/Makefile-SDK:
    27 CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -Werror=return-type
     24CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -Wno-invalid-offsetof -Werror=return-type
    2825
    29 SDK_BUILD_CONFIG= -include frams/config/sdk_build_config.h
    30 CACHE_DESTINATION= --cache $(CACHE_DIR)
    31 CXXFLAGS= -I$(CURDIR) -std=gnu++11 -O3 $(SDK_BUILD_CONFIG) $(CXXWARNINGS) $(CACHE_DESTINATION)
     26SDK_BUILD_CONFIG= -include frams/config/sdk-build-config.h
     27CXXFLAGS= -I$(CURDIR) -std=gnu++17 -O3 $(SDK_BUILD_CONFIG) $(CXXWARNINGS)
     28
     29# avoid "duplicate symbol" linking errors. Instead of this pipeline, could use the "uniq" function built in included gmsl, or define a recursive function to filter out duplicates while preserving the order of elements. Also consider "$^".
     30SDK_LIB_OBJS := $(shell echo $(SDK_LIB_OBJS) | tr ' ' '\n' | sort | uniq | tr '\n' ' ')
    3231
    3332#############################################
    3433
    35 $(SDK_JS): $(I_IMPL_JS) $(I_IMPL_SRC) $(I_OBJ) $(SDK_BIN)
    36         $(CXX) $(SDK_BIN) $(I_OBJ) --post-js $(I_IMPL_JS) -g4 --memory-init-file 0 -s FORCE_FILESYSTEM=1 -s ALIASING_FUNCTION_POINTERS=0 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=3 -s BINARYEN_ASYNC_COMPILATION=0 -s WASM=0 $(CACHE_DESTINATION) -o $@
    37 
    38 $(SDK_BIN): $(SDK_LIB_OBJS)
    39         $(CXX) $(SDK_LIB_OBJS) $(LDFLAGS) $(CACHE_DESTINATION) -o $@
     34$(SDK_JS): $(I_IMPL_JS) $(I_IMPL_SRC) $(I_OBJ) $(SDK_LIB_OBJS)
     35        $(CXX) $(SDK_LIB_OBJS) $(I_OBJ) --post-js $(I_IMPL_JS) -O3 -s FORCE_FILESYSTEM=1 -s ALIASING_FUNCTION_POINTERS=0 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=3 -s BINARYEN_ASYNC_COMPILATION=0 -sWASM=0  -o $@
    4036
    4137$(I_IMPL_SRC) $(I_IMPL_JS): $(I_IDL)
    42         python $(EMSCRIPTEN)/tools/webidl_binder.py $(I_IDL) $(I_PATH)/js_interface_impl
     38        python3 $(EMSCRIPTEN)/tools/webidl_binder.py $(I_IDL) $(I_PATH)/js_interface_impl
    4339
    4440#############################################
    4541
     42include common/Makefile-maintain
    4643
    47 full_clean:
    48 ifeq ($(OS),Windows_NT)
    49         del /s /q WebIDLGrammar.pkl parser.out *.o
    50         rmdir /s /q $(CACHE_DIR)
    51 else
    52         rm -f WebIDLGrammar.pkl parser.out $(SDK_LIB_OBJS)
    53         rm -rf $(CACHE_DIR)
    54 endif
     44full_clean: clean
     45        rm -f WebIDLGrammar.pkl parser.out $(I_OBJ) $(I_IMPL_SRC) $(I_IMPL_JS) $(SDK_BIN) $(SDK_JS)
  • js/sdk/README.txt

    r865 r1324  
    88of Emscripten installed. To perform a compilation, you first need to activate the Emscripten SDK:
    99
    10 On Windows:
     10On Windows (deprecated):
    1111        emsdk.bat activate latest
    1212
     
    1818After activating the Emscripten SDK, to compile Framsticks SDK you need to call:
    1919
    20 On Windows:
     20On Windows (deprecated):
    2121        emmake.bat mingw32-make.exe -j8 --directory=../../cpp -f ../js/sdk/Makefile-SDK-Emscripten.mak
    2222
  • js/sdk/js_interface/js_interface.cpp

    r944 r1324  
    1515#include <frams/genetics/f9/f9_oper.h>
    1616#include <frams/genetics/fF/fF_oper.h>
     17#include <frams/genetics/fS/fS_oper.h>
     18#include <frams/genetics/fn/fn_oper.h>
     19#include <frams/genetics/genoconv.h>
     20#include <frams/genetics/f4/f4_conv.h>
     21#include <frams/genetics/fH/fH_conv.h>
     22#include <frams/genetics/fB/fB_conv.h>
     23#include <frams/genetics/f9/f9_conv.h>
     24#include <frams/genetics/fS/fS_conv.h>
     25#include <frams/genetics/fn/fn_conv.h>
     26#include <frams/genetics/fL/fL_conv.h>
    1727#include <common/loggers/loggers.h>
    1828#include <common/loggers/loggertostdout.h>
  • js/sdk/js_interface/js_interface.idl

    r944 r1324  
    9191
    9292enum Part_Shape {
    93         "Part::SHAPE_BALL_AND_STICK",
     93        "Part::SHAPE_BALL",
    9494        "Part::SHAPE_ELLIPSOID",
    9595        "Part::SHAPE_CUBOID",
     
    111111        [Value] attribute Pt3D scale;
    112112        [Value] attribute Pt3D vcolor;
    113         attribute double vsize;
    114113        attribute long shape;
    115 
    116         void Part(optional Part_Shape s = "Part::SHAPE_BALL_AND_STICK");
     114        static readonly attribute double BALL_AND_STICK_RADIUS;
     115
     116        void Part(optional Part_Shape s = "Part::SHAPE_BALL");
    117117
    118118        void setPositionAndRotationFromAxis([Const, Ref] Pt3D p1, [Const, Ref] Pt3D p2);
     
    126126
    127127enum Joint_Shape {
    128         "Joint::SHAPE_BALL_AND_STICK",
    129         "Joint::SHAPE_FIXED"
     128        "Joint::SHAPE_STICK",
     129        "Joint::SHAPE_FIXED",
     130        "Joint::SHAPE_HINGE_X",
     131        "Joint::SHAPE_HINGE_XY"
    130132};
    131133
     
    247249        void Geno([Const] DOMString genstring, byte genformat, [Const] DOMString genname, [Const] DOMString comment);
    248250        boolean isValid();
    249         byte getFormat();
     251        [Value] SString getFormat();
    250252        [Value] SString getGenes();
     253        [Value] SString getGenesAndFormat();
    251254        static Validators useValidators(Validators val);
    252255        static GenoConvManager useConverters(GenoConvManager gcm);
     
    261264
    262265enum Model_ShapeType {
    263         "Model::SHAPE_UNKNOWN",
    264         "Model::SHAPE_ILLEGAL",
    265         "Model::SHAPE_BALL_AND_STICK",
    266         "Model::SHAPE_SOLIDS"
     266        "Model::SHAPETYPE_UNKNOWN",
     267        "Model::SHAPETYPE_ILLEGAL",
     268        "Model::SHAPETYPE_BALL_AND_STICK",
     269        "Model::SHAPETYPE_SOLIDS"
    267270};
    268271
     
    272275        attribute double startenergy;
    273276
    274         void Model();
    275         void Model([Ref, Const] Geno newgeno, optional boolean buildmaps = false);
     277        void Model(optional Model_ShapeType sh = "Model::SHAPETYPE_UNKNOWN");
     278
     279        void Model([Ref, Const] Geno src, Model_ShapeType sh, optional boolean buildmaps = false, optional boolean _using_checkpoints = false, optional boolean _is_checkpoint = false);
     280        // The following constructor exists in the SDK, however in idl functions need to differ in number of arguments so it can't exist with the previous constructor
     281        //void Model([Ref, Const] Model model, optional boolean buildmaps = false, optional boolean _using_checkpoints = false, optional boolean _is_checkpoint = false);
    276282
    277283        [Value] MultiMap getMap();
     
    283289        long getErrorPosition(boolean includingwarnings);
    284290        Model_ShapeType getShapeType();
     291        void declareShapeType(Model_ShapeType sh);
    285292        void updateRefno();
    286293        [Const, Value] Geno getF0Geno();
    287         void makeGeno([Ref] Geno geno);
     294        void makeGeno([Ref] Geno geno, optional MultiMap sh,optional boolean handle_defaults,optional boolean can_be_invalid);
    288295        void setGeno([Const, Ref] Geno newgeno);
    289296        void setValidationLevel(long level);
     
    348355
    349356interface GenotypeMiniLoader : MultiParamLoader {
    350     void GenotypeMiniLoader(VirtFILE f);
     357        //this constructor has the same number of arguments as the next one which is not allowed in idl
     358    //void GenotypeMiniLoader(VirtFILE f);
     359        void GenotypeMiniLoader([Const] DOMString filename);
    351360        GenotypeMini loadNextGenotype();
    352361};
     
    442451};
    443452
     453interface GenoConverter {
     454        [Const] attribute DOMString name;
     455        [Value] attribute SString in_format;
     456        [Value] attribute SString out_format;
     457};
     458
     459interface GenoConv_f40 : GenoConverter{
     460        void GenoConv_f40();
     461};
     462
     463interface GenoConv_f90 : GenoConverter{
     464        void GenoConv_f90();
     465};
     466
     467interface GenoConv_fL0 : GenoConverter{
     468        void GenoConv_fL0();
     469};
     470
     471interface GenoConv_fBH : GenoConverter{
     472        void GenoConv_fBH();
     473};
     474
     475
     476interface GenoConv_fS0s : GenoConverter{
     477        void GenoConv_fS0s();
     478};
     479
     480interface GenoConv_fH0 : GenoConverter{
     481        void GenoConv_fH0();
     482};
     483
     484interface GenoConvHelper{
     485        void GenoConvHelper(GenoConverter genoConv);
     486        [Const] DOMString getName();
     487};
     488
    444489interface GenoOperators {
    445490        void GenoOperators();
     
    447492        long checkValidity([Const] DOMString geno, [Const] DOMString genoname);
    448493        long validate(DOMString geno, [Const] DOMString genoname);
    449         [Value] SString getSimplest();
     494        [Const] DOMString getSimplest();
    450495};
    451496
     
    473518        void GenoOper_fF();
    474519};
     520
     521interface GenoOper_fS : GenoOperators {
     522        void GenoOper_fS();
     523};
     524
    475525
    476526interface GenoOperatorsHelper {
     
    481531        [Value] SString getLastCrossGeno1();
    482532        [Value] SString getLastCrossGeno2();
     533        [Const] DOMString getSimplest();
    483534};
    484535
     
    542593        void quickCopyFrom(ParamInterface src);
    543594
    544         //long save(VirtFILE file, [Const] DOMString altname, optional boolean force = false);
     595        //long saveMultiLine(VirtFILE file, [Const] DOMString altname, optional boolean force = false);
    545596
    546597        static boolean isValidTypeDescription([Const] DOMString t);
     
    553604interface Param : SimpleAbstractParam {
    554605        void Param(ParamEntry t, VoidPtr o);
    555         //long save(VirtFILE file, [Const] DOMString altname, optional boolean force = false);
     606        long saveMultiLine(VirtFILE file, [Const] DOMString altname, optional boolean force = false);
    556607};
    557608
  • js/sdk/js_interface/js_types.h

    r879 r1324  
    205205        }
    206206
     207        const char* getSimplest()
     208        {
     209                return genoOper->getSimplest();
     210        }
     211
    207212        ~GenoOperatorsHelper()
    208213        {
     
    214219};
    215220
     221struct GenoConvHelper
     222{
     223        GenoConverter* genoConv;
     224        GenoConvHelper(GenoConverter* _genoConv)
     225        {
     226                genoConv = _genoConv;
     227        }
     228        const char* getName()
     229        {
     230                return genoConv->name;
     231        }
     232};
     233
    216234#endif
    217235#endif //JS_TYPES_H_
Note: See TracChangeset for help on using the changeset viewer.